PARROT_EXPORT void Parrot_set_flag(PARROT_INTERP, INTVAL flag) { /* These two macros (from interpreter.h) do exactly what they look like. */ Interp_flags_SET(interp, flag); switch (flag) { case PARROT_BOUNDS_FLAG: case PARROT_PROFILE_FLAG: Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "slow")); break; default: break; } }
void Parrot_set_flag(struct Parrot_Interp *interpreter, Parrot_Interp_flag flag) { /* These two macros (from interpreter.h) do exactly what they look like. */ Interp_flags_SET(interpreter, flag); switch (flag) { case PARROT_BOUNDS_FLAG: case PARROT_PROFILE_FLAG: case PARROT_TRACE_FLAG: Interp_core_SET(interpreter, PARROT_SLOW_CORE); break; default: break; } }
opcode_t * runops_slow_core(struct Parrot_Interp *interpreter, opcode_t *pc) { #ifdef USE_TRACE_INTERP Interp * trace_i; struct Parrot_Context *trace_ctx; #endif opcode_t *opc, *ostart, *oend; static size_t dod, gc; #ifdef code_start # undef code_start #endif #ifdef code_end # undef code_end #endif #define code_start interpreter->code->byte_code #define code_end (interpreter->code->byte_code + \ interpreter->code->cur_cs->base.size) #ifdef USE_TRACE_INTERP if (Interp_flags_TEST(interpreter, PARROT_TRACE_FLAG)) { trace_i = make_interpreter(interpreter, NO_FLAGS); Parrot_init(trace_i); /* remeber old context */ trace_ctx = mem_sys_allocate(sizeof(struct Parrot_Context)); mem_sys_memcopy(trace_ctx, &trace_i->ctx, sizeof(struct Parrot_Context)); /* copy in current */ mem_sys_memcopy(&trace_i->ctx, &interpreter->ctx, sizeof(struct Parrot_Context)); trace_i->code = interpreter->code; Interp_flags_SET(trace_i, PARROT_EXTERN_CODE_FLAG); } #endif dod = interpreter->dod_runs; gc = interpreter->collect_runs; while (pc) {/* && pc >= code_start && pc < code_end) {*/ interpreter->cur_pc = pc; opc = pc; ostart = code_start; oend = code_end; DO_OP(pc, interpreter); if (Interp_flags_TEST(interpreter, PARROT_TRACE_FLAG)) { #ifdef USE_TRACE_INTERP mem_sys_memcopy(&trace_i->ctx, &interpreter->ctx, sizeof(struct Parrot_Context)); trace_op(trace_i, ostart, oend, opc); #else trace_op(interpreter, ostart, oend, opc); #endif if (dod != interpreter->dod_runs) { dod = interpreter->dod_runs; PIO_printf(interpreter, " DOD\n"); } if (gc != interpreter->collect_runs) { gc = interpreter->collect_runs; PIO_printf(interpreter, " GC\n"); } } } #ifdef USE_TRACE_INTERP if (Interp_flags_TEST(interpreter, PARROT_TRACE_FLAG)) { /* restore trace context */ mem_sys_memcopy(&trace_i->ctx, trace_ctx, sizeof(struct Parrot_Context)); mem_sys_free(trace_ctx); } #endif /* 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)); }*/ #undef code_start #undef code_end return pc; }