Skip to content

Fix incorrect loads when setting Array#length #923

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

Merged
merged 1 commit into from
Oct 22, 2019
Merged
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
5 changes: 3 additions & 2 deletions std/assembly/array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ export class Array<T> extends ArrayBufferView {
var oldLength = this.length_;
if (isManaged<T>()) {
if (oldLength > newLength) { // release no longer used refs
let cur = (<usize>newLength << alignof<T>());
let end = (<usize>oldLength << alignof<T>());
let dataStart = this.dataStart;
let cur = dataStart + (<usize>newLength << alignof<T>());
let end = dataStart + (<usize>oldLength << alignof<T>());
do __release(load<usize>(cur));
while ((cur += sizeof<T>()) < end);
} else {
Expand Down
6 changes: 3 additions & 3 deletions tests/compiler/assert-nonnull.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
if
i32.const 24
i32.const 80
i32.const 92
i32.const 93
i32.const 41
call $~lib/builtins/abort
unreachable
Expand All @@ -76,7 +76,7 @@
if
i32.const 128
i32.const 80
i32.const 96
i32.const 97
i32.const 39
call $~lib/builtins/abort
unreachable
Expand All @@ -100,7 +100,7 @@
if
i32.const 24
i32.const 80
i32.const 92
i32.const 93
i32.const 41
call $~lib/builtins/abort
unreachable
Expand Down
6 changes: 3 additions & 3 deletions tests/compiler/assert-nonnull.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
if
i32.const 24
i32.const 80
i32.const 92
i32.const 93
i32.const 41
call $~lib/builtins/abort
unreachable
Expand All @@ -123,7 +123,7 @@
call $~lib/rt/stub/__release
i32.const 128
i32.const 80
i32.const 96
i32.const 97
i32.const 39
call $~lib/builtins/abort
unreachable
Expand Down Expand Up @@ -168,7 +168,7 @@
if
i32.const 24
i32.const 80
i32.const 92
i32.const 93
i32.const 41
call $~lib/builtins/abort
unreachable
Expand Down
2 changes: 1 addition & 1 deletion tests/compiler/resolve-access.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@
if
i32.const 48
i32.const 104
i32.const 92
i32.const 93
i32.const 41
call $~lib/builtins/abort
unreachable
Expand Down
2 changes: 1 addition & 1 deletion tests/compiler/resolve-access.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -1449,7 +1449,7 @@
if
i32.const 48
i32.const 104
i32.const 92
i32.const 93
i32.const 41
call $~lib/builtins/abort
unreachable
Expand Down
2 changes: 1 addition & 1 deletion tests/compiler/retain-release-sanity.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -2298,7 +2298,7 @@
if
i32.const 424
i32.const 376
i32.const 270
i32.const 271
i32.const 20
call $~lib/builtins/abort
unreachable
Expand Down
2 changes: 1 addition & 1 deletion tests/compiler/retain-release-sanity.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -3909,7 +3909,7 @@
if
i32.const 424
i32.const 376
i32.const 270
i32.const 271
i32.const 20
call $~lib/builtins/abort
unreachable
Expand Down
6 changes: 3 additions & 3 deletions tests/compiler/std/array-access.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
if
i32.const 24
i32.const 80
i32.const 92
i32.const 93
i32.const 41
call $~lib/builtins/abort
unreachable
Expand All @@ -42,7 +42,7 @@
if
i32.const 128
i32.const 80
i32.const 96
i32.const 97
i32.const 39
call $~lib/builtins/abort
unreachable
Expand All @@ -57,7 +57,7 @@
if
i32.const 24
i32.const 80
i32.const 92
i32.const 93
i32.const 41
call $~lib/builtins/abort
unreachable
Expand Down
14 changes: 7 additions & 7 deletions tests/compiler/std/array-access.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
if
i32.const 24
i32.const 80
i32.const 92
i32.const 93
i32.const 41
call $~lib/builtins/abort
unreachable
Expand All @@ -63,7 +63,7 @@
call $~lib/rt/stub/__release
i32.const 128
i32.const 80
i32.const 96
i32.const 97
i32.const 39
call $~lib/builtins/abort
unreachable
Expand All @@ -88,7 +88,7 @@
if
i32.const 24
i32.const 80
i32.const 92
i32.const 93
i32.const 41
call $~lib/builtins/abort
unreachable
Expand Down Expand Up @@ -137,7 +137,7 @@
if
i32.const 24
i32.const 80
i32.const 92
i32.const 93
i32.const 41
call $~lib/builtins/abort
unreachable
Expand All @@ -153,7 +153,7 @@
call $~lib/rt/stub/__release
i32.const 128
i32.const 80
i32.const 96
i32.const 97
i32.const 39
call $~lib/builtins/abort
unreachable
Expand Down Expand Up @@ -420,7 +420,7 @@
if
i32.const 24
i32.const 80
i32.const 92
i32.const 93
i32.const 41
call $~lib/builtins/abort
unreachable
Expand All @@ -436,7 +436,7 @@
call $~lib/rt/stub/__release
i32.const 128
i32.const 80
i32.const 96
i32.const 97
i32.const 39
call $~lib/builtins/abort
unreachable
Expand Down
4 changes: 2 additions & 2 deletions tests/compiler/std/array-literal.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
if
i32.const 136
i32.const 192
i32.const 92
i32.const 93
i32.const 41
call $~lib/builtins/abort
unreachable
Expand All @@ -66,7 +66,7 @@
if
i32.const 136
i32.const 192
i32.const 92
i32.const 93
i32.const 41
call $~lib/builtins/abort
unreachable
Expand Down
4 changes: 2 additions & 2 deletions tests/compiler/std/array-literal.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
if
i32.const 136
i32.const 192
i32.const 92
i32.const 93
i32.const 41
call $~lib/builtins/abort
unreachable
Expand Down Expand Up @@ -104,7 +104,7 @@
if
i32.const 136
i32.const 192
i32.const 92
i32.const 93
i32.const 41
call $~lib/builtins/abort
unreachable
Expand Down
Loading