#include "arch.h"
+#include "vm/jit/code.h"
+#include "vm/jit/codegen-common.h"
+#include "vm/jit/methodheader.h"
#include "mm/memory.h"
#include "vm/options.h"
#include "vm/jit/code.h"
}
+/* code_find_codeinfo_for_pc ***************************************************
+
+ Return the codeinfo for the compilation unit that contains the
+ given PC.
+
+ IN:
+ pc...............machine code position
+
+ RETURN VALUE:
+ the codeinfo * for the given PC
+
+*******************************************************************************/
+
+codeinfo *code_find_codeinfo_for_pc(u1 *pc)
+{
+ u1 *pv;
+
+ pv = codegen_get_pv_from_pc(pc);
+ assert(pv);
+
+ return *(codeinfo **)(pv + CodeinfoPointer);
+}
+
+
/* code_get_sync_slot_count ****************************************************
Return the number of stack slots used for storing the synchronized object
#include "vm/jit/replace.h"
+/* constants ******************************************************************/
+
+#define CODE_FLAG_INVALID 0x0001
+#define CODE_FLAG_LEAFMETHOD 0x0002
+
+
/* codeinfo *******************************************************************
A codeinfo represents a particular realization of a method in
methodinfo *m; /* method this is a realization of */
codeinfo *prev; /* previous codeinfo of this method */
- bool invalid;
+ u4 codeflags; /* or of CODE_FLAG_ constants */
u1 optlevel; /* optimization level of this code */
s4 basicblockcount; /* number of basic blocks */
/* replacement */
rplpoint *rplpoints; /* replacement points */
rplalloc *regalloc; /* register allocation info */
+ u1 *replacementstubs; /* beginning of replacement stubs */
s4 rplpointcount; /* number of replacement points */
s4 globalcount; /* number of global allocations */
s4 regalloccount; /* number of total allocations */
s4 stackframesize; /* size of the stackframe in slots */
u1 savedintcount; /* number of callee saved int regs */
u1 savedfltcount; /* number of callee saved flt regs */
+ u1 *savedmcode; /* saved code under patches */
u4 frequency; /* number of method invocations */
u4 *bbfrequency;
};
+/* macros *********************************************************************/
+
+#define CODE_IS_VALID(code) (!((code)->codeflags & CODE_FLAG_INVALID))
+#define CODE_IS_INVALID(code) ((code)->codeflags & CODE_FLAG_INVALID)
+#define CODE_IS_LEAFMETHOD(code) ((code)->codeflags & CODE_FLAG_LEAFMETHOD)
+
+#define CODE_SETFLAG_INVALID(code) \
+ ((code)->codeflags |= CODE_FLAG_INVALID)
+#define CODE_SETFLAG_LEAFMETHOD(code) \
+ ((code)->codeflags |= CODE_FLAG_LEAFMETHOD)
+
+
/* function prototypes ********************************************************/
bool code_init(void);
codeinfo *code_codeinfo_new(methodinfo *m);
void code_codeinfo_free(codeinfo *code);
+codeinfo *code_find_codeinfo_for_pc(u1 *pc);
+
int code_get_sync_slot_count(codeinfo *code);
int code_get_stack_frame_size(codeinfo *code);
Christian Thalinger
Christian Ullrich
- $Id: jit.c 6114 2006-12-04 22:21:49Z twisti $
+ $Id: jit.c 6135 2006-12-07 20:39:57Z edwin $
*/
s4 i;
code = m->code;
- if (code == NULL || code->invalid)
+ if (code == NULL || CODE_IS_INVALID(code))
return;
- code->invalid = true;
+ CODE_SETFLAG_INVALID(code);
rp = code->rplpoints;
i = code->rplpointcount;
/* if we have valid code, return it */
- if (m->code && !m->code->invalid)
+ if (m->code && CODE_IS_VALID(m->code))
return m->code;
/* otherwise: recompile */