cvsuser     03/02/26 09:02:53

  Modified:    .        core.ops
               lib/Parrot Op.pm OpsFile.pm
               lib/Parrot/OpTrans Compiled.pm
  Log:
  Add an OP_SIZE macro to the core.ops processing system.
  
  Change expr NEXT() to compute offsets from the start of the actual
  bytecode, because users of the value may have switched cores from the
  time the offset was generated, so global offsets are the only thing
  they can rely upon.
  
  Revision  Changes    Path
  1.261     +4 -14     parrot/core.ops
  
  Index: core.ops
  ===================================================================
  RCS file: /cvs/public/parrot/core.ops,v
  retrieving revision 1.260
  retrieving revision 1.261
  diff -u -w -r1.260 -r1.261
  --- core.ops  23 Feb 2003 09:58:29 -0000      1.260
  +++ core.ops  26 Feb 2003 17:02:48 -0000      1.261
  @@ -16,16 +16,6 @@
   
   Parrot's core library of ops.
   
  -=head1 NOTE
  -
  -Some branching ops use B<CUR_OPCODE + size> as branch destination and
  -not B<expr NEXT()>. This is done, to get a branch destination in terms
  -of offsets in the normal core, and not in terms of the running core.
  -
  -This is needed, for all branching ops, that might leave the actual
  -core, so that the branch offset can be recalculated to the other core,
  -Currently used in the native run core generated by B<pbc2c.pl>.
  -
   =cut
   
   # ' for emacs
  @@ -3799,7 +3789,7 @@
   =cut
   
   inline op bsr (in INT) {
  -  stack_push(interpreter, &interpreter->ctx.control_stack, CUR_OPCODE + 2,  
STACK_ENTRY_DESTINATION, STACK_CLEANUP_NULL);
  +  stack_push(interpreter, &interpreter->ctx.control_stack, expr NEXT(),  
STACK_ENTRY_DESTINATION, STACK_CLEANUP_NULL);
     goto OFFSET($1);
   }
   
  @@ -3815,7 +3805,7 @@
   
   inline op jsr(in INT) {
     opcode_t * loc;
  -  stack_push(interpreter, &interpreter->ctx.control_stack, CUR_OPCODE + 2,  
STACK_ENTRY_DESTINATION, STACK_CLEANUP_NULL);
  +  stack_push(interpreter, &interpreter->ctx.control_stack, expr NEXT(),  
STACK_ENTRY_DESTINATION, STACK_CLEANUP_NULL);
     loc = INTVAL2PTR(opcode_t *, $1);
     goto ADDRESS(loc);
   }
  @@ -4592,7 +4582,7 @@
     opcode_t *dest;
     PMC * p = interpreter->ctx.pmc_reg.registers[0];
   
  -  dest = (opcode_t *)p->vtable->invoke(interpreter, p, CUR_OPCODE + 1);
  +  dest = (opcode_t *)p->vtable->invoke(interpreter, p, expr NEXT());
   
     goto ADDRESS(dest);
   }
  @@ -4601,7 +4591,7 @@
     opcode_t *dest;
     PMC * p = $1;
   
  -  dest = (opcode_t *)p->vtable->invoke(interpreter, p, CUR_OPCODE + 2);
  +  dest = (opcode_t *)p->vtable->invoke(interpreter, p, expr NEXT());
   
     goto ADDRESS(dest);
   }
  
  
  
  1.10      +1 -0      parrot/lib/Parrot/Op.pm
  
  Index: Op.pm
  ===================================================================
  RCS file: /cvs/public/parrot/lib/Parrot/Op.pm,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -w -r1.9 -r1.10
  --- Op.pm     22 Apr 2002 02:40:59 -0000      1.9
  +++ Op.pm     26 Feb 2003 17:02:50 -0000      1.10
  @@ -202,6 +202,7 @@
     s/{{-=([^{]*?)}}/     $trans->goto_offset(-$1); /me;
     s/{{=([^*][^{]*?)}}/  $trans->goto_address($1); /me;
   
  +  s/{{\^(-?\d+)}}/      $1                        /me;
     s/{{\^\+([^{]*?)}}/   $trans->expr_offset($1);  /me;
     s/{{\^-([^{]*?)}}/    $trans->expr_offset(-$1); /me;
     s/{{\^([^{]*?)}}/     $trans->expr_address($1); /me;
  
  
  
  1.32      +3 -1      parrot/lib/Parrot/OpsFile.pm
  
  Index: OpsFile.pm
  ===================================================================
  RCS file: /cvs/public/parrot/lib/Parrot/OpsFile.pm,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -w -r1.31 -r1.32
  --- OpsFile.pm        22 Jan 2003 15:57:24 -0000      1.31
  +++ OpsFile.pm        26 Feb 2003 17:02:50 -0000      1.32
  @@ -232,7 +232,7 @@
       }
   
       #
  -    # Accummulate the code into the op's body:
  +    # Accumulate the code into the op's body:
       #
   
       if ($seen_op) {
  @@ -301,6 +301,7 @@
         #   expr OFFSET(X)     {{^+X}}  PC + X        Relative address
         #   expr NEXT()        {{^+S}}  PC + S        Where S is op size
         #   expr ADDRESS(X)    {{^X}}   X             Absolute address
  +      #   OP_SIZE            {{^S}}   S             op size
         #
         #   HALT()             {{=0}}   PC' = 0       Halts run_ops loop, no resume
         #
  @@ -327,6 +328,7 @@
         $absolute ||= $body =~ s/\bgoto\s+ADDRESS\(\( (.*?) \)\)/{{=$1}}/mg;
                       $body =~ s/\bexpr\s+OFFSET\(\( (.*?) \)\)/{{^+$1}}/mg;
                       $body =~ s/\bexpr\s+ADDRESS\(\( (.*?) \)\)/{{^$1}}/mg;
  +                    $body =~ s/\bOP_SIZE\b/{{^$op_size}}/mg;
   
         $branch   ||= $body =~ s/\bgoto\s+OFFSET\((.*?)\)/{{+=$1}}/mg;
                       $body =~ s/\bgoto\s+NEXT\(\)/{{+=$op_size}}/mg;
  
  
  
  1.11      +10 -3     parrot/lib/Parrot/OpTrans/Compiled.pm
  
  Index: Compiled.pm
  ===================================================================
  RCS file: /cvs/public/parrot/lib/Parrot/OpTrans/Compiled.pm,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -w -r1.10 -r1.11
  --- Compiled.pm       3 Feb 2003 16:18:59 -0000       1.10
  +++ Compiled.pm       26 Feb 2003 17:02:53 -0000      1.11
  @@ -1,7 +1,7 @@
   #
   # CGoto.pm
   #
  -# $Id: Compiled.pm,v 1.10 2003/02/03 16:18:59 leo Exp $
  +# $Id: Compiled.pm,v 1.11 2003/02/26 17:02:53 sfink Exp $
   #
   
   use strict;
  @@ -16,7 +16,6 @@
   sub defines
   {
     return <<END;
  -#define CUR_OPCODE cur_opcode
   #define REL_PC (cur_opcode - start_code)
   #define IREG(i) interpreter->ctx.int_reg.registers[i]
   #define NREG(i) interpreter->ctx.num_reg.registers[i]
  @@ -85,9 +84,17 @@
   }
   
   
  +#
  +# expr_offset()
  +#
  +# On offset expression is always an offset from start_code, because
  +# the 'ret' instruction may be in a different runops core. 'ret' will
  +# always treat saved addresses as relative to start_code, because that
  +# interpretation is global across all runops cores.
  +#
   sub expr_offset {
       my ($self, $offset) = @_;
  -    return sprintf("&&PC_%d", $self->pc + $offset);
  +    return sprintf("start_code + %d + %s", $self->pc, $offset);
   }
   
   #
  
  
  

Reply via email to