Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0fba073934 |
@@ -2089,7 +2089,7 @@ function computeSignatureForInstruction(
|
|||||||
effects.push({
|
effects.push({
|
||||||
kind: 'Freeze',
|
kind: 'Freeze',
|
||||||
value: operand,
|
value: operand,
|
||||||
reason: ValueReason.Other,
|
reason: ValueReason.HookCaptured,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -546,7 +546,7 @@ class CollectDependenciesVisitor extends ReactiveFunctionVisitor<
|
|||||||
* memoization. Note: we may still prune primitive-producing scopes if
|
* memoization. Note: we may still prune primitive-producing scopes if
|
||||||
* they don't ultimately escape at all.
|
* they don't ultimately escape at all.
|
||||||
*/
|
*/
|
||||||
const level = MemoizationLevel.Memoized;
|
const level = MemoizationLevel.Conditional;
|
||||||
return {
|
return {
|
||||||
lvalues: lvalue !== null ? [{place: lvalue, level}] : [],
|
lvalues: lvalue !== null ? [{place: lvalue, level}] : [],
|
||||||
rvalues: [...eachReactiveValueOperand(value)],
|
rvalues: [...eachReactiveValueOperand(value)],
|
||||||
@@ -701,9 +701,7 @@ class CollectDependenciesVisitor extends ReactiveFunctionVisitor<
|
|||||||
}
|
}
|
||||||
case 'ComputedLoad':
|
case 'ComputedLoad':
|
||||||
case 'PropertyLoad': {
|
case 'PropertyLoad': {
|
||||||
const level = options.forceMemoizePrimitives
|
const level = MemoizationLevel.Conditional;
|
||||||
? MemoizationLevel.Memoized
|
|
||||||
: MemoizationLevel.Conditional;
|
|
||||||
return {
|
return {
|
||||||
// Indirection for the inner value, memoized if the value is
|
// Indirection for the inner value, memoized if the value is
|
||||||
lvalues: lvalue !== null ? [{place: lvalue, level}] : [],
|
lvalues: lvalue !== null ? [{place: lvalue, level}] : [],
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
## Input
|
## Input
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
|
// @compilationMode:"infer"
|
||||||
import {makeArray} from 'shared-runtime';
|
import {makeArray} from 'shared-runtime';
|
||||||
|
|
||||||
function Component() {
|
function Component() {
|
||||||
@@ -30,7 +31,7 @@ export const FIXTURE_ENTRYPOINT = {
|
|||||||
## Code
|
## Code
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
import { c as _c } from "react/compiler-runtime";
|
import { c as _c } from "react/compiler-runtime"; // @compilationMode:"infer"
|
||||||
import { makeArray } from "shared-runtime";
|
import { makeArray } from "shared-runtime";
|
||||||
|
|
||||||
function Component() {
|
function Component() {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// @compilationMode:"infer"
|
||||||
import {makeArray} from 'shared-runtime';
|
import {makeArray} from 'shared-runtime';
|
||||||
|
|
||||||
function Component() {
|
function Component() {
|
||||||
|
|||||||
@@ -0,0 +1,86 @@
|
|||||||
|
|
||||||
|
## Input
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
// @enablePreserveExistingMemoizationGuarantees
|
||||||
|
import {fbt} from 'fbt';
|
||||||
|
|
||||||
|
function Component() {
|
||||||
|
const buttonLabel = () => {
|
||||||
|
if (!someCondition) {
|
||||||
|
return <fbt desc="My label">{'Purchase as a gift'}</fbt>;
|
||||||
|
} else if (
|
||||||
|
!iconOnly &&
|
||||||
|
showPrice &&
|
||||||
|
item?.current_gift_offer?.price?.formatted != null
|
||||||
|
) {
|
||||||
|
return (
|
||||||
|
<fbt desc="Gift button's label">
|
||||||
|
{'Gift | '}
|
||||||
|
<fbt:param name="price">
|
||||||
|
{item?.current_gift_offer?.price?.formatted}
|
||||||
|
</fbt:param>
|
||||||
|
</fbt>
|
||||||
|
);
|
||||||
|
} else if (!iconOnly && !showPrice) {
|
||||||
|
return <fbt desc="Gift button's label">{'Gift'}</fbt>;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View>
|
||||||
|
<Button text={buttonLabel()} />
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
## Code
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
import { c as _c } from "react/compiler-runtime"; // @enablePreserveExistingMemoizationGuarantees
|
||||||
|
import { fbt } from "fbt";
|
||||||
|
|
||||||
|
function Component() {
|
||||||
|
const $ = _c(1);
|
||||||
|
const buttonLabel = _temp;
|
||||||
|
let t0;
|
||||||
|
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
||||||
|
t0 = (
|
||||||
|
<View>
|
||||||
|
<Button text={buttonLabel()} />
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
$[0] = t0;
|
||||||
|
} else {
|
||||||
|
t0 = $[0];
|
||||||
|
}
|
||||||
|
return t0;
|
||||||
|
}
|
||||||
|
function _temp() {
|
||||||
|
if (!someCondition) {
|
||||||
|
return fbt._("Purchase as a gift", null, { hk: "1gHj4g" });
|
||||||
|
} else {
|
||||||
|
if (
|
||||||
|
!iconOnly &&
|
||||||
|
showPrice &&
|
||||||
|
item?.current_gift_offer?.price?.formatted != null
|
||||||
|
) {
|
||||||
|
return fbt._(
|
||||||
|
"Gift | {price}",
|
||||||
|
[fbt._param("price", item?.current_gift_offer?.price?.formatted)],
|
||||||
|
{ hk: "3GTnGE" },
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
if (!iconOnly && !showPrice) {
|
||||||
|
return fbt._("Gift", null, { hk: "3fqfrk" });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
### Eval output
|
||||||
|
(kind: exception) Fixture not implemented
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
// @enablePreserveExistingMemoizationGuarantees
|
||||||
|
import {fbt} from 'fbt';
|
||||||
|
|
||||||
|
function Component() {
|
||||||
|
const buttonLabel = () => {
|
||||||
|
if (!someCondition) {
|
||||||
|
return <fbt desc="My label">{'Purchase as a gift'}</fbt>;
|
||||||
|
} else if (
|
||||||
|
!iconOnly &&
|
||||||
|
showPrice &&
|
||||||
|
item?.current_gift_offer?.price?.formatted != null
|
||||||
|
) {
|
||||||
|
return (
|
||||||
|
<fbt desc="Gift button's label">
|
||||||
|
{'Gift | '}
|
||||||
|
<fbt:param name="price">
|
||||||
|
{item?.current_gift_offer?.price?.formatted}
|
||||||
|
</fbt:param>
|
||||||
|
</fbt>
|
||||||
|
);
|
||||||
|
} else if (!iconOnly && !showPrice) {
|
||||||
|
return <fbt desc="Gift button's label">{'Gift'}</fbt>;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View>
|
||||||
|
<Button text={buttonLabel()} />
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
## Input
|
## Input
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
// @enableForest
|
// @enablePreserveExistingMemoizationGuarantees
|
||||||
function Component({base, start, increment, test}) {
|
function Component({base, start, increment, test}) {
|
||||||
let value = base;
|
let value = base;
|
||||||
for (let i = start; i < test; i += increment) {
|
for (let i = start; i < test; i += increment) {
|
||||||
@@ -27,25 +27,23 @@ export const FIXTURE_ENTRYPOINT = {
|
|||||||
## Code
|
## Code
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
import { c as _c } from "react/compiler-runtime"; // @enableForest
|
import { c as _c } from "react/compiler-runtime"; // @enablePreserveExistingMemoizationGuarantees
|
||||||
function Component(t0) {
|
function Component(t0) {
|
||||||
const $ = _c(5);
|
const $ = _c(2);
|
||||||
const { base, start, increment, test } = t0;
|
const { base, start, increment, test } = t0;
|
||||||
let value;
|
let value = base;
|
||||||
if ($[0] !== base || $[1] !== increment || $[2] !== start || $[3] !== test) {
|
for (let i = start; i < test; i = i + increment, i) {
|
||||||
value = base;
|
value = value + i;
|
||||||
for (let i = start; i < test; i = i + increment, i) {
|
|
||||||
value = value + i;
|
|
||||||
}
|
|
||||||
$[0] = base;
|
|
||||||
$[1] = increment;
|
|
||||||
$[2] = start;
|
|
||||||
$[3] = test;
|
|
||||||
$[4] = value;
|
|
||||||
} else {
|
|
||||||
value = $[4];
|
|
||||||
}
|
}
|
||||||
return <div>{value}</div>;
|
let t1;
|
||||||
|
if ($[0] !== value) {
|
||||||
|
t1 = <div>{value}</div>;
|
||||||
|
$[0] = value;
|
||||||
|
$[1] = t1;
|
||||||
|
} else {
|
||||||
|
t1 = $[1];
|
||||||
|
}
|
||||||
|
return t1;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const FIXTURE_ENTRYPOINT = {
|
export const FIXTURE_ENTRYPOINT = {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// @enableForest
|
// @enablePreserveExistingMemoizationGuarantees
|
||||||
function Component({base, start, increment, test}) {
|
function Component({base, start, increment, test}) {
|
||||||
let value = base;
|
let value = base;
|
||||||
for (let i = start; i < test; i += increment) {
|
for (let i = start; i < test; i += increment) {
|
||||||
|
|||||||
Reference in New Issue
Block a user