Skip to content

Commit c0cdd1d

Browse files
committed
more strict assert
1 parent 0dbf650 commit c0cdd1d

File tree

158 files changed

+4262
-4209
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

158 files changed

+4262
-4209
lines changed

std/assembly/rt/tlsf.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,9 @@ function prepareBlock(root: Root, block: Block, size: usize): void {
373373
}
374374

375375
/** Adds more memory to the pool. */
376-
function addMemory(root: Root, start: usize, end: usize): bool {
377-
if (DEBUG) assert(start <= end || end == 0); // must be valid
376+
function addMemory(root: Root, start: usize, endU64: u64): bool {
377+
let end = <usize>endU64;
378+
if (DEBUG) assert(<u64>start <= endU64); // must be valid
378379
start = ((start + BLOCK_OVERHEAD + AL_MASK) & ~AL_MASK) - BLOCK_OVERHEAD;
379380
end &= ~AL_MASK;
380381

@@ -442,7 +443,7 @@ function growMemory(root: Root, size: usize): void {
442443
if (memory.grow(pagesNeeded) < 0) unreachable();
443444
}
444445
let pagesAfter = memory.size();
445-
addMemory(root, <usize>pagesBefore << 16, <usize>pagesAfter << 16);
446+
addMemory(root, <usize>pagesBefore << 16, <u64>pagesAfter << 16);
446447
}
447448

448449
/** Computes the size (excl. header) of a block. */
@@ -477,11 +478,11 @@ function initialize(): void {
477478
}
478479
let memStart = rootOffset + ROOT_SIZE;
479480
if (ASC_LOW_MEMORY_LIMIT) {
480-
const memEnd = <usize>ASC_LOW_MEMORY_LIMIT & ~AL_MASK;
481+
const memEnd = <u64>ASC_LOW_MEMORY_LIMIT & ~AL_MASK;
481482
if (memStart <= memEnd) addMemory(root, memStart, memEnd);
482483
else unreachable(); // low memory limit already exceeded
483484
} else {
484-
addMemory(root, memStart, memory.size() << 16);
485+
addMemory(root, memStart, <u64>memory.size() << 16);
485486
}
486487
ROOT = root;
487488
}

tests/compiler/bindings/esm.debug.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ async function instantiate(module, imports = {}) {
1818
// ~lib/bindings/dom/Math.E: f64
1919
Math.E
2020
),
21-
"Math.log": (
21+
"Math.log"(x) {
2222
// ~lib/bindings/dom/Math.log(f64) => f64
23-
Math.log
24-
),
23+
return Math.log(x);
24+
},
2525
"globalThis.globalThis": (
2626
// bindings/esm/immutableGlobalNested: ref_extern | null}
2727
globalThis.globalThis

tests/compiler/bindings/esm.debug.wat

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77
(type $i32_i32_i32_=>_none (func (param i32 i32 i32)))
88
(type $none_=>_i32 (func (result i32)))
99
(type $i32_i32_i32_i32_=>_none (func (param i32 i32 i32 i32)))
10-
(type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32)))
1110
(type $i32_i64_=>_none (func (param i32 i64)))
1211
(type $i32_i32_f64_f64_f64_f64_f64_=>_none (func (param i32 i32 f64 f64 f64 f64 f64)))
1312
(type $f64_=>_f64 (func (param f64) (result f64)))
1413
(type $i64_i64_=>_i64 (func (param i64 i64) (result i64)))
1514
(type $none_=>_i64 (func (result i64)))
15+
(type $i32_i32_i64_=>_i32 (func (param i32 i32 i64) (result i32)))
1616
(type $i32_f32_=>_none (func (param i32 f32)))
1717
(type $i32_f64_=>_none (func (param i32 f64)))
18+
(type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32)))
1819
(type $i32_i32_i64_=>_none (func (param i32 i32 i64)))
1920
(type $i32_i32_=>_f32 (func (param i32 i32) (result f32)))
2021
(import "env" "Math.E" (global $~lib/bindings/dom/Math.E f64))
@@ -1123,32 +1124,30 @@
11231124
local.get $slMap
11241125
i32.store $0 offset=4
11251126
)
1126-
(func $~lib/rt/tlsf/addMemory (param $root i32) (param $start i32) (param $end i32) (result i32)
1127-
(local $root|3 i32)
1127+
(func $~lib/rt/tlsf/addMemory (param $root i32) (param $start i32) (param $endU64 i64) (result i32)
1128+
(local $end i32)
1129+
(local $root|4 i32)
11281130
(local $tail i32)
11291131
(local $tailInfo i32)
11301132
(local $size i32)
11311133
(local $leftSize i32)
11321134
(local $left i32)
1133-
(local $root|9 i32)
1134-
(local $tail|10 i32)
1135+
(local $root|10 i32)
1136+
(local $tail|11 i32)
1137+
local.get $endU64
1138+
i32.wrap_i64
1139+
local.set $end
11351140
i32.const 1
11361141
drop
11371142
local.get $start
1138-
local.get $end
1139-
i32.le_u
1140-
if (result i32)
1141-
i32.const 1
1142-
else
1143-
local.get $end
1144-
i32.const 0
1145-
i32.eq
1146-
end
1143+
i64.extend_i32_u
1144+
local.get $endU64
1145+
i64.le_u
11471146
i32.eqz
11481147
if
11491148
i32.const 0
11501149
i32.const 672
1151-
i32.const 377
1150+
i32.const 378
11521151
i32.const 14
11531152
call $~lib/builtins/abort
11541153
unreachable
@@ -1173,8 +1172,8 @@
11731172
local.set $end
11741173
block $~lib/rt/tlsf/GETTAIL|inlined.0 (result i32)
11751174
local.get $root
1176-
local.set $root|3
1177-
local.get $root|3
1175+
local.set $root|4
1176+
local.get $root|4
11781177
i32.load $0 offset=1568
11791178
br $~lib/rt/tlsf/GETTAIL|inlined.0
11801179
end
@@ -1194,7 +1193,7 @@
11941193
if
11951194
i32.const 0
11961195
i32.const 672
1197-
i32.const 384
1196+
i32.const 385
11981197
i32.const 16
11991198
call $~lib/builtins/abort
12001199
unreachable
@@ -1227,7 +1226,7 @@
12271226
if
12281227
i32.const 0
12291228
i32.const 672
1230-
i32.const 397
1229+
i32.const 398
12311230
i32.const 5
12321231
call $~lib/builtins/abort
12331232
unreachable
@@ -1283,11 +1282,11 @@
12831282
i32.or
12841283
call $~lib/rt/common/BLOCK#set:mmInfo
12851284
local.get $root
1286-
local.set $root|9
1285+
local.set $root|10
12871286
local.get $tail
1288-
local.set $tail|10
1289-
local.get $root|9
1290-
local.get $tail|10
1287+
local.set $tail|11
1288+
local.get $root|10
1289+
local.get $tail|11
12911290
i32.store $0 offset=1568
12921291
local.get $root
12931292
local.get $left
@@ -1433,8 +1432,9 @@
14331432
local.get $root
14341433
local.get $memStart
14351434
memory.size $0
1436-
i32.const 16
1437-
i32.shl
1435+
i64.extend_i32_s
1436+
i64.const 16
1437+
i64.shl
14381438
call $~lib/rt/tlsf/addMemory
14391439
drop
14401440
local.get $root
@@ -1470,7 +1470,7 @@
14701470
if
14711471
i32.const 0
14721472
i32.const 672
1473-
i32.const 559
1473+
i32.const 560
14741474
i32.const 3
14751475
call $~lib/builtins/abort
14761476
unreachable
@@ -1799,7 +1799,7 @@
17991799
if
18001800
i32.const 336
18011801
i32.const 672
1802-
i32.const 458
1802+
i32.const 459
18031803
i32.const 29
18041804
call $~lib/builtins/abort
18051805
unreachable
@@ -2101,8 +2101,9 @@
21012101
i32.const 16
21022102
i32.shl
21032103
local.get $pagesAfter
2104-
i32.const 16
2105-
i32.shl
2104+
i64.extend_i32_s
2105+
i64.const 16
2106+
i64.shl
21062107
call $~lib/rt/tlsf/addMemory
21072108
drop
21082109
)
@@ -2242,7 +2243,7 @@
22422243
if
22432244
i32.const 0
22442245
i32.const 672
2245-
i32.const 496
2246+
i32.const 497
22462247
i32.const 16
22472248
call $~lib/builtins/abort
22482249
unreachable
@@ -2262,7 +2263,7 @@
22622263
if
22632264
i32.const 0
22642265
i32.const 672
2265-
i32.const 498
2266+
i32.const 499
22662267
i32.const 14
22672268
call $~lib/builtins/abort
22682269
unreachable

tests/compiler/bindings/esm.release.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ async function instantiate(module, imports = {}) {
1818
// ~lib/bindings/dom/Math.E: f64
1919
Math.E
2020
),
21-
"Math.log": (
21+
"Math.log"(x) {
2222
// ~lib/bindings/dom/Math.log(f64) => f64
23-
Math.log
24-
),
23+
return Math.log(x);
24+
},
2525
"globalThis.globalThis": (
26-
// bindings/esm/immutableGlobalNested: externref
26+
// bindings/esm/immutableGlobalNested: ref_extern | null}
2727
globalThis.globalThis
2828
),
2929
"Date.getTimezoneOffset"() {

tests/compiler/bindings/esm.release.wat

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
(module
22
(type $i32_i32_=>_i32 (func (param i32 i32) (result i32)))
33
(type $i32_=>_none (func (param i32)))
4-
(type $i32_i32_i32_=>_none (func (param i32 i32 i32)))
54
(type $i32_=>_i32 (func (param i32) (result i32)))
65
(type $none_=>_i32 (func (result i32)))
76
(type $none_=>_none (func))
7+
(type $i32_i32_i32_=>_none (func (param i32 i32 i32)))
88
(type $i32_i32_=>_none (func (param i32 i32)))
9+
(type $i32_i32_i64_=>_none (func (param i32 i32 i64)))
910
(type $i32_i32_f64_f64_f64_f64_f64_=>_none (func (param i32 i32 f64 f64 f64 f64 f64)))
1011
(type $f64_=>_f64 (func (param f64) (result f64)))
1112
(type $i64_i64_=>_i64 (func (param i64 i64) (result i64)))
1213
(type $none_=>_i64 (func (result i64)))
1314
(type $i32_i32_i32_i32_=>_none (func (param i32 i32 i32 i32)))
14-
(type $i32_i32_i64_=>_none (func (param i32 i32 i64)))
1515
(import "env" "Math.E" (global $~lib/bindings/dom/Math.E f64))
1616
(import "env" "trace" (func $~lib/builtins/trace (param i32 i32 f64 f64 f64 f64 f64)))
1717
(import "env" "console.log" (func $~lib/bindings/dom/console.log (param i32)))
@@ -731,20 +731,17 @@
731731
i32.or
732732
i32.store $0 offset=4
733733
)
734-
(func $~lib/rt/tlsf/addMemory (param $0 i32) (param $1 i32) (param $2 i32)
734+
(func $~lib/rt/tlsf/addMemory (param $0 i32) (param $1 i32) (param $2 i64)
735735
(local $3 i32)
736736
(local $4 i32)
737737
local.get $2
738-
i32.eqz
739738
local.get $1
740-
local.get $2
741-
i32.le_u
742-
i32.or
743-
i32.eqz
739+
i64.extend_i32_u
740+
i64.lt_u
744741
if
745742
i32.const 0
746743
i32.const 1696
747-
i32.const 377
744+
i32.const 378
748745
i32.const 14
749746
call $~lib/builtins/abort
750747
unreachable
@@ -769,7 +766,7 @@
769766
if
770767
i32.const 0
771768
i32.const 1696
772-
i32.const 384
769+
i32.const 385
773770
i32.const 16
774771
call $~lib/builtins/abort
775772
unreachable
@@ -797,18 +794,19 @@
797794
if
798795
i32.const 0
799796
i32.const 1696
800-
i32.const 397
797+
i32.const 398
801798
i32.const 5
802799
call $~lib/builtins/abort
803800
unreachable
804801
end
805802
end
806803
local.get $2
804+
i32.wrap_i64
807805
i32.const -16
808806
i32.and
809807
local.get $1
810808
i32.sub
811-
local.tee $2
809+
local.tee $4
812810
i32.const 20
813811
i32.lt_u
814812
if
@@ -818,10 +816,10 @@
818816
local.get $3
819817
i32.const 2
820818
i32.and
821-
local.get $2
819+
local.get $4
822820
i32.const 8
823821
i32.sub
824-
local.tee $2
822+
local.tee $3
825823
i32.const 1
826824
i32.or
827825
i32.or
@@ -835,13 +833,13 @@
835833
local.get $1
836834
i32.const 4
837835
i32.add
838-
local.get $2
836+
local.get $3
839837
i32.add
840-
local.tee $2
838+
local.tee $3
841839
i32.const 2
842840
i32.store $0
843841
local.get $0
844-
local.get $2
842+
local.get $3
845843
i32.store $0 offset=1568
846844
local.get $0
847845
local.get $1
@@ -920,8 +918,9 @@
920918
i32.const 35056
921919
i32.const 36628
922920
memory.size $0
923-
i32.const 16
924-
i32.shl
921+
i64.extend_i32_s
922+
i64.const 16
923+
i64.shl
925924
call $~lib/rt/tlsf/addMemory
926925
i32.const 35056
927926
global.set $~lib/rt/tlsf/ROOT
@@ -1162,7 +1161,7 @@
11621161
if
11631162
i32.const 0
11641163
i32.const 1696
1165-
i32.const 559
1164+
i32.const 560
11661165
i32.const 3
11671166
call $~lib/builtins/abort
11681167
unreachable
@@ -1397,7 +1396,7 @@
13971396
if
13981397
i32.const 1360
13991398
i32.const 1696
1400-
i32.const 458
1399+
i32.const 459
14011400
i32.const 29
14021401
call $~lib/builtins/abort
14031402
unreachable
@@ -1476,8 +1475,9 @@
14761475
i32.const 16
14771476
i32.shl
14781477
memory.size $0
1479-
i32.const 16
1480-
i32.shl
1478+
i64.extend_i32_s
1479+
i64.const 16
1480+
i64.shl
14811481
call $~lib/rt/tlsf/addMemory
14821482
local.get $4
14831483
local.get $5
@@ -1487,7 +1487,7 @@
14871487
if
14881488
i32.const 0
14891489
i32.const 1696
1490-
i32.const 496
1490+
i32.const 497
14911491
i32.const 16
14921492
call $~lib/builtins/abort
14931493
unreachable
@@ -1502,7 +1502,7 @@
15021502
if
15031503
i32.const 0
15041504
i32.const 1696
1505-
i32.const 498
1505+
i32.const 499
15061506
i32.const 14
15071507
call $~lib/builtins/abort
15081508
unreachable

0 commit comments

Comments
 (0)