Skip to content

Commit b3cffa3

Browse files
authored
Remove unchecked indexed set on normal arrays (#2586)
1 parent 378659a commit b3cffa3

19 files changed

+4636
-2521
lines changed

Diff for: std/assembly/array.ts

-4
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,6 @@ export class Array<T> {
131131
ensureCapacity(changetype<usize>(this), index + 1, alignof<T>());
132132
this.length_ = index + 1;
133133
}
134-
this.__uset(index, value);
135-
}
136-
137-
@unsafe @operator("{}=") private __uset(index: i32, value: T): void {
138134
store<T>(this.dataStart + (<usize>index << alignof<T>()), value);
139135
if (isManaged<T>()) {
140136
__link(changetype<usize>(this), changetype<usize>(value), true);

Diff for: tests/compiler/bindings/esm.debug.wat

+7-13
Original file line numberDiff line numberDiff line change
@@ -2840,18 +2840,6 @@
28402840
i32.store $0 offset=8
28412841
end
28422842
)
2843-
(func $~lib/array/Array<i32>#__uset (type $i32_i32_i32_=>_none) (param $this i32) (param $index i32) (param $value i32)
2844-
local.get $this
2845-
call $~lib/array/Array<i32>#get:dataStart
2846-
local.get $index
2847-
i32.const 2
2848-
i32.shl
2849-
i32.add
2850-
local.get $value
2851-
i32.store $0
2852-
i32.const 0
2853-
drop
2854-
)
28552843
(func $~lib/array/Array<i32>#__set (type $i32_i32_i32_=>_none) (param $this i32) (param $index i32) (param $value i32)
28562844
local.get $index
28572845
local.get $this
@@ -2883,9 +2871,15 @@
28832871
call $~lib/array/Array<i32>#set:length_
28842872
end
28852873
local.get $this
2874+
call $~lib/array/Array<i32>#get:dataStart
28862875
local.get $index
2876+
i32.const 2
2877+
i32.shl
2878+
i32.add
28872879
local.get $value
2888-
call $~lib/array/Array<i32>#__uset
2880+
i32.store $0
2881+
i32.const 0
2882+
drop
28892883
)
28902884
(func $bindings/esm/PlainObject#set:a (type $i32_i32_=>_none) (param $this i32) (param $a i32)
28912885
local.get $this

Diff for: tests/compiler/bindings/raw.debug.wat

+7-13
Original file line numberDiff line numberDiff line change
@@ -2843,18 +2843,6 @@
28432843
i32.store $0 offset=8
28442844
end
28452845
)
2846-
(func $~lib/array/Array<i32>#__uset (type $i32_i32_i32_=>_none) (param $this i32) (param $index i32) (param $value i32)
2847-
local.get $this
2848-
call $~lib/array/Array<i32>#get:dataStart
2849-
local.get $index
2850-
i32.const 2
2851-
i32.shl
2852-
i32.add
2853-
local.get $value
2854-
i32.store $0
2855-
i32.const 0
2856-
drop
2857-
)
28582846
(func $~lib/array/Array<i32>#__set (type $i32_i32_i32_=>_none) (param $this i32) (param $index i32) (param $value i32)
28592847
local.get $index
28602848
local.get $this
@@ -2886,9 +2874,15 @@
28862874
call $~lib/array/Array<i32>#set:length_
28872875
end
28882876
local.get $this
2877+
call $~lib/array/Array<i32>#get:dataStart
28892878
local.get $index
2879+
i32.const 2
2880+
i32.shl
2881+
i32.add
28902882
local.get $value
2891-
call $~lib/array/Array<i32>#__uset
2883+
i32.store $0
2884+
i32.const 0
2885+
drop
28922886
)
28932887
(func $bindings/esm/PlainObject#set:a (type $i32_i32_=>_none) (param $this i32) (param $a i32)
28942888
local.get $this

0 commit comments

Comments
 (0)