summaryrefslogtreecommitdiff
path: root/zjit.h
diff options
context:
space:
mode:
Diffstat (limited to 'zjit.h')
-rw-r--r--zjit.h21
1 files changed, 14 insertions, 7 deletions
diff --git a/zjit.h b/zjit.h
index f8bffb19ca..5a56297a4e 100644
--- a/zjit.h
+++ b/zjit.h
@@ -49,6 +49,7 @@ void rb_zjit_tracing_invalidate_all(void);
void rb_zjit_invalidate_no_singleton_class(VALUE klass);
void rb_zjit_invalidate_root_box(void);
void rb_zjit_jit_frame_update_references(zjit_jit_frame_t *jit_frame);
+void rb_zjit_materialize_frames(const rb_execution_context_t *ec, rb_control_frame_t *cfp);
// Special value for cfp->jit_return that means "this is a C method frame, use
// rb_zjit_c_frame as the JITFrame". We don't control the native stack layout
@@ -56,13 +57,24 @@ void rb_zjit_jit_frame_update_references(zjit_jit_frame_t *jit_frame);
// instead of a heap-allocated JITFrame pointer.
#define ZJIT_JIT_RETURN_C_FRAME 0x1
+// BADFrame. The high bit is set, so likely SEGV on linux and darwin if dereferenced.
+#define ZJIT_JIT_RETURN_POISON 0xbadfbadfbadfbadfULL
+
static inline const zjit_jit_frame_t *
CFP_ZJIT_FRAME(const rb_control_frame_t *cfp)
{
if ((VALUE)cfp->jit_return == ZJIT_JIT_RETURN_C_FRAME) {
return &rb_zjit_c_frame;
}
- return (const zjit_jit_frame_t *)cfp->jit_return;
+ else {
+#if USE_ZJIT
+ RUBY_ASSERT((unsigned long long)((VALUE *)cfp->jit_return)[-1] != ZJIT_JIT_RETURN_POISON);
+#endif
+ // Read JITFrame from the stack slot. gen_entry_point() writes an initial
+ // frame describing the entry PC + iseq; subsequent gen_save_pc_for_gc()
+ // calls update it with a more accurate PC before any non-leaf C call.
+ return (const zjit_jit_frame_t *)((VALUE *)cfp->jit_return)[-1];
+ }
}
#else
#define rb_zjit_entry 0
@@ -78,22 +90,17 @@ static inline void rb_zjit_tracing_invalidate_all(void) {}
static inline void rb_zjit_invalidate_no_singleton_class(VALUE klass) {}
static inline void rb_zjit_invalidate_root_box(void) {}
static inline void rb_zjit_jit_frame_update_references(zjit_jit_frame_t *jit_frame) {}
+static inline void rb_zjit_materialize_frames(const rb_execution_context_t *ec, rb_control_frame_t *cfp) {}
static inline const zjit_jit_frame_t *CFP_ZJIT_FRAME(const rb_control_frame_t *cfp) { return NULL; }
#endif // #if USE_ZJIT
#define rb_zjit_enabled_p (rb_zjit_entry != 0)
-// BADFrame. The high bit is set, so likely SEGV on linux and darwin if dereferenced.
-#define ZJIT_JIT_RETURN_POISON 0xbadfbadfbadfbadfULL
-
// Return true if a given CFP has ZJIT's JITFrame.
static inline bool
CFP_ZJIT_FRAME_P(const rb_control_frame_t *cfp)
{
if (!rb_zjit_enabled_p) return false;
-#if USE_ZJIT
- RUBY_ASSERT((unsigned long long)cfp->jit_return != ZJIT_JIT_RETURN_POISON);
-#endif
return cfp->jit_return != NULL;
}