summaryrefslogtreecommitdiff
path: root/yjit/src/cruby_bindings.inc.rs
diff options
context:
space:
mode:
authorAaron Patterson <tenderlove@ruby-lang.org>2022-05-03 15:25:03 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2022-05-12 14:34:18 -0700
commitebaf56c013fa3c24bc680cd7482845b9ed30cda8 (patch)
tree7e85ccf3a758cd9a60c569942f9ee5d7cd6453a7 /yjit/src/cruby_bindings.inc.rs
parent14ae97ded37f9474feccbfb345735b8240c2776c (diff)
YJIT: Implement getblockparam
This implements the getblockparam instruction. There are two cases we need to handle depending on whether or not VM_FRAME_FLAG_MODIFIED_BLOCK_PARAM is set in the environment flag. When the modified flag is unset, we need to call rb_vm_bh_to_procval to get a proc from our passed block, save the proc in the environment, and set the modified flag. In the case that the modified flag is set we are able to just use the existing proc in the environment. One quirk of this is that we need to call jit_prepare_routine_call early and ensure we update PC and SP regardless of the branch taken, so that we have a consistent SP offset at the start of the next instruction. We considered using a chain guard to generate these two paths separately, but decided against it because it's very common to see both and the modified case is basically a subset of the instructions in the unmodified case. This includes tests for both getblockparam and getblockparamproxy which was previously missing a test.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/5881
Diffstat (limited to 'yjit/src/cruby_bindings.inc.rs')
-rw-r--r--yjit/src/cruby_bindings.inc.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/yjit/src/cruby_bindings.inc.rs b/yjit/src/cruby_bindings.inc.rs
index ac54ba4446..d1bba429d0 100644
--- a/yjit/src/cruby_bindings.inc.rs
+++ b/yjit/src/cruby_bindings.inc.rs
@@ -589,6 +589,9 @@ pub const VM_ENV_FLAG_WB_REQUIRED: vm_frame_env_flags = 8;
pub const VM_ENV_FLAG_ISOLATED: vm_frame_env_flags = 16;
pub type vm_frame_env_flags = u32;
extern "C" {
+ pub fn rb_vm_bh_to_procval(ec: *const rb_execution_context_t, block_handler: VALUE) -> VALUE;
+}
+extern "C" {
pub fn rb_vm_frame_method_entry(
cfp: *const rb_control_frame_t,
) -> *const rb_callable_method_entry_t;