mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
some functions accept ec
instead of th
.
* vm.c (vm_make_env_object): accepts `ec`. * vm.c (rb_vm_get_ruby_level_next_cfp): ditto. * vm.c (rb_vm_make_proc): ditto. * vm.c (rb_vm_make_proc_lambda): ditto. * vm_core.h: some macros accept ec instead of th (and make them inline functions): * RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW * RUBY_VM_END_CONTROL_FRAME * RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P * eval.c (frame_func_id): constify for the first parameter. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60441 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
837fd5e494
commit
e95de48f1d
11 changed files with 92 additions and 84 deletions
|
@ -7602,9 +7602,9 @@ rb_local_defined(ID id, const struct rb_block *base_block)
|
|||
static int
|
||||
caller_location(VALUE *path, VALUE *realpath)
|
||||
{
|
||||
const rb_thread_t *const th = GET_THREAD();
|
||||
const rb_execution_context_t *ec = GET_EC();
|
||||
const rb_control_frame_t *const cfp =
|
||||
rb_vm_get_ruby_level_next_cfp(th, th->ec->cfp);
|
||||
rb_vm_get_ruby_level_next_cfp(ec, ec->cfp);
|
||||
|
||||
if (cfp) {
|
||||
int line = rb_vm_get_sourceline(cfp);
|
||||
|
|
5
error.c
5
error.c
|
@ -1297,10 +1297,9 @@ name_err_initialize(int argc, VALUE *argv, VALUE self)
|
|||
rb_call_super(argc, argv);
|
||||
rb_ivar_set(self, id_name, name);
|
||||
{
|
||||
rb_thread_t *th = GET_THREAD();
|
||||
const rb_execution_context_t *ec = GET_EC();
|
||||
rb_control_frame_t *cfp =
|
||||
rb_vm_get_ruby_level_next_cfp(th,
|
||||
RUBY_VM_PREVIOUS_CONTROL_FRAME(th->ec->cfp));
|
||||
rb_vm_get_ruby_level_next_cfp(ec, RUBY_VM_PREVIOUS_CONTROL_FRAME(ec->cfp));
|
||||
if (cfp) iseqw = rb_iseqw_new(cfp->iseq);
|
||||
}
|
||||
rb_ivar_set(self, id_iseq, iseqw);
|
||||
|
|
14
eval.c
14
eval.c
|
@ -1062,7 +1062,7 @@ rb_ensure(VALUE (*b_proc)(ANYARGS), VALUE data1, VALUE (*e_proc)(ANYARGS), VALUE
|
|||
}
|
||||
|
||||
static ID
|
||||
frame_func_id(rb_control_frame_t *cfp)
|
||||
frame_func_id(const rb_control_frame_t *cfp)
|
||||
{
|
||||
const rb_callable_method_entry_t *me = rb_vm_frame_method_entry(cfp);
|
||||
|
||||
|
@ -1158,13 +1158,13 @@ prev_frame_func(void)
|
|||
ID
|
||||
rb_frame_last_func(void)
|
||||
{
|
||||
rb_thread_t *th = GET_THREAD();
|
||||
rb_control_frame_t *cfp = th->ec->cfp;
|
||||
const rb_execution_context_t *ec = GET_EC();
|
||||
const rb_control_frame_t *cfp = ec->cfp;
|
||||
ID mid;
|
||||
|
||||
while (!(mid = frame_func_id(cfp)) &&
|
||||
(cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp),
|
||||
!RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th, cfp)));
|
||||
!RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(ec, cfp)));
|
||||
return mid;
|
||||
}
|
||||
|
||||
|
@ -1722,10 +1722,10 @@ top_using(VALUE self, VALUE module)
|
|||
}
|
||||
|
||||
static const VALUE *
|
||||
errinfo_place(rb_thread_t *th)
|
||||
errinfo_place(const rb_thread_t *th)
|
||||
{
|
||||
rb_control_frame_t *cfp = th->ec->cfp;
|
||||
rb_control_frame_t *end_cfp = RUBY_VM_END_CONTROL_FRAME(th);
|
||||
const rb_control_frame_t *cfp = th->ec->cfp;
|
||||
const rb_control_frame_t *end_cfp = RUBY_VM_END_CONTROL_FRAME(th->ec);
|
||||
|
||||
while (RUBY_VM_VALID_CONTROL_FRAME_P(cfp, end_cfp)) {
|
||||
if (VM_FRAME_RUBYFRAME_P(cfp)) {
|
||||
|
|
4
proc.c
4
proc.c
|
@ -749,7 +749,7 @@ proc_new(VALUE klass, int8_t is_lambda)
|
|||
|
||||
case block_handler_type_ifunc:
|
||||
case block_handler_type_iseq:
|
||||
return rb_vm_make_proc_lambda(th, VM_BH_TO_CAPT_BLOCK(block_handler), klass, is_lambda);
|
||||
return rb_vm_make_proc_lambda(th->ec, VM_BH_TO_CAPT_BLOCK(block_handler), klass, is_lambda);
|
||||
}
|
||||
VM_UNREACHABLE(proc_new);
|
||||
return Qnil;
|
||||
|
@ -1923,7 +1923,7 @@ rb_mod_define_method(int argc, VALUE *argv, VALUE mod)
|
|||
break;
|
||||
case block_handler_type_iseq:
|
||||
case block_handler_type_ifunc:
|
||||
body = rb_vm_make_proc_lambda(th, VM_BH_TO_CAPT_BLOCK(block_handler), rb_cProc, TRUE);
|
||||
body = rb_vm_make_proc_lambda(th->ec, VM_BH_TO_CAPT_BLOCK(block_handler), rb_cProc, TRUE);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
84
vm.c
84
vm.c
|
@ -38,7 +38,7 @@ rb_vm_search_cf_from_ep(const rb_thread_t * const th, const rb_control_frame_t *
|
|||
return NULL;
|
||||
}
|
||||
else {
|
||||
const rb_control_frame_t * const eocfp = RUBY_VM_END_CONTROL_FRAME(th); /* end of control frame pointer */
|
||||
const rb_control_frame_t * const eocfp = RUBY_VM_END_CONTROL_FRAME(th->ec); /* end of control frame pointer */
|
||||
|
||||
while (cfp < eocfp) {
|
||||
if (cfp->ep == ep) {
|
||||
|
@ -290,7 +290,7 @@ static void vm_collect_usage_insn(int insn);
|
|||
static void vm_collect_usage_register(int reg, int isset);
|
||||
#endif
|
||||
|
||||
static VALUE vm_make_env_object(rb_thread_t *th, rb_control_frame_t *cfp);
|
||||
static VALUE vm_make_env_object(const rb_execution_context_t *ec, rb_control_frame_t *cfp);
|
||||
|
||||
static VALUE vm_invoke_bmethod(rb_thread_t *th, rb_proc_t *proc, VALUE self,
|
||||
int argc, const VALUE *argv, VALUE block_handler);
|
||||
|
@ -480,14 +480,14 @@ vm_set_main_stack(rb_thread_t *th, const rb_iseq_t *iseq)
|
|||
|
||||
/* save binding */
|
||||
if (iseq->body->local_table_size > 0) {
|
||||
vm_bind_update_env(toplevel_binding, bind, vm_make_env_object(th, th->ec->cfp));
|
||||
vm_bind_update_env(toplevel_binding, bind, vm_make_env_object(th->ec, th->ec->cfp));
|
||||
}
|
||||
}
|
||||
|
||||
rb_control_frame_t *
|
||||
rb_vm_get_binding_creatable_next_cfp(const rb_thread_t *th, const rb_control_frame_t *cfp)
|
||||
{
|
||||
while (!RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th, cfp)) {
|
||||
while (!RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th->ec, cfp)) {
|
||||
if (cfp->iseq) {
|
||||
return (rb_control_frame_t *)cfp;
|
||||
}
|
||||
|
@ -497,9 +497,10 @@ rb_vm_get_binding_creatable_next_cfp(const rb_thread_t *th, const rb_control_fra
|
|||
}
|
||||
|
||||
rb_control_frame_t *
|
||||
rb_vm_get_ruby_level_next_cfp(const rb_thread_t *th, const rb_control_frame_t *cfp)
|
||||
rb_vm_get_ruby_level_next_cfp(const rb_execution_context_t *ec, const rb_control_frame_t *cfp)
|
||||
{
|
||||
while (!RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th, cfp)) {
|
||||
if (RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(ec, cfp)) bp();
|
||||
while (!RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(ec, cfp)) {
|
||||
if (VM_FRAME_RUBYFRAME_P(cfp)) {
|
||||
return (rb_control_frame_t *)cfp;
|
||||
}
|
||||
|
@ -517,7 +518,7 @@ vm_get_ruby_level_caller_cfp(const rb_thread_t *th, const rb_control_frame_t *cf
|
|||
|
||||
cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
|
||||
|
||||
while (!RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th, cfp)) {
|
||||
while (!RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th->ec, cfp)) {
|
||||
if (VM_FRAME_RUBYFRAME_P(cfp)) {
|
||||
return (rb_control_frame_t *)cfp;
|
||||
}
|
||||
|
@ -616,12 +617,12 @@ check_env_value(const rb_env_t *env)
|
|||
}
|
||||
|
||||
static void
|
||||
vm_block_handler_escape(rb_thread_t *th, VALUE block_handler, VALUE *procvalptr)
|
||||
vm_block_handler_escape(const rb_execution_context_t *ec, VALUE block_handler, VALUE *procvalptr)
|
||||
{
|
||||
switch (vm_block_handler_type(block_handler)) {
|
||||
case block_handler_type_ifunc:
|
||||
case block_handler_type_iseq:
|
||||
*procvalptr = rb_vm_make_proc(th, VM_BH_TO_CAPT_BLOCK(block_handler), rb_cProc);
|
||||
*procvalptr = rb_vm_make_proc(ec, VM_BH_TO_CAPT_BLOCK(block_handler), rb_cProc);
|
||||
return;
|
||||
|
||||
case block_handler_type_symbol:
|
||||
|
@ -634,7 +635,7 @@ vm_block_handler_escape(rb_thread_t *th, VALUE block_handler, VALUE *procvalptr)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
vm_make_env_each(rb_thread_t *const th, rb_control_frame_t *const cfp)
|
||||
vm_make_env_each(const rb_execution_context_t * const ec, rb_control_frame_t *const cfp)
|
||||
{
|
||||
VALUE blockprocval = Qfalse;
|
||||
const VALUE * const ep = cfp->ep;
|
||||
|
@ -658,7 +659,7 @@ vm_make_env_each(rb_thread_t *const th, rb_control_frame_t *const cfp)
|
|||
VM_ASSERT(prev_cfp->ep != NULL);
|
||||
}
|
||||
|
||||
vm_make_env_each(th, prev_cfp);
|
||||
vm_make_env_each(ec, prev_cfp);
|
||||
VM_FORCE_WRITE_SPECIAL_CONST(&ep[VM_ENV_DATA_INDEX_SPECVAL], VM_GUARDED_PREV_EP(prev_cfp->ep));
|
||||
}
|
||||
}
|
||||
|
@ -666,7 +667,7 @@ vm_make_env_each(rb_thread_t *const th, rb_control_frame_t *const cfp)
|
|||
VALUE block_handler = VM_ENV_BLOCK_HANDLER(ep);
|
||||
|
||||
if (block_handler != VM_BLOCK_HANDLER_NONE) {
|
||||
vm_block_handler_escape(th, block_handler, &blockprocval);
|
||||
vm_block_handler_escape(ec, block_handler, &blockprocval);
|
||||
VM_STACK_ENV_WRITE(ep, VM_ENV_DATA_INDEX_SPECVAL, blockprocval);
|
||||
}
|
||||
}
|
||||
|
@ -718,9 +719,9 @@ vm_make_env_each(rb_thread_t *const th, rb_control_frame_t *const cfp)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
vm_make_env_object(rb_thread_t *th, rb_control_frame_t *cfp)
|
||||
vm_make_env_object(const rb_execution_context_t *ec, rb_control_frame_t *cfp)
|
||||
{
|
||||
VALUE envval = vm_make_env_each(th, cfp);
|
||||
VALUE envval = vm_make_env_each(ec, cfp);
|
||||
|
||||
if (PROCDEBUG) {
|
||||
check_env_value((const rb_env_t *)envval);
|
||||
|
@ -734,7 +735,7 @@ rb_vm_stack_to_heap(rb_thread_t *th)
|
|||
{
|
||||
rb_control_frame_t *cfp = th->ec->cfp;
|
||||
while ((cfp = rb_vm_get_binding_creatable_next_cfp(th, cfp)) != 0) {
|
||||
vm_make_env_object(th, cfp);
|
||||
vm_make_env_object(th->ec, cfp);
|
||||
cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
|
||||
}
|
||||
}
|
||||
|
@ -867,27 +868,27 @@ rb_proc_create(VALUE klass, const struct rb_block *block,
|
|||
}
|
||||
|
||||
VALUE
|
||||
rb_vm_make_proc(rb_thread_t *th, const struct rb_captured_block *captured, VALUE klass)
|
||||
rb_vm_make_proc(const rb_execution_context_t *ec, const struct rb_captured_block *captured, VALUE klass)
|
||||
{
|
||||
return rb_vm_make_proc_lambda(th, captured, klass, FALSE);
|
||||
return rb_vm_make_proc_lambda(ec, captured, klass, FALSE);
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_vm_make_proc_lambda(rb_thread_t *th, const struct rb_captured_block *captured, VALUE klass, int8_t is_lambda)
|
||||
rb_vm_make_proc_lambda(const rb_execution_context_t *ec, const struct rb_captured_block *captured, VALUE klass, int8_t is_lambda)
|
||||
{
|
||||
VALUE procval;
|
||||
|
||||
if (!VM_ENV_ESCAPED_P(captured->ep)) {
|
||||
rb_control_frame_t *cfp = VM_CAPTURED_BLOCK_TO_CFP(captured);
|
||||
vm_make_env_object(th, cfp);
|
||||
vm_make_env_object(ec, cfp);
|
||||
}
|
||||
VM_ASSERT(VM_EP_IN_HEAP_P(th->ec, captured->ep));
|
||||
VM_ASSERT(VM_EP_IN_HEAP_P(ec, captured->ep));
|
||||
VM_ASSERT(imemo_type_p(captured->code.val, imemo_iseq) ||
|
||||
imemo_type_p(captured->code.val, imemo_ifunc));
|
||||
|
||||
procval = rb_proc_create_from_captured(klass, captured,
|
||||
imemo_type(captured->code.val) == imemo_iseq ? block_type_iseq : block_type_ifunc,
|
||||
(int8_t)th->ec->safe_level, FALSE, is_lambda);
|
||||
(int8_t)ec->safe_level, FALSE, is_lambda);
|
||||
return procval;
|
||||
}
|
||||
|
||||
|
@ -897,7 +898,7 @@ VALUE
|
|||
rb_vm_make_binding(rb_thread_t *th, const rb_control_frame_t *src_cfp)
|
||||
{
|
||||
rb_control_frame_t *cfp = rb_vm_get_binding_creatable_next_cfp(th, src_cfp);
|
||||
rb_control_frame_t *ruby_level_cfp = rb_vm_get_ruby_level_next_cfp(th, src_cfp);
|
||||
rb_control_frame_t *ruby_level_cfp = rb_vm_get_ruby_level_next_cfp(th->ec, src_cfp);
|
||||
VALUE bindval, envval;
|
||||
rb_binding_t *bind;
|
||||
|
||||
|
@ -906,7 +907,7 @@ rb_vm_make_binding(rb_thread_t *th, const rb_control_frame_t *src_cfp)
|
|||
}
|
||||
|
||||
while (1) {
|
||||
envval = vm_make_env_object(th, cfp);
|
||||
envval = vm_make_env_object(th->ec, cfp);
|
||||
if (cfp == ruby_level_cfp) {
|
||||
break;
|
||||
}
|
||||
|
@ -961,7 +962,7 @@ rb_binding_add_dynavars(VALUE bindval, rb_binding_t *bind, int dyncount, const I
|
|||
ALLOCV_END(idtmp);
|
||||
|
||||
vm_set_eval_stack(th, iseq, 0, base_block);
|
||||
vm_bind_update_env(bindval, bind, envval = vm_make_env_object(th, th->ec->cfp));
|
||||
vm_bind_update_env(bindval, bind, envval = vm_make_env_object(th->ec, th->ec->cfp));
|
||||
rb_vm_pop_frame(th);
|
||||
|
||||
env = (const rb_env_t *)envval;
|
||||
|
@ -1193,7 +1194,7 @@ vm_normal_frame(rb_thread_t *th, rb_control_frame_t *cfp)
|
|||
{
|
||||
while (cfp->pc == 0) {
|
||||
cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
|
||||
if (RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th, cfp)) {
|
||||
if (RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th->ec, cfp)) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -1257,8 +1258,8 @@ rb_lastline_set(VALUE val)
|
|||
VALUE
|
||||
rb_sourcefilename(void)
|
||||
{
|
||||
rb_thread_t *th = GET_THREAD();
|
||||
rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(th, th->ec->cfp);
|
||||
const rb_execution_context_t *ec = GET_EC();
|
||||
const rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(ec, ec->cfp);
|
||||
|
||||
if (cfp) {
|
||||
return rb_iseq_path(cfp->iseq);
|
||||
|
@ -1271,8 +1272,8 @@ rb_sourcefilename(void)
|
|||
const char *
|
||||
rb_sourcefile(void)
|
||||
{
|
||||
rb_thread_t *th = GET_THREAD();
|
||||
rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(th, th->ec->cfp);
|
||||
const rb_execution_context_t *ec = GET_EC();
|
||||
const rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(ec, ec->cfp);
|
||||
|
||||
if (cfp) {
|
||||
return RSTRING_PTR(rb_iseq_path(cfp->iseq));
|
||||
|
@ -1285,8 +1286,8 @@ rb_sourcefile(void)
|
|||
int
|
||||
rb_sourceline(void)
|
||||
{
|
||||
rb_thread_t *th = GET_THREAD();
|
||||
rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(th, th->ec->cfp);
|
||||
const rb_execution_context_t *ec = GET_EC();
|
||||
const rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(ec, ec->cfp);
|
||||
|
||||
if (cfp) {
|
||||
return rb_vm_get_sourceline(cfp);
|
||||
|
@ -1299,8 +1300,8 @@ rb_sourceline(void)
|
|||
VALUE
|
||||
rb_source_location(int *pline)
|
||||
{
|
||||
rb_thread_t *th = GET_THREAD();
|
||||
rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(th, th->ec->cfp);
|
||||
const rb_execution_context_t *ec = GET_EC();
|
||||
const rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(ec, ec->cfp);
|
||||
|
||||
if (cfp) {
|
||||
if (pline) *pline = rb_vm_get_sourceline(cfp);
|
||||
|
@ -1323,21 +1324,20 @@ rb_source_loc(int *pline)
|
|||
rb_cref_t *
|
||||
rb_vm_cref(void)
|
||||
{
|
||||
rb_thread_t *th = GET_THREAD();
|
||||
rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(th, th->ec->cfp);
|
||||
const rb_execution_context_t *ec = GET_EC();
|
||||
const rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(ec, ec->cfp);
|
||||
|
||||
if (cfp == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return rb_vm_get_cref(cfp->ep);
|
||||
}
|
||||
|
||||
rb_cref_t *
|
||||
rb_vm_cref_replace_with_duplicated_cref(void)
|
||||
{
|
||||
rb_thread_t *th = GET_THREAD();
|
||||
rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(th, th->ec->cfp);
|
||||
const rb_execution_context_t *ec = GET_EC();
|
||||
const rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(ec, ec->cfp);
|
||||
rb_cref_t *cref = vm_cref_replace_with_duplicated_cref(cfp->ep);
|
||||
return cref;
|
||||
}
|
||||
|
@ -1345,8 +1345,8 @@ rb_vm_cref_replace_with_duplicated_cref(void)
|
|||
const rb_cref_t *
|
||||
rb_vm_cref_in_context(VALUE self, VALUE cbase)
|
||||
{
|
||||
rb_thread_t *th = GET_THREAD();
|
||||
const rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(th, th->ec->cfp);
|
||||
const rb_execution_context_t *ec = GET_EC();
|
||||
const rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(ec, ec->cfp);
|
||||
const rb_cref_t *cref;
|
||||
if (cfp->self != self) return NULL;
|
||||
if (!vm_env_cref_by_cref(cfp->ep)) return NULL;
|
||||
|
@ -1370,8 +1370,8 @@ debug_cref(rb_cref_t *cref)
|
|||
VALUE
|
||||
rb_vm_cbase(void)
|
||||
{
|
||||
rb_thread_t *th = GET_THREAD();
|
||||
rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(th, th->ec->cfp);
|
||||
const rb_execution_context_t *ec = GET_EC();
|
||||
const rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(ec, ec->cfp);
|
||||
|
||||
if (cfp == 0) {
|
||||
rb_raise(rb_eRuntimeError, "Can't call on top of Fiber or Thread");
|
||||
|
|
|
@ -427,9 +427,9 @@ backtrace_each(rb_thread_t *th,
|
|||
void (*iter_cfunc)(void *arg, const rb_control_frame_t *cfp, ID mid),
|
||||
void *arg)
|
||||
{
|
||||
rb_control_frame_t *last_cfp = th->ec->cfp;
|
||||
rb_control_frame_t *start_cfp = RUBY_VM_END_CONTROL_FRAME(th);
|
||||
rb_control_frame_t *cfp;
|
||||
const rb_control_frame_t *last_cfp = th->ec->cfp;
|
||||
const rb_control_frame_t *start_cfp = RUBY_VM_END_CONTROL_FRAME(th->ec);
|
||||
const rb_control_frame_t *cfp;
|
||||
ptrdiff_t size, i;
|
||||
|
||||
/* <- start_cfp (end control frame)
|
||||
|
@ -1246,8 +1246,8 @@ int
|
|||
rb_profile_frames(int start, int limit, VALUE *buff, int *lines)
|
||||
{
|
||||
int i;
|
||||
rb_thread_t *th = GET_THREAD();
|
||||
rb_control_frame_t *cfp = th->ec->cfp, *end_cfp = RUBY_VM_END_CONTROL_FRAME(th);
|
||||
const rb_execution_context_t *ec = GET_EC();
|
||||
const rb_control_frame_t *cfp = ec->cfp, *end_cfp = RUBY_VM_END_CONTROL_FRAME(ec);
|
||||
const rb_callable_method_entry_t *cme;
|
||||
|
||||
for (i=0; i<limit && cfp != end_cfp;) {
|
||||
|
|
23
vm_core.h
23
vm_core.h
|
@ -1238,12 +1238,21 @@ VALUE rb_vm_frame_block_handler(const rb_control_frame_t *cfp);
|
|||
|
||||
#define RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp) ((cfp)+1)
|
||||
#define RUBY_VM_NEXT_CONTROL_FRAME(cfp) ((cfp)-1)
|
||||
#define RUBY_VM_END_CONTROL_FRAME(th) \
|
||||
((rb_control_frame_t *)((th)->ec->vm_stack + (th)->ec->vm_stack_size))
|
||||
|
||||
#define RUBY_VM_VALID_CONTROL_FRAME_P(cfp, ecfp) \
|
||||
((void *)(ecfp) > (void *)(cfp))
|
||||
#define RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th, cfp) \
|
||||
(!RUBY_VM_VALID_CONTROL_FRAME_P((cfp), RUBY_VM_END_CONTROL_FRAME(th)))
|
||||
|
||||
static inline const rb_control_frame_t *
|
||||
RUBY_VM_END_CONTROL_FRAME(const rb_execution_context_t *ec)
|
||||
{
|
||||
return (rb_control_frame_t *)(ec->vm_stack + ec->vm_stack_size);
|
||||
}
|
||||
|
||||
static inline int
|
||||
RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(const rb_execution_context_t *ec, const rb_control_frame_t *cfp)
|
||||
{
|
||||
return !RUBY_VM_VALID_CONTROL_FRAME_P(cfp, RUBY_VM_END_CONTROL_FRAME(ec));
|
||||
}
|
||||
|
||||
static inline int
|
||||
VM_BH_ISEQ_BLOCK_P(VALUE block_handler)
|
||||
|
@ -1490,8 +1499,8 @@ void rb_iseq_pathobj_set(const rb_iseq_t *iseq, VALUE path, VALUE realpath);
|
|||
int rb_thread_method_id_and_class(rb_thread_t *th, ID *idp, ID *called_idp, VALUE *klassp);
|
||||
|
||||
VALUE rb_vm_invoke_proc(rb_thread_t *th, rb_proc_t *proc, int argc, const VALUE *argv, VALUE block_handler);
|
||||
VALUE rb_vm_make_proc_lambda(rb_thread_t *th, const struct rb_captured_block *captured, VALUE klass, int8_t is_lambda);
|
||||
VALUE rb_vm_make_proc(rb_thread_t *th, const struct rb_captured_block *captured, VALUE klass);
|
||||
VALUE rb_vm_make_proc_lambda(const rb_execution_context_t *ec, const struct rb_captured_block *captured, VALUE klass, int8_t is_lambda);
|
||||
VALUE rb_vm_make_proc(const rb_execution_context_t *ec, const struct rb_captured_block *captured, VALUE klass);
|
||||
VALUE rb_vm_make_binding(rb_thread_t *th, const rb_control_frame_t *src_cfp);
|
||||
VALUE rb_vm_env_local_variables(const rb_env_t *env);
|
||||
const rb_env_t *rb_vm_env_prev_env(const rb_env_t *env);
|
||||
|
@ -1530,7 +1539,7 @@ rb_vm_living_threads_remove(rb_vm_t *vm, rb_thread_t *th)
|
|||
}
|
||||
|
||||
typedef int rb_backtrace_iter_func(void *, VALUE, int, VALUE);
|
||||
rb_control_frame_t *rb_vm_get_ruby_level_next_cfp(const rb_thread_t *th, const rb_control_frame_t *cfp);
|
||||
rb_control_frame_t *rb_vm_get_ruby_level_next_cfp(const rb_execution_context_t *ec, const rb_control_frame_t *cfp);
|
||||
rb_control_frame_t *rb_vm_get_binding_creatable_next_cfp(const rb_thread_t *th, const rb_control_frame_t *cfp);
|
||||
int rb_vm_get_sourceline(const rb_control_frame_t *);
|
||||
VALUE rb_name_err_mesg_new(VALUE mesg, VALUE recv, VALUE method);
|
||||
|
|
|
@ -851,7 +851,7 @@ static VALUE *
|
|||
current_vm_stack_arg(rb_thread_t *th, const VALUE *argv)
|
||||
{
|
||||
rb_control_frame_t *prev_cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(th->ec->cfp);
|
||||
if (RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th, prev_cfp)) return NULL;
|
||||
if (RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th->ec, prev_cfp)) return NULL;
|
||||
if (prev_cfp->sp + 1 != argv) return NULL;
|
||||
return prev_cfp->sp + 1;
|
||||
}
|
||||
|
@ -1296,7 +1296,7 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, rb_cref_t *const cref_
|
|||
base_block = &bind->block;
|
||||
}
|
||||
else {
|
||||
rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(th, th->ec->cfp);
|
||||
rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(th->ec, th->ec->cfp);
|
||||
|
||||
if (cfp != 0) {
|
||||
block.as.captured = *VM_CFP_TO_CAPTURED_BLOCK(cfp);
|
||||
|
@ -1340,7 +1340,7 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, rb_cref_t *const cref_
|
|||
|
||||
/* save new env */
|
||||
if (bind && iseq->body->local_table_size > 0) {
|
||||
vm_bind_update_env(scope, bind, vm_make_env_object(th, th->ec->cfp));
|
||||
vm_bind_update_env(scope, bind, vm_make_env_object(th->ec, th->ec->cfp));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -369,7 +369,7 @@ rb_vm_bh_to_procval(rb_thread_t *th, VALUE block_handler)
|
|||
switch (vm_block_handler_type(block_handler)) {
|
||||
case block_handler_type_iseq:
|
||||
case block_handler_type_ifunc:
|
||||
return rb_vm_make_proc(th, VM_BH_TO_CAPT_BLOCK(block_handler), rb_cProc);
|
||||
return rb_vm_make_proc(th->ec, VM_BH_TO_CAPT_BLOCK(block_handler), rb_cProc);
|
||||
case block_handler_type_symbol:
|
||||
return rb_sym_to_proc(VM_BH_TO_SYMBOL(block_handler));
|
||||
case block_handler_type_proc:
|
||||
|
@ -1085,7 +1085,7 @@ vm_throw_start(rb_thread_t *const th, rb_control_frame_t *const reg_cfp, enum ru
|
|||
const int flag, const rb_num_t level, const VALUE throwobj)
|
||||
{
|
||||
const rb_control_frame_t *escape_cfp = NULL;
|
||||
const rb_control_frame_t * const eocfp = RUBY_VM_END_CONTROL_FRAME(th); /* end of control frame pointer */
|
||||
const rb_control_frame_t * const eocfp = RUBY_VM_END_CONTROL_FRAME(th->ec); /* end of control frame pointer */
|
||||
|
||||
if (flag != 0) {
|
||||
/* do nothing */
|
||||
|
@ -2160,7 +2160,7 @@ current_method_entry(rb_thread_t *th, rb_control_frame_t *cfp)
|
|||
|
||||
do {
|
||||
cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
|
||||
if (RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th, cfp)) {
|
||||
if (RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th->ec, cfp)) {
|
||||
/* TODO: orphan block */
|
||||
return top_cfp;
|
||||
}
|
||||
|
@ -2528,7 +2528,7 @@ vm_block_handler_to_proc(rb_thread_t *th, VALUE block_handler)
|
|||
break;
|
||||
case block_handler_type_iseq:
|
||||
case block_handler_type_ifunc:
|
||||
blockarg = rb_vm_make_proc(th, VM_BH_TO_CAPT_BLOCK(block_handler), rb_cProc);
|
||||
blockarg = rb_vm_make_proc(th->ec, VM_BH_TO_CAPT_BLOCK(block_handler), rb_cProc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -2772,8 +2772,8 @@ vm_invoke_block(rb_thread_t *th, rb_control_frame_t *reg_cfp, struct rb_calling_
|
|||
static VALUE
|
||||
vm_make_proc_with_iseq(const rb_iseq_t *blockiseq)
|
||||
{
|
||||
rb_thread_t *th = GET_THREAD();
|
||||
const rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(th, th->ec->cfp);
|
||||
const rb_execution_context_t *ec = GET_EC();
|
||||
const rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(ec, ec->cfp);
|
||||
struct rb_captured_block *captured;
|
||||
|
||||
if (cfp == 0) {
|
||||
|
@ -2783,7 +2783,7 @@ vm_make_proc_with_iseq(const rb_iseq_t *blockiseq)
|
|||
captured = VM_CFP_TO_CAPTURED_BLOCK(cfp);
|
||||
captured->code.iseq = blockiseq;
|
||||
|
||||
return rb_vm_make_proc(th, captured, rb_cProc);
|
||||
return rb_vm_make_proc(ec, captured, rb_cProc);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
|
10
vm_method.c
10
vm_method.c
|
@ -264,7 +264,7 @@ method_definition_set(const rb_method_entry_t *me, rb_method_definition_t *def,
|
|||
|
||||
def->body.attr.id = (ID)(VALUE)opts;
|
||||
|
||||
cfp = rb_vm_get_ruby_level_next_cfp(th, th->ec->cfp);
|
||||
cfp = rb_vm_get_ruby_level_next_cfp(th->ec, th->ec->cfp);
|
||||
|
||||
if (cfp && (line = rb_vm_get_sourceline(cfp))) {
|
||||
VALUE location = rb_ary_new3(2, rb_iseq_path(cfp->iseq), INT2FIX(line));
|
||||
|
@ -1088,8 +1088,8 @@ rb_method_boundp(VALUE klass, ID id, int ex)
|
|||
static rb_method_visibility_t
|
||||
rb_scope_visibility_get(void)
|
||||
{
|
||||
rb_thread_t *th = GET_THREAD();
|
||||
rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(th, th->ec->cfp);
|
||||
const rb_execution_context_t *ec = GET_EC();
|
||||
const rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(ec, ec->cfp);
|
||||
|
||||
if (!vm_env_cref_by_cref(cfp->ep)) {
|
||||
return METHOD_VISI_PUBLIC;
|
||||
|
@ -1102,8 +1102,8 @@ rb_scope_visibility_get(void)
|
|||
static int
|
||||
rb_scope_module_func_check(void)
|
||||
{
|
||||
rb_thread_t *th = GET_THREAD();
|
||||
rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(th, th->ec->cfp);
|
||||
const rb_execution_context_t *ec = GET_EC();
|
||||
const rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(ec, ec->cfp);
|
||||
|
||||
if (!vm_env_cref_by_cref(cfp->ep)) {
|
||||
return FALSE;
|
||||
|
|
|
@ -735,7 +735,7 @@ static void
|
|||
fill_path_and_lineno(rb_trace_arg_t *trace_arg)
|
||||
{
|
||||
if (trace_arg->path == Qundef) {
|
||||
rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(trace_arg->th, trace_arg->cfp);
|
||||
rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(trace_arg->th->ec, trace_arg->cfp);
|
||||
|
||||
if (cfp) {
|
||||
trace_arg->path = rb_iseq_path(cfp->iseq);
|
||||
|
|
Loading…
Reference in a new issue