Skip to content

Commit

Permalink
[compiler][cleanup] Remove unused enableReactiveScopesInHIR flag
Browse files Browse the repository at this point in the history
Reactive scopes in HIR has been stable for over 3 months now and is the future direction of react compiler, removing this flag to reduce implementation forks.

ghstack-source-id: 65cdf63cf76029fa22d40fd85aba0ac976dcfc08
Pull Request resolved: #30891
  • Loading branch information
mofeiZ committed Sep 6, 2024
1 parent a03254b commit 43264a6
Show file tree
Hide file tree
Showing 24 changed files with 47 additions and 1,355 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,13 @@ import {instructionReordering} from '../Optimization/InstructionReordering';
import {
CodegenFunction,
alignObjectMethodScopes,
alignReactiveScopesToBlockScopes,
assertScopeInstructionsWithinScopes,
assertWellFormedBreakTargets,
buildReactiveBlocks,
buildReactiveFunction,
codegenFunction,
extractScopeDeclarationsFromDestructuring,
flattenReactiveLoops,
flattenScopesWithHooksOrUse,
inferReactiveScopeVariables,
memoizeFbtAndMacroOperandsInSameScope,
mergeOverlappingReactiveScopes,
mergeReactiveScopesThatInvalidateTogether,
promoteUsedTemporaries,
propagateEarlyReturns,
Expand Down Expand Up @@ -300,54 +295,52 @@ function* runWithEnvironment(
value: hir,
});

if (env.config.enableReactiveScopesInHIR) {
pruneUnusedLabelsHIR(hir);
yield log({
kind: 'hir',
name: 'PruneUnusedLabelsHIR',
value: hir,
});
pruneUnusedLabelsHIR(hir);
yield log({
kind: 'hir',
name: 'PruneUnusedLabelsHIR',
value: hir,
});

alignReactiveScopesToBlockScopesHIR(hir);
yield log({
kind: 'hir',
name: 'AlignReactiveScopesToBlockScopesHIR',
value: hir,
});
alignReactiveScopesToBlockScopesHIR(hir);
yield log({
kind: 'hir',
name: 'AlignReactiveScopesToBlockScopesHIR',
value: hir,
});

mergeOverlappingReactiveScopesHIR(hir);
yield log({
kind: 'hir',
name: 'MergeOverlappingReactiveScopesHIR',
value: hir,
});
assertValidBlockNesting(hir);
mergeOverlappingReactiveScopesHIR(hir);
yield log({
kind: 'hir',
name: 'MergeOverlappingReactiveScopesHIR',
value: hir,
});
assertValidBlockNesting(hir);

buildReactiveScopeTerminalsHIR(hir);
yield log({
kind: 'hir',
name: 'BuildReactiveScopeTerminalsHIR',
value: hir,
});
buildReactiveScopeTerminalsHIR(hir);
yield log({
kind: 'hir',
name: 'BuildReactiveScopeTerminalsHIR',
value: hir,
});

assertValidBlockNesting(hir);
assertValidBlockNesting(hir);

flattenReactiveLoopsHIR(hir);
yield log({
kind: 'hir',
name: 'FlattenReactiveLoopsHIR',
value: hir,
});
flattenReactiveLoopsHIR(hir);
yield log({
kind: 'hir',
name: 'FlattenReactiveLoopsHIR',
value: hir,
});

flattenScopesWithHooksOrUseHIR(hir);
yield log({
kind: 'hir',
name: 'FlattenScopesWithHooksOrUseHIR',
value: hir,
});
assertTerminalSuccessorsExist(hir);
assertTerminalPredsExist(hir);
}
flattenScopesWithHooksOrUseHIR(hir);
yield log({
kind: 'hir',
name: 'FlattenScopesWithHooksOrUseHIR',
value: hir,
});
assertTerminalSuccessorsExist(hir);
assertTerminalPredsExist(hir);

const reactiveFunction = buildReactiveFunction(hir);
yield log({
Expand All @@ -364,44 +357,6 @@ function* runWithEnvironment(
name: 'PruneUnusedLabels',
value: reactiveFunction,
});

if (!env.config.enableReactiveScopesInHIR) {
alignReactiveScopesToBlockScopes(reactiveFunction);
yield log({
kind: 'reactive',
name: 'AlignReactiveScopesToBlockScopes',
value: reactiveFunction,
});

mergeOverlappingReactiveScopes(reactiveFunction);
yield log({
kind: 'reactive',
name: 'MergeOverlappingReactiveScopes',
value: reactiveFunction,
});

buildReactiveBlocks(reactiveFunction);
yield log({
kind: 'reactive',
name: 'BuildReactiveBlocks',
value: reactiveFunction,
});

flattenReactiveLoops(reactiveFunction);
yield log({
kind: 'reactive',
name: 'FlattenReactiveLoops',
value: reactiveFunction,
});

flattenScopesWithHooksOrUse(reactiveFunction);
yield log({
kind: 'reactive',
name: 'FlattenScopesWithHooks',
value: reactiveFunction,
});
}

assertScopeInstructionsWithinScopes(reactiveFunction);

propagateScopeDependencies(reactiveFunction);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,6 @@ const EnvironmentConfigSchema = z.object({
*/
enableUseTypeAnnotations: z.boolean().default(false),

enableReactiveScopesInHIR: z.boolean().default(true),

/**
* Enables inference of optional dependency chains. Without this flag
* a property chain such as `props?.items?.foo` will infer as a dep on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
## Input

```javascript
// @enableReactiveScopesInHIR:false

import {Stringify, identity, makeArray, mutate} from 'shared-runtime';

/**
Expand Down Expand Up @@ -37,8 +35,7 @@ export const FIXTURE_ENTRYPOINT = {
## Code

```javascript
import { c as _c } from "react/compiler-runtime"; // @enableReactiveScopesInHIR:false

import { c as _c } from "react/compiler-runtime";
import { Stringify, identity, makeArray, mutate } from "shared-runtime";

/**
Expand All @@ -52,11 +49,12 @@ import { Stringify, identity, makeArray, mutate } from "shared-runtime";
* handles this correctly.
*/
function Foo(t0) {
const $ = _c(4);
const $ = _c(3);
const { cond1, cond2 } = t0;
const arr = makeArray({ a: 2 }, 2, []);
let t1;
if ($[0] !== cond1 || $[1] !== cond2 || $[2] !== arr) {
if ($[0] !== cond1 || $[1] !== cond2) {
const arr = makeArray({ a: 2 }, 2, []);

t1 = cond1 ? (
<>
<div>{identity("foo")}</div>
Expand All @@ -65,10 +63,9 @@ function Foo(t0) {
) : null;
$[0] = cond1;
$[1] = cond2;
$[2] = arr;
$[3] = t1;
$[2] = t1;
} else {
t1 = $[3];
t1 = $[2];
}
return t1;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @enableReactiveScopesInHIR:false

import {Stringify, identity, makeArray, mutate} from 'shared-runtime';

/**
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 43264a6

Please sign in to comment.