Skip to content

Commit 1d9fdfc

Browse files
Merge branch 'bytecodealliance:main' into feature/remove_const_indirect_load
2 parents 29175ec + 5d8fe5d commit 1d9fdfc

37 files changed

+4778
-2064
lines changed

.github/workflows/codeql.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353

5454
# Initializes the CodeQL tools for scanning.
5555
- name: Initialize CodeQL
56-
uses: github/codeql-action/[email protected].10
56+
uses: github/codeql-action/[email protected].11
5757
with:
5858
languages: ${{ matrix.language }}
5959

@@ -70,7 +70,7 @@ jobs:
7070
- run: |
7171
./.github/scripts/codeql_buildscript.sh
7272
- name: Perform CodeQL Analysis
73-
uses: github/codeql-action/[email protected].10
73+
uses: github/codeql-action/[email protected].11
7474
with:
7575
category: "/language:${{matrix.language}}"
7676
upload: false
@@ -99,7 +99,7 @@ jobs:
9999
output: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif
100100

101101
- name: Upload CodeQL results to code scanning
102-
uses: github/codeql-action/[email protected].10
102+
uses: github/codeql-action/[email protected].11
103103
with:
104104
sarif_file: ${{ steps.step1.outputs.sarif-output }}
105105
category: "/language:${{matrix.language}}"

.github/workflows/compilation_on_android_ubuntu.yml

+3-6
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ jobs:
158158
"-DWAMR_BUILD_PERF_PROFILING=1",
159159
"-DWAMR_BUILD_REF_TYPES=1",
160160
"-DWAMR_BUILD_SIMD=1",
161+
"-DWAMR_BUILD_LIB_SIMDE=1",
161162
"-DWAMR_BUILD_TAIL_CALL=1",
162163
"-DWAMR_DISABLE_HW_BOUND_CHECK=1",
163164
"-DWAMR_BUILD_MEMORY64=1",
@@ -178,11 +179,9 @@ jobs:
178179
make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
179180
- make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
180181
make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
181-
# SIMD only on JIT/AOT mode
182+
# SIMD only on JIT/AOT/fast interpreter mode
182183
- make_options_run_mode: $CLASSIC_INTERP_BUILD_OPTIONS
183184
make_options_feature: "-DWAMR_BUILD_SIMD=1"
184-
- make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
185-
make_options_feature: "-DWAMR_BUILD_SIMD=1"
186185
# DEBUG_INTERP only on CLASSIC INTERP mode
187186
- make_options_run_mode: $AOT_BUILD_OPTIONS
188187
make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
@@ -649,11 +648,9 @@ jobs:
649648
test_option: $WAMR_COMPILER_TEST_OPTIONS
650649
exclude:
651650
# incompatible modes and features
652-
# classic-interp and fast-interp don't support simd
651+
# classic-interp doesn't support simd
653652
- running_mode: "classic-interp"
654653
test_option: $SIMD_TEST_OPTIONS
655-
- running_mode: "fast-interp"
656-
test_option: $SIMD_TEST_OPTIONS
657654
# llvm jit doesn't support multi module
658655
- running_mode: "jit"
659656
test_option: $MULTI_MODULES_TEST_OPTIONS

.github/workflows/compilation_on_nuttx.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,14 @@ jobs:
8888
uses: actions/checkout@v4
8989
with:
9090
repository: apache/nuttx
91-
ref: releases/12.6
91+
ref: releases/12.9
9292
path: nuttx
9393

9494
- name: Checkout NuttX Apps
9595
uses: actions/checkout@v4
9696
with:
9797
repository: apache/nuttx-apps
98-
ref: releases/12.6
98+
ref: releases/12.9
9999
path: apps
100100

101101
- name: Checkout WAMR

