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

1555 Коммитов

Автор SHA1 Сообщение Дата
samuel 3ccb5b9770 Support Visual C++ (mswin)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65879 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-20 10:18:25 +00:00
nobu 45295303ac gmake.mk: force updating revision.h
Since `.revision.time` recipe needs `$(BASERUBY)`, it should not
try to get updated unconditionally, or tarballs fail to build on
environments where BASERUBY is not available.

All developers who build frequently use GNU make anyway, don't
you?

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65695 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-13 03:24:18 +00:00
nobu 1febaff10d win32/setup.mak: Substitute slashes in `MJIT_CC`
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65669 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-11 23:22:54 +00:00
nobu 2fcdfa6e9b `MJIT_BUILD_DIR` is not used on Windows
Because `LOAD_RELATIVE` is always enabled on Windows.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65668 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-11 23:22:53 +00:00
nobu 852ddf187b Expand MJIT_CC on mswin too
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65608 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-07 15:47:21 +00:00
ko1 b4766a4d9e support --disable-mjit-support on mswin32/64.
* win32/configure.bat: add --enable/disable-mjit-support
  configure.bat options.

* win32/setup.mak: ditto.

* win32/Makefile.sub: ditto.

* win32/Makefile.sub: fix typo for congig.status file.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65249 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-20 14:07:59 +00:00
ko1 9f5d9d3169 fix macro-name.
* win32/Makefile.sub: Not MJIT_SUPPORT, but USE_MJIT.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-20 11:35:11 +00:00
ko1 ecac8d0c34 fix MJIT_SUPPORT on win32.
* win32/Makefile.sub: add MJIT_SUPPORT macro for C codes
  and variable for Makefile.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65232 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-20 11:27:48 +00:00
ko1 0b19e15a12 rename configure option `--disable-mjit` to `--disable-mjit-support`
* configure.ac: rename configure option `--disable-mjit` to
  `--disable-mjit-support` because `--disable-mjit` is ambiguous that
  runtime MJIT default enable option or supporting MJIT features.
  `ENABLE_MJIT` is also renamed to `MJIT_SUPPORT`

* Makefile.in: catch up this fix.

* common.mk: ditto.

* test/ruby/test_jit.rb: ditto.

* win32/Makefile.sub: catch up this fix on mswin.

* tool/mkconfig.rb: fix to pass `MJIT_SUPPORT` key.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65217 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-20 08:00:42 +00:00
k0kubun 6e11415b9c configure.ac: add --disable-install-mjit-header
and substitute INSTALL_MJIT_HEADER. This would be convenient as a workaround
for user if we found a platform that can't compile Ruby after Ruby 2.6.0 release.

