1263 Commits

Author SHA1 Message Date
Benoit Daloze
7add6b2ac3 ruby/spec has a minimum of Ruby 3.2 now 2025-05-10 10:29:48 +02:00
Hiroshi SHIBATA
d6d63b278a
Enabled debug mode for CodeQL 2025-05-07 07:32:18 +09:00
Hiroshi SHIBATA
994dadfbf4 Removed unused OS_VER variable 2025-05-01 10:46:00 +09:00
Hiroshi SHIBATA
17912cb500 windows-2019 will be EOL at end of June, 2025 2025-05-01 10:46:00 +09:00
Hiroshi SHIBATA
cbc045a0ea Added GCC 15 build 2025-04-30 13:12:19 +09:00
Takashi Kokubun
0f3d6ee578
ZJIT: Disable ZJIT instructions when USE_ZJIT is 0 (#13199)
* ZJIT: Disable ZJIT instructions when USE_ZJIT is 0

* Test the order of ZJIT instructions

* Add more jobs that disable JITs

* Show instruction names in the message
2025-04-29 11:03:13 -07:00
Jeremy Evans
e4f85bfc31 Implement Set as a core class
Set has been an autoloaded standard library since Ruby 3.2.
The standard library Set is less efficient than it could be, as it
uses Hash for storage, which stores unnecessary values for each key.

Implementation details:

* Core Set uses a modified version of `st_table`, named `set_table`.
  than `s/st_/set_/`, the main difference is that the stored records
  do not have values, making them 1/3 smaller. `st_table_entry` stores
  `hash`, `key`, and `record` (value), while `set_table_entry` only
  stores `hash` and `key`.  This results in large sets using ~33% less
  memory compared to stdlib Set.  For small sets, core Set uses 12% more
  memory (160 byte object slot and 64 malloc bytes, while stdlib set
  uses 40 for Set and 160 for Hash).  More memory is used because
  the set_table is embedded and 72 bytes in the object slot are
  currently wasted. Hopefully we can make this more efficient and have
  it stored in an 80 byte object slot in the future.

* All methods are implemented as cfuncs, except the pretty_print
  methods, which were moved to `lib/pp.rb` (which is where the
  pretty_print methods for other core classes are defined).  As is
  typical for core classes, internal calls call C functions and
  not Ruby methods.  For example, to check if something is a Set,
  `rb_obj_is_kind_of` is used, instead of calling `is_a?(Set)` on the
  related object.

* Almost all methods use the same algorithm that the pure-Ruby
  implementation used.  The exception is when calling `Set#divide` with a
  block with 2-arity.  The pure-Ruby method used tsort to implement this.
  I developed an algorithm that only allocates a single intermediate
  hash and does not need tsort.

* The `flatten_merge` protected method is no longer necessary, so it
  is not implemented (it could be).

* Similar to Hash/Array, subclasses of Set are no longer reflected in
  `inspect` output.

* RDoc from stdlib Set was moved to core Set, with minor updates.

This includes a comprehensive benchmark suite for all public Set
methods.  As you would expect, the native version is faster in the
vast majority of cases, and multiple times faster in many cases.
There are a few cases where it is significantly slower:

* Set.new with no arguments (~1.6x)
* Set#compare_by_identity for small sets (~1.3x)
* Set#clone for small sets (~1.5x)
* Set#dup for small sets (~1.7x)

These are slower as Set does not currently use the AR table
optimization that Hash does, so a new set_table is initialized for
each call.  I'm not sure it's worth the complexity to have an AR
table-like optimization for small sets (for hashes it makes sense,
as small hashes are used everywhere in Ruby).

The rbs and repl_type_completor bundled gems will need updates to
support core Set.  The pull request marks them as allowed failures.

This passes all set tests with no changes.  The following specs
needed modification:

* Modifying frozen set error message (changed for the better)
* `Set#divide` when passed a 2-arity block no longer yields the same
  object as both the first and second argument (this seems like an issue
  with the previous implementation).
* Set-like objects that override `is_a?` such that `is_a?(Set)` return
  `true` are no longer treated as Set instances.
* `Set.allocate.hash` is no longer the same as `nil.hash`
* `Set#join` no longer calls `Set#to_a` (it calls the underlying C
   function).
* `Set#flatten_merge` protected method is not implemented.

Previously, `set.rb` added a `SortedSet` autoload, which loads
`set/sorted_set.rb`.  This replaces the `Set` autoload in `prelude.rb`
with a `SortedSet` autoload, but I recommend removing it and
`set/sorted_set.rb`.

This moves `test/set/test_set.rb` to `test/ruby/test_set.rb`,
reflecting that switch to a core class.  This does not move the spec
files, as I'm not sure how they should be handled.

Internally, this uses the st_* types and functions as much as
possible, and only adds set_* types and functions as needed.
The underlying set_table implementation is stored in st.c, but
there is no public C-API for it, nor is there one planned, in
order to keep the ability to change the internals going forward.

For internal uses of st_table with Qtrue values, those can
probably be replaced with set_table.  To do that, include
internal/set_table.h.  To handle symbol visibility (rb_ prefix),
internal/set_table.h uses the same macro approach that
include/ruby/st.h uses.

The Set class (rb_cSet) and all methods are defined in set.c.
There isn't currently a C-API for the Set class, though C-API
functions can be added as needed going forward.

Implements [Feature #21216]

Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
Co-authored-by: Oliver Nutter <mrnoname1000@riseup.net>
2025-04-26 10:31:11 +09:00
Hiroshi SHIBATA
f501d114ad
Use OS label for actions/cache. vcpkg only uses same os cache 2025-04-25 16:37:03 +09:00
Hiroshi SHIBATA
ffa40d3418 Use actions/cache instead of vcpkg built-in cache feature 2025-04-25 14:24:41 +09:00
Hiroshi SHIBATA
08f62809ea Revert "Extract windows-11-arm job from windows.yml because it may ignored vcpkg binary cache for x64-windows"
This reverts commit 8e258af5b083a417a8f5e424a2c7d2c4800f8ca2.
2025-04-25 14:24:41 +09:00
Hiroshi SHIBATA
8e258af5b0 Extract windows-11-arm job from windows.yml because it may ignored vcpkg binary cache for x64-windows 2025-04-25 11:37:18 +09:00
Hiroshi SHIBATA
842547604c Move VCPKG_BINARY_SOURCES to global environmental variable on workflow 2025-04-24 18:40:28 +09:00
Hiroshi SHIBATA
d34ba74ca5 Added --vcpkg-root for fixing mismatched vcpkg root with scoop version 2025-04-24 14:06:16 +09:00
Hiroshi SHIBATA
0714867dba codeql-trap cache is growing over 300MB. We should enable to cleanup needless cache from actions/cache 2025-04-24 14:06:16 +09:00
Nobuyoshi Nakada
7d7478c7bc
Run auto-style.rb only on ruby/ruby
`github.event.before` for newly pushed branch is all zero and cannot
check out.
2025-04-23 19:05:31 +09:00
Hiroshi SHIBATA
d4815d39b7 Test with Windows 2025 server 2025-04-22 10:40:23 +09:00
Hiroshi SHIBATA
85bab61565 Try to run only working tests 2025-04-21 12:25:41 +09:00
Hiroshi SHIBATA
d414dbae0a nmake check is crashed with windows-11-arm, we need to try test-spec 2025-04-21 12:25:41 +09:00
Hiroshi SHIBATA
99a16757ca windows-11-arm has only C drive 2025-04-21 12:25:41 +09:00
Hiroshi SHIBATA
9e3c120a15 set arm64-windows for VCPKG_DEFAULT_TRIPLET 2025-04-21 12:25:41 +09:00
Hiroshi SHIBATA
a12fe40124 Manually generate dummy revision.h file 2025-04-21 12:25:41 +09:00
Hiroshi SHIBATA
123726ca78 Don't specify old version of Visual Studio 2025-04-21 12:25:41 +09:00
Hiroshi SHIBATA
9408bdb571 Use vcvarsarm64.bat directly on ARM platform 2025-04-21 12:25:41 +09:00
Hiroshi SHIBATA
22d72fed56 Skip to install BASERUBY from ruby/setup-ruby when windows-11-arm runner is active 2025-04-21 12:25:41 +09:00
Hiroshi SHIBATA
c1393bb92b Try to build with windows-11-arm 2025-04-21 12:25:41 +09:00
Takashi Kokubun
0232c31555 Resurrect concurrency in JIT workflows 2025-04-18 21:54:22 +09:00
Takashi Kokubun
2ef85c12fb Drop duplicated workflow jobs 2025-04-18 21:53:01 +09:00
Takashi Kokubun
f5c3fc877e Rename a reference to an obsoleted variable 2025-04-18 21:53:00 +09:00
Takashi Kokubun
d492734d14 Fix a ubuntu job with --disable-zjit 2025-04-18 21:53:00 +09:00
Takashi Kokubun
31121a9107 Avoid running the same test in multiple workflows
This workflow is supposed to test that we didn't mess up the
interpreter's implementation. We shouldn't need to run test_zjit.rb on
this workflow.
2025-04-18 21:53:00 +09:00
Takashi Kokubun
33a052486b Assert everything is compiled in test_zjit (https://github.com/Shopify/zjit/pull/40)
* Assert everything is compiled in test_zjit

* Update a comment on rb_zjit_assert_compiles

Co-authored-by: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com>

* Add a comment about assert_compiles

* Actually use pipe_fd

---------

Co-authored-by: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com>
2025-04-18 21:52:59 +09:00
Takashi Kokubun
48fa16f644 Load Param off of cfp->ep (https://github.com/Shopify/zjit/pull/31)
* Load Param off of cfp->ep

* Test with --zjit-call-threshold=1 as well

* Fix get_opnd's debug output

* Return Mem operand from gen_param

* Test both first and second calls

* Spell out the namespace for Opnd returns

* Update a comment about gen_param

* Explain why we take a lock

* Fix a typo
2025-04-18 21:52:59 +09:00
Takashi Kokubun
22c73f1ccb Implement FixnumAdd and stub PatchPoint/GuardType (https://github.com/Shopify/zjit/pull/30)
* Implement FixnumAdd and stub PatchPoint/GuardType

Co-authored-by: Max Bernstein <max.bernstein@shopify.com>
Co-authored-by: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com>

* Clone Target for arm64

* Use $create instead of use create

Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>

* Fix misindentation from suggested changes

* Drop an unneeded variable for mut

* Load operand into a register only if necessary

---------

Co-authored-by: Max Bernstein <max.bernstein@shopify.com>
Co-authored-by: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com>
Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>
2025-04-18 21:52:59 +09:00
Takashi Kokubun
e4d4ee7517 Fix inconsistent triggers of workflows
This is another left-over from https://github.com/Shopify/zjit/pull/12.
No reason to duplicate jobs for PRs.
2025-04-18 21:52:59 +09:00
Takashi Kokubun
c443e538b6 Fix inconsistent workflow settings
This is a left-over from https://github.com/Shopify/zjit/pull/12.
It was supposed to be removed from both workflows in the PR, but this
was somehow uncommitted.
2025-04-18 21:52:59 +09:00
Alan Wu
bd0f63507d Use rustup to get 1.85.0 since GitHub's image doesn't have it 2025-04-18 21:52:59 +09:00
Takashi Kokubun
e68f5a1816 Add result CI job to enable auto-merge (https://github.com/Shopify/zjit/pull/12)
* Add `result` CI job to enable auto-merge

* Avoid triggering duplicated jobs on PRs

* Drop cancel-in-progress

We don't run as many jobs as ruby/ruby CI. We shouldn't need this here.

* Fix a typo

* Drop the concurrency group too

Similarly, we shouldn't need this in the Shopify/zjit repo
2025-04-18 21:52:58 +09:00
Takashi Kokubun
53bee25068 Implement --zjit-call-threshold
As a preparation for introducing a profiling layer, we need to be able
to raise the threshold to run a few cycles for profiling.
2025-04-18 21:52:58 +09:00
Takashi Kokubun
24f8a78709 btest jobs are now passing 2025-04-18 21:52:58 +09:00
Takashi Kokubun
d68f878976 Ignore btest failures for now 2025-04-18 21:52:58 +09:00
Takashi Kokubun
83da2dd1ea Try to fix the BTESTS path 2025-04-18 21:52:58 +09:00
Takashi Kokubun
ec35162536 Fix BTESTS path 2025-04-18 21:52:58 +09:00
Takashi Kokubun
d093793e6b Pass BTESTS to make properly 2025-04-18 21:52:58 +09:00
Takashi Kokubun
fc03b7353d Start testing the actual JIT code on CI 2025-04-18 21:52:58 +09:00
Takashi Kokubun
6f3f69098b Drop redundant options in workflows 2025-04-18 21:52:58 +09:00
Alan Wu
ed2ff3bb4c zjit-ubuntu: remove continue on error for make zjit-test. Passes now 2025-04-18 21:52:58 +09:00
Takashi Kokubun
78d60548ef Allow failing zjit-test on Linux 2025-04-18 21:52:58 +09:00
Takashi Kokubun
daced753a5 Fix YJIT references in comments 2025-04-18 21:52:58 +09:00
Takashi Kokubun
fa9713d59c Drop cargo build jobs
It doesn't seem important to keep `cargo build`-only jobs. The zjit-test
task should be covering most of what we wanted in the job now.
2025-04-18 21:52:58 +09:00
Alan Wu
ea932d8735 Fix s/test-zjit/zjit-test/ 2025-04-18 21:52:58 +09:00