.github/workflows/compilation_on_sgx.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ env:
4949
# ref types enabled in wamrc by default, so we need to enable it for iwasm in AOT mode
5050
AOT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0 -DWAMR_BUILD_REF_TYPES=1"
5151
CLASSIC_INTERP_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=0 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
52-
FAST_INTERP_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=0 -DWAMR_BUILD_FAST_INTERP=1 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
52+
FAST_INTERP_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=0 -DWAMR_BUILD_FAST_INTERP=1 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0 -DWAMR_BUILD_SIMD=0"
5353
FAST_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=1"
5454
LLVM_LAZY_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=1"
5555
LLVM_EAGER_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=0"
@@ -97,7 +97,7 @@ jobs:
9797
"-DWAMR_BUILD_PERF_PROFILING=1",
9898
"-DWAMR_BUILD_REF_TYPES=1",
9999
# doesn't support
100-
# "-DWAMR_BUILD_SIMD=1",
100+
"-DWAMR_BUILD_SIMD=0",
101101
"-DWAMR_BUILD_TAIL_CALL=1",
102102
"-DWAMR_DISABLE_HW_BOUND_CHECK=1",
103103
"-DWAMR_BUILD_SGX_IPFS=1",

.github/workflows/spec_test_on_nuttx.yml

+2-24
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,14 @@ jobs:
146146
uses: actions/checkout@v4
147147
with:
148148
repository: apache/nuttx
149-
ref: ${{ matrix.target_config.target == 'xtensa' && '985d395b025cf2012b22f6bb4461959fa6d87645' || 'releases/12.6' }}
149+
ref: ${{ matrix.target_config.target == 'xtensa' && '985d395b025cf2012b22f6bb4461959fa6d87645' || 'releases/12.9' }}
150150
path: nuttx
151151

152152
- name: Checkout NuttX Apps
153153
uses: actions/checkout@v4
154154
with:
155155
repository: apache/nuttx-apps
156-
ref: ${{ matrix.target_config.target == 'xtensa' && '2ef3eb25c0cec944b13792185f7e5d5a05990d5f' || 'releases/12.6' }}
156+
ref: ${{ matrix.target_config.target == 'xtensa' && '2ef3eb25c0cec944b13792185f7e5d5a05990d5f' || 'releases/12.9' }}
157157
path: apps
158158

159159
- name: Checkout WAMR
@@ -183,28 +183,6 @@ jobs:
183183
if: contains(matrix.wamr_test_option.mode, 'aot')
184184
run: cp -r core/deps/llvm apps/interpreters/wamr/wamr/core/deps/llvm
185185

186-
# Inject the config option to NuttX
187-
# TODO: Merge this into NuttX once GC is generally available
188-
#
189-
# Note: the version of nuttx-apps we use for xtensa does have
190-
# an equivalent. (the default of INTERPRETERS_WAMR_TAIL_CALL is
191-
# different though.)
192-
- name: Modify Kconfig
193-
if: matrix.target_config.target != 'xtensa'
194-
run: |
195-
echo "\n" >> apps/interpreters/wamr/Kconfig
196-
echo "config INTERPRETERS_WAMR_GC" >> apps/interpreters/wamr/Kconfig
197-
echo "\tbool \"Enable GC\"" >> apps/interpreters/wamr/Kconfig
198-
echo "\tdefault n" >> apps/interpreters/wamr/Kconfig
199-
echo "\n" >> apps/interpreters/wamr/Kconfig
200-
echo "config INTERPRETERS_WAMR_AOT_STACK_FRAME" >> apps/interpreters/wamr/Kconfig
201-
echo "\tbool \"Enable AOT stack frame\"" >> apps/interpreters/wamr/Kconfig
202-
echo "\tdefault n" >> apps/interpreters/wamr/Kconfig
203-
echo "\n" >> apps/interpreters/wamr/Kconfig
204-
echo "config INTERPRETERS_WAMR_TAIL_CALL" >> apps/interpreters/wamr/Kconfig
205-
echo "\tbool \"Enable Tail Call\"" >> apps/interpreters/wamr/Kconfig
206-
echo "\tdefault y" >> apps/interpreters/wamr/Kconfig
207-
208186
- name: Build wamrc
209187
if: contains(matrix.wamr_test_option.mode, 'aot')
210188
working-directory: apps/interpreters/wamr/wamr/wamr-compiler

.github/workflows/supply_chain.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,6 @@ jobs:
6060

6161
# Upload the results to GitHub's code scanning dashboard.
6262
- name: "Upload to code-scanning"
63-
uses: github/codeql-action/upload-sarif@ff79de67cc25c7617163ae1e4b8aa23b902fdf15
63+
uses: github/codeql-action/upload-sarif@b2e6519679e446e7bb7c3466d70f13a6b5461fcd
6464
with:
6565
sarif_file: results.sarif

CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ if (NOT DEFINED WAMR_BUILD_LIB_WASI_THREADS)
9999
set (WAMR_BUILD_LIB_WASI_THREADS 0)
100100
endif ()
101101

102+
if (NOT DEFINED WAMR_ENABLE_COPY_CALLSTACK)
103+
# Disable copy callstack by default
104+
set (WAMR_ENABLE_COPY_CALLSTACK 0)
105+
endif()
106+
102107
if (NOT DEFINED WAMR_BUILD_MINI_LOADER)
103108
# Disable wasm mini loader by default
104109
set (WAMR_BUILD_MINI_LOADER 0)

build-scripts/config_common.cmake

+20-3
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,9 @@ endif ()
300300
if (WAMR_BUILD_LIB_RATS EQUAL 1)
301301
message (" Lib rats enabled")
302302
endif()
303+
if ((WAMR_BUILD_LIB_SIMDE EQUAL 1))
304+
message (" Lib simde enabled")
305+
endif()
303306
################## WAMR features ##################
304307
if (WAMR_BUILD_MULTI_MODULE EQUAL 1)
305308
add_definitions (-DWASM_ENABLE_MULTI_MODULE=1)
@@ -324,6 +327,14 @@ if (WAMR_BUILD_SHARED_HEAP EQUAL 1)
324327
message (" Shared heap enabled")
325328
endif()
326329

330+
if (WAMR_ENABLE_COPY_CALLSTACK EQUAL 1)
331+
add_definitions (-DWAMR_ENABLE_COPY_CALLSTACK=1)
332+
message(" Copy callstack enabled")
333+
else ()
334+
add_definitions (-DWAMR_ENABLE_COPY_CALLSTACK=0)
335+
message(" Copy callstack disabled")
336+
endif()
337+
327338
if (WAMR_BUILD_MEMORY64 EQUAL 1)
328339
# if native is 32-bit or cross-compiled to 32-bit
329340
if (NOT WAMR_BUILD_TARGET MATCHES ".*64.*")
@@ -363,11 +374,17 @@ else ()
363374
message (" Wakeup of blocking operations enabled")
364375
endif ()
365376
if (WAMR_BUILD_SIMD EQUAL 1)
366-
if (NOT WAMR_BUILD_TARGET MATCHES "RISCV64.*")
367-
add_definitions (-DWASM_ENABLE_SIMD=1)
368-
else ()
377+
if (WAMR_BUILD_FAST_INTERP EQUAL 1 AND WAMR_BUILD_SIMDE EQUAL 0)
378+
set(SIMD_ENABLED 0)
379+
message(" SIMD disabled for fast-interp as simde is not being built")
380+
elseif (WAMR_BUILD_TARGET MATCHES "RISCV64.*")
381+
set(SIMD_ENABLED 0)
369382
message (" SIMD disabled due to not supported on target RISCV64")
383+
else()
384+
set(SIMD_ENABLED 1)
385+
message (" SIMD enabled")
370386
endif ()
387+
add_definitions(-DWASM_ENABLE_SIMD=${SIMD_ENABLED})
371388
endif ()
372389
if (WAMR_BUILD_AOT_STACK_FRAME EQUAL 1)
373390
add_definitions (-DWASM_ENABLE_AOT_STACK_FRAME=1)

build-scripts/runtime_lib.cmake

+10
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,16 @@ if (WAMR_BUILD_LIB_RATS EQUAL 1)
155155
include (${IWASM_DIR}/libraries/lib-rats/lib_rats.cmake)
156156
endif ()
157157

158+
if (WAMR_BUILD_SIMD EQUAL 1 AND WAMR_BUILD_FAST_INTERP EQUAL 1)
159+
if (WAMR_BUILD_PLATFORM STREQUAL "windows")
160+
message(STATUS "SIMDe doesnt support platform " ${WAMR_BUILD_PLATFORM})
161+
set(WAMR_BUILD_SIMDE 0)
162+
else()
163+
include (${IWASM_DIR}/libraries/simde/simde.cmake)
164+
set (WAMR_BUILD_SIMDE 1)
165+
endif()
166+
endif ()
167+
158168
if (WAMR_BUILD_WASM_CACHE EQUAL 1)
159169
include (${WAMR_ROOT_DIR}/build-scripts/involve_boringssl.cmake)
160170
endif ()

ci/coding_guidelines_check.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def run_clang_format_diff(root: Path, commits: str) -> bool:
145145
found = False
146146
for summary in [x for x in diff_content if x.startswith("diff --git")]:
147147
# b/path/to/file -> path/to/file
148-
with_invalid_format = re.split("\s+", summary)[-1][2:]
148+
with_invalid_format = re.split(r"\s+", summary)[-1][2:]
149149
if not is_excluded(with_invalid_format):
150150
print(f"--- {with_invalid_format} failed on code style checking.")
151151
found = True

core/config.h

+10
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@
193193
#error "Heap aux stack allocation must be enabled for WASI threads"
194194
#endif
195195

196+
#ifndef WAMR_ENABLE_COPY_CALLSTACK
197+
#define WAMR_ENABLE_COPY_CALLSTACK 0
198+
#endif
199+
196200
#ifndef WASM_ENABLE_BASE_LIB
197201
#define WASM_ENABLE_BASE_LIB 0
198202
#endif
@@ -318,6 +322,12 @@
318322
#define WASM_ENABLE_SIMD 0
319323
#endif
320324

325+
/* Disable SIMDe (used in the fast interpreter for SIMD opcodes)
326+
unless used elsewhere */
327+
#ifndef WASM_ENABLE_SIMDE
328+
#define WASM_ENABLE_SIMDE 0
329+
#endif
330+
321331
/* GC performance profiling */
322332
#ifndef WASM_ENABLE_GC_PERF_PROFILING
323333
#define WASM_ENABLE_GC_PERF_PROFILING 0

core/iwasm/aot/aot_runtime.c

+130
Original file line numberDiff line numberDiff line change
@@ -4103,6 +4103,136 @@ aot_frame_update_profile_info(WASMExecEnv *exec_env, bool alloc_frame)
41034103
}
41044104
#endif /* end of WASM_ENABLE_AOT_STACK_FRAME != 0 */
41054105

