@@ -86,84 +86,6 @@ static bh_list registered_module_list_head;
8686static bh_list * const registered_module_list = & registered_module_list_head ;
8787static korp_mutex registered_module_list_lock ;
8888
89- void
90- wasm_runtime_propagate_exception_from_import (
91- WASMModuleInstanceCommon * parent , WASMModuleInstanceCommon * sub_module )
92- {
93- static const uint32 exception_prefix_len = sizeof ("Exception: " ) - 1 ;
94- static const char memory_oob_exception [] = "out of bounds memory access" ;
95- char exception_buf [EXCEPTION_BUF_LEN ] = { 0 };
96- const char * message = NULL ;
97- bool has_exception = false;
98-
99- if (!parent || !sub_module )
100- return ;
101-
102- switch (sub_module -> module_type ) {
103- #if WASM_ENABLE_INTERP != 0
104- case Wasm_Module_Bytecode :
105- has_exception = wasm_copy_exception (
106- (WASMModuleInstance * )sub_module , exception_buf );
107- break ;
108- #endif
109- #if WASM_ENABLE_AOT != 0
110- case Wasm_Module_AoT :
111- has_exception = aot_copy_exception ((AOTModuleInstance * )sub_module ,
112- exception_buf );
113- break ;
114- #endif
115- default :
116- return ;
117- }
118-
119- if (has_exception ) {
120- message = exception_buf ;
121- if (strlen (message ) >= exception_prefix_len ) {
122- message += exception_prefix_len ;
123- }
124- else {
125- LOG_WARNING ("sub-module exception format unexpected: %s" , message );
126- return ;
127- }
128-
129- if (strcmp (message , memory_oob_exception ) != 0 ) {
130- LOG_WARNING ("skip propagating non-memory-OOB exception: %s" ,
131- message );
132- return ;
133- }
134-
135- switch (parent -> module_type ) {
136- #if WASM_ENABLE_INTERP != 0
137- case Wasm_Module_Bytecode :
138- wasm_set_exception ((WASMModuleInstance * )parent , message );
139- break ;
140- #endif
141- #if WASM_ENABLE_AOT != 0
142- case Wasm_Module_AoT :
143- aot_set_exception ((AOTModuleInstance * )parent , message );
144- break ;
145- #endif
146- default :
147- break ;
148- }
149-
150- switch (sub_module -> module_type ) {
151- #if WASM_ENABLE_INTERP != 0
152- case Wasm_Module_Bytecode :
153- wasm_set_exception ((WASMModuleInstance * )sub_module , NULL );
154- break ;
155- #endif
156- #if WASM_ENABLE_AOT != 0
157- case Wasm_Module_AoT :
158- aot_set_exception ((AOTModuleInstance * )sub_module , NULL );
159- break ;
160- #endif
161- default :
162- break ;
163- }
164- }
165- }
166-
16789static void
16890wasm_runtime_destroy_registered_module_list (void );
16991#endif /* WASM_ENABLE_MULTI_MODULE */
@@ -1449,6 +1371,84 @@ wasm_runtime_destroy_loading_module_list()
14491371
14501372 os_mutex_unlock (& loading_module_list_lock );
14511373}
1374+
1375+ void
1376+ wasm_runtime_propagate_exception_from_import (
1377+ WASMModuleInstanceCommon * parent , WASMModuleInstanceCommon * sub_module )
1378+ {
1379+ static const uint32 exception_prefix_len = sizeof ("Exception: " ) - 1 ;
1380+ static const char memory_oob_exception [] = "out of bounds memory access" ;
1381+ char exception_buf [EXCEPTION_BUF_LEN ] = { 0 };
1382+ const char * message = NULL ;
1383+ bool has_exception = false;
1384+
1385+ if (!parent || !sub_module )
1386+ return ;
1387+
1388+ switch (sub_module -> module_type ) {
1389+ #if WASM_ENABLE_INTERP != 0
1390+ case Wasm_Module_Bytecode :
1391+ has_exception = wasm_copy_exception (
1392+ (WASMModuleInstance * )sub_module , exception_buf );
1393+ break ;
1394+ #endif
1395+ #if WASM_ENABLE_AOT != 0
1396+ case Wasm_Module_AoT :
1397+ has_exception = aot_copy_exception ((AOTModuleInstance * )sub_module ,
1398+ exception_buf );
1399+ break ;
1400+ #endif
1401+ default :
1402+ return ;
1403+ }
1404+
1405+ if (has_exception ) {
1406+ message = exception_buf ;
1407+ if (strlen (message ) >= exception_prefix_len ) {
1408+ message += exception_prefix_len ;
1409+ }
1410+ else {
1411+ LOG_WARNING ("sub-module exception format unexpected: %s" , message );
1412+ return ;
1413+ }
1414+
1415+ if (strcmp (message , memory_oob_exception ) != 0 ) {
1416+ LOG_WARNING ("skip propagating non-memory-OOB exception: %s" ,
1417+ message );
1418+ return ;
1419+ }
1420+
1421+ switch (parent -> module_type ) {
1422+ #if WASM_ENABLE_INTERP != 0
1423+ case Wasm_Module_Bytecode :
1424+ wasm_set_exception ((WASMModuleInstance * )parent , message );
1425+ break ;
1426+ #endif
1427+ #if WASM_ENABLE_AOT != 0
1428+ case Wasm_Module_AoT :
1429+ aot_set_exception ((AOTModuleInstance * )parent , message );
1430+ break ;
1431+ #endif
1432+ default :
1433+ break ;
1434+ }
1435+
1436+ switch (sub_module -> module_type ) {
1437+ #if WASM_ENABLE_INTERP != 0
1438+ case Wasm_Module_Bytecode :
1439+ wasm_set_exception ((WASMModuleInstance * )sub_module , NULL );
1440+ break ;
1441+ #endif
1442+ #if WASM_ENABLE_AOT != 0
1443+ case Wasm_Module_AoT :
1444+ aot_set_exception ((AOTModuleInstance * )sub_module , NULL );
1445+ break ;
1446+ #endif
1447+ default :
1448+ break ;
1449+ }
1450+ }
1451+ }
14521452#endif /* WASM_ENABLE_MULTI_MODULE */
14531453
14541454bool
0 commit comments