Граф коммитов

52 Коммитов

Автор SHA1 Сообщение Дата
Takashi Kokubun b93d554be9
Fix a typo [ci skip] 2022-08-20 18:36:52 -07:00
Takashi Kokubun ddf96b7693
Drop mswin support of MJIT (#6265)
The current MJIT relies on SIGCHLD and fork(2) to be performant, and
it's something mswin can't offer. You could run Linux MJIT on WSL
instead.

[Misc #18968]
2022-08-20 18:35:36 -07:00
Peter Zhu 3df16924b4 [Feature #18249] Implement ABI checking
Header file include/ruby/internal/abi.h contains RUBY_ABI_VERSION which
is the ABI version. This value should be bumped whenever an ABI
incompatible change is introduced.

When loading dynamic libraries, Ruby will compare its own
`ruby_abi_version` and the `ruby_abi_version` of the loaded library. If
these two values don't match it will raise a `LoadError`. This feature
can also be turned off by setting the environment variable
`RUBY_RUBY_ABI_CHECK=0`.

This feature will prevent cases where previously installed native gems
fail in unexpected ways due to incompatibility of changes in header
files. This will force the developer to recompile their gems to use the
same header files as the built Ruby.

In Ruby, the ABI version is exposed through
`RbConfig::CONFIG["ruby_abi_version"]`.
2022-02-22 09:55:21 -05:00
Nobuyoshi Nakada 7806b2e28b
Use colorize.rb for non-capable terminals 2020-08-11 18:35:08 +09:00
Takashi Kokubun 0e5a58b6bf
Mark some JIT-ed functions as COLDFUNC
Put some functions which are unlikely to be called on JIT in
.text.unlikely section to improve hot code's locality.
2020-05-17 22:21:31 -07:00
Takashi Kokubun fcd2576290
Stop always inlining not-optimized get/setivar
As we have the optimization in _mjit_compile_ivar.erb, we don't use
these functions if we successfully optimize ivars. Therefore it's
consuming code size where we can't optimize it well.

To decrease code size, we'd better avoid inlining them.

```
$ benchmark-driver -v --rbenv 'before --jit;after --jit' benchmark.yml --repeat-count=12 --output=all
before --jit: ruby 2.8.0dev (2020-05-13T04:49:21Z master 61d451d6ce) +JIT [x86_64-linux]
after --jit: ruby 2.8.0dev (2020-05-13T05:46:59Z master a072d323db) +JIT [x86_64-linux]
Calculating -------------------------------------
                                 before --jit           after --jit
Optcarrot Lan_Master.nes     69.8567095356444      73.0360609399857 fps
                             70.3283101279035      74.6106251902062
                             72.9135395729567      75.2797344839106
                             76.6944690546044      77.5705757485036
                             77.0027971817715      78.2269524040059
                             78.5069033659736      78.4457471014131
                             80.1873218604913      80.1273811685818
                             81.3079566400696      81.7148593303302
                             81.7285827817226      81.7637234555871
                             81.7657097839637      82.4520295422720
                             81.8310114206406      82.7532354379759
                             81.9886488857863      82.8358739858206
```
2020-05-12 22:50:05 -07:00
Takashi Kokubun 3cf3427c99
Try asserting no static decl rather than warning
This didn't exist in my machine, but it may exist in some CI
environments.
2020-03-22 15:49:55 -07:00
Takashi Kokubun a55f670757
Reduce the number of lines used by transform_mjit_header 2020-03-22 15:46:53 -07:00
Nobuyoshi Nakada f7f8dc5fd4
Unnamed groups are not captured when named groups are used 2020-01-30 11:31:48 +09:00
kazu c8cbae685f Fix a typo [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65546 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-05 06:02:42 +00:00
nobu 002e0ca428 Create MJIT header with strict permission
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65544 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-05 02:25:46 +00:00
nobu a9025c8841 transform_mjit_header.rb: fix up r65169
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65173 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-19 13:11:33 +00:00
nobu 5a8b81fdd3 transform_mjit_header.rb: `inline` may be a macro
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65170 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-19 12:29:47 +00:00
nobu 15d0180b6e transform_mjit_header.rb: add system_header pragma
* tool/transform_mjit_header.rb: insert GCC system_header pragma
  to get rid of errors caused by the contents included from system
  headers.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65169 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-19 12:29:46 +00:00
k0kubun 6e62e59eec revert r64847, r64846 and r64839
because r64849 seems to fix issues which we were confused about.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64850 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-26 02:38:45 +00:00
k0kubun e08f418230 revert r64838 and r64839
because some build failures persisted

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-26 01:11:20 +00:00
k0kubun 08c9f030f6 Revert "Revert r64824 to fix build failure on AppVeyor"
This reverts commit r64829. I'll prepare another temporary fix, but I'll
separately commit that to make it easier to revert that later.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64838 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-25 17:19:51 +00:00
k0kubun f00bf24272 Revert r64824 to fix build failure on AppVeyor
AppVeyor msys2/MinGW build started to fail like:
https://ci.appveyor.com/project/ruby/ruby/build/9722/job/b94kixi004klmye3

Until I can investigate that, I revert this for now.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64829 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-25 04:03:35 +00:00
k0kubun fb80f6c7ba insns.def: optimize & and | of Integer [experimental]
not optimizing Array#& and Array#| because vm_insnhelper.c can't easily
inline it (large amount of array.c code would be needed in vm_insnhelper.c)
and the method body is a little complicated compared to Integer's ones.
So I thought only Integer#& and Integer#| have a significant impact,
and eliminating unnecessary branches would contribute to JIT's performance.

vm_insnhelper.c: ditto

tool/transform_mjit_header.rb: make sure these instructions are inlined
on JIT.

compile.c: compile vm_opt_and and vm_opt_or.
id.def: define id for them to be used in compile.c and vm*.c
vm.c: track redefinition of Integer#& and Integer#|
vm_core.h: allow detecting redefinition of & and |

test/ruby/test_jit.rb: test new insns
test/ruby/test_optimization.rb: ditto

* Optcarrot benchmark

This is a kind of experimental thing but I'm committing this since the
performance impact is significant especially on Optcarrot with JIT.

$ benchmark-driver benchmark.yml --rbenv 'before::before --disable-gems;before+JIT::before --disable-gems --jit;after::after --disable-gems;after+JIT::after --disable-gems --jit' -v --repeat-count 24
before: ruby 2.6.0dev (2018-09-24 trunk 64821) [x86_64-linux]
before+JIT: ruby 2.6.0dev (2018-09-24 trunk 64821) +JIT [x86_64-linux]
after: ruby 2.6.0dev (2018-09-24 opt_and 64821) [x86_64-linux]
last_commit=opt_or
after+JIT: ruby 2.6.0dev (2018-09-24 opt_and 64821) +JIT [x86_64-linux]
last_commit=opt_or
Calculating -------------------------------------
                             before  before+JIT       after   after+JIT
Optcarrot Lan_Master.nes     51.460      66.315      53.023      71.173 fps

Comparison:
             Optcarrot Lan_Master.nes
               after+JIT:        71.2 fps
              before+JIT:        66.3 fps - 1.07x  slower
                   after:        53.0 fps - 1.34x  slower
                  before:        51.5 fps - 1.38x  slower

[close https://github.com/ruby/ruby/pull/1963]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64824 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-24 12:40:28 +00:00
k0kubun 24e30ef76e transform_mjit_header.rb: add static to Init_*
as well, to make CI succeed with VM_CHECK_MODE > 1.

vm_insnhelper.c: drop unnecessary MJIT_HEADER ifdef. This is intended to
be ignored by having `static inline`. Removing that by macro would be
helpful for minimizing compilation time, but the impact is not so big
and having many MJIT_HEADER check would be bad for maintainability.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64682 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-11 11:26:15 +00:00
k0kubun cf855124d6 transform_mjit_header.rb: more strict FUNC_HEADER_REGEXP
to reduce "SKIPPED" logs on MJIT header build.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64144 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-31 12:55:28 +00:00
k0kubun d3f57771e0 transform_mjit_header.rb: accept having attribute
between a type of return value and function identifier. Like:

```
rb_control_frame_t *
__attribute__ ((__fastcall__)) rb_vm_opt_struct_aref(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp)
{
    ...
}
```

[Bug #14949]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64138 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-31 11:18:59 +00:00
k0kubun 63f51f5283 transform_mjit_header.rb: fix performance regression
on r64031. Compiling vm_search_method_slowpath is very slow.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64034 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-24 14:43:40 +00:00
ngoto 1c67c46efb transform_mjit_header.rb: workaround for Solaris 10 with old GCC
* 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
2018-05-11 16:47:38 +00:00
nobu 3f8711a092 transform_mjit_header.rb: read output and errors
* 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
2018-03-17 02:18:46 +00:00
k0kubun 0a2fb188e3 transform_mjit_header.rb: inline ivar operations
* Optcarrot

before,--jit: ruby 2.6.0dev (2018-03-07 trunk 62689) +JIT [x86_64-linux]
after,--jit: ruby 2.6.0dev (2018-03-07 trunk 62689) +JIT [x86_64-linux]
last_commit=transform_mjit_header.rb: inline ivar operations
Calculating -------------------------------------
                     before,--jit  after,--jit
           optcarrot       67.852       69.359 fps

Comparison:
                        optcarrot
         after,--jit:        69.4 fps
        before,--jit:        67.9 fps - 1.02x  slower

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62693 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-07 14:35:28 +00:00
k0kubun eeaa053eae transform_mjit_header.rb: inline VM instructions
* Optcarrot benchmark (--jit)

Before: 62.42 fps
After: 65.31 fps

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62677 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-06 12:53:19 +00:00
k0kubun 5053851ef8 transform_mjit_header.rb: drop obsoleted debug code
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
2018-03-06 11:46:02 +00:00
k0kubun 29777e308c common.mk: add comments about r62355 [ci skip]
transform_mjit_header.rb: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-11 05:29:13 +00:00
k0kubun 1a45a3a797 transform_mjit_header.rb: fix typo in r62326
Today's AIX CI failed due to this... 😇

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62332 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-09 13:14:17 +00:00
k0kubun 211ff9499d transform_mjit_header.rb: pass -std=c99 for AIX gcc
I heard `error: conflicting types for 'restrict'` can be solved by
adding `-std=c99`.

Ideally we should use the same cflags which are used to compile vm.c,
but let me try this and see what happens on AIX.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62326 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-09 00:00:27 +00:00
k0kubun cf03675ce8 transform_mjit_header.rb: very verbose error log
for debugging AIX..... I have no idea why AIX's gcc is failing to
transform MJIT header....

Today's CI output:
https://rubyci.org/logs/rubyci.s3.amazonaws.com/aix71_ppc/ruby-trunk/log/20180207T113303Z.log.html.gz#make

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62290 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-07 14:25:03 +00:00
k0kubun 13b376c561 transform_mjit_header.rb: apply Regexp.escape
to prevent future breakage

Following up r62285

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62287 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-07 14:01:51 +00:00
k0kubun 646b24a9c8 transform_mjit_header.rb: ignore unsupported cc
to generate MJIT header.

Even if we can't build MJIT header, Ruby's build should success. And
compilers which are not explicitly supported are likely to fail to
transform MJIT header.

Also you can pass only gcc or clang to --jit-cc=xxx for now. Thus
generating header does never make sense.

So I decided to conservatively give up MJIT header generation.
But please feel free to add your favorite compiler's macro if you think
it's working. (Another workaround is passing -D__GNUC__ :p)

[Bug #14447] [Bug #14446]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62285 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-07 13:48:48 +00:00
k0kubun 7536797f81 transform_mjit_header.rb: resurrect `exit false`
which was just unintentionally dropped at r62252.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62257 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-06 14:58:12 +00:00
k0kubun dbb63aeea6 transform_mjit_header.rb: add output for debug
AIX's header build is failing like:

./miniruby -I./lib -I. -I.ext/common  ./tool/transform_mjit_header.rb "/usr/bin/gcc " rb_mjit_header.h .ext/include/powerpc-aix7.1.3.0/rb_mjit_min_header-2.6.0.h
error in initial header file:
/home/odaira/chkbuild/tmp/build/20180206T113302Z/tmp/20180206-15335556-aaiego.c:19:59: error: conflicting types for 'restrict'
 extern size_t fread(void *restrict, size_t, size_t, FILE *restrict);
                                                           ^

https://rubyci.org/logs/rubyci.s3.amazonaws.com/aix71_ppc/ruby-trunk/log/20180206T113302Z.log.html.gz#make

It's so hard to know the cause from current output. Let me add debug
output and see tomorrow's CI result.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62252 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-06 13:47:02 +00:00
kazu 49d787359a Remove unused capture
Because `Regexp#to_s` add `(?-mix:)`, it is not unnecessary.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62250 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-06 12:40:41 +00:00
k0kubun e23aefe288 transform_mjit_header.rb: restrict transformation
to whitelisted patterns. This fix is for NetBSD.

[Bug #14439]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-05 15:39:55 +00:00
nobu da79033a30 transform_mjit_header.rb: same command after error
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62232 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-05 13:58:48 +00:00
k0kubun 9895f69460 transform_mjit_header.rb: check initial code
separating the macros. Applying the kept macros to code which is already
affected by the macros may cause errors in initial code.

This is hopefully the final fix for icc build failure.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62226 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-05 12:19:38 +00:00
k0kubun 70a7bc3967 transform_mjit_header.rb: remove predefined macros
semi-automatically.

This is basically for icc's __DATE__, __TIME__, and many other families.
It causes an error by predefined macro redefinition.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-05 12:05:04 +00:00
nobu 961569b952 transform_mjit_header.rb: no extra CRs
* tool/transform_mjit_header.rb (MJITHeader.check_code!): open
  temporary file in binary mode too, not to include extra CRs.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62222 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-05 04:58:04 +00:00
nobu 5c6162ad3f transform_mjit_header.rb: take program name from $0
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62216 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-05 02:07:49 +00:00
nobu 3f45bbfe0e transform_mjit_header.rb: read/write in binmode
* tool/transform_mjit_header.rb: read and write as ASCII-8BIT to
  make single-byte-optimizable always.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62215 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-05 02:02:23 +00:00
nobu 70ae83f8e1 transform_mjit_header.rb: separate macro and code
* tool/transform_mjit_header.rb (separate_macro_and_code): return
  macro and code separately as the name, and concat before output.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62214 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-05 00:52:45 +00:00
nobu a38b3307b6 transform_mjit_header.rb: scan by regexp
* tool/transform_mjit_header.rb (find_decl): scan by regexp
  instead of char-by-char loop.  return nil when finished.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-05 00:52:20 +00:00
kazu e743b36318 Use system option instead of shell redirect
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62212 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-05 00:09:09 +00:00
nobu e81687527a transform_mjit_header.rb: refactor messages and exit
* tool/transform_mjit_header.rb: print non-error messages to
  STDOUT instead of STDERR.  exit with false or abort instead of
  exit 1.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62205 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-04 13:51:02 +00:00
nobu e35ff78985 match whole word
* tool/transform_mjit_header.rb: add word boundary anchors and
  match whole word to get rid of false `static` declarations,
  e.g., rb_str_new_static.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62199 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-04 13:12:57 +00:00
kazu 83a9ccb0f2 Fix typos and remove redundant `/#{}/`
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62198 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-04 11:59:19 +00:00