From 2b5bb8a0875b75f18e628c8b2df22760536bdad9 Mon Sep 17 00:00:00 2001 From: ko1 Date: Fri, 5 Apr 2019 08:15:11 +0000 Subject: add definemethod/definesmethod insn. * insns.def: add definemethod and definesmethod (singleton method) instructions. Old YARV contains these instructions, but it is moved to methods of FrozenCore class because remove number of instructions can improve performance for some techniques (static stack caching and so on). However, we don't employ these technique and it is hard to optimize/analysis definition sequence. So I decide to introduce them (and remove definition methods). `putiseq` insn is also removed. * vm_method.c (rb_scope_visibility_get): renamed to `vm_scope_visibility_get()` and make it accept `ec`. Same for `vm_scope_module_func_check()`. These fixes are result of refactoring `vm_define_method`. * vm_insnhelper.c (rb_vm_get_cref): renamed to `vm_get_cref` because of consistency with other functions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67442 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- vm_method.c | 35 ++++------------------------------- 1 file changed, 4 insertions(+), 31 deletions(-) (limited to 'vm_method.c') diff --git a/vm_method.c b/vm_method.c index 9d4e25e05b..3a9dfc1c5d 100644 --- a/vm_method.c +++ b/vm_method.c @@ -669,7 +669,7 @@ rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *opts, rb_method_ return me; } -void +MJIT_FUNC_EXPORTED void rb_add_method_iseq(VALUE klass, ID mid, const rb_iseq_t *iseq, rb_cref_t *cref, rb_method_visibility_t visi) { struct { /* should be same fields with rb_method_iseq_struct */ @@ -1117,34 +1117,6 @@ rb_method_boundp(VALUE klass, ID id, int ex) return 0; } -static rb_method_visibility_t -rb_scope_visibility_get(void) -{ - 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; - } - else { - return CREF_SCOPE_VISI(rb_vm_cref())->method_visi; - } -} - -static int -rb_scope_module_func_check(void) -{ - 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; - } - else { - return CREF_SCOPE_VISI(rb_vm_cref())->module_func; - } -} - static void vm_cref_set_visibility(rb_method_visibility_t method_visi, int module_func) { @@ -1170,14 +1142,15 @@ rb_attr(VALUE klass, ID id, int read, int write, int ex) { ID attriv; rb_method_visibility_t visi; + const rb_execution_context_t *ec = GET_EC(); if (!ex) { visi = METHOD_VISI_PUBLIC; } else { - switch (rb_scope_visibility_get()) { + switch (vm_scope_visibility_get(ec)) { case METHOD_VISI_PRIVATE: - if (rb_scope_module_func_check()) { + if (vm_scope_module_func_check(ec)) { rb_warning("attribute accessor as module_function"); } visi = METHOD_VISI_PRIVATE; -- cgit v1.2.3