-
Notifications
You must be signed in to change notification settings - Fork 5.4k
ZJIT: Add support for putspecialobject #13565
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
811e6c2
to
14440bd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the current tests cover 2 special object types: VMCORE
and CBASE
. But I'm not sure how to generate CONST_BASE
🤔
vm_insnhelper.c
Outdated
@@ -5550,6 +5550,13 @@ vm_get_special_object(const VALUE *const reg_ep, | |||
} | |||
} | |||
|
|||
// ZJIT implementation is using the C function | |||
// and needs to call a non-static function | |||
VALUE rb_vm_get_special_object(const VALUE *reg_ep, enum vm_special_object_type type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if exposing static VM functions for jit is allowed as I didn't see many examples. But we seems to do rb_vm_concat_array
for YJIT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is allowed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do the wrapper function one when I hope its performance impact on the interpreter will be smaller than just removing static (because static functions may be inlined), but they may actually result in the same compilation result. If you're unsure, just try both and pick whichever you think is better.
Also, like other functions in this file, CRuby uses this style:
VALUE rb_vm_get_special_object(const VALUE *reg_ep, enum vm_special_object_type type) | |
VALUE | |
rb_vm_get_special_object(const VALUE *reg_ep, enum vm_special_object_type type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm! if you want to get fancy, you can add something to infer_type
that in the case of VM_SPECIAL_OBJECT_VMCORE
does Type::from_value(rb_mRubyVMFrozenCore)
vm_insnhelper.c
Outdated
@@ -5550,6 +5550,13 @@ vm_get_special_object(const VALUE *const reg_ep, | |||
} | |||
} | |||
|
|||
// ZJIT implementation is using the C function | |||
// and needs to call a non-static function | |||
VALUE rb_vm_get_special_object(const VALUE *reg_ep, enum vm_special_object_type type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is allowed
search for |
EDIT: Or even |
zjit/src/hir.rs
Outdated
impl From<u32> for SpecialObjectType { | ||
fn from(value: u32) -> Self { | ||
match value { | ||
1 => SpecialObjectType::VMCore, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, since rb_mRubyVMFrozenCore
is used expressly by YJIT already, we should be able to do the same. So please instead compile the 1
case into a Const
instruction with rb_mRubyVMFrozenCore
test/ruby/test_zjit.rb
Outdated
@@ -610,6 +610,18 @@ def test() = @foo = 1 | |||
} | |||
end | |||
|
|||
def test_putspecialobject |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please try to cover each subcase of putspecialobject
, if possible, in the execution tests?
14440bd
to
04815b6
Compare
@k0kubun @tekknolagi I'm having issues adding test cases for For integration tests, I'm trying Foo = 1
def test
Foo
end
test which I'd expect to have hirs like:
But the test fails with
I'm not sure how those additional insn are generated 🤔 |
No description provided.