ZJIT: Support invokebuiltin opcodes (#13632)

* `invokebuiltin`
* `invokebuiltin_delegate`
* `invokebuiltin_delegate_leave`

These instructions all call out to a C function, passing EC, self, and
some number of arguments. `invokebuiltin` gets the arguments from the
stack, whereas the `_delegate` instructions use a subset of the locals.

`opt_invokebuiltin_delegate_leave` has a fast path for `leave`, but I'm
not sure we need to do anything special for that here (FWIW YJIT appears
to treat the two delegate instructions the same).
This commit is contained in:
Daniel Colson 2025-06-18 18:58:34 -04:00 committed by GitHub
parent 521b2fcba4
commit 3290d3d7f0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
Notes: git 2025-06-18 22:58:47 +00:00
Merged-By: k0kubun <takashikkbn@gmail.com>
4 changed files with 126 additions and 7 deletions

View file

@ -76,6 +76,21 @@ class TestZJIT < Test::Unit::TestCase
}
end
def test_invokebuiltin
assert_compiles '["."]', %q{
def test = Dir.glob(".")
test
}
end
def test_invokebuiltin_delegate
assert_compiles '[[], true]', %q{
def test = [].clone(freeze: true)
r = test
[r, r.frozen?]
}
end
def test_opt_plus_const
assert_compiles '3', %q{
def test = 1 + 2