Skip to content

Commit

Permalink
Update on "[compiler] Add lowerContextAccess pass"
Browse files Browse the repository at this point in the history
*This is only for internal profiling, not intended to ship.*

This pass is intended to be used with #30407.

This pass synthesizes selector functions by collecting immediately
destructured context acesses. We bailout for other types of context
access.

This pass lowers context access to use a selector function by passing
the synthesized selector function as the second argument.

[ghstack-poisoned]
  • Loading branch information
gsathya committed Aug 6, 2024
2 parents 74cbfc7 + 542e0df commit 08720a3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1205,7 +1205,7 @@ export type ValidIdentifierName = string & {
[opaqueValidIdentifierName]: 'ValidIdentifierName';
};

export function makeTemporary(
export function makeTemporaryIdentifier(
id: IdentifierId,
loc: SourceLocation,
): Identifier {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
makeBlockId,
makeIdentifierName,
makeInstructionId,
makeTemporary,
makeTemporaryIdentifier,
makeType,
} from './HIR';
import {printInstruction} from './PrintHIR';
Expand Down Expand Up @@ -183,7 +183,7 @@ export default class HIRBuilder {

makeTemporary(loc: SourceLocation): Identifier {
const id = this.nextIdentifierId;
return makeTemporary(id, loc);
return makeTemporaryIdentifier(id, loc);
}

#resolveBabelBinding(
Expand Down Expand Up @@ -891,14 +891,7 @@ export function createTemporaryPlace(
): Place {
return {
kind: 'Identifier',
identifier: {
id: env.nextIdentifierId,
mutableRange: {start: makeInstructionId(0), end: makeInstructionId(0)},
name: null,
scope: null,
type: makeType(),
loc,
},
identifier: makeTemporaryIdentifier(env.nextIdentifierId, loc),
reactive: false,
effect: Effect.Unknown,
loc: GeneratedSource,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
isUseContextHookType,
makeBlockId,
makeInstructionId,
makeTemporary,
markInstructionIds,
promoteTemporary,
reversePostorderBlocks,
Expand Down Expand Up @@ -236,13 +235,7 @@ function emitSelectorFn(env: Environment, keys: Array<string>): Instruction {
type: 'ArrowFunctionExpression',
loc: GeneratedSource,
},
lvalue: {
kind: 'Identifier',
identifier: makeTemporary(env.nextIdentifierId, GeneratedSource),
effect: Effect.Unknown,
reactive: false,
loc: GeneratedSource,
},
lvalue: createTemporaryPlace(env, GeneratedSource),
loc: GeneratedSource,
};
return fnInstr;
Expand All @@ -254,13 +247,7 @@ function emitArrayInstr(elements: Array<Place>, env: Environment): Instruction {
elements,
loc: GeneratedSource,
};
const arrayLvalue: Place = {
kind: 'Identifier',
identifier: makeTemporary(env.nextIdentifierId, GeneratedSource),
effect: Effect.Unknown,
reactive: false,
loc: GeneratedSource,
};
const arrayLvalue: Place = createTemporaryPlace(env, GeneratedSource);
const arrayInstr: Instruction = {
id: makeInstructionId(0),
value: array,
Expand Down

0 comments on commit 08720a3

Please sign in to comment.