summaryrefslogtreecommitdiff
path: root/compile.c
AgeCommit message (Collapse)Author
2017-04-18compile.c: wrong optimizationnobu
* 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
2017-04-07introduce imemo_type_p(v, imemo_type)ko1
* 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
2017-04-05compile.c: remove side effects by debug macrosnobu
* 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
2017-04-02compile.c: avoid duplicate mark entry for string literal Rangenormal
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
2017-04-01compile.c: optimize literal String range in case/when dispatchnormal
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
2017-03-27fix redefinition optimization for -"literal string" (UMinus)normal
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
2017-03-17remove branches in dmark and dfree GC callbacksnormal
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
2017-03-14Fix a consistency bug of ISEQ_COVERAGE [Bug #13305]mame
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
2017-03-13compile.c: compile flip-flopnobu
* 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
2017-03-13compile.c: omit newrangenobu
* 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
2017-03-12compile.c: compile_const_prefixnobu
* 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
2017-03-12compile.c: omit newhashnobu
* 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
2017-03-12compile.c: NODE_VALUES must not be poppednobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57891 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-11compile.c: iseq_compile_each0nobu
* 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
2017-03-11compile.c: compile_whennobu
* 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
2017-03-11compile.c: compile_casenobu
* 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
2017-03-11compile.c: constify flagsnobu
* 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
2017-03-10compile.c: apply opt_str_freeze to String#-@ (uminus)normal
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
2017-03-09revert RB_FIXABLE related changesets [Bug #13288][Bug #13293][Bug #13294]shyouhei
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
2017-03-06optimize FIXABLE macroshyouhei
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
2017-03-05compile.c: variable typenobu
* 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
2017-03-04compile.c: operand size checknobu
* 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
2017-03-04compile.c: memory leaknobu
* 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
2017-03-04compile.c: fix invalid label messagenobu
* 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
2017-03-01deduplicate strings sooner at load and compilenormal
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
2017-02-27kwrest arg namenobu
* 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
2017-02-20compile.c: Fix a typoyui-knk
* 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
2017-02-13compile.c: suppress a warningnobu
* 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
2017-02-02compile.c: restore catch entry spnobu
* 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
2017-02-02compile.c: restore misc paramsnobu
* 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
2017-02-02compile.c: keyword table for required kwargnobu
* 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
2017-01-20compile.c: optimization of defined? in conditionnobu
* 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
2017-01-19compile.c: check err_infonobu
* 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
2017-01-12immediate message mode of compile errornobu
* 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
2017-01-12compile.c: invalid yield in mainnobu
* 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
2017-01-10compile.c: check compilenobu
* 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
2017-01-03compile.c: fallback nilnobu
* 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
2017-01-03compile.c: omit unnecessary defined guardnobu
* 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
2016-12-24compile.c: constifynobu
* 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
2016-12-21compile.c: toplevel returnnobu
* 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
2016-12-17compile.c: do not emit numeric literal range in void contextrhe
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
2016-12-09remove core#hash_merge_arynobu
* 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
2016-12-08compile.c: static_literal_valuenobu
* 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
2016-12-08compile.c: optimize literal nodesnobu
* 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
2016-12-07compile.c: remove dead codenobu
* 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
2016-12-06Fix typoskazu
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
2016-11-28compile.c: splatarray peephole optnobu
* 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
2016-11-05* compile.c (tailcallable_p): disable tail call optimization forshugo
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
2016-10-29compile.c: not flip-flopnobu
* 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
2016-10-22compile.c: order with splattingnobu
* 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