summaryrefslogtreecommitdiff
path: root/iseq.c
AgeCommit message (Collapse)Author
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
2014-12-03mostly fix rb_iseq_loadnormal
This allows reporters commenters of [Feature #8543] to load instruction sequences directly. Some test cases are still failing but documented in test/-ext-/iseq_load/test_iseq_load.rb. * compile.c (rb_iseq_build_from_exception): entry->sp is unsigned (iseq_build_callinfo_from_hash): account for kw_arg (iseq_build_from_ary_body): update for r35459 (CHECK_STRING, CHECK_INTEGER): remove unused checks (int_param): new function for checking new `params' hash (iseq_build_kw): new function for loading rb_iseq_param_keyword (rb_iseq_build_from_ary): account for `misc' entry and general structure changes [Feature #8543] * iseq.c (CHECK_HASH): new macro (for `misc' and `param' entries) (iseq_load): account for `misc' and `params' hashes (iseq_data_to_ary): add final opt to arg_opt_labels, fix kw support, account for unsigned entry->sp * ext/-test-/iseq_load/iseq_load.c: new ext for test * ext/-test-/iseq_load/extconf.rb: ditto * test/-ext-/iseq_load/test_iseq_load.rb: new test git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48705 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-03iseq.c: avoid segfault on incomplete iseqnormal
Compile failures will trigger iseq_free before iseq->callinfo_entries are allocated at all. * iseq.c (iseq_free): avoid segfault on incomplete iseq * test/ruby/test_syntax.rb (test_invalid_next): new test for syntax error, not segfault git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48704 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-02iseq.c: use lvar indexnobu
* iseq.c (iseq_data_to_ary): use local variable indexes for hidden variable instead of meaningless ID values. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48679 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-01iseq.c (iseq_data_to_ary): keep hidden variablesnormal
We must not ignore hidden variables when rb_id2str fails. Thanks to wanabe [ruby-core:66566] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48678 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-01use 0 for reservednobu
use 0 for rb_data_type_t::reserved instead of NULL, since its type may be changed in the future and possibly not a pointer type. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-27iseq.c (iseq_data_to_ary): add missing GC guardnormal
It seems possible for a compiler to optimize away nbody because we only access it via RARRAY_AREF and RARRAY_LEN macros. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48597 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-26iseq.c (iseq_s_compile_file): close IO when donenormal
This will prevent some leaked FD warnings in future tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48578 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-23iseq.c: preserve encoding at disassemblingnobu
* iseq.c (rb_insn_operand_intern): preserve encoding of method name in CALL_INFO at disassembling. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48548 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-15* internal.h: Include ruby.h and ruby/encoding.h to beakr
includable without prior inclusion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-03* iseq.c (iseq_free): resolve memory leak.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48251 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-03* iseq.c (iseq_memsize): catch up recent changes.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48248 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-03* vm_core.h: change semantics of opt_num and opt_table.ko1
`opt_num' was the number of optional parameters + 1. `opt_table' has "opt_num" entries. Change them to: `opt_num' is the number of optional parameters. `opt_talbe' has "opt_num + 1" entries. This change simplify parameter fitting logics. * compile.c: catch up this change. * iseq.c: ditto. * proc.c: ditto. * vm_args.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48247 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-02* vm_core.h: change iseq parameter data structure.ko1
https://bugs.ruby-lang.org/issues/10440#change-49694 * change terminology `arg' to `param'. * move rb_iseq_t::arg_* to rb_iseq_t::param. * move rb_iseq_t::arg_size to rb_iseq_t::param::size. * move rb_iseq_t::argc to rb_iseq_t::param::lead_num. * move rb_iseq_t::arg_opts to rb_iseq_t::param::opt_num. * move rb_iseq_t::arg_rest to rb_iseq_t::param::rest_start. * move rb_iseq_t::arg_post_num to rb_iseq_t::param::post_num. * move rb_iseq_t::arg_post_start to rb_iseq_t::param::post_start. * move rb_iseq_t::arg_block to rb_iseq_t::param::block_start. * move rb_iseq_t::arg_keyword* to rb_iseq_t::param::keyword. rb_iseq_t::param::keyword is allocated only when keyword parameters are available. * introduce rb_iseq_t::param::flags to represent parameter availability. For example, rb_iseq_t::param::flags::has_kw represents that this iseq has keyword parameters and rb_iseq_t::param::keyword is allocated. We don't need to compare with -1 to check availability. * remove rb_iseq_t::arg_simple. * compile.c: catch up this change. * iseq.c: ditto. * proc.c: ditto. * vm.c, vm_args.c, vm_dump.c, vm_insnhelper.c: ditto. * iseq.c (iseq_data_to_ary): support keyword argument. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48242 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-02* rewrite method/block parameter fitting logic to optimizeko1
keyword arguments/parameters and a splat argument. [Feature #10440] (Details are described in this ticket) Most of complex part is moved to vm_args.c. Now, ISeq#to_a does not catch up new instruction format. * vm_core.h: change iseq data structures. * introduce rb_call_info_kw_arg_t to represent keyword arguments. * add rb_call_info_t::kw_arg. * rename rb_iseq_t::arg_post_len to rb_iseq_t::arg_post_num. * rename rb_iseq_t::arg_keywords to arg_keyword_num. * rename rb_iseq_t::arg_keyword to rb_iseq_t::arg_keyword_bits. to represent keyword bitmap parameter index. This bitmap parameter shows that which keyword parameters are given or not given (0 for given). It is refered by `checkkeyword' instruction described bellow. * rename rb_iseq_t::arg_keyword_check to rb_iseq_t::arg_keyword_rest to represent keyword rest parameter index. * add rb_iseq_t::arg_keyword_default_values to represent default keyword values. * rename VM_CALL_ARGS_SKIP_SETUP to VM_CALL_ARGS_SIMPLE to represent (ci->flag & (SPLAT|BLOCKARG)) && ci->blockiseq == NULL && ci->kw_arg == NULL. * vm_insnhelper.c, vm_args.c: rewrite with refactoring. * rewrite splat argument code. * rewrite keyword arguments/parameters code. * merge method and block parameter fitting code into one code base. * vm.c, vm_eval.c: catch up these changes. * compile.c (new_callinfo): callinfo requires kw_arg parameter. * compile.c (compile_array_): check the last argument Hash object or not. If Hash object and all keys are Symbol literals, they are compiled to keyword arguments. * insns.def (checkkeyword): add new instruction. This instruction check the availability of corresponding keyword. For example, a method "def foo k1: 'v1'; end" is cimpiled to the following instructions. 0000 checkkeyword 2, 0 # check k1 is given. 0003 branchif 9 # if given, jump to address #9 0005 putstring "v1" 0007 setlocal_OP__WC__0 3 # k1 = 'v1' 0009 trace 8 0011 putnil 0012 trace 16 0014 leave * insns.def (opt_send_simple): removed and add new instruction "opt_send_without_block". * parse.y (new_args_tail_gen): reorder variables. Before this patch, a method "def foo(k1: 1, kr1:, k2: 2, **krest, &b)" has parameter variables "k1, kr1, k2, &b, internal_id, krest", but this patch reorders to "kr1, k1, k2, internal_id, krest, &b". (locate a block variable at last) * parse.y (vtable_pop): added. This function remove latest `n' variables from vtable. * iseq.c: catch up iseq data changes. * proc.c: ditto. * class.c (keyword_error): export as rb_keyword_error(). * common.mk: depend vm_args.c for vm.o. * hash.c (rb_hash_has_key): export. * internal.h: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48239 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-14symbol.c: rename rb_str_dynamic_internnobu
* iseq.c, marshal.c, string.c: use rb_str_intern instead of rb_str_dynamic_intern. * symbol.c (rb_str_intern): rename rb_str_dynamic_intern. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47912 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-01iseq.c (rb_iseq_line_trace_each): explicit castnormal
Fix https://travis-ci.org/ruby/ruby/jobs/36814282 Tested with -Wconversion since my gcc lacks -Wshorten-64-to-32 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47760 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-21iseq.c (rb_iseq_defined_string): trim redundant semi-colonnormal
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47666 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-10compile: translate iseq in-placenormal
running "ruby -rpp -e 'pp GC.stat'", a reduction in malloc usage is shown: before: :malloc_increase=>118784, :oldmalloc_increase=>1178736, after: :malloc_increase=>99832, :oldmalloc_increase=>1031976, For "ruby -e exit", valgrind reports over 300K reduction in overall allocations (and unnecessary memory copies). before: total heap usage: 49,622 allocs, 20,492 frees, 8,697,493 bytes allocated after: total heap usage: 48,935 allocs, 19,805 frees, 8,373,773 bytes allocated (numbers from x86-64) v2 changes based on ko1 recommendations [ruby-core:64883]: - squashed in-place direct thread translation to avoid alloc+copy - renamed rb_iseq_untranslate_threaded_code to rb_iseq_original_iseq, cache new iseq->iseq_original field. * compile.c (rb_iseq_translate_threaded_code): modify in-place w/o copy (rb_vm_addr2insn): new function for debug (rb_iseq_original_iseq): ditto (iseq_set_sequence): assign iseq_encoded directly [Feature #10185] * vm_core (rb_iseq_t): move original ->iseq to bottom * iseq.c (iseq_free, iseq_free): adjust for new layout (rb_iseq_disasm): use original iseq for dump (iseq_data_to_ary): ditto (rb_iseq_line_trace_each): ditto (rb_iseq_build_for_ruby2cext): use iseq_encoded directly * vm_dump.c (rb_vmdebug_debug_print_pre): use original iseq git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47508 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-25rb_iseq_location_t: change first_lineno type to VALUEnormal
Nearly all current uses of iseq->location.first_lineno are as a VALUE, not a size_t. The only exception was the experimental (and currently unused) rb_iseq_build_for_ruby2cext function. * vm_core.h (rb_iseq_location_t): change first_lineno type to VALUE * iseq.c (rb_iseq_build_for_ruby2cext): update based on argument git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47269 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-15* iseq.c (rb_iseq_clone): Should not insert write barrier fromko1
non-RVALUE data (to non-RVALUE data, of course). Ruby 2.1 also has a same problem. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47191 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-28symbols instead of IDsnobu
* encoding.c (rb_enc_get_index): deal with symbols instead of IDs to get rid of inadvertent pin-downs. * enum.c (chunk_ii): ditto. * enumerator.c (append_method): ditto. * iseq.c (iseq_load): ditto. * marshal.c (w_symbol, r_symlink, r_symreal, r_symbol): ditto. * signal.c (trap_handler): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46988 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-26struct iseq_compile_data_storage: 16 bytes (from 32) overheadnormal
This reduces the iseq_compile_data_storage header from 32 to 16 bytes on 64-bit systems. pos and size fields cannot exceed 32-bit sizes due to stack size limits. Using a flexible array for the buffer also saves us 8 bytes of pointer overhead. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46958 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-26rb_iseq_t: reduce to (280 bytes from 288 bytes) on 64-bitnormal
iseq_size and line_info_size may be 32-bit. 4GB instruction sequences should be big enough for anyone. Other existing line info counters are 32-bit, and nobody should need all that. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46957 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-25introduce ZALLOC{,_N} to replace ALLOC{,_N}+MEMZERO usenormal
Using calloc where possible reduces code and binary sizes. * include/ruby/ruby.h (ZALLOC, ZALLOC_N): implement (Data_Make_Struct, TypedData_Make_Struct): ZALLOC replaces ALLOC+memset * compile.c (iseq_seq_sequence): ZALLOC_N replaces ALLOC_N+MEMZERO * cont.c (fiber_t_alloc): ZALLOC replaces ALLOC+MEMZERO * io.c (rb_io_reopen): ditto * iseq.c (prepare_iseq_build): ditto * parse.y (new_args_tail_gen, parser_new, ripper_s_allocate): ditto * re.c (match_alloc): ditto * variable.c (rb_const_set): ditto * ext/socket/raddrinfo.c (get_addrinfo): ditto * ext/strscan/strscan.c (strscan_s_allocate): ditto * gc.c (rb_objspace_alloc): calloc replaces malloc+MEMZERO git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e