14
14
extern "C" {
15
15
#endif
16
16
17
+
18
+ #if WASM_ENABLE_EXCE_HANDLING != 0
19
+ #define _EXCEWARNING LOG_WARNING /* for exception handling misbehavior logging */
20
+ #define _EXCEDEBUG LOG_VERBOSE /* for exception handling debugging */
21
+ #define _EXCEVERBOSE LOG_VERBOSE /* more excessive tracing of tagbrowsing and stack pointers */
22
+ #endif
23
+
17
24
/** Value Type */
18
25
#define VALUE_TYPE_I32 0x7F
19
26
#define VALUE_TYPE_I64 0X7E
@@ -65,6 +72,9 @@ extern "C" {
65
72
#if WASM_ENABLE_BULK_MEMORY != 0
66
73
#define SECTION_TYPE_DATACOUNT 12
67
74
#endif
75
+ #if WASM_ENABLE_TAGS != 0
76
+ #define SECTION_TYPE_TAG 13
77
+ #endif
68
78
69
79
#define SUB_SECTION_TYPE_MODULE 0
70
80
#define SUB_SECTION_TYPE_FUNC 1
@@ -74,20 +84,34 @@ extern "C" {
74
84
#define IMPORT_KIND_TABLE 1
75
85
#define IMPORT_KIND_MEMORY 2
76
86
#define IMPORT_KIND_GLOBAL 3
87
+ #if WASM_ENABLE_TAGS != 0
88
+ #define IMPORT_KIND_TAG 4
89
+ #endif
77
90
78
91
#define EXPORT_KIND_FUNC 0
79
92
#define EXPORT_KIND_TABLE 1
80
93
#define EXPORT_KIND_MEMORY 2
81
94
#define EXPORT_KIND_GLOBAL 3
95
+ #if WASM_ENABLE_TAGS != 0
96
+ #define EXPORT_KIND_TAG 4
97
+ #endif
82
98
83
99
#define LABEL_TYPE_BLOCK 0
84
100
#define LABEL_TYPE_LOOP 1
85
101
#define LABEL_TYPE_IF 2
86
102
#define LABEL_TYPE_FUNCTION 3
103
+ #if WASM_ENABLE_EXCE_HANDLING != 0
104
+ #define LABEL_TYPE_TRY 4
105
+ #define LABEL_TYPE_CATCH 5
106
+ #define LABEL_TYPE_CATCH_ALL 6
107
+ #endif
87
108
88
109
typedef struct WASMModule WASMModule ;
89
110
typedef struct WASMFunction WASMFunction ;
90
111
typedef struct WASMGlobal WASMGlobal ;
112
+ #if WASM_ENABLE_TAGS != 0
113
+ typedef struct WASMTag WASMTag ;
114
+ #endif
91
115
92
116
typedef union V128 {
93
117
int8 i8x16 [16 ];
@@ -197,6 +221,13 @@ typedef struct WASMFunctionImport {
197
221
bool call_conv_wasm_c_api ;
198
222
} WASMFunctionImport ;
199
223
224
+ #if WASM_ENABLE_TAGS != 0
225
+ typedef struct WASMTagImport {
226
+ uint8 attribute ; /* the type of the tag (numerical) */
227
+ uint32 type ; /* the type of the catch function (numerical)*/
228
+ } WASMTagImport ;
229
+ #endif
230
+
200
231
typedef struct WASMGlobalImport {
201
232
char * module_name ;
202
233
char * field_name ;
@@ -223,6 +254,9 @@ typedef struct WASMImport {
223
254
WASMFunctionImport function ;
224
255
WASMTableImport table ;
225
256
WASMMemoryImport memory ;
257
+ #if WASM_ENABLE_TAGS != 0
258
+ WASMTagImport tag ;
259
+ #endif
226
260
WASMGlobalImport global ;
227
261
struct {
228
262
char * module_name ;
@@ -261,6 +295,10 @@ struct WASMFunction {
261
295
uint32 const_cell_num ;
262
296
#endif
263
297
298
+ #if WASM_ENABLE_EXCE_HANDLING != 0
299
+ uint32 exception_handler_count ;
300
+ #endif
301
+
264
302
#if WASM_ENABLE_FAST_JIT != 0 || WASM_ENABLE_JIT != 0 \
265
303
|| WASM_ENABLE_WAMR_COMPILER != 0
266
304
/* Whether function has opcode memory.grow */
@@ -290,6 +328,13 @@ struct WASMFunction {
290
328
#endif
291
329
};
292
330
331
+ #if WASM_ENABLE_TAGS != 0
332
+ struct WASMTag {
333
+ uint8 attribute ; /* the attribute property of the tag (expected to be 0) */
334
+ uint32 type ; /* the type of the tag (expected valid inden in type table) */
335
+ };
336
+ #endif
337
+
293
338
struct WASMGlobal {
294
339
uint8 type ;
295
340
bool is_mutable ;
@@ -417,6 +462,9 @@ struct WASMModule {
417
462
uint32 function_count ;
418
463
uint32 table_count ;
419
464
uint32 memory_count ;
465
+ #if WASM_ENABLE_TAGS != 0
466
+ uint32 tag_count ;
467
+ #endif
420
468
uint32 global_count ;
421
469
uint32 export_count ;
422
470
uint32 table_seg_count ;
@@ -430,18 +478,28 @@ struct WASMModule {
430
478
uint32 import_function_count ;
431
479
uint32 import_table_count ;
432
480
uint32 import_memory_count ;
481
+ #if WASM_ENABLE_TAGS != 0
482
+ uint32 import_tag_count ;
483
+ #endif
433
484
uint32 import_global_count ;
434
485
435
486
WASMImport * import_functions ;
436
487
WASMImport * import_tables ;
437
488
WASMImport * import_memories ;
489
+ #if WASM_ENABLE_TAGS != 0
490
+ WASMImport * import_tags ;
491
+ #endif
438
492
WASMImport * import_globals ;
439
493
494
+
440
495
WASMType * * types ;
441
496
WASMImport * imports ;
442
497
WASMFunction * * functions ;
443
498
WASMTable * tables ;
444
499
WASMMemory * memories ;
500
+ #if WASM_ENABLE_TAGS != 0
501
+ WASMTag * tags ;
502
+ #endif
445
503
WASMGlobal * globals ;
446
504
WASMExport * exports ;
447
505
WASMTableSeg * table_segments ;
@@ -625,6 +683,10 @@ typedef struct WASMBranchBlock {
625
683
uint8 * target_addr ;
626
684
uint32 * frame_sp ;
627
685
uint32 cell_num ;
686
+ #if WASM_ENABLE_EXCE_HANDLING != 0
687
+ /* in exception handling, label_type needs to be stored to lookup exception handlers */
688
+ uint8 label_type ;
689
+ #endif
628
690
} WASMBranchBlock ;
629
691
630
692
/* Execution environment, e.g. stack info */
0 commit comments