summaryrefslogtreecommitdiff
path: root/compile.c
AgeCommit message (Collapse)Author
2015-11-16compile.c: tailcall on aref and asetnobu
* compile.c (iseq_peephole_optimize): optimize tail calls on aref and aset specialized instructions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-16compile.c: optimize leavenobu
* compile.c (iseq_peephole_optimize): optimize replaced leave instruction copied to jump instruction too. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52594 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-14compile.c: fix variablenobu
* compile.c (iseq_peephole_optimize): use proper variable, without cast. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-14compile.c: remove unused labelsnobu
* compile.c (iseq_label_data): manage reference count. * compile.c (iseq_peephole_optimize): remove unreferred labels which may disturb optimization. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52567 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-13* vm.c (vm_define_method): refactoring.ko1
* get CREF in this function. * cbase is no longer needed (CREF_CLASS(cref) is enough). * compile.c: RubyVM::FrozenCore.define_method only accept 2 args. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52563 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-11compile.c: comments for r52517 [ci skip]nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52538 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-10compile.c: peepholenobu
* compile.c (iseq_peephole_optimize): remove putting object to be popped just soon. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52517 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-09* compile.c (iseq_compile_each): Dynamic string literals should beshugo
frozen. [ruby-core:57574] [Feature #8976] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52501 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-27id.def: internal IDsnobu
* defs/id.def: move internal IDs for frozen-string-literal-debug. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52300 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-23* ruby.c: introduce --enable-frozen-string-literal-debug option.ko1
If this option is enabled, the modify error will be: can't modify frozen String (RuntimeError) => can't modify frozen String, created at test.rb:3 (RuntimeError) * iseq.h: add compile option frozen_string_literal_debug. * compile.c: catch up this fix. * error.c (rb_error_frozen): ditto. * iseq.c (set_compile_option_from_hash): ditto. * test/ruby/test_rubyoptions.rb: add a test for this fix. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52257 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-23compile.c: optimize method chainnobu
* compile.c (iseq_peephole_optimize): optimize lengthy safe navigation method chain. [Feature #11537] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52237 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-23safe navigation attrsetnobu
* compile.c (iseq_compile_each): support safe navigation of simple attribute assignment. [Feature #11537] * parse.y (mlhs_node, lhs, attrset_gen): ditto. keep mid non-attrset as the sign of safe navigation. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-23compile.c: just insertnobu
* compile.c (compile_massign_lhs): just insert topn insn instead of popping and adding. [Feature #11537] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52233 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-22Safe navigation operatornobu
* compile.c (iseq_peephole_optimize): peephole optimization for branchnil jumps. * compile.c (iseq_compile_each): generate save navigation operator code. * insns.def (branchnil): new opcode to pop the tos and branch if it is nil. * parse.y (NEW_QCALL, call_op, parser_yylex): parse token '.?'. [Feature #11537] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52214 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-12node.h: no attrset ID in NODEnobu
* compile.c (iseq_compile_each), node.h (NEW_OP_ASGN22): attrset ID no longer needs to be stored in a NODE, create at byte code generation. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52113 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-09* compile.c (iseq_compile_each): Dynamic string literals (e.g.,shugo
"#{x}") should not be frozen because they don't literally represent strings. https://twitter.com/shugomaeda/status/651937650027401216 https://twitter.com/yukihiro_matz/status/651942882312482817 https://twitter.com/yukihiro_matz/status/651980835181096960 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52087 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-05compile.c: dstr head typenobu
* compile.c (compile_dstr_fragments): head of dstr must be a string. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52047 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-29compile.c: fix performance of strconcatnobu
* compile.c (compile_dstr_fragments): fix performance by omitting the first empty string only for keeping literal encoding if other literals are too. [ruby-core:70930] [Bug #11556] * string.c (rb_str_append_literal): append but keep encoding non US-ASCII. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51970 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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* 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-12* vm_insnhelper.c (vm_call_iseq_setup_normal): do not clear localko1
variables here. vm_push_frame() clears. * vm_insnhelper.c (vm_call_iseq_setup_tailcall): ditto. * vm_insnhelper.c (vm_push_frame): move check code to vm_check_frame(). Reorder initialization timing to reuse same values (sp). * compile.c (rb_iseq_compile_node): use iseq_set_exception_local_table() for ISEQ_TYPE_DEFINED_GUARD. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-10compile.c: register cdhashnobu
* compile.c (iseq_build_from_ary_body): register cdhash to the iseq constant body instead of compile time mark array, not to get GCed. [ruby-core:70708] [Feature #8543] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51816 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-08-27* compile.c (iseq_set_sequence): rename variable namesko1
to make it readable. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51707 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-12hoist out rb_call_info_kw_arg_bytes to inline functionnormal
* vm_core.h (rb_call_info_kw_arg_bytes): extract from compile.c * compile.c (iseq_build_callinfo_from_hash): use above function This will be use for implementing iseq_memsize git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51546 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::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