Skip to content

Commit 5bfa7ad

Browse files
committed
fix(ci): clear updated main regression gates
1 parent abaf773 commit 5bfa7ad

11 files changed

Lines changed: 38 additions & 71 deletions

File tree

crates/perry-codegen/src/dialect/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ mod tests;
3535
/// native path pre-declares every define before reading any body — calls to
3636
/// module-internal functions are forward references at module scope, exactly
3737
/// like registers are at function scope.
38+
#[cfg(test)]
3839
pub(crate) fn predeclare_function_from_text<'ctx>(
3940
context: &'ctx Context,
4041
module: &Module<'ctx>,
@@ -104,6 +105,7 @@ impl<'ctx, 'm> FnStream<'ctx, 'm> {
104105

105106
/// Parse `fn_text` (a complete `define ... { ... }`) and build it into
106107
/// `module`. Returns the number of instructions constructed.
108+
#[cfg(test)]
107109
pub(crate) fn add_function_from_text<'ctx>(
108110
context: &'ctx Context,
109111
module: &Module<'ctx>,

crates/perry-codegen/src/gc_map.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ const ELF_SECTION: &str = ".perry_gcmap,\"awR\",@progbits";
8282
const COFF_SECTION: &str = ".pgcmap,\"dw\"";
8383
/// What the runtime looks for in a PE image. Must match `COFF_SECTION`'s name
8484
/// and stay within eight bytes.
85+
#[cfg(test)]
8586
pub(crate) const COFF_SECTION_NAME: &str = ".pgcmap";
8687

8788
/// LLVM stack-map v3 location kinds. Only these two describe a frame slot;

crates/perry-codegen/src/linker.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -713,11 +713,14 @@ fn compile_ll_inprocess_in(
713713
policy: TempFilePolicy,
714714
) -> Result<Vec<u8>> {
715715
let (paths, _pid, _nonce) = llvm_temp_paths(tmp_dir, ll_text);
716+
// The in-process backend still needs a companion clang for structural
717+
// analysis metadata and, for statepoints, final assembly.
718+
let companion_clang = find_clang().unwrap_or_else(|| PathBuf::from("(in-process)"));
716719
// Same decision inputs as the clang path — opt level (#4880 fallback
717720
// included), CPU tuning, inlinehint threshold — via the same plan
718721
// constructor, so the backends cannot drift on a decision independently.
719722
let plan = build_clang_compile_plan(
720-
PathBuf::from("(in-process)"),
723+
companion_clang,
721724
paths.ll_path.clone(),
722725
paths.obj_path.clone(),
723726
target_triple,
@@ -767,8 +770,9 @@ fn compile_ll_inprocess_in(
767770
}
768771
fs::write(asm_path, &bytes)
769772
.with_context(|| format!("Failed to write {}", asm_path.display()))?;
770-
// `plan.clang` is the literal `(in-process)` placeholder here, so
771-
// resolve a real assembler. Using the system clang for this step is
773+
// Resolve the assembler again so a missing companion recorded as
774+
// `(in-process)` above still gets a precise error here. Using the
775+
// system clang for this step is
772776
// sound: the version skew that motivated the in-process backend was
773777
// an *IR* parse failure (`unterminated attribute group`), and by
774778
// this point the IR is gone — what is being assembled is text this

crates/perry-codegen/src/statepoint_report.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
//! knob with no CI arm, so that spelling was deleted under CLAUDE.md's GC knob
1212
//! kill policy. `gc-native-roots.yml` exercises the report through the flag.
1313
14-
use std::collections::BTreeMap;
1514
use std::fmt::Write as _;
1615
use std::sync::{Mutex, OnceLock};
1716

@@ -164,21 +163,6 @@ fn totals(records: &[FunctionRecord]) -> Totals {
164163
out
165164
}
166165

167-
fn render_ranked_map(out: &mut String, heading: &str, values: &BTreeMap<String, u64>) {
168-
if values.is_empty() {
169-
return;
170-
}
171-
let mut rows: Vec<_> = values.iter().collect();
172-
rows.sort_by(|(name_a, count_a), (name_b, count_b)| {
173-
count_b.cmp(count_a).then_with(|| name_a.cmp(name_b))
174-
});
175-
let _ = writeln!(out, "{heading}");
176-
for (name, count) in rows.into_iter().take(25) {
177-
let _ = writeln!(out, " {count:>6} {name}");
178-
}
179-
out.push('\n');
180-
}
181-
182166
pub fn render_text(records: &[FunctionRecord]) -> String {
183167
render_text_with(records, take_gc_map())
184168
}

crates/perry-runtime/src/eh.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,13 @@ extern "C" {
6161
fn _Unwind_RaiseException(exception: *mut UnwindException) -> UnwindReasonCode;
6262
fn _Unwind_GetLanguageSpecificData(ctx: *mut UnwindContext) -> *const u8;
6363
fn _Unwind_GetIPInfo(ctx: *mut UnwindContext, ip_before_insn: *mut c_int) -> usize;
64+
pub(crate) fn _Unwind_GetIP(ctx: *mut UnwindContext) -> usize;
6465
fn _Unwind_GetRegionStart(ctx: *mut UnwindContext) -> usize;
6566
fn _Unwind_SetGR(ctx: *mut UnwindContext, reg_index: c_int, value: usize);
6667
fn _Unwind_SetIP(ctx: *mut UnwindContext, value: usize);
6768
fn _Unwind_GetCFA(ctx: *mut UnwindContext) -> usize;
68-
fn _Unwind_Backtrace(
69-
trace: extern "C" fn(*mut UnwindContext, *mut core::ffi::c_void) -> UnwindReasonCode,
69+
pub(crate) fn _Unwind_Backtrace(
70+
trace: unsafe extern "C" fn(*mut UnwindContext, *mut core::ffi::c_void) -> UnwindReasonCode,
7071
arg: *mut core::ffi::c_void,
7172
) -> UnwindReasonCode;
7273
}
@@ -113,7 +114,10 @@ fn selfcheck_frame_a() -> usize {
113114

114115
#[inline(never)]
115116
fn selfcheck_frame_b() -> usize {
116-
extern "C" fn count(_ctx: *mut UnwindContext, arg: *mut core::ffi::c_void) -> UnwindReasonCode {
117+
unsafe extern "C" fn count(
118+
_ctx: *mut UnwindContext,
119+
arg: *mut core::ffi::c_void,
120+
) -> UnwindReasonCode {
117121
unsafe { *(arg as *mut usize) += 1 };
118122
// _URC_NO_REASON: the ONLY value that lets _Unwind_Backtrace keep
119123
// walking — any other reason code stops the trace after one frame.

crates/perry-runtime/src/eh_walker.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,11 @@ fn parse_unwind_info(ui: &[u8], image_base: u64) -> (Vec<(u64, u32)>, Vec<(u64,
277277
let enc = if idx < common.len() {
278278
common[idx]
279279
} else {
280-
u32at(page_off + enc_off + 4 * (idx - common.len()))
280+
let local_idx = idx - common.len();
281+
if local_idx >= enc_count {
282+
continue;
283+
}
284+
u32at(page_off + enc_off + 4 * local_idx)
281285
};
282286
funcs.push((image_base + fn_base + (raw & 0x00FF_FFFF) as u64, enc));
283287
}
@@ -919,17 +923,12 @@ mod tests {
919923
/// Collect frame PCs via the SYSTEM unwinder (_Unwind_Backtrace) —
920924
/// the oracle the owned walk must match.
921925
fn system_pcs(max: usize) -> Vec<u64> {
922-
use core::ffi::{c_int, c_void};
923-
unsafe extern "C" {
924-
fn _Unwind_Backtrace(
925-
trace: extern "C" fn(*mut c_void, *mut c_void) -> c_int,
926-
arg: *mut c_void,
927-
) -> c_int;
928-
fn _Unwind_GetIP(ctx: *mut c_void) -> u64;
929-
}
930-
extern "C" fn cb(ctx: *mut c_void, arg: *mut c_void) -> c_int {
926+
use crate::eh::{_Unwind_Backtrace, _Unwind_GetIP, UnwindContext, UnwindReasonCode};
927+
use core::ffi::c_void;
928+
929+
unsafe extern "C" fn cb(ctx: *mut UnwindContext, arg: *mut c_void) -> UnwindReasonCode {
931930
let v = unsafe { &mut *(arg as *mut Vec<u64>) };
932-
unsafe { v.push(_Unwind_GetIP(ctx)) };
931+
unsafe { v.push(_Unwind_GetIP(ctx) as u64) };
933932
0
934933
}
935934
let mut v: Vec<u64> = Vec::with_capacity(max);

crates/perry-runtime/src/gc/roots.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -663,14 +663,7 @@ pub(super) fn try_mark_value_or_raw(word: u64, valid_ptrs: &ValidPointerSet) ->
663663
#[inline(always)]
664664
#[cfg(target_os = "macos")]
665665
pub(super) fn get_stack_bottom() -> usize {
666-
extern "C" {
667-
fn pthread_self() -> *mut std::ffi::c_void;
668-
fn pthread_get_stackaddr_np(thread: *mut std::ffi::c_void) -> *mut std::ffi::c_void;
669-
}
670-
unsafe {
671-
let thread = pthread_self();
672-
pthread_get_stackaddr_np(thread) as usize
673-
}
666+
unsafe { libc::pthread_get_stackaddr_np(libc::pthread_self()) as usize }
674667
}
675668

676669
#[cfg(target_os = "linux")]

crates/perry-runtime/src/gc/roots/stack_maps.rs

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -984,18 +984,9 @@ fn loaded_stack_map_section() -> Option<&'static [u8]> {
984984
#[cfg(any(target_vendor = "apple", target_os = "linux"))]
985985
mod unwind {
986986
use super::*;
987-
988-
#[repr(C)]
989-
struct UnwindContext {
990-
_private: [u8; 0],
991-
}
987+
use crate::eh::{_Unwind_Backtrace, _Unwind_GetIP, UnwindContext, UnwindReasonCode};
992988

993989
unsafe extern "C" {
994-
fn _Unwind_Backtrace(
995-
trace: unsafe extern "C" fn(*mut UnwindContext, *mut c_void) -> i32,
996-
argument: *mut c_void,
997-
) -> i32;
998-
fn _Unwind_GetIP(context: *mut UnwindContext) -> usize;
999990
fn _Unwind_GetGR(context: *mut UnwindContext, register: i32) -> usize;
1000991
/// The frame's canonical frame address — the supported way to reach a
1001992
/// frame's stack pointer. `_Unwind_GetGR` on the SP column is not a
@@ -1033,7 +1024,7 @@ mod unwind {
10331024
unsafe extern "C" fn walk_frame<F: FnMut(MutableRootSlot)>(
10341025
context: *mut UnwindContext,
10351026
argument: *mut c_void,
1036-
) -> i32 {
1027+
) -> UnwindReasonCode {
10371028
let state = &mut *argument.cast::<WalkState<'_, F>>();
10381029
state.stats.frames_visited = state.stats.frames_visited.saturating_add(1);
10391030
let ip = _Unwind_GetIP(context);
@@ -1360,11 +1351,7 @@ mod fp_chain {
13601351
// the alternative was this module quietly not existing there.
13611352
#[cfg(target_vendor = "apple")]
13621353
fn stack_top() -> usize {
1363-
unsafe extern "C" {
1364-
fn pthread_self() -> usize;
1365-
fn pthread_get_stackaddr_np(thread: usize) -> *mut c_void;
1366-
}
1367-
unsafe { pthread_get_stackaddr_np(pthread_self()) as usize }
1354+
unsafe { libc::pthread_get_stackaddr_np(libc::pthread_self()) as usize }
13681355
}
13691356

13701357
/// Linux (#7173): stack bounds via pthread attrs — the returned address

crates/perry-runtime/src/module_require.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -448,11 +448,8 @@ fn link_parent(cache: f64, record: f64, parent_filename: &str) {
448448
let children = js_object_get_field_by_name(object_ptr(parent.get_nanbox_f64()), children_key);
449449
let mut children_ptr = if children.is_pointer() {
450450
let ptr = children.as_pointer::<u8>();
451-
if crate::value::addr_class::is_plausible_heap_addr(ptr as usize)
452-
&& unsafe {
453-
(*(ptr.sub(crate::gc::GC_HEADER_SIZE) as *const crate::gc::GcHeader)).obj_type
454-
== crate::gc::GC_TYPE_ARRAY
455-
}
451+
if unsafe { crate::value::addr_class::try_read_gc_header(ptr as usize) }
452+
.is_some_and(|header| header.obj_type == crate::gc::GC_TYPE_ARRAY)
456453
{
457454
ptr as *mut crate::array::ArrayHeader
458455
} else {

crates/perry-runtime/src/process/node_module/source_map.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ pub extern "C" fn js_module_source_map_new(payload: f64, options: f64) -> f64 {
5959
unsafe {
6060
let obj = obj.get_raw_mut_ptr::<crate::object::ObjectHeader>();
6161
(*obj).class_id = SOURCE_MAP_CLASS_ID;
62+
// GC_STORE_AUDIT(INIT): the fresh object is still rooted and unpublished.
6263
(*obj).keys_array = std::ptr::null_mut();
6364
}
6465
crate::object::js_object_set_field(

0 commit comments

Comments
 (0)