Skip to content

Commit

Permalink
Fix function type not set issue of aot_call_indirect (bytecodeallianc…
Browse files Browse the repository at this point in the history
…e#229)

Add registration of libc-wasi to 'wasi_snapshot_preview1' to support cargo-wasi
change zephyr build method from cmake to west
fix problem when preserve space for local vars
fix wasi authority problem
  • Loading branch information
xujuntwt95329 authored Apr 7, 2020
1 parent 374e687 commit 5e19625
Show file tree
Hide file tree
Showing 26 changed files with 513 additions and 144 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ core/deps/llvm
core/deps/lvgl
core/shared/mem-alloc/tlsf

wamr-sdk/out/
wamr-sdk/runtime/build_runtime_sdk/
test-tools/host-tool/bin/
129 changes: 129 additions & 0 deletions _clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
---
BasedOnStyle: Mozilla
IndentWidth: 4

---
Language: Cpp
AlignConsecutiveMacros: true
AllowShortBlocksOnASingleLine: true
BinPackArguments: true
BinPackParameters: true
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: false
AfterClass: true
AfterControlStatement: false
AfterEnum: true
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: true
AfterUnion: false
AfterExternBlock: true
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: false
SplitEmptyNamespace: true
ColumnLimit: 79
DerivePointerAlignment: false
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 1
- Regex: ".*"
Priority: 3
PointerAlignment: Right
ReflowComments: false
Standard: Cpp03
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
# AccessModifierOffset: -2
# AlignAfterOpenBracket: Align
# AlignConsecutiveAssignments: false
# AlignConsecutiveDeclarations: false
# AlignEscapedNewlines: Right
# AlignOperands: true
# AlignTrailingComments: true
# AllowAllArgumentsOnNextLine: true
# AllowAllConstructorInitializersOnNextLine: true
# AllowAllParametersOfDeclarationOnNextLine: false
# AllowShortCaseLabelsOnASingleLine: false
# AllowShortFunctionsOnASingleLine: Inline
# AllowShortLambdasOnASingleLine: All
# AllowShortIfStatementsOnASingleLine: Never
# AllowShortLoopsOnASingleLine: false
# AlwaysBreakAfterDefinitionReturnType: TopLevel
# AlwaysBreakAfterReturnType: TopLevel
# AlwaysBreakBeforeMultilineStrings: false
# AlwaysBreakTemplateDeclarations: Yes
# BreakBeforeBinaryOperators: None
# BreakBeforeInheritanceComma: false
# BreakInheritanceList: BeforeComma
# BreakBeforeTernaryOperators: true
# BreakConstructorInitializersBeforeComma: false
# BreakConstructorInitializers: BeforeComma
# BreakAfterJavaFieldAnnotations: false
# BreakStringLiterals: true
# CommentPragmas: '^ IWYU pragma:'
# CompactNamespaces: false
# ConstructorInitializerAllOnOneLineOrOnePerLine: false
# ConstructorInitializerIndentWidth: 2
# ContinuationIndentWidth: 2
# Cpp11BracedListStyle: false
# DisableFormat: false
# ExperimentalAutoDetectBinPacking: false
# FixNamespaceComments: false
# ForEachMacros:
# - foreach
# - Q_FOREACH
# - BOOST_FOREACH
# IncludeIsMainRegex: '(Test)?$'
# IndentCaseLabels: true
# IndentPPDirectives: None
# IndentWrappedFunctionNames: false
# JavaScriptQuotes: Leave
# JavaScriptWrapImports: true
# KeepEmptyLinesAtTheStartOfBlocks: true
# MacroBlockBegin: ''
# MacroBlockEnd: ''
# MaxEmptyLinesToKeep: 1
# NamespaceIndentation: None
# ObjCBinPackProtocolList: Auto
# ObjCBlockIndentWidth: 2
# ObjCSpaceAfterProperty: true
# ObjCSpaceBeforeProtocolList: false
# PenaltyBreakAssignment: 2
# PenaltyBreakBeforeFirstCallParameter: 19
# PenaltyBreakComment: 300
# PenaltyBreakFirstLessLess: 120
# PenaltyBreakString: 1000
# PenaltyBreakTemplateDeclaration: 10
# PenaltyExcessCharacter: 1000000
# PenaltyReturnTypeOnItsOwnLine: 200
# SortIncludes: true
# SortUsingDeclarations: true
# SpaceAfterCStyleCast: false
# SpaceAfterLogicalNot: false
# SpaceAfterTemplateKeyword: false
# SpaceBeforeAssignmentOperators: true
# SpaceBeforeCpp11BracedList: false
# SpaceBeforeCtorInitializerColon: true
# SpaceBeforeInheritanceColon: true
# SpaceBeforeParens: ControlStatements
# SpaceBeforeRangeBasedForLoopColon: true
# SpaceInEmptyParentheses: false
# SpacesBeforeTrailingComments: 1
# SpacesInAngles: false
# SpacesInContainerLiterals: true
# SpacesInCStyleCastParentheses: false
# SpacesInParentheses: false
# SpacesInSquareBrackets: false
# TabWidth: 4
# UseTab: Never
# ...

12 changes: 6 additions & 6 deletions build-scripts/config_common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -94,33 +94,33 @@ message (" CMAKE_BUILD_TYPE " ${CMAKE_BUILD_TYPE})
if (WAMR_BUILD_INTERP EQUAL 1)
message (" WAMR Interpreter enabled")
else ()
message (" WAMR Interpreter disbled")
message (" WAMR Interpreter disabled")
endif ()
if (WAMR_BUILD_AOT EQUAL 1)
message (" WAMR AOT enabled")
else ()
message (" WAMR AOT disbled")
message (" WAMR AOT disabled")
endif ()
if (WAMR_BUILD_JIT EQUAL 1)
message (" WAMR JIT enabled")
else ()
message (" WAMR JIT disbled")
message (" WAMR JIT disabled")
endif ()
if (WAMR_BUILD_LIBC_BUILTIN EQUAL 1)
message (" Libc builtin enabled")
else ()
message (" Libc builtin disbled")
message (" Libc builtin disabled")
endif ()
if (WAMR_BUILD_LIBC_WASI EQUAL 1)
message (" Libc WASI enabled")
else ()
message (" Libc WASI disbled")
message (" Libc WASI disabled")
endif ()
if (WAMR_BUILD_FAST_INTERP EQUAL 1)
add_definitions (-DWASM_ENABLE_FAST_INTERP=1)
message (" Fast interpreter enabled")
else ()
add_definitions (-DWASM_ENABLE_FAST_INTERP=0)
message (" Fast interpreter disbled")
message (" Fast interpreter disabled")
endif ()

3 changes: 2 additions & 1 deletion core/iwasm/aot/aot_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,8 @@ load_import_funcs(const uint8 **p_buf, const uint8 *buf_end,
}

#if WASM_ENABLE_LIBC_WASI != 0
if (!strcmp(import_funcs[i].module_name, "wasi_unstable"))
if (!strcmp(import_funcs[i].module_name, "wasi_unstable")
|| !strcmp(import_funcs[i].module_name, "wasi_snapshot_preview1"))
module->is_wasi_module = true;
#endif
}
Expand Down
17 changes: 11 additions & 6 deletions core/iwasm/aot/aot_runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -855,15 +855,16 @@ aot_invoke_native(WASMExecEnv *exec_env, uint32 func_idx,

bool
aot_call_indirect(WASMExecEnv *exec_env,
uint32 func_type_idx, uint32 table_elem_idx,
bool check_func_type, uint32 func_type_idx,
uint32 table_elem_idx,
uint32 *frame_lp, uint32 argc, uint32 *argv_ret)
{
AOTModuleInstance *module_inst = (AOTModuleInstance*)
wasm_runtime_get_module_inst(exec_env);
AOTModule *aot_module = (AOTModule*)module_inst->aot_module.ptr;
uint32 *func_type_indexes = (uint32*)module_inst->func_type_indexes.ptr;
uint32 *table_data = (uint32*)module_inst->table_data.ptr;
AOTFuncType *func_type = aot_module->func_types[func_type_idx];;
AOTFuncType *func_type;
void **func_ptrs = (void**)module_inst->func_ptrs.ptr, *func_ptr;
uint32 table_size = module_inst->table_size;
uint32 func_idx, func_type_idx1;
Expand All @@ -884,10 +885,14 @@ aot_call_indirect(WASMExecEnv *exec_env,
}

func_type_idx1 = func_type_indexes[func_idx];
if (!aot_is_wasm_type_equal(module_inst, func_type_idx, func_type_idx1)) {
aot_set_exception_with_id(module_inst, EXCE_INVALID_FUNCTION_TYPE_INDEX);
if (check_func_type
&& !aot_is_wasm_type_equal(module_inst, func_type_idx,
func_type_idx1)) {
aot_set_exception_with_id(module_inst,
EXCE_INVALID_FUNCTION_TYPE_INDEX);
return false;
}
func_type = aot_module->func_types[func_type_idx1];

if (!(func_ptr = func_ptrs[func_idx])) {
bh_assert(func_idx < aot_module->import_func_count);
Expand All @@ -906,7 +911,8 @@ aot_call_indirect(WASMExecEnv *exec_env,
if (import_func->call_conv_raw) {
attachment = import_func->attachment;
return wasm_runtime_invoke_native_raw(exec_env, func_ptr,
func_type, signature, attachment,
func_type, signature,
attachment,
frame_lp, argc, argv_ret);
}
}
Expand All @@ -915,4 +921,3 @@ aot_call_indirect(WASMExecEnv *exec_env,
func_type, signature, attachment,
frame_lp, argc, argv_ret);
}

3 changes: 2 additions & 1 deletion core/iwasm/aot/aot_runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,8 @@ aot_invoke_native(WASMExecEnv *exec_env, uint32 func_idx,

bool
aot_call_indirect(WASMExecEnv *exec_env,
uint32 func_type_idx, uint32 table_elem_idx,
bool check_func_type, uint32 func_type_idx,
uint32 table_elem_idx,
uint32 *frame_lp, uint32 argc, uint32 *argv_ret);

uint32
Expand Down
14 changes: 7 additions & 7 deletions core/iwasm/aot/iwasm_aot.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ include_directories (${IWASM_AOT_DIR})

file (GLOB c_source_all ${IWASM_AOT_DIR}/*.c)

if (${WAMR_BUILD_TARGET} STREQUAL "X86_64" OR ${WAMR_BUILD_TARGET} STREQUAL "AMD_64")
if (WAMR_BUILD_TARGET STREQUAL "X86_64" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
set (arch_source ${IWASM_AOT_DIR}/arch/aot_reloc_x86_64.c)
elseif (${WAMR_BUILD_TARGET} STREQUAL "X86_32")
elseif (WAMR_BUILD_TARGET STREQUAL "X86_32")
set (arch_source ${IWASM_AOT_DIR}/arch/aot_reloc_x86_32.c)
elseif (${WAMR_BUILD_TARGET} MATCHES "AARCH64.*")
elseif (WAMR_BUILD_TARGET MATCHES "AARCH64.*")
set (arch_source ${IWASM_AOT_DIR}/arch/aot_reloc_aarch64.c)
elseif (${WAMR_BUILD_TARGET} MATCHES "ARM.*")
elseif (WAMR_BUILD_TARGET MATCHES "ARM.*")
set (arch_source ${IWASM_AOT_DIR}/arch/aot_reloc_arm.c)
elseif (${WAMR_BUILD_TARGET} MATCHES "THUMB.*")
elseif (WAMR_BUILD_TARGET MATCHES "THUMB.*")
set (arch_source ${IWASM_AOT_DIR}/arch/aot_reloc_thumb.c)
elseif (${WAMR_BUILD_TARGET} STREQUAL "MIPS")
elseif (WAMR_BUILD_TARGET STREQUAL "MIPS")
set (arch_source ${IWASM_AOT_DIR}/arch/aot_reloc_mips.c)
elseif (${WAMR_BUILD_TARGET} STREQUAL "XTENSA")
elseif (WAMR_BUILD_TARGET STREQUAL "XTENSA")
set (arch_source ${IWASM_AOT_DIR}/arch/aot_reloc_xtensa.c)
else ()
message (FATAL_ERROR "Build target isn't set")
Expand Down
20 changes: 10 additions & 10 deletions core/iwasm/common/iwasm_common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,29 @@ add_definitions(-DBH_FREE=wasm_runtime_free)

file (GLOB c_source_all ${IWASM_COMMON_DIR}/*.c)

if (${WAMR_BUILD_TARGET} STREQUAL "X86_64" OR ${WAMR_BUILD_TARGET} STREQUAL "AMD_64")
if (WAMR_BUILD_TARGET STREQUAL "X86_64" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
set (source_all ${c_source_all} ${IWASM_COMMON_DIR}/arch/invokeNative_em64.s)
elseif (${WAMR_BUILD_TARGET} STREQUAL "X86_32")
elseif (WAMR_BUILD_TARGET STREQUAL "X86_32")
set (source_all ${c_source_all} ${IWASM_COMMON_DIR}/arch/invokeNative_ia32.s)
elseif (${WAMR_BUILD_TARGET} MATCHES "ARM.*")
if (${WAMR_BUILD_TARGET} MATCHES "ARM.*_VFP")
elseif (WAMR_BUILD_TARGET MATCHES "ARM.*")
if (WAMR_BUILD_TARGET MATCHES "ARM.*_VFP")
set (source_all ${c_source_all} ${IWASM_COMMON_DIR}/arch/invokeNative_arm_vfp.s)
else ()
set (source_all ${c_source_all} ${IWASM_COMMON_DIR}/arch/invokeNative_arm.s)
endif ()
elseif (${WAMR_BUILD_TARGET} MATCHES "THUMB.*")
if (${WAMR_BUILD_TARGET} MATCHES "THUMB.*_VFP")
elseif (WAMR_BUILD_TARGET MATCHES "THUMB.*")
if (WAMR_BUILD_TARGET MATCHES "THUMB.*_VFP")
set (source_all ${c_source_all} ${IWASM_COMMON_DIR}/arch/invokeNative_thumb_vfp.s)
else ()
set (source_all ${c_source_all} ${IWASM_COMMON_DIR}/arch/invokeNative_thumb.s)
endif ()
elseif (${WAMR_BUILD_TARGET} MATCHES "AARCH64.*")
elseif (WAMR_BUILD_TARGET MATCHES "AARCH64.*")
set (source_all ${c_source_all} ${IWASM_COMMON_DIR}/arch/invokeNative_aarch64.s)
elseif (${WAMR_BUILD_TARGET} STREQUAL "MIPS")
elseif (WAMR_BUILD_TARGET STREQUAL "MIPS")
set (source_all ${c_source_all} ${IWASM_COMMON_DIR}/arch/invokeNative_mips.s)
elseif (${WAMR_BUILD_TARGET} STREQUAL "XTENSA")
elseif (WAMR_BUILD_TARGET STREQUAL "XTENSA")
set (source_all ${c_source_all} ${IWASM_COMMON_DIR}/arch/invokeNative_xtensa.s)
elseif (${WAMR_BUILD_TARGET} STREQUAL "GENERAL")
elseif (WAMR_BUILD_TARGET STREQUAL "GENERAL")
# Use invokeNative_general.c instead of assembly code,
# but the maximum number of native arguments is limited to 20,
# and there are possible issues when passing arguments to
Expand Down
3 changes: 3 additions & 0 deletions core/iwasm/common/wasm_native.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@ wasm_native_init()
if (!wasm_native_register_natives("wasi_unstable",
native_symbols, n_native_symbols))
return false;
if (!wasm_native_register_natives("wasi_snapshot_preview1",
native_symbols, n_native_symbols))
return false;
#endif

#if WASM_ENABLE_BASE_LIB != 0
Expand Down
Loading

0 comments on commit 5e19625

Please sign in to comment.