Skip to content

[compiler] Sketch of new InferReferenceEffects equivalent #33185

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: gh/josephsavona/89/base
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ export function lower(
loc: func.node.loc ?? GeneratedSource,
env,
effects: null,
aliasingEffects: null,
directives,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ export type HIRFunction = {
returnType: Type;
context: Array<Place>;
effects: Array<FunctionEffect> | null;
aliasingEffects: Array<AliasingEffect> | null;
body: HIR;
generator: boolean;
async: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,59 @@ export type FunctionSignature = {
impure?: boolean;

canonicalName?: string;

aliasing?: AliasingSignature;
};

export type LifetimeId = number;
export type AliasingSignature = {
receiver: LifetimeId;
params: Array<LifetimeId> | null;
restParam: LifetimeId;
returns: LifetimeId;
effects: Array<AliasingSignatureEffect>;
};

export type AliasingSignatureEffect =
/**
* Freezes the operand if not already frozen
*/
| {kind: 'Freeze'; place: LifetimeId}
/**
* Known mutation of a value, which may effect that value or values that it contains.
* This is rare!
*/
| {kind: 'MutateTransitive'; place: LifetimeId}
/**
* Known mutation of a specific value, targeting only that specific value but not
* values that it contains.
*
* Example: `array.push(item)` mutates the array but does not mutate items stored in the array.
*/
| {kind: 'MutateLocal'; place: LifetimeId}
/**
* Possible mutation of a specific value
*/
| {kind: 'ConditionallyMutate'; place: LifetimeId}
/**
* Direct aliasing of one identifier by another identifier
* Examples: `x = y` (from y -> to x) or phis (from operand -> to phi)
*/
| {kind: 'Alias'; from: LifetimeId; to: LifetimeId}
/**
* Direct aliasing of an identifier (or a sub-path), or storing a value/sub-path
* into a part of another object.
*
* One of from.path and/or to.path must be non-null (else this is equivalent to Alias)
*/
| {
kind: 'Capture';
from: {place: LifetimeId; path: '*' | null};
to: {place: LifetimeId; path: '*' | null};
}
// Known mutation of a global
| {kind: 'MutateGlobal'; place: LifetimeId};

/*
* Shape of an {@link FunctionType} if {@link ObjectShape.functionType} is present,
* or {@link ObjectType} otherwise.
Expand Down
Loading
Loading