summaryrefslogtreecommitdiff
path: root/iseq.c
AgeCommit message (Collapse)Author
2015-09-27fronzen-string-literal pragmanobu
* compile.c (iseq_compile_each): override compile option by option given by pragma. * iseq.c (rb_iseq_make_compile_option): extract a function to overwrite rb_compile_option_t. * parse.y (parser_set_compile_option_flag): introduce pragma to override compile options. * parse.y (magic_comments): new pragma "fronzen-string-literal". [Feature #8976] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51953 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-19* iseq.c (rb_iseq_free): free rb_iseq_t::body::cc_entries.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51904 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-19* vm_core.h: split rb_call_info_t into several structs.ko1
* rb_call_info (ci) has compiled fixed information. * if ci->flag & VM_CALL_KWARG, then rb_call_info is also rb_call_info_with_kwarg. This technique reduce one word for major rb_call_info data. * rb_calling_info has temporary data (argc, blockptr, recv). for each method dispatch. This data is allocated only on machine stack. * rb_call_cache is for inline method cache. Before this patch, only rb_call_info_t data is passed. After this patch, above three structs are passed. This patch improves: * data locarity (rb_call_info is now read-only data). * reduce memory consumption (rb_call_info_with_kwarg, rb_calling_info). * compile.c: use above data. * insns.def: ditto. * iseq.c: ditto. * vm_args.c: ditto. * vm_eval.c: ditto. * vm_insnhelper.c: ditto. * vm_insnhelper.h: ditto. * iseq.h: add iseq_compile_data::ci_index and iseq_compile_data::ci_kw_indx. * tool/instruction.rb: introduce TS_CALLCACHE operand type. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51903 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-11* iseq.c: disable ISeq.load. It enabled accidentally at r51794.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-08* vm_core.h: remove rb_call_info_t::blockiseq.ko1
* insns.def (send, invokesuper): pass blockiseq explicitly. * compile.c: catch up this fix. * iseq.c: ditto. * vm_args.c: ditto. * iseq.c (ISEQ_MINOR_VERSION): 2->3 because instruction spec was changed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51794 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-03* iseq.c (iseq_memsize): functions for wrapper object should haveko1
iseqw_ prefix. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51755 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-21* vm_opts.h, iseq.c, iseq.h: add compile option to force frozenko1
string literals. [Feature #11473] This addition is not specification change, but to try frozen string literal world discussed on [Feature #11473]. You can try frozen string literal world using this magical line: RubyVM::InstructionSequence.compile_option = {frozen_string_literal: true} Note that this is a global compilation option, so that you need to compile another script like that: p 'foo'.frozen? #=> false RubyVM::InstructionSequence.compile_option = {frozen_string_literal: true} p 'foo'.frozen? #=> false, because this line is already compiled. p eval("'foo'.frozen?") #=> true Details: * String literals are deduped by rb_fstring(). * Dynamic string literals ("...#{xyz}...") is now only frozen, not deduped. Maybe you have other ideas. Now, please do not use this option on your productions :) Of course, current specification can be changed. * compile.c: ditto. * test/ruby/test_iseq.rb: add a test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51659 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-14iseq.c (rb_iseq_mark): reduce NULL checksnormal
iseq_location_setup always sets path, label and base_label fields, and the only caller of iseq_location_setup (prepare_iseq_build) will always pass non-nil `name' and `path' arguments. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51581 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-12iseq.c (iseq_memsize): reimplement for wrappernormal
* iseq.c (iseq_memsize): reimplement for wrapper (param_keyword_size): extracted from iseq_memsize (iseqw_mark): new mark function (iseqw_data_type): new data type (iseqw_new): wrap as iseqw_data_type (iseqw_check): adjust for wrapper (Init_ISeq): remove iseqw_iseq_key initialization * test/objspace/test_objspace.rb: new test [ruby-core:70344] [Feature #11435] v2 changes: - added RUBY_TYPED_WB_PROTECTED and write barrier - account for rb_call_info_kw_arg_t entries git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51547 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-25iseq.c: fix typenobu
* iseq.c (rb_iseq_disasm, iseq_data_to_ary): fix loop counter type for array length. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51373 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-24* vm_core.h: size should be unsigned.ko1
* rb_call_info_t::index * rb_iseq_constant_body::stack_max * rb_iseq_constant_body::local_size * rb_iseq_constant_body::param::size * rb_iseq_constant_body::local_table_size * rb_iseq_constant_body::is_size * rb_iseq_constant_body::callinfo_size * iseq.h: same for iseq_catch_table::size. * compile.c: catch up these fix. * iseq.c: ditto. * proc.c: ditto. * vm.c: ditto. * vm_args.c: ditto. * vm_eval.c: ditto. * vm_insnhelper.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51369 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-24* vm_core.h: constify rb_iseq_constant_body::line_info_table.ko1
* iseq.c: catch up this fix. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51368 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-24* vm_core.h: constify rb_iseq_constant_body::catch_table.ko1
* compile.c (iseq_set_exception_table): catch up this fix. * iseq.c: ditto. * vm.c (vm_exec): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51365 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-23* vm_core.h: constify rb_iseq_constant_body::local_table andko1
rb_iseq_param_keyword::table and rb_iseq_param_keyword::default_values. * compile.c: catch up this fix. * iseq.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-23* vm_core.h: constify rb_iseq_constant_body::iseq_encoded andko1
rb_control_frame_t::pc. * compile.c (rb_iseq_translate_threaded_code): catch up this fix. * iseq.c: ditto. * vm_exec.c (vm_exec_core): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51356 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-22* vm_core.h: separate rb_iseq_body into rb_iseq_constant_body andko1
rb_iseq_variable_body (rb_iseq_t::variable_body). rb_iseq_variable_body can be modified after compilation. * compile.c: use rb_iseq_t::variable_body. * iseq.c: ditto. * thread.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51339 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-21* make rb_iseq_t T_IMEMO object (type is imemo_iseq).ko1
All contents of previous rb_iseq_t is in rb_iseq_t::body. Remove rb_iseq_t::self because rb_iseq_t is an object. RubyVM::InstructionSequence is wrapper object points T_IMEMO/iseq. So RubyVM::ISeq.of(something) method returns different wrapper objects but they point the same T_IMEMO/iseq object. This patch is big, but most of difference is replacement of iseq->xxx to iseq->body->xxx. (previous) rb_iseq_t::compile_data is also located to rb_iseq_t::compile_data. It was moved from rb_iseq_body::compile_data. Now rb_iseq_t has empty two pointers. I will split rb_iseq_body data into static data and dynamic data. * compile.c: rename some functions/macros. Now, we don't need to separate iseq and iseqval (only VALUE). * eval.c (ruby_exec_internal): `n' is rb_iseq_t (T_IMEMO/iseq). * ext/objspace/objspace.c (count_imemo_objects): count T_IMEMO/iseq. * gc.c: check T_IMEMO/iseq. * internal.h: add imemo_type::imemo_iseq. * iseq.c: define RubyVM::InstructionSequnce as T_OBJECT. Methods are implemented by functions named iseqw_.... * load.c (rb_load_internal0): rb_iseq_new_top() returns rb_iseq_t (T_IMEMO/iesq). * method.h (rb_add_method_iseq): accept rb_iseq_t (T_IMEMO/iseq). * vm_core.h (GetISeqPtr): removed because it is not T_DATA now. * vm_core.h (struct rb_iseq_body): remove padding for [Bug #10037][ruby-core:63721]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51327 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-21* vm_core.h: constify rb_call_info_t::kw_arg,ko1
rb_control_frame_t::iseq and rb_control_frame_t::block_iseq. * iseq.c (iseq_free): catch up this fix. * vm.c: ditto. * vm_dump.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51325 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-21* vm_core.h: constify rb_call_info_t::blockiseq and rb_iseq_t::iseq.ko1
* vm.c, vm_insnhelper.c: catch up this fix. * iseq.c (iseq_data_to_ary): constify the first iseq parameter. * vm_insnhelper.c (vm_make_proc_with_iseq): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51323 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-21* compile.c: constify the first parameter (iseq).ko1
* iseq_add_mark_object() * iseq_add_mark_object_compile_time() * iseq.c, iseq.h (rb_iseq_add_mark_object): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51311 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-16avoid redundant GET_THREAD() callsnormal
This reduces binary size slightly on my 32-bit system: text data bss dec hex filename 2847705 12360 30632 2890697 2c1bc9 ruby.orig 2847641 12360 30632 2890633 2c1b89 ruby * iseq.c (rb_iseq_compile_with_option): reuse result of previous GET_THREAD() call * thread.c (thread_create_core): ditto (rb_mutex_trylock): ditto (rb_mutex_lock): ditto * process.c (rb_waitpid): avoid multiple eval from RUBY_VM_CHECK_INTS * thread.c (rb_thread_check_ints): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51273 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-16* vm_core.h: constify rb_iseq_t::parent_iseq.ko1
rb_iseq_t::local_iseq is not constant data because local_iseq::flip_cnt can be modified (commentted). * compile.c: catch up this fix. * iseq.c: ditto. * vm_insnhelper.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51269 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-16* iseq.c (rb_iseq_disasm): rename rb_iseq_t *iseqdat to iseqko1
and VALUE *iseq to code. * iseq.c (rb_iseq_disasm_insn): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51267 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-15remove redundant NULL check in mark functionsnormal
gc.c (gc_mark_children)only calls mark_func if the T_DATA ptr is non-NULL, so avoid redundantly checking for that in each mark function. * iseq.c (iseq_mark): remove check for data pointer * proc.c (binding_mark): ditto * vm.c (rb_thread_mark): ditto * vm_trace.c (tp_mark): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51252 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-07iseq.c (iseq_data_to_ary): dump kw_arg as symbolnormal
Fix RubyVM::InstructionSequence#to_a after r49517 Keywords were made symbols to fix [Bug #10831] [ruby-core:68031], so we should dump symbols as-is instead of attempting to convert them from IDs * iseq.c (iseq_data_to_ary): dump kw_arg as symbol * test/-ext-/iseq_load/test_iseq_load.rb: test kw_arg roundtrip [ruby-core:69891] [Bug #11338] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51190 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-07* vm_core.h: remove rb_iseq_t::orig because rb_iseq_clone()ko1
no longer exists. * iseq.c: don't use rb_iseq_t::orig. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51172 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-07* iseq.c, internal.h (rb_iseq_clone): removed because we don't need toko1
clone iseq any more. * class.c (clone_method): share iseq between cloned methods. All of method dependent information are able to refer from method entry. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51171 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-06* vm_core.h: remove rb_iseq_t::defined_method_id because it is notko1
needed. * eval.c (frame_func_id): simplify. rb_callable_method_entry_t has enough information. * eval.c (frame_called_id): ditto. * iseq.c (prepare_iseq_build): catch up this fix. * proc.c (rb_mod_define_method): ditto. * vm.c (vm_define_method): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51168 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-06* vm_core.h: remove rb_iseq_t::klass to reduce dynamic data.ko1
* internal.h, iseq.c (rb_iseq_klass): remove it because rb_iseq_t::klass is removed. * vm_insnhelper.c (vm_super_outside): do not see cfp->iseq, but check callable method entry on a frame. This fix simplify the logic to search super class. * test/ruby/test_method.rb: support super() from Proc. Now, [Bug #4881] and [Bug #3136] was solved. * proc.c (rb_mod_define_method): catch up this change. * vm.c (vm_define_method): ditto. * vm_backtrace.c (rb_profile_frames): now, each `frame' objects are rb_callable_method_entry_t data or iseq VALUEs. This fix introduce minor compatibility issue that rb_profile_frame_label() always returns rb_profile_frame_base_label(). * test/-ext-/debug/test_profile_frames.rb: catch up this change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51166 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-30move RB_GC_GUARD responsibility to rb_add_method_iseqnormal
This simplifies all the callers and makes code easier to use and review. I was confused about the need for RB_GC_GUARD in define_{aset,aref}_method of struct.c without reading rb_add_method_iseq. Likewise, do the same for rb_iseq_clone, where the GC guard only seems neccesary iff RGenGC is disabled. * vm_method.c (rb_add_method_iseq): add RB_GC_GUARD * class.c (clone_method): remove RB_GC_GUARD * struct.c (define_aref_method): ditto (define_aset_method): ditto * vm.c (vm_define_method): * iseq.c (rb_iseq_clone): add RB_GC_GUARD git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51079 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-21* iseq.c: constify.ko1
* iseq.h: ditto. * method.h: ditto. * proc.c: ditto. * vm_method.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50593 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-21* proc.c (rb_method_get_iseq): rename to rb_method_iseq.ko1
* iseq.c: catch up this fix. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50587 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-20* iseq.c (exception_type2symbol): show correct bug message.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50566 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-19iseq.c: check srouce typenobu
* iseq.c (rb_iseq_compile_with_option): check srouce type, must be an IO or a String. [ruby-core:69219] [Bug #11159] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50541 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-18* iseq.c (iseq_mark): skip some marking if iseq->orig is available.ko1
* iseq.c (rb_iseq_clone): need WB for iseq1->klass = iseq0->klass (done in MEMCPY). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50015 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-06* fix namespace issue on singleton class expressions. [Bug #10943]ko1
* vm_core.h, method.h: remove rb_iseq_t::cref_stack. CREF is stored to rb_method_definition_t::body.iseq_body.cref. * vm_insnhelper.c: modify SVAR usage. When calling ISEQ type method, push CREF information onto method frame, SVAR located place. Before this fix, SVAR is simply nil. After this patch, CREF (or NULL == Qfalse for not iseq methods) is stored at the method invocation. When SVAR is requierd, then put NODE_IF onto SVAR location, and NDOE_IF::nd_reserved points CREF itself. * vm.c (vm_cref_new, vm_cref_dump, vm_cref_new_toplevel): added. * vm_insnhelper.c (vm_push_frame): accept CREF. * method.h, vm_method.c (rb_add_method_iseq): added. This function accepts iseq and CREF. * class.c (clone_method): use rb_add_method_iseq(). * gc.c (mark_method_entry): mark method_entry::body.iseq_body.cref. * iseq.c: remove CREF related codes. * insns.def (getinlinecache/setinlinecache): CREF should be cache key because a different CREF has a different namespace. * node.c (rb_gc_mark_node): mark NODE_IF::nd_reserved for SVAR. * proc.c: catch up changes. * struct.c: ditto. * insns.def: ditto. * vm_args.c (raise_argument_error): ditto. * vm_eval.c: ditto. * test/ruby/test_class.rb: add a test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-17compile.c: struct accessorsnobu
* compile.c (rb_method_for_self_aref, rb_method_for_self_aset): move from iseq.c to build from node instead of arrays. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48876 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-17iseq.c: default optionnobu
* iseq.c (rb_iseq_new_with_opt): allow NULL option as COMPILE_OPTION_DEFAULT. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-17iseq.c: absolute_pathnobu
* iseq.c (caller_location): separate absolute_path. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-16iseq.c: remove useless codenobu
* iseq.c (rb_method_for_self_aref): remove unused declaration. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-16iseq.c: struct accessorsnobu
* iseq.c (rb_method_for_self_aref, rb_method_for_self_aset): call accessor functions directly, not to be affected by [] and []= methods. [ruby-core:66846] [Bug #10601] * struct.c (define_aref_method, define_aset_method): ditto. * vm_insnhelper.c (rb_vm_opt_struct_aref, rb_vm_opt_struct_aset): direct accessors of Struct. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48864 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-16compile.c: wrap funcptrnobu
* compile.c (iseq_build_from_ary_body): enclose funcptr with Integer as raw pointer cannot appear in an Array. * iseq.c (iseq_data_to_ary): extract funcptr from Integer. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48863 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-16iseq.c: show function name if possiblenobu
* iseq.c (rb_insn_operand_intern): show the name of the nearest run-time symbol if possible. * compile.c (insn_data_to_s_detail): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48858 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-16compile.c: check funcptrnobu
* compile.c (iseq_build_from_ary_body): cannot load dumped funcptr. * iseq.c (iseq_data_to_ary): cannot dump funcptr. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48857 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-15iseq.c: use caller locationnobu
* iseq.c (rb_method_for_self_aref, rb_method_for_self_aset): set same location as the caller. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48851 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-15iseq.c: intermediate arraysnobu
* iseq.c (rb_method_for_self_aref, rb_method_for_self_aset): hide and clear intermediate array objects. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48850 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-11* class.c (class_alloc): Strat from age == 2.ko1
Class and Module objects can be living long life. * iseq.c: Same for ISeq objects. * gc.c (RVALUE_AGE_RESET): added. * gc.c (newobj_of): allow to generate (age != 0) objects. * gc.c (rb_copy_wb_protected_attribute): reset age for wb unprotected objects. * include/ruby/ruby.h: add RUBY_TYPED_PROMOTED1 as an unrecommended flag. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48771 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-10struct.c: use iseqvalnobu
* struct.c (define_aref_method, define_aset_method): use iseq VALUE instead of rb_iseq_t to prevent from GC, as RB_GC_GUARD makes sense only for local variables. [Feature #10575] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48754 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-09struct: avoid all O(n) behavior on accessnormal
This avoids O(n) on lookups with structs over 10 members. This also avoids O(n) behavior on all assignments on Struct members. Members 0..9 still use existing C methods to read in O(1) time Benchmark results: vm2_struct_big_aref_hi* 1.305 vm2_struct_big_aref_lo* 1.157 vm2_struct_big_aset* 3.306 vm2_struct_small_aref* 1.015 vm2_struct_small_aset* 3.273 Note: I chose use loading instructions from an array instead of writing directly to linked-lists in compile.c for ease-of-maintainability. We may move the method definitions to prelude.rb-like files in the future. I have also tested this patch with the following patch to disable the C ref_func methods and ensured the test suite and rubyspec works --- a/struct.c +++ b/struct.c @@ -209,7 +209,7 @@ setup_struct(VALUE nstr, VALUE members) ID id = SYM2ID(ptr_members[i]); VALUE off = LONG2NUM(i); - if (i < N_REF_FUNC) { + if (0 && i < N_REF_FUNC) { rb_define_method_id(nstr, id, ref_func[i], 0); } else { * iseq.c (rb_method_for_self_aref, rb_method_for_self_aset): new methods to generate bytecode for struct.c [Feature #10575] * struct.c (rb_struct_ref, rb_struct_set): remove (define_aref_method, define_aset_method): new functions (setup_struct): use new functions * test/ruby/test_struct.rb: add test for struct >10 members * benchmark/bm_vm2_struct_big_aref_hi.rb: new benchmark * benchmark/bm_vm2_struct_big_aref_lo.rb: ditto * benchmark/bm_vm2_struct_big_aset.rb: ditto * benchmark/bm_vm2_struct_small_aref.rb: ditto * benchmark/bm_vm2_struct_small_aset.rb: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48748 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-05iseq.c: remove unused rb_iseq_new_with_boptnormal
* iseq.c (prepare_iseq_build): remove unused block_opt param (rb_iseq_new_with_bopt_and_opt): remove (rb_iseq_new_with_opt): inline removed function (rb_iseq_new_with_bopt): remove (iseq_load): adjust prepare_iseq_build call [Feature #10565] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48713 b2dd03c8-39d4-4d8f-98ff-823fe69b080e