Skip to content

Commit 2fd014c

Browse files
committed
fix: module-level arrays with Unknown/Any type crash on Android (v0.4.28)
- analyze_module_var_types set is_union=true for Unknown/Any HIR types - functions.rs loaded module vars as F64 when is_pointer && is_union - Init stored I64 (raw pointer) but functions loaded F64 — type mismatch corrupted array pointers on Android (FP flush-to-zero) - Arrays/closures/maps/sets/buffers now always use I64 regardless of is_union - Also reverted the perry-ui-android JNI_GetCreatedJavaVMs stub (now handled by C stub in linker step from v0.4.27)
1 parent 2b59c0b commit 2fd014c

4 files changed

Lines changed: 34 additions & 27 deletions

File tree

CLAUDE.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
88

99
Perry is a native TypeScript compiler written in Rust that compiles TypeScript source code directly to native executables. It uses SWC for TypeScript parsing and Cranelift for code generation.
1010

11-
**Current Version:** 0.4.27
11+
**Current Version:** 0.4.28
1212

1313
## Workflow Requirements
1414

@@ -140,6 +140,9 @@ Projects can list npm packages to compile natively instead of routing to V8. Con
140140

141141
## Recent Changes
142142

143+
### v0.4.28
144+
- fix: module-level arrays/objects with `Unknown`/`Any` HIR type loaded as F64 instead of I64 in functions — `analyze_module_var_types` set `is_union=true` for Unknown/Any, causing `is_pointer && !is_union` to select F64; init stored I64 but functions loaded F64, corrupting pointers on Android (FP flush-to-zero); now arrays/closures/maps/sets/buffers always use I64
145+
143146
### v0.4.27
144147
- fix: Android `JNI_GetCreatedJavaVMs` undefined symbol — `jni-sys` declares extern ref but Android has no `libjvm.so` (`libnativehelper` only at API 31+); Perry's linker step now compiles a C stub `.o` and links it into the `.so`
145148

Cargo.lock

Lines changed: 24 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ opt-level = "s" # Optimize for size in stdlib
8585
opt-level = 3
8686

8787
[workspace.package]
88-
version = "0.4.27"
88+
version = "0.4.28"
8989
edition = "2021"
9090
license = "MIT"
9191
repository = "https://github.com/PerryTS/perry"

crates/perry-codegen/src/functions.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,11 @@ impl crate::codegen::Compiler {
471471
continue;
472472
}
473473
let (var_type, local_info_template) = if let Some(info) = self.module_level_locals.get(local_id) {
474-
let vt = if info.is_pointer && !info.is_union { types::I64 } else { types::F64 };
474+
// Arrays/closures/maps/sets/buffers are always I64 raw pointers, even
475+
// when is_union is set (e.g., ty=Unknown/Any inferred from untyped code).
476+
// The init function stores I64; loading as F64 causes a type mismatch
477+
// that corrupts the pointer on platforms with FP flush-to-zero (Android).
478+
let vt = if info.is_array || info.is_closure || info.is_map || info.is_set || info.is_buffer || (info.is_pointer && !info.is_union) { types::I64 } else { types::F64 };
475479
(vt, info.clone())
476480
} else {
477481
(types::F64, LocalInfo {

0 commit comments

Comments
 (0)