|
@@ -544,9 +544,9 @@ wasm_interp_get_frame_ref(WASMInterpFrame *frame)
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
#if WASM_ENABLE_MEMORY64 != 0
|
|
#if WASM_ENABLE_MEMORY64 != 0
|
|
|
-#define PUSH_MEM_OFFSET(value) \
|
|
|
|
|
|
|
+#define COND_PUSH_TEMPLATE(cond, value) \
|
|
|
do { \
|
|
do { \
|
|
|
- if (is_memory64) { \
|
|
|
|
|
|
|
+ if (cond) { \
|
|
|
PUT_I64_TO_ADDR(frame_sp, value); \
|
|
PUT_I64_TO_ADDR(frame_sp, value); \
|
|
|
frame_sp += 2; \
|
|
frame_sp += 2; \
|
|
|
} \
|
|
} \
|
|
@@ -554,8 +554,11 @@ wasm_interp_get_frame_ref(WASMInterpFrame *frame)
|
|
|
*(int32 *)frame_sp++ = (int32)(value); \
|
|
*(int32 *)frame_sp++ = (int32)(value); \
|
|
|
} \
|
|
} \
|
|
|
} while (0)
|
|
} while (0)
|
|
|
|
|
+#define PUSH_MEM_OFFSET(value) COND_PUSH_TEMPLATE(is_memory64, value)
|
|
|
|
|
+#define PUSH_TBL_ELEM_IDX(value) COND_PUSH_TEMPLATE(is_table64, value)
|
|
|
#else
|
|
#else
|
|
|
#define PUSH_MEM_OFFSET(value) PUSH_I32(value)
|
|
#define PUSH_MEM_OFFSET(value) PUSH_I32(value)
|
|
|
|
|
+#define PUSH_TBL_ELEM_IDX(value) PUSH_I32(value)
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
#define PUSH_PAGE_COUNT(value) PUSH_MEM_OFFSET(value)
|
|
#define PUSH_PAGE_COUNT(value) PUSH_MEM_OFFSET(value)
|
|
@@ -590,9 +593,11 @@ wasm_interp_get_frame_ref(WASMInterpFrame *frame)
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
#if WASM_ENABLE_MEMORY64 != 0
|
|
#if WASM_ENABLE_MEMORY64 != 0
|
|
|
-#define POP_MEM_OFFSET() (is_memory64 ? POP_I64() : POP_I32())
|
|
|
|
|
|
|
+#define POP_MEM_OFFSET() (is_memory64 ? POP_I64() : (uint32)POP_I32())
|
|
|
|
|
+#define POP_TBL_ELEM_IDX() (is_table64 ? POP_I64() : (uint32)POP_I32())
|
|
|
#else
|
|
#else
|
|
|
#define POP_MEM_OFFSET() POP_I32()
|
|
#define POP_MEM_OFFSET() POP_I32()
|
|
|
|
|
+#define POP_TBL_ELEM_IDX() POP_I32()
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
#define POP_PAGE_COUNT() POP_MEM_OFFSET()
|
|
#define POP_PAGE_COUNT() POP_MEM_OFFSET()
|
|
@@ -1595,7 +1600,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
|
|
uint8 opcode;
|
|
uint8 opcode;
|
|
|
uint32 i, depth, cond, count, fidx, tidx, lidx, frame_size = 0;
|
|
uint32 i, depth, cond, count, fidx, tidx, lidx, frame_size = 0;
|
|
|
uint32 all_cell_num = 0;
|
|
uint32 all_cell_num = 0;
|
|
|
- int32 val;
|
|
|
|
|
|
|
+ tbl_elem_idx_t val;
|
|
|
uint8 *else_addr, *end_addr, *maddr = NULL;
|
|
uint8 *else_addr, *end_addr, *maddr = NULL;
|
|
|
uint32 local_idx, local_offset, global_idx;
|
|
uint32 local_idx, local_offset, global_idx;
|
|
|
uint8 local_type, *global_addr;
|
|
uint8 local_type, *global_addr;
|
|
@@ -1635,6 +1640,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
|
|
/* TODO: multi-memories for now assuming the memory idx type is consistent
|
|
/* TODO: multi-memories for now assuming the memory idx type is consistent
|
|
|
* across multi-memories */
|
|
* across multi-memories */
|
|
|
bool is_memory64 = false;
|
|
bool is_memory64 = false;
|
|
|
|
|
+ bool is_table64 = false;
|
|
|
if (memory)
|
|
if (memory)
|
|
|
is_memory64 = memory->is_memory64;
|
|
is_memory64 = memory->is_memory64;
|
|
|
#endif
|
|
#endif
|
|
@@ -2364,7 +2370,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* type check. compiler will make sure all like
|
|
* type check. compiler will make sure all like
|
|
|
- * (call_indirect (type $x) (i32.const 1))
|
|
|
|
|
|
|
+ * (call_indirect (type $x) (it.const 1))
|
|
|
* the function type has to be defined in the module also
|
|
* the function type has to be defined in the module also
|
|
|
* no matter it is used or not
|
|
* no matter it is used or not
|
|
|
*/
|
|
*/
|
|
@@ -2383,9 +2389,12 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
|
|
/* clang-format on */
|
|
/* clang-format on */
|
|
|
|
|
|
|
|
tbl_inst = wasm_get_table_inst(module, tbl_idx);
|
|
tbl_inst = wasm_get_table_inst(module, tbl_idx);
|
|
|
|
|
+#if WASM_ENABLE_MEMORY64 != 0
|
|
|
|
|
+ is_table64 = tbl_inst->is_table64;
|
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
- val = POP_I32();
|
|
|
|
|
- if ((uint32)val >= tbl_inst->cur_size) {
|
|
|
|
|
|
|
+ val = POP_TBL_ELEM_IDX();
|
|
|
|
|
+ if (val >= tbl_inst->cur_size) {
|
|
|
wasm_set_exception(module, "undefined element");
|
|
wasm_set_exception(module, "undefined element");
|
|
|
goto got_exception;
|
|
goto got_exception;
|
|
|
}
|
|
}
|
|
@@ -2531,15 +2540,19 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
|
|
|
|
|
|
|
HANDLE_OP(WASM_OP_TABLE_GET)
|
|
HANDLE_OP(WASM_OP_TABLE_GET)
|
|
|
{
|
|
{
|
|
|
- uint32 tbl_idx, elem_idx;
|
|
|
|
|
|
|
+ uint32 tbl_idx;
|
|
|
|
|
+ tbl_elem_idx_t elem_idx;
|
|
|
WASMTableInstance *tbl_inst;
|
|
WASMTableInstance *tbl_inst;
|
|
|
|
|
|
|
|
read_leb_uint32(frame_ip, frame_ip_end, tbl_idx);
|
|
read_leb_uint32(frame_ip, frame_ip_end, tbl_idx);
|
|
|
bh_assert(tbl_idx < module->table_count);
|
|
bh_assert(tbl_idx < module->table_count);
|
|
|
|
|
|
|
|
tbl_inst = wasm_get_table_inst(module, tbl_idx);
|
|
tbl_inst = wasm_get_table_inst(module, tbl_idx);
|
|
|
|
|
+#if WASM_ENABLE_MEMORY64 != 0
|
|
|
|
|
+ is_table64 = tbl_inst->is_table64;
|
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
- elem_idx = POP_I32();
|
|
|
|
|
|
|
+ elem_idx = POP_TBL_ELEM_IDX();
|
|
|
if (elem_idx >= tbl_inst->cur_size) {
|
|
if (elem_idx >= tbl_inst->cur_size) {
|
|
|
wasm_set_exception(module, "out of bounds table access");
|
|
wasm_set_exception(module, "out of bounds table access");
|
|
|
goto got_exception;
|
|
goto got_exception;
|
|
@@ -2556,20 +2569,24 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
|
|
HANDLE_OP(WASM_OP_TABLE_SET)
|
|
HANDLE_OP(WASM_OP_TABLE_SET)
|
|
|
{
|
|
{
|
|
|
WASMTableInstance *tbl_inst;
|
|
WASMTableInstance *tbl_inst;
|
|
|
- uint32 tbl_idx, elem_idx;
|
|
|
|
|
|
|
+ uint32 tbl_idx;
|
|
|
|
|
+ tbl_elem_idx_t elem_idx;
|
|
|
table_elem_type_t elem_val;
|
|
table_elem_type_t elem_val;
|
|
|
|
|
|
|
|
read_leb_uint32(frame_ip, frame_ip_end, tbl_idx);
|
|
read_leb_uint32(frame_ip, frame_ip_end, tbl_idx);
|
|
|
bh_assert(tbl_idx < module->table_count);
|
|
bh_assert(tbl_idx < module->table_count);
|
|
|
|
|
|
|
|
tbl_inst = wasm_get_table_inst(module, tbl_idx);
|
|
tbl_inst = wasm_get_table_inst(module, tbl_idx);
|
|
|
|
|
+#if WASM_ENABLE_MEMORY64 != 0
|
|
|
|
|
+ is_table64 = tbl_inst->is_table64;
|
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
#if WASM_ENABLE_GC == 0
|
|
#if WASM_ENABLE_GC == 0
|
|
|
elem_val = POP_I32();
|
|
elem_val = POP_I32();
|
|
|
#else
|
|
#else
|
|
|
elem_val = POP_REF();
|
|
elem_val = POP_REF();
|
|
|
#endif
|
|
#endif
|
|
|
- elem_idx = POP_I32();
|
|
|
|
|
|
|
+ elem_idx = POP_TBL_ELEM_IDX();
|
|
|
if (elem_idx >= tbl_inst->cur_size) {
|
|
if (elem_idx >= tbl_inst->cur_size) {
|
|
|
wasm_set_exception(module, "out of bounds table access");
|
|
wasm_set_exception(module, "out of bounds table access");
|
|
|
goto got_exception;
|
|
goto got_exception;
|
|
@@ -2632,7 +2649,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
|
|
read_leb_uint32(frame_ip, frame_ip_end, type_index);
|
|
read_leb_uint32(frame_ip, frame_ip_end, type_index);
|
|
|
func_obj = POP_REF();
|
|
func_obj = POP_REF();
|
|
|
if (!func_obj) {
|
|
if (!func_obj) {
|
|
|
- wasm_set_exception(module, "null function object");
|
|
|
|
|
|
|
+ wasm_set_exception(module, "null function reference");
|
|
|
goto got_exception;
|
|
goto got_exception;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -2649,7 +2666,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
|
|
read_leb_uint32(frame_ip, frame_ip_end, type_index);
|
|
read_leb_uint32(frame_ip, frame_ip_end, type_index);
|
|
|
func_obj = POP_REF();
|
|
func_obj = POP_REF();
|
|
|
if (!func_obj) {
|
|
if (!func_obj) {
|
|
|
- wasm_set_exception(module, "null function object");
|
|
|
|
|
|
|
+ wasm_set_exception(module, "null function reference");
|
|
|
goto got_exception;
|
|
goto got_exception;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -2796,7 +2813,8 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
|
|
struct_obj = POP_REF();
|
|
struct_obj = POP_REF();
|
|
|
|
|
|
|
|
if (!struct_obj) {
|
|
if (!struct_obj) {
|
|
|
- wasm_set_exception(module, "null structure object");
|
|
|
|
|
|
|
+ wasm_set_exception(module,
|
|
|
|
|
+ "null structure reference");
|
|
|
goto got_exception;
|
|
goto got_exception;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -2852,7 +2870,8 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
|
|
|
|
|
|
|
struct_obj = POP_REF();
|
|
struct_obj = POP_REF();
|
|
|
if (!struct_obj) {
|
|
if (!struct_obj) {
|
|
|
- wasm_set_exception(module, "null structure object");
|
|
|
|
|
|
|
+ wasm_set_exception(module,
|
|
|
|
|
+ "null structure reference");
|
|
|
goto got_exception;
|
|
goto got_exception;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -4679,13 +4698,19 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
|
|
|
|
|
|
|
HANDLE_OP(WASM_OP_MEMORY_GROW)
|
|
HANDLE_OP(WASM_OP_MEMORY_GROW)
|
|
|
{
|
|
{
|
|
|
- uint32 mem_idx, delta, prev_page_count;
|
|
|
|
|
|
|
+ uint32 mem_idx, prev_page_count;
|
|
|
|
|
+ mem_offset_t delta;
|
|
|
|
|
|
|
|
read_leb_memidx(frame_ip, frame_ip_end, mem_idx);
|
|
read_leb_memidx(frame_ip, frame_ip_end, mem_idx);
|
|
|
prev_page_count = memory->cur_page_count;
|
|
prev_page_count = memory->cur_page_count;
|
|
|
- delta = (uint32)POP_PAGE_COUNT();
|
|
|
|
|
|
|
+ delta = POP_PAGE_COUNT();
|
|
|
|
|
|
|
|
- if (!wasm_enlarge_memory_with_idx(module, delta, mem_idx)) {
|
|
|
|
|
|
|
+ if (
|
|
|
|
|
+#if WASM_ENABLE_MEMORY64 != 0
|
|
|
|
|
+ delta > UINT32_MAX ||
|
|
|
|
|
+#endif
|
|
|
|
|
+ !wasm_enlarge_memory_with_idx(module, (uint32)delta,
|
|
|
|
|
+ mem_idx)) {
|
|
|
/* failed to memory.grow, return -1 */
|
|
/* failed to memory.grow, return -1 */
|
|
|
PUSH_PAGE_COUNT(-1);
|
|
PUSH_PAGE_COUNT(-1);
|
|
|
}
|
|
}
|
|
@@ -5880,8 +5905,9 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
|
|
#if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0
|
|
#if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0
|
|
|
case WASM_OP_TABLE_INIT:
|
|
case WASM_OP_TABLE_INIT:
|
|
|
{
|
|
{
|
|
|
- uint32 tbl_idx, elem_idx;
|
|
|
|
|
- uint32 n, s, d;
|
|
|
|
|
|
|
+ uint32 tbl_idx;
|
|
|
|
|
+ tbl_elem_idx_t elem_idx, d;
|
|
|
|
|
+ uint32 n, s;
|
|
|
WASMTableInstance *tbl_inst;
|
|
WASMTableInstance *tbl_inst;
|
|
|
table_elem_type_t *table_elems;
|
|
table_elem_type_t *table_elems;
|
|
|
InitializerExpression *tbl_seg_init_values = NULL,
|
|
InitializerExpression *tbl_seg_init_values = NULL,
|
|
@@ -5895,10 +5921,13 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
|
|
bh_assert(tbl_idx < module->module->table_count);
|
|
bh_assert(tbl_idx < module->module->table_count);
|
|
|
|
|
|
|
|
tbl_inst = wasm_get_table_inst(module, tbl_idx);
|
|
tbl_inst = wasm_get_table_inst(module, tbl_idx);
|
|
|
|
|
+#if WASM_ENABLE_MEMORY64 != 0
|
|
|
|
|
+ is_table64 = tbl_inst->is_table64;
|
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
n = (uint32)POP_I32();
|
|
n = (uint32)POP_I32();
|
|
|
s = (uint32)POP_I32();
|
|
s = (uint32)POP_I32();
|
|
|
- d = (uint32)POP_I32();
|
|
|
|
|
|
|
+ d = (tbl_elem_idx_t)POP_TBL_ELEM_IDX();
|
|
|
|
|
|
|
|
if (!bh_bitmap_get_bit(module->e->common.elem_dropped,
|
|
if (!bh_bitmap_get_bit(module->e->common.elem_dropped,
|
|
|
elem_idx)) {
|
|
elem_idx)) {
|
|
@@ -5911,8 +5940,15 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
|
|
.value_count;
|
|
.value_count;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (offset_len_out_of_bounds(s, n, tbl_seg_len)
|
|
|
|
|
- || offset_len_out_of_bounds(d, n,
|
|
|
|
|
|
|
+ /* TODO: memory64 current implementation of table64
|
|
|
|
|
+ * still assumes the max table size UINT32_MAX
|
|
|
|
|
+ */
|
|
|
|
|
+ if (
|
|
|
|
|
+#if WASM_ENABLE_MEMORY64 != 0
|
|
|
|
|
+ d > UINT32_MAX ||
|
|
|
|
|
+#endif
|
|
|
|
|
+ offset_len_out_of_bounds(s, n, tbl_seg_len)
|
|
|
|
|
+ || offset_len_out_of_bounds((uint32)d, n,
|
|
|
tbl_inst->cur_size)) {
|
|
tbl_inst->cur_size)) {
|
|
|
wasm_set_exception(module,
|
|
wasm_set_exception(module,
|
|
|
"out of bounds table access");
|
|
"out of bounds table access");
|
|
@@ -5966,7 +6002,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
|
|
case WASM_OP_TABLE_COPY:
|
|
case WASM_OP_TABLE_COPY:
|
|
|
{
|
|
{
|
|
|
uint32 src_tbl_idx, dst_tbl_idx;
|
|
uint32 src_tbl_idx, dst_tbl_idx;
|
|
|
- uint32 n, s, d;
|
|
|
|
|
|
|
+ tbl_elem_idx_t n, s, d;
|
|
|
WASMTableInstance *src_tbl_inst, *dst_tbl_inst;
|
|
WASMTableInstance *src_tbl_inst, *dst_tbl_inst;
|
|
|
|
|
|
|
|
read_leb_uint32(frame_ip, frame_ip_end, dst_tbl_idx);
|
|
read_leb_uint32(frame_ip, frame_ip_end, dst_tbl_idx);
|
|
@@ -5979,14 +6015,29 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
|
|
|
|
|
|
|
src_tbl_inst = wasm_get_table_inst(module, src_tbl_idx);
|
|
src_tbl_inst = wasm_get_table_inst(module, src_tbl_idx);
|
|
|
|
|
|
|
|
- n = (uint32)POP_I32();
|
|
|
|
|
- s = (uint32)POP_I32();
|
|
|
|
|
- d = (uint32)POP_I32();
|
|
|
|
|
|
|
+#if WASM_ENABLE_MEMORY64 != 0
|
|
|
|
|
+ is_table64 = src_tbl_inst->is_table64
|
|
|
|
|
+ && dst_tbl_inst->is_table64;
|
|
|
|
|
+#endif
|
|
|
|
|
+ n = (tbl_elem_idx_t)POP_TBL_ELEM_IDX();
|
|
|
|
|
+#if WASM_ENABLE_MEMORY64 != 0
|
|
|
|
|
+ is_table64 = src_tbl_inst->is_table64;
|
|
|
|
|
+#endif
|
|
|
|
|
+ s = (tbl_elem_idx_t)POP_TBL_ELEM_IDX();
|
|
|
|
|
+#if WASM_ENABLE_MEMORY64 != 0
|
|
|
|
|
+ is_table64 = dst_tbl_inst->is_table64;
|
|
|
|
|
+#endif
|
|
|
|
|
+ d = (tbl_elem_idx_t)POP_TBL_ELEM_IDX();
|
|
|
|
|
|
|
|
- if (offset_len_out_of_bounds(d, n,
|
|
|
|
|
|
|
+ if (
|
|
|
|
|
+#if WASM_ENABLE_MEMORY64 != 0
|
|
|
|
|
+ n > UINT32_MAX || s > UINT32_MAX || d > UINT32_MAX
|
|
|
|
|
+ ||
|
|
|
|
|
+#endif
|
|
|
|
|
+ offset_len_out_of_bounds((uint32)d, (uint32)n,
|
|
|
dst_tbl_inst->cur_size)
|
|
dst_tbl_inst->cur_size)
|
|
|
|| offset_len_out_of_bounds(
|
|
|| offset_len_out_of_bounds(
|
|
|
- s, n, src_tbl_inst->cur_size)) {
|
|
|
|
|
|
|
+ (uint32)s, (uint32)n, src_tbl_inst->cur_size)) {
|
|
|
wasm_set_exception(module,
|
|
wasm_set_exception(module,
|
|
|
"out of bounds table access");
|
|
"out of bounds table access");
|
|
|
goto got_exception;
|
|
goto got_exception;
|
|
@@ -6009,28 +6060,37 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
|
|
case WASM_OP_TABLE_GROW:
|
|
case WASM_OP_TABLE_GROW:
|
|
|
{
|
|
{
|
|
|
WASMTableInstance *tbl_inst;
|
|
WASMTableInstance *tbl_inst;
|
|
|
- uint32 tbl_idx, n, orig_tbl_sz;
|
|
|
|
|
|
|
+ uint32 tbl_idx, orig_tbl_sz;
|
|
|
|
|
+ tbl_elem_idx_t n;
|
|
|
table_elem_type_t init_val;
|
|
table_elem_type_t init_val;
|
|
|
|
|
|
|
|
read_leb_uint32(frame_ip, frame_ip_end, tbl_idx);
|
|
read_leb_uint32(frame_ip, frame_ip_end, tbl_idx);
|
|
|
bh_assert(tbl_idx < module->table_count);
|
|
bh_assert(tbl_idx < module->table_count);
|
|
|
|
|
|
|
|
tbl_inst = wasm_get_table_inst(module, tbl_idx);
|
|
tbl_inst = wasm_get_table_inst(module, tbl_idx);
|
|
|
|
|
+#if WASM_ENABLE_MEMORY64 != 0
|
|
|
|
|
+ is_table64 = tbl_inst->is_table64;
|
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
orig_tbl_sz = tbl_inst->cur_size;
|
|
orig_tbl_sz = tbl_inst->cur_size;
|
|
|
|
|
|
|
|
- n = POP_I32();
|
|
|
|
|
|
|
+ n = POP_TBL_ELEM_IDX();
|
|
|
#if WASM_ENABLE_GC == 0
|
|
#if WASM_ENABLE_GC == 0
|
|
|
init_val = POP_I32();
|
|
init_val = POP_I32();
|
|
|
#else
|
|
#else
|
|
|
init_val = POP_REF();
|
|
init_val = POP_REF();
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
- if (!wasm_enlarge_table(module, tbl_idx, n, init_val)) {
|
|
|
|
|
- PUSH_I32(-1);
|
|
|
|
|
|
|
+ if (
|
|
|
|
|
+#if WASM_ENABLE_MEMORY64 != 0
|
|
|
|
|
+ n > UINT32_MAX ||
|
|
|
|
|
+#endif
|
|
|
|
|
+ !wasm_enlarge_table(module, tbl_idx, (uint32)n,
|
|
|
|
|
+ init_val)) {
|
|
|
|
|
+ PUSH_TBL_ELEM_IDX(-1);
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
- PUSH_I32(orig_tbl_sz);
|
|
|
|
|
|
|
+ PUSH_TBL_ELEM_IDX(orig_tbl_sz);
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
@@ -6043,13 +6103,17 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
|
|
bh_assert(tbl_idx < module->table_count);
|
|
bh_assert(tbl_idx < module->table_count);
|
|
|
|
|
|
|
|
tbl_inst = wasm_get_table_inst(module, tbl_idx);
|
|
tbl_inst = wasm_get_table_inst(module, tbl_idx);
|
|
|
|
|
+#if WASM_ENABLE_MEMORY64 != 0
|
|
|
|
|
+ is_table64 = tbl_inst->is_table64;
|
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
- PUSH_I32(tbl_inst->cur_size);
|
|
|
|
|
|
|
+ PUSH_TBL_ELEM_IDX(tbl_inst->cur_size);
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
case WASM_OP_TABLE_FILL:
|
|
case WASM_OP_TABLE_FILL:
|
|
|
{
|
|
{
|
|
|
- uint32 tbl_idx, n;
|
|
|
|
|
|
|
+ uint32 tbl_idx;
|
|
|
|
|
+ tbl_elem_idx_t n, elem_idx;
|
|
|
WASMTableInstance *tbl_inst;
|
|
WASMTableInstance *tbl_inst;
|
|
|
table_elem_type_t fill_val;
|
|
table_elem_type_t fill_val;
|
|
|
|
|
|
|
@@ -6057,24 +6121,32 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
|
|
bh_assert(tbl_idx < module->table_count);
|
|
bh_assert(tbl_idx < module->table_count);
|
|
|
|
|
|
|
|
tbl_inst = wasm_get_table_inst(module, tbl_idx);
|
|
tbl_inst = wasm_get_table_inst(module, tbl_idx);
|
|
|
|
|
+#if WASM_ENABLE_MEMORY64 != 0
|
|
|
|
|
+ is_table64 = tbl_inst->is_table64;
|
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
- n = POP_I32();
|
|
|
|
|
|
|
+ n = POP_TBL_ELEM_IDX();
|
|
|
#if WASM_ENABLE_GC == 0
|
|
#if WASM_ENABLE_GC == 0
|
|
|
fill_val = POP_I32();
|
|
fill_val = POP_I32();
|
|
|
#else
|
|
#else
|
|
|
fill_val = POP_REF();
|
|
fill_val = POP_REF();
|
|
|
#endif
|
|
#endif
|
|
|
- i = POP_I32();
|
|
|
|
|
|
|
+ elem_idx = POP_TBL_ELEM_IDX();
|
|
|
|
|
|
|
|
- if (offset_len_out_of_bounds(i, n,
|
|
|
|
|
|
|
+ if (
|
|
|
|
|
+#if WASM_ENABLE_MEMORY64 != 0
|
|
|
|
|
+ n > UINT32_MAX || elem_idx > UINT32_MAX ||
|
|
|
|
|
+#endif
|
|
|
|
|
+ offset_len_out_of_bounds((uint32)elem_idx,
|
|
|
|
|
+ (uint32)n,
|
|
|
tbl_inst->cur_size)) {
|
|
tbl_inst->cur_size)) {
|
|
|
wasm_set_exception(module,
|
|
wasm_set_exception(module,
|
|
|
"out of bounds table access");
|
|
"out of bounds table access");
|
|
|
goto got_exception;
|
|
goto got_exception;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- for (; n != 0; i++, n--) {
|
|
|
|
|
- tbl_inst->elems[i] = fill_val;
|
|
|
|
|
|
|
+ for (; n != 0; elem_idx++, n--) {
|
|
|
|
|
+ tbl_inst->elems[elem_idx] = fill_val;
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
@@ -6657,7 +6729,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
|
|
|| WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS == 0 \
|
|
|| WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS == 0 \
|
|
|
|| WASM_ENABLE_BULK_MEMORY != 0
|
|
|| WASM_ENABLE_BULK_MEMORY != 0
|
|
|
if (memory)
|
|
if (memory)
|
|
|
- linear_mem_size = get_linear_mem_size();
|
|
|
|
|
|
|
+ linear_mem_size = GET_LINEAR_MEMORY_SIZE(memory);
|
|
|
#endif
|
|
#endif
|
|
|
if (wasm_copy_exception(module, NULL)) {
|
|
if (wasm_copy_exception(module, NULL)) {
|
|
|
#if WASM_ENABLE_EXCE_HANDLING != 0
|
|
#if WASM_ENABLE_EXCE_HANDLING != 0
|