Skip to content

Commit

Permalink
Push to scopes after setting fields to avoid deopt
Browse files Browse the repository at this point in the history
  • Loading branch information
jridgewell committed Jun 28, 2024
1 parent 154656b commit b3bb7f0
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/scopes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,10 @@ export function decodeOriginalScopes(input: string): OriginalScope[] {
const kind = decodeInteger(reader, 0);
const fields = decodeInteger(reader, 0);
const hasName = fields & 0b0001;

const scope: OriginalScope = (
hasName ? [line, column, 0, 0, kind, decodeInteger(reader, 0)] : [line, column, 0, 0, kind]
) as OriginalScope;
scopes.push(scope);
stack.push(scope);

let vars: Var[] = EMPTY;
if (hasMoreVlq(reader, length)) {
Expand All @@ -68,6 +67,9 @@ export function decodeOriginalScopes(input: string): OriginalScope[] {
} while (hasMoreVlq(reader, length));
}
scope.vars = vars;

scopes.push(scope);
stack.push(scope);
}

return scopes;
Expand Down Expand Up @@ -147,19 +149,19 @@ export function decodeGeneratedRanges(input: string): GeneratedRange[] {
genColumn = decodeInteger(reader, genColumn);

if (!hasMoreVlq(reader, semi)) {
const range = stack.pop()!;
range[2] = genLine;
range[3] = genColumn;
const last = stack.pop()!;
last[2] = genLine;
last[3] = genColumn;
continue;
}

const fields = decodeInteger(reader, 0);
const hasDefinition = fields & 0b0001;
const hasCallsite = fields & 0b0010;
const hasScope = fields & 0b0100;

let callsite: CallSite | null = null;
let bindings: Binding[] = EMPTY;

let range: GeneratedRange;
if (hasDefinition) {
const defSourcesIndex = decodeInteger(reader, definitionSourcesIndex);
Expand Down

0 comments on commit b3bb7f0

Please sign in to comment.