summaryrefslogtreecommitdiff
path: root/compile.c
AgeCommit message (Collapse)Author
2016-01-26fstring early for internal iseqnormal
All of the strings created here eventually get converted to fstrings when they are frozen into the iseq. Prepare the fstring early so we may reduce a one or two objects. This is a very minor change, mainly for the '<main>' dedupe. * compile.c (caller_location): use rb_fstring_cstr for "<compiled>" (it is converted to fstring anyways inside rb_iseq_new_with_opt) * iseq.c (iseqw_s_compile): ditto * iseq.c (rb_iseq_new_main): use rb_fstring_cstr for "<main>" * vm.c (Init_VM): ditto, share with with above * iseq.c (iseqw_s_compile_file): rb_fstring before rb_io_t->pathv share "<main>" with above * vm.c (rb_binding_add_dynavars): fstring "<temp>" immediately git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53659 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-26compile.c: fix tailcall optimizationnobu
* compile.c (iseq_peephole_optimize): don't apply tailcall optimization to send/invokesuper instructions with blockiseq. This is a follow-up to the changes in r51903; blockiseq is now the third operand of send/invokesuper instructions. [ruby-core:73413] [Bug #12018] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-10compile.c: fix lhs splat in massignnobu
* compile.c (compile_massign_lhs): when index ends with splat, append rhs value to it like POSTARG, since VM_CALL_ARGS_SPLAT splats the last argument only. [ruby-core:72777] [Bug #11970] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53495 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-01compile.c: adjust call_info countnobu
* compile.c (remove_unreachable_chunk): decrease count of call_info in removed instructions. fix up r53402. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53403 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-01compile.c: remove unreferred labelnobu
* compile.c (remove_unreachable_chunk): remove unreferred label to optimize away unreachable chunk. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53402 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-29compile.c: adjust label referencenobu
* compile.c (new_adjust_body): labels referred by adjuststack shoud not be optimized away. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53367 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-24fix common misspelling [ci skip]nobu
* compile.c, cont.c, doc, man: fix common misspelling. [ruby-core:72466] [Bug #11870] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53299 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-24preserve source file name encodingnobu
* compile.c (append_compile_error), parse.y (compile_error): preserve encoding of source file name in exceptions. * error.c (rb_compile_error_str, rb_compile_bug_str): add. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53278 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-18* compile.c (ibf_load_object_string): use fstring if frozen string.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53191 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-18* compile.c (ibf_load_setup): check tainted string argument.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53187 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-14* compile.c: fix typos.hsbt
[ci skip][fix GH-1140] Patch by @jutaz * dir.c: ditto. * gc.c: ditto. * io.c: ditto. * node.h: ditto. * thread_pthread.c: ditto. * vm_insnhelper.c: ditto. * vsnprintf.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53103 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-11compile.c: rehash cdhashnobu
* compile.c (iseq_compile_each, ibf_load_object_hash): rehash case-dispatch hash to reduce collisions. http://d.hatena.ne.jp/ku-ma-me/20151210 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53031 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-10compile.c (iseq_compile_each): reduce needless rb_str_dupnormal
There is no need to dup the fstring unless we want to set the debug ivar for it. [ruby-core:72018] <5668DB6E.8000101@ruby-lang.org> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53021 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-09* compile.c (iseq_compile_each): do not add debug informationko1
without --debug or --debug=frozen-string-literal option because String#dup slows down with debug information. [Feature #11725] * NEWS: apply about it. * test/ruby/test_rubyoptions.rb: catch up this fix with refactoring. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53009 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-09compile.c (ibf_dump_object_unsupported): fix spelling errornormal
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52989 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-09* *.c (*_memsize): do not check ptr.ko1
NULL checking is finished Before call of memsize functions. See r52979. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-08* compile.c (ibf_dump_memsize): should check NULL.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52978 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-08compile.c: suppress warningnobu
* compile.c (ibf_dump_overwrite): cast to unsigned long to suppress sign-compare warning. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52971 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-08* compile.c (iseq_ibf_dump): dump extra data just string length.ko1
* sample/iseq_loader.rb: add using RubyVM::InstructionSequence.from_binary_format_extra_data method (commented out). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52969 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-08compile.c: fix extra_strnobu
* compile.c (iseq_ibf_load_extra_data): fix offset and length of extra_str, which is not NUL-terminated. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52968 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-08* compile.c (ibf_load_setup): cast to int.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52966 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-08* compile.c (ibf_setup_load): rename to ibf_load_setup().ko1
* compile.c (iseq_load_setup): check binary format. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52965 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-08free ibf_dump at exceptionnobu
* compile.c (iseq_ibf_dump): wrap ibf_dump to free tables at exception. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52960 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-08compile.c: make opt a string valuenobu
* compile.c (iseq_ibf_dump): rb_check_string_type() returns nil if the object does not have to_str method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52958 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-08check loading object index rangenobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52956 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-08suppress warningsnobu
* compile.c (iseq_ibf_dump): check lenght overflow. * vm_core.h (rb_iseq_check): suppress unused-value warnings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52955 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-08* compile.c (iseq_ibf_dump): fix for clang type checker.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52954 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-08* introduce new ISeq binary format serializer/de-serializerko1
and a pre-compilation/runtime loader sample. [Feature #11788] * iseq.c: add new methods: * RubyVM::InstructionSequence#to_binary_format(extra_data = nil) * RubyVM::InstructionSequence.from_binary_format(binary) * RubyVM::InstructionSequence.from_binary_format_extra_data(binary) * compile.c: implement body of this new feature. * load.c (rb_load_internal0), iseq.c (rb_iseq_load_iseq): call RubyVM::InstructionSequence.load_iseq(fname) with loading script name if this method is defined. We can return any ISeq object as a result value. Otherwise loading will be continue as usual. This interface is not matured and is not extensible. So that we don't guarantee the future compatibility of this method. Basically, you should'nt use this method. * iseq.h: move ISEQ_MAJOR/MINOR_VERSION (and some definitions) from iseq.c. * encoding.c (rb_data_is_encoding), internal.h: added. * vm_core.h: add several supports for lazy load. * add USE_LAZY_LOAD macro to specify enable or disable of this feature. * add several fields to rb_iseq_t. * introduce new macro rb_iseq_check(). * insns.def: some check for lazy loading feature. * vm_insnhelper.c: ditto. * proc.c: ditto. * vm.c: ditto. * test/lib/iseq_loader_checker.rb: enabled iff suitable environment variables are provided. * test/runner.rb: enable lib/iseq_loader_checker.rb. * sample/iseq_loader.rb: add sample compiler and loader. $ ruby sample/iseq_loader.rb [dir] will compile all ruby scripts in [dir]. With default setting, this compile creates *.rb.yarb files in same directory of target .rb scripts. $ ruby -r sample/iseq_loader.rb [app] will run with enable to load compiled binary data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52949 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-08compile.c (iseq_build_from_ary_body): avoid rb_ary_dup for CDHASHnormal
This reverts r16587 ("compile.c (iseq_build_body): remove side effect from VM::InstructionSequence.load." as that change was obsoleted by r48705 ("mostly fix rb_iseq_load") git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52938 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-08compile optimized case dispatch for nil/true/falsenormal
nil/true/false are special literals just like floats, integers, literal strings, and symbols. Optimize when statements with them by using a jump table, too. target 0: a (ruby 2.3.0dev (2015-12-08 trunk 52928) [x86_64-linux]) at "/home/ew/rrrr/b/ruby" target 1: b (ruby 2.3.0dev (2015-12-08 master 52928) [x86_64-linux]) at "/home/ew/ruby/b/ruby" benchmark results: minimum results in each 5 measurements. Execution time (sec) name a b loop_whileloop2 0.102 0.103 vm2_case_lit* 1.657 0.549 Speedup ratio: compare with the result of `a' (greater is better) name b loop_whileloop2 0.988 vm2_case_lit* 3.017 * benchmark/bm_vm2_case_lit.rb: new benchmark * compile.c (case_when_optimizable_literal): add nil/true/false * insns.def (opt_case_dispatch): ditto * vm.c (vm_redefinition_check_flag): ditto * vm.c (vm_init_redefined_flag): ditto * vm_core.h: ditto * object.c (InitVM_Object): define === explicitly for nil/true/false * test/ruby/test_case.rb (test_deoptimize_nil): new test * test/ruby/test_optimization.rb (test_opt_case_dispatch): update (test_eqq): new test [ruby-core:71923] [Feature #11769] Original patch by Aaron Patterson <tenderlove@ruby-lang.org> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52931 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-07* compile.c (rb_iseq_build_from_ary): do not allocate tableko1
if table_size is 0. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52923 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-04compile.c: no extra parenthesesnobu
* compile.c (COMPILE_ERROR): remove extra parentheses to enclose variadic arguments. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52889 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-04compile.c: just append compile error messagenobu
* compile.c (append_compile_error, prepare_compile_error): simply append messages to the same SyntaxError exception. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52888 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-02* vm_core.h, iseq.h: remove rb_iseq_t::variable_body.ko1
Fields in rb_iseq_t::variable_body are contained by rb_iseq_t::body::mark_ary (hidden Array object). Index 0 to 2 of mark_ary are reserved by these objects. * iseq.c: catch up this fix. * compile.c (rb_iseq_original_iseq): trivial rewrite. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-02* iseq.h: introduce ISEQ_ORIGINAL_ISEQ() andko1
ISEQ_ORIGINAL_ISEQ_ALLOC() macro. * compile.c: use them to access original iseq buffer. * iseq.c: ditto. * vm_core.h: rename iseq field to support this fix. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52862 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-02* iseq.h: introduce ISEQ_FLIP_CNT_INCREMENT() macro.ko1
* compile.c (iseq_compile_each): use it. * vm_core.h: rename flip_cnt field to support this fix. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-02* iseq.h: introduce ISEQ_COVERAGE() and ISEQ_COVERAGE_SET() macro.ko1
* compile.c: use them. * iseq.c: ditto. * iseq.c (rb_iseq_coverage): added. * thread.c (update_coverage): use rb_iseq_coverage(). * vm_core.h: rename coverage field name to support this fix. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52860 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-02* iseq.h: introduce ISEQ_COMPILE_DATA() macro.ko1
* compile.c, iseq.c: use ISEQ_COMPILE_DATA(). * vm_core.h: rename compile_data field to support this fix. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52858 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-02compile.c: fix the elementnobu
* compile.c (iseq_set_sequence): fix the element for line number to rb_compile_bug. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52857 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-01compile.c: consistent messagesnobu
* compile.c (EXPECT_NODE, EXPECT_NODE_NONULL, UNKNOWN_NODE): make compile bug messages consistent. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52830 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-26compile.c: tailcall opt for indexersnobu
* compile.c (iseq_peephole_optimize): enable tail call optimization for specialized indexers. * compile.c (iseq_compile_each): blockiseq should be NULL, but not Qnil. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52759 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-25iseq.h: rename membernobu
* iseq.h (rb_compile_option_struct): rename the member frozen_string_literal_debug as debug_frozen_string_literal. [Feature #11725] * ruby.c (proc_options): do not set $DEBUG and $VERBOSE only if no arguments is given. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52749 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-22compile.c: fix positionnobu
* compile.c (iseq_compile_each): vals is NULL here, show the position of the parent node. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52712 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-22compile.c: move logop DCEnobu
* compile.c (iseq_peephole_optimize): remove unreachable code chunk after jump/leave. * parse.y: move dead code elimination of logical operation to compile.c. not to warn logical operation of literal constants. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52711 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-22compile.c: optimize useless branchesnobu
* compile.c (iseq_peephole_optimize): eliminate always/never branches after a literal object and when the value is used after the branch. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52710 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-22compile.c: free labels tablenobu
* compile.c (validate_labels): free labels table before raising an exception. * compile.c (rb_iseq_build_from_ary): wrap labels table to ensure freeing. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52708 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-22compile.c: use rb_compile_bugnobu
* compile.c: use rb_compile_bug instead of rb_bug to show error position precisely. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52707 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-22compile.c: use COMPILE_ERRORnobu
* compile.c: use COMPILE_ERROR to save an exception to be raised at cleanup_iseq_build. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52706 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-22compile.c: flush disasmnobu
* compile.c (dump_disasm_list): flush disassembled list. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52705 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-22compile.c: check each stepsnobu
* compile.c (iseq_setup): check return values of each steps. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52704 b2dd03c8-39d4-4d8f-98ff-823fe69b080e