* src/vm/jit/code.c (code_find_codeinfo_for_pc): New function.
authoredwin <none@none>
Thu, 7 Dec 2006 20:39:57 +0000 (20:39 +0000)
committeredwin <none@none>
Thu, 7 Dec 2006 20:39:57 +0000 (20:39 +0000)
* src/vm/jit/code.h (codeinfo): Added codeinfo flags, replacementstubs,
and savedmcode.

* src/vm/jit/jit.c (jit_invalidate_code): Use codeinfo flags.
(jit_get_current_code): Likewise.

src/vm/jit/code.c
src/vm/jit/code.h
src/vm/jit/jit.c

index bc17442ec135fea2a9d558a6c5648dfd51a52546..75fb6b344f08ff6bd60db1b78280640d61c85003 100644 (file)
@@ -40,6 +40,9 @@
 
 #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"
@@ -98,6 +101,30 @@ codeinfo *code_codeinfo_new(methodinfo *m)
 }
 
 
+/* 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
index 13fc19cc069255435e0e56363b3b7a2da361576e..a8e4708441c810c41f5439e1b9bb842e1414f782 100644 (file)
@@ -47,6 +47,12 @@ typedef struct codeinfo codeinfo;
 #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
@@ -62,7 +68,7 @@ struct codeinfo {
        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             */
@@ -75,6 +81,7 @@ struct codeinfo {
        /* 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        */
@@ -82,6 +89,7 @@ struct codeinfo {
        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;                  
@@ -89,6 +97,18 @@ struct codeinfo {
 };
 
 
+/* 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);
@@ -96,6 +116,8 @@ 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);
 
index 8059a963f2080ae2ed0030fae5305eeebc9abb9b..91fa28f016d82c310c937fdca59c3d73f24d66eb 100644 (file)
@@ -31,7 +31,7 @@
             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 $
 
 */
 
@@ -1552,10 +1552,10 @@ void jit_invalidate_code(methodinfo *m)
        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;
@@ -1615,7 +1615,7 @@ codeinfo *jit_get_current_code(methodinfo *m)
 
        /* 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 */