summaryrefslogtreecommitdiff
path: root/compile.c
AgeCommit message (Collapse)Author
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::param::opt_table andko1
rb_iseq_constant_body::param::keyword. * compile.c: catch up this fix. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51367 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* 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-20ruby_vm_throw_flagsnobu
* vm_core.h (ruby_vm_throw_flags): constants for throw. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51300 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-17compile.c: use ruby_tag_typenobu
* compile.c (iseq_compile_each): use enum ruby_tag_type names. * vm_core.h (ruby_tag_type): move from eval_intern.h for compiling break/next/redo/return. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51283 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-17compile.c: remove unused bignobu
* compile.c (iseq_compile_each): remove unused big flag, `while` loop always leaves a result on the stack. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51282 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-07compile.c (COMPILE_ERROR): reduce GET_THREAD() callsnormal
Shorten a long line and reduce global variable access, giving a minor code size reduction (at least on 32-bit x86): text data bss dec hex filename 96807 772 48 97627 17d5b compile.orig 96775 772 48 97595 17d3b compile.o git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51184 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-17compile.c: use %+PRIsVALUE instead of rb_inspectnormal
* compile.c (get_exception_sym2type, iseq_build_from_ary_body): rely on %+PRIsVALUE instead of calling rb_inspect directly This yields a minor size reduction on 32-bit x86: text data bss dec hex filename 96807 772 48 97627 17d5b compile.o 96851 772 48 97671 17d87 compile.orig git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50940 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-29parse.y: check NTH_REF rangenobu
* compile.c (iseq_compile_each): out of range NTH_REF is always nil. * parse.y (parse_numvar): check overflow of NTH_REF and range. [ruby-core:69393] [Bug #11192] * util.c (ruby_scan_digits): make public and add length parameter. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50671 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-30compile.c: disallow private readersnobu
* compile.c (iseq_compile_each): revert r46873 and r46875, not to allow to execute private readers by pretending op assign. [ruby-core:68984] [Bug #11096] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50408 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-29compile.c: move expansion of massignnobu
* compile.c (iseq_compile_each): move expansion for massign to variable of for-loop from the parser, to reduce method calls on intermediate objects. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50398 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-27vm_eval.c: simplify rb_iteratenobu
* internal.h (IFUNC_NEW): add argument for ID. * vm_eval.c (rb_iterate): create ifunnc only when it is used. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50102 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-11* node.h: remove NODE_IFUNC, NEW_IFUNC.ko1
* internal.h: use T_IMEMO for IFUNC. rename `struct IFUNC' to `struct vm_ifunc' and move the definition from vm_insnhelper.h. Add imemo_ifunc. * gc.c (gc_mark_children): mark imemo_ifunc type T_IMEMO object. * compile.c: catch up these changes. * proc.c: ditto. * vm_core.h (RUBY_VM_IFUNC_P): ditto. * vm_eval.c (rb_iterate): ditto. * vm_insnhelper.c: ditto. * ext/objspace/objspace.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49938 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-27* vm_core.h: define vm_svar_index.ko1
* vm_insnhelper.c, vm.c, compile.c: use vm_svar_index names. * iseq.h: remove DEFAULT_SPECIAL_VAR_COUNT. use VM_SVAR_FLIPFLOP_START instead. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49772 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-27compile.c: debug prints to stderrnobu
* compile.c: send all debug prints to stderr, as ruby_debug_printf does. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49771 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-27compile.c: fix function namenobu
* compile.c (APPEND_ELEM): fix function name so that the first argument will be inserted. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49770 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-25insns.def: reversenobu
* insns.def (reverse): add new instruction for massign. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49731 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-25compile.c: unbalanced massignnobu
* compile.c (compile_massign): adjust stack for unbalanced massign. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49730 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-16compile.c: massign optimizationnobu
* compile.c (compile_massign): optimization for special case, assignments by aset or attrset. http://kokizzu.blogspot.jp/2015/02/c-java-hhvm-ruby-nodejsrhinojscspidermo.html http://www.atdot.net/~ko1/diary/201502.html#d16 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49614 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-06vm_core.h: fix symbols leaknobu
* vm_core.h (rb_call_info_kw_arg_struct): make keywords a symbols list to get rid of inadvertent creation by variable keyword arguments. [ruby-core:68031] [Bug #10831] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49517 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-09parse.y: eliminate empty hashesnobu
* parse.y (assocs, assoc): eliminate splatting empty literal hashes. [ruby-core:67446] [Bug #10719] * compile.c (compile_array_): supprt splatted hash in hash type. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49193 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-26fix printf format conversion specifiersnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49021 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-19compile.c: add commentsnobu
* compile.c (rb_method_for_self_aref, rb_method_for_self_aset): add comments about inputs and outputs of func. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48893 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-17compile.c: constifynobu
* compile.c (iseq_set_local_table): constify ID table. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-17* compile.c (iseq_compile_each): checkko1
iseq->compile_data->option->specialized_instruction for opt_* insn. * test/ruby/test_iseq.rb: check no specialized_instructions option. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48870 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-17compile.c: skip opt_* insns for fstr args with block givennormal
* compile.c (iseq_compile_each): only emit opt_str_freeze, opt_aref_with, and opt_aset_with insn when no block is given [Bug #10557] [ruby-core:66595] * test/ruby/test_optimization.rb (test_block_given_aset_aref): new test for bug thanks to Bartosz Kopinski. (test_string_freeze): additional assertion for object_id git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48869 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-15compile.c: support for TS_FUNCPTRnobu
* compile.c (iseq_set_sequence): support for TS_FUNCPTR. * compile.c (insn_data_to_s_detail): ditto. * compile.c (iseq_build_from_ary_body): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48849 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-05compile.c (rb_iseq_build_from_ary): remove misc handlingnormal
iseq->local_size is calculated, too, along with stack_size and param.size, meaning there is no need to blindly load values in the misc hash passed to us. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48725 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-02compile.c: set true and false directlynobu
* compile.c (iseq_set_arguments): directly set true and false default values not only nil to keyword arguments. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48680 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-27* compile.c (iseq_compile_each): remove duplicated line event.ko1
[Bug #10449] * test/ruby/test_settracefunc.rb: add and fix tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48609 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-26compile.c (iseq_calc_param_size): hoist out of iseq_set_argumentsnormal
This will be reused for iseq loading. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48593 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-26* compile.c (iseq_set_sequence): use "nop" insn instead ofko1
"jump to next insn". https://bugs.ruby-lang.org/issues/8543#change-50085 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48579 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-25rb_id2str over rb_id2namenobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48575 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-25compile.c (iseq_build_callinfo_from_hash): hoist outnormal
iseq_build_from_ary_body indentation was too deep for my little terminal, so extract it so it is easier to add keyword support. * compile.c (iseq_build_callinfo_from_hash): hoist out (iseq_build_from_ary_body): shorten callinfo case git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48554 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-05* remove trailing spaces.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48289 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-05* compile.c (compile_data_alloc): add padding when strict alignmentngoto
is required for memory access. Currently, the padding is enabled only when the CPU is 32-bit SPARC and the compiler is GCC. [Bug #9681] [ruby-core:61715] * compile.c (STRICT_ALIGNMENT): defined if strict alignment is required * compile.c (ALIGNMENT_SIZE, ALIGNMENT_SIZE_MASK, PADDING_SIZE_MAX): new macros for alignemnt word size, bit mask, max size of padding. * compile.c (calc_padding): new function to calculate padding size. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48288 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