Skip to content

Commit da77630

Browse files
authored
fix: remove unused tmp local in array literal generated code (#2917)
1 parent 91976df commit da77630

26 files changed

+11305
-11898
lines changed

src/compiler.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8189,11 +8189,9 @@ export class Compiler extends DiagnosticEmitter {
81898189
let arrayInstance = <Class>element;
81908190
let arrayType = arrayInstance.type;
81918191
let elementType = arrayInstance.getTypeArgumentsTo(program.arrayPrototype)![0];
8192-
let arrayBufferInstance = assert(program.arrayBufferInstance);
81938192

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

81988196
// compile value expressions and find out whether all are constant
81998197
let expressions = expression.elementExpressions;
@@ -8269,16 +8267,6 @@ export class Compiler extends DiagnosticEmitter {
82698267
let dataStartProperty = (<PropertyPrototype>dataStartMember).instance;
82708268
if (!dataStartProperty) return module.unreachable();
82718269
assert(dataStartProperty.isField && dataStartProperty.memoryOffset >= 0);
8272-
stmts.push(
8273-
module.local_set(tempDataStart.index,
8274-
module.load(arrayType.byteSize, false,
8275-
module.local_get(tempThis.index, arrayTypeRef),
8276-
arrayTypeRef,
8277-
dataStartProperty.memoryOffset
8278-
),
8279-
true // ArrayBuffer
8280-
)
8281-
);
82828270
for (let i = 0; i < length; ++i) {
82838271
// this[i] = value
82848272
stmts.push(

tests/compiler/bindings/noExportRuntime.debug.wat

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2361,8 +2361,6 @@
23612361
(func $start:bindings/noExportRuntime
23622362
(local $0 i32)
23632363
(local $1 i32)
2364-
(local $2 i32)
2365-
(local $3 i32)
23662364
memory.size
23672365
i32.const 16
23682366
i32.shl

0 commit comments

Comments
 (0)