common.mk: Install MJIT header only when INSTALL_MJIT_HEADER
Makefile.in: ditto
win32/Makefile.sub: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65171 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-19 12:31:02 +00:00
nobu f2427a436f Define PRIdPTR etc
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65064 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-13 16:21:07 +00:00
k0kubun e296f6cf63 win32/win32.c: fix typo in comment [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65051 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-13 01:32:20 +00:00
k0kubun cc5154af6d win32/win32.c: I meant FindFreeChildSlot [ci skip]
which was formerly used in CreateChild.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65049 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-13 00:25:58 +00:00
k0kubun 26519ebaed win32/win32.c: don't call FindChildSlot in MJIT
worker. It's very likely to be thread-unsafe and so it's better to avoid
using in MJIT worker to prevent surprises by race condition.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65048 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-13 00:22:18 +00:00
svn d6b0fe7db1 * expand tabs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65045 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-12 23:57:44 +00:00
k0kubun 09cd99b304 win32/win32.c: drop always-NULL psa parameter
I'm simplifying the interface of ChildRecord as I'm going to complicate
it a little next.

I didn't drop hInput since leaving it would be more natural as its
interface.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65044 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-12 23:57:42 +00:00
k0kubun b712840c8a mjit_worker.c: suppress child process's output properly
Prior to this commit, some of parent process's output was unintentionally
suppressed. We couldn't suppress only child process's output with spawnvp.

Instead of that, this commit uses CreateProcess directly to redirect stdout
and stderr only for child process.

As it's dealing with HANDLE returned from CreateProcess, now waitpid macro
needs to CloseHandle it.

win32/win32.c: Introduce rb_w32_start_process which is designed for MJIT
worker. Other similar functions can't be used since they are using ALLOCV
that may trigger GC, which should be avoided on MJIT worker.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65033 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-12 15:14:51 +00:00
k0kubun 0fd5f063aa win32/Makefile.sub: generate MJIT header pdb
in the MJIT-header-specific path, not default path like vc140.pdb.

mjit_worker.c: specify the MJIT-header-specific pdb path.

tool/rbinstall.rb: install MJIT header pdb as well.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65003 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-11 16:28:04 +00:00
k0kubun 34ade9a4b7 win32/Makefile.sub: install MJIT header and object
to prefix. This is a retry of r64947. So this doesn't still make mswin MJIT
on install directory succeed. One more step required.

tool/rbinstall.rb: This change is needed to install headers correctly since
the extensions are .obj and .pch, not .h


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65000 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-11 15:01:56 +00:00
k0kubun 1f49e9bc62 revert r64947 and r64949
Both didn't work well on mswin. Reverting.
https://ci.appveyor.com/project/ruby/ruby/builds/19322867/job/28fgwiq8j7hdmeu6
https://ci.appveyor.com/project/ruby/ruby/builds/19323721/job/1s73mrgu8n8wpa5f

We need to revisit this to have MJIT header in a correct place, but
having both in the place didn't make JIT on install directory functional
either anyway...

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64950 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-08 00:12:21 +00:00
k0kubun 0da1f4e8bb win32/Makefile.sub: create header install dir first
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64949 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-07 16:52:21 +00:00
k0kubun 24ca872070 win32/Makefile.sub: install precompiled header to prefix
This is needed to run JIT from the installed ruby binary.

Even after this, we're hitting another error though.

start compilation: a@-e:1 -> C:\Users\k0kubun\AppData\Local\Temp/_ruby_mjit_p9712u0.c
Starting process: cl cl -nologo -LD -DMJIT_HEADER -MD -Zi -W2 -wd4100 -wd4127 -wd4210 -wd4214 -wd4255 -wd4574 -wd4668 -wd4710 -wd4711 -wd4820 -wd4996 -we4028 -we4142 -O2sy- -Zm600 -DRUBY_EXPORT -I. -I.ext/include/x64-mswin64_140 -I../ruby/include -I../ruby -I../ruby/enc/unicode/10.0.0 -DRUBY_DEVEL=1 -DCANONICALIZATION_FOR_MATHN -D_WIN32_WINNT=0x0600 -FeC:\Users\k0kubun\AppData\Local\Temp/_ruby_mjit_p9712u0.so -FoC:\Users\k0kubun\AppData\Local\Temp/_ruby_mjit_p9712u0.obj -YuC:/usr/include/ruby-2.6.0/x64-mswin64_140/rb_mjit_header-2.6.0.pch C:/usr/include/ruby-2.6.0/x64-mswin64_140/rb_mjit_header-2.6.0.obj -TcC:\Users\k0kubun\AppData\Local\Temp/_ruby_mjit_p9712u0.c -link -LIBPATH:C:/usr/lib x64-vcruntime140-ruby260.lib -incremental:no -debug -opt:ref -opt:icf -dll
_ruby_mjit_p9712u0.c
C:\Users\k0kubun\AppData\Local\Temp/_ruby_mjit_p9712u0.c(1): error C2859: C:\usr\bin\vc140.pdb is not the pdb file that was used when this precompiled header was created, recreate the precompiled header.
compile_c_to_so: compile error: 2
Failed to generate so: C:\Users\k0kubun\AppData\Local\Temp/_ruby_mjit_p9712u0.so


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64947 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-07 15:38:06 +00:00
usa c4e433a83a Support ubasecrt.dll 10.0.17763.1 included in Windows 10 October 2018 Update
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64913 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-04 06:29:31 +00:00
nobu 0d95805c2e Suppress more -Wparentheses warnings
[Fix GH-1958]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64808 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-21 10:31:11 +00:00
nobu 4bf11e21f9 Makefile.sub: remove -DRUBY_EXPORT overridden by -U option
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64397 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-16 16:11:55 +00:00
k0kubun 8430d0d123 win32/Makefile.sub: escape `=` in MJIT cflags
Since `=` is considered as delimiter in `()` of `for`, having
`-DRUBY_DEVEL=1` in CPPFLAGS had resulted in:

 #define MJIT_OPTFLAGS "-DMJIT_HEADER", \
   "-DRUBY_DEVEL", \
   "1", \

Even escaped `for %I in (... -DRUBY_DEVEL^=1)` does not yield an
expected result. This commit is a workaround for this issue.

After this commit, mjit_config.h will have:

 #define MJIT_OPTFLAGS "-DMJIT_HEADER", \
   "-DRUBY_DEVEL" MJIT_CONFIG_ESCAPED_EQ "1", \

And C macro resolves MJIT_CONFIG_ESCAPED_EQ to "=".

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64219 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-07 15:14:48 +00:00
k0kubun 20c1e4a733 win32/Makefile.sub: remove RUBY_EXPORT macro
defined in XCFLAGS.

This change resolves following link errors in MJIT:

```
rb_mjit_header-2.6.0.obj : error LNK2001: unresolved external symbol rb_cObject
rb_mjit_header-2.6.0.obj : error LNK2001: unresolved external symbol rb_cFalseClass
rb_mjit_header-2.6.0.obj : error LNK2001: unresolved external symbol rb_cFloat
rb_mjit_header-2.6.0.obj : error LNK2001: unresolved external symbol rb_cInteger
rb_mjit_header-2.6.0.obj : error LNK2001: unresolved external symbol rb_cNilClass
rb_mjit_header-2.6.0.obj : error LNK2001: unresolved external symbol rb_cProc
rb_mjit_header-2.6.0.obj : error LNK2001: unresolved external symbol rb_cString
rb_mjit_header-2.6.0.obj : error LNK2001: unresolved external symbol rb_cSymbol
rb_mjit_header-2.6.0.obj : error LNK2001: unresolved external symbol rb_cTrueClass
rb_mjit_header-2.6.0.obj : error LNK2001: unresolved external symbol rb_eArgError
rb_mjit_header-2.6.0.obj : error LNK2001: unresolved external symbol rb_eNoMethodError
rb_mjit_header-2.6.0.obj : error LNK2001: unresolved external symbol rb_eNameError
_ruby_mjit_p41476u0.obj : error LNK2001: unresolved external symbol rb_eFatal
```

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64207 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-07 01:17:39 +00:00
k0kubun 88975c821c mjit.c: link precompiled object
This is needed to resolve:
"error LNK2011: precompiled object not linked in; image may not run"

win32/Makefile.sub: Use the same flags as ones for precompiled header.

This is needed to resolve:
"error C2855: command-line option '/Z7' inconsistent with precompiled header"

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64192 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-05 05:34:37 +00:00
k0kubun 5f13fe31ad mjit.c: initialize prebuilt precompiled header
file name correctly. This allows to use the header installed by r64188.

win32/Makefile.sub: define prebuilt precompiled header path instead of
unused min header path

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64189 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-05 03:12:09 +00:00
k0kubun cdf72ddc3b win32/Makefile.sub: build precompiled header
See the comment in win32/Makefile.sub.
Not only .pch, but also .obj needs to be installed and used on runtime.

.gitignore: ignore .pch that will be built by this.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64188 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-04 23:53:41 +00:00
k0kubun 11974fc010 mjit.c: allow using MJIT header in build directory
when $MJIT_SEARCH_BUILD_DIR is set.

If prefix path is owned by root, `make install` needs to be run by root.
But in general we don't want to run `make test-all`, and also running
`make test-all` currently fails due to permission tests of rdoc and rubygems.
Thus, prior to this commit, specifying a prefix like "/usr/local" could
mean there was no way to pass test-all.

So we should not depend on `make install` for `make test-all`. Thus I
reverted r64104 and r64103, and applied this workaround to pass `make
test-all` without `make install`.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64143 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-31 12:43:06 +00:00
nobu 63ae1e3cb5 mkexports.rb: flip-flop
* win32/mkexports.rb (Exports::Mswin#each_export): get rid of
  flip-flop warning.  [ruby-core:88147] [Bug #14946]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64095 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-29 00:09:08 +00:00
nobu 73ae3e9b46 win32.c: limit write size on console
* win32/win32.c (constat_parse): split long buffer and limit write
  size on a console, as well as rb_w32_write.
  [ruby-dev:50597] [Bug #14942]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64092 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-28 15:29:14 +00:00
nobu bf9169d555 common.mk: codesign ruby-runner too
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63910 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-09 01:50:12 +00:00
k0kubun 3293322a39 benchmark: introduce benchmark_driver.gem
Makefile.in: Clone benchmark-driver repository in benchmark/benchmark-driver
  `make update-benchmark-driver`, like simplecov.
win32/Makefile.sub: Roughly do the same thing.
.gitignore: Ignore the cloned repository.
common.mk: Trigger `make update-benchmark-driver` to run `make benchmark`
  and adjust arguments for benchmark_driver.gem.

benchmark/require.yml: renamed from benchmark/bm_require.rb, benchmark/prepare_require.rb
benchmark/require_thread.yml: renamed from benchmark/bm_require_thread.rb, benchmark/prepare_require_thread.rb
benchmark/so_count_words.yml: renamed from benchmark/bm_so_count_words.rb, benchmark/prepare_so_count_words.rb,
  benchmark/wc.input.base
benchmark/so_k_nucleotide.yml: renamed from benchmark/bm_so_k_nucleotide.rb, benchmark/prepare_so_k_nucleotide.rb,
  benchmark/make_fasta_output.rb
benchmark/so_reverse_complement.yml: renamed from benchmark/bm_so_reverse_complement.rb, benchmark/prepare_so_reverse_complement.rb,
  benchmark/make_fasta_output.rb

I'm sorry but I made some duplications between benchmark/require.yml and benchmark/require_thread.yml,
and between benchmark/so_k_nucleotide.yml and benchmark/so_reverse_complement.yml.

If you're not comfortable with it, please combine these YAMLs to share
the same prelude. One YAML file can have multiple benchmark definitions
sharing prelude.

benchmark/driver.rb: Replace its core feature with benchmark_driver.gem.
  Some old features are gone for now, but I'll add them again later.

[Misc #14902]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63888 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-08 14:38:05 +00:00
normal 4c777ac94e Revert "get rid of a compiler warning of VC"
Partially revert r63820.  mjit.c seems to have different idea of
"pid" type/size than the rest of Ruby on win32.

As noted in [ruby-core:87794], this seems to break Greg's build.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63856 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-05 03:20:20 +00:00
normal 44fc3d08eb unrevert r63852 but keep SIGCHLD path disabled for win32
Reading win32/win32.c waitpid implementation, maybe waitpid(-1, ...)
on that platform will never conflict with mjit use of waitpid.

In any case, I've added WAITPID_USE_SIGCHLD macro to vm_core.h
so it can be easy for Linux/BSD users to test (hopefully!)
win32-compatible code.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63855 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-05 03:02:33 +00:00
naruse df4a126d65 Revert r63758 and related commits
The change is unstable on Windows. Please re-commit it when it correctly
supports Windows.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63852 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-04 15:08:56 +00:00
usa dea8422992 get rid of a compiler warning of VC
* mjit.c (exec_prcess): use PRI_PIDT_PREFIX for pid.

* win32/Makefile.sub (PRI_PIDT_PREFIX): force to "I".


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63820 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-02 01:50:23 +00:00
nobu 64a189d207 remove DISABLE_RUBYGEMS from config files
* 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
2018-06-22 04:13:02 +00:00
nobu d31d66314b win32/Makefile.sub: gettimeofday is defined in win32.c
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63670 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-15 10:15:40 +00:00
nobu 19ad3b2b2d win32.c: precise time
* win32/win32.c (filetime_split, clock_gettime): keep the
  precision as possible as the FILETIME format.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63636 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-12 00:39:14 +00:00
usa 300524a0bd goruby build was broken
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63473 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-20 18:36:53 +00:00
usa 9fe9ffb842 goruby build was broken
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63471 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-20 18:13:08 +00:00
nobu 13dc8e4ef0 mjit_config.h: expand min header name
* Makefile.in, win32/Makefile.sub (mjit_config.h): expand min
  header name, including the version number and the suffix.

* mjit.c (init_header_filename): the version number and the suffix
  are now included in the header name.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63279 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-28 01:45:52 +00:00
nobu 81f02142b8 win32/Makefile.sub: LIBDIR_BASENAME
* mjit.c (init_header_filename): support LIBDIR_BASENAME.

* win32/Makefile.sub (config.h): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63264 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-26 12:36:27 +00:00
nobu 56e87b2c4b made *.cmd excutable
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-22 00:47:56 +00:00
nobu 55d3ed4b9d win32.c: fix CSI sequences to delete
* win32/win32.c (constat_apply): CSI 'J' and 'K' are defaulted to
  1, not 0.  [ruby-core:86560] [Bug #14691]

* win32/win32.c (constat_apply): "delete before cursor" sequences
  include the cursor position.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63187 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-18 03:51:19 +00:00
kazu dfeafff30e [DOC] Add win32/README.win32 to .document
see https://github.com/ruby/docs.ruby-lang.org/issues/56

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63139 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-12 14:24:06 +00:00
nobu 5bcb76ebbd removed never used variable
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63066 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-03 06:25:10 +00:00
nobu ebf5348528 win32/file.c: relative path with drive letter
* win32/file.c (IS_ABSOLUTE_PATH_P): home directory should not be
  a relative path regardless a drive letter.   PathIsRelativeW
  returns FALSE on such path.  [ruby-core:86356] [Bug #14638]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-28 07:01:48 +00:00
usa de87b9695f * win32/README.win32: `make up` is only necessary when building from SVN source.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62843 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-19 15:40:32 +00:00
usa 68f374727a note that patch is required and need to run make up before make
* win32/README.win32: patch(1) is required, and running `make up` before
	  `make` is also required.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-19 13:04:22 +00:00
nobu 80e8b524d3 win32/configure.bat: stop when setup failed
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62753 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-15 01:05:00 +00:00
nobu 2dafe8df55 configure.ac: --disable-mathn option
* Makefile.in, win32/Makefile.sub: move CANONICALIZATION_FOR_MATHN
  from config.h which affects all extension libraries to XCFLAGS
  for the core only.

* configure.ac: added --disable-mathn option.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62705 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-09 04:24:48 +00:00
kazu 4f125262f4 Fix a typo [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62664 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-05 12:23:48 +00:00
nobu ec7ee438ac Makefile.sub: reconfig
* win32/Makefile.sub (reconfig): phony target to force reconfigure
  with previous options.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62659 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-05 01:54:21 +00:00
nobu 3bc92b8eac mjit_config.h: MJIT_LDSHARED
* configure.in (MJIT_LDSHARED): define based on LDSHARED with
  replacing CC with MJIT_CC.

* Makefile.in, win32/Makefile.sub (mjit_config.h): instead of the
  default LDSHARED, use MJIT_LDSHARED to link mjit shared objects.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62644 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-03 05:09:32 +00:00
nobu d1d2235ed9 Makefile.sub: need suffix
* win32/Makefile.sub: fix missing suffix of user32.lib.
  [Bug #14422]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62630 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-02 07:49:20 +00:00
nobu 0f3452f4c2 Makefile.sub: link user32.lib
* win32/Makefile.sub: always link user32.lib which provides a lot
  of very common library functions.  [Bug #14422]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62629 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-02 07:24:16 +00:00
nobu bb3db69e2a configure.ac: library options to MAINLIBS
* configure.ac (MAINLIBS): moved library options for main program
  and static libruby, and append MAINLIBS to LIBRUBYARG_STATIC, as
  these libraries are not needed for linking to shared libruby.
  [ruby-core:85882] [Bug #14422]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62627 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-02 01:37:53 +00:00
nobu f6ff45ceb3 MJIT specific flags
Passing options to configure like as `configure MJIT_OPTFLAGS=-O
MJIT_DEBUGFLAGS=-g` overrides options to be used to compile JIT
code, separately from the default options to be used for ruby
itself.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62623 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-01 22:49:26 +00:00
nobu fe5d65f157 common.mk: moved macros to mjit_config.h
* Makefile.in, common.mk, win32/Makefile.sub: moved MJIT macros to
  mjit_config.h from XCFLAGS.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62488 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-20 02:37:28 +00:00
nobu a4f2606b2d LIBRUBY_A with exts
* Makefile.in, win32/Makefile.sub (LIBRUBY_A): link with extension
  libraries if EXTSTATIC is set, so that static-ruby would work
  too.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62448 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-17 05:52:21 +00:00
nobu e28a7c204d separate PRE_LIBRUBY_UPDATE
* Makefile.in, win32/Makefile.sub (PRE_LIBRUBY_UPDATE): separate
  definitions without miniruby.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-17 05:52:20 +00:00
nobu aae7d3d6df win32/Makefile.sub: fix typo, missing comma
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62366 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-11 09:00:44 +00:00
nobu fa6e29175b mjit_config.h: include trailing comma for empty list
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62362 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-11 07:10:37 +00:00
nobu 8f66876988 mjit_config.h: more macros
* Makefie.in, win32/Makefile.sub: add more macros for compiler to
  mjit_config.h.

* mjit.c: unification VC and GCC in progress.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62356 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-11 04:54:15 +00:00
nobu cb1cde4621 Makefile.sub: cpp out for older VC
* win32/Makefile.sub (CPPOUTFLAG, MJIT_HEADER_FLAGS): -Fi option
  is available since VC 10.  redirect stdout on older versions.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62352 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-11 01:01:09 +00:00
nobu b40f9d55b6 mjit_config.h: show content if verbose
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62347 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-10 10:07:41 +00:00
nobu f6ca5edf3e mjit_config.h
* Makefie.in, win32/Makefile.sub: make mjit_config.h from
  configured variables, including necessary options, e.g., `-m32`
  for 32bit binary on 64bit platform.

* mjit.c: always use configured CC command.  as config.h depends
  on the compiler, different compilers cannot work.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62343 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-10 06:22:38 +00:00
nobu f6ea97260d Makefile.sub: MESSAGE_BEGIN/END redirection
* win32/Makefile.sub (MESSAGE_BEGIN, MESSAGE_END): group the whole
  `for` command, to redirect all lines but not overwrite line by
  line.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62331 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-09 03:51:57 +00:00
usa 355b147f5e missing macro definition
* win32/Makefile.sub (RUBY_VERSION_NAME): used in this file but not defined.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62324 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-08 18:48:25 +00:00
nobu 4b8719c1cd MJIT header for multiarch
* configure.ac: MJIT_HEADER_INSTALL_DIR to rubyarchhdrdir to
  support multiarch.

* Makefile.in (MJIT_HEADER_INSTALL_DIR): configured by multiarch.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62320 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-08 15:19:32 +00:00
nobu 4695019a1c ifchange: --debug option
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62300 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-08 02:08:27 +00:00
nobu d34e50570c ifchange.bat: --color option
* win32/ifchange.bat: added --color option for the compatibility
  with tool/ifchange.  do nothing right now.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62299 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-08 02:08:26 +00:00
usa d8c19c3e6e mjit mswin support (WIP)
* win32/Makefile.sub (LIBRUBYARG_SHARED): define for MJIT because it is used in
  common.mk.

* mjit.c (make_pch): skip temporary for mswin.

* mjit.c (compile_c_to_so, init_header_filename, mjit_init): mswin support.

* mjig_compile.c (mjit_compile): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62267 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-06 18:59:18 +00:00
nobu 7449619dd3 moved MJIT_CPPFLAGS
* Makefile.in, win32/Makefile.sub (XCFLAGS): moved MJIT_CPPFLAGS
  from CPPFLAGS.  MJIT_CPPFLAGS is only for mjit.c, unused in
  extension libraries.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62261 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-06 15:55:12 +00:00
nobu d3e6af0041 common.mk: MJIT_CPPFLAGS
* common.mk (MJIT_CPPFLAGS): moved common definition flags for
  mjit compilation.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62256 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-06 14:45:11 +00:00
nobu 88035b9979 mjit headers for universal binary
* common.mk (MJIT_HEADER, MJIT_MIN_HEADER): added hook to separate
  intermediate headers per archs.

* defs/gmake.mk: build mjit headers per -arch options, and then
  merge the headers with `#ifdef`s.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62245 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-06 03:19:42 +00:00
k0kubun 1fd0a7a660 mjit.c: determine prefix of MJIT header at runtime
so that MJIT can work if Ruby is distributed as prebuilt binary.

Now mjit_init() depends on the internal const TMP_RUBY_PREFIX which is
only available after ruby_init_loadpath_safe() (L1608) and before
ruby_init_prelude() (L1681). So the place of mjit_init() is moved.

Makefile.in: Removed static prefix from MJIT_HEADER_ISNTALL_DIR macro.
And this removes the unused LIBRUBY_LIBDIR macro as well.
win32/Makefile.sub: ditto.

Patch by: Lars Kanis <lars@greiz-reinsdorf.de>
[Bug #14445]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62238 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-05 16:51:12 +00:00
nobu 08332d5357 Makefile.sub: va_copy in old version
* win32/Makefile.sub: va_copy is available since VS12 (VC 18.00).
  simple copy same as VC1 19.00.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62223 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-05 04:58:07 +00:00
shyouhei 779c18bf23 va_copy is a C99ism
Should provide appropriate fallback implementation.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62220 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-05 04:07:25 +00:00
nobu 24fcc0275b common.mk: CPPOUTFLAG
* common.mk (rb_mjit_header.h): use $(CPPOUTFLAG).

* win32/Makefile.sub (CPPOUTFLAG): needs -Fi to let cl.exe name
  preprocessed file, instead of -Fo.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62208 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-04 15:17:44 +00:00
nobu 29c9dc3162 common.mk: rb_mjit_header.h
* common.mk (rb_mjit_header.h): moved from Makefile.in and
  win32/Makefile.sub.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62202 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-04 13:43:06 +00:00
nobu 1a5470e95b Makefile.sub: CFLAGS_NO_ARCH
* win32/Makefile.sub: split CFLAGS into CFLAGS_NO_ARCH and
  ARCH_FLAG, as well as Makefile.in.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62201 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-04 13:33:13 +00:00
k0kubun ed935aa5be mjit_compile.c: merge initial JIT compiler
which has been developed by Takashi Kokubun <takashikkbn@gmail> as
YARV-MJIT. Many of its bugs are fixed by wanabe <s.wanabe@gmail.com>.

This JIT compiler is designed to be a safe migration path to introduce
JIT compiler to MRI. So this commit does not include any bytecode
changes or dynamic instruction modifications, which are done in original
MJIT.

This commit even strips off some aggressive optimizations from
YARV-MJIT, and thus it's slower than YARV-MJIT too. But it's still
fairly faster than Ruby 2.5 in some benchmarks (attached below).

Note that this JIT compiler passes `make test`, `make test-all`, `make
test-spec` without JIT, and even with JIT. Not only it's perfectly safe
with JIT disabled because it does not replace VM instructions unlike
MJIT, but also with JIT enabled it stably runs Ruby applications
including Rails applications.

I'm expecting this version as just "initial" JIT compiler. I have many
optimization ideas which are skipped for initial merging, and you may
easily replace this JIT compiler with a faster one by just replacing
mjit_compile.c. `mjit_compile` interface is designed for the purpose.

common.mk: update dependencies for mjit_compile.c.

internal.h: declare `rb_vm_insn_addr2insn` for MJIT.

vm.c: exclude some definitions if `-DMJIT_HEADER` is provided to
compiler. This avoids to include some functions which take a long time
to compile, e.g. vm_exec_core. Some of the purpose is achieved in
transform_mjit_header.rb (see `IGNORED_FUNCTIONS`) but others are
manually resolved for now. Load mjit_helper.h for MJIT header.
mjit_helper.h: New. This is a file used only by JIT-ed code. I'll
refactor `mjit_call_cfunc` later.
vm_eval.c: add some #ifdef switches to skip compiling some functions
like Init_vm_eval.

win32/mkexports.rb: export thread/ec functions, which are used by MJIT.

include/ruby/defines.h: add MJIT_FUNC_EXPORTED macro alis to clarify
that a function is exported only for MJIT.

array.c: export a function used by MJIT.
bignum.c: ditto.
class.c: ditto.
compile.c: ditto.
error.c: ditto.
gc.c: ditto.
hash.c: ditto.
iseq.c: ditto.
numeric.c: ditto.
object.c: ditto.
proc.c: ditto.
re.c: ditto.
st.c: ditto.
string.c: ditto.
thread.c: ditto.
variable.c: ditto.
vm_backtrace.c: ditto.
vm_insnhelper.c: ditto.
vm_method.c: ditto.

I would like to improve maintainability of function exports, but I
believe this way is acceptable as initial merging if we clarify the
new exports are for MJIT (so that we can use them as TODO list to fix)
and add unit tests to detect unresolved symbols.
I'll add unit tests of JIT compilations in succeeding commits.

Author: Takashi Kokubun <takashikkbn@gmail.com>
Contributor: wanabe <s.wanabe@gmail.com>

Part of [Feature #14235]

---

* Known issues
  * Code generated by gcc is faster than clang. The benchmark may be worse
    in macOS. Following benchmark result is provided by gcc w/ Linux.
  * Performance is decreased when Google Chrome is running
  * JIT can work on MinGW, but it doesn't improve performance at least
    in short running benchmark.
  * Currently it doesn't perform well with Rails. We'll try to fix this
    before release.

---

* Benchmark reslts

Benchmarked with:
Intel 4.0GHz i7-4790K with 16GB memory under x86-64 Ubuntu 8 Cores

- 2.0.0-p0: Ruby 2.0.0-p0
- r62186: Ruby trunk (early 2.6.0), before MJIT changes
- JIT off: On this commit, but without `--jit` option
- JIT on: On this commit, and with `--jit` option

** Optcarrot fps

Benchmark: https://github.com/mame/optcarrot

|         |2.0.0-p0 |r62186   |JIT off  |JIT on   |
|:--------|:--------|:--------|:--------|:--------|
|fps      |37.32    |51.46    |51.31    |58.88    |
|vs 2.0.0 |1.00x    |1.38x    |1.37x    |1.58x    |

** MJIT benchmarks

Benchmark: https://github.com/benchmark-driver/mjit-benchmarks
(Original: https://github.com/vnmakarov/ruby/tree/rtl_mjit_branch/MJIT-benchmarks)

|           |2.0.0-p0 |r62186   |JIT off  |JIT on   |
|:----------|:--------|:--------|:--------|:--------|
|aread      |1.00     |1.09     |1.07     |2.19     |
|aref       |1.00     |1.13     |1.11     |2.22     |
|aset       |1.00     |1.50     |1.45     |2.64     |
|awrite     |1.00     |1.17     |1.13     |2.20     |
|call       |1.00     |1.29     |1.26     |2.02     |
|const2     |1.00     |1.10     |1.10     |2.19     |
|const      |1.00     |1.11     |1.10     |2.19     |
|fannk      |1.00     |1.04     |1.02     |1.00     |
|fib        |1.00     |1.32     |1.31     |1.84     |
|ivread     |1.00     |1.13     |1.12     |2.43     |
|ivwrite    |1.00     |1.23     |1.21     |2.40     |
|mandelbrot |1.00     |1.13     |1.16     |1.28     |
|meteor     |1.00     |2.97     |2.92     |3.17     |
|nbody      |1.00     |1.17     |1.15     |1.49     |
|nest-ntimes|1.00     |1.22     |1.20     |1.39     |
|nest-while |1.00     |1.10     |1.10     |1.37     |
|norm       |1.00     |1.18     |1.16     |1.24     |
|nsvb       |1.00     |1.16     |1.16     |1.17     |
|red-black  |1.00     |1.02     |0.99     |1.12     |
|sieve      |1.00     |1.30     |1.28     |1.62     |
|trees      |1.00     |1.14     |1.13     |1.19     |
|while      |1.00     |1.12     |1.11     |2.41     |

** Discourse's script/bench.rb

Benchmark: https://github.com/discourse/discourse/blob/v1.8.7/script/bench.rb

NOTE: Rails performance was somehow a little degraded with JIT for now.
We should fix this.
(At least I know opt_aref is performing badly in JIT and I have an idea
 to fix it. Please wait for the fix.)

*** JIT off
Your Results: (note for timings- percentile is first, duration is second in millisecs)

categories_admin:
  50: 17
  75: 18
  90: 22
  99: 29
home_admin:
  50: 21
  75: 21
  90: 27
  99: 40
topic_admin:
  50: 17
  75: 18
  90: 22
  99: 32
categories:
  50: 35
  75: 41
  90: 43
  99: 77
home:
  50: 39
  75: 46
  90: 49
  99: 95
topic:
  50: 46
  75: 52
  90: 56
  99: 101

*** JIT on
Your Results: (note for timings- percentile is first, duration is second in millisecs)

categories_admin:
  50: 19
  75: 21
  90: 25
  99: 33
home_admin:
  50: 24
  75: 26
  90: 30
  99: 35
topic_admin:
  50: 19
  75: 20
  90: 25
  99: 30
categories:
  50: 40
  75: 44
  90: 48
  99: 76
home:
  50: 42
  75: 48
  90: 51
  99: 89
topic:
  50: 49
  75: 55
  90: 58
  99: 99

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-04 11:22:28 +00:00
nobu b421f1a715 common.mk: MJIT_MIN_HEADER
* common.mk ($(MJIT_MIN_HEADER)): moved duplicate recipe from
  Makefile.in and win32/Makefile.sub.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-04 09:34:16 +00:00
nobu 5dc3da0843 use ifchange tool for rb_mjit_header.h
* Makefile.in, win32/Makefile.sub (rb_mjit_header.h): use ifchange
  tool.  cmp command is not available on Windows.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62194 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-04 09:13:19 +00:00
k0kubun fd44a5777f mjit.c: merge MJIT infrastructure
that allows to JIT-compile Ruby methods by generating C code and
using C compiler.  See the first comment of mjit.c to know what this
file does.

mjit.c is authored by Vladimir Makarov <vmakarov@redhat.com>.
After he invented great method JIT infrastructure for MRI as MJIT,
Lars Kanis <lars@greiz-reinsdorf.de> sent the patch to support MinGW
in MJIT. In addition to merging it, I ported pthread to Windows native
threads. Now this MJIT infrastructure can be compiled on Visual Studio.

This commit simplifies mjit.c to decrease code at initial merge. For
example, this commit does not provide multiple JIT threads support.
We can resurrect them later if we really want them, but I wanted to minimize
diff to make it easier to review this patch.

`/tmp/_mjitXXX` file is renamed to `/tmp/_ruby_mjitXXX` because non-Ruby
developers may not know the name "mjit" and the file name should make
sure it's from Ruby and not from some harmful programs.  TODO: it may be
better to store this to some temporary directory which Ruby is already using
by Tempfile, if it's not bad for performance.

mjit.h: New. It has `mjit_exec` interface similar to `vm_exec`, which is
for triggering MJIT. This drops interface for AOT compared to the original
MJIT.

Makefile.in: define macros to let MJIT know the path of MJIT header.
Probably we can refactor this to reduce the number of macros (TODO).
win32/Makefile.sub: ditto.

common.mk: compile mjit.o and mjit_compile.o. Unlike original MJIT, this
commit separates MJIT infrastructure and JIT compiler code as independent
object files. As initial patch is NOT going to have ultra-fast JIT compiler,
it's likely to replace JIT compiler, e.g. original MJIT's compiler or some
future JIT impelementations which are not public now.

inits.c: define MJIT module. This is added because `MJIT.enabled?` was
necessary for testing.
test/lib/zombie_hunter.rb: skip if `MJIT.enabled?`. Obviously this
wouldn't work with current code when JIT is enabled.
test/ruby/test_io.rb: skip this too. This would make no sense with MJIT.

ruby.c: define MJIT CLI options. As major difference from original MJIT,
"-j:l"/"--jit:llvm" are renamed to "--jit-cc" because I want to support
not only gcc/clang but also cl.exe (Visual Studio) in the future. But it
takes only "--jit-cc=gcc", "--jit-cc=clang" for now. And only long "--jit"
options are allowed since some Ruby committers preferred it at Ruby
developers Meeting on January, and some of options are renamed.
This file also triggers to initialize MJIT thread and variables.
eval.c: finalize MJIT worker thread and variables.
test/ruby/test_rubyoptions.rb: fix number of CLI options for --jit.

thread_pthread.c: change for pthread abstraction in MJIT. Prefix rb_ for
functions which are used by other files.
thread_win32.c: ditto, for Windows.  Those pthread porting is one of major
works that YARV-MJIT created, which is my fork of MJIT, in Feature 14235.
thread.c: follow rb_ prefix changes

vm.c: trigger MJIT call on VM invocation. Also trigger `mjit_mark` to avoid
SEGV by race between JIT and GC of ISeq. The improvement was provided by
wanabe <s.wanabe@gmail.com>.
In JIT compiler I created and am going to add in my next commit, I found
that having `mjit_exec` after `vm_loop_start:` is harmful because the
JIT-ed function doesn't proceed other ISeqs on RESTORE_REGS of leave insn.
Executing non-FINISH frame is unexpected for my JIT compiler and
`exception_handler` triggers executions of such ISeqs. So `mjit_exec`
here should be executed only when it directly comes from `vm_exec` call.
`RubyVM::MJIT` module and `.enabled?` method is added so that we can skip
some tests which don't expect JIT threads or compiler file descriptors.

vm_insnhelper.h: trigger MJIT on method calls during VM execution.

vm_core.h: add fields required for mjit.c. `bp` must be `cfp[6]` because
rb_control_frame_struct is likely to be casted to another struct. The
last position is the safest place to add the new field.
vm_insnhelper.c: save initial value of cfp->ep as cfp->bp. This is an
optimization which are done in both MJIT and YARV-MJIT. So this change
is added in this commit. Calculating bp from ep is a little heavy work,
so bp is kind of cache for it.

iseq.c: notify ISeq GC to MJIT. We should know which iseq in MJIT queue
is GCed to avoid SEGV.  TODO: unload some GCed units in some safe way.

gc.c: add hooks so that MJIT can wait GC, and vice versa. Simultaneous
JIT and GC executions may cause SEGV and so we should synchronize them.

cont.c: save continuation information in MJIT worker. As MJIT shouldn't
unload JIT-ed code which is being used, MJIT wants to know full list of
saved execution contexts for continuation and detect ISeqs in use.

mjit_compile.c: added empty JIT compiler so that you can reuse this commit
to build your own JIT compiler. This commit tries to compile ISeqs but
all of them are considered as not supported in this commit. So you can't
use JIT compiler in this commit yet while we added --jit option now.

Patch author: Vladimir Makarov <vmakarov@redhat.com>.

Contributors:
Takashi Kokubun <takashikkbn@gmail.com>.
wanabe <s.wanabe@gmail.com>.
Lars Kanis <lars@greiz-reinsdorf.de>.

Part of Feature 12589 and 14235.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62189 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-04 06:58:09 +00:00
k0kubun 0af44e7261 common.mk: install a single header file for JIT
compilation which is created by transforming a preprocessed vm.c.
This file will be used by JIT compiler's generated code which we are
going to have from succeeding commits.

Makefile.in: generate MJIT header for UNIX environments.
win32/Makefile.sub: generate MJIT header for mswin environments.
At initial merge, we're going to support only MinGW for Windows. So the
header installed by this file won't be used for short term, but we'll
add mswin support in a half year or so, for sure.

tool/transform_mjit_header.rb: New. This script was originally written as
minimize_mjit_header.rb by Vladimir N. Makarov <vmakarov@redhat.com> for
Feature 12589.
Then I refactored a little so that it can conform CodeClimate CI which is
currently set for Ruby's GitHub repository, and fixed some bugs and ported
it to work on Windows.

Also, as original minimize_mjit_header.rb takes too long time to run,
this is modified to skip minimization step because having *static*
unused definitions does not waste compilation time on -O2 since compiler
can skip to compile unused static functions. So this does no longer
"minimize" the header and is renamed.

This header installation does NOT include a header to automatically
export symbols used by MJIT. That's because original MJIT code was
failing to export symbols in the import header in macOS environment.
But I would like to have the functionality for maintainability in the
future. I'll manually export things but it would be just an intemediate
solution.

Patch by: Vladimir N. Makarov <vmakarov@redhat.com>
Part of: Feature 12589 and 14235.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62187 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-04 05:49:21 +00:00
nobu 044e6f12be win32.c: EPIPE for ERROR_NO_DATA
* win32/win32.c (rb_w32_write): writing to closed pipe fails with
  ERROR_NO_DATA but msvcrt maps it to EINVAL.  map it to EPIPE.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62150 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-01 02:56:28 +00:00
nobu 51fdac39eb setup.mak: discard BASERUBY output
* win32/setup.mak: discard output from BASERUBY command, even if
  it contains multiple commands.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62110 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-30 11:12:21 +00:00
k0kubun d678c274aa win32/Makefile.sub: fix typo
Other places are using RT_VER. So I guess this is correct.
Currently AppVeyor CI is failing and I want to fix that.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62063 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-27 01:28:21 +00:00
usa d2bd7d7b98 need to declare the prototype of nan() if missing
* include/ruby/missing.h (nan): need to declare the prototype of nan() if
  missing.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62061 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-26 16:38:38 +00:00
nobu 645e441c32 Makefile.sub: missing/nan.obj
* win32/Makefile.sub (MISSING): nan() is available since msvcrr120.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61980 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-20 06:49:30 +00:00
hsbt 2701001b2f Fix a typo.
* win32/win32.c: wrok -> work

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61851 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-15 10:09:00 +00:00
shyouhei 21429b1488 __alignof__ to take alignment of a type
C11 and C++11 has this feature so why not use it when available.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61828 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-15 02:35:17 +00:00
shyouhei f089a52865 __attibute__((__aligned__)) for RSTRING_PTR()
For instance array.c:rb_ary_product() uses RSTRING_PTR() as an
array of int. So to avoid misaligned memory access RSTRING_PTR()
must at least be sizeof(int)-aligned.  However the type of
RSTRING_PTR() is char*, which of course can expect alignment as
much as 1.  This is a problem.

The reality is, there is no misaligned memory access because the
memory region behind RSTRING_PTR() is allocated using malloc().
Memory regions returned from malloc() are always aligned
appropriately.  So let's tell the compiler about this information.
It seems GCC, clang, and MSVC have such feature.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61827 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-15 02:35:16 +00:00
shyouhei f6ea376317 delete tool/instruction.rb (2nd try)
Previous commit changed insns.def format. Now is the time for its
generators. In doing so I chose to modernize the system, not just
patch.  My attempt includes

- extensive use of Onigumo regular expressions
- split from one big file (instruction.rb) into separated MVC
- partial view

Also, let me take this opportunity to kill old unused features
such as

- stack caching
- minsns / yasmdata which are never seriously used
- yarvarch document generation (moved to doc/)
- vast majority of unused arguments to insns2vm.rb

This commit generates VM source codes that cleanly compile, and
the generated binary passes tests.  At least for me.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-12 08:38:09 +00:00