cvsuser     04/10/15 09:05:27

  Modified:    imcc     main.c
               jit/i386 jit_emit.h
               src      jit.c
               t/pmc    nci.t
  Log:
  JIT_i386 - relative register addressing
  * turn on JIT (and other cores) again - we accidentally ran only slow core
  * finish the proposed framework for interpreter-relative addressing
  * use this for JIT/i386 register load and stores
  
  Revision  Changes    Path
  1.80      +0 -1      parrot/imcc/main.c
  
  Index: main.c
  ===================================================================
  RCS file: /cvs/public/parrot/imcc/main.c,v
  retrieving revision 1.79
  retrieving revision 1.80
  diff -u -w -r1.79 -r1.80
  --- main.c    9 Oct 2004 12:07:54 -0000       1.79
  +++ main.c    15 Oct 2004 16:05:22 -0000      1.80
  @@ -426,7 +426,6 @@
       IMCC_ast_init(interpreter);
   
       sourcefile = parseflags(interpreter, &argc, &argv);
  -    interpreter->run_core = 0;
   
       if (Interp_flags_TEST(interpreter, PARROT_PYTHON_MODE))
           Parrot_py_init(interpreter);
  
  
  
  1.122     +61 -1     parrot/jit/i386/jit_emit.h
  
  Index: jit_emit.h
  ===================================================================
  RCS file: /cvs/public/parrot/jit/i386/jit_emit.h,v
  retrieving revision 1.121
  retrieving revision 1.122
  diff -u -w -r1.121 -r1.122
  --- jit_emit.h        14 Oct 2004 15:09:46 -0000      1.121
  +++ jit_emit.h        15 Oct 2004 16:05:23 -0000      1.122
  @@ -3,7 +3,7 @@
    *
    * i386
    *
  - * $Id: jit_emit.h,v 1.121 2004/10/14 15:09:46 leo Exp $
  + * $Id: jit_emit.h,v 1.122 2004/10/15 16:05:23 leo Exp $
    */
   
   #if !defined(PARROT_I386_JIT_EMIT_H_GUARD)
  @@ -2592,6 +2592,52 @@
           ((Parrot_jit_info_t *)(interpreter->jit_info))->native_ptr, reg, mem);
   }
   
  +void
  +Parrot_jit_emit_mov_mr_n_offs(Interp *interpreter,
  +        int base_reg, size_t offs, int src_reg)
  +{
  +    emitm_fld(((Parrot_jit_info_t *)(interpreter->jit_info))->native_ptr,
  +            src_reg);
  +#  if NUMVAL_SIZE == 8
  +    emitm_fstpl(((Parrot_jit_info_t *)(interpreter->jit_info))->native_ptr,
  +            base_reg, emit_None, 1, offs);
  +#  else
  +    emitm_fstpt(((Parrot_jit_info_t *)(interpreter->jit_info))->native_ptr,
  +            base_reg, emit_None, 1, offs);
  +#  endif
  +}
  +
  +void
  +Parrot_jit_emit_mov_mr_offs(Interp *interpreter,
  +        int base_reg, size_t offs, int src_reg)
  +{
  +    emitm_movl_r_m(((Parrot_jit_info_t *)(interpreter->jit_info))->native_ptr,
  +            src_reg, base_reg, emit_None, 1, offs);
  +}
  +
  +void
  +Parrot_jit_emit_mov_rm_n_offs(Interp *interpreter,
  +        int dst_reg, int base_reg, size_t offs)
  +{
  +#  if NUMVAL_SIZE == 8
  +    emitm_fldl(((Parrot_jit_info_t *)(interpreter->jit_info))->native_ptr,
  +            base_reg, emit_None, 1, offs);
  +#  else
  +    emitm_fldt(((Parrot_jit_info_t *)(interpreter->jit_info))->native_ptr,
  +            base_reg, emit_None, 1, offs);
  +#  endif
  +    emitm_fstp(((Parrot_jit_info_t *)(interpreter->jit_info))->native_ptr,
  +            (dst_reg+1));
  +}
  +
  +void
  +Parrot_jit_emit_mov_rm_offs(Interp *interpreter,
  +        int dst_reg, int base_reg, size_t offs)
  +{
  +    emitm_movl_m_r(((Parrot_jit_info_t *)(interpreter->jit_info))->native_ptr,
  +            dst_reg, base_reg, emit_None, 1, offs);
  +}
  +
   static void
   Parrot_jit_emit_finit(Parrot_jit_info_t *jit_info)
   {
  @@ -3181,6 +3227,20 @@
    */
   #  define ALLOCATE_REGISTERS_PER_SECTION 1
   
  +/*
  + * new style move function using offsets relative to the base_reg
  + */
  +#  ifdef JIT_CGP
  +#    define INTERP_BP_OFFS todo
  +#  else
  +#    define INTERP_BP_OFFS -16
  +#  endif
  +
  +#  define Parrot_jit_emit_get_base_reg_no(interp) \
  +    (Parrot_jit_emit_mov_rm_offs(interpreter, emit_EAX, \
  +                                 emit_EBP,INTERP_BP_OFFS), \
  +    emit_EAX)
  +
   
   /*
    * I386 has JITed vtables, which have the vtable# in extcall.
  
  
  
  1.88      +112 -1    parrot/src/jit.c
  
  Index: jit.c
  ===================================================================
  RCS file: /cvs/public/parrot/src/jit.c,v
  retrieving revision 1.87
  retrieving revision 1.88
  diff -u -w -r1.87 -r1.88
  --- jit.c     9 Aug 2004 15:27:34 -0000       1.87
  +++ jit.c     15 Oct 2004 16:05:25 -0000      1.88
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -$Id: jit.c,v 1.87 2004/08/09 15:27:34 grunblatt Exp $
  +$Id: jit.c,v 1.88 2004/10/15 16:05:25 leo Exp $
   
   =head1 NAME
   
  @@ -960,6 +960,19 @@
   
   */
   
  +#if defined(Parrot_jit_emit_get_base_reg_no)
  +static size_t
  +reg_offs(Interp * interpreter, int typ, int i)
  +{
  +    switch (typ) {
  +        case 0:
  +            return REG_OFFS_INT(i);
  +        case 3:
  +            return REG_OFFS_NUM(i);
  +    }
  +    return 0;
  +}
  +#else
   static char *
   reg_addr(Interp * interpreter, int typ, int i)
   {
  @@ -988,6 +1001,7 @@
                   return 0;   /* not currently */
           }
   }
  +#endif
   
   /*
   
  @@ -1001,6 +1015,102 @@
   
   */
   
  +
  +#if defined(Parrot_jit_emit_get_base_reg_no)
  +
  +static void
  +Parrot_jit_load_registers(Parrot_jit_info_t *jit_info,
  +                          Interp * interpreter)
  +{
  +    Parrot_jit_optimizer_section_t *sect = jit_info->optimizer->cur_section;
  +    Parrot_jit_register_usage_t *ru = sect->ru;
  +    int i, typ;
  +    void (*mov_f[4])(Interp *, int, int, size_t)
  +        = { Parrot_jit_emit_mov_rm_offs, 0, 0, Parrot_jit_emit_mov_rm_n_offs};
  +    int lasts[] = { PRESERVED_INT_REGS, 0,0,  PRESERVED_FLOAT_REGS };
  +    char * maps[] = {0, 0, 0, 0};
  +    int first = 1;
  +    int base_reg;
  +    size_t offs;
  +
  +    maps[0] = jit_info->intval_map;
  +    maps[3] = jit_info->floatval_map;
  +
  +
  +    for (typ = 0; typ < 4; typ++) {
  +        if (maps[typ]) {
  +            for (i = ru[typ].registers_used-1; i >= 0; --i) {
  +                int us = ru[typ].reg_usage[i];
  +                if ((i >= lasts[typ] && ru[typ].reg_dir[us]) ||
  +                        (ru[typ].reg_dir[us] & PARROT_ARGDIR_IN)) {
  +                    if (first) {
  +                        base_reg = Parrot_jit_emit_get_base_reg_no(
  +                                interpreter);
  +                        first = 0;
  +                    }
  +                    offs = reg_offs(interpreter, typ, us);
  +                    (mov_f[typ])(interpreter, maps[typ][i], base_reg, offs);
  +                }
  +            }
  +        }
  +    }
  +
  +    /* The total size of the loads. This is used for branches to
  +     * the same section - these skip the load asm bytes */
  +    sect->load_size = jit_info->native_ptr -
  +        (jit_info->arena.start +
  +         jit_info->arena.op_map[jit_info->op_i].offset);
  +}
  +
  +/*
  +
  +=item C<static void
  +Parrot_jit_save_registers(Parrot_jit_info_t *jit_info,
  +                          Interp * interpreter)>
  +
  +Save registers for the current section.
  +
  +=cut
  +
  +*/
  +
  +static void
  +Parrot_jit_save_registers(Parrot_jit_info_t *jit_info,
  +                          Interp * interpreter)
  +{
  +    Parrot_jit_optimizer_section_t *sect = jit_info->optimizer->cur_section;
  +    Parrot_jit_register_usage_t *ru = sect->ru;
  +    int i, typ;
  +    void (*mov_f[4])(Interp * ,int, size_t, int)
  +        = { Parrot_jit_emit_mov_mr_offs, 0, 0, Parrot_jit_emit_mov_mr_n_offs};
  +    int lasts[] = { PRESERVED_INT_REGS, 0,0,  PRESERVED_FLOAT_REGS };
  +    char * maps[] = {0, 0, 0, 0};
  +    int first = 1;
  +    int base_reg;
  +    size_t offs;
  +
  +    maps[0] = jit_info->intval_map;
  +    maps[3] = jit_info->floatval_map;
  +    for (typ = 0; typ < 4; typ++) {
  +        if (maps[typ])
  +            for (i = 0; i < ru[typ].registers_used; ++i) {
  +                int us = ru[typ].reg_usage[i];
  +                if ((i >= lasts[typ] && ru[typ].reg_dir[us]) ||
  +                    ru[typ].reg_dir[us] & PARROT_ARGDIR_OUT) {
  +                    if (first) {
  +                        base_reg = Parrot_jit_emit_get_base_reg_no(
  +                                interpreter);
  +                        first = 0;
  +                    }
  +                    offs = reg_offs(interpreter, typ, us);
  +                    (mov_f[typ])(interpreter, base_reg, offs, maps[typ][i]);
  +                }
  +            }
  +    }
  +}
  +
  +#else
  +
   static void
   Parrot_jit_load_registers(Parrot_jit_info_t *jit_info,
                             Interp * interpreter)
  @@ -1087,6 +1197,7 @@
               }
       }
   }
  +#endif
   
   /*
   
  
  
  
  1.59      +3 -1      parrot/t/pmc/nci.t
  
  Index: nci.t
  ===================================================================
  RCS file: /cvs/public/parrot/t/pmc/nci.t,v
  retrieving revision 1.58
  retrieving revision 1.59
  diff -u -w -r1.58 -r1.59
  --- nci.t     14 Oct 2004 15:09:47 -0000      1.58
  +++ nci.t     15 Oct 2004 16:05:27 -0000      1.59
  @@ -1,7 +1,7 @@
   #! perl -w
   
   # Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -# $Id: nci.t,v 1.58 2004/10/14 15:09:47 leo Exp $
  +# $Id: nci.t,v 1.59 2004/10/15 16:05:27 leo Exp $
   
   =head1 NAME
   
  @@ -1583,6 +1583,8 @@
   
   .sub _test @MAIN
   
  +    # turn off JIT or special core - no events yet
  +    bounds 1
       # prepare user data
       .local pmc user_data
       user_data = new Integer
  
  
  

Reply via email to