krillplayer-plugin 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +2 -1
- package/README.md +2 -0
- package/dist/cli.js +397 -80
- package/dist/crypto.js +38 -11
- package/dist/engine/engine.c +6 -3
- package/kernel/Sources/CQuickJS/include/kernel_qjs.h +8 -1
- package/kernel/Sources/CQuickJS/kernel_internal.h +54 -0
- package/kernel/Sources/CQuickJS/kernel_qjs.c +17 -29
- package/kernel/Sources/CQuickJS/kernel_wasm.c +1155 -0
- package/kernel/Sources/CWAMR/include/kernel_wamr.h +151 -0
- package/kernel/Sources/CWAMR/include/kernel_wamr_config.h +66 -0
- package/kernel/Sources/CWAMR/vendor/LICENSE +219 -0
- package/kernel/Sources/CWAMR/vendor/core/config.h +727 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/aot/aot_runtime.h +899 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/common/arch/invokeNative_general.c +123 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_application.c +933 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_blocking_op.c +92 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_c_api.c +5391 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_c_api_internal.h +246 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_exec_env.c +336 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_exec_env.h +328 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_loader_common.c +242 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_loader_common.h +62 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_memory.c +1999 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_memory.h +154 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_native.c +1532 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_native.h +117 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_runtime_common.c +8070 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_runtime_common.h +1396 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_shared_memory.c +477 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_shared_memory.h +63 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_suspend_flags.h +52 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/compilation/aot.h +366 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/include/lib_export.h +60 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/include/wasm_c_api.h +910 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/include/wasm_export.h +2440 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/interpreter/wasm.h +1492 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/interpreter/wasm_interp.h +122 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/interpreter/wasm_interp_fast.c +7998 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/interpreter/wasm_loader.c +16909 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/interpreter/wasm_loader.h +80 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/interpreter/wasm_opcode.h +1043 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/interpreter/wasm_runtime.c +5174 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/interpreter/wasm_runtime.h +912 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/libraries/thread-mgr/thread_manager.c +1569 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/libraries/thread-mgr/thread_manager.h +256 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/mem-alloc/ems/ems_alloc.c +1169 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/mem-alloc/ems/ems_gc.c +497 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/mem-alloc/ems/ems_gc.h +350 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/mem-alloc/ems/ems_gc_internal.h +384 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/mem-alloc/ems/ems_hmu.c +95 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/mem-alloc/ems/ems_kfc.c +547 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/mem-alloc/mem_alloc.c +252 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/mem-alloc/mem_alloc.h +96 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/platform/common/memory/mremap.c +12 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/platform/common/posix/posix_blocking_op.c +70 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/platform/common/posix/posix_malloc.c +72 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/platform/common/posix/posix_memmap.c +302 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/platform/common/posix/posix_sleep.c +20 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/platform/common/posix/posix_thread.c +784 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/platform/common/posix/posix_time.c +28 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/platform/darwin/platform_init.c +43 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/platform/darwin/platform_internal.h +126 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/platform/include/platform_api_extension.h +1676 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/platform/include/platform_api_vmcore.h +192 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/platform/include/platform_common.h +204 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/platform/include/platform_wasi_types.h +610 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/platform/linux/platform_init.c +43 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/platform/linux/platform_internal.h +139 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_assert.c +25 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_assert.h +42 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_atomic.h +300 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_bitmap.c +27 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_bitmap.h +114 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_common.c +217 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_common.h +83 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_hashmap.c +339 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_hashmap.h +168 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_leb128.c +77 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_leb128.h +30 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_list.c +111 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_list.h +109 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_log.c +111 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_log.h +94 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_platform.h +38 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_queue.c +256 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_queue.h +80 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_vector.c +279 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_vector.h +126 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/gnuc.h +14 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/runtime_timer.c +469 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/runtime_timer.h +51 -0
- package/kernel/Sources/CWAMR/vendor/core/version.h +24 -0
- package/kernel/Sources/CWAMR/wamr_bh_assert.c +98 -0
- package/kernel/Sources/CWAMR/wamr_bh_bitmap.c +98 -0
- package/kernel/Sources/CWAMR/wamr_bh_common.c +98 -0
- package/kernel/Sources/CWAMR/wamr_bh_hashmap.c +98 -0
- package/kernel/Sources/CWAMR/wamr_bh_leb128.c +98 -0
- package/kernel/Sources/CWAMR/wamr_bh_list.c +98 -0
- package/kernel/Sources/CWAMR/wamr_bh_log.c +98 -0
- package/kernel/Sources/CWAMR/wamr_bh_queue.c +98 -0
- package/kernel/Sources/CWAMR/wamr_bh_vector.c +98 -0
- package/kernel/Sources/CWAMR/wamr_ems_alloc.c +98 -0
- package/kernel/Sources/CWAMR/wamr_ems_gc.c +98 -0
- package/kernel/Sources/CWAMR/wamr_ems_hmu.c +98 -0
- package/kernel/Sources/CWAMR/wamr_ems_kfc.c +98 -0
- package/kernel/Sources/CWAMR/wamr_invokeNative_general.c +98 -0
- package/kernel/Sources/CWAMR/wamr_mem_alloc.c +98 -0
- package/kernel/Sources/CWAMR/wamr_mremap.c +98 -0
- package/kernel/Sources/CWAMR/wamr_platform_init_darwin.c +100 -0
- package/kernel/Sources/CWAMR/wamr_platform_init_linux.c +100 -0
- package/kernel/Sources/CWAMR/wamr_posix_blocking_op.c +98 -0
- package/kernel/Sources/CWAMR/wamr_posix_malloc.c +98 -0
- package/kernel/Sources/CWAMR/wamr_posix_memmap.c +98 -0
- package/kernel/Sources/CWAMR/wamr_posix_sleep.c +98 -0
- package/kernel/Sources/CWAMR/wamr_posix_thread.c +98 -0
- package/kernel/Sources/CWAMR/wamr_posix_time.c +98 -0
- package/kernel/Sources/CWAMR/wamr_runtime_timer.c +98 -0
- package/kernel/Sources/CWAMR/wamr_thread_manager.c +98 -0
- package/kernel/Sources/CWAMR/wamr_wasm_application.c +98 -0
- package/kernel/Sources/CWAMR/wamr_wasm_blocking_op.c +98 -0
- package/kernel/Sources/CWAMR/wamr_wasm_c_api.c +98 -0
- package/kernel/Sources/CWAMR/wamr_wasm_exec_env.c +98 -0
- package/kernel/Sources/CWAMR/wamr_wasm_interp_fast.c +98 -0
- package/kernel/Sources/CWAMR/wamr_wasm_loader.c +98 -0
- package/kernel/Sources/CWAMR/wamr_wasm_loader_common.c +98 -0
- package/kernel/Sources/CWAMR/wamr_wasm_memory.c +98 -0
- package/kernel/Sources/CWAMR/wamr_wasm_native.c +98 -0
- package/kernel/Sources/CWAMR/wamr_wasm_runtime.c +98 -0
- package/kernel/Sources/CWAMR/wamr_wasm_runtime_common.c +98 -0
- package/kernel/Sources/CWAMR/wamr_wasm_shared_memory.c +98 -0
- package/kernel/Sources/Kernel/PluginPrelude.js +5 -2
- package/kernel/Tests/KernelTests/CasePins.js +50 -0
- package/package.json +2 -2
- package/skill/krillplayer-plugin/SKILL.md +2 -0
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/danmaku-send-content-rejected.json +8 -4
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/danmaku-send-login-expired.json +8 -4
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/danmaku-send-muted.json +8 -4
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/danmaku-send-other.json +8 -4
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/danmaku-send-rate-limited.json +8 -4
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/danmaku-send-sent.json +8 -4
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/play-live-logged-in.json +39 -0
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/play-live-selected-backup-line.json +46 -0
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/play-live-selected-line-gone.json +46 -0
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/play-live.json +21 -1
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/plugin.ts +39 -4
- package/skill/krillplayer-plugin/references/cases.md +20 -2
- package/skill/krillplayer-plugin/references/contract.d.ts +114 -12
- package/skill/krillplayer-plugin/references/crypto-tools.md +104 -0
- package/skill/krillplayer-plugin/references/errors-and-fixes.md +5 -1
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
#ifndef _AOT_H_
|
|
7
|
+
#define _AOT_H_
|
|
8
|
+
|
|
9
|
+
#include "bh_platform.h"
|
|
10
|
+
#include "bh_assert.h"
|
|
11
|
+
#include "../common/wasm_runtime_common.h"
|
|
12
|
+
#include "../interpreter/wasm.h"
|
|
13
|
+
|
|
14
|
+
#ifdef __cplusplus
|
|
15
|
+
extern "C" {
|
|
16
|
+
#endif
|
|
17
|
+
|
|
18
|
+
#ifndef AOT_FUNC_PREFIX
|
|
19
|
+
#define AOT_FUNC_PREFIX "aot_func#"
|
|
20
|
+
#endif
|
|
21
|
+
|
|
22
|
+
#ifndef AOT_FUNC_INTERNAL_PREFIX
|
|
23
|
+
#define AOT_FUNC_INTERNAL_PREFIX "aot_func_internal#"
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
#ifndef AOT_STACK_SIZES_NAME
|
|
27
|
+
#define AOT_STACK_SIZES_NAME "aot_stack_sizes"
|
|
28
|
+
#endif
|
|
29
|
+
extern const char *aot_stack_sizes_name;
|
|
30
|
+
|
|
31
|
+
#ifndef AOT_STACK_SIZES_ALIAS_NAME
|
|
32
|
+
#define AOT_STACK_SIZES_ALIAS_NAME "aot_stack_sizes_alias"
|
|
33
|
+
#endif
|
|
34
|
+
extern const char *aot_stack_sizes_alias_name;
|
|
35
|
+
|
|
36
|
+
#ifndef AOT_STACK_SIZES_SECTION_NAME
|
|
37
|
+
#define AOT_STACK_SIZES_SECTION_NAME ".aot_stack_sizes"
|
|
38
|
+
#endif
|
|
39
|
+
extern const char *aot_stack_sizes_section_name;
|
|
40
|
+
|
|
41
|
+
typedef InitializerExpression AOTInitExpr;
|
|
42
|
+
typedef WASMType AOTType;
|
|
43
|
+
typedef WASMFuncType AOTFuncType;
|
|
44
|
+
#if WASM_ENABLE_GC != 0
|
|
45
|
+
typedef WASMStructType AOTStructType;
|
|
46
|
+
typedef WASMArrayType AOTArrayType;
|
|
47
|
+
#endif
|
|
48
|
+
typedef WASMExport AOTExport;
|
|
49
|
+
typedef WASMMemory AOTMemory;
|
|
50
|
+
typedef WASMMemoryType AOTMemoryType;
|
|
51
|
+
typedef WASMTableType AOTTableType;
|
|
52
|
+
typedef WASMTable AOTTable;
|
|
53
|
+
|
|
54
|
+
#if WASM_ENABLE_DEBUG_AOT != 0
|
|
55
|
+
typedef void *dwarf_extractor_handle_t;
|
|
56
|
+
#endif
|
|
57
|
+
|
|
58
|
+
typedef enum AOTIntCond {
|
|
59
|
+
INT_EQZ = 0,
|
|
60
|
+
INT_EQ,
|
|
61
|
+
INT_NE,
|
|
62
|
+
INT_LT_S,
|
|
63
|
+
INT_LT_U,
|
|
64
|
+
INT_GT_S,
|
|
65
|
+
INT_GT_U,
|
|
66
|
+
INT_LE_S,
|
|
67
|
+
INT_LE_U,
|
|
68
|
+
INT_GE_S,
|
|
69
|
+
INT_GE_U
|
|
70
|
+
} AOTIntCond;
|
|
71
|
+
|
|
72
|
+
typedef enum AOTFloatCond {
|
|
73
|
+
FLOAT_EQ = 0,
|
|
74
|
+
FLOAT_NE,
|
|
75
|
+
FLOAT_LT,
|
|
76
|
+
FLOAT_GT,
|
|
77
|
+
FLOAT_LE,
|
|
78
|
+
FLOAT_GE,
|
|
79
|
+
FLOAT_UNO
|
|
80
|
+
} AOTFloatCond;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Import memory
|
|
84
|
+
*/
|
|
85
|
+
typedef struct AOTImportMemory {
|
|
86
|
+
char *module_name;
|
|
87
|
+
char *memory_name;
|
|
88
|
+
AOTMemoryType mem_type;
|
|
89
|
+
} AOTImportMemory;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* A segment of memory init data
|
|
93
|
+
*/
|
|
94
|
+
typedef struct AOTMemInitData {
|
|
95
|
+
#if WASM_ENABLE_BULK_MEMORY != 0
|
|
96
|
+
/* Passive flag */
|
|
97
|
+
bool is_passive;
|
|
98
|
+
/* memory index */
|
|
99
|
+
uint32 memory_index;
|
|
100
|
+
#endif
|
|
101
|
+
/* Start address of init data */
|
|
102
|
+
AOTInitExpr offset;
|
|
103
|
+
/* Byte count */
|
|
104
|
+
uint32 byte_count;
|
|
105
|
+
/* Byte array */
|
|
106
|
+
uint8 *bytes;
|
|
107
|
+
} AOTMemInitData;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Import table
|
|
111
|
+
*/
|
|
112
|
+
typedef struct AOTImportTable {
|
|
113
|
+
char *module_name;
|
|
114
|
+
char *table_name;
|
|
115
|
+
AOTTableType table_type;
|
|
116
|
+
} AOTImportTable;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* A segment of table init data
|
|
120
|
+
*/
|
|
121
|
+
typedef struct AOTTableInitData {
|
|
122
|
+
/* 0 to 7 */
|
|
123
|
+
uint32 mode;
|
|
124
|
+
/* funcref or externref, elemkind will be considered as funcref */
|
|
125
|
+
uint32 elem_type;
|
|
126
|
+
#if WASM_ENABLE_GC != 0
|
|
127
|
+
WASMRefType *elem_ref_type;
|
|
128
|
+
#endif
|
|
129
|
+
/* optional, only for active */
|
|
130
|
+
uint32 table_index;
|
|
131
|
+
/* Start address of init data */
|
|
132
|
+
AOTInitExpr offset;
|
|
133
|
+
/* Function index count */
|
|
134
|
+
uint32 value_count;
|
|
135
|
+
/* Function index array */
|
|
136
|
+
InitializerExpression init_values[1];
|
|
137
|
+
} AOTTableInitData;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Import global variable
|
|
141
|
+
*/
|
|
142
|
+
typedef struct AOTImportGlobal {
|
|
143
|
+
char *module_name;
|
|
144
|
+
char *global_name;
|
|
145
|
+
WASMGlobalType type;
|
|
146
|
+
uint32 size;
|
|
147
|
+
/* The data offset of current global in global data */
|
|
148
|
+
uint32 data_offset;
|
|
149
|
+
#if WASM_ENABLE_WAMR_COMPILER != 0 || WASM_ENABLE_JIT != 0
|
|
150
|
+
/*
|
|
151
|
+
* The data size and data offset of a wasm global may vary
|
|
152
|
+
* in 32-bit target and 64-bit target, e.g., the size of a
|
|
153
|
+
* GC obj is 4 bytes in the former and 8 bytes in the
|
|
154
|
+
* latter, the AOT compiler needs to use the correct data
|
|
155
|
+
* offset according to the target info.
|
|
156
|
+
*/
|
|
157
|
+
uint32 size_64bit;
|
|
158
|
+
uint32 size_32bit;
|
|
159
|
+
uint32 data_offset_64bit;
|
|
160
|
+
uint32 data_offset_32bit;
|
|
161
|
+
#endif
|
|
162
|
+
/* global data after linked */
|
|
163
|
+
WASMValue global_data_linked;
|
|
164
|
+
bool is_linked;
|
|
165
|
+
} AOTImportGlobal;
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Global variable
|
|
169
|
+
*/
|
|
170
|
+
typedef struct AOTGlobal {
|
|
171
|
+
WASMGlobalType type;
|
|
172
|
+
uint32 size;
|
|
173
|
+
/* The data offset of current global in global data */
|
|
174
|
+
uint32 data_offset;
|
|
175
|
+
#if WASM_ENABLE_WAMR_COMPILER != 0 || WASM_ENABLE_JIT != 0
|
|
176
|
+
/* See comments in AOTImportGlobal */
|
|
177
|
+
uint32 size_64bit;
|
|
178
|
+
uint32 size_32bit;
|
|
179
|
+
uint32 data_offset_64bit;
|
|
180
|
+
uint32 data_offset_32bit;
|
|
181
|
+
#endif
|
|
182
|
+
AOTInitExpr init_expr;
|
|
183
|
+
} AOTGlobal;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Import function
|
|
187
|
+
*/
|
|
188
|
+
typedef struct AOTImportFunc {
|
|
189
|
+
char *module_name;
|
|
190
|
+
char *func_name;
|
|
191
|
+
AOTFuncType *func_type;
|
|
192
|
+
uint32 func_type_index;
|
|
193
|
+
/* function pointer after linked */
|
|
194
|
+
void *func_ptr_linked;
|
|
195
|
+
/* signature from registered native symbols */
|
|
196
|
+
const char *signature;
|
|
197
|
+
/* attachment */
|
|
198
|
+
void *attachment;
|
|
199
|
+
bool call_conv_raw;
|
|
200
|
+
bool call_conv_wasm_c_api;
|
|
201
|
+
bool wasm_c_api_with_env;
|
|
202
|
+
} AOTImportFunc;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Function
|
|
206
|
+
*/
|
|
207
|
+
typedef struct AOTFunc {
|
|
208
|
+
AOTFuncType *func_type;
|
|
209
|
+
uint32 func_type_index;
|
|
210
|
+
uint32 local_count;
|
|
211
|
+
uint8 *local_types_wp;
|
|
212
|
+
uint16 param_cell_num;
|
|
213
|
+
uint16 local_cell_num;
|
|
214
|
+
uint32 max_stack_cell_num;
|
|
215
|
+
uint32 code_size;
|
|
216
|
+
uint8 *code;
|
|
217
|
+
/* offset of each local, including function parameters
|
|
218
|
+
and local variables */
|
|
219
|
+
uint16 *local_offsets;
|
|
220
|
+
} AOTFunc;
|
|
221
|
+
|
|
222
|
+
typedef struct AOTCompData {
|
|
223
|
+
/* Import memories */
|
|
224
|
+
uint32 import_memory_count;
|
|
225
|
+
AOTImportMemory *import_memories;
|
|
226
|
+
|
|
227
|
+
/* Memories */
|
|
228
|
+
uint32 memory_count;
|
|
229
|
+
AOTMemory *memories;
|
|
230
|
+
|
|
231
|
+
/* Memory init data info */
|
|
232
|
+
uint32 mem_init_data_count;
|
|
233
|
+
AOTMemInitData **mem_init_data_list;
|
|
234
|
+
|
|
235
|
+
/* Import tables */
|
|
236
|
+
uint32 import_table_count;
|
|
237
|
+
AOTImportTable *import_tables;
|
|
238
|
+
|
|
239
|
+
/* Tables */
|
|
240
|
+
uint32 table_count;
|
|
241
|
+
AOTTable *tables;
|
|
242
|
+
|
|
243
|
+
/* Table init data info */
|
|
244
|
+
uint32 table_init_data_count;
|
|
245
|
+
AOTTableInitData **table_init_data_list;
|
|
246
|
+
|
|
247
|
+
/* Import globals */
|
|
248
|
+
uint32 import_global_count;
|
|
249
|
+
AOTImportGlobal *import_globals;
|
|
250
|
+
|
|
251
|
+
/* Globals */
|
|
252
|
+
uint32 global_count;
|
|
253
|
+
AOTGlobal *globals;
|
|
254
|
+
|
|
255
|
+
/* Function types */
|
|
256
|
+
uint32 type_count;
|
|
257
|
+
AOTType **types;
|
|
258
|
+
|
|
259
|
+
/* Import functions */
|
|
260
|
+
uint32 import_func_count;
|
|
261
|
+
AOTImportFunc *import_funcs;
|
|
262
|
+
|
|
263
|
+
/* Functions */
|
|
264
|
+
uint32 func_count;
|
|
265
|
+
AOTFunc **funcs;
|
|
266
|
+
|
|
267
|
+
/* Custom name sections */
|
|
268
|
+
const uint8 *name_section_buf;
|
|
269
|
+
const uint8 *name_section_buf_end;
|
|
270
|
+
uint8 *aot_name_section_buf;
|
|
271
|
+
uint32 aot_name_section_size;
|
|
272
|
+
|
|
273
|
+
uint32 global_data_size_64bit;
|
|
274
|
+
uint32 global_data_size_32bit;
|
|
275
|
+
|
|
276
|
+
uint32 start_func_index;
|
|
277
|
+
uint32 malloc_func_index;
|
|
278
|
+
uint32 free_func_index;
|
|
279
|
+
uint32 retain_func_index;
|
|
280
|
+
|
|
281
|
+
uint32 aux_data_end_global_index;
|
|
282
|
+
uint64 aux_data_end;
|
|
283
|
+
uint32 aux_heap_base_global_index;
|
|
284
|
+
uint64 aux_heap_base;
|
|
285
|
+
uint32 aux_stack_top_global_index;
|
|
286
|
+
uint64 aux_stack_bottom;
|
|
287
|
+
uint32 aux_stack_size;
|
|
288
|
+
|
|
289
|
+
#if WASM_ENABLE_STRINGREF != 0
|
|
290
|
+
uint32 string_literal_count;
|
|
291
|
+
uint32 *string_literal_lengths_wp;
|
|
292
|
+
const uint8 **string_literal_ptrs_wp;
|
|
293
|
+
#endif
|
|
294
|
+
|
|
295
|
+
WASMModule *wasm_module;
|
|
296
|
+
#if WASM_ENABLE_DEBUG_AOT != 0
|
|
297
|
+
dwarf_extractor_handle_t extractor;
|
|
298
|
+
#endif
|
|
299
|
+
} AOTCompData;
|
|
300
|
+
|
|
301
|
+
typedef struct AOTNativeSymbol {
|
|
302
|
+
bh_list_link link;
|
|
303
|
+
char symbol[48];
|
|
304
|
+
int32 index;
|
|
305
|
+
} AOTNativeSymbol;
|
|
306
|
+
|
|
307
|
+
AOTCompData *
|
|
308
|
+
aot_create_comp_data(WASMModule *module, const char *target_arch,
|
|
309
|
+
bool gc_enabled);
|
|
310
|
+
|
|
311
|
+
void
|
|
312
|
+
aot_destroy_comp_data(AOTCompData *comp_data);
|
|
313
|
+
|
|
314
|
+
char *
|
|
315
|
+
aot_get_last_error(void);
|
|
316
|
+
|
|
317
|
+
void
|
|
318
|
+
aot_set_last_error(const char *error);
|
|
319
|
+
|
|
320
|
+
void
|
|
321
|
+
aot_set_last_error_v(const char *format, ...);
|
|
322
|
+
|
|
323
|
+
#if BH_DEBUG != 0
|
|
324
|
+
#define HANDLE_FAILURE(callee) \
|
|
325
|
+
do { \
|
|
326
|
+
aot_set_last_error_v("call %s failed in %s:%d", (callee), \
|
|
327
|
+
__FUNCTION__, __LINE__); \
|
|
328
|
+
} while (0)
|
|
329
|
+
#else
|
|
330
|
+
#define HANDLE_FAILURE(callee) \
|
|
331
|
+
do { \
|
|
332
|
+
aot_set_last_error_v("call %s failed", (callee)); \
|
|
333
|
+
} while (0)
|
|
334
|
+
#endif
|
|
335
|
+
|
|
336
|
+
static inline uint32
|
|
337
|
+
aot_get_imp_tbl_data_slots(const AOTImportTable *tbl, bool is_jit_mode)
|
|
338
|
+
{
|
|
339
|
+
#if WASM_ENABLE_MULTI_MODULE != 0
|
|
340
|
+
if (is_jit_mode)
|
|
341
|
+
return tbl->table_type.max_size;
|
|
342
|
+
#else
|
|
343
|
+
(void)is_jit_mode;
|
|
344
|
+
#endif
|
|
345
|
+
return tbl->table_type.possible_grow ? tbl->table_type.max_size
|
|
346
|
+
: tbl->table_type.init_size;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
static inline uint32
|
|
350
|
+
aot_get_tbl_data_slots(const AOTTable *tbl, bool is_jit_mode)
|
|
351
|
+
{
|
|
352
|
+
#if WASM_ENABLE_MULTI_MODULE != 0
|
|
353
|
+
if (is_jit_mode)
|
|
354
|
+
return tbl->table_type.max_size;
|
|
355
|
+
#else
|
|
356
|
+
(void)is_jit_mode;
|
|
357
|
+
#endif
|
|
358
|
+
return tbl->table_type.possible_grow ? tbl->table_type.max_size
|
|
359
|
+
: tbl->table_type.init_size;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
#ifdef __cplusplus
|
|
363
|
+
} /* end of extern "C" */
|
|
364
|
+
#endif
|
|
365
|
+
|
|
366
|
+
#endif /* end of _AOT_H_ */
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @file lib_export.h
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#ifndef _LIB_EXPORT_H_
|
|
12
|
+
#define _LIB_EXPORT_H_
|
|
13
|
+
|
|
14
|
+
#include <stdint.h>
|
|
15
|
+
|
|
16
|
+
#ifdef __cplusplus
|
|
17
|
+
extern "C" {
|
|
18
|
+
#endif
|
|
19
|
+
|
|
20
|
+
typedef struct NativeSymbol {
|
|
21
|
+
const char *symbol;
|
|
22
|
+
void *func_ptr;
|
|
23
|
+
const char *signature;
|
|
24
|
+
/* attachment which can be retrieved in native API by
|
|
25
|
+
calling wasm_runtime_get_function_attachment(exec_env) */
|
|
26
|
+
void *attachment;
|
|
27
|
+
} NativeSymbol;
|
|
28
|
+
|
|
29
|
+
/* clang-format off */
|
|
30
|
+
#define EXPORT_WASM_API(symbol) \
|
|
31
|
+
{ #symbol, (void *)symbol, NULL, NULL }
|
|
32
|
+
#define EXPORT_WASM_API2(symbol) \
|
|
33
|
+
{ #symbol, (void *)symbol##_wrapper, NULL, NULL }
|
|
34
|
+
|
|
35
|
+
#define EXPORT_WASM_API_WITH_SIG(symbol, signature) \
|
|
36
|
+
{ #symbol, (void *)symbol, signature, NULL }
|
|
37
|
+
#define EXPORT_WASM_API_WITH_SIG2(symbol, signature) \
|
|
38
|
+
{ #symbol, (void *)symbol##_wrapper, signature, NULL }
|
|
39
|
+
|
|
40
|
+
#define EXPORT_WASM_API_WITH_ATT(symbol, signature, attachment) \
|
|
41
|
+
{ #symbol, (void *)symbol, signature, attachment }
|
|
42
|
+
#define EXPORT_WASM_API_WITH_ATT2(symbol, signature, attachment) \
|
|
43
|
+
{ #symbol, (void *)symbol##_wrapper, signature, attachment }
|
|
44
|
+
/* clang-format on */
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Get the exported APIs of base lib
|
|
48
|
+
*
|
|
49
|
+
* @param p_base_lib_apis return the exported API array of base lib
|
|
50
|
+
*
|
|
51
|
+
* @return the number of the exported API
|
|
52
|
+
*/
|
|
53
|
+
uint32_t
|
|
54
|
+
get_base_lib_export_apis(NativeSymbol **p_base_lib_apis);
|
|
55
|
+
|
|
56
|
+
#ifdef __cplusplus
|
|
57
|
+
}
|
|
58
|
+
#endif
|
|
59
|
+
|
|
60
|
+
#endif /* end of _LIB_EXPORT_H_ */
|