From 3fdb237682513d27a2131663f58cf4a6e3c82305 Mon Sep 17 00:00:00 2001 From: Joe Savona Date: Thu, 5 Oct 2023 09:20:14 -0700 Subject: [PATCH] Promote enableNoAliasOptimizations to stable (remove flag) Per title, this feature flag is enabled everywhere and is stable enough, let's promote to stable and remove the flag to simplify. --- .../src/HIR/Environment.ts | 10 -------- .../ReactiveScopes/PruneNonEscapingScopes.ts | 24 +++++++++---------- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/compiler/packages/babel-plugin-react-forget/src/HIR/Environment.ts b/compiler/packages/babel-plugin-react-forget/src/HIR/Environment.ts index c675872400..a8d3c67094 100644 --- a/compiler/packages/babel-plugin-react-forget/src/HIR/Environment.ts +++ b/compiler/packages/babel-plugin-react-forget/src/HIR/Environment.ts @@ -140,15 +140,6 @@ export type EnvironmentConfig = { */ inlineUseMemo: boolean; - /** - * Enable optimizations based on the `noAlias` flag of method signatures. When enabled, - * function signatures can declare that they do not alias their arguments, allowing - * Forget to (in some cases) avoid memoizing arguments if they do not otherwise escape. - * - * Defaults to false - */ - enableNoAliasOptimizations: boolean; - /** * When enabled, the compiler assumes that hooks follow the Rules of React: * - Hooks may memoize computation based on any of their parameters, thus @@ -235,7 +226,6 @@ const DEFAULT_ENVIRONMENT_CONFIG: Readonly = { memoizeJsxElements: true, inlineUseMemo: true, validateHooksUsage: true, - enableNoAliasOptimizations: true, assertValidMutableRanges: false, bailoutOnHoleyArrays: false, diff --git a/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/PruneNonEscapingScopes.ts b/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/PruneNonEscapingScopes.ts index 5dfd64bde2..4855bfb18b 100644 --- a/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/PruneNonEscapingScopes.ts +++ b/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/PruneNonEscapingScopes.ts @@ -611,9 +611,10 @@ function computeMemoizationInputs( }; } case "CallExpression": { - const signature = env.config.enableNoAliasOptimizations - ? getFunctionCallSignature(env, value.callee.identifier.type) - : null; + const signature = getFunctionCallSignature( + env, + value.callee.identifier.type + ); const operands = [...eachReactiveValueOperand(value)]; let lvalues = []; if (lvalue !== null) { @@ -636,9 +637,10 @@ function computeMemoizationInputs( }; } case "MethodCall": { - const signature = env.config.enableNoAliasOptimizations - ? getFunctionCallSignature(env, value.property.identifier.type) - : null; + const signature = getFunctionCallSignature( + env, + value.property.identifier.type + ); const operands = [...eachReactiveValueOperand(value)]; let lvalues = []; if (lvalue !== null) { @@ -808,12 +810,10 @@ class CollectDependenciesVisitor extends ReactiveFunctionVisitor { } else if (instruction.value.kind === "CallExpression") { const callee = instruction.value.callee; if (getHookKind(state.env, callee.identifier) != null) { - const signature = this.env.config.enableNoAliasOptimizations - ? getFunctionCallSignature( - this.env, - instruction.value.callee.identifier.type - ) - : null; + const signature = getFunctionCallSignature( + this.env, + instruction.value.callee.identifier.type + ); // Hook values are assumed to escape by default since they can be inputs // to reactive scopes in the hook. However if the hook is annotated as // noAlias we know that the arguments cannot escape and don't need to