mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-21 19:45:53 +00:00
Fix CI build issues
* Mac build fix * Windows build fix * Windows instruction counter fix
This commit is contained in:
175
external/wamr/patches/ripp_metering.patch
vendored
175
external/wamr/patches/ripp_metering.patch
vendored
@@ -87,7 +87,7 @@ index ce0c1fa7..2713a092 100644
|
|||||||
/**
|
/**
|
||||||
* Cache for
|
* Cache for
|
||||||
diff --git a/core/iwasm/common/wasm_runtime_common.c b/core/iwasm/common/wasm_runtime_common.c
|
diff --git a/core/iwasm/common/wasm_runtime_common.c b/core/iwasm/common/wasm_runtime_common.c
|
||||||
index d33c0272..900fb536 100644
|
index d33c0272..21bfdf29 100644
|
||||||
--- a/core/iwasm/common/wasm_runtime_common.c
|
--- a/core/iwasm/common/wasm_runtime_common.c
|
||||||
+++ b/core/iwasm/common/wasm_runtime_common.c
|
+++ b/core/iwasm/common/wasm_runtime_common.c
|
||||||
@@ -2285,6 +2285,31 @@ wasm_runtime_access_exce_check_guard_page()
|
@@ -2285,6 +2285,31 @@ wasm_runtime_access_exce_check_guard_page()
|
||||||
@@ -122,15 +122,39 @@ index d33c0272..900fb536 100644
|
|||||||
WASMFuncType *
|
WASMFuncType *
|
||||||
wasm_runtime_get_function_type(const WASMFunctionInstanceCommon *function,
|
wasm_runtime_get_function_type(const WASMFunctionInstanceCommon *function,
|
||||||
uint32 module_type)
|
uint32 module_type)
|
||||||
@@ -7803,7 +7828,7 @@ wasm_runtime_detect_native_stack_overflow(WASMExecEnv *exec_env)
|
@@ -7792,13 +7817,14 @@ wasm_runtime_get_module_name(wasm_module_t module)
|
||||||
|
bool
|
||||||
|
wasm_runtime_detect_native_stack_overflow(WASMExecEnv *exec_env)
|
||||||
|
{
|
||||||
|
+#if WASM_DISABLE_STACK_HW_BOUND_CHECK == 0
|
||||||
|
uint8 *boundary = exec_env->native_stack_boundary;
|
||||||
|
RECORD_STACK_USAGE(exec_env, (uint8 *)&boundary);
|
||||||
|
if (boundary == NULL) {
|
||||||
|
/* the platform doesn't support os_thread_get_stack_boundary */
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
-#if defined(OS_ENABLE_HW_BOUND_CHECK) && WASM_DISABLE_STACK_HW_BOUND_CHECK == 0
|
||||||
|
+#if defined(OS_ENABLE_HW_BOUND_CHECK)
|
||||||
|
uint32 page_size = os_getpagesize();
|
||||||
uint32 guard_page_count = STACK_OVERFLOW_CHECK_GUARD_PAGE_COUNT;
|
uint32 guard_page_count = STACK_OVERFLOW_CHECK_GUARD_PAGE_COUNT;
|
||||||
boundary = boundary + page_size * guard_page_count;
|
boundary = boundary + page_size * guard_page_count;
|
||||||
#endif
|
@@ -7808,6 +7834,7 @@ wasm_runtime_detect_native_stack_overflow(WASMExecEnv *exec_env)
|
||||||
- if ((uint8 *)&boundary < boundary) {
|
|
||||||
+ if (((uint8 *)&boundary < boundary) && ((uint8 *)&boundary > exec_env->native_stack_boundary)){
|
|
||||||
wasm_runtime_set_exception(wasm_runtime_get_module_inst(exec_env),
|
|
||||||
"native stack overflow");
|
"native stack overflow");
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
+#endif
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -7830,7 +7857,7 @@ wasm_runtime_detect_native_stack_overflow_size(WASMExecEnv *exec_env,
|
||||||
|
boundary = boundary - WASM_STACK_GUARD_SIZE + requested_size;
|
||||||
|
if ((uint8 *)&boundary < boundary) {
|
||||||
|
wasm_runtime_set_exception(wasm_runtime_get_module_inst(exec_env),
|
||||||
|
- "native stack overflow");
|
||||||
|
+ "native s stack overflow");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
diff --git a/core/iwasm/common/wasm_runtime_common.h b/core/iwasm/common/wasm_runtime_common.h
|
diff --git a/core/iwasm/common/wasm_runtime_common.h b/core/iwasm/common/wasm_runtime_common.h
|
||||||
index 8ac032bf..5ca5d489 100644
|
index 8ac032bf..5ca5d489 100644
|
||||||
--- a/core/iwasm/common/wasm_runtime_common.h
|
--- a/core/iwasm/common/wasm_runtime_common.h
|
||||||
@@ -163,10 +187,22 @@ index 8ac032bf..5ca5d489 100644
|
|||||||
bool enable);
|
bool enable);
|
||||||
|
|
||||||
diff --git a/core/iwasm/include/wasm_c_api.h b/core/iwasm/include/wasm_c_api.h
|
diff --git a/core/iwasm/include/wasm_c_api.h b/core/iwasm/include/wasm_c_api.h
|
||||||
index 241a0eec..82e048c0 100644
|
index 241a0eec..9eb0dde1 100644
|
||||||
--- a/core/iwasm/include/wasm_c_api.h
|
--- a/core/iwasm/include/wasm_c_api.h
|
||||||
+++ b/core/iwasm/include/wasm_c_api.h
|
+++ b/core/iwasm/include/wasm_c_api.h
|
||||||
@@ -701,6 +701,11 @@ WASM_API_EXTERN double wasm_instance_sum_wasm_exec_time(const wasm_instance_t*);
|
@@ -19,8 +19,10 @@
|
||||||
|
#if defined(_MSC_BUILD)
|
||||||
|
#if defined(COMPILING_WASM_RUNTIME_API)
|
||||||
|
#define WASM_API_EXTERN __declspec(dllexport)
|
||||||
|
-#else
|
||||||
|
+#elif defined(_DLL)
|
||||||
|
#define WASM_API_EXTERN __declspec(dllimport)
|
||||||
|
+#else
|
||||||
|
+#define WASM_API_EXTERN
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#define WASM_API_EXTERN
|
||||||
|
@@ -701,6 +703,11 @@ WASM_API_EXTERN double wasm_instance_sum_wasm_exec_time(const wasm_instance_t*);
|
||||||
// func_name. If the function is not found, return 0.
|
// func_name. If the function is not found, return 0.
|
||||||
WASM_API_EXTERN double wasm_instance_get_wasm_func_exec_time(const wasm_instance_t*, const char *);
|
WASM_API_EXTERN double wasm_instance_get_wasm_func_exec_time(const wasm_instance_t*, const char *);
|
||||||
|
|
||||||
@@ -179,10 +215,22 @@ index 241a0eec..82e048c0 100644
|
|||||||
// Convenience
|
// Convenience
|
||||||
|
|
||||||
diff --git a/core/iwasm/include/wasm_export.h b/core/iwasm/include/wasm_export.h
|
diff --git a/core/iwasm/include/wasm_export.h b/core/iwasm/include/wasm_export.h
|
||||||
index b73a0364..f7e20b24 100644
|
index b73a0364..3fd0949f 100644
|
||||||
--- a/core/iwasm/include/wasm_export.h
|
--- a/core/iwasm/include/wasm_export.h
|
||||||
+++ b/core/iwasm/include/wasm_export.h
|
+++ b/core/iwasm/include/wasm_export.h
|
||||||
@@ -1821,6 +1821,27 @@ WASM_RUNTIME_API_EXTERN void
|
@@ -20,8 +20,10 @@
|
||||||
|
#if defined(_MSC_BUILD)
|
||||||
|
#if defined(COMPILING_WASM_RUNTIME_API)
|
||||||
|
#define WASM_RUNTIME_API_EXTERN __declspec(dllexport)
|
||||||
|
-#else
|
||||||
|
+#elif defined(_DLL)
|
||||||
|
#define WASM_RUNTIME_API_EXTERN __declspec(dllimport)
|
||||||
|
+#else
|
||||||
|
+#define WASM_RUNTIME_API_EXTERN
|
||||||
|
#endif
|
||||||
|
#elif defined(__GNUC__) || defined(__clang__)
|
||||||
|
#define WASM_RUNTIME_API_EXTERN __attribute__((visibility("default")))
|
||||||
|
@@ -1821,6 +1823,27 @@ WASM_RUNTIME_API_EXTERN void
|
||||||
wasm_runtime_set_native_stack_boundary(wasm_exec_env_t exec_env,
|
wasm_runtime_set_native_stack_boundary(wasm_exec_env_t exec_env,
|
||||||
uint8_t *native_stack_boundary);
|
uint8_t *native_stack_boundary);
|
||||||
|
|
||||||
@@ -211,7 +259,7 @@ index b73a0364..f7e20b24 100644
|
|||||||
* Dump runtime memory consumption, including:
|
* Dump runtime memory consumption, including:
|
||||||
* Exec env memory consumption
|
* Exec env memory consumption
|
||||||
diff --git a/core/iwasm/interpreter/wasm_interp_classic.c b/core/iwasm/interpreter/wasm_interp_classic.c
|
diff --git a/core/iwasm/interpreter/wasm_interp_classic.c b/core/iwasm/interpreter/wasm_interp_classic.c
|
||||||
index 41ac4c72..1aa1fe1c 100644
|
index 41ac4c72..bd8f714a 100644
|
||||||
--- a/core/iwasm/interpreter/wasm_interp_classic.c
|
--- a/core/iwasm/interpreter/wasm_interp_classic.c
|
||||||
+++ b/core/iwasm/interpreter/wasm_interp_classic.c
|
+++ b/core/iwasm/interpreter/wasm_interp_classic.c
|
||||||
@@ -1516,10 +1516,13 @@ wasm_interp_call_func_import(WASMModuleInstance *module_inst,
|
@@ -1516,10 +1516,13 @@ wasm_interp_call_func_import(WASMModuleInstance *module_inst,
|
||||||
@@ -243,18 +291,20 @@ index 41ac4c72..1aa1fe1c 100644
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* end of WASM_ENABLE_LABELS_AS_VALUES */
|
#endif /* end of WASM_ENABLE_LABELS_AS_VALUES */
|
||||||
@@ -1562,6 +1568,18 @@ get_global_addr(uint8 *global_data, WASMGlobalInstance *global)
|
@@ -1562,6 +1568,20 @@ get_global_addr(uint8 *global_data, WASMGlobalInstance *global)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
+#if WASM_ENABLE_INSTRUCTION_METERING != 0
|
+#if WASM_ENABLE_INSTRUCTION_METERING != 0
|
||||||
+#define CHECK_INSTRUCTION_LIMIT() \
|
+#define CHECK_INSTRUCTION_LIMIT() \
|
||||||
+ if (instructions_to_execute == 0) { \
|
+ if (instructions_to_execute >= 0) \
|
||||||
|
+ { \
|
||||||
|
+ instructions_to_execute -= instructions_schedule[opcode];\
|
||||||
|
+ if (instructions_to_execute < 0) { \
|
||||||
+ wasm_set_exception(module, "instruction limit exceeded"); \
|
+ wasm_set_exception(module, "instruction limit exceeded"); \
|
||||||
+ goto got_exception; \
|
+ goto got_exception; \
|
||||||
+ } \
|
+ } \
|
||||||
+ else if (instructions_to_execute > 0) \
|
+ }
|
||||||
+ instructions_to_execute--;
|
|
||||||
+#else
|
+#else
|
||||||
+#define CHECK_INSTRUCTION_LIMIT() (void)0
|
+#define CHECK_INSTRUCTION_LIMIT() (void)0
|
||||||
+#endif
|
+#endif
|
||||||
@@ -262,21 +312,25 @@ index 41ac4c72..1aa1fe1c 100644
|
|||||||
static void
|
static void
|
||||||
wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
||||||
WASMExecEnv *exec_env,
|
WASMExecEnv *exec_env,
|
||||||
@@ -1605,6 +1623,13 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
@@ -1605,6 +1625,17 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
||||||
uint32 local_idx, local_offset, global_idx;
|
uint32 local_idx, local_offset, global_idx;
|
||||||
uint8 local_type, *global_addr;
|
uint8 local_type, *global_addr;
|
||||||
uint32 cache_index, type_index, param_cell_num, cell_num;
|
uint32 cache_index, type_index, param_cell_num, cell_num;
|
||||||
+
|
+
|
||||||
+#if WASM_ENABLE_INSTRUCTION_METERING != 0
|
+#if WASM_ENABLE_INSTRUCTION_METERING != 0
|
||||||
+ int64 instructions_to_execute = -1;
|
+ int64 instructions_to_execute = -1;
|
||||||
|
+ int64 const *instructions_schedule = NULL;
|
||||||
+ if(exec_env)
|
+ if(exec_env)
|
||||||
|
+ {
|
||||||
+ instructions_to_execute = exec_env->instructions_to_execute;
|
+ instructions_to_execute = exec_env->instructions_to_execute;
|
||||||
|
+ instructions_schedule = exec_env->instructions_schedule;
|
||||||
|
+ }
|
||||||
+#endif
|
+#endif
|
||||||
+
|
+
|
||||||
#if WASM_ENABLE_EXCE_HANDLING != 0
|
#if WASM_ENABLE_EXCE_HANDLING != 0
|
||||||
int32_t exception_tag_index;
|
int32_t exception_tag_index;
|
||||||
#endif
|
#endif
|
||||||
@@ -6859,6 +6884,11 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
@@ -6859,6 +6890,11 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
||||||
FREE_FRAME(exec_env, frame);
|
FREE_FRAME(exec_env, frame);
|
||||||
wasm_exec_env_set_cur_frame(exec_env, prev_frame);
|
wasm_exec_env_set_cur_frame(exec_env, prev_frame);
|
||||||
|
|
||||||
@@ -288,7 +342,7 @@ index 41ac4c72..1aa1fe1c 100644
|
|||||||
if (!prev_frame->ip) {
|
if (!prev_frame->ip) {
|
||||||
/* Called from native. */
|
/* Called from native. */
|
||||||
return;
|
return;
|
||||||
@@ -6899,6 +6929,12 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
@@ -6899,6 +6935,12 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
SYNC_ALL_TO_FRAME();
|
SYNC_ALL_TO_FRAME();
|
||||||
@@ -302,18 +356,17 @@ index 41ac4c72..1aa1fe1c 100644
|
|||||||
|
|
||||||
#if WASM_ENABLE_LABELS_AS_VALUES == 0
|
#if WASM_ENABLE_LABELS_AS_VALUES == 0
|
||||||
diff --git a/core/iwasm/interpreter/wasm_interp_fast.c b/core/iwasm/interpreter/wasm_interp_fast.c
|
diff --git a/core/iwasm/interpreter/wasm_interp_fast.c b/core/iwasm/interpreter/wasm_interp_fast.c
|
||||||
index f33ad60e..a7078fe8 100644
|
index f33ad60e..9cbf2010 100644
|
||||||
--- a/core/iwasm/interpreter/wasm_interp_fast.c
|
--- a/core/iwasm/interpreter/wasm_interp_fast.c
|
||||||
+++ b/core/iwasm/interpreter/wasm_interp_fast.c
|
+++ b/core/iwasm/interpreter/wasm_interp_fast.c
|
||||||
@@ -105,6 +105,20 @@ typedef float64 CellType_F64;
|
@@ -105,6 +105,19 @@ typedef float64 CellType_F64;
|
||||||
goto unaligned_atomic; \
|
goto unaligned_atomic; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
+#if WASM_ENABLE_INSTRUCTION_METERING != 0
|
+#if WASM_ENABLE_INSTRUCTION_METERING != 0
|
||||||
+#define CHECK_INSTRUCTION_LIMIT() \
|
+#define CHECK_INSTRUCTION_LIMIT() \
|
||||||
+ if (instructions_to_execute >= 0) \
|
+ if (instructions_to_execute >= 0) { \
|
||||||
+ { \
|
+ instructions_to_execute -= instructions_schedule[opcode]; \
|
||||||
+ instructions_to_execute -= instructions_schedule[opc]; \
|
|
||||||
+ if (instructions_to_execute < 0) { \
|
+ if (instructions_to_execute < 0) { \
|
||||||
+ wasm_set_exception(module, "instruction limit exceeded"); \
|
+ wasm_set_exception(module, "instruction limit exceeded"); \
|
||||||
+ goto got_exception; \
|
+ goto got_exception; \
|
||||||
@@ -326,40 +379,24 @@ index f33ad60e..a7078fe8 100644
|
|||||||
static inline uint32
|
static inline uint32
|
||||||
rotl32(uint32 n, uint32 c)
|
rotl32(uint32 n, uint32 c)
|
||||||
{
|
{
|
||||||
@@ -1439,8 +1453,10 @@ wasm_interp_dump_op_count()
|
@@ -1466,12 +1479,14 @@ wasm_interp_dump_op_count()
|
||||||
#if WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS != 0
|
|
||||||
#define FETCH_OPCODE_AND_DISPATCH() \
|
|
||||||
do { \
|
|
||||||
+ const uint64 opc = *frame_ip; \
|
|
||||||
const void *p_label_addr = *(void **)frame_ip; \
|
|
||||||
frame_ip += sizeof(void *); \
|
|
||||||
+ CHECK_INSTRUCTION_LIMIT(); \
|
|
||||||
goto *p_label_addr; \
|
|
||||||
} while (0)
|
|
||||||
#else
|
|
||||||
@@ -1450,8 +1466,10 @@ wasm_interp_dump_op_count()
|
|
||||||
const void *p_label_addr; \
|
|
||||||
bh_assert(((uintptr_t)frame_ip & 1) == 0); \
|
|
||||||
/* int32 relative offset was emitted in 64-bit target */ \
|
|
||||||
+ const uint64 opc = LOAD_U32_WITH_2U16S(frame_ip); \
|
|
||||||
p_label_addr = label_base + (int32)LOAD_U32_WITH_2U16S(frame_ip); \
|
|
||||||
frame_ip += sizeof(int32); \
|
|
||||||
+ CHECK_INSTRUCTION_LIMIT(); \
|
|
||||||
goto *p_label_addr; \
|
|
||||||
} while (0)
|
|
||||||
#else
|
|
||||||
@@ -1460,8 +1478,10 @@ wasm_interp_dump_op_count()
|
|
||||||
const void *p_label_addr; \
|
|
||||||
bh_assert(((uintptr_t)frame_ip & 1) == 0); \
|
|
||||||
/* uint32 label address was emitted in 32-bit target */ \
|
|
||||||
+ const uint64 opc = LOAD_U32_WITH_2U16S(frame_ip); \
|
|
||||||
p_label_addr = (void *)(uintptr_t)LOAD_U32_WITH_2U16S(frame_ip); \
|
|
||||||
frame_ip += sizeof(int32); \
|
|
||||||
+ CHECK_INSTRUCTION_LIMIT(); \
|
|
||||||
goto *p_label_addr; \
|
|
||||||
} while (0)
|
} while (0)
|
||||||
#endif
|
#endif
|
||||||
@@ -1538,6 +1558,17 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
#endif /* end of WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS */
|
||||||
|
-#define HANDLE_OP_END() FETCH_OPCODE_AND_DISPATCH()
|
||||||
|
+#define HANDLE_OP_END() CHECK_INSTRUCTION_LIMIT(); FETCH_OPCODE_AND_DISPATCH()
|
||||||
|
|
||||||
|
#else /* else of WASM_ENABLE_LABELS_AS_VALUES */
|
||||||
|
|
||||||
|
#define HANDLE_OP(opcode) case opcode:
|
||||||
|
-#define HANDLE_OP_END() continue
|
||||||
|
+#define HANDLE_OP_END() \
|
||||||
|
+ CHECK_INSTRUCTION_LIMIT(); \
|
||||||
|
+ continue
|
||||||
|
|
||||||
|
#endif /* end of WASM_ENABLE_LABELS_AS_VALUES */
|
||||||
|
|
||||||
|
@@ -1538,6 +1553,16 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
||||||
uint8 *maddr = NULL;
|
uint8 *maddr = NULL;
|
||||||
uint32 local_idx, local_offset, global_idx;
|
uint32 local_idx, local_offset, global_idx;
|
||||||
uint8 opcode = 0, local_type, *global_addr;
|
uint8 opcode = 0, local_type, *global_addr;
|
||||||
@@ -367,8 +404,7 @@ index f33ad60e..a7078fe8 100644
|
|||||||
+#if WASM_ENABLE_INSTRUCTION_METERING != 0
|
+#if WASM_ENABLE_INSTRUCTION_METERING != 0
|
||||||
+ int64 instructions_to_execute = -1;
|
+ int64 instructions_to_execute = -1;
|
||||||
+ int64 const *instructions_schedule = NULL;
|
+ int64 const *instructions_schedule = NULL;
|
||||||
+ if(exec_env)
|
+ if (exec_env) {
|
||||||
+ {
|
|
||||||
+ instructions_to_execute = exec_env->instructions_to_execute;
|
+ instructions_to_execute = exec_env->instructions_to_execute;
|
||||||
+ instructions_schedule = exec_env->instructions_schedule;
|
+ instructions_schedule = exec_env->instructions_schedule;
|
||||||
+ }
|
+ }
|
||||||
@@ -377,29 +413,46 @@ index f33ad60e..a7078fe8 100644
|
|||||||
#if !defined(OS_ENABLE_HW_BOUND_CHECK) \
|
#if !defined(OS_ENABLE_HW_BOUND_CHECK) \
|
||||||
|| WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS == 0
|
|| WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS == 0
|
||||||
#if WASM_CONFIGURABLE_BOUNDS_CHECKS != 0
|
#if WASM_CONFIGURABLE_BOUNDS_CHECKS != 0
|
||||||
@@ -7761,6 +7792,11 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
@@ -7761,6 +7786,11 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
||||||
FREE_FRAME(exec_env, frame);
|
FREE_FRAME(exec_env, frame);
|
||||||
wasm_exec_env_set_cur_frame(exec_env, (WASMRuntimeFrame *)prev_frame);
|
wasm_exec_env_set_cur_frame(exec_env, (WASMRuntimeFrame *)prev_frame);
|
||||||
|
|
||||||
+#if WASM_ENABLE_INSTRUCTION_METERING != 0
|
+#if WASM_ENABLE_INSTRUCTION_METERING != 0
|
||||||
+ if(exec_env)
|
+ if (exec_env)
|
||||||
+ exec_env->instructions_to_execute = instructions_to_execute;
|
+ exec_env->instructions_to_execute = instructions_to_execute;
|
||||||
+#endif
|
+#endif
|
||||||
+
|
+
|
||||||
if (!prev_frame->ip)
|
if (!prev_frame->ip)
|
||||||
/* Called from native. */
|
/* Called from native. */
|
||||||
return;
|
return;
|
||||||
@@ -7789,6 +7825,10 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
@@ -7789,6 +7819,10 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
||||||
|
|
||||||
got_exception:
|
got_exception:
|
||||||
SYNC_ALL_TO_FRAME();
|
SYNC_ALL_TO_FRAME();
|
||||||
+#if WASM_ENABLE_INSTRUCTION_METERING != 0
|
+#if WASM_ENABLE_INSTRUCTION_METERING != 0
|
||||||
+ if(exec_env)
|
+ if (exec_env)
|
||||||
+ exec_env->instructions_to_execute = instructions_to_execute;
|
+ exec_env->instructions_to_execute = instructions_to_execute;
|
||||||
+#endif
|
+#endif
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#if WASM_ENABLE_LABELS_AS_VALUES == 0
|
#if WASM_ENABLE_LABELS_AS_VALUES == 0
|
||||||
|
diff --git a/core/shared/platform/include/platform_wasi_types.h b/core/shared/platform/include/platform_wasi_types.h
|
||||||
|
index ac1a95ea..e23b500e 100644
|
||||||
|
--- a/core/shared/platform/include/platform_wasi_types.h
|
||||||
|
+++ b/core/shared/platform/include/platform_wasi_types.h
|
||||||
|
@@ -36,7 +36,11 @@ extern "C" {
|
||||||
|
#if WASM_ENABLE_UVWASI != 0 || WASM_ENABLE_LIBC_WASI == 0
|
||||||
|
#define assert_wasi_layout(expr, message) /* nothing */
|
||||||
|
#else
|
||||||
|
-#define assert_wasi_layout(expr, message) _Static_assert(expr, message)
|
||||||
|
+ #ifndef _MSC_VER
|
||||||
|
+ #define assert_wasi_layout(expr, message) _Static_assert(expr, message)
|
||||||
|
+ #else
|
||||||
|
+ #define assert_wasi_layout(expr, message) static_assert(expr, message)
|
||||||
|
+ #endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
assert_wasi_layout(_Alignof(int8_t) == 1, "non-wasi data layout");
|
||||||
diff --git a/doc/build_wamr.md b/doc/build_wamr.md
|
diff --git a/doc/build_wamr.md b/doc/build_wamr.md
|
||||||
index 6425450b..94dd9628 100644
|
index 6425450b..94dd9628 100644
|
||||||
--- a/doc/build_wamr.md
|
--- a/doc/build_wamr.md
|
||||||
|
|||||||
@@ -31,10 +31,11 @@ static void
|
|||||||
print_wasm_error(const char* message, wasm_trap_t* trap)
|
print_wasm_error(const char* message, wasm_trap_t* trap)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "WAMR error: %s\n", message);
|
fprintf(stderr, "WAMR error: %s\n", message);
|
||||||
wasm_byte_vec_t error_message;
|
|
||||||
|
|
||||||
if (trap)
|
if (trap)
|
||||||
{
|
{
|
||||||
|
wasm_byte_vec_t error_message;
|
||||||
|
|
||||||
wasm_trap_message(trap, &error_message);
|
wasm_trap_message(trap, &error_message);
|
||||||
wasm_trap_delete(trap);
|
wasm_trap_delete(trap);
|
||||||
fprintf(
|
fprintf(
|
||||||
|
|||||||
@@ -57,11 +57,20 @@ runEscrowWasm(
|
|||||||
|
|
||||||
std::int64_t const sgas = gasLimit; // vm.getGas();
|
std::int64_t const sgas = gasLimit; // vm.getGas();
|
||||||
auto ret = vm.run(wasmCode, funcName, imports);
|
auto ret = vm.run(wasmCode, funcName, imports);
|
||||||
|
|
||||||
|
// std::cout << "runEscrowWasm, mod size: " << wasmCode.size()
|
||||||
|
// << ", gasLimit: " << gasLimit << ", funcName: " << funcName;
|
||||||
|
|
||||||
if (!ret.has_value())
|
if (!ret.has_value())
|
||||||
|
{
|
||||||
|
// std::cout << ", error: " << ret.error() << std::endl;
|
||||||
return Unexpected<TER>(ret.error());
|
return Unexpected<TER>(ret.error());
|
||||||
|
}
|
||||||
std::int64_t const egas = vm.getGas();
|
std::int64_t const egas = vm.getGas();
|
||||||
std::uint64_t const spent = static_cast<std::uint64_t>(sgas - egas);
|
std::uint64_t const spent = static_cast<std::uint64_t>(sgas - egas);
|
||||||
|
|
||||||
|
// std::cout << ", ret: " << ret.value() << ", gas spent: " << spent
|
||||||
|
// << std::endl;
|
||||||
return EscrowResult{static_cast<bool>(ret.value()), spent};
|
return EscrowResult{static_cast<bool>(ret.value()), spent};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user