4106+
#if WAMR_ENABLE_COPY_CALLSTACK != 0
4107+
uint32
4108+
aot_copy_callstack_tiny_frame(WASMExecEnv *exec_env, wasm_frame_t *buffer,
4109+
const uint32 length, const uint32 skip_n,
4110+
char *error_buf, uint32 error_buf_size)
4111+
{
4112+
/*
4113+
* Note for devs: please refrain from such modifications inside of
4114+
* aot_copy_callstack_tiny_frame
4115+
* - any allocations/freeing memory
4116+
* - dereferencing any pointers other than: exec_env, exec_env->module_inst,
4117+
* exec_env->module_inst->module, pointers between stack's bottom and
4118+
* top_boundary For more details check wasm_copy_callstack in
4119+
* wasm_export.h
4120+
*/
4121+
uint8 *top_boundary = exec_env->wasm_stack.top_boundary;
4122+
uint8 *top = exec_env->wasm_stack.top;
4123+
uint8 *bottom = exec_env->wasm_stack.bottom;
4124+
uint32 count = 0;
4125+
4126+
bool is_top_index_in_range =
4127+
top_boundary >= top && top >= (bottom + sizeof(AOTTinyFrame));
4128+
if (!is_top_index_in_range) {
4129+
char *err_msg =
4130+
"Top of the stack pointer is outside of the stack boundaries";
4131+
strncpy(error_buf, err_msg, error_buf_size);
4132+
return 0;
4133+
}
4134+
bool is_top_aligned_with_bottom =
4135+
(unsigned long)(top - bottom) % sizeof(AOTTinyFrame) == 0;
4136+
if (!is_top_aligned_with_bottom) {
4137+
char *err_msg = "Top of the stack is not aligned with the bottom";
4138+
strncpy(error_buf, err_msg, error_buf_size);
4139+
return 0;
4140+
}
4141+
4142+
AOTTinyFrame *frame = (AOTTinyFrame *)(top - sizeof(AOTTinyFrame));
4143+
WASMCApiFrame record_frame;
4144+
while (frame && (uint8_t *)frame >= bottom && count < (skip_n + length)) {
4145+
if (count < skip_n) {
4146+
++count;
4147+
frame -= 1;
4148+
continue;
4149+
}
4150+
record_frame.instance = exec_env->module_inst;
4151+
record_frame.module_offset = 0;
4152+
record_frame.func_index = frame->func_index;
4153+
record_frame.func_offset = frame->ip_offset;
4154+
buffer[count - skip_n] = record_frame;
4155+
frame -= 1;
4156+
++count;
4157+
}
4158+
return count >= skip_n ? count - skip_n : 0;
4159+
}
4160+
4161+
uint32
4162+
aot_copy_callstack_standard_frame(WASMExecEnv *exec_env, wasm_frame_t *buffer,
4163+
const uint32 length, const uint32 skip_n,
4164+
char *error_buf, uint32_t error_buf_size)
4165+
{
4166+
/*
4167+
* Note for devs: please refrain from such modifications inside of
4168+
* aot_iterate_callstack_standard_frame
4169+
* - any allocations/freeing memory
4170+
* - dereferencing any pointers other than: exec_env, exec_env->module_inst,
4171+
* exec_env->module_inst->module, pointers between stack's bottom and
4172+
* top_boundary For more details check wasm_iterate_callstack in
4173+
* wasm_export.h
4174+
*/
4175+
4176+
uint32 count = 0;
4177+
#if WASM_ENABLE_GC == 0
4178+
WASMModuleInstance *module_inst =
4179+
(WASMModuleInstance *)wasm_exec_env_get_module_inst(exec_env);
4180+
AOTFrame *cur_frame = (AOTFrame *)wasm_exec_env_get_cur_frame(exec_env);
4181+
uint8 *top_boundary = exec_env->wasm_stack.top_boundary;
4182+
uint8 *bottom = exec_env->wasm_stack.bottom;
4183+
uint32 frame_size = (uint32)offsetof(AOTFrame, lp);
4184+
4185+
WASMCApiFrame record_frame;
4186+
while (cur_frame && (uint8_t *)cur_frame >= bottom
4187+
&& (uint8_t *)cur_frame + frame_size <= top_boundary
4188+
&& count < (skip_n + length)) {
4189+
if (count < skip_n) {
4190+
++count;
4191+
cur_frame = cur_frame->prev_frame;
4192+
continue;
4193+
}
4194+
record_frame.instance = module_inst;
4195+
record_frame.module_offset = 0;
4196+
record_frame.func_index = (uint32)cur_frame->func_index;
4197+
record_frame.func_offset = (uint32)cur_frame->ip_offset;
4198+
buffer[count - skip_n] = record_frame;
4199+
cur_frame = cur_frame->prev_frame;
4200+
++count;
4201+
}
4202+
#else
4203+
/*
4204+
* TODO: add support for standard frames when GC is enabled
4205+
* now it poses a risk due to variable size of the frame
4206+
*/
4207+
#endif
4208+
return count >= skip_n ? count - skip_n : 0;
4209+
}
4210+
4211+
uint32
4212+
aot_copy_callstack(WASMExecEnv *exec_env, wasm_frame_t *buffer,
4213+
const uint32 length, const uint32 skip_n, char *error_buf,
4214+
uint32_t error_buf_size)
4215+
{
4216+
/*
4217+
* Note for devs: please refrain from such modifications inside of
4218+
* aot_iterate_callstack
4219+
* - any allocations/freeing memory
4220+
* - dereferencing any pointers other than: exec_env, exec_env->module_inst,
4221+
* exec_env->module_inst->module, pointers between stack's bottom and
4222+
* top_boundary For more details check wasm_iterate_callstack in
4223+
* wasm_export.h
4224+
*/
4225+
if (!is_tiny_frame(exec_env)) {
4226+
return aot_copy_callstack_standard_frame(
4227+
exec_env, buffer, length, skip_n, error_buf, error_buf_size);
4228+
}
4229+
else {
4230+
return aot_copy_callstack_tiny_frame(exec_env, buffer, length, skip_n,
4231+
error_buf, error_buf_size);
4232+
}
4233+
}
4234+
#endif // WAMR_ENABLE_COPY_CALLSTACK
4235+
41064236
#if WASM_ENABLE_DUMP_CALL_STACK != 0
41074237
bool
41084238
aot_create_call_stack(struct WASMExecEnv *exec_env)

0 commit comments

Comments
 (0)