Skip to content

Commit 8cf0c72

Browse files
authored
Merge pull request #897 from bytecodealliance/main
Merge main into dev/socket_api
2 parents d6f90ac + e70867c commit 8cf0c72

File tree

7 files changed

+95
-129
lines changed

7 files changed

+95
-129
lines changed

core/iwasm/aot/aot_loader.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,11 +1689,19 @@ resolve_target_sym(const char *symbol, int32 *p_index)
16891689
if (!(target_sym_map = get_target_symbol_map(&num)))
16901690
return NULL;
16911691

1692-
for (i = 0; i < num; i++)
1693-
if (!strcmp(target_sym_map[i].symbol_name, symbol)) {
1692+
for (i = 0; i < num; i++) {
1693+
if (!strcmp(target_sym_map[i].symbol_name, symbol)
1694+
#if defined(_WIN32) || defined(_WIN32_)
1695+
/* In Win32, the symbol name of function added by
1696+
LLVMAddFunction() is prefixed by '_', ignore it */
1697+
|| (strlen(symbol) > 1 && symbol[0] == '_'
1698+
&& !strcmp(target_sym_map[i].symbol_name, symbol + 1))
1699+
#endif
1700+
) {
16941701
*p_index = (int32)i;
16951702
return target_sym_map[i].symbol_addr;
16961703
}
1704+
}
16971705
return NULL;
16981706
}
16991707

core/iwasm/compilation/aot_emit_aot_file.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -149,17 +149,17 @@ static void dump_buf(uint8 *buf, uint32 size, char *title)
149149
#endif
150150

151151
static bool
152-
is_32bit_binary(LLVMBinaryRef binary)
152+
is_32bit_binary(const AOTObjectData *obj_data)
153153
{
154-
LLVMBinaryType type = LLVMBinaryGetType(binary);
155-
return (type == LLVMBinaryTypeELF32L || type == LLVMBinaryTypeELF32B);
154+
/* bit 1: 0 is 32-bit, 1 is 64-bit */
155+
return obj_data->target_info.bin_type & 2 ? false : true;
156156
}
157157

158158
static bool
159-
is_little_endian_binary(LLVMBinaryRef binary)
159+
is_little_endian_binary(const AOTObjectData *obj_data)
160160
{
161-
LLVMBinaryType type = LLVMBinaryGetType(binary);
162-
return (type == LLVMBinaryTypeELF32L || type == LLVMBinaryTypeELF64L);
161+
/* bit 0: 0 is little-endian, 1 is big-endian */
162+
return obj_data->target_info.bin_type & 1 ? false : true;
163163
}
164164

165165
static bool
@@ -568,7 +568,7 @@ get_func_section_size(AOTCompData *comp_data, AOTObjectData *obj_data)
568568
/* text offsets + function type indexs */
569569
uint32 size = 0;
570570

571-
if (is_32bit_binary(obj_data->binary))
571+
if (is_32bit_binary(obj_data))
572572
size = (uint32)sizeof(uint32) * comp_data->func_count;
573573
else
574574
size = (uint32)sizeof(uint64) * comp_data->func_count;
@@ -852,7 +852,7 @@ get_relocation_section_size(AOTCompContext *comp_ctx, AOTObjectData *obj_data)
852852
return (uint32)sizeof(uint32) + symbol_table_size
853853
+ get_relocation_groups_size(relocation_groups,
854854
relocation_group_count,
855-
is_32bit_binary(obj_data->binary));
855+
is_32bit_binary(obj_data));
856856
}
857857

858858
static uint32
@@ -1181,7 +1181,7 @@ get_name_section_size(AOTCompData *comp_data)
11811181
return 0;
11821182
}
11831183

