Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion crates/perry-codegen-wasm/src/emit/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,6 @@ impl WasmModuleEmitter {
// suffix/basename match on `import.source`.
let src_idx_opt = resolve_source_module_idx(modules, import, &name_to_idx);
let Some(src_idx) = src_idx_opt else { continue };
let src_lets = &src_let_names[src_idx];
for spec in &import.specifiers {
if let perry_hir::ir::ImportSpecifier::Named { imported, local } = spec {
// Resolve the public `imported` name to a let
Expand Down
1 change: 0 additions & 1 deletion crates/perry-codegen-wasm/src/emit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ use wasm_encoder::{
use closures::{collect_closures_from_expr, collect_closures_from_stmts};
// `f64_const_bits` is held alive for future use (matches the pre-split
// `#[allow(dead_code)]` annotation on its original definition).
#[allow(unused_imports)]
use constants::f64_const_bits;
use constants::{
f64_const, EnumResolvedValue, STRING_TAG, TAG_FALSE, TAG_NULL, TAG_TRUE, TAG_UNDEFINED,
Expand Down
1 change: 0 additions & 1 deletion crates/perry-codegen-wasm/src/emit/runtime_imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
//!
//! Pure code-movement from `mod.rs`.

#[allow(unused_imports)]
use super::*;

/// Import function indices (must match the order imports are added)
Expand Down
1 change: 0 additions & 1 deletion crates/perry-codegen-wasm/src/emit/ui_method_map.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! `map_ui_method`: maps perry/ui and perry/system method names to bridge
//! function names. Pure code-movement from `mod.rs`.

#[allow(unused_imports)]
use super::*;

/// Map perry/ui and perry/system method names to bridge function names.
Expand Down
9 changes: 0 additions & 9 deletions crates/perry-codegen/src/codegen/boxed_locals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,12 @@
//! the module init — and accumulate a single flat set/map keyed by HIR
//! LocalId (which is globally unique within the module).

use super::*;

use std::collections::HashMap;

use anyhow::{Context, Result};
use perry_hir::Module as HirModule;

use crate::module::LlModule;
use crate::runtime_decls;
use crate::strings::StringPool;
use crate::types::{LlvmType, DOUBLE, I64};

// Collector and boxing-analysis walkers live in dedicated modules.
use crate::boxed_vars::{collect_boxed_param_ids, collect_boxed_vars, collect_let_types_in_stmts};
use crate::collectors::{collect_closures_in_stmts, collect_let_ids, collect_ref_ids_in_stmts};

/// Module-level boxed_vars: union of every per-function/method/
/// closure/module-init boxed set. We compute this once because
Expand Down
1 change: 0 additions & 1 deletion crates/perry-codegen/src/codegen/closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
use std::collections::{HashMap, HashSet};

use anyhow::{anyhow, Context, Result};
use perry_hir::Stmt;

use crate::collectors::{collect_let_ids, collect_ref_ids_in_stmts};
use crate::expr::FnCtx;
Expand Down
11 changes: 1 addition & 10 deletions crates/perry-codegen/src/codegen/closure_collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,12 @@
//! every `Expr::Closure` so the closure creation site can take its address,
//! then derives the rest/arity/arguments/arrow maps from the collected set.

use super::*;

use std::collections::HashMap;

use anyhow::{Context, Result};
use perry_hir::Module as HirModule;

use crate::module::LlModule;
use crate::runtime_decls;
use crate::strings::StringPool;
use crate::types::{LlvmType, DOUBLE, I64};

// Collector and boxing-analysis walkers live in dedicated modules.
use crate::boxed_vars::{collect_boxed_param_ids, collect_boxed_vars, collect_let_types_in_stmts};
use crate::collectors::{collect_closures_in_stmts, collect_let_ids, collect_ref_ids_in_stmts};
use crate::collectors::collect_closures_in_stmts;

// `spec_function_length` is a trunk free fn (also reachable via `super::*`).
use super::spec_function_length;
Expand Down
10 changes: 0 additions & 10 deletions crates/perry-codegen/src/codegen/func_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,11 @@
//! about emission order, and records each function's ABI signature
//! `(param_count, has_rest, returns_number, synthetic_is_rest)`.

use super::*;

use std::collections::HashMap;

use anyhow::{Context, Result};
use perry_hir::Module as HirModule;

use crate::module::LlModule;
use crate::runtime_decls;
use crate::strings::StringPool;
use crate::types::{LlvmType, DOUBLE, I64};

// Collector and boxing-analysis walkers live in dedicated modules.
use crate::boxed_vars::{collect_boxed_param_ids, collect_boxed_vars, collect_let_types_in_stmts};
use crate::collectors::{collect_closures_in_stmts, collect_let_ids, collect_ref_ids_in_stmts};

// Name-mangling helper from the trunk (also reachable via `super::*`).
use super::helpers::scoped_fn_name;
Expand Down
2 changes: 1 addition & 1 deletion crates/perry-codegen/src/codegen/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use std::collections::{HashMap, HashSet};

use anyhow::{anyhow, Context, Result};
use perry_hir::{Function, Stmt};
use perry_hir::Function;

use crate::expr::FnCtx;
use crate::module::LlModule;
Expand Down
7 changes: 0 additions & 7 deletions crates/perry-codegen/src/codegen/i64_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,14 @@
//! the f64 wrapper calls fptosi → i64_fn → sitofp. Returns the set of FuncIds
//! that were specialized so the main compile loop can skip re-emitting them.

use super::*;

use std::collections::HashMap;

use anyhow::{Context, Result};
use perry_hir::Module as HirModule;

use crate::module::LlModule;
use crate::runtime_decls;
use crate::strings::StringPool;
use crate::types::{LlvmType, DOUBLE, I64};

// Collector and boxing-analysis walkers live in dedicated modules.
use crate::boxed_vars::{collect_boxed_param_ids, collect_boxed_vars, collect_let_types_in_stmts};
use crate::collectors::{collect_closures_in_stmts, collect_let_ids, collect_ref_ids_in_stmts};

/// Emit i64-specialized bodies (+ f64 wrappers) for integer-specializable
/// functions. Returns the set of specialized FuncIds.
Expand Down
9 changes: 1 addition & 8 deletions crates/perry-codegen/src/codegen/method_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,14 @@
//! and pre-declares imported-class methods/getters/setters/ctors/statics as
//! extern LLVM functions so the linker can resolve cross-module method calls.

use super::*;

use std::collections::HashMap;

use anyhow::{Context, Result};
use perry_hir::Module as HirModule;

use crate::module::LlModule;
use crate::runtime_decls;
use crate::strings::StringPool;
use crate::types::{LlvmType, DOUBLE, I64};
use crate::types::DOUBLE;

// Collector and boxing-analysis walkers live in dedicated modules.
use crate::boxed_vars::{collect_boxed_param_ids, collect_boxed_vars, collect_let_types_in_stmts};
use crate::collectors::{collect_closures_in_stmts, collect_let_ids, collect_ref_ids_in_stmts};

// Name-mangling helpers from the trunk (also reachable via `super::*`).
use super::helpers::{sanitize, sanitize_member, scoped_method_name, scoped_static_method_name};
Expand Down
2 changes: 1 addition & 1 deletion crates/perry-codegen/src/codegen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ use function::{
};
use helpers::{
collect_return_class, emit_buffer_alias_metadata, function_body_returns_generator_object,
sanitize, sanitize_member, scoped_fn_name, scoped_method_name, scoped_static_method_name,
sanitize,
};

// Collector and boxing-analysis walkers live in dedicated modules. The
Expand Down
8 changes: 1 addition & 7 deletions crates/perry-codegen/src/codegen/module_globals_emit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,14 @@
//! globalized), emits the backing `@perry_global_*` globals + exported-var
//! getters, and registers/emits the `@perry_static_*` class-field globals.

use super::*;

use std::collections::HashMap;

use anyhow::{Context, Result};
use perry_hir::Module as HirModule;

use crate::module::LlModule;
use crate::runtime_decls;
use crate::strings::StringPool;
use crate::types::{LlvmType, DOUBLE, I64};
use crate::types::DOUBLE;

// Collector and boxing-analysis walkers live in dedicated modules.
use crate::boxed_vars::{collect_boxed_param_ids, collect_boxed_vars, collect_let_types_in_stmts};
use crate::collectors::{collect_closures_in_stmts, collect_let_ids, collect_ref_ids_in_stmts};

// Name-mangling helpers + ImportedClass from the trunk (also via `super::*`).
Expand Down
40 changes: 7 additions & 33 deletions crates/perry-codegen/src/collectors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,39 +37,13 @@ pub use i64_emit::emit_i64_function;
// Internal-to-crate re-exports — explicit names because globs don't
// transitively expose through `pub(crate) use crate::collectors::*`.
pub(crate) use class_accessors::{is_class_getter, is_class_setter};
pub(crate) use closures::{collect_closures_in_expr, collect_closures_in_stmts};
pub(crate) use escape_arrays::{
check_array_escapes_in_expr, check_array_escapes_in_stmts, collect_non_escaping_arrays,
const_index, find_array_candidates, MAX_SCALAR_OBJECT_FIELDS,
};
pub(crate) use escape_check::{check_escapes_in_expr, check_escapes_in_stmts, find_new_candidates};
pub(crate) use escape_news::{
collect_non_escaping_new_used_fields, collect_non_escaping_news, MAX_SCALAR_ARRAY_LEN,
};
pub(crate) use escape_objects::{
check_object_literal_escapes_in_expr, check_object_literal_escapes_in_stmts,
collect_non_escaping_object_literals, find_object_literal_candidates,
};
pub(crate) use hir_facts::{
collect_hir_facts, collect_native_region_fact_graph, collect_type_facts, NativeRegionFactGraph,
};
pub(crate) use i32_locals::{
collect_integer_let_ids, collect_localset_ids_in_expr_filtered, collect_localset_ids_in_stmts,
collect_localset_ids_in_stmts_filtered, collect_strictly_i32_bounded_locals,
collect_unsigned_i32_locals, is_bitwise_expr, is_flat_const_indexget,
is_strictly_i32_bounded_expr, is_ushr_zero, walk_writes_for_strict,
walk_writes_in_expr_for_strict,
};
pub(crate) use i64_emit::{i64_body, i64_cond, i64_val};
pub(crate) use index_uses::{
absorb_writes_in_expr, absorb_writes_into_index_used, collect_index_used_locals,
collect_localsets_in_expr_for_propagate, propagate_index_used_transitive,
walk_index_uses_in_expr, walk_index_uses_in_stmts,
};
pub(crate) use integer_locals::{
collect_extra_integer_let_ids, collect_flat_row_aliases, collect_integer_locals,
is_int32_producing_expr,
};
pub(crate) use closures::collect_closures_in_stmts;
pub(crate) use escape_arrays::{const_index, MAX_SCALAR_OBJECT_FIELDS};
pub(crate) use escape_check::{check_escapes_in_stmts, find_new_candidates};
pub(crate) use escape_news::MAX_SCALAR_ARRAY_LEN;
pub(crate) use hir_facts::{collect_native_region_fact_graph, NativeRegionFactGraph};
pub(crate) use i32_locals::{collect_integer_let_ids, collect_localset_ids_in_stmts, is_ushr_zero};
pub(crate) use integer_locals::{collect_flat_row_aliases, is_int32_producing_expr};
pub(crate) use local_refs::{expr_contains_local_get, mark_all_candidate_refs_in_expr};
pub(crate) use mutation::has_any_mutation;
pub(crate) use pointer_locals::collect_pointer_typed_locals;
Expand Down
41 changes: 5 additions & 36 deletions crates/perry-codegen/src/expr/array_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,45 +5,14 @@
//! `lower_expr`'s outer dispatch.

use anyhow::Result;
#[allow(unused_imports)]
use perry_hir::{BinaryOp, CompareOp, Expr, UnaryOp, UpdateOp};
#[allow(unused_imports)]
use perry_types::Type as HirType;
use perry_hir::Expr;

#[allow(unused_imports)]
use crate::lower_call::{lower_call, lower_native_method_call, lower_new};
#[allow(unused_imports)]
use crate::lower_conditional::{lower_conditional, lower_logical, lower_truthy};
#[allow(unused_imports)]
use crate::lower_string_method::{
flatten_string_add_chain, lower_string_coerce_concat, lower_string_concat,
lower_string_concat_chain, lower_string_self_append,
};
#[allow(unused_imports)]
use crate::nanbox::{double_literal, POINTER_MASK_I64};
#[allow(unused_imports)]
use crate::type_analysis::{
compute_auto_captures, is_array_expr, is_bigint_expr, is_bool_expr, is_map_expr,
is_numeric_expr, is_set_expr, is_string_expr, is_url_search_params_expr, receiver_class_name,
};
#[allow(unused_imports)]
use crate::types::{DOUBLE, I1, I32, I64, I8, PTR};
use crate::nanbox::double_literal;
use crate::types::{DOUBLE, I32, I64};

#[allow(unused_imports)]
use super::{
buffer_alias_metadata_suffix, can_lower_expr_as_i32, emit_layout_note_slot_on_block,
emit_shadow_slot_clear, emit_shadow_slot_update_for_expr, emit_string_literal_global,
emit_v8_export_call, emit_v8_member_method_call, emit_write_barrier,
emit_write_barrier_slot_on_block, expr_is_known_non_pointer_shadow_value,
extract_array_of_object_shape, i32_bool_to_nanbox, import_origin_suffix,
is_global_this_builtin_function_name, is_global_this_builtin_name, is_known_finite,
lower_array_literal, lower_channel_reduction, lower_expr, lower_expr_as_i32,
lower_index_set_fast, lower_js_args_array, lower_math_operand, lower_object_literal,
lower_stream_super_init, lower_url_string_getter, nanbox_bigint_inline, nanbox_pointer_inline,
nanbox_pointer_inline_pub, nanbox_string_inline, proxy_build_args_array, try_flat_const_2d_int,
try_lower_flat_const_index_get, try_match_channel_reduction, try_static_class_name,
unbox_str_handle, unbox_to_i64, variant_name, ChannelReduction, FlatConstInfo, FnCtx,
I18nLowerCtx,
i32_bool_to_nanbox, lower_expr, lower_math_operand, nanbox_pointer_inline,
nanbox_string_inline, unbox_str_handle, unbox_to_i64, FnCtx,
};

pub(crate) fn lower(ctx: &mut FnCtx<'_>, expr: &Expr) -> Result<String> {
Expand Down
50 changes: 10 additions & 40 deletions crates/perry-codegen/src/expr/array_push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,23 @@
//! `lower_expr`'s outer dispatch.

use anyhow::{anyhow, Result};
#[allow(unused_imports)]
use perry_hir::{BinaryOp, CompareOp, Expr, UnaryOp, UpdateOp};
#[allow(unused_imports)]
use perry_types::Type as HirType;
use perry_hir::Expr;

#[allow(unused_imports)]
use crate::lower_call::{lower_call, lower_native_method_call, lower_new};
#[allow(unused_imports)]
use crate::lower_conditional::{lower_conditional, lower_logical, lower_truthy};
#[allow(unused_imports)]
use crate::lower_string_method::{
flatten_string_add_chain, lower_string_coerce_concat, lower_string_concat,
lower_string_concat_chain, lower_string_self_append,
};
#[allow(unused_imports)]
use crate::nanbox::{double_literal, POINTER_MASK_I64};
use crate::native_value::{
BoundsState, BufferAccessMode, ExpectedNativeRep, LoweredValue, MaterializationReason,
NativeRep, SemanticKind,
};
#[allow(unused_imports)]
use crate::type_analysis::{
compute_auto_captures, is_array_expr, is_bigint_expr, is_bool_expr, is_map_expr,
is_numeric_expr, is_set_expr, is_string_expr, is_url_search_params_expr, receiver_class_name,
};
#[allow(unused_imports)]
use crate::types::{DOUBLE, I1, I16, I32, I64, I8, PTR};
use crate::type_analysis::is_numeric_expr;
use crate::types::{DOUBLE, I1, I16, I32, I64, I8};

#[allow(unused_imports)]
use super::{
array_store_needs_layout_note, array_store_needs_write_barrier, buffer_alias_metadata_suffix,
can_lower_expr_as_i32, emit_array_numeric_write_note_on_block,
emit_jsvalue_slot_store_on_block, emit_jsvalue_slot_store_with_value_bits_on_block,
emit_layout_note_slot_on_block, emit_root_nanbox_store_on_block, emit_shadow_slot_clear,
emit_shadow_slot_update_for_expr, emit_string_literal_global,
emit_typed_feedback_register_site, emit_v8_export_call, emit_v8_member_method_call,
emit_write_barrier, emit_write_barrier_slot_on_block,
expr_has_numeric_pointer_free_array_layout, expr_is_known_non_pointer_shadow_value,
extract_array_of_object_shape, i32_bool_to_nanbox, import_origin_suffix,
is_global_this_builtin_function_name, is_global_this_builtin_name, is_known_finite,
lower_array_literal, lower_channel_reduction, lower_expr, lower_expr_as_i32, lower_expr_native,
lower_index_set_fast, lower_js_args_array, lower_object_literal, lower_stream_super_init,
lower_url_string_getter, nanbox_bigint_inline, nanbox_pointer_inline,
nanbox_pointer_inline_pub, nanbox_string_inline, proxy_build_args_array, raw_f64_layout_fact,
try_flat_const_2d_int, try_lower_flat_const_index_get, try_match_channel_reduction,
try_static_class_name, unbox_str_handle, unbox_to_i64, variant_name, ChannelReduction,
FlatConstInfo, FnCtx, I18nLowerCtx, TypedFeedbackContract, TypedFeedbackKind,
array_store_needs_layout_note, array_store_needs_write_barrier,
emit_array_numeric_write_note_on_block, emit_jsvalue_slot_store_on_block,
emit_jsvalue_slot_store_with_value_bits_on_block, emit_root_nanbox_store_on_block,
emit_typed_feedback_register_site, emit_write_barrier,
expr_has_numeric_pointer_free_array_layout, lower_expr, lower_expr_native,
nanbox_pointer_inline, raw_f64_layout_fact, unbox_to_i64, FnCtx, TypedFeedbackContract,
TypedFeedbackKind,
};

fn emit_array_handle_length(ctx: &mut FnCtx<'_>, array_handle: &str) -> String {
Expand Down
Loading
Loading