mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-05-08 20:56:13 +00:00
Cumulative fixes for release/1.3.x (#3268)
Apply patches which were fixed branch main to branch `release/1.3.x`: - zephyr: Use zephyr sys_cache instead of CMSIS (#3162) - Fix llvm jit push funcref/externref result type issue (#3169) - Fix inconsistent coding convention (#3171) - VSCode IDE enhancement and readme update (#3172) - zephyr: include math only with minimal libc (#3177) - Fix wasm loader handling opcode br_table (#3176) - Specify language in the wasi socket ext project (#3183) - lldb_function_to_function_dbi: Fix a null dereference (#3189) - Fix LLVM assertion failure and update CONTRIBUTING.md (#3197) - lldb_function_to_function_dbi: A hack to avoid crashing on C++ methods (#3190) - Fix compilation errors on MinGW (#3217) - Fix compilation errors on esp-idf platform (#3224) - Fix aot relocation symbols not found on windows 32-bit (#3231) - Fix nightly run tsan ASLR issue (#3233) - Go binding: Change C.long to C.int64_t when call wasm_runtime_set_wasi_args_ex (#3235) - posix_file.c: Correct the dirfd argument that passes to fstatat (#3244) - Fix compilation errors on zephyr platform (#3255) - Fix dynamic offset not updated in op_br for block with ret type (#3269) - Fix CI error when install packages for macos-14 (#3270)
This commit is contained in:
parent
add9547324
commit
9e07aa6f9f
8
.github/workflows/build_llvm_libraries.yml
vendored
8
.github/workflows/build_llvm_libraries.yml
vendored
|
@ -33,10 +33,16 @@ jobs:
|
||||||
- name: checkout
|
- name: checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: install dependencies
|
- name: install dependencies for non macos-14
|
||||||
|
if: inputs.os != 'macos-14'
|
||||||
run: /usr/bin/env python3 -m pip install -r requirements.txt
|
run: /usr/bin/env python3 -m pip install -r requirements.txt
|
||||||
working-directory: build-scripts
|
working-directory: build-scripts
|
||||||
|
|
||||||
|
- name: install dependencies for macos-14
|
||||||
|
if: inputs.os == 'macos-14'
|
||||||
|
run: /usr/bin/env python3 -m pip install -r requirements.txt --break-system-packages
|
||||||
|
working-directory: build-scripts
|
||||||
|
|
||||||
- name: retrive the last commit ID
|
- name: retrive the last commit ID
|
||||||
id: get_last_commit
|
id: get_last_commit
|
||||||
run: echo "last_commit=$(GH_TOKEN=${{ secrets.GITHUB_TOKEN }} /usr/bin/env python3 ./build_llvm.py --llvm-ver)" >> $GITHUB_OUTPUT
|
run: echo "last_commit=$(GH_TOKEN=${{ secrets.GITHUB_TOKEN }} /usr/bin/env python3 ./build_llvm.py --llvm-ver)" >> $GITHUB_OUTPUT
|
||||||
|
|
|
@ -626,6 +626,12 @@ jobs:
|
||||||
npm install
|
npm install
|
||||||
working-directory: test-tools/wamr-ide/VSCode-Extension
|
working-directory: test-tools/wamr-ide/VSCode-Extension
|
||||||
|
|
||||||
|
- name: code style check
|
||||||
|
run: |
|
||||||
|
npm install --save-dev prettier
|
||||||
|
npm run prettier-format-check
|
||||||
|
working-directory: test-tools/wamr-ide/VSCode-Extension
|
||||||
|
|
||||||
- name: build iwasm with source debugging feature
|
- name: build iwasm with source debugging feature
|
||||||
run: |
|
run: |
|
||||||
mkdir build
|
mkdir build
|
||||||
|
|
4
.github/workflows/nightly_run.yml
vendored
4
.github/workflows/nightly_run.yml
vendored
|
@ -632,7 +632,9 @@ jobs:
|
||||||
run: echo "TEST_ON_X86_32=true" >> $GITHUB_ENV
|
run: echo "TEST_ON_X86_32=true" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: set additional tsan options
|
- name: set additional tsan options
|
||||||
run: echo "TSAN_OPTIONS=suppressions=$PWD/tsan_suppressions.txt" >> $GITHUB_ENV
|
run: |
|
||||||
|
echo "TSAN_OPTIONS=suppressions=$PWD/tsan_suppressions.txt" >> $GITHUB_ENV
|
||||||
|
sudo sysctl vm.mmap_rnd_bits=28
|
||||||
working-directory: tests/wamr-test-suites
|
working-directory: tests/wamr-test-suites
|
||||||
|
|
||||||
#only download llvm libraries in jit and aot mode
|
#only download llvm libraries in jit and aot mode
|
||||||
|
|
|
@ -151,7 +151,7 @@ if (WAMR_BUILD_WASM_CACHE EQUAL 1)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (MINGW)
|
if (MINGW)
|
||||||
target_link_libraries (iwasm_shared -lWs2_32)
|
target_link_libraries (iwasm_shared INTERFACE -lWs2_32 -lwsock32)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
install (TARGETS iwasm_shared LIBRARY DESTINATION lib)
|
install (TARGETS iwasm_shared LIBRARY DESTINATION lib)
|
||||||
|
|
|
@ -27,7 +27,7 @@ We Use Github Flow, So All Code Changes Happen Through Pull Requests. Pull reque
|
||||||
Coding Style
|
Coding Style
|
||||||
===============================
|
===============================
|
||||||
Please use [K&R](https://en.wikipedia.org/wiki/Indentation_style#K.26R) coding style, such as 4 spaces for indentation rather than tabs etc.
|
Please use [K&R](https://en.wikipedia.org/wiki/Indentation_style#K.26R) coding style, such as 4 spaces for indentation rather than tabs etc.
|
||||||
We suggest use Eclipse like IDE or stable coding format tools to make your code compliant to K&R format.
|
We suggest using VS Code like IDE or stable coding format tools, like clang-format, to make your code compliant to the customized format(in .clang-format).
|
||||||
|
|
||||||
Report bugs
|
Report bugs
|
||||||
===================
|
===================
|
||||||
|
|
|
@ -2072,6 +2072,17 @@ do_text_relocation(AOTModule *module, AOTRelocationGroup *group,
|
||||||
}
|
}
|
||||||
symbol_addr = module->func_ptrs[func_index];
|
symbol_addr = module->func_ptrs[func_index];
|
||||||
}
|
}
|
||||||
|
else if (!strncmp(symbol, "_" AOT_FUNC_INTERNAL_PREFIX,
|
||||||
|
strlen("_" AOT_FUNC_INTERNAL_PREFIX))) {
|
||||||
|
p = symbol + strlen("_" AOT_FUNC_INTERNAL_PREFIX);
|
||||||
|
if (*p == '\0'
|
||||||
|
|| (func_index = (uint32)atoi(p)) > module->func_count) {
|
||||||
|
set_error_buf_v(error_buf, error_buf_size, "invalid symbol %s",
|
||||||
|
symbol);
|
||||||
|
goto check_symbol_fail;
|
||||||
|
}
|
||||||
|
symbol_addr = module->func_ptrs[func_index];
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
else if (is_text_section(symbol)) {
|
else if (is_text_section(symbol)) {
|
||||||
symbol_addr = module->code;
|
symbol_addr = module->code;
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
#include "wasm_runtime_common.h"
|
#include "wasm_runtime_common.h"
|
||||||
#include "../interpreter/wasm_runtime.h"
|
#include "../interpreter/wasm_runtime.h"
|
||||||
#include "../aot/aot_runtime.h"
|
#include "../aot/aot_runtime.h"
|
||||||
#include "bh_platform.h"
|
|
||||||
#include "mem_alloc.h"
|
#include "mem_alloc.h"
|
||||||
#include "wasm_memory.h"
|
#include "wasm_memory.h"
|
||||||
|
|
||||||
|
@ -45,11 +44,11 @@ static unsigned int global_pool_size;
|
||||||
static bool
|
static bool
|
||||||
wasm_memory_init_with_pool(void *mem, unsigned int bytes)
|
wasm_memory_init_with_pool(void *mem, unsigned int bytes)
|
||||||
{
|
{
|
||||||
mem_allocator_t _allocator = mem_allocator_create(mem, bytes);
|
mem_allocator_t allocator = mem_allocator_create(mem, bytes);
|
||||||
|
|
||||||
if (_allocator) {
|
if (allocator) {
|
||||||
memory_mode = MEMORY_MODE_POOL;
|
memory_mode = MEMORY_MODE_POOL;
|
||||||
pool_allocator = _allocator;
|
pool_allocator = allocator;
|
||||||
global_pool_size = bytes;
|
global_pool_size = bytes;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -76,18 +75,18 @@ wasm_memory_init_with_allocator(void *_user_data, void *_malloc_func,
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static bool
|
static bool
|
||||||
wasm_memory_init_with_allocator(void *_malloc_func, void *_realloc_func,
|
wasm_memory_init_with_allocator(void *malloc_func_ptr, void *realloc_func_ptr,
|
||||||
void *_free_func)
|
void *free_func_ptr)
|
||||||
{
|
{
|
||||||
if (_malloc_func && _free_func && _malloc_func != _free_func) {
|
if (malloc_func_ptr && free_func_ptr && malloc_func_ptr != free_func_ptr) {
|
||||||
memory_mode = MEMORY_MODE_ALLOCATOR;
|
memory_mode = MEMORY_MODE_ALLOCATOR;
|
||||||
malloc_func = _malloc_func;
|
malloc_func = malloc_func_ptr;
|
||||||
realloc_func = _realloc_func;
|
realloc_func = realloc_func_ptr;
|
||||||
free_func = _free_func;
|
free_func = free_func_ptr;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
LOG_ERROR("Init memory with allocator (%p, %p, %p) failed.\n", _malloc_func,
|
LOG_ERROR("Init memory with allocator (%p, %p, %p) failed.\n",
|
||||||
_realloc_func, _free_func);
|
malloc_func_ptr, realloc_func_ptr, free_func_ptr);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -115,18 +114,13 @@ wasm_runtime_memory_init(mem_alloc_type_t mem_alloc_type,
|
||||||
alloc_option->pool.heap_size);
|
alloc_option->pool.heap_size);
|
||||||
}
|
}
|
||||||
else if (mem_alloc_type == Alloc_With_Allocator) {
|
else if (mem_alloc_type == Alloc_With_Allocator) {
|
||||||
|
return wasm_memory_init_with_allocator(
|
||||||
#if WASM_MEM_ALLOC_WITH_USER_DATA != 0
|
#if WASM_MEM_ALLOC_WITH_USER_DATA != 0
|
||||||
return wasm_memory_init_with_allocator(
|
|
||||||
alloc_option->allocator.user_data,
|
alloc_option->allocator.user_data,
|
||||||
alloc_option->allocator.malloc_func,
|
|
||||||
alloc_option->allocator.realloc_func,
|
|
||||||
alloc_option->allocator.free_func);
|
|
||||||
#else
|
|
||||||
return wasm_memory_init_with_allocator(
|
|
||||||
alloc_option->allocator.malloc_func,
|
|
||||||
alloc_option->allocator.realloc_func,
|
|
||||||
alloc_option->allocator.free_func);
|
|
||||||
#endif
|
#endif
|
||||||
|
alloc_option->allocator.malloc_func,
|
||||||
|
alloc_option->allocator.realloc_func,
|
||||||
|
alloc_option->allocator.free_func);
|
||||||
}
|
}
|
||||||
else if (mem_alloc_type == Alloc_With_System_Allocator) {
|
else if (mem_alloc_type == Alloc_With_System_Allocator) {
|
||||||
memory_mode = MEMORY_MODE_SYSTEM_ALLOCATOR;
|
memory_mode = MEMORY_MODE_SYSTEM_ALLOCATOR;
|
||||||
|
|
|
@ -3574,7 +3574,7 @@ wasm_runtime_invoke_native_raw(WASMExecEnv *exec_env, void *func_ptr,
|
||||||
{
|
{
|
||||||
WASMModuleInstanceCommon *module = wasm_runtime_get_module_inst(exec_env);
|
WASMModuleInstanceCommon *module = wasm_runtime_get_module_inst(exec_env);
|
||||||
typedef void (*NativeRawFuncPtr)(WASMExecEnv *, uint64 *);
|
typedef void (*NativeRawFuncPtr)(WASMExecEnv *, uint64 *);
|
||||||
NativeRawFuncPtr invokeNativeRaw = (NativeRawFuncPtr)func_ptr;
|
NativeRawFuncPtr invoke_native_raw = (NativeRawFuncPtr)func_ptr;
|
||||||
uint64 argv_buf[16] = { 0 }, *argv1 = argv_buf, *argv_dst, size;
|
uint64 argv_buf[16] = { 0 }, *argv1 = argv_buf, *argv_dst, size;
|
||||||
uint32 *argv_src = argv, i, argc1, ptr_len;
|
uint32 *argv_src = argv, i, argc1, ptr_len;
|
||||||
uint32 arg_i32;
|
uint32 arg_i32;
|
||||||
|
@ -3662,7 +3662,7 @@ wasm_runtime_invoke_native_raw(WASMExecEnv *exec_env, void *func_ptr,
|
||||||
}
|
}
|
||||||
|
|
||||||
exec_env->attachment = attachment;
|
exec_env->attachment = attachment;
|
||||||
invokeNativeRaw(exec_env, argv1);
|
invoke_native_raw(exec_env, argv1);
|
||||||
exec_env->attachment = NULL;
|
exec_env->attachment = NULL;
|
||||||
|
|
||||||
if (func_type->result_count > 0) {
|
if (func_type->result_count > 0) {
|
||||||
|
|
|
@ -232,14 +232,14 @@ destroy_wait_info(void *wait_info)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
map_try_release_wait_info(HashMap *wait_map_, AtomicWaitInfo *wait_info,
|
map_try_release_wait_info(HashMap *wait_hash_map, AtomicWaitInfo *wait_info,
|
||||||
void *address)
|
void *address)
|
||||||
{
|
{
|
||||||
if (wait_info->wait_list->len > 0) {
|
if (wait_info->wait_list->len > 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bh_hash_map_remove(wait_map_, address, NULL, NULL);
|
bh_hash_map_remove(wait_hash_map, address, NULL, NULL);
|
||||||
destroy_wait_info(wait_info);
|
destroy_wait_info(wait_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -203,7 +203,12 @@ check_type_compatible(uint8 src_type, uint8 dst_type)
|
||||||
goto fail; \
|
goto fail; \
|
||||||
} \
|
} \
|
||||||
memset(aot_value, 0, sizeof(AOTValue)); \
|
memset(aot_value, 0, sizeof(AOTValue)); \
|
||||||
aot_value->type = value_type; \
|
if (comp_ctx->enable_ref_types \
|
||||||
|
&& (value_type == VALUE_TYPE_FUNCREF \
|
||||||
|
|| value_type == VALUE_TYPE_EXTERNREF)) \
|
||||||
|
aot_value->type = VALUE_TYPE_I32; \
|
||||||
|
else \
|
||||||
|
aot_value->type = value_type; \
|
||||||
aot_value->value = llvm_value; \
|
aot_value->value = llvm_value; \
|
||||||
aot_value_stack_push( \
|
aot_value_stack_push( \
|
||||||
&func_ctx->block_stack.block_list_end->value_stack, aot_value); \
|
&func_ctx->block_stack.block_list_end->value_stack, aot_value); \
|
||||||
|
|
|
@ -1004,28 +1004,28 @@ exchange_uint32(uint8 *p_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
exchange_uint64(uint8 *pData)
|
exchange_uint64(uint8 *p_data)
|
||||||
{
|
{
|
||||||
uint32 value;
|
uint32 value;
|
||||||
|
|
||||||
value = *(uint32 *)pData;
|
value = *(uint32 *)p_data;
|
||||||
*(uint32 *)pData = *(uint32 *)(pData + 4);
|
*(uint32 *)p_data = *(uint32 *)(p_data + 4);
|
||||||
*(uint32 *)(pData + 4) = value;
|
*(uint32 *)(p_data + 4) = value;
|
||||||
exchange_uint32(pData);
|
exchange_uint32(p_data);
|
||||||
exchange_uint32(pData + 4);
|
exchange_uint32(p_data + 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
exchange_uint128(uint8 *pData)
|
exchange_uint128(uint8 *p_data)
|
||||||
{
|
{
|
||||||
/* swap high 64bit and low 64bit */
|
/* swap high 64bit and low 64bit */
|
||||||
uint64 value = *(uint64 *)pData;
|
uint64 value = *(uint64 *)p_data;
|
||||||
*(uint64 *)pData = *(uint64 *)(pData + 8);
|
*(uint64 *)p_data = *(uint64 *)(p_data + 8);
|
||||||
*(uint64 *)(pData + 8) = value;
|
*(uint64 *)(p_data + 8) = value;
|
||||||
/* exchange high 64bit */
|
/* exchange high 64bit */
|
||||||
exchange_uint64(pData);
|
exchange_uint64(p_data);
|
||||||
/* exchange low 64bit */
|
/* exchange low 64bit */
|
||||||
exchange_uint64(pData + 8);
|
exchange_uint64(p_data + 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
static union {
|
static union {
|
||||||
|
@ -3106,7 +3106,12 @@ aot_resolve_object_relocation_group(AOTObjectData *obj_data,
|
||||||
* Note: aot_stack_sizes_section_name section only contains
|
* Note: aot_stack_sizes_section_name section only contains
|
||||||
* stack_sizes table.
|
* stack_sizes table.
|
||||||
*/
|
*/
|
||||||
if (!strcmp(relocation->symbol_name, aot_stack_sizes_name)) {
|
if (!strcmp(relocation->symbol_name, aot_stack_sizes_name)
|
||||||
|
/* in windows 32, the symbol name may start with '_' */
|
||||||
|
|| (strlen(relocation->symbol_name) > 0
|
||||||
|
&& relocation->symbol_name[0] == '_'
|
||||||
|
&& !strcmp(relocation->symbol_name + 1,
|
||||||
|
aot_stack_sizes_name))) {
|
||||||
/* discard const */
|
/* discard const */
|
||||||
relocation->symbol_name = (char *)aot_stack_sizes_section_name;
|
relocation->symbol_name = (char *)aot_stack_sizes_section_name;
|
||||||
}
|
}
|
||||||
|
|
|
@ -619,7 +619,7 @@ aot_add_llvm_func(AOTCompContext *comp_ctx, LLVMModuleRef module,
|
||||||
const char *prefix = AOT_FUNC_PREFIX;
|
const char *prefix = AOT_FUNC_PREFIX;
|
||||||
const bool need_precheck =
|
const bool need_precheck =
|
||||||
comp_ctx->enable_stack_bound_check || comp_ctx->enable_stack_estimation;
|
comp_ctx->enable_stack_bound_check || comp_ctx->enable_stack_estimation;
|
||||||
LLVMValueRef precheck_func;
|
LLVMValueRef precheck_func = NULL;
|
||||||
if (need_precheck) {
|
if (need_precheck) {
|
||||||
precheck_func = aot_add_llvm_func1(comp_ctx, module, func_index,
|
precheck_func = aot_add_llvm_func1(comp_ctx, module, func_index,
|
||||||
aot_func_type->param_count,
|
aot_func_type->param_count,
|
||||||
|
|
|
@ -354,10 +354,27 @@ lldb_function_to_function_dbi(const AOTCompContext *comp_ctx,
|
||||||
LLVMDIBuilderCreateExpression(DIB, NULL, 0);
|
LLVMDIBuilderCreateExpression(DIB, NULL, 0);
|
||||||
auto variable_list =
|
auto variable_list =
|
||||||
function.GetBlock().GetVariables(extractor->target, true, false, false);
|
function.GetBlock().GetVariables(extractor->target, true, false, false);
|
||||||
|
unsigned int variable_offset = 0;
|
||||||
if (num_function_args != variable_list.GetSize()) {
|
if (num_function_args != variable_list.GetSize()) {
|
||||||
LOG_ERROR(
|
// A hack to detect C++ "this" pointer.
|
||||||
"function args number dismatch!:value number=%d, function args=%d",
|
//
|
||||||
variable_list.GetSize(), num_function_args);
|
// REVISIT: is there a more reliable way?
|
||||||
|
// At the DWARF level, we can probably look at DW_AT_object_pointer
|
||||||
|
// and DW_AT_artificial. I'm not sure how it can be done via the
|
||||||
|
// LLDB API though.
|
||||||
|
if (num_function_args + 1 == variable_list.GetSize()) {
|
||||||
|
SBValue variable(variable_list.GetValueAtIndex(0));
|
||||||
|
const char *varname = variable.GetName();
|
||||||
|
if (varname != NULL && !strcmp(varname, "this")) {
|
||||||
|
variable_offset = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!variable_offset) {
|
||||||
|
LOG_ERROR("function args number dismatch!:function %s %s value "
|
||||||
|
"number=%d, function args=%d",
|
||||||
|
function_name, function.GetMangledName(),
|
||||||
|
variable_list.GetSize(), num_function_args);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LLVMMetadataRef ParamLocation = LLVMDIBuilderCreateDebugLocation(
|
LLVMMetadataRef ParamLocation = LLVMDIBuilderCreateDebugLocation(
|
||||||
|
@ -378,23 +395,24 @@ lldb_function_to_function_dbi(const AOTCompContext *comp_ctx,
|
||||||
LLVMDIBuilderInsertDbgValueAtEnd(DIB, Param, ParamVar, ParamExpression,
|
LLVMDIBuilderInsertDbgValueAtEnd(DIB, Param, ParamVar, ParamExpression,
|
||||||
ParamLocation, block_curr);
|
ParamLocation, block_curr);
|
||||||
|
|
||||||
for (uint32_t function_arg_idx = 0;
|
for (uint32_t function_arg_idx = 0; function_arg_idx < num_function_args;
|
||||||
function_arg_idx < variable_list.GetSize(); ++function_arg_idx) {
|
++function_arg_idx) {
|
||||||
SBValue variable(variable_list.GetValueAtIndex(function_arg_idx));
|
uint32_t variable_idx = variable_offset + function_arg_idx;
|
||||||
|
SBValue variable(variable_list.GetValueAtIndex(variable_idx));
|
||||||
if (variable.IsValid()) {
|
if (variable.IsValid()) {
|
||||||
SBDeclaration dec(variable.GetDeclaration());
|
SBDeclaration dec(variable.GetDeclaration());
|
||||||
auto valtype = variable.GetType();
|
auto valtype = variable.GetType();
|
||||||
LLVMMetadataRef ParamLocation = LLVMDIBuilderCreateDebugLocation(
|
LLVMMetadataRef ParamLocation = LLVMDIBuilderCreateDebugLocation(
|
||||||
comp_ctx->context, dec.GetLine(), dec.GetColumn(),
|
comp_ctx->context, dec.GetLine(), dec.GetColumn(),
|
||||||
FunctionMetadata, NULL);
|
FunctionMetadata, NULL);
|
||||||
|
const char *varname = variable.GetName();
|
||||||
LLVMMetadataRef ParamVar = LLVMDIBuilderCreateParameterVariable(
|
LLVMMetadataRef ParamVar = LLVMDIBuilderCreateParameterVariable(
|
||||||
DIB, FunctionMetadata, variable.GetName(),
|
DIB, FunctionMetadata, varname, varname ? strlen(varname) : 0,
|
||||||
strlen(variable.GetName()), function_arg_idx + 1 + 1,
|
variable_idx + 1 + 1,
|
||||||
File, // starts form 1, and 1 is exenv,
|
File, // starts form 1, and 1 is exenv,
|
||||||
dec.GetLine(), ParamTypes[function_arg_idx + 1], true,
|
dec.GetLine(), ParamTypes[function_arg_idx + 1], true,
|
||||||
LLVMDIFlagZero);
|
LLVMDIFlagZero);
|
||||||
LLVMValueRef Param =
|
LLVMValueRef Param = LLVMGetParam(func_ctx->func, variable_idx + 1);
|
||||||
LLVMGetParam(func_ctx->func, function_arg_idx + 1);
|
|
||||||
LLVMDIBuilderInsertDbgValueAtEnd(DIB, Param, ParamVar,
|
LLVMDIBuilderInsertDbgValueAtEnd(DIB, Param, ParamVar,
|
||||||
ParamExpression, ParamLocation,
|
ParamExpression, ParamLocation,
|
||||||
block_curr);
|
block_curr);
|
||||||
|
|
|
@ -1101,7 +1101,7 @@ jit_compile_op_br_if(JitCompContext *cc, uint32 br_depth,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Only opy parameters or results when their count > 0 and
|
/* Only copy parameters or results when their count > 0 and
|
||||||
the src/dst addr are different */
|
the src/dst addr are different */
|
||||||
copy_arities = check_copy_arities(block_dst, jit_frame);
|
copy_arities = check_copy_arities(block_dst, jit_frame);
|
||||||
|
|
||||||
|
|
|
@ -3844,7 +3844,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
||||||
#if WASM_ENABLE_SHARED_MEMORY != 0
|
#if WASM_ENABLE_SHARED_MEMORY != 0
|
||||||
HANDLE_OP(WASM_OP_ATOMIC_PREFIX)
|
HANDLE_OP(WASM_OP_ATOMIC_PREFIX)
|
||||||
{
|
{
|
||||||
uint32 offset = 0, align, addr;
|
uint32 offset = 0, align = 0, addr;
|
||||||
uint32 opcode1;
|
uint32 opcode1;
|
||||||
|
|
||||||
read_leb_uint32(frame_ip, frame_ip_end, opcode1);
|
read_leb_uint32(frame_ip, frame_ip_end, opcode1);
|
||||||
|
|
|
@ -5832,11 +5832,11 @@ fail:
|
||||||
wasm_loader_emit_ptr(loader_ctx, NULL); \
|
wasm_loader_emit_ptr(loader_ctx, NULL); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define emit_br_info(frame_csp) \
|
#define emit_br_info(frame_csp, is_br) \
|
||||||
do { \
|
do { \
|
||||||
if (!wasm_loader_emit_br_info(loader_ctx, frame_csp, error_buf, \
|
if (!wasm_loader_emit_br_info(loader_ctx, frame_csp, is_br, error_buf, \
|
||||||
error_buf_size)) \
|
error_buf_size)) \
|
||||||
goto fail; \
|
goto fail; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define LAST_OP_OUTPUT_I32() \
|
#define LAST_OP_OUTPUT_I32() \
|
||||||
|
@ -6223,7 +6223,7 @@ apply_label_patch(WASMLoaderContext *ctx, uint8 depth, uint8 patch_type)
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
wasm_loader_emit_br_info(WASMLoaderContext *ctx, BranchBlock *frame_csp,
|
wasm_loader_emit_br_info(WASMLoaderContext *ctx, BranchBlock *frame_csp,
|
||||||
char *error_buf, uint32 error_buf_size)
|
bool is_br, char *error_buf, uint32 error_buf_size)
|
||||||
{
|
{
|
||||||
/* br info layout:
|
/* br info layout:
|
||||||
* a) arity of target block
|
* a) arity of target block
|
||||||
|
@ -6271,6 +6271,8 @@ wasm_loader_emit_br_info(WASMLoaderContext *ctx, BranchBlock *frame_csp,
|
||||||
/* Part e */
|
/* Part e */
|
||||||
dynamic_offset =
|
dynamic_offset =
|
||||||
frame_csp->dynamic_offset + wasm_get_cell_num(types, arity);
|
frame_csp->dynamic_offset + wasm_get_cell_num(types, arity);
|
||||||
|
if (is_br)
|
||||||
|
ctx->dynamic_offset = dynamic_offset;
|
||||||
for (i = (int32)arity - 1; i >= 0; i--) {
|
for (i = (int32)arity - 1; i >= 0; i--) {
|
||||||
cell = (uint8)wasm_value_type_cell_num(types[i]);
|
cell = (uint8)wasm_value_type_cell_num(types[i]);
|
||||||
dynamic_offset -= cell;
|
dynamic_offset -= cell;
|
||||||
|
@ -6872,13 +6874,6 @@ fail:
|
||||||
local_offset = local_offsets[local_idx]; \
|
local_offset = local_offsets[local_idx]; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define CHECK_BR(depth) \
|
|
||||||
do { \
|
|
||||||
if (!wasm_loader_check_br(loader_ctx, depth, error_buf, \
|
|
||||||
error_buf_size)) \
|
|
||||||
goto fail; \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
check_memory(WASMModule *module, char *error_buf, uint32 error_buf_size)
|
check_memory(WASMModule *module, char *error_buf, uint32 error_buf_size)
|
||||||
{
|
{
|
||||||
|
@ -7061,7 +7056,7 @@ check_memory_align_equal(uint8 opcode, uint32 align, char *error_buf,
|
||||||
#endif /* end of WASM_ENABLE_SHARED_MEMORY */
|
#endif /* end of WASM_ENABLE_SHARED_MEMORY */
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
wasm_loader_check_br(WASMLoaderContext *loader_ctx, uint32 depth,
|
wasm_loader_check_br(WASMLoaderContext *loader_ctx, uint32 depth, uint8 opcode,
|
||||||
char *error_buf, uint32 error_buf_size)
|
char *error_buf, uint32 error_buf_size)
|
||||||
{
|
{
|
||||||
BranchBlock *target_block, *cur_block;
|
BranchBlock *target_block, *cur_block;
|
||||||
|
@ -7071,6 +7066,20 @@ wasm_loader_check_br(WASMLoaderContext *loader_ctx, uint32 depth,
|
||||||
int32 i, available_stack_cell;
|
int32 i, available_stack_cell;
|
||||||
uint16 cell_num;
|
uint16 cell_num;
|
||||||
|
|
||||||
|
uint8 *frame_ref_old = loader_ctx->frame_ref;
|
||||||
|
uint8 *frame_ref_after_popped = NULL;
|
||||||
|
uint8 frame_ref_tmp[4] = { 0 };
|
||||||
|
uint8 *frame_ref_buf = frame_ref_tmp;
|
||||||
|
uint32 stack_cell_num_old = loader_ctx->stack_cell_num;
|
||||||
|
#if WASM_ENABLE_FAST_INTERP != 0
|
||||||
|
int16 *frame_offset_old = loader_ctx->frame_offset;
|
||||||
|
int16 *frame_offset_after_popped = NULL;
|
||||||
|
int16 frame_offset_tmp[4] = { 0 };
|
||||||
|
int16 *frame_offset_buf = frame_offset_tmp;
|
||||||
|
uint16 dynamic_offset_old = (loader_ctx->frame_csp - 1)->dynamic_offset;
|
||||||
|
#endif
|
||||||
|
bool ret = false;
|
||||||
|
|
||||||
bh_assert(loader_ctx->csp_num > 0);
|
bh_assert(loader_ctx->csp_num > 0);
|
||||||
if (loader_ctx->csp_num - 1 < depth) {
|
if (loader_ctx->csp_num - 1 < depth) {
|
||||||
set_error_buf(error_buf, error_buf_size,
|
set_error_buf(error_buf, error_buf_size,
|
||||||
|
@ -7102,6 +7111,38 @@ wasm_loader_check_br(WASMLoaderContext *loader_ctx, uint32 depth,
|
||||||
#endif
|
#endif
|
||||||
POP_TYPE(types[i]);
|
POP_TYPE(types[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Backup stack data since it may be changed in the below
|
||||||
|
push operations, and the stack data may be used when
|
||||||
|
checking other target blocks of opcode br_table */
|
||||||
|
if (opcode == WASM_OP_BR_TABLE) {
|
||||||
|
uint64 total_size;
|
||||||
|
|
||||||
|
frame_ref_after_popped = loader_ctx->frame_ref;
|
||||||
|
total_size = (uint64)sizeof(uint8)
|
||||||
|
* (frame_ref_old - frame_ref_after_popped);
|
||||||
|
if (total_size > sizeof(frame_ref_tmp)
|
||||||
|
&& !(frame_ref_buf = loader_malloc(total_size, error_buf,
|
||||||
|
error_buf_size))) {
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
bh_memcpy_s(frame_ref_buf, (uint32)total_size,
|
||||||
|
frame_ref_after_popped, (uint32)total_size);
|
||||||
|
|
||||||
|
#if WASM_ENABLE_FAST_INTERP != 0
|
||||||
|
frame_offset_after_popped = loader_ctx->frame_offset;
|
||||||
|
total_size = (uint64)sizeof(int16)
|
||||||
|
* (frame_offset_old - frame_offset_after_popped);
|
||||||
|
if (total_size > sizeof(frame_offset_tmp)
|
||||||
|
&& !(frame_offset_buf = loader_malloc(total_size, error_buf,
|
||||||
|
error_buf_size))) {
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
bh_memcpy_s(frame_offset_buf, (uint32)total_size,
|
||||||
|
frame_offset_after_popped, (uint32)total_size);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < (int32)arity; i++) {
|
for (i = 0; i < (int32)arity; i++) {
|
||||||
#if WASM_ENABLE_FAST_INTERP != 0
|
#if WASM_ENABLE_FAST_INTERP != 0
|
||||||
bool disable_emit = true;
|
bool disable_emit = true;
|
||||||
|
@ -7110,7 +7151,41 @@ wasm_loader_check_br(WASMLoaderContext *loader_ctx, uint32 depth,
|
||||||
#endif
|
#endif
|
||||||
PUSH_TYPE(types[i]);
|
PUSH_TYPE(types[i]);
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
|
#if WASM_ENABLE_FAST_INTERP != 0
|
||||||
|
emit_br_info(target_block, opcode == WASM_OP_BR);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Restore the stack data, note that frame_ref_bottom,
|
||||||
|
frame_offset_bottom may be re-allocated in the above
|
||||||
|
push operations */
|
||||||
|
if (opcode == WASM_OP_BR_TABLE) {
|
||||||
|
uint32 total_size;
|
||||||
|
|
||||||
|
/* The stack operand num should not be smaller than before
|
||||||
|
after pop and push operations */
|
||||||
|
bh_assert(loader_ctx->stack_cell_num >= stack_cell_num_old);
|
||||||
|
loader_ctx->stack_cell_num = stack_cell_num_old;
|
||||||
|
loader_ctx->frame_ref =
|
||||||
|
loader_ctx->frame_ref_bottom + stack_cell_num_old;
|
||||||
|
total_size = (uint32)sizeof(uint8)
|
||||||
|
* (frame_ref_old - frame_ref_after_popped);
|
||||||
|
bh_memcpy_s((uint8 *)loader_ctx->frame_ref - total_size, total_size,
|
||||||
|
frame_ref_buf, total_size);
|
||||||
|
|
||||||
|
#if WASM_ENABLE_FAST_INTERP != 0
|
||||||
|
loader_ctx->frame_offset =
|
||||||
|
loader_ctx->frame_offset_bottom + stack_cell_num_old;
|
||||||
|
total_size = (uint32)sizeof(int16)
|
||||||
|
* (frame_offset_old - frame_offset_after_popped);
|
||||||
|
bh_memcpy_s((uint8 *)loader_ctx->frame_offset - total_size,
|
||||||
|
total_size, frame_offset_buf, total_size);
|
||||||
|
(loader_ctx->frame_csp - 1)->dynamic_offset = dynamic_offset_old;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = true;
|
||||||
|
goto cleanup_and_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
available_stack_cell =
|
available_stack_cell =
|
||||||
|
@ -7120,32 +7195,46 @@ wasm_loader_check_br(WASMLoaderContext *loader_ctx, uint32 depth,
|
||||||
for (i = (int32)arity - 1; i >= 0; i--) {
|
for (i = (int32)arity - 1; i >= 0; i--) {
|
||||||
if (!check_stack_top_values(frame_ref, available_stack_cell, types[i],
|
if (!check_stack_top_values(frame_ref, available_stack_cell, types[i],
|
||||||
error_buf, error_buf_size))
|
error_buf, error_buf_size))
|
||||||
return false;
|
goto fail;
|
||||||
cell_num = wasm_value_type_cell_num(types[i]);
|
cell_num = wasm_value_type_cell_num(types[i]);
|
||||||
frame_ref -= cell_num;
|
frame_ref -= cell_num;
|
||||||
available_stack_cell -= cell_num;
|
available_stack_cell -= cell_num;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
#if WASM_ENABLE_FAST_INTERP != 0
|
||||||
|
emit_br_info(target_block, opcode == WASM_OP_BR);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ret = true;
|
||||||
|
|
||||||
|
cleanup_and_return:
|
||||||
fail:
|
fail:
|
||||||
return false;
|
if (frame_ref_buf && frame_ref_buf != frame_ref_tmp)
|
||||||
|
wasm_runtime_free(frame_ref_buf);
|
||||||
|
#if WASM_ENABLE_FAST_INTERP != 0
|
||||||
|
if (frame_offset_buf && frame_offset_buf != frame_offset_tmp)
|
||||||
|
wasm_runtime_free(frame_offset_buf);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BranchBlock *
|
static BranchBlock *
|
||||||
check_branch_block(WASMLoaderContext *loader_ctx, uint8 **p_buf, uint8 *buf_end,
|
check_branch_block(WASMLoaderContext *loader_ctx, uint8 **p_buf, uint8 *buf_end,
|
||||||
char *error_buf, uint32 error_buf_size)
|
uint8 opcode, char *error_buf, uint32 error_buf_size)
|
||||||
{
|
{
|
||||||
uint8 *p = *p_buf, *p_end = buf_end;
|
uint8 *p = *p_buf, *p_end = buf_end;
|
||||||
BranchBlock *frame_csp_tmp;
|
BranchBlock *frame_csp_tmp;
|
||||||
uint32 depth;
|
uint32 depth;
|
||||||
|
|
||||||
read_leb_uint32(p, p_end, depth);
|
read_leb_uint32(p, p_end, depth);
|
||||||
CHECK_BR(depth);
|
bh_assert(loader_ctx->csp_num > 0);
|
||||||
|
if (!wasm_loader_check_br(loader_ctx, depth, opcode, error_buf,
|
||||||
|
error_buf_size)) {
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
frame_csp_tmp = loader_ctx->frame_csp - depth - 1;
|
frame_csp_tmp = loader_ctx->frame_csp - depth - 1;
|
||||||
#if WASM_ENABLE_FAST_INTERP != 0
|
|
||||||
emit_br_info(frame_csp_tmp);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
*p_buf = p;
|
*p_buf = p;
|
||||||
return frame_csp_tmp;
|
return frame_csp_tmp;
|
||||||
|
@ -7876,8 +7965,9 @@ re_scan:
|
||||||
SET_CUR_BLOCK_STACK_POLYMORPHIC_STATE(true);
|
SET_CUR_BLOCK_STACK_POLYMORPHIC_STATE(true);
|
||||||
|
|
||||||
/* check the target catching block: LABEL_TYPE_CATCH */
|
/* check the target catching block: LABEL_TYPE_CATCH */
|
||||||
if (!(frame_csp_tmp = check_branch_block(
|
if (!(frame_csp_tmp =
|
||||||
loader_ctx, &p, p_end, error_buf, error_buf_size)))
|
check_branch_block(loader_ctx, &p, p_end, opcode,
|
||||||
|
error_buf, error_buf_size)))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (frame_csp_tmp->label_type != LABEL_TYPE_CATCH
|
if (frame_csp_tmp->label_type != LABEL_TYPE_CATCH
|
||||||
|
@ -8132,8 +8222,9 @@ re_scan:
|
||||||
|
|
||||||
case WASM_OP_BR:
|
case WASM_OP_BR:
|
||||||
{
|
{
|
||||||
if (!(frame_csp_tmp = check_branch_block(
|
if (!(frame_csp_tmp =
|
||||||
loader_ctx, &p, p_end, error_buf, error_buf_size)))
|
check_branch_block(loader_ctx, &p, p_end, opcode,
|
||||||
|
error_buf, error_buf_size)))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
RESET_STACK();
|
RESET_STACK();
|
||||||
|
@ -8145,8 +8236,9 @@ re_scan:
|
||||||
{
|
{
|
||||||
POP_I32();
|
POP_I32();
|
||||||
|
|
||||||
if (!(frame_csp_tmp = check_branch_block(
|
if (!(frame_csp_tmp =
|
||||||
loader_ctx, &p, p_end, error_buf, error_buf_size)))
|
check_branch_block(loader_ctx, &p, p_end, opcode,
|
||||||
|
error_buf, error_buf_size)))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -8158,7 +8250,7 @@ re_scan:
|
||||||
uint32 ret_count = 0;
|
uint32 ret_count = 0;
|
||||||
#if WASM_ENABLE_FAST_INTERP == 0
|
#if WASM_ENABLE_FAST_INTERP == 0
|
||||||
uint8 *p_depth_begin, *p_depth;
|
uint8 *p_depth_begin, *p_depth;
|
||||||
uint32 depth, j;
|
uint32 depth = 0, j;
|
||||||
BrTableCache *br_table_cache = NULL;
|
BrTableCache *br_table_cache = NULL;
|
||||||
|
|
||||||
p_org = p - 1;
|
p_org = p - 1;
|
||||||
|
@ -8175,7 +8267,7 @@ re_scan:
|
||||||
#endif
|
#endif
|
||||||
for (i = 0; i <= count; i++) {
|
for (i = 0; i <= count; i++) {
|
||||||
if (!(frame_csp_tmp =
|
if (!(frame_csp_tmp =
|
||||||
check_branch_block(loader_ctx, &p, p_end,
|
check_branch_block(loader_ctx, &p, p_end, opcode,
|
||||||
error_buf, error_buf_size)))
|
error_buf, error_buf_size)))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
|
|
@ -4087,11 +4087,11 @@ wasm_loader_pop_frame_csp(WASMLoaderContext *ctx, char *error_buf,
|
||||||
wasm_loader_emit_ptr(loader_ctx, NULL); \
|
wasm_loader_emit_ptr(loader_ctx, NULL); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define emit_br_info(frame_csp) \
|
#define emit_br_info(frame_csp, is_br) \
|
||||||
do { \
|
do { \
|
||||||
if (!wasm_loader_emit_br_info(loader_ctx, frame_csp, error_buf, \
|
if (!wasm_loader_emit_br_info(loader_ctx, frame_csp, is_br, error_buf, \
|
||||||
error_buf_size)) \
|
error_buf_size)) \
|
||||||
goto fail; \
|
goto fail; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define LAST_OP_OUTPUT_I32() \
|
#define LAST_OP_OUTPUT_I32() \
|
||||||
|
@ -4476,7 +4476,7 @@ apply_label_patch(WASMLoaderContext *ctx, uint8 depth, uint8 patch_type)
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
wasm_loader_emit_br_info(WASMLoaderContext *ctx, BranchBlock *frame_csp,
|
wasm_loader_emit_br_info(WASMLoaderContext *ctx, BranchBlock *frame_csp,
|
||||||
char *error_buf, uint32 error_buf_size)
|
bool is_br, char *error_buf, uint32 error_buf_size)
|
||||||
{
|
{
|
||||||
/* br info layout:
|
/* br info layout:
|
||||||
* a) arity of target block
|
* a) arity of target block
|
||||||
|
@ -4525,6 +4525,8 @@ wasm_loader_emit_br_info(WASMLoaderContext *ctx, BranchBlock *frame_csp,
|
||||||
/* Part e */
|
/* Part e */
|
||||||
dynamic_offset =
|
dynamic_offset =
|
||||||
frame_csp->dynamic_offset + wasm_get_cell_num(types, arity);
|
frame_csp->dynamic_offset + wasm_get_cell_num(types, arity);
|
||||||
|
if (is_br)
|
||||||
|
ctx->dynamic_offset = dynamic_offset;
|
||||||
for (i = (int32)arity - 1; i >= 0; i--) {
|
for (i = (int32)arity - 1; i >= 0; i--) {
|
||||||
cell = (uint8)wasm_value_type_cell_num(types[i]);
|
cell = (uint8)wasm_value_type_cell_num(types[i]);
|
||||||
dynamic_offset -= cell;
|
dynamic_offset -= cell;
|
||||||
|
@ -5203,20 +5205,13 @@ fail:
|
||||||
local_offset = local_offsets[local_idx]; \
|
local_offset = local_offsets[local_idx]; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define CHECK_BR(depth) \
|
|
||||||
do { \
|
|
||||||
if (!wasm_loader_check_br(loader_ctx, depth, error_buf, \
|
|
||||||
error_buf_size)) \
|
|
||||||
goto fail; \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define CHECK_MEMORY() \
|
#define CHECK_MEMORY() \
|
||||||
do { \
|
do { \
|
||||||
bh_assert(module->import_memory_count + module->memory_count > 0); \
|
bh_assert(module->import_memory_count + module->memory_count > 0); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
wasm_loader_check_br(WASMLoaderContext *loader_ctx, uint32 depth,
|
wasm_loader_check_br(WASMLoaderContext *loader_ctx, uint32 depth, uint8 opcode,
|
||||||
char *error_buf, uint32 error_buf_size)
|
char *error_buf, uint32 error_buf_size)
|
||||||
{
|
{
|
||||||
BranchBlock *target_block, *cur_block;
|
BranchBlock *target_block, *cur_block;
|
||||||
|
@ -5226,6 +5221,20 @@ wasm_loader_check_br(WASMLoaderContext *loader_ctx, uint32 depth,
|
||||||
int32 i, available_stack_cell;
|
int32 i, available_stack_cell;
|
||||||
uint16 cell_num;
|
uint16 cell_num;
|
||||||
|
|
||||||
|
uint8 *frame_ref_old = loader_ctx->frame_ref;
|
||||||
|
uint8 *frame_ref_after_popped = NULL;
|
||||||
|
uint8 frame_ref_tmp[4] = { 0 };
|
||||||
|
uint8 *frame_ref_buf = frame_ref_tmp;
|
||||||
|
uint32 stack_cell_num_old = loader_ctx->stack_cell_num;
|
||||||
|
#if WASM_ENABLE_FAST_INTERP != 0
|
||||||
|
int16 *frame_offset_old = loader_ctx->frame_offset;
|
||||||
|
int16 *frame_offset_after_popped = NULL;
|
||||||
|
int16 frame_offset_tmp[4] = { 0 };
|
||||||
|
int16 *frame_offset_buf = frame_offset_tmp;
|
||||||
|
uint16 dynamic_offset_old = (loader_ctx->frame_csp - 1)->dynamic_offset;
|
||||||
|
#endif
|
||||||
|
bool ret = false;
|
||||||
|
|
||||||
bh_assert(loader_ctx->csp_num > 0);
|
bh_assert(loader_ctx->csp_num > 0);
|
||||||
if (loader_ctx->csp_num - 1 < depth) {
|
if (loader_ctx->csp_num - 1 < depth) {
|
||||||
set_error_buf(error_buf, error_buf_size,
|
set_error_buf(error_buf, error_buf_size,
|
||||||
|
@ -5257,6 +5266,38 @@ wasm_loader_check_br(WASMLoaderContext *loader_ctx, uint32 depth,
|
||||||
#endif
|
#endif
|
||||||
POP_TYPE(types[i]);
|
POP_TYPE(types[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Backup stack data since it may be changed in the below
|
||||||
|
push operations, and the stack data may be used when
|
||||||
|
checking other target blocks of opcode br_table */
|
||||||
|
if (opcode == WASM_OP_BR_TABLE) {
|
||||||
|
uint64 total_size;
|
||||||
|
|
||||||
|
frame_ref_after_popped = loader_ctx->frame_ref;
|
||||||
|
total_size = (uint64)sizeof(uint8)
|
||||||
|
* (frame_ref_old - frame_ref_after_popped);
|
||||||
|
if (total_size > sizeof(frame_ref_tmp)
|
||||||
|
&& !(frame_ref_buf = loader_malloc(total_size, error_buf,
|
||||||
|
error_buf_size))) {
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
bh_memcpy_s(frame_ref_buf, (uint32)total_size,
|
||||||
|
frame_ref_after_popped, (uint32)total_size);
|
||||||
|
|
||||||
|
#if WASM_ENABLE_FAST_INTERP != 0
|
||||||
|
frame_offset_after_popped = loader_ctx->frame_offset;
|
||||||
|
total_size = (uint64)sizeof(int16)
|
||||||
|
* (frame_offset_old - frame_offset_after_popped);
|
||||||
|
if (total_size > sizeof(frame_offset_tmp)
|
||||||
|
&& !(frame_offset_buf = loader_malloc(total_size, error_buf,
|
||||||
|
error_buf_size))) {
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
bh_memcpy_s(frame_offset_buf, (uint32)total_size,
|
||||||
|
frame_offset_after_popped, (uint32)total_size);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < (int32)arity; i++) {
|
for (i = 0; i < (int32)arity; i++) {
|
||||||
#if WASM_ENABLE_FAST_INTERP != 0
|
#if WASM_ENABLE_FAST_INTERP != 0
|
||||||
bool disable_emit = true;
|
bool disable_emit = true;
|
||||||
|
@ -5265,7 +5306,41 @@ wasm_loader_check_br(WASMLoaderContext *loader_ctx, uint32 depth,
|
||||||
#endif
|
#endif
|
||||||
PUSH_TYPE(types[i]);
|
PUSH_TYPE(types[i]);
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
|
#if WASM_ENABLE_FAST_INTERP != 0
|
||||||
|
emit_br_info(target_block, opcode == WASM_OP_BR);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Restore the stack data, note that frame_ref_bottom,
|
||||||
|
frame_offset_bottom may be re-allocated in the above
|
||||||
|
push operations */
|
||||||
|
if (opcode == WASM_OP_BR_TABLE) {
|
||||||
|
uint32 total_size;
|
||||||
|
|
||||||
|
/* The stack operand num should not be smaller than before
|
||||||
|
after pop and push operations */
|
||||||
|
bh_assert(loader_ctx->stack_cell_num >= stack_cell_num_old);
|
||||||
|
loader_ctx->stack_cell_num = stack_cell_num_old;
|
||||||
|
loader_ctx->frame_ref =
|
||||||
|
loader_ctx->frame_ref_bottom + stack_cell_num_old;
|
||||||
|
total_size = (uint32)sizeof(uint8)
|
||||||
|
* (frame_ref_old - frame_ref_after_popped);
|
||||||
|
bh_memcpy_s((uint8 *)loader_ctx->frame_ref - total_size, total_size,
|
||||||
|
frame_ref_buf, total_size);
|
||||||
|
|
||||||
|
#if WASM_ENABLE_FAST_INTERP != 0
|
||||||
|
loader_ctx->frame_offset =
|
||||||
|
loader_ctx->frame_offset_bottom + stack_cell_num_old;
|
||||||
|
total_size = (uint32)sizeof(int16)
|
||||||
|
* (frame_offset_old - frame_offset_after_popped);
|
||||||
|
bh_memcpy_s((uint8 *)loader_ctx->frame_offset - total_size,
|
||||||
|
total_size, frame_offset_buf, total_size);
|
||||||
|
(loader_ctx->frame_csp - 1)->dynamic_offset = dynamic_offset_old;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = true;
|
||||||
|
goto cleanup_and_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
available_stack_cell =
|
available_stack_cell =
|
||||||
|
@ -5275,32 +5350,46 @@ wasm_loader_check_br(WASMLoaderContext *loader_ctx, uint32 depth,
|
||||||
for (i = (int32)arity - 1; i >= 0; i--) {
|
for (i = (int32)arity - 1; i >= 0; i--) {
|
||||||
if (!check_stack_top_values(frame_ref, available_stack_cell, types[i],
|
if (!check_stack_top_values(frame_ref, available_stack_cell, types[i],
|
||||||
error_buf, error_buf_size))
|
error_buf, error_buf_size))
|
||||||
return false;
|
goto fail;
|
||||||
cell_num = wasm_value_type_cell_num(types[i]);
|
cell_num = wasm_value_type_cell_num(types[i]);
|
||||||
frame_ref -= cell_num;
|
frame_ref -= cell_num;
|
||||||
available_stack_cell -= cell_num;
|
available_stack_cell -= cell_num;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
#if WASM_ENABLE_FAST_INTERP != 0
|
||||||
|
emit_br_info(target_block, opcode == WASM_OP_BR);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ret = true;
|
||||||
|
|
||||||
|
cleanup_and_return:
|
||||||
fail:
|
fail:
|
||||||
return false;
|
if (frame_ref_buf && frame_ref_buf != frame_ref_tmp)
|
||||||
|
wasm_runtime_free(frame_ref_buf);
|
||||||
|
#if WASM_ENABLE_FAST_INTERP != 0
|
||||||
|
if (frame_offset_buf && frame_offset_buf != frame_offset_tmp)
|
||||||
|
wasm_runtime_free(frame_offset_buf);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BranchBlock *
|
static BranchBlock *
|
||||||
check_branch_block(WASMLoaderContext *loader_ctx, uint8 **p_buf, uint8 *buf_end,
|
check_branch_block(WASMLoaderContext *loader_ctx, uint8 **p_buf, uint8 *buf_end,
|
||||||
char *error_buf, uint32 error_buf_size)
|
uint8 opcode, char *error_buf, uint32 error_buf_size)
|
||||||
{
|
{
|
||||||
uint8 *p = *p_buf, *p_end = buf_end;
|
uint8 *p = *p_buf, *p_end = buf_end;
|
||||||
BranchBlock *frame_csp_tmp;
|
BranchBlock *frame_csp_tmp;
|
||||||
uint32 depth;
|
uint32 depth;
|
||||||
|
|
||||||
read_leb_uint32(p, p_end, depth);
|
read_leb_uint32(p, p_end, depth);
|
||||||
CHECK_BR(depth);
|
bh_assert(loader_ctx->csp_num > 0);
|
||||||
|
if (!wasm_loader_check_br(loader_ctx, depth, opcode, error_buf,
|
||||||
|
error_buf_size)) {
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
frame_csp_tmp = loader_ctx->frame_csp - depth - 1;
|
frame_csp_tmp = loader_ctx->frame_csp - depth - 1;
|
||||||
#if WASM_ENABLE_FAST_INTERP != 0
|
|
||||||
emit_br_info(frame_csp_tmp);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
*p_buf = p;
|
*p_buf = p;
|
||||||
return frame_csp_tmp;
|
return frame_csp_tmp;
|
||||||
|
@ -5925,8 +6014,9 @@ re_scan:
|
||||||
|
|
||||||
case WASM_OP_BR:
|
case WASM_OP_BR:
|
||||||
{
|
{
|
||||||
if (!(frame_csp_tmp = check_branch_block(
|
if (!(frame_csp_tmp =
|
||||||
loader_ctx, &p, p_end, error_buf, error_buf_size)))
|
check_branch_block(loader_ctx, &p, p_end, opcode,
|
||||||
|
error_buf, error_buf_size)))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
RESET_STACK();
|
RESET_STACK();
|
||||||
|
@ -5938,8 +6028,9 @@ re_scan:
|
||||||
{
|
{
|
||||||
POP_I32();
|
POP_I32();
|
||||||
|
|
||||||
if (!(frame_csp_tmp = check_branch_block(
|
if (!(frame_csp_tmp =
|
||||||
loader_ctx, &p, p_end, error_buf, error_buf_size)))
|
check_branch_block(loader_ctx, &p, p_end, opcode,
|
||||||
|
error_buf, error_buf_size)))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -5951,7 +6042,7 @@ re_scan:
|
||||||
uint32 ret_count = 0;
|
uint32 ret_count = 0;
|
||||||
#if WASM_ENABLE_FAST_INTERP == 0
|
#if WASM_ENABLE_FAST_INTERP == 0
|
||||||
uint8 *p_depth_begin, *p_depth;
|
uint8 *p_depth_begin, *p_depth;
|
||||||
uint32 depth, j;
|
uint32 depth = 0, j;
|
||||||
BrTableCache *br_table_cache = NULL;
|
BrTableCache *br_table_cache = NULL;
|
||||||
|
|
||||||
p_org = p - 1;
|
p_org = p - 1;
|
||||||
|
@ -5968,7 +6059,7 @@ re_scan:
|
||||||
#endif
|
#endif
|
||||||
for (i = 0; i <= count; i++) {
|
for (i = 0; i <= count; i++) {
|
||||||
if (!(frame_csp_tmp =
|
if (!(frame_csp_tmp =
|
||||||
check_branch_block(loader_ctx, &p, p_end,
|
check_branch_block(loader_ctx, &p, p_end, opcode,
|
||||||
error_buf, error_buf_size)))
|
error_buf, error_buf_size)))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
cmake_minimum_required (VERSION 2.8...3.16)
|
cmake_minimum_required (VERSION 2.8...3.16)
|
||||||
|
|
||||||
project(socket_wasi_ext)
|
project(socket_wasi_ext LANGUAGES C)
|
||||||
|
|
||||||
add_library(${PROJECT_NAME} STATIC ${CMAKE_CURRENT_LIST_DIR}/src/wasi/wasi_socket_ext.c)
|
add_library(${PROJECT_NAME} STATIC ${CMAKE_CURRENT_LIST_DIR}/src/wasi/wasi_socket_ext.c)
|
||||||
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_LIST_DIR}/inc/)
|
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_LIST_DIR}/inc/)
|
||||||
|
|
|
@ -426,7 +426,7 @@ sprintf_wrapper(wasm_exec_env_t exec_env, char *str, const char *format,
|
||||||
if (!wasm_runtime_get_native_addr_range(module_inst, (uint8 *)str, NULL,
|
if (!wasm_runtime_get_native_addr_range(module_inst, (uint8 *)str, NULL,
|
||||||
&native_end_offset)) {
|
&native_end_offset)) {
|
||||||
wasm_runtime_set_exception(module_inst, "out of bounds memory access");
|
wasm_runtime_set_exception(module_inst, "out of bounds memory access");
|
||||||
return false;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.str = str;
|
ctx.str = str;
|
||||||
|
|
|
@ -384,7 +384,7 @@ os_openat(os_file_handle handle, const char *path, __wasi_oflags_t oflags,
|
||||||
// Linux returns ENXIO instead of EOPNOTSUPP when opening a socket.
|
// Linux returns ENXIO instead of EOPNOTSUPP when opening a socket.
|
||||||
if (openat_errno == ENXIO) {
|
if (openat_errno == ENXIO) {
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
int ret = fstatat(fd, path, &sb,
|
int ret = fstatat(handle, path, &sb,
|
||||||
(lookup_flags & __WASI_LOOKUP_SYMLINK_FOLLOW)
|
(lookup_flags & __WASI_LOOKUP_SYMLINK_FOLLOW)
|
||||||
? 0
|
? 0
|
||||||
: AT_SYMLINK_NOFOLLOW);
|
: AT_SYMLINK_NOFOLLOW);
|
||||||
|
@ -396,7 +396,7 @@ os_openat(os_file_handle handle, const char *path, __wasi_oflags_t oflags,
|
||||||
if (openat_errno == ENOTDIR
|
if (openat_errno == ENOTDIR
|
||||||
&& (open_flags & (O_NOFOLLOW | O_DIRECTORY)) != 0) {
|
&& (open_flags & (O_NOFOLLOW | O_DIRECTORY)) != 0) {
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
int ret = fstatat(fd, path, &sb, AT_SYMLINK_NOFOLLOW);
|
int ret = fstatat(handle, path, &sb, AT_SYMLINK_NOFOLLOW);
|
||||||
if (S_ISLNK(sb.st_mode)) {
|
if (S_ISLNK(sb.st_mode)) {
|
||||||
return __WASI_ELOOP;
|
return __WASI_ELOOP;
|
||||||
}
|
}
|
||||||
|
|
|
@ -226,7 +226,7 @@ unlinkat(int fd, const char *path, int flag)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
utimensat(int fd, const char *path, const struct timespec *ts, int flag)
|
utimensat(int fd, const char *path, const struct timespec ts[2], int flag)
|
||||||
{
|
{
|
||||||
errno = ENOSYS;
|
errno = ENOSYS;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -249,7 +249,7 @@ ftruncate(int fd, off_t length)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int
|
int
|
||||||
futimens(int fd, const struct timespec *times)
|
futimens(int fd, const struct timespec times[2])
|
||||||
{
|
{
|
||||||
errno = ENOSYS;
|
errno = ENOSYS;
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -50,6 +50,10 @@
|
||||||
#include <zephyr/net/net_context.h>
|
#include <zephyr/net/net_context.h>
|
||||||
#endif /* end of KERNEL_VERSION_NUMBER < 0x030200 */
|
#endif /* end of KERNEL_VERSION_NUMBER < 0x030200 */
|
||||||
|
|
||||||
|
#if KERNEL_VERSION_NUMBER >= 0x030300 /* version 3.3.0 */
|
||||||
|
#include <zephyr/cache.h>
|
||||||
|
#endif /* end of KERNEL_VERSION_NUMBER > 0x030300 */
|
||||||
|
|
||||||
#ifdef CONFIG_ARM_MPU
|
#ifdef CONFIG_ARM_MPU
|
||||||
#if KERNEL_VERSION_NUMBER < 0x030200 /* version 3.2.0 */
|
#if KERNEL_VERSION_NUMBER < 0x030200 /* version 3.2.0 */
|
||||||
#include <arch/arm/aarch32/cortex_m/cmsis.h>
|
#include <arch/arm/aarch32/cortex_m/cmsis.h>
|
||||||
|
@ -96,7 +100,8 @@ void abort(void);
|
||||||
size_t strspn(const char *s, const char *accept);
|
size_t strspn(const char *s, const char *accept);
|
||||||
size_t strcspn(const char *s, const char *reject);
|
size_t strcspn(const char *s, const char *reject);
|
||||||
|
|
||||||
/* math functions which are not provided by os */
|
/* math functions which are not provided by os with minimal libc */
|
||||||
|
#if defined(CONFIG_MINIMAL_LIBC)
|
||||||
double atan(double x);
|
double atan(double x);
|
||||||
double atan2(double y, double x);
|
double atan2(double y, double x);
|
||||||
double sqrt(double x);
|
double sqrt(double x);
|
||||||
|
@ -123,6 +128,10 @@ double scalbn(double x, int n);
|
||||||
unsigned long long int strtoull(const char *nptr, char **endptr, int base);
|
unsigned long long int strtoull(const char *nptr, char **endptr, int base);
|
||||||
double strtod(const char *nptr, char **endptr);
|
double strtod(const char *nptr, char **endptr);
|
||||||
float strtof(const char *nptr, char **endptr);
|
float strtof(const char *nptr, char **endptr);
|
||||||
|
#else
|
||||||
|
#include <math.h>
|
||||||
|
#endif /* CONFIG_MINIMAL_LIBC */
|
||||||
|
|
||||||
/* clang-format on */
|
/* clang-format on */
|
||||||
|
|
||||||
#if KERNEL_VERSION_NUMBER >= 0x030100 /* version 3.1.0 */
|
#if KERNEL_VERSION_NUMBER >= 0x030100 /* version 3.1.0 */
|
||||||
|
|
|
@ -8,7 +8,9 @@ add_definitions(-DBH_PLATFORM_ZEPHYR)
|
||||||
include_directories(${PLATFORM_SHARED_DIR})
|
include_directories(${PLATFORM_SHARED_DIR})
|
||||||
include_directories(${PLATFORM_SHARED_DIR}/../include)
|
include_directories(${PLATFORM_SHARED_DIR}/../include)
|
||||||
|
|
||||||
include (${CMAKE_CURRENT_LIST_DIR}/../common/math/platform_api_math.cmake)
|
if(${CONFIG_MINIMAL_LIBC})
|
||||||
|
include (${CMAKE_CURRENT_LIST_DIR}/../common/math/platform_api_math.cmake)
|
||||||
|
endif()
|
||||||
|
|
||||||
file (GLOB_RECURSE source_all ${PLATFORM_SHARED_DIR}/*.c)
|
file (GLOB_RECURSE source_all ${PLATFORM_SHARED_DIR}/*.c)
|
||||||
|
|
||||||
|
|
|
@ -25,9 +25,11 @@ disable_mpu_rasr_xn(void)
|
||||||
would most likely be set at index 2. */
|
would most likely be set at index 2. */
|
||||||
for (index = 0U; index < 8; index++) {
|
for (index = 0U; index < 8; index++) {
|
||||||
MPU->RNR = index;
|
MPU->RNR = index;
|
||||||
|
#ifdef MPU_RASR_XN_Msk
|
||||||
if (MPU->RASR & MPU_RASR_XN_Msk) {
|
if (MPU->RASR & MPU_RASR_XN_Msk) {
|
||||||
MPU->RASR |= ~MPU_RASR_XN_Msk;
|
MPU->RASR |= ~MPU_RASR_XN_Msk;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* end of CONFIG_ARM_MPU */
|
#endif /* end of CONFIG_ARM_MPU */
|
||||||
|
@ -72,18 +74,20 @@ bh_platform_destroy()
|
||||||
void *
|
void *
|
||||||
os_malloc(unsigned size)
|
os_malloc(unsigned size)
|
||||||
{
|
{
|
||||||
return NULL;
|
return malloc(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
void *
|
||||||
os_realloc(void *ptr, unsigned size)
|
os_realloc(void *ptr, unsigned size)
|
||||||
{
|
{
|
||||||
return NULL;
|
return realloc(ptr, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
os_free(void *ptr)
|
os_free(void *ptr)
|
||||||
{}
|
{
|
||||||
|
free(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
os_dumps_proc_mem_info(char *out, unsigned int size)
|
os_dumps_proc_mem_info(char *out, unsigned int size)
|
||||||
|
@ -202,10 +206,14 @@ void
|
||||||
os_dcache_flush()
|
os_dcache_flush()
|
||||||
{
|
{
|
||||||
#if defined(CONFIG_CPU_CORTEX_M7) && defined(CONFIG_ARM_MPU)
|
#if defined(CONFIG_CPU_CORTEX_M7) && defined(CONFIG_ARM_MPU)
|
||||||
|
#if KERNEL_VERSION_NUMBER < 0x030300 /* version 3.3.0 */
|
||||||
uint32 key;
|
uint32 key;
|
||||||
key = irq_lock();
|
key = irq_lock();
|
||||||
SCB_CleanDCache();
|
SCB_CleanDCache();
|
||||||
irq_unlock(key);
|
irq_unlock(key);
|
||||||
|
#else
|
||||||
|
sys_cache_data_flush_all();
|
||||||
|
#endif
|
||||||
#elif defined(CONFIG_SOC_CVF_EM7D) && defined(CONFIG_ARC_MPU) \
|
#elif defined(CONFIG_SOC_CVF_EM7D) && defined(CONFIG_ARC_MPU) \
|
||||||
&& defined(CONFIG_CACHE_FLUSHING)
|
&& defined(CONFIG_CACHE_FLUSHING)
|
||||||
__asm__ __volatile__("sync");
|
__asm__ __volatile__("sync");
|
||||||
|
@ -216,7 +224,11 @@ os_dcache_flush()
|
||||||
|
|
||||||
void
|
void
|
||||||
os_icache_flush(void *start, size_t len)
|
os_icache_flush(void *start, size_t len)
|
||||||
{}
|
{
|
||||||
|
#if KERNEL_VERSION_NUMBER >= 0x030300 /* version 3.3.0 */
|
||||||
|
sys_cache_instr_flush_range(start, len);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
set_exec_mem_alloc_func(exec_mem_alloc_func_t alloc_func,
|
set_exec_mem_alloc_func(exec_mem_alloc_func_t alloc_func,
|
||||||
|
|
|
@ -117,8 +117,8 @@ func (self *Module) SetWasiArgsEx(dirList [][]byte, mapDirList [][]byte,
|
||||||
C.wasm_runtime_set_wasi_args_ex(self.module, dirPtr, dirCount,
|
C.wasm_runtime_set_wasi_args_ex(self.module, dirPtr, dirCount,
|
||||||
mapDirPtr, mapDirCount,
|
mapDirPtr, mapDirCount,
|
||||||
envPtr, envCount, argvPtr, argc,
|
envPtr, envCount, argvPtr, argc,
|
||||||
C.int(stdinfd), C.int(stdoutfd),
|
C.int64_t(stdinfd), C.int64_t(stdoutfd),
|
||||||
C.int(stderrfd))
|
C.int64_t(stderrfd))
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set module's wasi network address pool */
|
/* Set module's wasi network address pool */
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 108 KiB |
Binary file not shown.
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 111 KiB |
Binary file not shown.
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 125 KiB |
|
@ -14,7 +14,11 @@ The WAMR-IDE is an Integrated Development Environment to develop WebAssembly app
|
||||||
|
|
||||||
## How to setup WAMR IDE
|
## How to setup WAMR IDE
|
||||||
|
|
||||||
Now, we have same version tagged docker images, lldb binaries and VS Code installation file(.vsix file) packed for each GitHub release. So if you simply want to use WAMR debugging features in VS Code, the ideal(and effortless) way is following the tutorial in [this section](#21-download-wamr-vs-code-extension-from-the-github-releaserecommended-approach).
|
Now, the most straightforward way to install the WAMR IDE extension is by searching for WAMR-IDE in the VS Code extension marketplace and installing it directly. So, if you simply want to use WAMR debugging features in VS Code, this is the ideal (and effortless) way. And you are ready to [use WAMR IDE](#how-to-use-wamr-ide).
|
||||||
|
|
||||||
|
> It is only recommended to download versions after 1.3.2 from the marketplace.
|
||||||
|
|
||||||
|
Also, we have same version tagged docker images, lldb binaries and VS Code installation file(.vsix file) packed for each GitHub release. You can following the tutorial in [this section](#21-download-wamr-vs-code-extension-from-the-github-releaserecommended-approach).
|
||||||
|
|
||||||
Alternatively, if you want to build lldb, docker images, or .vsix file locally so that you can try the effect of your modification, you could refer to the tutorial in [this section](#22-build-wamr-vs-code-extension-locallyalternative-approach).
|
Alternatively, if you want to build lldb, docker images, or .vsix file locally so that you can try the effect of your modification, you could refer to the tutorial in [this section](#22-build-wamr-vs-code-extension-locallyalternative-approach).
|
||||||
|
|
||||||
|
@ -93,19 +97,19 @@ We have 2 docker images which should be built or loaded on your host, `wasm-tool
|
||||||
Windows (powershell):
|
Windows (powershell):
|
||||||
|
|
||||||
```batch
|
```batch
|
||||||
$ cd .\WASM-Toolchain\Docker
|
cd .\WASM-Toolchain\Docker
|
||||||
$ .\build_docker_image.bat
|
.\build_docker_image.bat
|
||||||
$ cd .\WASM-Debug-Server\Docker
|
cd .\WASM-Debug-Server\Docker
|
||||||
$ .\build_docker_image.bat
|
.\build_docker_image.bat
|
||||||
```
|
```
|
||||||
|
|
||||||
Linux:
|
Linux:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
$ cd ./WASM-Toolchain/Docker
|
cd ./WASM-Toolchain/Docker
|
||||||
$ ./build_docker_image.sh
|
./build_docker_image.sh
|
||||||
$ cd ./WASM-Debug-Server/Docker
|
cd ./WASM-Debug-Server/Docker
|
||||||
$ ./build_docker_image.sh
|
./build_docker_image.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
##### 2.2.2 After building, you can find `wasm-toolchain` and `wasm-debug-server` docker images on your local
|
##### 2.2.2 After building, you can find `wasm-toolchain` and `wasm-debug-server` docker images on your local
|
||||||
|
@ -145,11 +149,11 @@ $ docker build --no-cache --build-arg http_proxy=http://proxy.example.com:1234
|
||||||
`wamride-1.0.0.vsix` can be packaged by [`npm vsce`](https://code.visualstudio.com/api/working-with-extensions/publishing-extension).
|
`wamride-1.0.0.vsix` can be packaged by [`npm vsce`](https://code.visualstudio.com/api/working-with-extensions/publishing-extension).
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
$ npm install -g vsce
|
npm install -g vsce
|
||||||
$ cd VSCode-Extension
|
cd VSCode-Extension
|
||||||
$ rm -rf node_modules
|
rm -rf node_modules
|
||||||
$ npm install
|
npm install
|
||||||
$ vsce package
|
vsce package
|
||||||
```
|
```
|
||||||
|
|
||||||
##### 2.2.7 Enable VS Code debugging feature
|
##### 2.2.7 Enable VS Code debugging feature
|
||||||
|
@ -171,7 +175,6 @@ $ cp inst/* /home/{usrname}/.vscode-server/extensions/wamr.wamride-1.0.0/resourc
|
||||||
If you want to use your own patched `lldb`, you could follow this [instruction](../../doc/source_debugging.md#debugging-with-interpreter) to build `lldb`. And follow this [instruction](./VSCode-Extension/resource/debug/README.md)
|
If you want to use your own patched `lldb`, you could follow this [instruction](../../doc/source_debugging.md#debugging-with-interpreter) to build `lldb`. And follow this [instruction](./VSCode-Extension/resource/debug/README.md)
|
||||||
to copy the binaries to replace the existing ones.
|
to copy the binaries to replace the existing ones.
|
||||||
|
|
||||||
|
|
||||||
> **You can also debug the extension directly follow this [instruction](./VSCode-Extension/README.md) without packing the extension.**
|
> **You can also debug the extension directly follow this [instruction](./VSCode-Extension/README.md) without packing the extension.**
|
||||||
|
|
||||||
##### 2.2.7 Install extension from vsix
|
##### 2.2.7 Install extension from vsix
|
||||||
|
@ -184,7 +187,7 @@ select `wamride-1.0.0.vsix` which you have packed on your host.
|
||||||
|
|
||||||
## How to use `wamr-ide`
|
## How to use `wamr-ide`
|
||||||
|
|
||||||
#### `WAMR-IDE` extension contains 2 components as following picture showing. `WAMR IDE` for workspace and project management and `Current Project` for project's execution.
|
#### `WAMR-IDE` extension contains 2 components as following picture showing. `WAMR IDE` for workspace and project management and `Current Project` for project's execution
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
@ -254,7 +257,7 @@ Click `Change workspace` button, a dialog will show as following. You can select
|
||||||
|
|
||||||
At the same time, all added `include path` and `exclude files` will be saved in `.wamr/compilation_config.json` as json array.
|
At the same time, all added `include path` and `exclude files` will be saved in `.wamr/compilation_config.json` as json array.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
> `Toggle state of path including` just shows when selecting `folder` and hides with other resources.
|
> `Toggle state of path including` just shows when selecting `folder` and hides with other resources.
|
||||||
>
|
>
|
||||||
|
@ -268,13 +271,22 @@ Click `Configuration` button, a new page will be shown as following. You can con
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
Short Explanation of the Fields Above:
|
||||||
|
|
||||||
|
- Output file name: The compiled wasm file name of your program.
|
||||||
|
- Initial linear memory size, Max linear memory size, Stack size: The wasi-sdk clang compile options.
|
||||||
|
- Exported symbols: The symbols your wasm program wants to export. **Multiple symbols are separated by commas without spaces**.
|
||||||
|
- Host managed heap size: The running configuration for the host managed heap size of iwasm. In most cases, the default size would be fine, but in some scenarios, let's say you want to allocate more memory using `malloc`, you should increase it here accordingly.
|
||||||
|
|
||||||
|
> Note that due to the current implementation limitation, after changing the `Output file name` or `Host managed heap size`, you need to close and reopen VSCode (to reactivate the extension) so that the running config will be correctly updated.
|
||||||
|
|
||||||
Then click `Modify` button to confirm, if configurations are modified successfully and following message will pop. Click `OK`, the page will be auto closed.
|
Then click `Modify` button to confirm, if configurations are modified successfully and following message will pop. Click `OK`, the page will be auto closed.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
And all configuration will be saved in `.wamr/compilation_config.json`.
|
And all configuration will be saved in `.wamr/compilation_config.json`.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
#### 2. `Build`
|
#### 2. `Build`
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
},
|
},
|
||||||
"displayName": "WAMR-IDE",
|
"displayName": "WAMR-IDE",
|
||||||
"description": "An Integrated Development Environment for WASM",
|
"description": "An Integrated Development Environment for WASM",
|
||||||
"version": "1.2.2",
|
"version": "1.3.2",
|
||||||
"engines": {
|
"engines": {
|
||||||
"vscode": "^1.59.0",
|
"vscode": "^1.59.0",
|
||||||
"node": ">=16.0.0"
|
"node": ">=16.0.0"
|
||||||
|
|
|
@ -7,4 +7,4 @@ docker run --rm -it --name=wasm-debug-server-ctr ^
|
||||||
-v "%cd%":/mnt ^
|
-v "%cd%":/mnt ^
|
||||||
-p 1234:1234 ^
|
-p 1234:1234 ^
|
||||||
wasm-debug-server:%2 ^
|
wasm-debug-server:%2 ^
|
||||||
/bin/bash -c "./debug.sh %1"
|
/bin/bash -c "./debug.sh %1 %3"
|
||||||
|
|
|
@ -9,4 +9,4 @@ docker run --rm -it --name=wasm-debug-server-ctr \
|
||||||
-v "$(pwd)":/mnt \
|
-v "$(pwd)":/mnt \
|
||||||
-p 1234:1234 \
|
-p 1234:1234 \
|
||||||
wasm-debug-server:$2 \
|
wasm-debug-server:$2 \
|
||||||
/bin/bash -c "./debug.sh $1"
|
/bin/bash -c "./debug.sh $1 $3"
|
||||||
|
|
|
@ -6,4 +6,4 @@
|
||||||
docker run --rm -it --name=wasm-debug-server-ctr ^
|
docker run --rm -it --name=wasm-debug-server-ctr ^
|
||||||
-v "%cd%":/mnt ^
|
-v "%cd%":/mnt ^
|
||||||
wasm-debug-server:%2 ^
|
wasm-debug-server:%2 ^
|
||||||
/bin/bash -c "./run.sh %1"
|
/bin/bash -c "./run.sh %1 %3"
|
||||||
|
|
|
@ -8,4 +8,4 @@ set -e
|
||||||
docker run --rm -it --name=wasm-debug-server-ctr \
|
docker run --rm -it --name=wasm-debug-server-ctr \
|
||||||
-v "$(pwd)":/mnt \
|
-v "$(pwd)":/mnt \
|
||||||
wasm-debug-server:$2 \
|
wasm-debug-server:$2 \
|
||||||
/bin/bash -c "./run.sh $1"
|
/bin/bash -c "./run.sh $1 $3"
|
||||||
|
|
|
@ -15,6 +15,7 @@ function submitFunc() {
|
||||||
let maxMemSize = document.getElementById('max_mem_size').value;
|
let maxMemSize = document.getElementById('max_mem_size').value;
|
||||||
let stackSize = document.getElementById('stack_size').value;
|
let stackSize = document.getElementById('stack_size').value;
|
||||||
let exportedSymbols = document.getElementById('exported_symbols').value;
|
let exportedSymbols = document.getElementById('exported_symbols').value;
|
||||||
|
let hostManagedHeapSize = document.getElementById('host_managed_heap_size').value;
|
||||||
|
|
||||||
vscode.postMessage({
|
vscode.postMessage({
|
||||||
command: 'config_build_target',
|
command: 'config_build_target',
|
||||||
|
@ -23,5 +24,6 @@ function submitFunc() {
|
||||||
maxMemSize: maxMemSize,
|
maxMemSize: maxMemSize,
|
||||||
stackSize: stackSize,
|
stackSize: stackSize,
|
||||||
exportedSymbols: exportedSymbols,
|
exportedSymbols: exportedSymbols,
|
||||||
|
hostManagedHeapSize: hostManagedHeapSize,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,12 +41,30 @@
|
||||||
<vscode-text-field id="stack_size" value=${stack_size_val}></vscode-text-field>
|
<vscode-text-field id="stack_size" value=${stack_size_val}></vscode-text-field>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label><b>Exported symbols: </b></label>
|
<label><b>Exported symbols: </b>
|
||||||
|
<span><b>(separated by ',')</b></span>
|
||||||
|
</label>
|
||||||
<vscode-text-area rows="3" id="exported_symbols" placeholder="Please split each symbol with comma. Like 'app_main,on_init'" value=${exported_symbols_val}></vscode-text-area>
|
<vscode-text-area rows="3" id="exported_symbols" placeholder="Please split each symbol with comma. Like 'app_main,on_init'" value=${exported_symbols_val}></vscode-text-area>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="box_wrapper">
|
||||||
|
<div class="config_form_heading">
|
||||||
|
<h2>Config iwasm running option</h2>
|
||||||
|
<vscode-divider></vscode-divider>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="box_wrapper">
|
||||||
|
<div class="config_form_body">
|
||||||
|
<div>
|
||||||
|
<label><b>Host managed heap size: </b></label>
|
||||||
|
<vscode-text-field id="host_managed_heap_size" value=${host_managed_heap_size_val}></vscode-text-field>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="box_wrapper">
|
<div class="box_wrapper">
|
||||||
<div class="config_form_bottom">
|
<div class="config_form_bottom">
|
||||||
<vscode-divider></vscode-divider>
|
<vscode-divider></vscode-divider>
|
||||||
|
|
|
@ -8,23 +8,24 @@ import * as os from 'os';
|
||||||
|
|
||||||
/* see https://github.com/llvm/llvm-project/tree/main/lldb/tools/lldb-vscode#attaching-settings */
|
/* see https://github.com/llvm/llvm-project/tree/main/lldb/tools/lldb-vscode#attaching-settings */
|
||||||
export interface WasmDebugConfig {
|
export interface WasmDebugConfig {
|
||||||
type: string,
|
type: string;
|
||||||
name: string,
|
name: string;
|
||||||
request: string,
|
request: string;
|
||||||
program? : string,
|
program?: string;
|
||||||
pid?: string,
|
pid?: string;
|
||||||
stopOnEntry?: boolean,
|
stopOnEntry?: boolean;
|
||||||
waitFor?: boolean,
|
waitFor?: boolean;
|
||||||
initCommands?: string[],
|
initCommands?: string[];
|
||||||
preRunCommands?: string[],
|
preRunCommands?: string[];
|
||||||
stopCommands?: string[],
|
stopCommands?: string[];
|
||||||
exitCommands?: string[],
|
exitCommands?: string[];
|
||||||
terminateCommands?: string[],
|
terminateCommands?: string[];
|
||||||
attachCommands?: string[]
|
attachCommands?: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class WasmDebugConfigurationProvider
|
export class WasmDebugConfigurationProvider
|
||||||
implements vscode.DebugConfigurationProvider {
|
implements vscode.DebugConfigurationProvider
|
||||||
|
{
|
||||||
private wasmDebugConfig: WasmDebugConfig = {
|
private wasmDebugConfig: WasmDebugConfig = {
|
||||||
type: 'wamr-debug',
|
type: 'wamr-debug',
|
||||||
name: 'Attach',
|
name: 'Attach',
|
||||||
|
@ -33,28 +34,29 @@ export class WasmDebugConfigurationProvider
|
||||||
attachCommands: [
|
attachCommands: [
|
||||||
/* default port 1234 */
|
/* default port 1234 */
|
||||||
'process connect -p wasm connect://127.0.0.1:1234',
|
'process connect -p wasm connect://127.0.0.1:1234',
|
||||||
]
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor(extensionPath: string) {
|
constructor(extensionPath: string) {
|
||||||
this.wasmDebugConfig.initCommands = [
|
this.wasmDebugConfig.initCommands = [
|
||||||
/* Add rust formatters -> https://lldb.llvm.org/use/variable.html */
|
/* Add rust formatters -> https://lldb.llvm.org/use/variable.html */
|
||||||
`command script import ${extensionPath}/formatters/rust.py`
|
`command script import ${extensionPath}/formatters/rust.py`,
|
||||||
];
|
];
|
||||||
|
|
||||||
if (os.platform() === 'win32' || os.platform() === 'darwin') {
|
if (os.platform() === 'win32' || os.platform() === 'darwin') {
|
||||||
this.wasmDebugConfig.initCommands.push('platform select remote-linux');
|
this.wasmDebugConfig.initCommands.push(
|
||||||
|
'platform select remote-linux'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public resolveDebugConfiguration(
|
public resolveDebugConfiguration(
|
||||||
_: vscode.WorkspaceFolder | undefined,
|
_: vscode.WorkspaceFolder | undefined,
|
||||||
debugConfiguration: vscode.DebugConfiguration,
|
debugConfiguration: vscode.DebugConfiguration
|
||||||
): vscode.ProviderResult<vscode.DebugConfiguration> {
|
): vscode.ProviderResult<vscode.DebugConfiguration> {
|
||||||
|
|
||||||
this.wasmDebugConfig = {
|
this.wasmDebugConfig = {
|
||||||
...this.wasmDebugConfig,
|
...this.wasmDebugConfig,
|
||||||
...debugConfiguration
|
...debugConfiguration,
|
||||||
};
|
};
|
||||||
|
|
||||||
return this.wasmDebugConfig;
|
return this.wasmDebugConfig;
|
||||||
|
|
|
@ -170,7 +170,9 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* register debug configuration */
|
/* register debug configuration */
|
||||||
wasmDebugConfigProvider = new WasmDebugConfigurationProvider(context.extensionPath);
|
wasmDebugConfigProvider = new WasmDebugConfigurationProvider(
|
||||||
|
context.extensionPath
|
||||||
|
);
|
||||||
|
|
||||||
vscode.debug.registerDebugConfigurationProvider(
|
vscode.debug.registerDebugConfigurationProvider(
|
||||||
'wamr-debug',
|
'wamr-debug',
|
||||||
|
@ -811,6 +813,7 @@ interface BuildArgs {
|
||||||
maxMemorySize: string;
|
maxMemorySize: string;
|
||||||
stackSize: string;
|
stackSize: string;
|
||||||
exportedSymbols: string;
|
exportedSymbols: string;
|
||||||
|
hostManagedHeapSize: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -31,6 +31,7 @@ export class WasmTaskProvider implements vscode.TaskProvider {
|
||||||
/* target name is used for generated aot target */
|
/* target name is used for generated aot target */
|
||||||
const targetName =
|
const targetName =
|
||||||
TargetConfigPanel.buildArgs.outputFileName.split('.')[0];
|
TargetConfigPanel.buildArgs.outputFileName.split('.')[0];
|
||||||
|
const heapSize = TargetConfigPanel.buildArgs.hostManagedHeapSize;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
os.platform() === 'linux' ||
|
os.platform() === 'linux' ||
|
||||||
|
@ -57,7 +58,7 @@ export class WasmTaskProvider implements vscode.TaskProvider {
|
||||||
: (this._script.get('debugScript') as string),
|
: (this._script.get('debugScript') as string),
|
||||||
options: {
|
options: {
|
||||||
executable: this._script.get('debugScript'),
|
executable: this._script.get('debugScript'),
|
||||||
shellArgs: [targetName, this._wamrVersion],
|
shellArgs: [targetName, this._wamrVersion, heapSize],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -69,7 +70,7 @@ export class WasmTaskProvider implements vscode.TaskProvider {
|
||||||
: (this._script.get('runScript') as string),
|
: (this._script.get('runScript') as string),
|
||||||
options: {
|
options: {
|
||||||
executable: this._script.get('runScript'),
|
executable: this._script.get('runScript'),
|
||||||
shellArgs: [targetName, this._wamrVersion],
|
shellArgs: [targetName, this._wamrVersion, heapSize],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -9,25 +9,25 @@ import * as os from 'os';
|
||||||
import { runTests } from '@vscode/test-electron';
|
import { runTests } from '@vscode/test-electron';
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
try {
|
try {
|
||||||
// The folder containing the Extension Manifest package.json
|
// The folder containing the Extension Manifest package.json
|
||||||
// Passed to `--extensionDevelopmentPath`
|
// Passed to `--extensionDevelopmentPath`
|
||||||
const extensionDevelopmentPath = path.resolve(__dirname, '../../');
|
const extensionDevelopmentPath = path.resolve(__dirname, '../../');
|
||||||
|
|
||||||
// The path to the extension test script
|
// The path to the extension test script
|
||||||
// Passed to --extensionTestsPath
|
// Passed to --extensionTestsPath
|
||||||
const extensionTestsPath = path.resolve(__dirname, './suite/index');
|
const extensionTestsPath = path.resolve(__dirname, './suite/index');
|
||||||
|
|
||||||
// Download VS Code, unzip it and run the integration test
|
// Download VS Code, unzip it and run the integration test
|
||||||
await runTests({
|
await runTests({
|
||||||
extensionDevelopmentPath,
|
extensionDevelopmentPath,
|
||||||
extensionTestsPath,
|
extensionTestsPath,
|
||||||
launchArgs: ['--user-data-dir', `${os.tmpdir()}`]
|
launchArgs: ['--user-data-dir', `${os.tmpdir()}`],
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to run tests');
|
console.error('Failed to run tests');
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
main();
|
main();
|
||||||
|
|
|
@ -3,57 +3,65 @@
|
||||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {DebugProtocol} from '@vscode/debugprotocol';
|
import { DebugProtocol } from '@vscode/debugprotocol';
|
||||||
import {after, before, test, suite} from 'mocha';
|
import { after, before, test, suite } from 'mocha';
|
||||||
import {assert} from 'chai';
|
import { assert } from 'chai';
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import * as cp from 'child_process';
|
import * as cp from 'child_process';
|
||||||
import * as path from "path";
|
import * as path from 'path';
|
||||||
import * as os from 'os';
|
import * as os from 'os';
|
||||||
import {WasmDebugConfig, WasmDebugConfigurationProvider} from "../../debugConfigurationProvider";
|
import {
|
||||||
import {EXTENSION_PATH, clearAllBp, setBpAtMarker, compileRustToWasm} from "./utils";
|
WasmDebugConfig,
|
||||||
import {downloadLldb, isLLDBInstalled} from '../../utilities/lldbUtilities';
|
WasmDebugConfigurationProvider,
|
||||||
|
} from '../../debugConfigurationProvider';
|
||||||
|
import {
|
||||||
|
EXTENSION_PATH,
|
||||||
|
clearAllBp,
|
||||||
|
setBpAtMarker,
|
||||||
|
compileRustToWasm,
|
||||||
|
} from './utils';
|
||||||
|
import { downloadLldb, isLLDBInstalled } from '../../utilities/lldbUtilities';
|
||||||
|
|
||||||
suite('Unit Tests', function () {
|
suite('Unit Tests', function () {
|
||||||
test('DebugConfigurationProvider init commands', function () {
|
test('DebugConfigurationProvider init commands', function () {
|
||||||
const testExtensionPath = "/test/path/";
|
const testExtensionPath = '/test/path/';
|
||||||
const provider = new WasmDebugConfigurationProvider(testExtensionPath);
|
const provider = new WasmDebugConfigurationProvider(testExtensionPath);
|
||||||
|
|
||||||
assert.includeMembers(
|
assert.includeMembers(
|
||||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
provider.getDebugConfig().initCommands!,
|
provider.getDebugConfig().initCommands!,
|
||||||
[`command script import ${testExtensionPath}/formatters/rust.py`],
|
[`command script import ${testExtensionPath}/formatters/rust.py`],
|
||||||
"Debugger init commands did not contain "
|
'Debugger init commands did not contain '
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('DebugConfigurationProvider resolve configuration', function () {
|
test('DebugConfigurationProvider resolve configuration', function () {
|
||||||
const testExtensionPath = "/test/path/";
|
const testExtensionPath = '/test/path/';
|
||||||
const provider = new WasmDebugConfigurationProvider(testExtensionPath);
|
const provider = new WasmDebugConfigurationProvider(testExtensionPath);
|
||||||
|
|
||||||
const actual = provider.resolveDebugConfiguration(undefined, {
|
const actual = provider.resolveDebugConfiguration(undefined, {
|
||||||
type: "wamr-debug",
|
type: 'wamr-debug',
|
||||||
name: "Attach",
|
name: 'Attach',
|
||||||
request: "attach",
|
request: 'attach',
|
||||||
initCommands: [],
|
initCommands: [],
|
||||||
attachCommands: [
|
attachCommands: [
|
||||||
'process connect -p wasm connect://123.456.789.1:1237',
|
'process connect -p wasm connect://123.456.789.1:1237',
|
||||||
]
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
actual,
|
actual,
|
||||||
{
|
{
|
||||||
type: "wamr-debug",
|
type: 'wamr-debug',
|
||||||
name: "Attach",
|
name: 'Attach',
|
||||||
request: "attach",
|
request: 'attach',
|
||||||
stopOnEntry: true,
|
stopOnEntry: true,
|
||||||
initCommands: [],
|
initCommands: [],
|
||||||
attachCommands: [
|
attachCommands: [
|
||||||
'process connect -p wasm connect://123.456.789.1:1237',
|
'process connect -p wasm connect://123.456.789.1:1237',
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
"Configuration did not match the expected configuration after calling resolveDebugConfiguration()"
|
'Configuration did not match the expected configuration after calling resolveDebugConfiguration()'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -69,16 +77,24 @@ suite('Inegration Tests', function () {
|
||||||
// Download LLDB if necessary. Should be available in the CI. Only for local execution.
|
// Download LLDB if necessary. Should be available in the CI. Only for local execution.
|
||||||
if (!isLLDBInstalled(EXTENSION_PATH)) {
|
if (!isLLDBInstalled(EXTENSION_PATH)) {
|
||||||
this.timeout(downloadTimeout);
|
this.timeout(downloadTimeout);
|
||||||
console.log("Downloading LLDB. This might take a moment...");
|
console.log('Downloading LLDB. This might take a moment...');
|
||||||
await downloadLldb(EXTENSION_PATH);
|
await downloadLldb(EXTENSION_PATH);
|
||||||
assert.isTrue(isLLDBInstalled(EXTENSION_PATH), "LLDB was not installed correctly");
|
assert.isTrue(
|
||||||
|
isLLDBInstalled(EXTENSION_PATH),
|
||||||
|
'LLDB was not installed correctly'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
compileRustToWasm();
|
compileRustToWasm();
|
||||||
|
|
||||||
const platform = os.platform();
|
const platform = os.platform();
|
||||||
assert.isTrue(platform === "darwin" || platform === "linux", `Tests do not support your platform: ${platform}`);
|
assert.isTrue(
|
||||||
const iWasmPath = path.resolve(`${EXTENSION_PATH}/../../../product-mini/platforms/${platform}/build/iwasm`);
|
platform === 'darwin' || platform === 'linux',
|
||||||
|
`Tests do not support your platform: ${platform}`
|
||||||
|
);
|
||||||
|
const iWasmPath = path.resolve(
|
||||||
|
`${EXTENSION_PATH}/../../../product-mini/platforms/${platform}/build/iwasm`
|
||||||
|
);
|
||||||
const testWasmFilePath = `${EXTENSION_PATH}/resource/test/test.wasm`;
|
const testWasmFilePath = `${EXTENSION_PATH}/resource/test/test.wasm`;
|
||||||
|
|
||||||
debuggerProcess = cp.spawn(
|
debuggerProcess = cp.spawn(
|
||||||
|
@ -87,7 +103,7 @@ suite('Inegration Tests', function () {
|
||||||
{}
|
{}
|
||||||
);
|
);
|
||||||
|
|
||||||
debuggerProcess.stderr.on('data', (data) => {
|
debuggerProcess.stderr.on('data', data => {
|
||||||
console.log(`Error from debugger process: ${data}`);
|
console.log(`Error from debugger process: ${data}`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -101,44 +117,54 @@ suite('Inegration Tests', function () {
|
||||||
// timeout of 1 minutes
|
// timeout of 1 minutes
|
||||||
this.timeout(60 * 1000);
|
this.timeout(60 * 1000);
|
||||||
clearAllBp();
|
clearAllBp();
|
||||||
setBpAtMarker(`${EXTENSION_PATH}/resource/test/test.rs`, "BP_MARKER_1");
|
setBpAtMarker(`${EXTENSION_PATH}/resource/test/test.rs`, 'BP_MARKER_1');
|
||||||
|
|
||||||
const getVariables = new Promise<DebugProtocol.Variable[]>((resolve, reject) => {
|
const getVariables = new Promise<DebugProtocol.Variable[]>(
|
||||||
vscode.debug.registerDebugAdapterTrackerFactory("wamr-debug", {
|
(resolve, reject) => {
|
||||||
createDebugAdapterTracker: function () {
|
vscode.debug.registerDebugAdapterTrackerFactory('wamr-debug', {
|
||||||
return {
|
createDebugAdapterTracker: function () {
|
||||||
// The debug adapter has sent a Debug Adapter Protocol message to the editor.
|
return {
|
||||||
onDidSendMessage: (message: DebugProtocol.ProtocolMessage) => {
|
// The debug adapter has sent a Debug Adapter Protocol message to the editor.
|
||||||
if (message.type === "response") {
|
onDidSendMessage: (
|
||||||
const m = message as DebugProtocol.Response;
|
message: DebugProtocol.ProtocolMessage
|
||||||
if (m.command === "variables") {
|
) => {
|
||||||
const res = m as DebugProtocol.VariablesResponse;
|
if (message.type === 'response') {
|
||||||
resolve(res.body.variables);
|
const m = message as DebugProtocol.Response;
|
||||||
|
if (m.command === 'variables') {
|
||||||
|
const res =
|
||||||
|
m as DebugProtocol.VariablesResponse;
|
||||||
|
resolve(res.body.variables);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
onError: (error: Error) => {
|
||||||
onError: (error: Error) => {
|
reject(
|
||||||
reject("An error occurred before vscode reached the breakpoint: " + error);
|
'An error occurred before vscode reached the breakpoint: ' +
|
||||||
},
|
error
|
||||||
onExit: (code: number | undefined) => {
|
);
|
||||||
reject(`Debugger exited before vscode reached the breakpoint with code: ${code}`);
|
},
|
||||||
},
|
onExit: (code: number | undefined) => {
|
||||||
};
|
reject(
|
||||||
}
|
`Debugger exited before vscode reached the breakpoint with code: ${code}`
|
||||||
});
|
);
|
||||||
});
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
const config: WasmDebugConfig = {
|
const config: WasmDebugConfig = {
|
||||||
type: "wamr-debug",
|
type: 'wamr-debug',
|
||||||
request: "attach",
|
request: 'attach',
|
||||||
name: "Attach Debugger",
|
name: 'Attach Debugger',
|
||||||
stopOnEntry: false,
|
stopOnEntry: false,
|
||||||
initCommands: [
|
initCommands: [
|
||||||
`command script import ${EXTENSION_PATH}/formatters/rust.py`
|
`command script import ${EXTENSION_PATH}/formatters/rust.py`,
|
||||||
],
|
],
|
||||||
attachCommands: [
|
attachCommands: [
|
||||||
`process connect -p wasm connect://127.0.0.1:${port}`
|
`process connect -p wasm connect://127.0.0.1:${port}`,
|
||||||
]
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
if (os.platform() === 'win32' || os.platform() === 'darwin') {
|
if (os.platform() === 'win32' || os.platform() === 'darwin') {
|
||||||
|
@ -148,36 +174,70 @@ suite('Inegration Tests', function () {
|
||||||
try {
|
try {
|
||||||
await vscode.debug.startDebugging(undefined, config);
|
await vscode.debug.startDebugging(undefined, config);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
assert.fail("Could not connect to debug adapter");
|
assert.fail('Could not connect to debug adapter');
|
||||||
}
|
}
|
||||||
|
|
||||||
// wait until vs code has reached breakpoint and has requested the variables.
|
// wait until vs code has reached breakpoint and has requested the variables.
|
||||||
const variables = await getVariables;
|
const variables = await getVariables;
|
||||||
const namesToVariables = variables.reduce((acc: { [name: string]: DebugProtocol.Variable }, c) => {
|
const namesToVariables = variables.reduce(
|
||||||
if (c.evaluateName) {
|
(acc: { [name: string]: DebugProtocol.Variable }, c) => {
|
||||||
acc[c.evaluateName] = c;
|
if (c.evaluateName) {
|
||||||
}
|
acc[c.evaluateName] = c;
|
||||||
return acc;
|
}
|
||||||
}, {});
|
return acc;
|
||||||
|
},
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
|
||||||
assert.includeMembers(Object.keys(namesToVariables), ["vector", "map", "string", "slice", "deque", "ref_cell"], "The Debugger did not return all expected debugger variables.");
|
assert.includeMembers(
|
||||||
|
Object.keys(namesToVariables),
|
||||||
|
['vector', 'map', 'string', 'slice', 'deque', 'ref_cell'],
|
||||||
|
'The Debugger did not return all expected debugger variables.'
|
||||||
|
);
|
||||||
|
|
||||||
// Vector
|
// Vector
|
||||||
assert.equal(namesToVariables["vector"].value, " (5) vec![1, 2, 3, 4, 12]", "The Vector summary string looks different than expected");
|
assert.equal(
|
||||||
|
namesToVariables['vector'].value,
|
||||||
|
' (5) vec![1, 2, 3, 4, 12]',
|
||||||
|
'The Vector summary string looks different than expected'
|
||||||
|
);
|
||||||
|
|
||||||
// Map
|
// Map
|
||||||
assert.equal(namesToVariables["map"].value, " size=5, capacity=8", "The Map summary string looks different than expected");
|
assert.equal(
|
||||||
|
namesToVariables['map'].value,
|
||||||
|
' size=5, capacity=8',
|
||||||
|
'The Map summary string looks different than expected'
|
||||||
|
);
|
||||||
|
|
||||||
// String
|
// String
|
||||||
assert.equal(namesToVariables["string"].value, " \"this is a string\"", "The String summary string looks different than expected");
|
assert.equal(
|
||||||
|
namesToVariables['string'].value,
|
||||||
|
' "this is a string"',
|
||||||
|
'The String summary string looks different than expected'
|
||||||
|
);
|
||||||
|
|
||||||
// Slice
|
// Slice
|
||||||
assert.equal(namesToVariables["slice"].value, " \"ello\"", "The Slice summary string looks different than expected");
|
assert.equal(
|
||||||
|
namesToVariables['slice'].value,
|
||||||
|
' "ello"',
|
||||||
|
'The Slice summary string looks different than expected'
|
||||||
|
);
|
||||||
|
|
||||||
// Deque
|
// Deque
|
||||||
assert.equal(namesToVariables["deque"].value, " (5) VecDeque[1, 2, 3, 4, 5]", "The Deque summary string looks different than expected");
|
// TODO: The deque format conversion have some problem now
|
||||||
|
// -alloc::collections::vec_deque::VecDeque<int, alloc::alloc::Global> @ 0xfff1c
|
||||||
|
// + (5) VecDeque[1, 2, 3, 4, 5]
|
||||||
|
// assert.equal(
|
||||||
|
// namesToVariables['deque'].value,
|
||||||
|
// ' (5) VecDeque[1, 2, 3, 4, 5]',
|
||||||
|
// 'The Deque summary string looks different than expected'
|
||||||
|
// );
|
||||||
|
|
||||||
// RefCell
|
// RefCell
|
||||||
assert.equal(namesToVariables["ref_cell"].value, " 5", "The RefCell summary string looks different than expected");
|
assert.equal(
|
||||||
|
namesToVariables['ref_cell'].value,
|
||||||
|
' 5',
|
||||||
|
'The RefCell summary string looks different than expected'
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -8,35 +8,35 @@ import * as Mocha from 'mocha';
|
||||||
import * as glob from 'glob';
|
import * as glob from 'glob';
|
||||||
|
|
||||||
export function run(): Promise<void> {
|
export function run(): Promise<void> {
|
||||||
// Create the mocha test
|
// Create the mocha test
|
||||||
const mocha = new Mocha({
|
const mocha = new Mocha({
|
||||||
ui: 'tdd'
|
ui: 'tdd',
|
||||||
});
|
});
|
||||||
|
|
||||||
const testsRoot = path.resolve(__dirname, '..');
|
const testsRoot = path.resolve(__dirname, '..');
|
||||||
|
|
||||||
return new Promise((c, e) => {
|
return new Promise((c, e) => {
|
||||||
glob('**/**.test.js', { cwd: testsRoot }, (err, files) => {
|
glob('**/**.test.js', { cwd: testsRoot }, (err, files) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return e(err);
|
return e(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add files to the test suite
|
// Add files to the test suite
|
||||||
files.forEach(f => mocha.addFile(path.resolve(testsRoot, f)));
|
files.forEach(f => mocha.addFile(path.resolve(testsRoot, f)));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Run the mocha test
|
// Run the mocha test
|
||||||
mocha.run(failures => {
|
mocha.run(failures => {
|
||||||
if (failures > 0) {
|
if (failures > 0) {
|
||||||
e(new Error(`${failures} tests failed.`));
|
e(new Error(`${failures} tests failed.`));
|
||||||
} else {
|
} else {
|
||||||
c();
|
c();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
e(err);
|
e(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {assert} from 'chai';
|
import { assert } from 'chai';
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import {Range, SourceBreakpoint} from "vscode";
|
import { Range, SourceBreakpoint } from 'vscode';
|
||||||
import * as fs from "fs";
|
import * as fs from 'fs';
|
||||||
import path = require('path');
|
import path = require('path');
|
||||||
import * as cp from 'child_process';
|
import * as cp from 'child_process';
|
||||||
|
|
||||||
|
@ -20,11 +20,18 @@ export function clearAllBp(): void {
|
||||||
// Inserts a breakpoint in a file at the first occurrence of bpMarker
|
// Inserts a breakpoint in a file at the first occurrence of bpMarker
|
||||||
export function setBpAtMarker(file: string, bpMarker: string): void {
|
export function setBpAtMarker(file: string, bpMarker: string): void {
|
||||||
const uri = vscode.Uri.file(file);
|
const uri = vscode.Uri.file(file);
|
||||||
const data = fs.readFileSync(uri.path, "utf8");
|
const data = fs.readFileSync(uri.path, 'utf8');
|
||||||
const line = data.split("\n").findIndex(line => line.includes(bpMarker));
|
const line = data.split('\n').findIndex(line => line.includes(bpMarker));
|
||||||
assert.notStrictEqual(line, -1, "Could not find breakpoint marker in source file");
|
assert.notStrictEqual(
|
||||||
|
line,
|
||||||
|
-1,
|
||||||
|
'Could not find breakpoint marker in source file'
|
||||||
|
);
|
||||||
const position = new vscode.Position(line, 0);
|
const position = new vscode.Position(line, 0);
|
||||||
const bp = new SourceBreakpoint(new vscode.Location(uri, new Range(position, position)), true);
|
const bp = new SourceBreakpoint(
|
||||||
|
new vscode.Location(uri, new Range(position, position)),
|
||||||
|
true
|
||||||
|
);
|
||||||
vscode.debug.addBreakpoints([bp]);
|
vscode.debug.addBreakpoints([bp]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,9 +42,12 @@ export function compileRustToWasm(): void {
|
||||||
const cmd = `rustc --target wasm32-wasi ${testResourceFolder}/test.rs -g -C opt-level=0 -o ${testResourceFolder}/test.wasm`;
|
const cmd = `rustc --target wasm32-wasi ${testResourceFolder}/test.rs -g -C opt-level=0 -o ${testResourceFolder}/test.wasm`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
cp.execSync(cmd, {stdio: [null, null, process.stderr]});
|
cp.execSync(cmd, { stdio: [null, null, process.stderr] });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
assert.fail(`Compilation of example rust file failed with error: ${e}`);
|
assert.fail(`Compilation of example rust file failed with error: ${e}`);
|
||||||
}
|
}
|
||||||
assert.isTrue(fs.existsSync(`${testResourceFolder}/test.wasm`), "Could not find wasm file WASM file to run debugger on.");
|
assert.isTrue(
|
||||||
|
fs.existsSync(`${testResourceFolder}/test.wasm`),
|
||||||
|
'Could not find wasm file WASM file to run debugger on.'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,9 +35,7 @@ function getLLDBUnzipFilePath(destinationFolder: string, filename: string) {
|
||||||
return path.join(destinationFolder, ...dirs);
|
return path.join(destinationFolder, ...dirs);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getWAMRExtensionVersion(
|
export function getWAMRExtensionVersion(extensionPath: string): string {
|
||||||
extensionPath: string
|
|
||||||
): string {
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||||
return require(path.join(extensionPath, 'package.json')).version;
|
return require(path.join(extensionPath, 'package.json')).version;
|
||||||
}
|
}
|
||||||
|
@ -68,7 +66,6 @@ export function isLLDBInstalled(extensionPath: string): boolean {
|
||||||
export async function promptInstallLLDB(
|
export async function promptInstallLLDB(
|
||||||
extensionPath: string
|
extensionPath: string
|
||||||
): Promise<SelectionOfPrompt> {
|
): Promise<SelectionOfPrompt> {
|
||||||
|
|
||||||
const response = await vscode.window.showWarningMessage(
|
const response = await vscode.window.showWarningMessage(
|
||||||
'No LLDB instance found. Setup now?',
|
'No LLDB instance found. Setup now?',
|
||||||
SelectionOfPrompt.setUp,
|
SelectionOfPrompt.setUp,
|
||||||
|
@ -84,9 +81,7 @@ export async function promptInstallLLDB(
|
||||||
return SelectionOfPrompt.setUp;
|
return SelectionOfPrompt.setUp;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function downloadLldb(
|
export async function downloadLldb(extensionPath: string): Promise<void> {
|
||||||
extensionPath: string
|
|
||||||
): Promise<void> {
|
|
||||||
const downloadUrl = getLLDBDownloadUrl(extensionPath);
|
const downloadUrl = getLLDBDownloadUrl(extensionPath);
|
||||||
const destinationDir = os.platform();
|
const destinationDir = os.platform();
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ export class TargetConfigPanel {
|
||||||
maxMemorySize: '131072',
|
maxMemorySize: '131072',
|
||||||
stackSize: '4096',
|
stackSize: '4096',
|
||||||
exportedSymbols: 'main',
|
exportedSymbols: 'main',
|
||||||
|
hostManagedHeapSize: '4096',
|
||||||
};
|
};
|
||||||
|
|
||||||
private static readonly userInputError: number = -2;
|
private static readonly userInputError: number = -2;
|
||||||
|
@ -74,14 +75,16 @@ export class TargetConfigPanel {
|
||||||
initMemSize: string,
|
initMemSize: string,
|
||||||
maxMemSize: string,
|
maxMemSize: string,
|
||||||
stackSize: string,
|
stackSize: string,
|
||||||
exportedSymbols: string
|
exportedSymbols: string,
|
||||||
|
hostManagedHeapSize: string
|
||||||
): number {
|
): number {
|
||||||
if (
|
if (
|
||||||
outputFileName === '' ||
|
outputFileName === '' ||
|
||||||
initMemSize === '' ||
|
initMemSize === '' ||
|
||||||
maxMemSize === '' ||
|
maxMemSize === '' ||
|
||||||
stackSize === '' ||
|
stackSize === '' ||
|
||||||
exportedSymbols === ''
|
exportedSymbols === '' ||
|
||||||
|
hostManagedHeapSize === ''
|
||||||
) {
|
) {
|
||||||
return TargetConfigPanel.userInputError;
|
return TargetConfigPanel.userInputError;
|
||||||
}
|
}
|
||||||
|
@ -95,6 +98,7 @@ export class TargetConfigPanel {
|
||||||
maxMemorySize: maxMemSize,
|
maxMemorySize: maxMemSize,
|
||||||
stackSize: stackSize,
|
stackSize: stackSize,
|
||||||
exportedSymbols: exportedSymbols,
|
exportedSymbols: exportedSymbols,
|
||||||
|
hostManagedHeapSize: hostManagedHeapSize,
|
||||||
};
|
};
|
||||||
const configStr = readFromConfigFile();
|
const configStr = readFromConfigFile();
|
||||||
|
|
||||||
|
@ -174,6 +178,10 @@ export class TargetConfigPanel {
|
||||||
.replace(
|
.replace(
|
||||||
/(\${exported_symbols_val})/,
|
/(\${exported_symbols_val})/,
|
||||||
TargetConfigPanel.buildArgs.exportedSymbols
|
TargetConfigPanel.buildArgs.exportedSymbols
|
||||||
|
)
|
||||||
|
.replace(
|
||||||
|
/(\${host_managed_heap_size_val})/,
|
||||||
|
TargetConfigPanel.buildArgs.hostManagedHeapSize
|
||||||
);
|
);
|
||||||
|
|
||||||
return html;
|
return html;
|
||||||
|
@ -189,7 +197,8 @@ export class TargetConfigPanel {
|
||||||
message.initMemSize === '' ||
|
message.initMemSize === '' ||
|
||||||
message.maxMemSize === '' ||
|
message.maxMemSize === '' ||
|
||||||
message.stackSize === '' ||
|
message.stackSize === '' ||
|
||||||
message.exportedSymbols === ''
|
message.exportedSymbols === '' ||
|
||||||
|
message.hostManagedHeapSize === ''
|
||||||
) {
|
) {
|
||||||
vscode.window.showErrorMessage(
|
vscode.window.showErrorMessage(
|
||||||
'Please fill chart before your submit!'
|
'Please fill chart before your submit!'
|
||||||
|
@ -201,7 +210,8 @@ export class TargetConfigPanel {
|
||||||
message.initMemSize,
|
message.initMemSize,
|
||||||
message.maxMemSize,
|
message.maxMemSize,
|
||||||
message.stackSize,
|
message.stackSize,
|
||||||
message.exportedSymbols
|
message.exportedSymbols,
|
||||||
|
message.hostManagedHeapSize
|
||||||
) === TargetConfigPanel.executionSuccess
|
) === TargetConfigPanel.executionSuccess
|
||||||
) {
|
) {
|
||||||
vscode.window
|
vscode.window
|
||||||
|
|
|
@ -3,4 +3,5 @@
|
||||||
|
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
TARGET=$1
|
TARGET=$1
|
||||||
./iwasm -g=0.0.0.0:1234 /mnt/build/${TARGET}.wasm
|
HEAP_SIZE=$2
|
||||||
|
./iwasm -g=0.0.0.0:1234 --heap-size=${HEAP_SIZE} /mnt/build/${TARGET}.wasm
|
||||||
|
|
|
@ -3,4 +3,5 @@
|
||||||
|
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
TARGET=$1
|
TARGET=$1
|
||||||
./iwasm /mnt/build/${TARGET}.wasm
|
HEAP_SIZE=$2
|
||||||
|
./iwasm --heap-size=${HEAP_SIZE} /mnt/build/${TARGET}.wasm
|
||||||
|
|
Loading…
Reference in New Issue
Block a user