зеркало из https://github.com/github/ruby.git
mjit_compile.c: original_body_iseq
* mjit_compile.c (mjit_compile): name the original iseq pointer to eliminate magic numbers. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62340 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
9da6b8dfdd
Коммит
0e1a5ece62
|
@ -142,6 +142,8 @@ mjit_compile(FILE *f, const struct rb_iseq_constant_body *body, const char *func
|
||||||
#endif
|
#endif
|
||||||
fprintf(f, "VALUE\n%s(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp)\n{\n", funcname);
|
fprintf(f, "VALUE\n%s(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp)\n{\n", funcname);
|
||||||
fprintf(f, " VALUE *stack = reg_cfp->sp;\n");
|
fprintf(f, " VALUE *stack = reg_cfp->sp;\n");
|
||||||
|
fprintf(f, " static const VALUE *const original_body_iseq = (VALUE *)%p;\n",
|
||||||
|
body->iseq_encoded);
|
||||||
|
|
||||||
/* Simulate `opt_pc` in setup_parameters_complex */
|
/* Simulate `opt_pc` in setup_parameters_complex */
|
||||||
if (body->param.flags.has_opt) {
|
if (body->param.flags.has_opt) {
|
||||||
|
@ -157,7 +159,7 @@ mjit_compile(FILE *f, const struct rb_iseq_constant_body *body, const char *func
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ISeq might be used for catch table too. For that usage, this code cancels JIT execution. */
|
/* ISeq might be used for catch table too. For that usage, this code cancels JIT execution. */
|
||||||
fprintf(f, " if (reg_cfp->pc != 0x%"PRIxVALUE") {\n", (VALUE)body->iseq_encoded);
|
fprintf(f, " if (reg_cfp->pc != original_body_iseq) {\n");
|
||||||
fprintf(f, " return Qundef;\n");
|
fprintf(f, " return Qundef;\n");
|
||||||
fprintf(f, " }\n");
|
fprintf(f, " }\n");
|
||||||
|
|
||||||
|
|
|
@ -50,10 +50,10 @@
|
||||||
%
|
%
|
||||||
% # JIT: move sp and pc if necessary
|
% # JIT: move sp and pc if necessary
|
||||||
% if insn.handles_frame?
|
% if insn.handles_frame?
|
||||||
fprintf(f, " reg_cfp->pc = (VALUE *)0x%"PRIxVALUE";\n", (VALUE)(body->iseq_encoded + next_pos)); /* ADD_PC(INSN_ATTR(width)); */
|
fprintf(f, " reg_cfp->pc = original_body_iseq + %d;\n", next_pos); /* ADD_PC(INSN_ATTR(width)); */
|
||||||
fprintf(f, " reg_cfp->sp = reg_cfp->bp + %d;\n", b->stack_size + 1 - <%= insn.pops.size %>); /* POPN(INSN_ATTR(popn)); */
|
fprintf(f, " reg_cfp->sp = reg_cfp->bp + %d;\n", b->stack_size + 1 - <%= insn.pops.size %>); /* POPN(INSN_ATTR(popn)); */
|
||||||
% else
|
% else
|
||||||
fprintf(f, " reg_cfp->pc = (VALUE *)0x%"PRIxVALUE";\n", (VALUE)(body->iseq_encoded + pos));
|
fprintf(f, " reg_cfp->pc = original_body_iseq + %d;\n", pos);
|
||||||
fprintf(f, " reg_cfp->sp = reg_cfp->bp + %d;\n", b->stack_size + 1);
|
fprintf(f, " reg_cfp->sp = reg_cfp->bp + %d;\n", b->stack_size + 1);
|
||||||
% end
|
% end
|
||||||
%
|
%
|
||||||
|
|
|
@ -23,12 +23,12 @@
|
||||||
int param_size = iseq->body->param.size; /* TODO: check calling->argc for argument_arity_error */
|
int param_size = iseq->body->param.size; /* TODO: check calling->argc for argument_arity_error */
|
||||||
|
|
||||||
% # JIT: move sp and pc if necessary
|
% # JIT: move sp and pc if necessary
|
||||||
fprintf(f, " reg_cfp->pc = (VALUE *)0x%"PRIxVALUE";\n", (VALUE)(body->iseq_encoded + next_pos)); /* ADD_PC(INSN_ATTR(width)); */
|
fprintf(f, " reg_cfp->pc = original_body_iseq + %d;\n", next_pos); /* ADD_PC(INSN_ATTR(width)); */
|
||||||
fprintf(f, " reg_cfp->sp = reg_cfp->bp + %d;\n", b->stack_size + 1 - <%= insn.pops.size %>); /* POPN(INSN_ATTR(popn)); */
|
fprintf(f, " reg_cfp->sp = reg_cfp->bp + %d;\n", b->stack_size + 1 - <%= insn.pops.size %>); /* POPN(INSN_ATTR(popn)); */
|
||||||
|
|
||||||
% # JIT: Invalidate call cache if it requires vm_search_method. This allows to inline some of following things.
|
% # JIT: Invalidate call cache if it requires vm_search_method. This allows to inline some of following things.
|
||||||
fprintf(f, " if (UNLIKELY(GET_GLOBAL_METHOD_STATE() != %llu || RCLASS_SERIAL(CLASS_OF(stack[%d])) != %llu)) {\n", cc->method_state, b->stack_size - 1 - argc, cc->class_serial);
|
fprintf(f, " if (UNLIKELY(GET_GLOBAL_METHOD_STATE() != %llu || RCLASS_SERIAL(CLASS_OF(stack[%d])) != %llu)) {\n", cc->method_state, b->stack_size - 1 - argc, cc->class_serial);
|
||||||
fprintf(f, " reg_cfp->pc = (VALUE *)0x%"PRIxVALUE";\n", (VALUE)(body->iseq_encoded + pos));
|
fprintf(f, " reg_cfp->pc = original_body_iseq + %d;\n", pos);
|
||||||
fprintf(f, " return Qundef; /* cancel JIT */\n");
|
fprintf(f, " return Qundef; /* cancel JIT */\n");
|
||||||
fprintf(f, " }\n");
|
fprintf(f, " }\n");
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче