Skip to content

fix: remove unused tmp local in array literal generated code #2917

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
12 changes: 0 additions & 12 deletions src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8189,11 +8189,9 @@ export class Compiler extends DiagnosticEmitter {
let arrayInstance = <Class>element;
let arrayType = arrayInstance.type;
let elementType = arrayInstance.getTypeArgumentsTo(program.arrayPrototype)![0];
let arrayBufferInstance = assert(program.arrayBufferInstance);

// block those here so compiling expressions doesn't conflict
let tempThis = flow.getTempLocal(this.options.usizeType);
let tempDataStart = flow.getTempLocal(arrayBufferInstance.type);

// compile value expressions and find out whether all are constant
let expressions = expression.elementExpressions;
Expand Down Expand Up @@ -8269,16 +8267,6 @@ export class Compiler extends DiagnosticEmitter {
let dataStartProperty = (<PropertyPrototype>dataStartMember).instance;
if (!dataStartProperty) return module.unreachable();
assert(dataStartProperty.isField && dataStartProperty.memoryOffset >= 0);
stmts.push(
module.local_set(tempDataStart.index,
module.load(arrayType.byteSize, false,
module.local_get(tempThis.index, arrayTypeRef),
arrayTypeRef,
dataStartProperty.memoryOffset
),
true // ArrayBuffer
)
);
for (let i = 0; i < length; ++i) {
// this[i] = value
stmts.push(
Expand Down
2 changes: 0 additions & 2 deletions tests/compiler/bindings/noExportRuntime.debug.wat
Original file line number Diff line number Diff line change
Expand Up @@ -2361,8 +2361,6 @@
(func $start:bindings/noExportRuntime
(local $0 i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
memory.size
i32.const 16
i32.shl
Expand Down
Loading
Loading