Skip to content

Commit 752826a

Browse files
authored
Implement multi-module feature and bulk-memory feature (#271)
Refine wasm loader and aot loader Fix potential issue of os_mmap/os_munmap Update document
1 parent e81f72d commit 752826a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+4919
-835
lines changed

_clang-format renamed to .clang-format

Lines changed: 48 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,47 @@
1-
---
2-
BasedOnStyle: Mozilla
3-
IndentWidth: 4
1+
RawStringFormats:
2+
- Language: Cpp
3+
Delimiters:
4+
- c
5+
- C
6+
- cc
7+
- CC
8+
- cpp
9+
- Cpp
10+
- CPP
11+
- 'c++'
12+
- 'C++'
13+
- h
14+
- hpp
15+
CanonicalDelimiter: ''
16+
BasedOnStyle: google
17+
- Language: TextProto
18+
Delimiters:
19+
- pb
20+
- PB
21+
- proto
22+
- PROTO
23+
EnclosingFunctions:
24+
- EqualsProto
25+
- EquivToProto
26+
- PARSE_PARTIAL_TEXT_PROTO
27+
- PARSE_TEST_PROTO
28+
- PARSE_TEXT_PROTO
29+
- ParseTextOrDie
30+
- ParseTextProtoOrDie
31+
CanonicalDelimiter: ''
32+
BasedOnStyle: google
433

5-
---
634
Language: Cpp
35+
BasedOnStyle: Mozilla
36+
IndentWidth: 4
37+
AlignAfterOpenBracket: Align
38+
AllowAllArgumentsOnNextLine: false
739
AlignConsecutiveMacros: true
840
AllowShortBlocksOnASingleLine: true
41+
AlwaysBreakAfterReturnType: All
942
BinPackArguments: true
10-
BinPackParameters: true
43+
BinPackParameters: false
44+
BreakBeforeBinaryOperators: NonAssignment
1145
BreakBeforeBraces: Custom
1246
BraceWrapping:
1347
AfterCaseLabel: false
@@ -17,16 +51,17 @@ BraceWrapping:
1751
AfterFunction: true
1852
AfterNamespace: false
1953
AfterObjCDeclaration: false
20-
AfterStruct: true
54+
AfterStruct: false
2155
AfterUnion: false
22-
AfterExternBlock: true
56+
AfterExternBlock: false
2357
BeforeCatch: false
24-
BeforeElse: false
58+
BeforeElse: true
2559
IndentBraces: false
2660
SplitEmptyFunction: true
2761
SplitEmptyRecord: false
2862
SplitEmptyNamespace: true
2963
ColumnLimit: 79
64+
ContinuationIndentWidth: 2
3065
DerivePointerAlignment: false
3166
IncludeBlocks: Regroup
3267
IncludeCategories:
@@ -36,20 +71,22 @@ IncludeCategories:
3671
Priority: 1
3772
- Regex: ".*"
3873
Priority: 3
74+
IndentPPDirectives: None
75+
KeepEmptyLinesAtTheStartOfBlocks: false
76+
NamespaceIndentation: None
3977
PointerAlignment: Right
4078
ReflowComments: false
41-
Standard: Cpp03
79+
Standard: Auto
4280
StatementMacros:
4381
- Q_UNUSED
4482
- QT_REQUIRE_VERSION
83+
4584
# AccessModifierOffset: -2
46-
# AlignAfterOpenBracket: Align
4785
# AlignConsecutiveAssignments: false
4886
# AlignConsecutiveDeclarations: false
4987
# AlignEscapedNewlines: Right
5088
# AlignOperands: true
5189
# AlignTrailingComments: true
52-
# AllowAllArgumentsOnNextLine: true
5390
# AllowAllConstructorInitializersOnNextLine: true
5491
# AllowAllParametersOfDeclarationOnNextLine: false
5592
# AllowShortCaseLabelsOnASingleLine: false
@@ -61,7 +98,6 @@ StatementMacros:
6198
# AlwaysBreakAfterReturnType: TopLevel
6299
# AlwaysBreakBeforeMultilineStrings: false
63100
# AlwaysBreakTemplateDeclarations: Yes
64-
# BreakBeforeBinaryOperators: None
65101
# BreakBeforeInheritanceComma: false
66102
# BreakInheritanceList: BeforeComma
67103
# BreakBeforeTernaryOperators: true
@@ -73,7 +109,6 @@ StatementMacros:
73109
# CompactNamespaces: false
74110
# ConstructorInitializerAllOnOneLineOrOnePerLine: false
75111
# ConstructorInitializerIndentWidth: 2
76-
# ContinuationIndentWidth: 2
77112
# Cpp11BracedListStyle: false
78113
# DisableFormat: false
79114
# ExperimentalAutoDetectBinPacking: false
@@ -84,15 +119,13 @@ StatementMacros:
84119
# - BOOST_FOREACH
85120
# IncludeIsMainRegex: '(Test)?$'
86121
# IndentCaseLabels: true
87-
# IndentPPDirectives: None
88122
# IndentWrappedFunctionNames: false
89123
# JavaScriptQuotes: Leave
90124
# JavaScriptWrapImports: true
91125
# KeepEmptyLinesAtTheStartOfBlocks: true
92126
# MacroBlockBegin: ''
93127
# MacroBlockEnd: ''
94128
# MaxEmptyLinesToKeep: 1
95-
# NamespaceIndentation: None
96129
# ObjCBinPackProtocolList: Auto
97130
# ObjCBlockIndentWidth: 2
98131
# ObjCSpaceAfterProperty: true

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
core/deps/lv_drivers
44
core/deps/llvm
55
core/deps/lvgl
6+
core/deps/tlsf
67
core/shared/mem-alloc/tlsf
8+
core/app-framework/wgl
79

810
wamr-sdk/out/
911
wamr-sdk/runtime/build_runtime_sdk/
1012
test-tools/host-tool/bin/
13+
product-mini/app-samples/hello-world/test.wasm

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,17 @@ iwasm VM core
2222

2323
- 100% compliant to the W3C WASM MVP
2424
- Small runtime binary size (85K for interpreter and 50K for AoT) and low memory usage
25-
- Near to native speed by AoT
25+
- Near to native speed by AoT
2626
- Self-implemented module loader enables AoT working cross Linux, SGX and MCU systems
2727
- Choices of WASM application libc support: the built-in libc subset for the embedded environment or [WASI](https://github.com/WebAssembly/WASI) for standard libc
2828
- [Embeddable with the supporting C API's](./doc/embed_wamr.md)
2929
- [The mechanism for exporting native API's to WASM applications](./doc/export_native_api.md)
30+
- [Multiple modules as dependencies](./doc/multi_module.md)
31+
32+
### post-MVP features
33+
- [Non-trapping float-to-int conversions](https://github.com/WebAssembly/nontrapping-float-to-int-conversions)
34+
- [Sign-extension operators](https://github.com/WebAssembly/sign-extension-ops)
35+
- [Bulk memory operations](https://github.com/WebAssembly/bulk-memory-operations)
3036

3137
### Performance and memory usage
3238
The WAMR performance, footprint and memory usage data are available at the [performance](../../wiki/Performance) wiki page.

assembly-script/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/node_modules

build-scripts/config_common.cmake

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,20 @@ else ()
123123
add_definitions (-DWASM_ENABLE_FAST_INTERP=0)
124124
message (" Fast interpreter disabled")
125125
endif ()
126-
126+
if (WAMR_BUILD_MULTI_MODULE EQUAL 1)
127+
add_definitions (-DWASM_ENABLE_MULTI_MODULE=1)
128+
message (" Multiple modules enabled")
129+
else ()
130+
add_definitions (-DWASM_ENABLE_MULTI_MODULE=0)
131+
message (" Multiple modules disabled")
132+
endif ()
127133
if (WAMR_BUILD_SPEC_TEST EQUAL 1)
128134
add_definitions (-DWASM_ENABLE_SPEC_TEST=1)
129135
message (" spec test compatible mode is on")
130136
endif()
137+
if (WAMR_BUILD_BULK_MEMORY EQUAL 1)
138+
add_definitions (-DWASM_ENABLE_BULK_MEMORY=1)
139+
message (" Bulk memory feature enabled")
140+
else ()
141+
add_definitions (-DWASM_ENABLE_BULK_MEMORY=0)
142+
endif()

core/app-framework/app-native-shared/bi-inc/attr_container.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#ifndef _ATTR_CONTAINER_H_
77
#define _ATTR_CONTAINER_H_
88

9-
#include <inttypes.h>
9+
#include <stdint.h>
1010
#include <stdio.h>
1111
#include <stdlib.h>
1212
#include <string.h>

core/app-framework/app-native-shared/restful_utils.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,23 +71,18 @@ void free_req_resp_packet(char * packet)
7171
request_t * unpack_request(char * packet, int size, request_t * request)
7272
{
7373
if (*packet != REQUES_PACKET_VER) {
74-
printf("version fail\n");
7574
return NULL;
7675
}
7776
if (size < REQUEST_PACKET_FIX_PART_LEN) {
78-
printf("size error: %d\n", size);
7977
return NULL;
8078
}
8179
uint16 url_len = ntohs(*((uint16*) (packet + 12)));
8280
uint32 payload_len = ntohl(*((uint32*) (packet + 14)));
8381

8482
if (size != ( REQUEST_PACKET_FIX_PART_LEN + url_len + payload_len)) {
85-
printf("size error: %d, expect: %d\n", size,
86-
REQUEST_PACKET_FIX_PART_LEN + url_len + payload_len);
8783
return NULL;
8884
}
8985
if (*(packet + REQUEST_PACKET_FIX_PART_LEN + url_len - 1) != 0) {
90-
printf("url not end with 0\n");
9186
return NULL;
9287
}
9388

core/app-mgr/app-manager/app_manager_host.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ bool app_manager_host_init(host_interface *interface)
246246
return true;
247247
}
248248

249-
int app_manager_host_send_msg(int msg_type, const unsigned char *buf, int size)
249+
int app_manager_host_send_msg(int msg_type, const char *buf, int size)
250250
{
251251
/* send an IMRT LINK message contains the buf as payload */
252252
if (host_commu.send != NULL) {
@@ -276,10 +276,10 @@ int app_manager_host_send_msg(int msg_type, const unsigned char *buf, int size)
276276
n = host_commu.send(NULL, buf, size);
277277
os_mutex_unlock(&host_lock);
278278

279-
printf("sent %d bytes to host\n", n);
279+
app_manager_printf("sent %d bytes to host\n", n);
280280
return n;
281281
} else {
282-
printf("no send api provided\n");
282+
app_manager_printf("no send api provided\n");
283283
}
284284
return 0;
285285
}

core/app-mgr/app-manager/module_wasm_app.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ wasm_app_routine(void *arg)
445445
0, NULL)) {
446446
const char *exception = wasm_runtime_get_exception(inst);
447447
bh_assert(exception);
448-
printf("Got exception running wasi start function: %s\n",
448+
app_manager_printf("Got exception running wasi start function: %s\n",
449449
exception);
450450
wasm_runtime_clear_exception(inst);
451451
goto fail1;
@@ -467,7 +467,7 @@ wasm_app_routine(void *arg)
467467
0, NULL)) {
468468
const char *exception = wasm_runtime_get_exception(inst);
469469
bh_assert(exception);
470-
printf("Got exception running WASM code: %s\n",
470+
app_manager_printf("Got exception running WASM code: %s\n",
471471
exception);
472472
wasm_runtime_clear_exception(inst);
473473
/* call on_destroy() in case some resources are opened in on_init()
@@ -644,7 +644,7 @@ wasm_app_module_install(request_t * msg)
644644
if (!module) {
645645
SEND_ERR_RESPONSE(msg->mid,
646646
"Install WASM app failed: load WASM file failed.");
647-
printf("error: %s\n", err);
647+
app_manager_printf("error: %s\n", err);
648648
destroy_all_aot_sections(aot_file->sections);
649649
return false;
650650
}
@@ -674,7 +674,7 @@ wasm_app_module_install(request_t * msg)
674674
if (!inst) {
675675
SEND_ERR_RESPONSE(msg->mid,
676676
"Install WASM app failed: instantiate wasm runtime failed.");
677-
printf("error: %s\n", err);
677+
app_manager_printf("error: %s\n", err);
678678
wasm_runtime_unload(module);
679679
destroy_all_aot_sections(aot_file->sections);
680680
return false;
@@ -713,7 +713,7 @@ wasm_app_module_install(request_t * msg)
713713
if (!module) {
714714
SEND_ERR_RESPONSE(msg->mid,
715715
"Install WASM app failed: load WASM file failed.");
716-
printf("error: %s\n", err);
716+
app_manager_printf("error: %s\n", err);
717717
destroy_all_wasm_sections(bytecode_file->sections);
718718
return false;
719719
}
@@ -744,7 +744,7 @@ wasm_app_module_install(request_t * msg)
744744
if (!inst) {
745745
SEND_ERR_RESPONSE(msg->mid,
746746
"Install WASM app failed: instantiate wasm runtime failed.");
747-
printf("error: %s\n", err);
747+
app_manager_printf("error: %s\n", err);
748748
wasm_runtime_unload(module);
749749
destroy_all_wasm_sections(bytecode_file->sections);
750750
return false;

core/app-mgr/app-mgr-shared/app_manager_export.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ bool
285285
bh_applet_check_permission(const char *perm);
286286

287287
int
288-
app_manager_host_send_msg(int msg_type, const unsigned char *buf, int size);
288+
app_manager_host_send_msg(int msg_type, const char *buf, int size);
289289

290290
#ifdef __cplusplus
291291
} /* end of extern "C" */

0 commit comments

Comments
 (0)