Open
Conversation
Co-authored-by: Alan Wu <alanwu@ruby-lang.org>
Instead of calling rb_zjit_materialize_frames in every side exit's generated code, call zjit_materialize_frames once in jit_exec() and JIT_EXEC() after the ZJIT entry trampoline returns. This reduces generated code size by removing a C function call from each unique side exit.
Instead of writing 3 fields to C frames (jit_return=0, iseq=0,
block_code=0), write a single JITFrame pointer with {pc=NULL,
iseq=NULL, materialize_block_code=true}. This eliminates 2 memory
writes per C method call.
Add rb_zjit_cfp_has_iseq() and rb_zjit_cfp_has_pc() helpers that
check JITFrame first when present, since cfp->iseq and cfp->pc may
be stale for frames with JITFrame. Replace all cfp->iseq ||
CFP_JIT_RETURN(cfp) and cfp->pc || CFP_JIT_RETURN(cfp) patterns
with the new helpers.
When CFP_JIT_RETURN is true for a C frame (iseq is NULL in JITFrame), block_code in the CFP is stale and must not be passed to rb_gc_location during GC compaction. Only relocate iseq and block_code for ISEQ frames with JITFrame.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cfp->jit_returnfor C frames instead of 0, eliminating 2 memory writes (cfp->iseq = 0andcfp->block_code = 0) per C method callrb_zjit_cfp_has_iseq()andrb_zjit_cfp_has_pc()helpers that check JITFrame first when present (sincecfp->iseqandcfp->pcmay be stale)cfp->iseq || CFP_JIT_RETURN(cfp)andcfp->pc || CFP_JIT_RETURN(cfp)patterns with the new helpers