dillon1000/react
Commit
Browse files Feature to optimize function expressions
This PR adds a new feature which enables additional validation/optimization of function expressions, gated by the `enableOptimizeFunctionExpressions` feature flag. When disabled, we actually revert the changes earlier in this stack, and do all our lowering of function expressions in AnalyzeFunctions. When the feature is enabled, we incrementally process function expressions in the various compilation stages, eg InferTypes infers into function expressions, ConstantPropagation propagates constants into function expressions, etc. Because this stage optimizes function expressions, in this mode codegen uses the HIR as the source rather than the original babel node. The feature is disabled by default so it has no impact on generated code. For now i've enabled the feature on just one test to demonstrate constant propagation into a function expression.
Changed paths13 files
First-parent comparisoncompiler/forget/packages/babel-plugin-react-forget/src/HIR/Environment.ts ModifiedM compiler/forget/packages/babel-plugin-react-forget/src/HIR/MergeConsecutiveBlocks.ts ModifiedM compiler/forget/packages/babel-plugin-react-forget/src/Inference/AnalyseFunctions.ts ModifiedM compiler/forget/packages/babel-plugin-react-forget/src/Optimization/ConstantPropagation.ts ModifiedM compiler/forget/packages/babel-plugin-react-forget/src/ReactiveScopes/CodegenReactiveFunction.ts ModifiedM compiler/forget/packages/babel-plugin-react-forget/src/SSA/EliminateRedundantPhi.ts ModifiedM compiler/forget/packages/babel-plugin-react-forget/src/SSA/EnterSSA.ts ModifiedM compiler/forget/packages/babel-plugin-react-forget/src/TypeInference/InferTypes.ts ModifiedM compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-at-closure.expect.md ModifiedA compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/constant-propagation-into-function-expressions.expect.md AddedA compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/constant-propagation-into-function-expressions.js AddedM compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructuring-mixed-scope-declarations-and-locals.expect.md ModifiedM compiler/forget/packages/snap/src/compiler-worker.ts ModifiedPatch
Files changed
Rendering syntax-highlighted changes…