Commit 313ce8c
authored
Fix memory/table segment checks in memory.init/table.init (#3081)
According to the wasm core spec, the checks for the table segments in
`table.init` opcode are similar to the checks for `memory.init` opcode:
- The size of a passive segment is shrunk to zero after `data.drop`
(or `elem.drop`) opcode is executed, and the segment can be used to do
`memory.init` (or `table.init`) again
- The `memory.init` only traps when `s+n > len(data.data)` or `d+n > len(mem.data)`
and `table.init` only traps when `s+n > len(elem.elem)` or `d+n > len(tab.elem)`
- The active segment can also be used to do `memory.init` (or `table.init`),
while it behaves like a dropped passive segment
https://github.com/WebAssembly/bulk-memory-operations/blob/master/proposals/bulk-memory-operations/Overview.md
```
Segments can also be shrunk to size zero by using the following new instructions:
- data.drop: discard the data in an data segment
- elem.drop: discard the data in an element segment
An active segment is equivalent to a passive segment, but with an implicit
memory.init followed by a data.drop (or table.init followed by a elem.drop)
that is prepended to the module's start function.
```
ps.
https://webassembly.github.io/spec/core/bikeshed/#-hrefsyntax-instr-memorymathsfmemoryinitx%E2%91%A0
https://webassembly.github.io/spec/core/bikeshed/#-hrefsyntax-instr-tablemathsftableinitxy%E2%91%A0
#30201 parent 6daaf6d commit 313ce8c
File tree
5 files changed
+73
-86
lines changed- core/iwasm
- aot
- fast-jit/fe
- interpreter
5 files changed
+73
-86
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1179 | 1179 | | |
1180 | 1180 | | |
1181 | 1181 | | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
1182 | 1186 | | |
1183 | 1187 | | |
1184 | 1188 | | |
| |||
1190 | 1194 | | |
1191 | 1195 | | |
1192 | 1196 | | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
1193 | 1201 | | |
1194 | 1202 | | |
1195 | 1203 | | |
| |||
2621 | 2629 | | |
2622 | 2630 | | |
2623 | 2631 | | |
| 2632 | + | |
2624 | 2633 | | |
2625 | 2634 | | |
2626 | 2635 | | |
| |||
2629 | 2638 | | |
2630 | 2639 | | |
2631 | 2640 | | |
2632 | | - | |
2633 | | - | |
2634 | | - | |
2635 | | - | |
2636 | | - | |
2637 | | - | |
2638 | | - | |
2639 | | - | |
2640 | | - | |
2641 | | - | |
2642 | | - | |
| 2641 | + | |
2643 | 2642 | | |
2644 | 2643 | | |
| 2644 | + | |
| 2645 | + | |
| 2646 | + | |
| 2647 | + | |
| 2648 | + | |
| 2649 | + | |
| 2650 | + | |
2645 | 2651 | | |
2646 | 2652 | | |
2647 | 2653 | | |
2648 | 2654 | | |
2649 | | - | |
2650 | | - | |
| 2655 | + | |
2651 | 2656 | | |
2652 | 2657 | | |
2653 | 2658 | | |
2654 | 2659 | | |
2655 | 2660 | | |
2656 | 2661 | | |
2657 | | - | |
| 2662 | + | |
2658 | 2663 | | |
2659 | 2664 | | |
2660 | 2665 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
91 | | - | |
| 91 | + | |
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
97 | | - | |
| 96 | + | |
| 97 | + | |
98 | 98 | | |
99 | | - | |
100 | | - | |
101 | | - | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
102 | 106 | | |
103 | 107 | | |
104 | 108 | | |
| |||
109 | 113 | | |
110 | 114 | | |
111 | 115 | | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | 116 | | |
119 | 117 | | |
120 | 118 | | |
121 | | - | |
122 | | - | |
| 119 | + | |
123 | 120 | | |
124 | 121 | | |
125 | 122 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3262 | 3262 | | |
3263 | 3263 | | |
3264 | 3264 | | |
| 3265 | + | |
3265 | 3266 | | |
3266 | 3267 | | |
3267 | 3268 | | |
| |||
3275 | 3276 | | |
3276 | 3277 | | |
3277 | 3278 | | |
3278 | | - | |
3279 | | - | |
| 3279 | + | |
| 3280 | + | |
| 3281 | + | |
| 3282 | + | |
3280 | 3283 | | |
3281 | | - | |
| 3284 | + | |
| 3285 | + | |
| 3286 | + | |
| 3287 | + | |
| 3288 | + | |
| 3289 | + | |
| 3290 | + | |
3282 | 3291 | | |
3283 | 3292 | | |
3284 | 3293 | | |
| |||
3290 | 3299 | | |
3291 | 3300 | | |
3292 | 3301 | | |
3293 | | - | |
3294 | | - | |
3295 | | - | |
3296 | | - | |
3297 | | - | |
3298 | | - | |
3299 | | - | |
3300 | | - | |
3301 | | - | |
3302 | | - | |
3303 | | - | |
3304 | | - | |
3305 | | - | |
3306 | | - | |
3307 | | - | |
3308 | 3302 | | |
3309 | 3303 | | |
3310 | 3304 | | |
3311 | 3305 | | |
3312 | 3306 | | |
3313 | | - | |
3314 | | - | |
3315 | | - | |
3316 | | - | |
| 3307 | + | |
3317 | 3308 | | |
3318 | 3309 | | |
3319 | 3310 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3023 | 3023 | | |
3024 | 3024 | | |
3025 | 3025 | | |
3026 | | - | |
3027 | 3026 | | |
3028 | 3027 | | |
3029 | 3028 | | |
| |||
3106 | 3105 | | |
3107 | 3106 | | |
3108 | 3107 | | |
| 3108 | + | |
3109 | 3109 | | |
3110 | 3110 | | |
3111 | 3111 | | |
| |||
3119 | 3119 | | |
3120 | 3120 | | |
3121 | 3121 | | |
3122 | | - | |
3123 | | - | |
| 3122 | + | |
| 3123 | + | |
| 3124 | + | |
| 3125 | + | |
| 3126 | + | |
| 3127 | + | |
| 3128 | + | |
3124 | 3129 | | |
3125 | | - | |
| 3130 | + | |
| 3131 | + | |
| 3132 | + | |
| 3133 | + | |
3126 | 3134 | | |
3127 | 3135 | | |
3128 | 3136 | | |
| |||
3134 | 3142 | | |
3135 | 3143 | | |
3136 | 3144 | | |
3137 | | - | |
3138 | | - | |
3139 | | - | |
3140 | | - | |
3141 | | - | |
3142 | | - | |
3143 | | - | |
3144 | | - | |
3145 | | - | |
3146 | | - | |
3147 | | - | |
3148 | | - | |
3149 | | - | |
3150 | | - | |
3151 | | - | |
3152 | 3145 | | |
3153 | 3146 | | |
3154 | 3147 | | |
3155 | 3148 | | |
3156 | 3149 | | |
3157 | | - | |
3158 | | - | |
3159 | | - | |
3160 | | - | |
| 3150 | + | |
3161 | 3151 | | |
3162 | 3152 | | |
3163 | 3153 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1670 | 1670 | | |
1671 | 1671 | | |
1672 | 1672 | | |
| 1673 | + | |
| 1674 | + | |
| 1675 | + | |
| 1676 | + | |
1673 | 1677 | | |
1674 | 1678 | | |
1675 | 1679 | | |
| |||
1682 | 1686 | | |
1683 | 1687 | | |
1684 | 1688 | | |
| 1689 | + | |
| 1690 | + | |
| 1691 | + | |
| 1692 | + | |
1685 | 1693 | | |
1686 | 1694 | | |
1687 | 1695 | | |
| |||
3278 | 3286 | | |
3279 | 3287 | | |
3280 | 3288 | | |
| 3289 | + | |
3281 | 3290 | | |
3282 | 3291 | | |
3283 | 3292 | | |
| |||
3287 | 3296 | | |
3288 | 3297 | | |
3289 | 3298 | | |
3290 | | - | |
3291 | | - | |
3292 | | - | |
3293 | | - | |
3294 | | - | |
3295 | | - | |
3296 | | - | |
3297 | | - | |
| 3299 | + | |
| 3300 | + | |
| 3301 | + | |
| 3302 | + | |
3298 | 3303 | | |
3299 | 3304 | | |
3300 | | - | |
| 3305 | + | |
| 3306 | + | |
3301 | 3307 | | |
3302 | 3308 | | |
3303 | 3309 | | |
3304 | 3310 | | |
3305 | | - | |
3306 | | - | |
| 3311 | + | |
3307 | 3312 | | |
3308 | 3313 | | |
3309 | 3314 | | |
3310 | 3315 | | |
3311 | 3316 | | |
3312 | 3317 | | |
3313 | | - | |
3314 | | - | |
| 3318 | + | |
3315 | 3319 | | |
3316 | 3320 | | |
3317 | 3321 | | |
| |||
0 commit comments