mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
[compiler] Add nullable abstract value field to places and phis
Test Plan:
This PR starts the process of tracking abstract values (and therefore value kinds) on a per-place basis and persisting that into the place data structure. Here, we simply add a nullable field for abstract values to all places and phis--it will be populated in the next PR.
ghstack-source-id: 9bccf5d09d
Pull Request resolved: https://github.com/facebook/react/pull/30972
This commit is contained in:
@@ -82,6 +82,7 @@ export function lower(
|
||||
kind: 'Identifier',
|
||||
identifier: builder.resolveBinding(ref),
|
||||
effect: Effect.Unknown,
|
||||
abstractValue: null,
|
||||
reactive: false,
|
||||
loc: ref.loc ?? GeneratedSource,
|
||||
});
|
||||
@@ -113,6 +114,7 @@ export function lower(
|
||||
kind: 'Identifier',
|
||||
identifier: binding.identifier,
|
||||
effect: Effect.Unknown,
|
||||
abstractValue: null,
|
||||
reactive: false,
|
||||
loc: param.node.loc ?? GeneratedSource,
|
||||
};
|
||||
@@ -126,6 +128,7 @@ export function lower(
|
||||
kind: 'Identifier',
|
||||
identifier: builder.makeTemporary(param.node.loc ?? GeneratedSource),
|
||||
effect: Effect.Unknown,
|
||||
abstractValue: null,
|
||||
reactive: false,
|
||||
loc: param.node.loc ?? GeneratedSource,
|
||||
};
|
||||
@@ -144,6 +147,7 @@ export function lower(
|
||||
kind: 'Identifier',
|
||||
identifier: builder.makeTemporary(param.node.loc ?? GeneratedSource),
|
||||
effect: Effect.Unknown,
|
||||
abstractValue: null,
|
||||
reactive: false,
|
||||
loc: param.node.loc ?? GeneratedSource,
|
||||
};
|
||||
@@ -460,6 +464,7 @@ function lowerStatement(
|
||||
});
|
||||
const place: Place = {
|
||||
effect: Effect.Unknown,
|
||||
abstractValue: null,
|
||||
identifier: identifier.identifier,
|
||||
kind: 'Identifier',
|
||||
reactive: false,
|
||||
@@ -853,6 +858,7 @@ function lowerStatement(
|
||||
} else {
|
||||
const place: Place = {
|
||||
effect: Effect.Unknown,
|
||||
abstractValue: null,
|
||||
identifier: binding.identifier,
|
||||
kind: 'Identifier',
|
||||
reactive: false,
|
||||
@@ -1264,6 +1270,7 @@ function lowerStatement(
|
||||
handlerBindingPath.node.loc ?? GeneratedSource,
|
||||
),
|
||||
effect: Effect.Unknown,
|
||||
abstractValue: null,
|
||||
reactive: false,
|
||||
loc: handlerBindingPath.node.loc ?? GeneratedSource,
|
||||
};
|
||||
@@ -3428,6 +3435,7 @@ function lowerIdentifier(
|
||||
kind: 'Identifier',
|
||||
identifier: binding.identifier,
|
||||
effect: Effect.Unknown,
|
||||
abstractValue: null,
|
||||
reactive: false,
|
||||
loc: exprLoc,
|
||||
};
|
||||
@@ -3449,6 +3457,7 @@ function buildTemporaryPlace(builder: HIRBuilder, loc: SourceLocation): Place {
|
||||
kind: 'Identifier',
|
||||
identifier: builder.makeTemporary(loc),
|
||||
effect: Effect.Unknown,
|
||||
abstractValue: null,
|
||||
reactive: false,
|
||||
loc,
|
||||
};
|
||||
@@ -3511,6 +3520,7 @@ function lowerIdentifierForAssignment(
|
||||
kind: 'Identifier',
|
||||
identifier: binding.identifier,
|
||||
effect: Effect.Unknown,
|
||||
abstractValue: null,
|
||||
reactive: false,
|
||||
loc,
|
||||
};
|
||||
|
||||
@@ -761,6 +761,7 @@ function _staticInvariantInstructionValueHasLocation(
|
||||
export type Phi = {
|
||||
kind: 'Phi';
|
||||
id: Identifier;
|
||||
abstractValue: AbstractValue | null;
|
||||
operands: Map<BlockId, Identifier>;
|
||||
};
|
||||
|
||||
@@ -1110,6 +1111,7 @@ export type Place = {
|
||||
kind: 'Identifier';
|
||||
identifier: Identifier;
|
||||
effect: Effect;
|
||||
abstractValue: AbstractValue | null;
|
||||
reactive: boolean;
|
||||
loc: SourceLocation;
|
||||
};
|
||||
|
||||
@@ -895,6 +895,7 @@ export function createTemporaryPlace(
|
||||
kind: 'Identifier',
|
||||
identifier: makeTemporaryIdentifier(env.nextIdentifierId, loc),
|
||||
reactive: false,
|
||||
abstractValue: null,
|
||||
effect: Effect.Unknown,
|
||||
loc: GeneratedSource,
|
||||
};
|
||||
|
||||
@@ -86,6 +86,7 @@ export function mergeConsecutiveBlocks(fn: HIRFunction): void {
|
||||
kind: 'Identifier',
|
||||
identifier: phi.id,
|
||||
effect: Effect.ConditionallyMutate,
|
||||
abstractValue: null,
|
||||
reactive: false,
|
||||
loc: GeneratedSource,
|
||||
},
|
||||
@@ -95,6 +96,7 @@ export function mergeConsecutiveBlocks(fn: HIRFunction): void {
|
||||
kind: 'Identifier',
|
||||
identifier: operand,
|
||||
effect: Effect.Read,
|
||||
abstractValue: null,
|
||||
reactive: false,
|
||||
loc: GeneratedSource,
|
||||
},
|
||||
|
||||
@@ -833,6 +833,8 @@ export function printPattern(pattern: Pattern | Place | SpreadPattern): string {
|
||||
|
||||
export function printPlace(place: Place): string {
|
||||
const items = [
|
||||
place.abstractValue?.kind,
|
||||
place.abstractValue ? ' ' : '',
|
||||
place.effect,
|
||||
' ',
|
||||
printIdentifier(place.identifier),
|
||||
|
||||
@@ -268,6 +268,7 @@ function getManualMemoizationReplacement(
|
||||
kind: 'Identifier',
|
||||
identifier: fn.identifier,
|
||||
effect: Effect.Unknown,
|
||||
abstractValue: null,
|
||||
reactive: false,
|
||||
loc,
|
||||
},
|
||||
@@ -420,6 +421,7 @@ export function dropManualMemoization(func: HIRFunction): void {
|
||||
kind: 'Identifier',
|
||||
identifier: fnPlace.identifier,
|
||||
effect: Effect.Unknown,
|
||||
abstractValue: null,
|
||||
reactive: false,
|
||||
loc: fnPlace.loc,
|
||||
};
|
||||
|
||||
+2
@@ -237,6 +237,7 @@ class Transform extends ReactiveFunctionTransform<State> {
|
||||
place: {
|
||||
kind: 'Identifier',
|
||||
effect: Effect.ConditionallyMutate,
|
||||
abstractValue: null,
|
||||
loc,
|
||||
reactive: true,
|
||||
identifier: earlyReturnValue.value,
|
||||
@@ -308,6 +309,7 @@ class Transform extends ReactiveFunctionTransform<State> {
|
||||
kind: 'Identifier',
|
||||
identifier: earlyReturnValue.value,
|
||||
effect: Effect.Capture,
|
||||
abstractValue: null,
|
||||
loc,
|
||||
reactive: true,
|
||||
},
|
||||
|
||||
@@ -191,6 +191,7 @@ class SSABuilder {
|
||||
const phi: Phi = {
|
||||
kind: 'Phi',
|
||||
id: newId,
|
||||
abstractValue: null,
|
||||
operands: predDefs,
|
||||
};
|
||||
|
||||
|
||||
+1
@@ -250,6 +250,7 @@ function validateInferredDep(
|
||||
identifier: dep.identifier,
|
||||
loc: GeneratedSource,
|
||||
effect: Effect.Read,
|
||||
abstractValue: null,
|
||||
reactive: false,
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user