Compare commits

...

5 Commits

Author SHA1 Message Date
Mike Vitousek
5d6702bffc Update base for Update on "[compiler] Initialize abstract values of places in InferReferenceEffects"
Test Plan:
In this diff, we now populate the abstractValue field of places during the InferReferenceEffects pass. The value we populate it with is the same value that we use internally in this pass, but it now will remain accessible to downstream phases as part of the Place.

For phis specifically, we need to do a bit of extra work to compute the appropriate value for the phi, since InferReferenceEffects currently doesn't need to infer a value for phis themselves, only values downstream of them. However, the value we compute should correspond to the value available downstream of the phi.

This changes the error message for one todo test case, because we now are querying for the valueKind earlier in the pass, and hitting an invariant violation as a result of that rather than a later invariant violation.

[ghstack-poisoned]
2024-09-16 16:26:18 -07:00
Mike Vitousek
e0e3e04639 Update base for Update on "[compiler] Initialize abstract values of places in InferReferenceEffects"
Test Plan:
In this diff, we now populate the abstractValue field of places during the InferReferenceEffects pass. The value we populate it with is the same value that we use internally in this pass, but it now will remain accessible to downstream phases as part of the Place.

For phis specifically, we need to do a bit of extra work to compute the appropriate value for the phi, since InferReferenceEffects currently doesn't need to infer a value for phis themselves, only values downstream of them. However, the value we compute should correspond to the value available downstream of the phi.

This changes the error message for one todo test case, because we now are querying for the valueKind earlier in the pass, and hitting an invariant violation as a result of that rather than a later invariant violation.

[ghstack-poisoned]
2024-09-16 15:49:43 -07:00
Mike Vitousek
8ad9d82179 Update base for Update on "[compiler] Initialize abstract values of places in InferReferenceEffects"
Test Plan:
In this diff, we now populate the abstractValue field of places during the InferReferenceEffects pass. The value we populate it with is the same value that we use internally in this pass, but it now will remain accessible to downstream phases as part of the Place.

For phis specifically, we need to do a bit of extra work to compute the appropriate value for the phi, since InferReferenceEffects currently doesn't need to infer a value for phis themselves, only values downstream of them. However, the value we compute should correspond to the value available downstream of the phi.

This changes the error message for one todo test case, because we now are querying for the valueKind earlier in the pass, and hitting an invariant violation as a result of that rather than a later invariant violation.

[ghstack-poisoned]
2024-09-16 13:16:10 -07:00
Mike Vitousek
bbc7deabdc Update base for Update on "[compiler] Initialize abstract values of places in InferReferenceEffects"
Test Plan:
In this diff, we now populate the abstractValue field of places during the InferReferenceEffects pass. The value we populate it with is the same value that we use internally in this pass, but it now will remain accessible to downstream phases as part of the Place.

For phis specifically, we need to do a bit of extra work to compute the appropriate value for the phi, since InferReferenceEffects currently doesn't need to infer a value for phis themselves, only values downstream of them. However, the value we compute should correspond to the value available downstream of the phi.

This changes the error message for one todo test case, because we now are querying for the valueKind earlier in the pass, and hitting an invariant violation as a result of that rather than a later invariant violation.

[ghstack-poisoned]
2024-09-16 11:09:08 -07:00
Mike Vitousek
6a77fd2ff7 [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-poisoned]
2024-09-16 10:54:44 -07:00
9 changed files with 23 additions and 0 deletions

View File

@@ -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,
};

View File

@@ -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;
};

View File

@@ -895,6 +895,7 @@ export function createTemporaryPlace(
kind: 'Identifier',
identifier: makeTemporaryIdentifier(env.nextIdentifierId, loc),
reactive: false,
abstractValue: null,
effect: Effect.Unknown,
loc: GeneratedSource,
};

View File

@@ -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,
},

View File

@@ -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),

View File

@@ -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,
};

View File

@@ -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,
},

View File

@@ -191,6 +191,7 @@ class SSABuilder {
const phi: Phi = {
kind: 'Phi',
id: newId,
abstractValue: null,
operands: predDefs,
};

View File

@@ -250,6 +250,7 @@ function validateInferredDep(
identifier: dep.identifier,
loc: GeneratedSource,
effect: Effect.Read,
abstractValue: null,
reactive: false,
},
},