aboutsummaryrefslogtreecommitdiffstats
path: root/compile.c
Commit message (Collapse)AuthorAgeFilesLines
* compile.c: wrong optimizationnobu2017-04-181-11/+1
| | | | | | | | * compile.c (compile_branch_condition): expression which has side effects should not be eliminated. [ruby-core:80740] [Bug #13444] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58398 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* introduce imemo_type_p(v, imemo_type)ko12017-04-071-1/+1
| | | | | | | | * internal.h: introduce imemo_type_p() which checks the given value is T_IMEMO and imemo_type() == given imemo_type. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58268 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: remove side effects by debug macrosnobu2017-04-051-17/+5
| | | | | | | | * compile.c (debugp_param): do not evaluate arguments of debug macros, unless the debug mode is enabled. these macros should not have side effects. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58253 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: avoid duplicate mark entry for string literal Rangenormal2017-04-021-1/+1
| | | | | | | | | | | | iseq_add_mark_object is called in iseq_set_sequence later on, so we only need to call iseq_add_mark_object_compile_time in iseq_peephole_optimize. Without this change, there would've been a duplicate entry in the long-lived iseq mark_ary. * compile.c (iseq_peephole_optimize): avoid duplicate mark object entry [ruby-core:80536] [Feature #13355] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58238 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: optimize literal String range in case/when dispatchnormal2017-04-011-0/+31
| | | | | | | | | | | | | | | | | | | This is similar in spirit to opt_case_dispatch as the literal Range here is guaranteed to be immutable when used for checkmatch. Normal range literals with non-frozen strings are actually mutable, as Range#begin and Range#end exposes the strings to modification. So those Range objects cannot be frozen without breaking compatibility, but Ranges in case/when dispatch can be frozen at compile time. * compile.c (iseq_peephole_optimize): persistent Range creation when String literals are used as beginning and end of range when used for case/when dispatch. [ruby-core:80290] [Feature #13355] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58233 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* fix redefinition optimization for -"literal string" (UMinus)normal2017-03-271-1/+6
| | | | | | | | | | | | | | | | | Unfortunately this enlarges insns.def by yet another instruction. However, it is much prettier than opt_str_freeze in use, and maybe we can avoid having so many instructions in the future. [ruby-core:80368] * insns.def (DEFINE_INSN): new instruction: opt_str_uminus (maybe temporary) * compile.c (iseq_compile_each0): split instructions * test/ruby/test_optimization.rb (test_string_uminus): new test * vm.c (vm_init_redefined_flag): set redefinintion flag for uminus * vm_core.h (enum ruby_basic_operators): add BOP_UMINUS git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58144 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* remove branches in dmark and dfree GC callbacksnormal2017-03-171-11/+7
| | | | | | | | | | | | | | | | | dmark and dfree callbacks are never called in gc.c for NULL DATA_PTR values, not even for zombie objects. * compile.c (ibf_loader_mark): remove branch for pointer validity * compile.c (ibf_loader_free): ditto * cont.c (cont_free): ditto * cont.c (fiber_free): ditto * dir.c (dir_free): ditto * ext/stringio/stringio.c (strio_mark): ditto * proc.c (binding_free): ditto * thread_sync.c (mutex_free): ditto * vm.c (thread_free): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Fix a consistency bug of ISEQ_COVERAGE [Bug #13305]mame2017-03-141-1/+4
| | | | | | | | | There is an invariant that ISEQ_COVERAGE(iseq) must be Qnil if and only if option->coverage_enabled is false. This invariant was broken by NODE_PRELUDE which updates option->coverage_enabled but not ISEQ_COVERAGE(iseq). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57971 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: compile flip-flopnobu2017-03-131-1/+2
| | | | | | * compile.c (iseq_compile_each0): compile flip-flop directly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57947 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: omit newrangenobu2017-03-131-8/+5
| | | | | | | * compile.c (iseq_compile_each): omit creating literal-only range to be popped immediately. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57946 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: compile_const_prefixnobu2017-03-121-7/+7
| | | | | | | * compile.c (compile_const_prefix): rename, and check the result of parts of the prefix. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57908 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: omit newhashnobu2017-03-121-5/+2
| | | | | | | * compile.c (iseq_compile_each): omit creating literal-only hash to be popped immediately. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57892 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: NODE_VALUES must not be poppednobu2017-03-121-3/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57891 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: iseq_compile_each0nobu2017-03-111-10/+13
| | | | | | | * compile.c (iseq_compile_each0): split from null node case to constify line and type. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57890 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: compile_whennobu2017-03-111-50/+56
| | | | | | * compile.c (compile_when): extract from iseq_compile_each. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57889 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: compile_casenobu2017-03-111-107/+115
| | | | | | * compile.c (compile_case): extract from iseq_compile_each. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57888 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: constify flagsnobu2017-03-111-11/+9
| | | | | | | | | * compile.c (compile_cpath): return `noscoped` bit flag, instead of boolean flag. * compile.c (iseq_compile_each): constify flags. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57836 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: apply opt_str_freeze to String#-@ (uminus)normal2017-03-101-1/+2
| | | | | | | | The same optimization used for "literal string".freeze can easily apply to uminus without introducing any compatibility problems. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57828 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* revert RB_FIXABLE related changesets [Bug #13288][Bug #13293][Bug #13294]shyouhei2017-03-091-1/+1
| | | | | | | | | This commit is auto-generated using following command: svn diff -r57807:57788 include internal.h bignum.c numeric.c compile.c insns.def object.c sprintf.c | patch -p0 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57818 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* optimize FIXABLE macroshyouhei2017-03-061-1/+1
| | | | | | | | | | | | Looking at the source code, FIXABLE tends to be just before LOING2FIX to check applicability of that operation. Why not try computing first then check for overflow, which should be optimial. I also tried the same thing for unsigned types but resulted in slower execution. It seems RB_POSFIXABLE() is fast enough on modern CPUs. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57789 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: variable typenobu2017-03-051-1/+1
| | | | | | | | * compile.c (iseq_compile_each): fix variable type, use VALUE for Symbol. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?revision=57772&view=revision git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57783 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: operand size checknobu2017-03-041-2/+4
| | | | | | | * compile.c (ibf_load_code): raise an exception on invalid operand size. should not use assert() to validate incoming data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57774 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: memory leaknobu2017-03-041-8/+17
| | | | | | | * compile.c (iseq_set_sequence): fix potential memory leaks on an invalid instruction sequence. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57773 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: fix invalid label messagenobu2017-03-041-2/+2
| | | | | | | * compile.c (validate_label): fix invalid label message. registered labels are Symbols, not IDs. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57772 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* deduplicate strings sooner at load and compilenormal2017-03-011-2/+2
| | | | | | | | | | | | We can use rb_fstring_cstr in some places to prevent an intermediate object from being created before deduplication via rb_fstring. * compile.c (iseq_compile_each): use rb_fstring_cstr (rb_insns_name_array): ditto * load.c (rb_load_internal0): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57745 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* kwrest arg namenobu2017-02-271-3/+3
| | | | | | | | | | * compile.c (iseq_set_arguments_keywords): make keyword rest argument name nd_vid consistently, regardless of whether other keyword arguments are present. [Fix GH-1529] * parse.y (new_args_tail_gen): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57733 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: Fix a typoyui-knk2017-02-201-1/+1
| | | | | | | * compile.c (compile_branch_condition): NODE_LIT is always true. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57666 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: suppress a warningnobu2017-02-131-1/+1
| | | | | | | * compile.c (iseq_build_kw): suppress an alloc-size-larger-than warning by gcc 7. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57617 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: restore catch entry spnobu2017-02-021-1/+8
| | | | | | | | * compile.c (iseq_build_from_ary_exception): restore stack depth of catch entries. accurate stack depths cannot be calculated from dumped array. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57498 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: restore misc paramsnobu2017-02-021-5/+13
| | | | | | | * compile.c (rb_iseq_build_from_ary): restore misc params. accurate stack depths cannot be calculated from dumped array. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57497 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: keyword table for required kwargnobu2017-02-021-1/+2
| | | | | | | * compile.c (iseq_build_kw): keyword table is necessary also when required keyword argumetns only. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57496 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* 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