This adds support for lldb as a debugger so that tests can be run under
lldb like this:
$ make test-all TESTS=test/some_test.rb RUNRUBYOPT=--debugger=lldb
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63921 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
if the tag is already checked out, to optimize the execution time.
I'm going to prepare a task depending on this tool, and I want that to
finish fast and output nothing when it's already up-to-date.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63883 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
r63655 was tightly coupled to handle_frames and some assumptions seems
to have been broken by r63763.
To partially resolve Bug#14892, this reverts the optimization for now. I
want to make MJIT CI happy first and then I'll probably retry r63655 by
partially reverting r63763 for sp changes.
The skipped test is not fixed yet.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63863 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
I introduced this mechanism in r62051 to speed things up. Later it
was reported that the change causes problems. I searched for
workarounds but nothing seemed appropriate. I hereby officially
give it up. The idea to move ADD_PC around was a mistake.
Fixes [Bug #14809] and [Bug #14834].
Signed-off-by: Urabe, Shyouhei <shyouhei@ruby-lang.org>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63763 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
It never becomes `dispatched: true` with the current code.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63751 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* configure.ac: removed DISABLE_RUBYGEMS macro from config.h, not
to rebuild everything when the flag changed.
* configure.ac, win32/configure.bat: make USE_RUBYGEMS lowercase.
* tool/mkconfig.rb: remove RUBYGEMS stuff from rbconfig.rb, not to
reconfigure and rebuild all extension libraries.
* Makefile.in (CPPFLAGS): enable/disable Rubygems by USE_RUBYGEMS.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63718 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This reverts commit 9d015aa91cc3ec45e41be58fd836fb7f6655a624.
Because tool/extlibs.rb runs with BASERUBY that may be ruby < 2.3
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63617 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This allows user to specify any name in `--with-so-name` that might
cause a name clash with LIBRUBY_ALIASES on the platform.
Without this, for example, configuring with `--with-soname=ruby
--enable-shared` on macOS would end up running `ln -sf libruby.dylib
libruby.dylib` only to fail with the following error in installation:
```
make[2]: stat: libruby.dylib: Too many levels of symbolic links
```
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63544 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* tool/redmine-backporter.rb (StringScanner.readline): use `true`
to suppress a "literal in condition" warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63458 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
for now, which was committed in r63333.
Currently trunk's JIT seems to have some wrong behaviors, and this is
the most suspicious culprit of them for now. In the future, I may have
a strict test environment to detect the cause, but there's no enough
time to test this until preview2. So let me revert this and see how it
goes after this.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63455 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* tool/generic_erb.rb: get rid of FileUtils.touch, not to depend
on fileutils.rb which will depend on rbconfig.rb which does not
exist when creating encdb.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63432 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* tool/transform_mjit_header.rb (MJITHeader.conflicting_types?):
Add workaround for Solaris 10 with old GCC (4.6.2), that is
essentially the same as for AIX (commit r62326), but probably
due to different GCC versions, different error message is shown.
[Bug #14751] [ruby-dev:50541]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63400 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
reverting r63379 (revert of r63360).
The cause of error seems to be r63350. See r63382.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Revert "_mjit_compile_send.erb: inline recursive call"
I reverted r63360 in r63379, but the errors were reproductive from
r63350. So I need to revert this.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63382 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Revert "_mjit_compile_pc_and_sp.erb: make sure no uninitialized"
This triggered some `NoMethodError`s which seem to be caused by the
commit like: https://travis-ci.org/k0kubun/mjit-test/builds/376416934
I'll add tests and fix it later...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63379 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
area on VM stack to prevent SEGV on GC. GC may mark every value in VM
stack.
Unfortunately I couldn't write a test for it... So let me explain the
situation.
SEGV example:
https://gist.github.com/k0kubun/c7cea2b5761ffdff29ec79ea1a8f7f91
```
$ ruby --dump=insns -e 'def oct(num, len); "%0#{len}o" % num; end'
== disasm: #<ISeq:oct@-e:1 (1,0)-(1,41)> (catch: FALSE)
local table (size: 2, argc: 2 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
[ 2] num@0<Arg> [ 1] len@1<Arg>
0000 putobject "%0" ( 1)[LiCa]
0002 getlocal_WC_0 len@1
0004 dup
0005 checktype T_STRING
0007 branchif 14
0009 dup
0010 opt_send_without_block <callinfo!mid:to_s, argc:0, FCALL|ARGS_SIMPLE>, <callcache>
0013 tostring
0014 putobject "o"
0016 concatstrings 3
0018 getlocal_WC_0 num@0
0020 opt_mod <callinfo!mid:%, argc:1, ARGS_SIMPLE>, <callcache>
0023 leave [Re]
```
Prior to this commit, after arguments are pushed on 0010, stacks were:
VM stack: [uninitialized, uninitialized, len]
JIT stack: ["%0", len, len]
And then, when GC is invoked on 0016, VM stack will be [uninitialized, uninitialized]
and those uninitialized values will be marked by GC.
With this commit, after arguments are pushed on 0010, stacks will be:
VM stack: [len]
JIT stack: ["%0", len, len]
And VM stack will be [] on 0016.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63360 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This reverts r63249 (revert r63212) and fixes a bug in it. The test to
prevent the bug is added as well.
vm_insnhelper.c: add `index` argument to vm_getivar. The argument is
created so that MJIT can pass the value of `cc->aux.index` on compilation
time. The cache invalidation in _mjit_compile_send_guard.erb is only
working for the cache value on compilation time.
Note: As `index` is always passed as constant and it's force-inlined,
the performance of `vm_getivar` won't be degraded in VM.
_mjit_compile_send_guard.erb: New. Used to invalidate inlined values of cc.
common.mk: update dependencies for _mjit_compile_send_guard.erb
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63333 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
between branches.
mjit_compile.inc.erb: move the compiled_for_pos reference to
mjit_compile.c
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63331 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
on JIT compilation. r63092 was risky without this check.
mjit_compile.c: update comment about stack consistency check
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63329 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* tool/rbinstall.rb ($script_installer.stub): read stub file on
demand. as `$cmdtype` is set to "exe" in parse_args, it is not
set yet when `$script_installer` is defined.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63268 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
except test_jit.rb.
In some situations, this generates a wrong code. I'll add a test for it
later but let me revert this to make it work for now.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63249 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
to introduce additional optimization for another `cc->me->def->type`
later. I carved out the `cc->me->def->type == VM_METHOD_TYPE_ISEQ`
part because I wanted to check other types as well.
mjit_compile.c: drop get_iseq_if_available and define simplified version
of it, has_valid_method_type.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63199 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
We need to mark default values for kwarg methods. This also fixes
Bootsnap. IBF iseq loading needed to mark iseqs as "having markable
objects".
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62851 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* tool/transform_mjit_header.rb (MJITHeader.check_code): read
output and errors than discarding errors. also cl.exe prints
the source file name which is a garbage at this time.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62788 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Directly marking iseq operands allows us to eliminate the "mark array"
stored on ISEQ objects, which will reduce the amount of memory ISEQ
objects consume. This patch changes the iseq mark function to:
* Directly marks ISEQ operands
* Iterate over and mark child ISEQs
It also introduces two flags on the ISEQ object. In order to mark
instruction operands, we have to disassemble the instructions and find
the instruction parameters and types. Instructions may also be
translated to jump addresses. Instruction sequences may get marked by
the GC *while* they're mid flight (being compiled). The
`ISEQ_TRANSLATED` flag is used to indicate whether or not the
instructions have been translated to jump addresses so that when we
decode the instructions we know whether or not we need to go from jump
location back to original instruction or not.
Not all ISEQ objects have any markable objects embedded in their
instructions. We can detect whether or not an ISEQ has markable objects
in the instructions at compile time. If the instructions contain
markable objects, we set a flag `ISEQ_MARKABLE_ISEQ` on the ISEQ object.
This means that during the mark phase, we can skip decompilation if the
flag is *not* set. In other words, we can avoid decompilation of we
know in advance there is nothing to mark.
`once` instructions have an operand that contains the result of a
one-time compilation of a regex. Before this patch, that operand was
called an "inline cache", even though the struct was actually an "inline
storage". This patch changes the operand to be an "inline storage" so
that we can differentiate between caches that need marking (the inline
storage) and caches that don't need marking (inline cache).
[ruby-core:84909]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62706 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
on !body->catch_except_p. We need to move pc only when JIT execution is
canceled if the frame does not catch an exception.
_mjit_compile_insn.erb: lazily move pc for such optimized case
_mjit_compile_insn_body.erb: ditto
_mjit_compile_send.erb: ditto
* Optcarrot benchmark (--jit)
Before: 65.31 fps
After: 67.82 fps
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62678 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Now RubyCI is stable for this part. We no longer use this.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62676 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
if catch_except_p is FALSE. If catch_except_p is TRUE, stack values
should be on VM's stack when exception is thrown and the JIT-ed frame
is re-executed by VM's exception handler. If it's FALSE, the JIT-ed
frame won't be re-executed and don't need to keep values on VM's stack.
Using local variables allows us to reduce cfp->sp motion. Moving cfp->sp
is needed only for insns whose handles_frame? is false. So it improves
performance.
_mjit_compile_insn.erb: Prepare `stack_size` variable for GET_SP,
STACK_ADDR_FROM_TOP, TOPN macros. Share pc and sp motion partial view.
Use cancel handler created in mjit_compile.c.
_mjit_compile_send.erb: ditto. Also, when iseq->body->catch_except_p is
TRUE, this stops to call mjit_exec directly. I described the reason in
vm_insnhelper.h's comment for EXEC_EC_CFP.
_mjit_compile_pc_and_sp.erb: Shared logic for moving sp and pc. As you
can see from thsi file, when status->local_stack_p is TRUE and
insn.handles_frame? is false, moving sp is skipped. But if
insn.handles_frame? is true, values should be rolled back to VM's stack.
common.mk: add dependency for the file
_mjit_compile_insn_body.erb: Set sp value before canceling JIT on
DISPATCH_ORIGINAL_INSN. Replace GET_SP, STACK_ADDR_FROM_TOP, TOPN macros
for the case ocal_stack_p is TRUE and insn.handles_frame? is false.
In that case, values are not available on VM's stack and those macros
should be replaced.
mjit_compile.inc.erb: updated comments of macros which are supported by
JIT compiler. All references to `cfp->sp` should be replaced and thus
INC_SP, SET_SV, PUSH are no longer supported for now, because they are
not used now.
vm_exec.h: moved EXEC_EC_CFP definition to vm_insnhelper.h because it's
tighly coupled to CALL_METHOD.
vm_insnhelper.h: Have revised EXEC_EC_CFP definition moved from vm_exec.h.
Now it triggers mjit_exec for VM, and has the guard for catch_except_p
on JIT-ed code. See comments for details. CALL_METHOD delegates
triggering mjit_exec to EXEC_EC_CFP.
insns.def: Stopped using EXEC_EC_CFP for the case we don't want to
trigger mjit_exec. Those insns (defineclass, opt_call_c_function) are
not supported by JIT and it's safe to use RESTORE_REGS(), NEXT_INSN().
expandarray is changed to pass GET_SP() to replace the macro in
_mjit_compile_insn_body.erb.
vm_insnhelper.c: change to take sp for the above reason.
[close https://github.com/ruby/ruby/pull/1828]
This patch resurrects the performance which was attached in
[Feature #14235].
* Benchmark
Optcarrot (with configuration for benchmark_driver.gem)
https://github.com/benchmark-driver/optcarrot
$ benchmark-driver benchmark.yml --verbose 1 --rbenv 'before;before+JIT::before,--jit;after;after+JIT::after,--jit' --repeat-count 10
before: ruby 2.6.0dev (2018-03-04 trunk 62652) [x86_64-linux]
before+JIT: ruby 2.6.0dev (2018-03-04 trunk 62652) +JIT [x86_64-linux]
after: ruby 2.6.0dev (2018-03-04 local-variable.. 62652) [x86_64-linux]
last_commit=mjit_compile.c: use local variables for stack
after+JIT: ruby 2.6.0dev (2018-03-04 local-variable.. 62652) +JIT [x86_64-linux]
last_commit=mjit_compile.c: use local variables for stack
Calculating -------------------------------------
before before+JIT after after+JIT
optcarrot 53.552 59.680 53.697 63.358 fps
Comparison:
optcarrot
after+JIT: 63.4 fps
before+JIT: 59.7 fps - 1.06x slower
after: 53.7 fps - 1.18x slower
before: 53.6 fps - 1.18x slower
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62655 b2dd03c8-39d4-4d8f-98ff-823fe69b080e