diff options
author | Alan Wu <XrXr@users.noreply.github.com> | 2021-11-04 12:30:30 -0400 |
---|---|---|
committer | Alan Wu <XrXr@users.noreply.github.com> | 2021-11-22 18:23:28 -0500 |
commit | 13d1ded253940585a993e92648ab9f77d355586d (patch) | |
tree | 40cd992d429c0e7c53e6e3c4b829b69d662099ff /yjit_core.h | |
parent | e42f994f6b20416853af0252029af94ff7c9b9a9 (diff) |
YJIT: Make block invalidation more robust
This commit adds an entry_exit field to block_t for use in
invalidate_block_version(). By patching the start of the block while
invalidating it, invalidate_block_version() can function correctly
while there is no executable memory left for new branch stubs.
This change additionally fixes correctness for situations where we
cannot patch incoming jumps to the invalidated block. In situations
such as Shopify/yjit#226, the address to the start of the block
is saved and used later, possibly after the block is invalidated.
The assume_* family of function now generate block->entry_exit before
remembering blocks for invalidation.
RubyVM::YJIT.simulate_oom! is introduced for testing out of memory
conditions. The test for it is disabled for now because OOM triggers
other failure conditions not addressed by this commit.
Fixes Shopify/yjit#226
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/5145
Diffstat (limited to 'yjit_core.h')
-rw-r--r-- | yjit_core.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/yjit_core.h b/yjit_core.h index 6cd3ec0095..f31fd58230 100644 --- a/yjit_core.h +++ b/yjit_core.h @@ -241,8 +241,8 @@ typedef struct yjit_block_version ctx_t ctx; // Positions where the generated code starts and ends - uint8_t* start_addr; - uint8_t* end_addr; + uint8_t *start_addr; + uint8_t *end_addr; // List of incoming branches (from predecessors) branch_array_t incoming; @@ -258,6 +258,10 @@ typedef struct yjit_block_version // block in the system. cme_dependency_array_t cme_dependencies; + // Code address of an exit for `ctx` and `blockid`. Used for block + // invalidation. + uint8_t *entry_exit; + // Index one past the last instruction in the iseq uint32_t end_idx; |