cvsuser     03/01/17 07:10:47

  Modified:    .        core.ops embed.c interpreter.c
  Log:
  runops cleanup
  
  Revision  Changes    Path
  1.248     +2 -1      parrot/core.ops
  
  Index: core.ops
  ===================================================================
  RCS file: /cvs/public/parrot/core.ops,v
  retrieving revision 1.247
  retrieving revision 1.248
  diff -u -w -r1.247 -r1.248
  --- core.ops  16 Jan 2003 17:26:17 -0000      1.247
  +++ core.ops  17 Jan 2003 15:10:46 -0000      1.248
  @@ -4250,7 +4250,8 @@
   op runinterp(inout PMC, in INT) {
     struct Parrot_Interp * new_interp = (struct Parrot_Interp *)$1->data;
     Interp_flags_SET(interpreter, PARROT_EXTERN_CODE_FLAG);
  -  runops(new_interp, interpreter->code, REL_PC + $2);
  +  new_interp->code = interpreter->code;
  +  runops(new_interp, REL_PC + $2);
     goto NEXT();
   }
   
  
  
  
  1.59      +2 -2      parrot/embed.c
  
  Index: embed.c
  ===================================================================
  RCS file: /cvs/public/parrot/embed.c,v
  retrieving revision 1.58
  retrieving revision 1.59
  diff -u -w -r1.58 -r1.59
  --- embed.c   9 Jan 2003 16:37:42 -0000       1.58
  +++ embed.c   17 Jan 2003 15:10:46 -0000      1.59
  @@ -1,7 +1,7 @@
   /* embed.c
    *  Copyright: (When this is determined...it will go here)
    *  CVS Info
  - *     $Id: embed.c,v 1.58 2003/01/09 16:37:42 leo Exp $
  + *     $Id: embed.c,v 1.59 2003/01/17 15:10:46 leo Exp $
    *  Overview:
    *     The Parrot embedding interface.
    *  Data Structure and Algorithms:
  @@ -305,7 +305,7 @@
       setup_argv(interpreter, argc, argv);
   
       /* Let's kick the tires and light the fires--call interpreter.c:runops. */
  -    runops(interpreter, interpreter->code, 0);
  +    runops(interpreter,  0);
   
       /*
        * If any profile information was gathered, print it out:
  
  
  
  1.129     +64 -78    parrot/interpreter.c
  
  Index: interpreter.c
  ===================================================================
  RCS file: /cvs/public/parrot/interpreter.c,v
  retrieving revision 1.128
  retrieving revision 1.129
  diff -u -w -r1.128 -r1.129
  --- interpreter.c     16 Jan 2003 17:26:17 -0000      1.128
  +++ interpreter.c     17 Jan 2003 15:10:46 -0000      1.129
  @@ -1,7 +1,7 @@
   /* interpreter.c
    *  Copyright: (When this is determined...it will go here)
    *  CVS Info
  - *     $Id: interpreter.c,v 1.128 2003/01/16 17:26:17 leo Exp $
  + *     $Id: interpreter.c,v 1.129 2003/01/17 15:10:46 leo Exp $
    *  Overview:
    *     The interpreter api handles running the operations
    *  Data Structure and Algorithms:
  @@ -54,22 +54,6 @@
       }
   }
   
  -/*=for api interpreter init_prederef
  - *
  - * interpreter->op_lib = prederefed oplib
  - *
  - * the "normal" op_lib has a copy in the interpreter structure
  - */
  -static void
  -init_prederef(struct Parrot_Interp *interpreter)
  -{
  -    interpreter->op_lib = PARROT_CORE_PREDEREF_OPLIB_INIT();
  -    if (interpreter->op_lib->op_count != interpreter->op_count)
  -        internal_exception(PREDEREF_LOAD_ERROR,
  -                           "Illegal op count (%d) in prederef oplib\n",
  -                           (int)interpreter->op_lib->op_count);
  -}
  -
   /*=for api interpreter load_oplib
    *
    * dynamically load an op_lib extension
  @@ -113,16 +97,7 @@
       Parrot_dlclose(handle);
   }
   #endif
  -/*=for api interpreter stop_prederef
  - *
  - * Unload the prederef oplib.
  - */
   
  -static void
  -stop_prederef(struct Parrot_Interp *interpreter)
  -{
  -    interpreter->op_lib = PARROT_CORE_OPLIB_INIT();
  -}
   
   /*=for api interpreter prederef
    *
  @@ -216,6 +191,43 @@
       return pc_prederef;
   }
   
  +/*=for api interpreter init_prederef
  + *
  + * interpreter->op_lib = prederefed oplib
  + *
  + * the "normal" op_lib has a copy in the interpreter structure
  + */
  +static void
  +init_prederef(struct Parrot_Interp *interpreter)
  +{
  +    interpreter->op_lib = PARROT_CORE_PREDEREF_OPLIB_INIT();
  +    if (interpreter->op_lib->op_count != interpreter->op_count)
  +        internal_exception(PREDEREF_LOAD_ERROR,
  +                "Illegal op count (%d) in prederef oplib\n",
  +                (int)interpreter->op_lib->op_count);
  +    if (!interpreter->prederef_code) {
  +        size_t N = interpreter->code->byte_code_size;
  +        size_t i;
  +        void **temp = (void **)mem_sys_allocate(N * sizeof(void *));
  +
  +        for (i = 0; i < N; i++) {
  +            temp[i] = (void *)(ptrcast_t)prederef;
  +        }
  +
  +        interpreter->prederef_code = temp;
  +    }
  +}
  +
  +/*=for api interpreter stop_prederef
  + *
  + * Unload the prederef oplib.
  + */
  +
  +static void
  +stop_prederef(struct Parrot_Interp *interpreter)
  +{
  +    interpreter->op_lib = PARROT_CORE_OPLIB_INIT();
  +}
   
   static void
   runops_jit(struct Parrot_Interp *interpreter, opcode_t *pc)
  @@ -254,22 +266,18 @@
    * (at the time of implementation that only occurs for interpreter
    * flag changing ops).
    */
  -static void
  -runops_prederef(struct Parrot_Interp *interpreter, opcode_t *pc,
  -                void **pc_prederef)
  +static opcode_t *
  +runops_prederef(struct Parrot_Interp *interpreter, opcode_t *pc)
   {
  -    opcode_t *code_start;
  +    opcode_t *code_start = (opcode_t *)interpreter->code->byte_code;
       UINTVAL code_size;          /* in opcodes */
       opcode_t *code_end;
       void **code_start_prederef;
  -
  -    code_start = interpreter->code->byte_code;
  -    code_size = interpreter->code->byte_code_size / sizeof(opcode_t);
  -    code_end = interpreter->code->byte_code + code_size;
  -
  -    code_start_prederef = pc_prederef;
  +    void **pc_prederef;
   
       init_prederef(interpreter);
  +    code_start_prederef = interpreter->prederef_code + (pc - code_start);
  +    pc_prederef = code_start_prederef;
   
       while (pc_prederef) {
           pc_prederef =
  @@ -285,25 +293,22 @@
       else {
           pc = code_start + (pc_prederef - code_start_prederef);
       }
  -
  -    if (pc && (pc < code_start || pc >= code_end)) {
  -        internal_exception(INTERP_ERROR,
  -                           "Error: Control left bounds of byte-code block (now at 
location %d)!\n",
  -                           (int)(pc - code_start));
  -    }
  +    return pc;
   }
   
   
   /*=for api interpreter runops
  - * run parrot operations until the program is complete
  + * run parrot operations of loaded code segment until an end opcode is reached
  + * run core is selected depending on the Interp_flags
  + * when restart opcode are encountered a different core my be selected
  + * and evaluation of opcode continues
    */
   void
  -runops(struct Parrot_Interp *interpreter, struct PackFile *code, size_t offset)
  +runops(struct Parrot_Interp *interpreter, size_t offset)
   {
       int lo_var_ptr;
       opcode_t *(*core) (struct Parrot_Interp *, opcode_t *);
   
  -    interpreter->code = code;
       interpreter->resume_offset = offset;
       interpreter->resume_flag = 1;
   
  @@ -319,8 +324,17 @@
                       PARROT_PROFILE_FLAG |
                       PARROT_TRACE_FLAG));
   
  -        if (slow)
  +        if (slow) {
               core = runops_slow_core;
  +
  +            if (Interp_flags_TEST(interpreter, PARROT_PROFILE_FLAG)) {
  +                if (interpreter->profile == NULL) {
  +                    interpreter->profile = (ProfData *)
  +                        mem_sys_allocate_zeroed(interpreter->op_count *
  +                                sizeof(ProfData));
  +                }
  +            }
  +        }
           else if (Interp_flags_TEST(interpreter, PARROT_CGOTO_FLAG)) {
               core = runops_cgoto_core;
               /* clear stacktop, it gets set in runops_cgoto_core beyond the
  @@ -333,36 +347,14 @@
                   interpreter->lo_var_ptr = 0;
   #endif
           }
  +        else if (Interp_flags_TEST(interpreter, PARROT_PREDEREF_FLAG)) {
  +            core = runops_prederef;
  +        }
           else
               core = runops_fast_core;
   
  -        if (Interp_flags_TEST(interpreter, PARROT_PROFILE_FLAG)) {
  -            if (interpreter->profile == NULL) {
  -                interpreter->profile = (ProfData *)
  -                    mem_sys_allocate_zeroed(interpreter->op_count *
  -                            sizeof(ProfData));
  -            }
  -        }
  -
  -        if (!slow && Interp_flags_TEST(interpreter, PARROT_PREDEREF_FLAG)) {
  -            offset = pc - (opcode_t *)interpreter->code->byte_code;
   
  -            if (!interpreter->prederef_code) {
  -                size_t N = interpreter->code->byte_code_size;
  -                size_t i;
  -                void **temp = (void **)mem_sys_allocate(N * sizeof(void *));
  -
  -                for (i = 0; i < N; i++) {
  -                    temp[i] = (void *)(ptrcast_t)prederef;
  -                }
  -
  -                interpreter->prederef_code = temp;
  -            }
  -
  -            runops_prederef(interpreter, pc,
  -                    interpreter->prederef_code + offset);
  -        }
  -        else if (!slow && Interp_flags_TEST(interpreter, PARROT_JIT_FLAG)) {
  +        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");
  @@ -379,11 +371,6 @@
            */
           interpreter->lo_var_ptr = (void *)&lo_var_ptr;
       }
  -
  -    if (interpreter->prederef_code) {
  -        free(interpreter->prederef_code);
  -        interpreter->prederef_code = NULL;
  -    }
   }
   
   static int
  @@ -570,7 +557,6 @@
           mem_sys_free(interpreter->profile);
       if (interpreter->prederef_code)
           free(interpreter->prederef_code);
  -    /* TODO cleanup JIT structures */
   
       mem_sys_free(interpreter->warns);
   
  
  
  


Reply via email to