Skip to content
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

YJIT: Delete stale frozen_bytes related code #7423

Merged
merged 1 commit into from Mar 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 0 additions & 5 deletions yjit/src/asm/mod.rs
Expand Up @@ -611,11 +611,6 @@ impl CodeBlock {
// This currently patches every ISEQ, which works, but in the future,
// we could limit that to patch only on-stack ISEQs for optimizing code GC.
rb_yjit_tracing_invalidate_all();
// When code GC runs next time, we could have reused pages in between
// invalidated pages. To invalidate them, we skip freezing them here.
// We free or not reuse the bytes frozen by any past invalidation, so this
// can be safely reset to pass the frozen bytes check on invalidation.
CodegenGlobals::set_inline_frozen_bytes(0);

// Assert that all code pages are freeable
assert_eq!(
Expand Down
15 changes: 0 additions & 15 deletions yjit/src/codegen.rs
Expand Up @@ -7662,12 +7662,6 @@ pub struct CodegenGlobals {
/// For implementing global code invalidation
global_inval_patches: Vec<CodepagePatch>,

/// For implementing global code invalidation. The number of bytes counting from the beginning
/// of the inline code block that should not be changed. After patching for global invalidation,
/// no one should make changes to the invalidated code region anymore. This is used to
/// break out of invalidation race when there are multiple ractors.
inline_frozen_bytes: usize,

// Methods for generating code for hardcoded (usually C) methods
method_codegen_table: HashMap<usize, MethodGenFn>,

Expand Down Expand Up @@ -7766,7 +7760,6 @@ impl CodegenGlobals {
outline_full_cfunc_return_pos: cfunc_exit_code,
branch_stub_hit_trampoline,
global_inval_patches: Vec::new(),
inline_frozen_bytes: 0,
method_codegen_table: HashMap::new(),
ocb_pages,
code_gc_count: 0,
Expand Down Expand Up @@ -7896,14 +7889,6 @@ impl CodegenGlobals {
mem::take(&mut globals.global_inval_patches)
}

pub fn get_inline_frozen_bytes() -> usize {
CodegenGlobals::get_instance().inline_frozen_bytes
}

pub fn set_inline_frozen_bytes(frozen_bytes: usize) {
CodegenGlobals::get_instance().inline_frozen_bytes = frozen_bytes;
}

pub fn get_outline_full_cfunc_return_pos() -> CodePtr {
CodegenGlobals::get_instance().outline_full_cfunc_return_pos
}
Expand Down
17 changes: 0 additions & 17 deletions yjit/src/core.rs
Expand Up @@ -1820,14 +1820,6 @@ pub fn gen_entry_point(iseq: IseqPtr, ec: EcPtr) -> Option<CodePtr> {

/// Generate code for a branch, possibly rewriting and changing the size of it
fn regenerate_branch(cb: &mut CodeBlock, branch: &mut Branch) {
// FIXME
/*
if (branch->start_addr < cb_get_ptr(cb, yjit_codepage_frozen_bytes)) {
// Generating this branch would modify frozen bytes. Do nothing.
return;
}
*/

// Remove old comments
if let (Some(start_addr), Some(end_addr)) = (branch.start_addr, branch.end_addr) {
cb.remove_comments(start_addr, end_addr)
Expand Down Expand Up @@ -2425,9 +2417,6 @@ pub fn invalidate_block_version(blockref: &BlockRef) {
// Some blocks exit on entry. Patching a jump to the entry at the
// entry makes an infinite loop.
} else {
// TODO(alan)
// if (block.start_addr >= cb_get_ptr(cb, yjit_codepage_frozen_bytes)) // Don't patch frozen code region

// Patch in a jump to block.entry_exit.

let cur_pos = cb.get_write_ptr();
Expand Down Expand Up @@ -2468,12 +2457,6 @@ pub fn invalidate_block_version(blockref: &BlockRef) {
assert_eq!(blockref, incoming_block);
}

// TODO(alan):
// Don't patch frozen code region
// if (branch.start_addr < cb_get_ptr(cb, yjit_codepage_frozen_bytes)) {
// continue;
// }

// Create a stub for this branch target or rewire it to a valid block
set_branch_target(target_idx as u32, block.blockid, &block.ctx, branchref, &mut branch, ocb);

Expand Down
11 changes: 0 additions & 11 deletions yjit/src/invariants.rs
Expand Up @@ -546,17 +546,6 @@ pub extern "C" fn rb_yjit_tracing_invalidate_all() {
cb.set_pos(old_pos);
cb.set_dropped_bytes(old_dropped_bytes);

// Freeze invalidated part of the codepage. We only want to wait for
// running instances of the code to exit from now on, so we shouldn't
// change the code. There could be other ractors sleeping in
// branch_stub_hit(), for example. We could harden this by changing memory
// protection on the frozen range.
assert!(
CodegenGlobals::get_inline_frozen_bytes() <= old_pos,
"frozen bytes should increase monotonically"
);
CodegenGlobals::set_inline_frozen_bytes(old_pos);

CodegenGlobals::get_outlined_cb()
.unwrap()
.mark_all_executable();
Expand Down