cvsuser     02/11/12 06:47:42

  Modified:    include/parrot interpreter.h jit.h
               .        interpreter.c jit.c
               jit/alpha jit_emit.h
               jit/arm  jit_emit.h
               jit/i386 jit_emit.h
               jit/ppc  jit_emit.h
               jit/sun4 jit_emit.h
  Log:
  make JIT restartable - i386
  
  Revision  Changes    Path
  1.57      +2 -1      parrot/include/parrot/interpreter.h
  
  Index: interpreter.h
  ===================================================================
  RCS file: /cvs/public/parrot/include/parrot/interpreter.h,v
  retrieving revision 1.56
  retrieving revision 1.57
  diff -u -w -r1.56 -r1.57
  --- interpreter.h     3 Nov 2002 21:15:17 -0000       1.56
  +++ interpreter.h     12 Nov 2002 14:47:15 -0000      1.57
  @@ -1,7 +1,7 @@
   /* interpreter.h
    *  Copyright: (When this is determined...it will go here)
    *  CVS Info
  - *     $Id: interpreter.h,v 1.56 2002/11/03 21:15:17 leo Exp $
  + *     $Id: interpreter.h,v 1.57 2002/11/12 14:47:15 leo Exp $
    *  Overview:
    *     The interpreter api handles running the operations
    *  Data Structure and Algorithms:
  @@ -137,6 +137,7 @@
   
       struct PackFile *code;      /* The code we are executing */
       void **prederef_code;       /* The predereferenced code */
  +    void *jit_info;             /* JITs data */
       size_t current_line;        /* Which line we're executing in the
                                    * source */
       String *current_file;       /* The file we're currently in */
  
  
  
  1.20      +24 -23    parrot/include/parrot/jit.h
  
  Index: jit.h
  ===================================================================
  RCS file: /cvs/public/parrot/include/parrot/jit.h,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -w -r1.19 -r1.20
  --- jit.h     13 Aug 2002 18:01:06 -0000      1.19
  +++ jit.h     12 Nov 2002 14:47:15 -0000      1.20
  @@ -1,7 +1,7 @@
   /*
    * jit.h
    *
  - * $Id: jit.h,v 1.19 2002/08/13 18:01:06 grunblatt Exp $
  + * $Id: jit.h,v 1.20 2002/11/12 14:47:15 leo Exp $
    */
   
   #ifndef JIT_H_GUARD
  @@ -11,6 +11,7 @@
   
   jit_f build_asm(struct Parrot_Interp *interpreter, opcode_t *pc,
                   opcode_t *code_start, opcode_t *code_end);
  +jit_f Parrot_jit_restart(struct Parrot_Interp * interpreter, opcode_t pc);
   
   /*  Parrot_jit_fixup_t
    *      Platform generic fixup information
  
  
  
  1.115     +4 -5      parrot/interpreter.c
  
  Index: interpreter.c
  ===================================================================
  RCS file: /cvs/public/parrot/interpreter.c,v
  retrieving revision 1.114
  retrieving revision 1.115
  diff -u -w -r1.114 -r1.115
  --- interpreter.c     10 Nov 2002 11:16:16 -0000      1.114
  +++ interpreter.c     12 Nov 2002 14:47:16 -0000      1.115
  @@ -1,7 +1,7 @@
   /* interpreter.c
    *  Copyright: (When this is determined...it will go here)
    *  CVS Info
  - *     $Id: interpreter.c,v 1.114 2002/11/10 11:16:16 leo Exp $
  + *     $Id: interpreter.c,v 1.115 2002/11/12 14:47:16 leo Exp $
    *  Overview:
    *     The interpreter api handles running the operations
    *  Data Structure and Algorithms:
  @@ -215,8 +215,6 @@
   }
   
   
  -/*=for api interpreter runops_jit
  - */
   static void
   runops_jit(struct Parrot_Interp *interpreter, opcode_t *pc)
   {
  @@ -237,7 +235,7 @@
        *
        * This is borken too, but better as endless loops
        */
  -    Interp_flags_CLEAR(interpreter, PARROT_JIT_FLAG);
  +/*    Interp_flags_CLEAR(interpreter, PARROT_JIT_FLAG); */
   #endif
   }
   
  @@ -370,7 +368,7 @@
               runops_prederef(interpreter, pc,
                       interpreter->prederef_code + offset);
           }
  -        else if (Interp_flags_TEST(interpreter, PARROT_JIT_FLAG)) {
  +        else if (!slow && Interp_flags_TEST(interpreter, PARROT_JIT_FLAG)) {
   #if !JIT_CAPABLE
               internal_exception(JIT_UNAVAILABLE,
                       "Error: PARROT_JIT_FLAG is set, but interpreter is not 
JIT_CAPABLE!\n");
  @@ -518,6 +516,7 @@
       SET_NULL_P(interpreter->code, struct PackFile *);
       SET_NULL_P(interpreter->profile, ProfData *);
       SET_NULL_P(interpreter->predref_code, void **);
  +    SET_NULL(interpreter->jit_info);
   
       /* Done. Return and be done with it */
   
  
  
  
  1.37      +8 -2      parrot/jit.c
  
  Index: jit.c
  ===================================================================
  RCS file: /cvs/public/parrot/jit.c,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -w -r1.36 -r1.37
  --- jit.c     9 Nov 2002 11:10:17 -0000       1.36
  +++ jit.c     12 Nov 2002 14:47:16 -0000      1.37
  @@ -1,7 +1,7 @@
   /*
    * jit.c
    *
  - * $Id: jit.c,v 1.36 2002/11/09 11:10:17 leo Exp $
  + * $Id: jit.c,v 1.37 2002/11/12 14:47:16 leo Exp $
    */
   
   #include <parrot/parrot.h>
  @@ -421,9 +421,15 @@
       UINTVAL i;
       char *new_arena;
       void *prev_address;
  -    Parrot_jit_info_t jit_info;
  +    /* FIXME allocate this for multiple interpreters */
  +    static Parrot_jit_info_t jit_info;
       opcode_t cur_opcode_byte;
   
  +
  +    if (pc != code_start && interpreter->jit_info)
  +        return Parrot_jit_restart(interpreter, pc - code_start);
  +
  +    interpreter->jit_info = &jit_info;
       jit_info.optimizer = optimize_jit(interpreter, pc, code_start, code_end);
   
       /* Attach the register map to the jit_info structure */
  
  
  
  1.9       +75 -70    parrot/jit/alpha/jit_emit.h
  
  Index: jit_emit.h
  ===================================================================
  RCS file: /cvs/public/parrot/jit/alpha/jit_emit.h,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -w -r1.8 -r1.9
  --- jit_emit.h        21 Aug 2002 17:48:31 -0000      1.8
  +++ jit_emit.h        12 Nov 2002 14:47:20 -0000      1.9
  @@ -3,7 +3,7 @@
    * 
    * ALPHA
    *
  - * $Id: jit_emit.h,v 1.8 2002/08/21 17:48:31 grunblatt Exp $
  + * $Id: jit_emit.h,v 1.9 2002/11/12 14:47:20 leo Exp $
    */
   
   /*  Register usage:
  @@ -368,6 +368,11 @@
       emit_lc(jit_info->native_ptr, REG11_s2, jit_info->arena.op_map); 
   }
   
  +jit_f
  +Parrot_jit_restart(struct Parrot_Interp * interpreter, opcode_t pc)
  +{
  +}
  +
   void
   Parrot_jit_dofixup(Parrot_jit_info_t *jit_info,
       struct Parrot_Interp * interpreter)
  
  
  
  1.12      +28 -23    parrot/jit/arm/jit_emit.h
  
  Index: jit_emit.h
  ===================================================================
  RCS file: /cvs/public/parrot/jit/arm/jit_emit.h,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -w -r1.11 -r1.12
  --- jit_emit.h        24 Aug 2002 22:55:18 -0000      1.11
  +++ jit_emit.h        12 Nov 2002 14:47:22 -0000      1.12
  @@ -3,7 +3,7 @@
    * 
    * ARM (I think this is all ARM2 or later, although it is APCS-32)
    *
  - * $Id: jit_emit.h,v 1.11 2002/08/24 22:55:18 tom Exp $
  + * $Id: jit_emit.h,v 1.12 2002/11/12 14:47:22 leo Exp $
    */
   
   #ifdef ARM
  @@ -861,6 +861,11 @@
       jit_info->native_ptr = emit_mov (jit_info->native_ptr, 4, 0);
   }
   
  +jit_f
  +Parrot_jit_restart(struct Parrot_Interp * interpreter, opcode_t pc)
  +{
  +}
  +
   /* I'm going to load registers to call functions in general like this:
       adr     r14,  .L1
       ldmia   r14!,  {r0, r1, r2, pc} ; register list built by jit
  
  
  
  1.12      +35 -4     parrot/jit/i386/jit_emit.h
  
  Index: jit_emit.h
  ===================================================================
  RCS file: /cvs/public/parrot/jit/i386/jit_emit.h,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -w -r1.11 -r1.12
  --- jit_emit.h        12 Nov 2002 09:54:43 -0000      1.11
  +++ jit_emit.h        12 Nov 2002 14:47:29 -0000      1.12
  @@ -3,7 +3,7 @@
    *
    * i386
    *
  - * $Id: jit_emit.h,v 1.11 2002/11/12 09:54:43 leo Exp $
  + * $Id: jit_emit.h,v 1.12 2002/11/12 14:47:29 leo Exp $
    */
   
   /* Register codes */
  @@ -900,7 +900,7 @@
   Parrot_jit_dofixup(Parrot_jit_info_t *jit_info,
                      struct Parrot_Interp * interpreter)
   {
  -    Parrot_jit_fixup_t *fixup;
  +    Parrot_jit_fixup_t *fixup, *next;
       char *fixup_ptr;
   
       fixup = jit_info->arena.fixups;
  @@ -931,14 +931,19 @@
                       fixup->type);
               break;
           }
  -        fixup = fixup->next;
  +        next = fixup->next;
  +        free(fixup);
  +        fixup = next;
       }
  +    jit_info->arena.fixups = NULL;
   }
   
   void
   Parrot_jit_begin(Parrot_jit_info_t *jit_info,
                    struct Parrot_Interp * interpreter)
   {
  +    int i;
  +
       /* Maintain the stack frame pointer for the sake of gdb */
       emit_pushl_r(jit_info->native_ptr, emit_EBP);
       emitm_movl_r_r(jit_info->native_ptr, emit_ESP, emit_EBP);
  @@ -959,6 +964,32 @@
   
       /* Point ESI to the opcode-native code map array */
       emitm_movl_i_r(jit_info->native_ptr, jit_info->arena.op_map, emit_ESI);
  +
  +    /* emit 5 noops. when JIT restarts a long jump will be patched in here */
  +    for (i = 0; i < 5; i++)
  +        emit_nop(jit_info->native_ptr);
  +}
  +
  +jit_f
  +Parrot_jit_restart(struct Parrot_Interp * interpreter, opcode_t pc)
  +{
  +    char *ptr;
  +    Parrot_jit_info_t *jit_info = (Parrot_jit_info_t *) interpreter->jit_info;
  +
  +    /* the 5 nops above are at native_ptr -5 of 1. instruction */
  +    jit_info->native_ptr = (char*)jit_info->arena.op_map[0].ptr - 5;
  +    /* pretend, we are at pc */
  +    jit_info->op_i = pc;
  +    /* op_map.ptr & op_map.offset are a union, which are absolute adr's
  +     * now -- fake offset */
  +    ptr = jit_info->arena.op_map[pc].ptr;
  +    jit_info->arena.op_map[pc].offset = ptr - jit_info->arena.start;
  +    /* emit jump with offset 0 */
  +    emit_jump(jit_info, 0);
  +    /* restore ptr */
  +    jit_info->arena.op_map[pc].ptr = ptr;
  +    /* return start of JIT code */
  +    return (jit_f)D2FPTR(jit_info->arena.start);
   }
   
   void
  @@ -976,7 +1007,7 @@
       emitm_addb_i_r(jit_info->native_ptr, 4, emit_ESP);
   }
   
  -extern void Parrot_end_jit(Parrot_jit_info_t *, struct Parrot_Interp * );
  +static void Parrot_end_jit(Parrot_jit_info_t *, struct Parrot_Interp * );
   void
   Parrot_jit_cpcf_op(Parrot_jit_info_t *jit_info,
                      struct Parrot_Interp * interpreter)
  
  
  
  1.12      +40 -34    parrot/jit/ppc/jit_emit.h
  
  Index: jit_emit.h
  ===================================================================
  RCS file: /cvs/public/parrot/jit/ppc/jit_emit.h,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -w -r1.11 -r1.12
  --- jit_emit.h        22 Aug 2002 03:17:49 -0000      1.11
  +++ jit_emit.h        12 Nov 2002 14:47:34 -0000      1.12
  @@ -3,7 +3,7 @@
    * 
    * PPC
    *
  - * $Id: jit_emit.h,v 1.11 2002/08/22 03:17:49 grunblatt Exp $
  + * $Id: jit_emit.h,v 1.12 2002/11/12 14:47:34 leo Exp $
    */
    
   #include <unistd.h>
  @@ -557,6 +557,12 @@
       emit_imm32(jit_info->native_ptr, r15, interpreter->code->byte_code);
   }
   
  +jit_f
  +Parrot_jit_restart(struct Parrot_Interp * interpreter, opcode_t pc)
  +{
  +}
  +
  +
   void
   Parrot_jit_normal_op(Parrot_jit_info_t *jit_info,
                        struct Parrot_Interp * interpreter)
  
  
  
  1.13      +14 -9     parrot/jit/sun4/jit_emit.h
  
  Index: jit_emit.h
  ===================================================================
  RCS file: /cvs/public/parrot/jit/sun4/jit_emit.h,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -w -r1.12 -r1.13
  --- jit_emit.h        13 Aug 2002 18:48:04 -0000      1.12
  +++ jit_emit.h        12 Nov 2002 14:47:42 -0000      1.13
  @@ -3,7 +3,7 @@
   **
   ** SPARC
   **
  -** $Id: jit_emit.h,v 1.12 2002/08/13 18:48:04 grunblatt Exp $
  +** $Id: jit_emit.h,v 1.13 2002/11/12 14:47:42 leo Exp $
   **/
   
   /* 
  @@ -534,6 +534,11 @@
           emitm_i(3), emitm_lo10(jit_info->arena.op_map), Parrot_jit_opmap);
   }
   
  +jit_f
  +Parrot_jit_restart(struct Parrot_Interp * interpreter, opcode_t pc)
  +{
  +}
  +
   void Parrot_jit_normal_op(Parrot_jit_info_t *jit_info,
                             struct Parrot_Interp * interpreter)
   {
  
  
  


Reply via email to