mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-05-30 21:47:24 +00:00
implement globals
This commit is contained in:
parent
b2804c004f
commit
28d74d2e6c
|
@ -3595,7 +3595,19 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
|||
GET_I64_FROM_ADDR((uint32 *)global_addr));
|
||||
HANDLE_OP_END();
|
||||
}
|
||||
|
||||
#if WASM_ENABLE_SIMDE != 0
|
||||
HANDLE_OP(WASM_OP_GET_GLOBAL_128)
|
||||
{
|
||||
global_idx = read_uint32(frame_ip);
|
||||
bh_assert(global_idx < module->e->global_count);
|
||||
global = globals + global_idx;
|
||||
global_addr = get_global_addr(global_data, global);
|
||||
addr_ret = GET_OFFSET();
|
||||
PUT_V128_TO_ADDR(frame_lp + addr_ret,
|
||||
GET_V128_FROM_ADDR((uint32 *)global_addr));
|
||||
HANDLE_OP_END();
|
||||
}
|
||||
#endif
|
||||
HANDLE_OP(WASM_OP_SET_GLOBAL)
|
||||
{
|
||||
global_idx = read_uint32(frame_ip);
|
||||
|
@ -3662,6 +3674,19 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
|||
GET_I64_FROM_ADDR(frame_lp + addr1));
|
||||
HANDLE_OP_END();
|
||||
}
|
||||
#if WASM_ENABLE_SIMDE != 0
|
||||
HANDLE_OP(WASM_OP_SET_GLOBAL_128)
|
||||
{
|
||||
global_idx = read_uint32(frame_ip);
|
||||
bh_assert(global_idx < module->e->global_count);
|
||||
global = globals + global_idx;
|
||||
global_addr = get_global_addr(global_data, global);
|
||||
addr1 = GET_OFFSET();
|
||||
PUT_V128_TO_ADDR((uint32 *)global_addr,
|
||||
GET_V128_FROM_ADDR(frame_lp + addr1));
|
||||
HANDLE_OP_END();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* memory load instructions */
|
||||
HANDLE_OP(WASM_OP_I32_LOAD)
|
||||
|
|
|
@ -7300,6 +7300,8 @@ wasm_loader_find_block_addr(WASMExecEnv *exec_env, BlockAddr *block_addr_cache,
|
|||
case WASM_OP_SET_GLOBAL:
|
||||
case WASM_OP_GET_GLOBAL_64:
|
||||
case WASM_OP_SET_GLOBAL_64:
|
||||
case WASM_OP_GET_GLOBAL_128:
|
||||
case WASM_OP_SET_GLOBAL_128:
|
||||
case WASM_OP_SET_GLOBAL_AUX_STACK:
|
||||
skip_leb_uint32(p, p_end); /* local index */
|
||||
break;
|
||||
|
@ -9111,6 +9113,11 @@ preserve_referenced_local(WASMLoaderContext *loader_ctx, uint8 opcode,
|
|||
loader_ctx->preserved_local_offset++;
|
||||
emit_label(EXT_OP_COPY_STACK_TOP);
|
||||
}
|
||||
else if (local_type == VALUE_TYPE_V128) {
|
||||
if (loader_ctx->p_code_compiled)
|
||||
loader_ctx->preserved_local_offset += 4;
|
||||
emit_label(EXT_OP_COPY_STACK_TOP_V128);
|
||||
}
|
||||
else {
|
||||
if (loader_ctx->p_code_compiled)
|
||||
loader_ctx->preserved_local_offset += 2;
|
||||
|
@ -13206,9 +13213,14 @@ re_scan:
|
|||
skip_label();
|
||||
emit_label(WASM_OP_GET_GLOBAL_64);
|
||||
}
|
||||
|
||||
if (global_type == VALUE_TYPE_V128) {
|
||||
skip_label();
|
||||
emit_label(WASM_OP_GET_GLOBAL_128);
|
||||
}
|
||||
#endif /* end of WASM_ENABLE_SIMDE */
|
||||
emit_uint32(loader_ctx, global_idx);
|
||||
PUSH_OFFSET_TYPE(global_type);
|
||||
#endif /* end of WASM_ENABLE_FAST_INTERP */
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -13300,6 +13312,12 @@ re_scan:
|
|||
skip_label();
|
||||
emit_label(WASM_OP_SET_GLOBAL_AUX_STACK);
|
||||
}
|
||||
#if WASM_ENABLE_SIMDE != 0
|
||||
else if (global_type == VALUE_TYPE_V128) {
|
||||
skip_label();
|
||||
emit_label(WASM_OP_SET_GLOBAL_128);
|
||||
}
|
||||
#endif /* end of WASM_ENABLE_SIMDE */
|
||||
emit_uint32(loader_ctx, global_idx);
|
||||
POP_OFFSET_TYPE(global_type);
|
||||
#endif /* end of WASM_ENABLE_FAST_INTERP */
|
||||
|
|
|
@ -284,6 +284,8 @@ typedef enum WASMOpcode {
|
|||
EXT_OP_SET_LOCAL_FAST_V128 = 0xdd,
|
||||
EXT_OP_TEE_LOCAL_FAST_V128 = 0xde,
|
||||
EXT_OP_COPY_STACK_TOP_V128 = 0xdf,
|
||||
WASM_OP_GET_GLOBAL_128 = 0xe0,
|
||||
WASM_OP_SET_GLOBAL_128 = 0xe1,
|
||||
#endif
|
||||
|
||||
/* Post-MVP extend op prefix */
|
||||
|
@ -803,7 +805,10 @@ typedef enum WASMAtomicEXTOpcode {
|
|||
#define DEF_EXT_V128_HANDLE() \
|
||||
SET_GOTO_TABLE_ELEM(EXT_OP_SET_LOCAL_FAST_V128), \
|
||||
SET_GOTO_TABLE_ELEM(EXT_OP_TEE_LOCAL_FAST_V128), \
|
||||
SET_GOTO_TABLE_ELEM(EXT_OP_COPY_STACK_TOP_V128),
|
||||
SET_GOTO_TABLE_ELEM(EXT_OP_COPY_STACK_TOP_V128), \
|
||||
SET_GOTO_TABLE_ELEM(WASM_OP_GET_GLOBAL_128), \
|
||||
SET_GOTO_TABLE_ELEM(WASM_OP_SET_GLOBAL_128), \
|
||||
|
||||
#else
|
||||
#define DEF_EXT_V128_HANDLE()
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue
Block a user