aboutsummaryrefslogtreecommitdiffstats
path: root/compile.c
Commit message (Collapse)AuthorAgeFilesLines
* compile.c: optimization of defined? in conditionnobu2017-01-201-20/+34
| | | | | | | | * compile.c (compile_branch_condition): trivial optimization of defined? expression in a branch condition, where a string is not needed, but just a boolean. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57381 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: check err_infonobu2017-01-191-3/+3
| | | | | | | * compile.c (iseq_setup): bail out if any errors found. [ruby-core:76531] [Bug #12613] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57368 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* immediate message mode of compile errornobu2017-01-121-1/+4
| | | | | | | | | | | | | | * compile.c (append_compile_error): set Qtrue for erred state with showing the message immediately. * iseq.c (prepare_iseq_build): make immediate message mode if main or top level context, not to show the failed path twice in the first line. * iseq.c (cleanup_iseq_build): raise default message exception if immediate message mode. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57313 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: invalid yield in mainnobu2017-01-121-1/+2
| | | | | | | * compile.c (iseq_compile_each): yield cannot be in the main context as well as a top context. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57312 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: check compilenobu2017-01-101-120/+129
| | | | | | | * compile.c (iseq_compile_each): check if sub nodes succeeded. [ruby-core:76531] [Bug #12613] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57300 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: fallback nilnobu2017-01-031-3/+4
| | | | | | | * compile.c (iseq_compile_each): push fallback nil only when defined guard is added. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: omit unnecessary defined guardnobu2017-01-031-1/+1
| | | | | | | * compile.c (defined_expr): omit unnecessary defined guard when method call has no receiver and no arguments. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57258 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: constifynobu2016-12-241-1/+1
| | | | | | | * compile.c (method_for_self): constify an argument of build function for VC6. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57173 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: toplevel returnnobu2016-12-211-8/+24
| | | | | | | * compile.c (iseq_compile_each): stop execution of the current source by toplevel return. [ruby-core:36785] [Feature #4840] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57132 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: do not emit numeric literal range in void contextrhe2016-12-171-3/+5
| | | | | | A fix-up for r56316. Fix stack consistency error on '1..3; nil'. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* remove core#hash_merge_arynobu2016-12-091-0/+5
| | | | | | | | | * compile.c (compile_array_): remove m_core_hash_merge_ary which seems unreachable, and wrong number of arguments. * vm.c (m_core_hash_merge_ary): removed because it is never used. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: static_literal_valuenobu2016-12-081-17/+26
| | | | | | | * compile.c (static_literal_value): separate getter from predicate function. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: optimize literal nodesnobu2016-12-081-8/+32
| | | | | | | | * compile.c (static_literal_node_p): optimize literal nodes for true, false, and nil, which are static literals in specific nodes but not in NODE_LIT. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: remove dead codenobu2016-12-071-55/+60
| | | | | | | | | * compile.c (DECL_ANCHOR, INIT_ANCHOR): make anchor name an array and unassignable. * compile.c (iseq_compile_each): ret is never 0. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57013 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Fix typoskazu2016-12-061-134/+134
| | | | | | | Patch by: Koichi ITO <koic.ito@gmail.com> [Fix GH-1498] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: splatarray peephole optnobu2016-11-281-0/+20
| | | | | | | * compile.c (iseq_peephole_optimize): remove splatarray following always-array insn. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56908 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * compile.c (tailcallable_p): disable tail call optimization forshugo2016-11-051-0/+4
| | | | | | | toplevel, eval, and load to avoid SEGV when interrupted by SIGINT. [ruby-core:76327] [Bug #12576] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: not flip-flopnobu2016-10-291-0/+15
| | | | | | | * compile.c (iseq_compile_each): turn flip-flop in a not-operator into a boolean value. fix up r56315 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56521 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: order with splattingnobu2016-10-221-2/+2
| | | | | | | | * compile.c (setup_args): duplicate splatting array if more arguments present to obey left-to-right execution order. [ruby-core:77701] [Bug# 12860] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56469 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: literal rangenobu2016-10-011-1/+16
| | | | | | | * compile.c (iseq_compile_each): move numeric literal range optimization from fixup_nodes() in parse.y. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56316 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: optimize flip-flopnobu2016-10-011-41/+39
| | | | | | | | * compile.c (compile_flip_flop): simplify generated code. * compile.c (compile_branch_condition): flip-flop can appear only in coditional expressions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56315 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: tailcall in conditinal blocknobu2016-09-231-0/+7
| | | | | | | * compile.c (iseq_peephole_optimize): enable tail call optimization inside a conditional block. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56208 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * vm_core.h: revisit the structure of frame, block and env.ko12016-07-281-55/+56
| | | | | | | | | | | | | | | | | | | | | | [Bug #12628] This patch introduce many changes. * Introduce concept of "Block Handler (BH)" to represent passed blocks. * move rb_control_frame_t::flag to ep[0] (as a special local variable). This flags represents not only frame type, but also env flags such as escaped. * rename `rb_block_t` to `struct rb_block`. * Make Proc, Binding and RubyVM::Env objects wb-protected. Check [Bug #12628] for more details. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55766 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Coverage on non-positive linesnobu2016-06-261-0/+1
| | | | | | | | | * compile.c (ADD_TRACE): ignore trace instruction on non-positive line. * parse.y (coverage): get rid of ArgumentError when the starting line number is not positive. [ruby-core:76141] [Bug #12517] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55509 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * iseq.h (struct iseq_compile_data): use struct rb_id_tablenaruse2016-05-141-4/+12
| | | | | | | | | | | | | | | instead of st_table. * iseq.c (prepare_iseq_build): don't allocate ivar_cache_table until it has at least one element. * iseq.c (compile_data_free): free ivar_cache_table only if it is allocated. * compile.c (get_ivar_ic_value): allocate if the table is not allocated yet. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55002 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * compile.c (iseq_compile_each): share InlineCache during sametarui2016-05-111-3/+17
| | | | | | | | | | | | | | | instance variable accesses. Reducing memory consumption, rasing cache hit rate and rasing branch prediction hit rate are expected. A part of [Bug #12274]. * iseq.h (struct iseq_compile_data): introduce instance variable IC table for sharing. * iseq.c (prepare_iseq_build, compile_data_free): construct/destruct above table. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54976 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: true conditionsnobu2016-04-261-0/+12
| | | | | | | * compile.c (compile_branch_condition): add more always-true conditions to optimize away unreachable branch. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54775 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: remove redundant trace insnnobu2016-04-231-0/+11
| | | | | | | * compile.c (iseq_peephole_optimize): remove successive line trace instructions except for the last. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54733 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: instruction ID predicatenobu2016-04-231-30/+31
| | | | | | * compile.c (IS_INSN_ID): add instruction ID predicate macro. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54731 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: ISeq element type predicatesnobu2016-04-231-15/+19
| | | | | | | * compile.c (IS_INSN, IS_LABEL, IS_ADJUST): add ISeq element type predicate macros. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54730 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: make SyntaxError after formattingnobu2016-04-201-7/+6
| | | | | | | * compile.c (append_compile_error): make SyntaxError instance by rb_syntax_error_append on demand after formatting the message. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* refactor syntax errornobu2016-04-201-8/+1
| | | | | | | | | | | * compile.c (append_compile_error): use rb_syntax_error_append. * error.c (rb_syntax_error_append): append messages into a SyntaxError exception instance. * parse.y (yycompile0): make new SyntaxError instance in main mode, otherwize error_buffer should be a SyntaxError if error has occurred. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54650 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* appending compile error without rb_errinfonobu2016-04-191-35/+48
| | | | | | | | | * compile.c (append_compile_error, compile_bug): pass iseq and get error info and file from it, not by the thread error info. * error.c (rb_report_bug_valist): take va_list instead of variadic arguments, and just report the bug but not abort. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54648 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: fix dangling linknobu2016-04-181-5/+5
| | | | | | | | * compile.c (iseq_peephole_optimize): should not replace the current target INSN, not to follow the replaced dangling link in the caller. [ruby-core:74993] [Bug #11816] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54628 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: initialize LABEL fieldsnobu2016-04-121-0/+2
| | | | | | | * compile.c (new_label_body): initialize bit fields, since compile_data_alloc does not clear the memory. [Bug #12082] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54548 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: disable tco with rescuenobu2016-04-111-2/+45
| | | | | | | | * compile.c (iseq_optimize): disable tail call optimization in rescued, rescue, and ensure blocks. [ruby-core:73871] [Bug #12082] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54542 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* remove rb_thread_t::parse_in_evalnobu2016-03-281-19/+5
| | | | | | | | | | | | * parse.y (struct parser_params): move parse_in_eval flag from rb_thread_t. * parse.y (rb_parser_set_context): set parsing context, not only mild error flag. * iseq.c (rb_iseq_compile_with_option): the parser now refers no thread local states to be restored. * vm_eval.c (eval_string_with_cref): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54343 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: explicit addressnobu2016-03-261-2/+2
| | | | | | | * compile.c (prepare_compile_error): add & to explicit address of functions to suppress warnings by old VC. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54294 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: strict conditionnobu2016-03-171-3/+4
| | | | | | | * compile.c (iseq_specialized_instruction): specialize only concatenated newarray and send, no labels and no adjusts. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54157 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: move newarray specializationnobu2016-03-171-20/+22
| | | | | | | * compile.c (iseq_specialized_instruction): move specialization for opt_newarray_max/min from translation phase. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * compile.c (NODE_CALL): add optimization shortcut for Array#max/min.mame2016-03-171-0/+20
| | | | | | | | | Now `[x, y].max` is optimized so that a temporal array object is not created in some condition. * insns.def (opt_newarray_max, opt_newarray_min): added. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54153 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: bit flagnobu2016-03-171-1/+1
| | | | | | * compile.c (LABEL): turn `set` flag a bit field. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54143 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* optimize named capture assignmentnobu2016-03-141-0/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * compile.c (compile_named_capture_assign): optimize named capture assignments, by replacing repeating global variable accesses with `dup`, and by returning the matched result instead of re-getting it from the MatchData. * parse.y (reg_named_capture_assign_gen): build just assignment nodes for the optimization. ex. `/(?<x>.)/ =~ "bar"` - old ``` 0000 putstring "bar" 0002 opt_regexpmatch1 /(?<x>.)/ 0004 pop 0005 getglobal $~ 0007 branchunless 25 0009 getglobal $~ 0011 putobject :x 0013 opt_aref <callinfo!mid:[], argc:1, ARGS_SIMPLE> 0016 setlocal_OP__WC__0 2 0018 getglobal $~ 0020 putobject_OP_INT2FIX_O_0_C_ 0021 opt_send_without_block <callinfo!mid:begin, argc:1, ARGS_SIMPLE> 0024 leave 0025 putobject nil 0027 setlocal_OP__WC__0 2 0029 putobject nil 0031 leave ``` - new ``` 0000 putstring "bar" 0002 opt_regexpmatch1 /(?<x>.)/ 0004 getglobal $~ 0006 dup 0007 branchunless 14 0009 putobject :x 0011 opt_aref <callinfo!mid:[], argc:1, ARGS_SIMPLE> 0014 setlocal_OP__WC__0 2 0016 leave ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54100 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* fstring early for internal iseqnormal2016-01-261-1/+1
| | | | | | | | | | | | | | | | | | | 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
* compile.c: fix tailcall optimizationnobu2016-01-261-2/+6
| | | | | | | | | | * 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
* compile.c: fix lhs splat in massignnobu2016-01-101-4/+18
| | | | | | | | * 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
* compile.c: adjust call_info countnobu2016-01-011-17/+24
| | | | | | | * 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
* compile.c: remove unreferred labelnobu2016-01-011-0/+3
| | | | | | | * 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
* compile.c: adjust label referencenobu2015-12-291-0/+1
| | | | | | | * 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
* fix common misspelling [ci skip]nobu2015-12-241-1/+1
| | | | | | | * 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