cvsuser     03/02/09 08:55:48

  Modified:    .        interpreter.c ops2c.pl
               lib/Parrot/OpTrans CGP.pm
  Log:
  cgp #2 - direct threaded now, thanks to Jerome Vouillon
  
  Revision  Changes    Path
  1.143     +7 -3      parrot/interpreter.c
  
  Index: interpreter.c
  ===================================================================
  RCS file: /cvs/public/parrot/interpreter.c,v
  retrieving revision 1.142
  retrieving revision 1.143
  diff -u -w -r1.142 -r1.143
  --- interpreter.c     6 Feb 2003 12:57:11 -0000       1.142
  +++ interpreter.c     9 Feb 2003 16:55:44 -0000       1.143
  @@ -1,7 +1,7 @@
   /* interpreter.c
    *  Copyright: (When this is determined...it will go here)
    *  CVS Info
  - *     $Id: interpreter.c,v 1.142 2003/02/06 12:57:11 leo Exp $
  + *     $Id: interpreter.c,v 1.143 2003/02/09 16:55:44 leo Exp $
    *  Overview:
    *     The interpreter api handles running the operations
    *  Data Structure and Algorithms:
  @@ -178,7 +178,11 @@
   static void
   init_prederef(struct Parrot_Interp *interpreter, int cgp)
   {
  -    interpreter->op_lib = PARROT_CORE_PREDEREF_OPLIB_INIT(1);
  +
  +    oplib_init_f init_func = cgp ?
  +        Parrot_DynOp_core_cgp_0_0_9 :
  +        PARROT_CORE_PREDEREF_OPLIB_INIT;
  +    interpreter->op_lib = init_func(1);
       interpreter->op_lib->op_code = PARROT_CORE_OPLIB_INIT(1)->op_code;
       if (interpreter->op_lib->op_count != interpreter->op_count)
           internal_exception(PREDEREF_LOAD_ERROR,
  @@ -200,7 +204,7 @@
               size_t n;
               for (i = 0; i < N; ) {
                   prederef(temp, interpreter);
  -                *temp = (void*)*pc;
  +                *temp = ((void**)(interpreter->op_lib->op_func_table)) [*pc];
                   n = interpreter->op_info_table[*pc].arg_count;
                   pc += n;
                   i += n;
  
  
  
  1.40      +35 -5     parrot/ops2c.pl
  
  Index: ops2c.pl
  ===================================================================
  RCS file: /cvs/public/parrot/ops2c.pl,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -w -r1.39 -r1.40
  --- ops2c.pl  6 Feb 2003 12:41:05 -0000       1.39
  +++ ops2c.pl  9 Feb 2003 16:55:44 -0000       1.40
  @@ -5,7 +5,7 @@
   # Generate a C header and source file from the operation definitions in
   # an .ops file, using a supplied transform.
   #
  -# $Id: ops2c.pl,v 1.39 2003/02/06 12:41:05 leo Exp $
  +# $Id: ops2c.pl,v 1.40 2003/02/09 16:55:44 leo Exp $
   #
   
   use strict;
  @@ -241,17 +241,35 @@
        if (!interpreter->lo_var_ptr)
            interpreter->lo_var_ptr = (void*)&lo_var_ptr;
       }
  -    _check();
   #endif
   /* #endif */
  +END_C
  +}
   
  +if ($suffix =~ /cgp/) {
  +    print SOURCE <<END_C;
  +    if (cur_opcode == 0)
  +      return (opcode_t *)ops_addr;
  +#ifdef __GNUC__
  +    else
  +      _check();
  +#endif
  +    goto **cur_opcode;
  +
  +END_C
  +} elsif ($suffix =~ /cg/) {
  +    print SOURCE <<END_C;
  +#ifdef __GNUC__
  +    _check();
  +#endif
   goto *ops_addr[*cur_opcode];
   
   END_C
   }
   
  -print SOURCE <<END_C;
   
  +
  +print SOURCE <<END_C;
   /*
   ** Op Function Definitions:
   */
  @@ -265,7 +283,8 @@
   
   if ($suffix =~ /cg/) {
       print SOURCE <<END_C;
  -} /* cg_$base */
  +} /* $cg_func$base */
  +
   END_C
   }
   
  @@ -490,8 +509,19 @@
   
   op_lib_t *
   
Parrot_DynOp_${base}${suffix}_${major_version}_${minor_version}_${patch_version}(int 
init) {
  -    if (init)
  +    if (init) {
  +
  +END_C
  +
  +if ($suffix =~ /cgp/) {
  +print SOURCE <<END_C;
  +     op_lib.op_func_table = (op_func_t *) cgp_$base(0, 0);
  +END_C
  +}
  +
  +print SOURCE <<END_C;
        return &op_lib;
  +    }
       else {
        hop_deinit();
        return NULL;
  
  
  
  1.4       +5 -5      parrot/lib/Parrot/OpTrans/CGP.pm
  
  Index: CGP.pm
  ===================================================================
  RCS file: /cvs/public/parrot/lib/Parrot/OpTrans/CGP.pm,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -w -r1.3 -r1.4
  --- CGP.pm    7 Feb 2003 14:06:52 -0000       1.3
  +++ CGP.pm    9 Feb 2003 16:55:48 -0000       1.4
  @@ -6,7 +6,7 @@
   #
   # Author: leo
   #
  -# $Id: CGP.pm,v 1.3 2003/02/07 14:06:52 leo Exp $
  +# $Id: CGP.pm,v 1.4 2003/02/09 16:55:48 leo Exp $
   #
   
   use strict;
  @@ -60,8 +60,8 @@
     } else {
        return "if ((opcode_t *) $addr == 0)
          return 0;
  -   goto *ops_addr[*(cur_opcode = (opcode_t *)
  -     opcode_to_prederef(interpreter, $addr))]";
  +   goto **(cur_opcode = (opcode_t *)
  +     opcode_to_prederef(interpreter, $addr))";
     }
   }
   
  @@ -72,7 +72,7 @@
   sub goto_offset
   {
     my ($self, $offset) = @_;
  -  return "goto *ops_addr[*(cur_opcode += $offset)]";
  +  return "goto **(cur_opcode += $offset)";
   }
   #
   # goto_pop()
  @@ -81,5 +81,5 @@
   sub goto_pop
   {
     my ($self) = @_;
  -  return "opcode_t* pop_addr = 
(opcode_t*)opcode_to_prederef(interpreter,pop_dest(interpreter));\ncur_opcode = 
pop_addr;goto *ops_addr[*(pop_addr)]";
  +  return "goto ** (cur_opcode = 
(opcode_t*)opcode_to_prederef(interpreter,pop_dest(interpreter)))";
   }
  
  
  


Reply via email to