diff --git a/changelog.d/6839-native-proof-uint8array-symbol.md b/changelog.d/6839-native-proof-uint8array-symbol.md new file mode 100644 index 0000000000..1e0ad1af65 --- /dev/null +++ b/changelog.d/6839-native-proof-uint8array-symbol.md @@ -0,0 +1,6 @@ +### Tests + +- Strengthened native `Uint8Array` codegen coverage so a proven inline byte + read must not call either the legacy byte helper or the JS-value fallback + helper. The disposed-view expectation already present on `main` remains + covered separately. diff --git a/crates/perry-codegen/src/loop_purity.rs b/crates/perry-codegen/src/loop_purity.rs index aeace93d48..364d34cb3b 100644 --- a/crates/perry-codegen/src/loop_purity.rs +++ b/crates/perry-codegen/src/loop_purity.rs @@ -121,9 +121,7 @@ fn expr_alloc_free(e: &Expr) -> bool { // Element READS never allocate — they return an existing element / a // number. Recurse so the object and index are themselves alloc-free. Expr::IndexGet { object, index } => expr_alloc_free(object) && expr_alloc_free(index), - Expr::BufferIndexGet { buffer, index } => { - expr_alloc_free(buffer) && expr_alloc_free(index) - } + Expr::BufferIndexGet { buffer, index } => expr_alloc_free(buffer) && expr_alloc_free(index), Expr::Uint8ArrayGet { array, index } => expr_alloc_free(array) && expr_alloc_free(index), // `arr[i]++` / `--`: read-modify-write of an existing numeric slot, no // growth, no allocation. diff --git a/crates/perry-codegen/tests/native_proof_buffer_views.rs b/crates/perry-codegen/tests/native_proof_buffer_views.rs index 3b312f218a..eaf9ea63ff 100644 --- a/crates/perry-codegen/tests/native_proof_buffer_views.rs +++ b/crates/perry-codegen/tests/native_proof_buffer_views.rs @@ -1650,6 +1650,13 @@ fn uint8array_const_local_length_uses_inline_byte_get_set() { !ir.contains("call i32 @js_uint8array_get"), "inline Uint8Array get should not call the runtime helper:\n{ir}" ); + // The JS-value getter is the other way this could fall back after + // #6088/#6092; without naming it here the negative assertion above would + // miss a regression that took the slow path. + assert!( + !ir.contains("call double @js_uint8array_index_get_value"), + "inline Uint8Array get should not call the JS-value runtime helper:\n{ir}" + ); } #[test]