mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Prune declarations not used after merging
This is the optimization mentioned in #2113. When we merge scopes, often the declarations from the first scope become unnecessary, since those values are only consumed by the subsequent, now-merged scope. There's no point emitting those values as outputs of the merged scope since no one can consume them. Thanks to the logic in #2116 we now know the last place each identifier is used. We use that again here, to prune declarations that aren't used past the end of the merged scope. This is a pretty dramatic win on cache slots used.
This commit is contained in:
+25
@@ -169,6 +169,9 @@ class Transform extends ReactiveFunctionTransform<void> {
|
||||
areLValuesLastUsedByScope(instr.scope, lvalues, this.lastUsage)
|
||||
) {
|
||||
const intermediateInstructions = block.slice(currentScope.to, i);
|
||||
currentScope.scope.scope.range.end = makeInstructionId(
|
||||
Math.max(currentScope.scope.scope.range.end, instr.scope.range.end)
|
||||
);
|
||||
currentScope.scope.instructions.push(...intermediateInstructions);
|
||||
currentScope.scope.instructions.push(...instr.instructions);
|
||||
for (const [key, value] of instr.scope.declarations) {
|
||||
@@ -193,12 +196,34 @@ class Transform extends ReactiveFunctionTransform<void> {
|
||||
}
|
||||
|
||||
if (nextInstructions !== null) {
|
||||
for (const instr of nextInstructions) {
|
||||
if (instr.kind === "scope") {
|
||||
updateScopeDeclarations(instr.scope, this.lastUsage);
|
||||
}
|
||||
}
|
||||
|
||||
block.length = 0;
|
||||
block.push(...nextInstructions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates @param scope's declarations to remove any declarations that are not
|
||||
* used after the scope, based on the scope's updated range post-merging.
|
||||
*/
|
||||
function updateScopeDeclarations(
|
||||
scope: ReactiveScope,
|
||||
lastUsage: Map<IdentifierId, InstructionId>
|
||||
): void {
|
||||
for (const [key] of scope.declarations) {
|
||||
const lastUsedAt = lastUsage.get(key)!;
|
||||
if (lastUsedAt < scope.range.end) {
|
||||
scope.declarations.delete(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the given @param scope is the last usage of all
|
||||
* the given @param lvalues. Returns false if any of the lvalues
|
||||
|
||||
+5
-11
@@ -31,25 +31,19 @@ import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
import { makeObject_Primitives, mutate } from "shared-runtime";
|
||||
|
||||
function Component() {
|
||||
const $ = useMemoCache(3);
|
||||
let x;
|
||||
let a;
|
||||
const $ = useMemoCache(1);
|
||||
let t0;
|
||||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
a = makeObject_Primitives();
|
||||
const a = makeObject_Primitives();
|
||||
|
||||
x = [];
|
||||
const x = [];
|
||||
x.push(a);
|
||||
|
||||
mutate(x);
|
||||
t0 = [x, a];
|
||||
$[0] = x;
|
||||
$[1] = a;
|
||||
$[2] = t0;
|
||||
$[0] = t0;
|
||||
} else {
|
||||
x = $[0];
|
||||
a = $[1];
|
||||
t0 = $[2];
|
||||
t0 = $[0];
|
||||
}
|
||||
return t0;
|
||||
}
|
||||
|
||||
+4
-7
@@ -20,7 +20,7 @@ function Component() {
|
||||
```javascript
|
||||
import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
function Component() {
|
||||
const $ = useMemoCache(3);
|
||||
const $ = useMemoCache(2);
|
||||
let t0;
|
||||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
t0 = someObj();
|
||||
@@ -29,18 +29,15 @@ function Component() {
|
||||
t0 = $[0];
|
||||
}
|
||||
const a = t0;
|
||||
let x;
|
||||
let t1;
|
||||
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
x = [];
|
||||
const x = [];
|
||||
x.push(a);
|
||||
|
||||
t1 = [x, a];
|
||||
$[1] = x;
|
||||
$[2] = t1;
|
||||
$[1] = t1;
|
||||
} else {
|
||||
x = $[1];
|
||||
t1 = $[2];
|
||||
t1 = $[1];
|
||||
}
|
||||
return t1;
|
||||
}
|
||||
|
||||
+4
-7
@@ -24,7 +24,7 @@ export const FIXTURE_ENTRYPOINT = {
|
||||
```javascript
|
||||
import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
function component() {
|
||||
const $ = useMemoCache(3);
|
||||
const $ = useMemoCache(2);
|
||||
let t0;
|
||||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
t0 = [];
|
||||
@@ -33,18 +33,15 @@ function component() {
|
||||
t0 = $[0];
|
||||
}
|
||||
const z = t0;
|
||||
let y;
|
||||
let x;
|
||||
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
y = {};
|
||||
const y = {};
|
||||
y.z = z;
|
||||
x = {};
|
||||
x.y = y;
|
||||
$[1] = y;
|
||||
$[2] = x;
|
||||
$[1] = x;
|
||||
} else {
|
||||
y = $[1];
|
||||
x = $[2];
|
||||
x = $[1];
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
+10
-16
@@ -24,37 +24,31 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // bar(props.b) i
|
||||
// Correctness:
|
||||
// - y depends on either bar(props.b) or bar(props.b) + 1
|
||||
function AllocatingPrimitiveAsDepNested(props) {
|
||||
const $ = useMemoCache(7);
|
||||
const $ = useMemoCache(5);
|
||||
const c_0 = $[0] !== props.b;
|
||||
const c_1 = $[1] !== props.a;
|
||||
let x;
|
||||
let y;
|
||||
let t2;
|
||||
if (c_0 || c_1) {
|
||||
x = {};
|
||||
const x = {};
|
||||
mutate(x);
|
||||
const t0 = bar(props.b) + 1;
|
||||
const c_5 = $[5] !== t0;
|
||||
const c_3 = $[3] !== t0;
|
||||
let t1;
|
||||
if (c_5) {
|
||||
if (c_3) {
|
||||
t1 = foo(t0);
|
||||
$[5] = t0;
|
||||
$[6] = t1;
|
||||
$[3] = t0;
|
||||
$[4] = t1;
|
||||
} else {
|
||||
t1 = $[6];
|
||||
t1 = $[4];
|
||||
}
|
||||
y = t1;
|
||||
const y = t1;
|
||||
mutate(x, props.a);
|
||||
t2 = [x, y];
|
||||
$[0] = props.b;
|
||||
$[1] = props.a;
|
||||
$[2] = x;
|
||||
$[3] = y;
|
||||
$[4] = t2;
|
||||
$[2] = t2;
|
||||
} else {
|
||||
x = $[2];
|
||||
y = $[3];
|
||||
t2 = $[4];
|
||||
t2 = $[2];
|
||||
}
|
||||
return t2;
|
||||
}
|
||||
|
||||
+10
-16
@@ -24,39 +24,33 @@ export const FIXTURE_ENTRYPOINT = {
|
||||
```javascript
|
||||
import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
function foo(a, b, c) {
|
||||
const $ = useMemoCache(8);
|
||||
const $ = useMemoCache(6);
|
||||
const c_0 = $[0] !== a;
|
||||
const c_1 = $[1] !== b;
|
||||
const c_2 = $[2] !== c;
|
||||
let x;
|
||||
let z;
|
||||
let t1;
|
||||
if (c_0 || c_1 || c_2) {
|
||||
x = [a];
|
||||
const c_6 = $[6] !== b;
|
||||
const x = [a];
|
||||
const c_4 = $[4] !== b;
|
||||
let t0;
|
||||
if (c_6) {
|
||||
if (c_4) {
|
||||
t0 = [null, b];
|
||||
$[6] = b;
|
||||
$[7] = t0;
|
||||
$[4] = b;
|
||||
$[5] = t0;
|
||||
} else {
|
||||
t0 = $[7];
|
||||
t0 = $[5];
|
||||
}
|
||||
const y = t0;
|
||||
z = [[], [], [c]];
|
||||
const z = [[], [], [c]];
|
||||
x[0] = y[1];
|
||||
z[0][0] = x[0];
|
||||
t1 = [x, z];
|
||||
$[0] = a;
|
||||
$[1] = b;
|
||||
$[2] = c;
|
||||
$[3] = x;
|
||||
$[4] = z;
|
||||
$[5] = t1;
|
||||
$[3] = t1;
|
||||
} else {
|
||||
x = $[3];
|
||||
z = $[4];
|
||||
t1 = $[5];
|
||||
t1 = $[3];
|
||||
}
|
||||
return t1;
|
||||
}
|
||||
|
||||
+20
-24
@@ -22,42 +22,38 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // arrayInstance.
|
||||
// - read on receiver
|
||||
// - mutate on lvalue
|
||||
function ArrayAtTest(props) {
|
||||
const $ = useMemoCache(8);
|
||||
const $ = useMemoCache(7);
|
||||
const c_0 = $[0] !== props.x;
|
||||
let t0;
|
||||
let t1;
|
||||
if (c_0) {
|
||||
t0 = foo(props.x);
|
||||
t1 = [t0];
|
||||
t0 = [foo(props.x)];
|
||||
$[0] = props.x;
|
||||
$[1] = t0;
|
||||
$[2] = t1;
|
||||
} else {
|
||||
t0 = $[1];
|
||||
t1 = $[2];
|
||||
}
|
||||
const arr = t1;
|
||||
const c_3 = $[3] !== props.y;
|
||||
const c_4 = $[4] !== arr;
|
||||
let t3;
|
||||
if (c_3 || c_4) {
|
||||
const c_6 = $[6] !== props.y;
|
||||
let t2;
|
||||
if (c_6) {
|
||||
t2 = bar(props.y);
|
||||
$[6] = props.y;
|
||||
$[7] = t2;
|
||||
const arr = t0;
|
||||
const c_2 = $[2] !== props.y;
|
||||
const c_3 = $[3] !== arr;
|
||||
let t2;
|
||||
if (c_2 || c_3) {
|
||||
const c_5 = $[5] !== props.y;
|
||||
let t1;
|
||||
if (c_5) {
|
||||
t1 = bar(props.y);
|
||||
$[5] = props.y;
|
||||
$[6] = t1;
|
||||
} else {
|
||||
t2 = $[7];
|
||||
t1 = $[6];
|
||||
}
|
||||
t3 = arr.at(t2);
|
||||
$[3] = props.y;
|
||||
$[4] = arr;
|
||||
$[5] = t3;
|
||||
t2 = arr.at(t1);
|
||||
$[2] = props.y;
|
||||
$[3] = arr;
|
||||
$[4] = t2;
|
||||
} else {
|
||||
t3 = $[5];
|
||||
t2 = $[4];
|
||||
}
|
||||
const result = t3;
|
||||
const result = t2;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
+3
-7
@@ -21,19 +21,15 @@ function Component(props) {
|
||||
import { unstable_useMemoCache as useMemoCache } from "react"; // x's mutable range should extend to `mutate(y)`
|
||||
|
||||
function Component(props) {
|
||||
const $ = useMemoCache(2);
|
||||
const $ = useMemoCache(1);
|
||||
let t0;
|
||||
let t1;
|
||||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
t0 = {};
|
||||
t1 = [42, t0];
|
||||
t0 = [42, {}];
|
||||
$[0] = t0;
|
||||
$[1] = t1;
|
||||
} else {
|
||||
t0 = $[0];
|
||||
t1 = $[1];
|
||||
}
|
||||
const x = t1;
|
||||
const x = t0;
|
||||
const idx = foo(props.b);
|
||||
const y = x.at(idx);
|
||||
mutate(y);
|
||||
|
||||
+3
-7
@@ -22,19 +22,15 @@ export const FIXTURE_ENTRYPOINT = {
|
||||
```javascript
|
||||
import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
function foo() {
|
||||
const $ = useMemoCache(2);
|
||||
const $ = useMemoCache(1);
|
||||
let t0;
|
||||
let t1;
|
||||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
t0 = [1];
|
||||
t1 = [t0];
|
||||
t0 = [[1]];
|
||||
$[0] = t0;
|
||||
$[1] = t1;
|
||||
} else {
|
||||
t0 = $[0];
|
||||
t1 = $[1];
|
||||
}
|
||||
const a = t1;
|
||||
const a = t0;
|
||||
const first = a.at(0);
|
||||
first.set(0, 2);
|
||||
return a;
|
||||
|
||||
+3
-7
@@ -14,20 +14,16 @@ function Component(props) {
|
||||
```javascript
|
||||
import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
function Component(props) {
|
||||
const $ = useMemoCache(2);
|
||||
const $ = useMemoCache(1);
|
||||
let t0;
|
||||
let t1;
|
||||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
const maybeMutable = new MaybeMutable();
|
||||
t0 = maybeMutate(maybeMutable);
|
||||
t1 = <div>{t0}</div>;
|
||||
t0 = <div>{maybeMutate(maybeMutable)}</div>;
|
||||
$[0] = t0;
|
||||
$[1] = t1;
|
||||
} else {
|
||||
t0 = $[0];
|
||||
t1 = $[1];
|
||||
}
|
||||
return t1;
|
||||
return t0;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
+11
-11
@@ -19,31 +19,31 @@ function Component(props) {
|
||||
```javascript
|
||||
import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
function Component(props) {
|
||||
const $ = useMemoCache(5);
|
||||
const $ = useMemoCache(4);
|
||||
const c_0 = $[0] !== props;
|
||||
let t2;
|
||||
let t1;
|
||||
if (c_0) {
|
||||
const x = makeFunction(props);
|
||||
const c_2 = $[2] !== props.text;
|
||||
let t0;
|
||||
let t1;
|
||||
if (c_2) {
|
||||
t0 = <span>{props.text}</span>;
|
||||
t1 = <div>{t0}</div>;
|
||||
t0 = (
|
||||
<div>
|
||||
<span>{props.text}</span>
|
||||
</div>
|
||||
);
|
||||
$[2] = props.text;
|
||||
$[3] = t0;
|
||||
$[4] = t1;
|
||||
} else {
|
||||
t0 = $[3];
|
||||
t1 = $[4];
|
||||
}
|
||||
t2 = x(t1);
|
||||
t1 = x(t0);
|
||||
$[0] = props;
|
||||
$[1] = t2;
|
||||
$[1] = t1;
|
||||
} else {
|
||||
t2 = $[1];
|
||||
t1 = $[1];
|
||||
}
|
||||
const y = t2;
|
||||
const y = t1;
|
||||
return y;
|
||||
}
|
||||
|
||||
|
||||
+5
-11
@@ -22,24 +22,18 @@ import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
function foo() {}
|
||||
|
||||
function Component(props) {
|
||||
const $ = useMemoCache(3);
|
||||
let a;
|
||||
let b;
|
||||
const $ = useMemoCache(1);
|
||||
let t0;
|
||||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
a = [];
|
||||
b = {};
|
||||
const a = [];
|
||||
const b = {};
|
||||
foo(a, b);
|
||||
|
||||
foo(b);
|
||||
t0 = <div a={a} b={b} />;
|
||||
$[0] = a;
|
||||
$[1] = b;
|
||||
$[2] = t0;
|
||||
$[0] = t0;
|
||||
} else {
|
||||
a = $[0];
|
||||
b = $[1];
|
||||
t0 = $[2];
|
||||
t0 = $[0];
|
||||
}
|
||||
return t0;
|
||||
}
|
||||
|
||||
+3
-7
@@ -23,21 +23,17 @@ export const FIXTURE_ENTRYPOINT = {
|
||||
```javascript
|
||||
import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
function component(a) {
|
||||
const $ = useMemoCache(3);
|
||||
const $ = useMemoCache(2);
|
||||
const c_0 = $[0] !== a;
|
||||
let t0;
|
||||
let t1;
|
||||
if (c_0) {
|
||||
t0 = { a };
|
||||
t1 = { a: t0 };
|
||||
t0 = { a: { a } };
|
||||
$[0] = a;
|
||||
$[1] = t0;
|
||||
$[2] = t1;
|
||||
} else {
|
||||
t0 = $[1];
|
||||
t1 = $[2];
|
||||
}
|
||||
const z = t1;
|
||||
const z = t0;
|
||||
return z;
|
||||
}
|
||||
|
||||
|
||||
+11
-15
@@ -25,35 +25,31 @@ export const FIXTURE_ENTRYPOINT = {
|
||||
```javascript
|
||||
import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
function component(a) {
|
||||
const $ = useMemoCache(5);
|
||||
const $ = useMemoCache(4);
|
||||
const c_0 = $[0] !== a;
|
||||
let t0;
|
||||
let t1;
|
||||
if (c_0) {
|
||||
t0 = { a };
|
||||
t1 = { a: t0 };
|
||||
t0 = { a: { a } };
|
||||
$[0] = a;
|
||||
$[1] = t0;
|
||||
$[2] = t1;
|
||||
} else {
|
||||
t0 = $[1];
|
||||
t1 = $[2];
|
||||
}
|
||||
const z = t1;
|
||||
const c_3 = $[3] !== z.a.a;
|
||||
let t2;
|
||||
if (c_3) {
|
||||
t2 = function () {
|
||||
const z = t0;
|
||||
const c_2 = $[2] !== z.a.a;
|
||||
let t1;
|
||||
if (c_2) {
|
||||
t1 = function () {
|
||||
(function () {
|
||||
console.log(z.a.a);
|
||||
})();
|
||||
};
|
||||
$[3] = z.a.a;
|
||||
$[4] = t2;
|
||||
$[2] = z.a.a;
|
||||
$[3] = t1;
|
||||
} else {
|
||||
t2 = $[4];
|
||||
t1 = $[3];
|
||||
}
|
||||
const x = t2;
|
||||
const x = t1;
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
+11
-15
@@ -23,33 +23,29 @@ export const FIXTURE_ENTRYPOINT = {
|
||||
```javascript
|
||||
import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
function component(a) {
|
||||
const $ = useMemoCache(5);
|
||||
const $ = useMemoCache(4);
|
||||
const c_0 = $[0] !== a;
|
||||
let t0;
|
||||
let t1;
|
||||
if (c_0) {
|
||||
t0 = { a };
|
||||
t1 = { a: t0 };
|
||||
t0 = { a: { a } };
|
||||
$[0] = a;
|
||||
$[1] = t0;
|
||||
$[2] = t1;
|
||||
} else {
|
||||
t0 = $[1];
|
||||
t1 = $[2];
|
||||
}
|
||||
const z = t1;
|
||||
const c_3 = $[3] !== z.a.a;
|
||||
let t2;
|
||||
if (c_3) {
|
||||
t2 = function () {
|
||||
const z = t0;
|
||||
const c_2 = $[2] !== z.a.a;
|
||||
let t1;
|
||||
if (c_2) {
|
||||
t1 = function () {
|
||||
console.log(z.a.a);
|
||||
};
|
||||
$[3] = z.a.a;
|
||||
$[4] = t2;
|
||||
$[2] = z.a.a;
|
||||
$[3] = t1;
|
||||
} else {
|
||||
t2 = $[4];
|
||||
t1 = $[3];
|
||||
}
|
||||
const x = t2;
|
||||
const x = t1;
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
+4
-7
@@ -23,13 +23,12 @@ import { makeReadOnly } from "react-forget-runtime";
|
||||
import { unstable_useMemoCache as useMemoCache } from "react"; // @enableEmitFreeze true
|
||||
|
||||
function MyComponentName(props) {
|
||||
const $ = useMemoCache(4);
|
||||
const $ = useMemoCache(3);
|
||||
const c_0 = $[0] !== props.a;
|
||||
const c_1 = $[1] !== props.b;
|
||||
let x;
|
||||
let y;
|
||||
if (c_0 || c_1) {
|
||||
x = {};
|
||||
const x = {};
|
||||
foo(x, props.a);
|
||||
foo(x, props.b);
|
||||
|
||||
@@ -37,11 +36,9 @@ function MyComponentName(props) {
|
||||
y.push(x);
|
||||
$[0] = props.a;
|
||||
$[1] = props.b;
|
||||
$[2] = __DEV__ ? makeReadOnly(x, "MyComponentName") : x;
|
||||
$[3] = __DEV__ ? makeReadOnly(y, "MyComponentName") : y;
|
||||
$[2] = __DEV__ ? makeReadOnly(y, "MyComponentName") : y;
|
||||
} else {
|
||||
x = $[2];
|
||||
y = $[3];
|
||||
y = $[2];
|
||||
}
|
||||
return y;
|
||||
}
|
||||
|
||||
+4
-8
@@ -30,7 +30,7 @@ export const FIXTURE_ENTRYPOINT = {
|
||||
```javascript
|
||||
import { unstable_useMemoCache as useMemoCache } from "react"; // Should print A, B, arg, original
|
||||
function Component() {
|
||||
const $ = useMemoCache(3);
|
||||
const $ = useMemoCache(2);
|
||||
let t0;
|
||||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
t0 = (o) => {
|
||||
@@ -41,20 +41,16 @@ function Component() {
|
||||
t0 = $[0];
|
||||
}
|
||||
const changeF = t0;
|
||||
let t1;
|
||||
let x;
|
||||
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
t1 = () => console.log("original");
|
||||
x = { f: t1 };
|
||||
x = { f: () => console.log("original") };
|
||||
|
||||
(console.log("A"), x)[(console.log("B"), "f")](
|
||||
(changeF(x), console.log("arg"), 1)
|
||||
);
|
||||
$[1] = t1;
|
||||
$[2] = x;
|
||||
$[1] = x;
|
||||
} else {
|
||||
t1 = $[1];
|
||||
x = $[2];
|
||||
x = $[1];
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
+5
-11
@@ -22,23 +22,17 @@ import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
function Foo() {}
|
||||
|
||||
function Component(props) {
|
||||
const $ = useMemoCache(3);
|
||||
let a;
|
||||
let b;
|
||||
const $ = useMemoCache(1);
|
||||
let t0;
|
||||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
a = [];
|
||||
b = {};
|
||||
const a = [];
|
||||
const b = {};
|
||||
new Foo(a, b);
|
||||
new Foo(b);
|
||||
t0 = <div a={a} b={b} />;
|
||||
$[0] = a;
|
||||
$[1] = b;
|
||||
$[2] = t0;
|
||||
$[0] = t0;
|
||||
} else {
|
||||
a = $[0];
|
||||
b = $[1];
|
||||
t0 = $[2];
|
||||
t0 = $[0];
|
||||
}
|
||||
return t0;
|
||||
}
|
||||
|
||||
+9
-9
@@ -29,27 +29,27 @@ import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
import fbt from "fbt";
|
||||
|
||||
export function Component(props) {
|
||||
const $ = useMemoCache(3);
|
||||
const $ = useMemoCache(2);
|
||||
let count = 0;
|
||||
if (props.items) {
|
||||
count = props.items.length;
|
||||
}
|
||||
const c_0 = $[0] !== count;
|
||||
let t0;
|
||||
let t1;
|
||||
if (c_0) {
|
||||
t0 = fbt._("for {count} experiences", [fbt._param("count", count)], {
|
||||
hk: "nmYpm",
|
||||
});
|
||||
t1 = <View>{t0}</View>;
|
||||
t0 = (
|
||||
<View>
|
||||
{fbt._("for {count} experiences", [fbt._param("count", count)], {
|
||||
hk: "nmYpm",
|
||||
})}
|
||||
</View>
|
||||
);
|
||||
$[0] = count;
|
||||
$[1] = t0;
|
||||
$[2] = t1;
|
||||
} else {
|
||||
t0 = $[1];
|
||||
t1 = $[2];
|
||||
}
|
||||
return t1;
|
||||
return t0;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
+7
-7
@@ -25,19 +25,19 @@ import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
import fbt from "fbt";
|
||||
|
||||
function Component(props) {
|
||||
const $ = useMemoCache(2);
|
||||
const $ = useMemoCache(1);
|
||||
let t0;
|
||||
let t1;
|
||||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
t0 = fbt._("{value}%", [fbt._param("value", "0")], { hk: "10F5Cc" });
|
||||
t1 = <Foo value={t0} />;
|
||||
t0 = (
|
||||
<Foo
|
||||
value={fbt._("{value}%", [fbt._param("value", "0")], { hk: "10F5Cc" })}
|
||||
/>
|
||||
);
|
||||
$[0] = t0;
|
||||
$[1] = t1;
|
||||
} else {
|
||||
t0 = $[0];
|
||||
t1 = $[1];
|
||||
}
|
||||
return t1;
|
||||
return t0;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
+27
-27
@@ -29,49 +29,49 @@ import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
import fbt from "fbt";
|
||||
|
||||
function Component(t39) {
|
||||
const $ = useMemoCache(5);
|
||||
const $ = useMemoCache(4);
|
||||
const { name, data, icon } = t39;
|
||||
const c_0 = $[0] !== name;
|
||||
const c_1 = $[1] !== icon;
|
||||
const c_2 = $[2] !== data;
|
||||
let t0;
|
||||
let t1;
|
||||
if (c_0 || c_1 || c_2) {
|
||||
t0 = fbt._(
|
||||
"{item author}{icon}{=m2}",
|
||||
[
|
||||
fbt._param(
|
||||
"item author",
|
||||
t0 = (
|
||||
<Text type="body4">
|
||||
{fbt._(
|
||||
"{item author}{icon}{=m2}",
|
||||
[
|
||||
fbt._param(
|
||||
"item author",
|
||||
|
||||
<Text type="h4">{name}</Text>
|
||||
),
|
||||
fbt._param(
|
||||
"icon",
|
||||
<Text type="h4">{name}</Text>
|
||||
),
|
||||
fbt._param(
|
||||
"icon",
|
||||
|
||||
icon
|
||||
),
|
||||
fbt._implicitParam(
|
||||
"=m2",
|
||||
<Text type="h4">
|
||||
{fbt._("{item details}", [fbt._param("item details", data)], {
|
||||
hk: "4jLfVq",
|
||||
})}
|
||||
</Text>
|
||||
),
|
||||
],
|
||||
{ hk: "2HLm2j" }
|
||||
icon
|
||||
),
|
||||
fbt._implicitParam(
|
||||
"=m2",
|
||||
<Text type="h4">
|
||||
{fbt._("{item details}", [fbt._param("item details", data)], {
|
||||
hk: "4jLfVq",
|
||||
})}
|
||||
</Text>
|
||||
),
|
||||
],
|
||||
{ hk: "2HLm2j" }
|
||||
)}
|
||||
</Text>
|
||||
);
|
||||
t1 = <Text type="body4">{t0}</Text>;
|
||||
$[0] = name;
|
||||
$[1] = icon;
|
||||
$[2] = data;
|
||||
$[3] = t0;
|
||||
$[4] = t1;
|
||||
} else {
|
||||
t0 = $[3];
|
||||
t1 = $[4];
|
||||
}
|
||||
return t1;
|
||||
return t0;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
+11
-9
@@ -27,23 +27,25 @@ import fbt from "fbt";
|
||||
import { identity } from "shared-runtime";
|
||||
|
||||
function Component(props) {
|
||||
const $ = useMemoCache(3);
|
||||
const $ = useMemoCache(2);
|
||||
const c_0 = $[0] !== props.text;
|
||||
let t0;
|
||||
let t1;
|
||||
if (c_0) {
|
||||
t0 = fbt._("{value}%", [fbt._param("value", <>{identity(props.text)}</>)], {
|
||||
hk: "10F5Cc",
|
||||
});
|
||||
t1 = <Foo value={t0} />;
|
||||
t0 = (
|
||||
<Foo
|
||||
value={fbt._(
|
||||
"{value}%",
|
||||
[fbt._param("value", <>{identity(props.text)}</>)],
|
||||
{ hk: "10F5Cc" }
|
||||
)}
|
||||
/>
|
||||
);
|
||||
$[0] = props.text;
|
||||
$[1] = t0;
|
||||
$[2] = t1;
|
||||
} else {
|
||||
t0 = $[1];
|
||||
t1 = $[2];
|
||||
}
|
||||
return t1;
|
||||
return t0;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
+4
-7
@@ -22,23 +22,20 @@ export const FIXTURE_ENTRYPOINT = {
|
||||
```javascript
|
||||
import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
function Component(props) {
|
||||
const $ = useMemoCache(3);
|
||||
const $ = useMemoCache(2);
|
||||
const c_0 = $[0] !== props;
|
||||
let items;
|
||||
let t0;
|
||||
if (c_0) {
|
||||
items = [];
|
||||
const items = [];
|
||||
for (const key in props) {
|
||||
items.push(<div key={key}>{key}</div>);
|
||||
}
|
||||
|
||||
t0 = <div>{items}</div>;
|
||||
$[0] = props;
|
||||
$[1] = items;
|
||||
$[2] = t0;
|
||||
$[1] = t0;
|
||||
} else {
|
||||
items = $[1];
|
||||
t0 = $[2];
|
||||
t0 = $[1];
|
||||
}
|
||||
return t0;
|
||||
}
|
||||
|
||||
+4
-7
@@ -28,22 +28,19 @@ import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
import { makeObject_Primitives, mutate, Stringify } from "shared-runtime";
|
||||
|
||||
function Component(_props) {
|
||||
const $ = useMemoCache(2);
|
||||
let results;
|
||||
const $ = useMemoCache(1);
|
||||
let t0;
|
||||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
const collection = [makeObject_Primitives()];
|
||||
results = [];
|
||||
const results = [];
|
||||
for (const item of collection) {
|
||||
results.push(<div key={Stringify(item)}>{Stringify(mutate(item))}</div>);
|
||||
}
|
||||
|
||||
t0 = <div>{results}</div>;
|
||||
$[0] = results;
|
||||
$[1] = t0;
|
||||
$[0] = t0;
|
||||
} else {
|
||||
results = $[0];
|
||||
t0 = $[1];
|
||||
t0 = $[0];
|
||||
}
|
||||
return t0;
|
||||
}
|
||||
|
||||
+4
-8
@@ -23,21 +23,17 @@ export const FIXTURE_ENTRYPOINT = {
|
||||
```javascript
|
||||
import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
function component() {
|
||||
const $ = useMemoCache(2);
|
||||
let t0;
|
||||
const $ = useMemoCache(1);
|
||||
let x;
|
||||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
t0 = function x(a) {
|
||||
x = function x(a) {
|
||||
a.foo();
|
||||
};
|
||||
x = t0;
|
||||
|
||||
x = {};
|
||||
$[0] = t0;
|
||||
$[1] = x;
|
||||
$[0] = x;
|
||||
} else {
|
||||
t0 = $[0];
|
||||
x = $[1];
|
||||
x = $[0];
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
+6
-14
@@ -25,25 +25,17 @@ function Component(props) {
|
||||
```javascript
|
||||
import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
function Component(props) {
|
||||
const $ = useMemoCache(3);
|
||||
let T0;
|
||||
let t1;
|
||||
let t2;
|
||||
const $ = useMemoCache(1);
|
||||
let t0;
|
||||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
const maybeMutable = new MaybeMutable();
|
||||
|
||||
T0 = View;
|
||||
t1 = maybeMutate(maybeMutable);
|
||||
t2 = <T0>{t1}</T0>;
|
||||
$[0] = T0;
|
||||
$[1] = t1;
|
||||
$[2] = t2;
|
||||
t0 = <View>{maybeMutate(maybeMutable)}</View>;
|
||||
$[0] = t0;
|
||||
} else {
|
||||
T0 = $[0];
|
||||
t1 = $[1];
|
||||
t2 = $[2];
|
||||
t0 = $[0];
|
||||
}
|
||||
return t2;
|
||||
return t0;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
+4
-7
@@ -24,20 +24,17 @@ export const FIXTURE_ENTRYPOINT = {
|
||||
```javascript
|
||||
import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
function hoisting() {
|
||||
const $ = useMemoCache(2);
|
||||
let foo;
|
||||
const $ = useMemoCache(1);
|
||||
let t0;
|
||||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
foo = () => bar + baz;
|
||||
const foo = () => bar + baz;
|
||||
|
||||
const bar = 3;
|
||||
const baz = 2;
|
||||
t0 = foo();
|
||||
$[0] = foo;
|
||||
$[1] = t0;
|
||||
$[0] = t0;
|
||||
} else {
|
||||
foo = $[0];
|
||||
t0 = $[1];
|
||||
t0 = $[0];
|
||||
}
|
||||
return t0;
|
||||
}
|
||||
|
||||
+13
-53
@@ -21,70 +21,30 @@ function Component(props) {
|
||||
```javascript
|
||||
import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
function Component(props) {
|
||||
const $ = useMemoCache(11);
|
||||
const $ = useMemoCache(2);
|
||||
let t1;
|
||||
let T2;
|
||||
let t3;
|
||||
let t0;
|
||||
let t4;
|
||||
let T5;
|
||||
let t6;
|
||||
let t7;
|
||||
let t8;
|
||||
let t9;
|
||||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
const count = new MaybeMutable();
|
||||
|
||||
T5 = View;
|
||||
t6 = "\n ";
|
||||
T2 = View;
|
||||
t3 = "\n ";
|
||||
if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
let t0;
|
||||
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
t0 = <span>Text</span>;
|
||||
$[10] = t0;
|
||||
$[1] = t0;
|
||||
} else {
|
||||
t0 = $[10];
|
||||
t0 = $[1];
|
||||
}
|
||||
t4 = "\n ";
|
||||
t1 = maybeMutate(count);
|
||||
t7 = <span>{t1}</span>;
|
||||
t8 = (
|
||||
<T2>
|
||||
{t3}
|
||||
{t0}
|
||||
{t4}
|
||||
{t7}
|
||||
</T2>
|
||||
);
|
||||
t9 = (
|
||||
<T5>
|
||||
{t6}
|
||||
{t8}
|
||||
</T5>
|
||||
t1 = (
|
||||
<View>
|
||||
<View>
|
||||
{t0}
|
||||
<span>{maybeMutate(count)}</span>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
$[0] = t1;
|
||||
$[1] = T2;
|
||||
$[2] = t3;
|
||||
$[3] = t0;
|
||||
$[4] = t4;
|
||||
$[5] = T5;
|
||||
$[6] = t6;
|
||||
$[7] = t7;
|
||||
$[8] = t8;
|
||||
$[9] = t9;
|
||||
} else {
|
||||
t1 = $[0];
|
||||
T2 = $[1];
|
||||
t3 = $[2];
|
||||
t0 = $[3];
|
||||
t4 = $[4];
|
||||
T5 = $[5];
|
||||
t6 = $[6];
|
||||
t7 = $[7];
|
||||
t8 = $[8];
|
||||
t9 = $[9];
|
||||
}
|
||||
return t9;
|
||||
return t1;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
+16
-15
@@ -26,34 +26,35 @@ export const FIXTURE_ENTRYPOINT = {
|
||||
```javascript
|
||||
import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
function Foo(props) {
|
||||
const $ = useMemoCache(4);
|
||||
const $ = useMemoCache(3);
|
||||
let t0;
|
||||
let t1;
|
||||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
t0 = <>Text</>;
|
||||
t1 = <div>{t0}</div>;
|
||||
t0 = (
|
||||
<div>
|
||||
<>Text</>
|
||||
</div>
|
||||
);
|
||||
$[0] = t0;
|
||||
$[1] = t1;
|
||||
} else {
|
||||
t0 = $[0];
|
||||
t1 = $[1];
|
||||
}
|
||||
const c_2 = $[2] !== props.greeting;
|
||||
let t2;
|
||||
if (c_2) {
|
||||
t2 = (
|
||||
const c_1 = $[1] !== props.greeting;
|
||||
let t1;
|
||||
if (c_1) {
|
||||
t1 = (
|
||||
<>
|
||||
Hello {props.greeting}
|
||||
{t1}
|
||||
{t0}
|
||||
</>
|
||||
);
|
||||
$[2] = props.greeting;
|
||||
$[3] = t2;
|
||||
$[1] = props.greeting;
|
||||
$[2] = t1;
|
||||
} else {
|
||||
t2 = $[3];
|
||||
t1 = $[2];
|
||||
}
|
||||
return t2;
|
||||
return t1;
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
fn: Foo,
|
||||
params: ["TodoAdd"],
|
||||
|
||||
+6
-14
@@ -14,24 +14,16 @@ function Component(props) {
|
||||
```javascript
|
||||
import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
function Component(props) {
|
||||
const $ = useMemoCache(3);
|
||||
let T0;
|
||||
let t1;
|
||||
let t2;
|
||||
const $ = useMemoCache(1);
|
||||
let t0;
|
||||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
const maybeMutable = new MaybeMutable();
|
||||
T0 = Foo.Bar;
|
||||
t1 = maybeMutate(maybeMutable);
|
||||
t2 = <T0>{t1}</T0>;
|
||||
$[0] = T0;
|
||||
$[1] = t1;
|
||||
$[2] = t2;
|
||||
t0 = <Foo.Bar>{maybeMutate(maybeMutable)}</Foo.Bar>;
|
||||
$[0] = t0;
|
||||
} else {
|
||||
T0 = $[0];
|
||||
t1 = $[1];
|
||||
t2 = $[2];
|
||||
t0 = $[0];
|
||||
}
|
||||
return t2;
|
||||
return t0;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
+7
-7
@@ -17,19 +17,19 @@ function Component(props) {
|
||||
```javascript
|
||||
import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
function Component(props) {
|
||||
const $ = useMemoCache(2);
|
||||
const $ = useMemoCache(1);
|
||||
let t0;
|
||||
let t1;
|
||||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
t0 = <Foo.Bar.Baz />;
|
||||
t1 = <Sathya.Codes.Forget>{t0}</Sathya.Codes.Forget>;
|
||||
t0 = (
|
||||
<Sathya.Codes.Forget>
|
||||
<Foo.Bar.Baz />
|
||||
</Sathya.Codes.Forget>
|
||||
);
|
||||
$[0] = t0;
|
||||
$[1] = t1;
|
||||
} else {
|
||||
t0 = $[0];
|
||||
t1 = $[1];
|
||||
}
|
||||
return t1;
|
||||
return t0;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
+7
-11
@@ -42,7 +42,7 @@ import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
import { fbt } from "fbt";
|
||||
|
||||
function Component() {
|
||||
const $ = useMemoCache(4);
|
||||
const $ = useMemoCache(2);
|
||||
let t0;
|
||||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
t0 = () => {
|
||||
@@ -72,21 +72,17 @@ function Component() {
|
||||
}
|
||||
const buttonLabel = t0;
|
||||
let t1;
|
||||
let t2;
|
||||
let t3;
|
||||
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
t1 = buttonLabel();
|
||||
t2 = <Button text={t1} />;
|
||||
t3 = <View>{t2}</View>;
|
||||
t1 = (
|
||||
<View>
|
||||
<Button text={buttonLabel()} />
|
||||
</View>
|
||||
);
|
||||
$[1] = t1;
|
||||
$[2] = t2;
|
||||
$[3] = t3;
|
||||
} else {
|
||||
t1 = $[1];
|
||||
t2 = $[2];
|
||||
t3 = $[3];
|
||||
}
|
||||
return t3;
|
||||
return t1;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
+13
-17
@@ -27,7 +27,7 @@ export const FIXTURE_ENTRYPOINT = {
|
||||
```javascript
|
||||
import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
function Component() {
|
||||
const $ = useMemoCache(9);
|
||||
const $ = useMemoCache(8);
|
||||
const [state, setState] = useState(0);
|
||||
let t0;
|
||||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
@@ -47,39 +47,35 @@ function Component() {
|
||||
}
|
||||
const c_3 = $[3] !== state;
|
||||
let t2;
|
||||
let t3;
|
||||
if (c_3) {
|
||||
t2 = () => setState(state + 1);
|
||||
t3 = (
|
||||
<button data-testid="button" onClick={t2}>
|
||||
t2 = (
|
||||
<button data-testid="button" onClick={() => setState(state + 1)}>
|
||||
increment
|
||||
</button>
|
||||
);
|
||||
$[3] = state;
|
||||
$[4] = t2;
|
||||
$[5] = t3;
|
||||
} else {
|
||||
t2 = $[4];
|
||||
t3 = $[5];
|
||||
}
|
||||
const c_6 = $[6] !== t1;
|
||||
const c_7 = $[7] !== t3;
|
||||
let t4;
|
||||
if (c_6 || c_7) {
|
||||
t4 = (
|
||||
const c_5 = $[5] !== t1;
|
||||
const c_6 = $[6] !== t2;
|
||||
let t3;
|
||||
if (c_5 || c_6) {
|
||||
t3 = (
|
||||
<div>
|
||||
{t0}
|
||||
{t1}
|
||||
{t3}
|
||||
{t2}
|
||||
</div>
|
||||
);
|
||||
$[6] = t1;
|
||||
$[5] = t1;
|
||||
$[6] = t2;
|
||||
$[7] = t3;
|
||||
$[8] = t4;
|
||||
} else {
|
||||
t4 = $[8];
|
||||
t3 = $[7];
|
||||
}
|
||||
return t4;
|
||||
return t3;
|
||||
}
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
fn: Component,
|
||||
|
||||
+4
-8
@@ -37,7 +37,7 @@ const ErrorView = isForgetEnabled_Fixtures()
|
||||
|
||||
export default Renderer = isForgetEnabled_Fixtures()
|
||||
? (props) => {
|
||||
const $ = useMemoCache(3);
|
||||
const $ = useMemoCache(2);
|
||||
let t0;
|
||||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
t0 = <Bar />;
|
||||
@@ -46,22 +46,18 @@ export default Renderer = isForgetEnabled_Fixtures()
|
||||
t0 = $[0];
|
||||
}
|
||||
let t1;
|
||||
let t2;
|
||||
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
t1 = <ErrorView />;
|
||||
t2 = (
|
||||
t1 = (
|
||||
<Foo>
|
||||
{t0}
|
||||
{t1}
|
||||
<ErrorView />
|
||||
</Foo>
|
||||
);
|
||||
$[1] = t1;
|
||||
$[2] = t2;
|
||||
} else {
|
||||
t1 = $[1];
|
||||
t2 = $[2];
|
||||
}
|
||||
return t2;
|
||||
return t1;
|
||||
}
|
||||
: (props) => (
|
||||
<Foo>
|
||||
|
||||
+4
-8
@@ -37,7 +37,7 @@ const ErrorView = isForgetEnabled_Fixtures()
|
||||
|
||||
export const Renderer = isForgetEnabled_Fixtures()
|
||||
? (props) => {
|
||||
const $ = useMemoCache(3);
|
||||
const $ = useMemoCache(2);
|
||||
let t0;
|
||||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
t0 = <Bar />;
|
||||
@@ -46,22 +46,18 @@ export const Renderer = isForgetEnabled_Fixtures()
|
||||
t0 = $[0];
|
||||
}
|
||||
let t1;
|
||||
let t2;
|
||||
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
t1 = <ErrorView />;
|
||||
t2 = (
|
||||
t1 = (
|
||||
<Foo>
|
||||
{t0}
|
||||
{t1}
|
||||
<ErrorView />
|
||||
</Foo>
|
||||
);
|
||||
$[1] = t1;
|
||||
$[2] = t2;
|
||||
} else {
|
||||
t1 = $[1];
|
||||
t2 = $[2];
|
||||
}
|
||||
return t2;
|
||||
return t1;
|
||||
}
|
||||
: (props) => (
|
||||
<Foo>
|
||||
|
||||
+4
-8
@@ -39,7 +39,7 @@ const ErrorView = isForgetEnabled_Fixtures()
|
||||
|
||||
const Renderer = isForgetEnabled_Fixtures()
|
||||
? (props) => {
|
||||
const $ = useMemoCache(3);
|
||||
const $ = useMemoCache(2);
|
||||
let t0;
|
||||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
t0 = <Bar />;
|
||||
@@ -48,22 +48,18 @@ const Renderer = isForgetEnabled_Fixtures()
|
||||
t0 = $[0];
|
||||
}
|
||||
let t1;
|
||||
let t2;
|
||||
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
t1 = <ErrorView />;
|
||||
t2 = (
|
||||
t1 = (
|
||||
<Foo>
|
||||
{t0}
|
||||
{t1}
|
||||
<ErrorView />
|
||||
</Foo>
|
||||
);
|
||||
$[1] = t1;
|
||||
$[2] = t2;
|
||||
} else {
|
||||
t1 = $[1];
|
||||
t2 = $[2];
|
||||
}
|
||||
return t2;
|
||||
return t1;
|
||||
}
|
||||
: (props) => (
|
||||
<Foo>
|
||||
|
||||
+7
-19
@@ -76,17 +76,13 @@ function cond(x) {
|
||||
}
|
||||
|
||||
function testFunction(props) {
|
||||
const $ = useMemoCache(5);
|
||||
let a;
|
||||
let b;
|
||||
let c;
|
||||
let d;
|
||||
const $ = useMemoCache(1);
|
||||
let t0;
|
||||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
a = {};
|
||||
b = {};
|
||||
c = {};
|
||||
d = {};
|
||||
let a = {};
|
||||
let b = {};
|
||||
let c = {};
|
||||
let d = {};
|
||||
while (true) {
|
||||
const z = a;
|
||||
a = b;
|
||||
@@ -109,17 +105,9 @@ function testFunction(props) {
|
||||
|
||||
mutate(d, null);
|
||||
t0 = { a, b, c, d };
|
||||
$[0] = a;
|
||||
$[1] = b;
|
||||
$[2] = c;
|
||||
$[3] = d;
|
||||
$[4] = t0;
|
||||
$[0] = t0;
|
||||
} else {
|
||||
a = $[0];
|
||||
b = $[1];
|
||||
c = $[2];
|
||||
d = $[3];
|
||||
t0 = $[4];
|
||||
t0 = $[0];
|
||||
}
|
||||
return t0;
|
||||
}
|
||||
|
||||
+4
-8
@@ -24,24 +24,20 @@ export const FIXTURE_ENTRYPOINT = {
|
||||
```javascript
|
||||
import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
function Foo() {
|
||||
const $ = useMemoCache(2);
|
||||
const $ = useMemoCache(1);
|
||||
let t0;
|
||||
let t1;
|
||||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
t0 = function t() {
|
||||
t0 = (function t() {
|
||||
return function a(t25) {
|
||||
const x_0 = t25 === undefined ? () => {} : t25;
|
||||
return x_0;
|
||||
};
|
||||
};
|
||||
t1 = t0();
|
||||
})();
|
||||
$[0] = t0;
|
||||
$[1] = t1;
|
||||
} else {
|
||||
t0 = $[0];
|
||||
t1 = $[1];
|
||||
}
|
||||
return t1;
|
||||
return t0;
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
|
||||
+5
-11
@@ -32,14 +32,12 @@ export const FIXTURE_ENTRYPOINT = {
|
||||
```javascript
|
||||
import { unstable_useMemoCache as useMemoCache } from "react"; // @debug
|
||||
function Component(props) {
|
||||
const $ = useMemoCache(4);
|
||||
const $ = useMemoCache(2);
|
||||
const c_0 = $[0] !== props;
|
||||
let x;
|
||||
let y;
|
||||
let t0;
|
||||
if (c_0) {
|
||||
x = {};
|
||||
y = undefined;
|
||||
const x = {};
|
||||
let y = undefined;
|
||||
if (props.cond) {
|
||||
y = [props.value];
|
||||
} else {
|
||||
@@ -50,13 +48,9 @@ function Component(props) {
|
||||
|
||||
t0 = [x, y];
|
||||
$[0] = props;
|
||||
$[1] = x;
|
||||
$[2] = y;
|
||||
$[3] = t0;
|
||||
$[1] = t0;
|
||||
} else {
|
||||
x = $[1];
|
||||
y = $[2];
|
||||
t0 = $[3];
|
||||
t0 = $[1];
|
||||
}
|
||||
return t0;
|
||||
}
|
||||
|
||||
+10
-16
@@ -26,37 +26,31 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // props.b + 1 is
|
||||
// Correctness:
|
||||
// y depends on either props.b or props.b + 1
|
||||
function PrimitiveAsDepNested(props) {
|
||||
const $ = useMemoCache(7);
|
||||
const $ = useMemoCache(5);
|
||||
const c_0 = $[0] !== props.b;
|
||||
const c_1 = $[1] !== props.a;
|
||||
let x;
|
||||
let y;
|
||||
let t2;
|
||||
if (c_0 || c_1) {
|
||||
x = {};
|
||||
const x = {};
|
||||
mutate(x);
|
||||
const t0 = props.b + 1;
|
||||
const c_5 = $[5] !== t0;
|
||||
const c_3 = $[3] !== t0;
|
||||
let t1;
|
||||
if (c_5) {
|
||||
if (c_3) {
|
||||
t1 = foo(t0);
|
||||
$[5] = t0;
|
||||
$[6] = t1;
|
||||
$[3] = t0;
|
||||
$[4] = t1;
|
||||
} else {
|
||||
t1 = $[6];
|
||||
t1 = $[4];
|
||||
}
|
||||
y = t1;
|
||||
const y = t1;
|
||||
mutate(x, props.a);
|
||||
t2 = [x, y];
|
||||
$[0] = props.b;
|
||||
$[1] = props.a;
|
||||
$[2] = x;
|
||||
$[3] = y;
|
||||
$[4] = t2;
|
||||
$[2] = t2;
|
||||
} else {
|
||||
x = $[2];
|
||||
y = $[3];
|
||||
t2 = $[4];
|
||||
t2 = $[2];
|
||||
}
|
||||
return t2;
|
||||
}
|
||||
|
||||
+4
-8
@@ -30,7 +30,7 @@ export const FIXTURE_ENTRYPOINT = {
|
||||
import { unstable_useMemoCache as useMemoCache } from "react"; // Should print A, arg, original
|
||||
|
||||
function Component() {
|
||||
const $ = useMemoCache(3);
|
||||
const $ = useMemoCache(2);
|
||||
let t0;
|
||||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
t0 = (o) => {
|
||||
@@ -41,18 +41,14 @@ function Component() {
|
||||
t0 = $[0];
|
||||
}
|
||||
const changeF = t0;
|
||||
let t1;
|
||||
let x;
|
||||
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
t1 = () => console.log("original");
|
||||
x = { f: t1 };
|
||||
x = { f: () => console.log("original") };
|
||||
|
||||
(console.log("A"), x).f((changeF(x), console.log("arg"), 1));
|
||||
$[1] = t1;
|
||||
$[2] = x;
|
||||
$[1] = x;
|
||||
} else {
|
||||
t1 = $[1];
|
||||
x = $[2];
|
||||
x = $[1];
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
+4
-7
@@ -26,13 +26,12 @@ export const FIXTURE_ENTRYPOINT = {
|
||||
```javascript
|
||||
import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
function f(a, b) {
|
||||
const $ = useMemoCache(4);
|
||||
const $ = useMemoCache(3);
|
||||
const c_0 = $[0] !== a.length;
|
||||
const c_1 = $[1] !== b;
|
||||
let x;
|
||||
let t0;
|
||||
if (c_0 || c_1) {
|
||||
x = [];
|
||||
const x = [];
|
||||
if (a.length === 1) {
|
||||
if (b) {
|
||||
x.push(b);
|
||||
@@ -42,11 +41,9 @@ function f(a, b) {
|
||||
t0 = <div>{x}</div>;
|
||||
$[0] = a.length;
|
||||
$[1] = b;
|
||||
$[2] = x;
|
||||
$[3] = t0;
|
||||
$[2] = t0;
|
||||
} else {
|
||||
x = $[2];
|
||||
t0 = $[3];
|
||||
t0 = $[2];
|
||||
}
|
||||
return t0;
|
||||
}
|
||||
|
||||
+10
-15
@@ -52,35 +52,30 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // This tests an
|
||||
// }
|
||||
|
||||
function TestJoinCondDepsInUncondScopes(props) {
|
||||
const $ = useMemoCache(6);
|
||||
const $ = useMemoCache(4);
|
||||
const c_0 = $[0] !== props.a.b;
|
||||
let x;
|
||||
let y;
|
||||
let t0;
|
||||
if (c_0) {
|
||||
y = {};
|
||||
const c_4 = $[4] !== props;
|
||||
if (c_4) {
|
||||
const y = {};
|
||||
const c_2 = $[2] !== props;
|
||||
let x;
|
||||
if (c_2) {
|
||||
x = {};
|
||||
if (foo) {
|
||||
mutate1(x, props.a.b);
|
||||
}
|
||||
$[4] = props;
|
||||
$[5] = x;
|
||||
$[2] = props;
|
||||
$[3] = x;
|
||||
} else {
|
||||
x = $[5];
|
||||
x = $[3];
|
||||
}
|
||||
|
||||
mutate2(y, props.a.b);
|
||||
t0 = [x, y];
|
||||
$[0] = props.a.b;
|
||||
$[1] = x;
|
||||
$[2] = y;
|
||||
$[3] = t0;
|
||||
$[1] = t0;
|
||||
} else {
|
||||
x = $[1];
|
||||
y = $[2];
|
||||
t0 = $[3];
|
||||
t0 = $[1];
|
||||
}
|
||||
return t0;
|
||||
}
|
||||
|
||||
+5
-11
@@ -25,26 +25,20 @@ import { unstable_useMemoCache as useMemoCache } from "react"; // @Pass runMutab
|
||||
function foo() {}
|
||||
|
||||
function Component(props) {
|
||||
const $ = useMemoCache(3);
|
||||
let a;
|
||||
let b;
|
||||
const $ = useMemoCache(1);
|
||||
let t0;
|
||||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
a = [];
|
||||
b = {};
|
||||
const a = [];
|
||||
const b = {};
|
||||
foo(a, b);
|
||||
if (foo()) {
|
||||
}
|
||||
|
||||
foo(a, b);
|
||||
t0 = <div a={a} b={b} />;
|
||||
$[0] = a;
|
||||
$[1] = b;
|
||||
$[2] = t0;
|
||||
$[0] = t0;
|
||||
} else {
|
||||
a = $[0];
|
||||
b = $[1];
|
||||
t0 = $[2];
|
||||
t0 = $[0];
|
||||
}
|
||||
return t0;
|
||||
}
|
||||
|
||||
+5
-11
@@ -22,24 +22,18 @@ import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
function foo() {}
|
||||
|
||||
function Component(props) {
|
||||
const $ = useMemoCache(3);
|
||||
let a;
|
||||
let b;
|
||||
const $ = useMemoCache(1);
|
||||
let t0;
|
||||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
a = [];
|
||||
b = {};
|
||||
const a = [];
|
||||
const b = {};
|
||||
foo(a, b);
|
||||
|
||||
foo(a, b);
|
||||
t0 = <div a={a} b={b} />;
|
||||
$[0] = a;
|
||||
$[1] = b;
|
||||
$[2] = t0;
|
||||
$[0] = t0;
|
||||
} else {
|
||||
a = $[0];
|
||||
b = $[1];
|
||||
t0 = $[2];
|
||||
t0 = $[0];
|
||||
}
|
||||
return t0;
|
||||
}
|
||||
|
||||
+3
-11
@@ -15,27 +15,19 @@ function Component(props) {
|
||||
```javascript
|
||||
import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
function Component(props) {
|
||||
const $ = useMemoCache(4);
|
||||
const $ = useMemoCache(2);
|
||||
const c_0 = $[0] !== props;
|
||||
let t0;
|
||||
let t1;
|
||||
let t2;
|
||||
if (c_0) {
|
||||
const maybeMutable = new MaybeMutable();
|
||||
const x = props;
|
||||
t0 = x;
|
||||
t1 = maybeMutate(maybeMutable);
|
||||
t2 = [t0, t1];
|
||||
t0 = [x, maybeMutate(maybeMutable)];
|
||||
$[0] = props;
|
||||
$[1] = t0;
|
||||
$[2] = t1;
|
||||
$[3] = t2;
|
||||
} else {
|
||||
t0 = $[1];
|
||||
t1 = $[2];
|
||||
t2 = $[3];
|
||||
}
|
||||
return t2;
|
||||
return t0;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
+3
-11
@@ -15,27 +15,19 @@ function Component(props) {
|
||||
```javascript
|
||||
import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
function Component(props) {
|
||||
const $ = useMemoCache(4);
|
||||
const $ = useMemoCache(2);
|
||||
const c_0 = $[0] !== props.value;
|
||||
let t0;
|
||||
let t1;
|
||||
let t2;
|
||||
if (c_0) {
|
||||
const maybeMutable = new MaybeMutable();
|
||||
const x = props.value;
|
||||
t0 = x;
|
||||
t1 = maybeMutate(maybeMutable);
|
||||
t2 = [t0, t1];
|
||||
t0 = [x, maybeMutate(maybeMutable)];
|
||||
$[0] = props.value;
|
||||
$[1] = t0;
|
||||
$[2] = t1;
|
||||
$[3] = t2;
|
||||
} else {
|
||||
t0 = $[1];
|
||||
t1 = $[2];
|
||||
t2 = $[3];
|
||||
}
|
||||
return t2;
|
||||
return t0;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
+3
-7
@@ -21,7 +21,7 @@ function component() {
|
||||
```javascript
|
||||
import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
function component() {
|
||||
const $ = useMemoCache(3);
|
||||
const $ = useMemoCache(2);
|
||||
let t0;
|
||||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
t0 = makeSomePrimitive();
|
||||
@@ -30,17 +30,13 @@ function component() {
|
||||
t0 = $[0];
|
||||
}
|
||||
let t1;
|
||||
let t2;
|
||||
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
t1 = makeSomePrimitive();
|
||||
t2 = { u: t0, v: t1 };
|
||||
t1 = { u: t0, v: makeSomePrimitive() };
|
||||
$[1] = t1;
|
||||
$[2] = t2;
|
||||
} else {
|
||||
t1 = $[1];
|
||||
t2 = $[2];
|
||||
}
|
||||
const x = t2;
|
||||
const x = t1;
|
||||
const u = x.u;
|
||||
const v = x.v;
|
||||
if (u > v) {
|
||||
|
||||
+5
-11
@@ -16,22 +16,16 @@ function Component(props) {
|
||||
```javascript
|
||||
import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
function Component(props) {
|
||||
const $ = useMemoCache(3);
|
||||
let y;
|
||||
let x;
|
||||
const $ = useMemoCache(1);
|
||||
let t0;
|
||||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
x = mutate();
|
||||
|
||||
const x = mutate();
|
||||
let y;
|
||||
foo(x);
|
||||
t0 = [y, x];
|
||||
$[0] = y;
|
||||
$[1] = x;
|
||||
$[2] = t0;
|
||||
$[0] = t0;
|
||||
} else {
|
||||
y = $[0];
|
||||
x = $[1];
|
||||
t0 = $[2];
|
||||
t0 = $[0];
|
||||
}
|
||||
return t0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user