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
6 changes: 6 additions & 0 deletions changelog.d/8607-pipeline-null-default-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
### Performance

- Speed up generic registries and record-processing pipelines by caching stable
array fields on proven-contained receivers and using a guarded numeric fast
path for null-defaulted counters, while preserving dynamic JavaScript
semantics on aliased and non-number fallback paths.
49 changes: 49 additions & 0 deletions crates/perry-codegen/src/codegen/artifacts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ pub(super) fn emit_module_artifacts(c: ModuleArtifactsCtx<'_>) -> Result<()> {
false,
None,
Some(nonnegative_index_params),
false,
)
.with_context(|| {
format!(
Expand Down Expand Up @@ -395,6 +396,7 @@ pub(super) fn emit_module_artifacts(c: ModuleArtifactsCtx<'_>) -> Result<()> {
.contains_key(&(class.name.clone(), method.name.clone())),
None,
None,
false,
)
.with_context(|| format!("lowering method '{}::{}'", class.name, method.name))?;
// Representation-selection Phase 5a: the additive `internal`
Expand Down Expand Up @@ -431,13 +433,56 @@ pub(super) fn emit_module_artifacts(c: ModuleArtifactsCtx<'_>) -> Result<()> {
false,
Some(fact.clone()),
None,
false,
)
.with_context(|| {
format!(
"lowering proven-`this` clone of method '{}::{}'",
class.name, method.name
)
})?;

// #8607: a second, stricter clone for the Phase 3b
// provenance+containment route. Its synthetic immutable
// aliases keep stable array-valued fields in local slots, so
// existing local-array loop optimizations can see through
// repeated `this.field` uses. It is never selected by the
// guarded or dispatch-tower `$pshape` routes.
if let Some(cached_method) =
crate::collectors::ptr_array_cached_method(class, method)
{
compile_method(
llmod,
class,
&cached_method,
func_names,
strings,
class_table,
method_names,
module_globals,
module_global_types,
opts.import_function_prefixes,
enum_table,
static_field_globals,
class_ids,
func_signatures,
func_synthetic_arguments,
module_boxed_vars,
closure_rest_params,
cross_module,
None,
false,
Some(fact.clone()),
None,
true,
)
.with_context(|| {
format!(
"lowering contained-receiver array-cache clone of method '{}::{}'",
class.name, method.name
)
})?;
}
}
}
for member in class
Expand Down Expand Up @@ -468,6 +513,7 @@ pub(super) fn emit_module_artifacts(c: ModuleArtifactsCtx<'_>) -> Result<()> {
false,
None,
None,
false,
)
.with_context(|| {
format!(
Expand Down Expand Up @@ -534,6 +580,7 @@ pub(super) fn emit_module_artifacts(c: ModuleArtifactsCtx<'_>) -> Result<()> {
false,
None,
None,
false,
)
.with_context(|| format!("lowering getter '{}::{}'", class.name, prop))?;
}
Expand Down Expand Up @@ -588,6 +635,7 @@ pub(super) fn emit_module_artifacts(c: ModuleArtifactsCtx<'_>) -> Result<()> {
false,
None,
None,
false,
)
.with_context(|| format!("lowering setter '{}::{}'", class.name, prop))?;
}
Expand Down Expand Up @@ -684,6 +732,7 @@ pub(super) fn emit_module_artifacts(c: ModuleArtifactsCtx<'_>) -> Result<()> {
false,
None,
None,
false,
)
.with_context(|| format!("lowering constructor for '{}'", class.name))?;
}
Expand Down
4 changes: 4 additions & 0 deletions crates/perry-codegen/src/codegen/method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ pub(super) fn compile_method(
force_generic_body: bool,
proven_this: Option<crate::collectors::PtrShapeLocal>,
nonnegative_index_params: Option<&[u32]>,
ptr_array_cache_clone: bool,
) -> Result<()> {
let public_llvm_name = methods
.get(&(class.name.clone(), method.name.clone()))
Expand All @@ -282,8 +283,11 @@ pub(super) fn compile_method(
let is_pshape_clone = proven_this.is_some();
let is_index_clone = nonnegative_index_params.is_some();
debug_assert!(!(is_pshape_clone && is_index_clone));
debug_assert!(!ptr_array_cache_clone || is_pshape_clone);
let llvm_name = if let Some(params) = nonnegative_index_params {
crate::codegen::nonnegative_index_method_name(&public_llvm_name, params)
} else if ptr_array_cache_clone {
crate::collectors::ptr_array_cache_method_name(&public_llvm_name)
} else if is_pshape_clone {
crate::collectors::pshape_method_name(&public_llvm_name)
} else if typed_public_trampoline.is_some() || force_generic_body {
Expand Down
3 changes: 2 additions & 1 deletion crates/perry-codegen/src/collectors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ pub(crate) use number_by_construction::collect_number_by_construction_locals;
pub(crate) use param_ranges::{collect_param_int_ranges, ParamIntRanges};
pub(crate) use pointer_locals::collect_pointer_typed_locals;
pub(crate) use proven_this::{
method_proven_this, prune_unregistered_clones, pshape_method_name,
method_proven_this, prune_unregistered_clones, pshape_method_name, ptr_array_cache_fields,
ptr_array_cache_method_name, ptr_array_cached_method,
tower_route_profitable as pshape_tower_route_profitable,
};
pub(crate) use ptr_numarray::{NumArrayDensity, NumArrayLocal};
Expand Down
Loading
Loading