* 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
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
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
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
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 (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_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 (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
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
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
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 (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
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
* 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 (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
* 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 (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 (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 (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 (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 (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
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
* 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_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 (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
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 (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 (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