1184-
max_aot_buf_size = 4 * (p_end - p);
1184+
max_aot_buf_size = 4 * (uint32)(p_end - p);
11851185
if (!(buf = comp_data->aot_name_section_buf =
11861186
wasm_runtime_malloc(max_aot_buf_size))) {
11871187
aot_set_last_error("allocate memory for custom name section failed.");
@@ -1689,7 +1689,7 @@ aot_emit_func_section(uint8 *buf, uint8 *buf_end, uint32 *p_offset,
16891689
EMIT_U32(section_size);
16901690

16911691
for (i = 0; i < obj_data->func_count; i++, func++) {
1692-
if (is_32bit_binary(obj_data->binary))
1692+
if (is_32bit_binary(obj_data))
16931693
EMIT_U32(func->text_offset);
16941694
else
16951695
EMIT_U64(func->text_offset);
@@ -1816,7 +1816,7 @@ aot_emit_relocation_section(uint8 *buf, uint8 *buf_end, uint32 *p_offset,
18161816
/* emit each relocation */
18171817
for (j = 0; j < relocation_group->relocation_count; j++, relocation++) {
18181818
offset = align_uint(offset, 4);
1819-
if (is_32bit_binary(obj_data->binary)) {
1819+
if (is_32bit_binary(obj_data)) {
18201820
EMIT_U32(relocation->relocation_offset);
18211821
EMIT_U32(relocation->relocation_addend);
18221822
}
@@ -1883,9 +1883,9 @@ aot_emit_name_section(uint8 *buf, uint8 *buf_end, uint32 *p_offset,
18831883
/* sub section id + name section size */
18841884
EMIT_U32(sizeof(uint32) * 1 + comp_data->aot_name_section_size);
18851885
EMIT_U32(AOT_CUSTOM_SECTION_NAME);
1886-
bh_memcpy_s((uint8 *)(buf + offset), buf_end - buf,
1886+
bh_memcpy_s((uint8 *)(buf + offset), (uint32)(buf_end - buf),
18871887
comp_data->aot_name_section_buf,
1888-
comp_data->aot_name_section_size);
1888+
(uint32)comp_data->aot_name_section_size);
18891889
offset += comp_data->aot_name_section_size;
18901890

18911891
*p_offset = offset;
@@ -2321,8 +2321,8 @@ aot_resolve_object_relocation_group(AOTObjectData *obj_data,
23212321
LLVMRelocationIteratorRef rel_itr;
23222322
AOTRelocation *relocation = group->relocations;
23232323
uint32 size;
2324-
bool is_binary_32bit = is_32bit_binary(obj_data->binary);
2325-
bool is_binary_little_endian = is_little_endian_binary(obj_data->binary);
2324+
bool is_binary_32bit = is_32bit_binary(obj_data);
2325+
bool is_binary_little_endian = is_little_endian_binary(obj_data);
23262326
bool has_addend = str_starts_with(group->section_name, ".rela");
23272327
uint8 *rela_content = NULL;
23282328

core/iwasm/compilation/aot_llvm.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,6 +1069,7 @@ static ArchItem valid_archs[] = {
10691069
{ "i386", false },
10701070
{ "xtensa", false },
10711071
{ "mips", true },
1072+
{ "mipsel", false },
10721073
{ "aarch64v8", false },
10731074
{ "aarch64v8.1", false },
10741075
{ "aarch64v8.2", false },

core/iwasm/interpreter/wasm_loader.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3342,6 +3342,7 @@ create_sections(const uint8 *buf, uint32 size, WASMSection **p_section_list,
33423342
if (last_section_index != (uint8)-1
33433343
&& (section_index <= last_section_index)) {
33443344
set_error_buf(error_buf, error_buf_size,
3345+
"unexpected content after last section or "
33453346
"junk after last section");
33463347
return false;
33473348
}

core/iwasm/libraries/libc-builtin/libc_builtin_wrapper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,7 @@ static NativeSymbol native_symbols_libc_builtin[] = {
11611161
REG_NATIVE_FUNC(strtol, "($*i)i"),
11621162
REG_NATIVE_FUNC(strtoul, "($*i)i"),
11631163
REG_NATIVE_FUNC(memchr, "(*ii)i"),
1164-
REG_NATIVE_FUNC(strncasecmp, "($$i)"),
1164+
REG_NATIVE_FUNC(strncasecmp, "($$i)i"),
11651165
REG_NATIVE_FUNC(strspn, "($$)i"),
11661166
REG_NATIVE_FUNC(strcspn, "($$)i"),
11671167
REG_NATIVE_FUNC(strstr, "($$)i"),

tests/wamr-test-suites/spec-test-script/all.py

Lines changed: 62 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -204,70 +204,59 @@ def test_suite(
204204
xip_flag=False,
205205
clean_up_flag=True,
206206
verbose_flag=True,
207+
parl_flag=False,
207208
):
208209
suite_path = pathlib.Path(SPEC_TEST_DIR).resolve()
209210
if not suite_path.exists():
210211
print(f"can not find spec test cases at {suite_path}")
211212
return False
212213

213-
case_list = sorted(suite_path.glob("**/*.wast"))
214+
case_list = sorted(suite_path.glob("*.wast"))
215+
if simd_flag:
216+
simd_case_list = sorted(suite_path.glob("simd/*.wast"))
217+
case_list.extend(simd_case_list)
218+
214219
case_count = len(case_list)
215220
failed_case = 0
216221
successful_case = 0
217-
for case_path in case_list:
218-
try:
219-
test_case(
220-
str(case_path),
221-
target,
222-
aot_flag,
223-
sgx_flag,
224-
multi_module_flag,
225-
multi_thread_flag,
226-
simd_flag,
227-
xip_flag,
228-
clean_up_flag,
229-
verbose_flag,
230-
)
231-
successful_case += 1
232-
except Exception:
233-
failed_case += 1
234-
break
235-
236-
print(
237-
f"IN ALL {case_count} cases: {successful_case} PASS, {failed_case} FAIL, {case_count - successful_case - failed_case} SKIP"
238-
)
239-
240-
return 0 == failed_case
241222

223+
if parl_flag:
224+
print(f"----- Run the whole spec test suite on {mp.cpu_count()} cores -----")
225+
with mp.Pool() as pool:
226+
results = {}
227+
for case_path in case_list:
228+
results[case_path.stem] = pool.apply_async(
229+
test_case,
230+
[
231+
str(case_path),
232+
target,
233+
aot_flag,
234+
sgx_flag,
235+
multi_module_flag,
236+
multi_thread_flag,
237+
simd_flag,
238+
xip_flag,
239+
clean_up_flag,
240+
verbose_flag,
241+
],
242+
)
242243

243-
def test_suite_parallelly(
244-
target,
245-
aot_flag=False,
246-
sgx_flag=False,
247-
multi_module_flag=False,
248-
multi_thread_flag=False,
249-
simd_flag=False,
250-
xip_flag=False,
251-
clean_up_flag=False,
252-
verbose_flag=False,
253-
):
254-
255-
suite_path = pathlib.Path(SPEC_TEST_DIR).resolve()
256-
if not suite_path.exists():
257-
print(f"can not find spec test cases at {suite_path}")
258-
return False
259-
260-
case_list = sorted(suite_path.glob("**/*.wast"))
261-
case_count = len(case_list)
262-
failed_case = 0
263-
successful_case = 0
264-
print(f"----- Run the whole spec test suite on {mp.cpu_count()} cores -----")
265-
with mp.Pool() as pool:
266-
results = {}
244+
for case_name, result in results.items():
245+
try:
246+
# 5 min / case
247+
result.wait(300)
248+
if not result.successful():
249+
failed_case += 1
250+
else:
251+
successful_case += 1
252+
except mp.TimeoutError:
253+
print(f"{case_name} meets TimeoutError")
254+
failed_case += 1
255+
else:
256+
print(f"----- Run the whole spec test suite -----")
267257
for case_path in case_list:
268-
results[case_path.stem] = pool.apply_async(
269-
test_case,
270-
[
258+
try:
259+
test_case(
271260
str(case_path),
272261
target,
273262
aot_flag,
@@ -278,20 +267,11 @@ def test_suite_parallelly(
278267
xip_flag,
279268
clean_up_flag,
280269
verbose_flag,
281-
],
282-
)
283-
284-
for case_name, result in results.items():
285-
try:
286-
# 5 min / case
287-
result.wait(300)
288-
if not result.successful():
289-
failed_case += 1
290-
else:
291-
successful_case += 1
292-
except mp.TimeoutError:
293-
print(f"{case_name} meets TimeoutError")
270+
)
271+
successful_case += 1
272+
except Exception:
294273
failed_case += 1
274+
break
295275

296276
print(
297277
f"IN ALL {case_count} cases: {successful_case} PASS, {failed_case} FAIL, {case_count - successful_case - failed_case} SKIP"
@@ -396,37 +376,23 @@ def main():
396376
options.clean_up_flag = False
397377
options.verbose_flag = False
398378

399-
start = time.time_ns()
400-
ret = test_suite_parallelly(
401-
options.target,
402-
options.aot_flag,
403-
options.sgx_flag,
404-
options.multi_module_flag,
405-
options.multi_thread_flag,
406-
options.simd_flag,
407-
options.xip_flag,
408-
options.clean_up_flag,
409-
options.verbose_flag,
410-
)
411-
end = time.time_ns()
412-
print(
413-
f"It takes {((end - start) / 1000000):,} ms to run test_suite_parallelly"
414-
)
415-
else:
416-
start = time.time_ns()
417-
ret = test_suite(
418-
options.target,
419-
options.aot_flag,
420-
options.sgx_flag,
421-
options.multi_module_flag,
422-
options.multi_thread_flag,
423-
options.simd_flag,
424-
options.xip_flag,
425-
options.clean_up_flag,
426-
options.verbose_flag,
427-
)
428-
end = time.time_ns()
429-
print(f"It takes {((end - start) / 1000000):,} ms to run test_suite")
379+
start = time.time_ns()
380+
ret = test_suite(
381+
options.target,
382+
options.aot_flag,
383+
options.sgx_flag,
384+
options.multi_module_flag,
385+
options.multi_thread_flag,
386+
options.simd_flag,
387+
options.xip_flag,
388+
options.clean_up_flag,
389+
options.verbose_flag,
390+
options.parl_flag,
391+
)
392+
end = time.time_ns()
393+
print(
394+
f"It takes {((end - start) / 1000000):,} ms to run test_suite {'parallelly' if options.parl_flag else ''}"
395+
)
430396
else:
431397
try:
432398
for case in options.cases:

tests/wamr-test-suites/test_wamr.sh

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,12 @@ function spec_test()
279279
# restore from XX_ignore_cases.patch
280280
# resotre branch
281281
git checkout -B master
282-
git reset --hard 397399a70565609bf142d211891724e21bffd01f
282+
# [spec] Fix instruction table (#1402) Thu Dec 2 17:21:54 2021 +0100
283+
git reset --hard 2460ad02b51fb5ed5824f44de287a8638b19a5f8
283284
git apply ../../spec-test-script/ignore_cases.patch
285+
if [[ ${ENABLE_SIMD} == 1 ]]; then
286+
git apply ../../spec-test-script/simd_ignore_cases.patch
287+
fi
284288

285289
# udpate thread cases
286290
if [ ${ENABLE_MULTI_THREAD} == 1 ]; then
@@ -298,20 +302,6 @@ function spec_test()
298302
git apply ../../spec-test-script/thread_proposal_ignore_cases.patch
299303
fi
300304

301-
# udpate SIMD cases
302-
if [[ ${ENABLE_SIMD} == 1 ]]; then
303-
echo "checkout spec for SIMD proposal"
304-
# check spec test cases for simd
305-
if [[ -z $(git remote | grep "\<simd\>") ]]; then
306-
git remote add simd https://github.com/WebAssembly/simd.git
307-
fi
308-
309-
git fetch simd
310-
git checkout simd/main -- test/core/simd
311-
312-
git apply ../../spec-test-script/simd_ignore_cases.patch
313-
fi
314-
315305
popd
316306
echo $(pwd)
317307

0 commit comments

Comments
 (0)