Skip to content

Commit d10091e

Browse files
committed
Re-organize LLVM JIT mode implementation
It includes: - Remove code with MCJIT APIs. Embrance ORC. - WASM_ENABLE_LAZY_JIT only represent lazy compilation. It won't specify ORC or MCJIT - Remove runtime ORC compilation threads and move all aot functions into one module - Current LLVM ORC JIT implements eagel compilation. Will add lazy compilation later - JIT and AOT both apply the new pass manager - All JIT passes are in IRTransferLayer P.S. | Varient impl. | Norm. Score | Norm. (ms) | | ----------------------- | ----------- | ---------- | | Original | 1.0 | 1.0 | | Apply the new PM | 1.01 | 1.007 | | Opt in IRTransformLayer | 0.997 | 1.04 |
1 parent 8283f9d commit d10091e

17 files changed

+262
-783
lines changed

.github/workflows/compilation_on_android_ubuntu.yml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ env:
3434
AOT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
3535
CLASSIC_INTERP_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=0 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
3636
FAST_INTERP_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=0 -DWAMR_BUILD_FAST_INTERP=1 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
37-
LAZY_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=1"
38-
MC_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=0"
37+
LLVM_JIT_EAGER_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=0"
38+
LLVM_JIT_LAZY_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=1"
3939
# LLVM
4040
LLVM_CACHE_SUFFIX: "build-llvm_libraries_ex"
4141
# For Spec Test
@@ -184,8 +184,8 @@ jobs:
184184
$AOT_BUILD_OPTIONS,
185185
$CLASSIC_INTERP_BUILD_OPTIONS,
186186
$FAST_INTERP_BUILD_OPTIONS,
187-
$LAZY_JIT_BUILD_OPTIONS,
188-
$MC_JIT_BUILD_OPTIONS,
187+
$LLVM_JIT_EAGER_BUILD_OPTIONS,
188+
#$LLVM_JIT_LAZY_BUILD_OPTIONS,
189189
]
190190
make_options_feature: [
191191
# Features
@@ -210,11 +210,11 @@ jobs:
210210
# uncompatiable feature and platform
211211
# uncompatiable mode and feature
212212
# MULTI_MODULE only on INTERP mode
213-
- make_options_run_mode: $LAZY_JIT_BUILD_OPTIONS
213+
- make_options_run_mode: $LLVM_JIT_EAGER_BUILD_OPTIONS
214214
make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
215-
- make_options_run_mode: $AOT_BUILD_OPTIONS
215+
- make_options_run_mode: $LLVM_JIT_LAZY_BUILD_OPTIONS
216216
make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
217-
- make_options_run_mode: $MC_JIT_BUILD_OPTIONS
217+
- make_options_run_mode: $AOT_BUILD_OPTIONS
218218
make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
219219
# SIMD only on JIT/AOT mode
220220
- make_options_run_mode: $CLASSIC_INTERP_BUILD_OPTIONS
@@ -224,9 +224,9 @@ jobs:
224224
# DEBUG_INTERP only on CLASSIC INTERP mode
225225
- make_options_run_mode: $AOT_BUILD_OPTIONS
226226
make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
227-
- make_options_run_mode: $LAZY_JIT_BUILD_OPTIONS
227+
- make_options_run_mode: $LLVM_JIT_EAGER_BUILD_OPTIONS
228228
make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
229-
- make_options_run_mode: $MC_JIT_BUILD_OPTIONS
229+
- make_options_run_mode: $LLVM_JIT_LAZY_BUILD_OPTIONS
230230
make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
231231
- make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
232232
make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
@@ -236,16 +236,16 @@ jobs:
236236
- make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
237237
make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
238238
# TODO: DEBUG_AOT on JIT
239-
- make_options_run_mode: $LAZY_JIT_BUILD_OPTIONS
239+
- make_options_run_mode: $LLVM_JIT_EAGER_BUILD_OPTIONS
240240
make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
241-
- make_options_run_mode: $MC_JIT_BUILD_OPTIONS
241+
- make_options_run_mode: $LLVM_JIT_LAZY_BUILD_OPTIONS
242242
make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
243243
# MINI_LOADER only on INTERP mode
244244
- make_options_run_mode: $AOT_BUILD_OPTIONS
245245
make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
246-
- make_options_run_mode: $LAZY_JIT_BUILD_OPTIONS
246+
- make_options_run_mode: $LLVM_JIT_EAGER_BUILD_OPTIONS
247247
make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
248-
- make_options_run_mode: $MC_JIT_BUILD_OPTIONS
248+
- make_options_run_mode: $LLVM_JIT_LAZY_BUILD_OPTIONS
249249
make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
250250
include:
251251
- os: ubuntu-20.04
@@ -293,11 +293,11 @@ jobs:
293293
matrix:
294294
make_options: [
295295
# Running mode
296+
$AOT_BUILD_OPTIONS,
296297
$CLASSIC_INTERP_BUILD_OPTIONS,
297298
$FAST_INTERP_BUILD_OPTIONS,
298-
$LAZY_JIT_BUILD_OPTIONS,
299-
$MC_JIT_BUILD_OPTIONS,
300-
$AOT_BUILD_OPTIONS,
299+
$LLVM_JIT_EAGER_BUILD_OPTIONS,
300+
$LLVM_JIT_LAZY_BUILD_OPTIONS,
301301
]
302302
os: [ubuntu-20.04, ubuntu-22.04]
303303
include:

.github/workflows/compilation_on_macos.yml

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@ concurrency:
3030
cancel-in-progress: true
3131

3232
env:
33+
# For BUILD
3334
AOT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
3435
CLASSIC_INTERP_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=0 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
3536
FAST_INTERP_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=0 -DWAMR_BUILD_FAST_INTERP=1 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
36-
LAZY_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=1"
37-
MC_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=0"
37+
LLVM_JIT_EAGER_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=0"
38+
LLVM_JIT_LAZY_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=1"
39+
# LLVM
3840
LLVM_CACHE_SUFFIX: "build-llvm_libraries_ex"
3941

4042
jobs:
@@ -160,8 +162,8 @@ jobs:
160162
$AOT_BUILD_OPTIONS,
161163
$CLASSIC_INTERP_BUILD_OPTIONS,
162164
$FAST_INTERP_BUILD_OPTIONS,
163-
$LAZY_JIT_BUILD_OPTIONS,
164-
$MC_JIT_BUILD_OPTIONS,
165+
$LLVM_JIT_EAGER_BUILD_OPTIONS,
166+
$LLVM_JIT_LAZY_BUILD_OPTIONS,
165167
]
166168
make_options_feature: [
167169
# Features
@@ -187,11 +189,11 @@ jobs:
187189
# uncompatiable feature and platform
188190
# uncompatiable mode and feature
189191
# MULTI_MODULE only on INTERP mode
190-
- make_options_run_mode: $LAZY_JIT_BUILD_OPTIONS
192+
- make_options_run_mode: $LLVM_JIT_EAGER_BUILD_OPTIONS
191193
make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
192-
- make_options_run_mode: $AOT_BUILD_OPTIONS
194+
- make_options_run_mode: $LLVM_JIT_LAZY_BUILD_OPTIONS
193195
make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
194-
- make_options_run_mode: $MC_JIT_BUILD_OPTIONS
196+
- make_options_run_mode: $AOT_BUILD_OPTIONS
195197
make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
196198
# SIMD only on JIT/AOT mode
197199
- make_options_run_mode: $CLASSIC_INTERP_BUILD_OPTIONS
@@ -201,9 +203,9 @@ jobs:
201203
# DEBUG_INTERP only on CLASSIC INTERP mode
202204
- make_options_run_mode: $AOT_BUILD_OPTIONS
203205
make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
204-
- make_options_run_mode: $LAZY_JIT_BUILD_OPTIONS
206+
- make_options_run_mode: $LLVM_JIT_EAGER_BUILD_OPTIONS
205207
make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
206-
- make_options_run_mode: $MC_JIT_BUILD_OPTIONS
208+
- make_options_run_mode: $LLVM_JIT_LAZY_BUILD_OPTIONS
207209
make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
208210
- make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
209211
make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
@@ -213,16 +215,16 @@ jobs:
213215
- make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
214216
make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
215217
# TODO: DEBUG_AOT on JIT
216-
- make_options_run_mode: $LAZY_JIT_BUILD_OPTIONS
218+
- make_options_run_mode: $LLVM_JIT_EAGER_BUILD_OPTIONS
217219
make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
218-
- make_options_run_mode: $MC_JIT_BUILD_OPTIONS
220+
- make_options_run_mode: $LLVM_JIT_LAZY_BUILD_OPTIONS
219221
make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
220222
# MINI_LOADER only on INTERP mode
221223
- make_options_run_mode: $AOT_BUILD_OPTIONS
222224
make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
223-
- make_options_run_mode: $LAZY_JIT_BUILD_OPTIONS
225+
- make_options_run_mode: $LLVM_JIT_EAGER_BUILD_OPTIONS
224226
make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
225-
- make_options_run_mode: $MC_JIT_BUILD_OPTIONS
227+
- make_options_run_mode: $LLVM_JIT_LAZY_BUILD_OPTIONS
226228
make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
227229
include:
228230
- os: macos-latest
@@ -271,9 +273,9 @@ jobs:
271273
$CLASSIC_INTERP_BUILD_OPTIONS,
272274
$FAST_INTERP_BUILD_OPTIONS,
273275
# doesn't support
274-
#$LAZY_JIT_BUILD_OPTIONS,
275-
#$MC_JIT_BUILD_OPTIONS,
276276
#$AOT_BUILD_OPTIONS,
277+
#$LLVM_JIT_EAGER_BUILD_OPTIONS,
278+
#$LLVM_JIT_LAZY_BUILD_OPTIONS,
277279
]
278280
os: [macos-latest]
279281
include:

.github/workflows/compilation_on_sgx.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@ concurrency:
3030
cancel-in-progress: true
3131

3232
env:
33+
# For BUILD
3334
AOT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
3435
CLASSIC_INTERP_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=0 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
3536
FAST_INTERP_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=0 -DWAMR_BUILD_FAST_INTERP=1 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
36-
LAZY_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=1"
37-
MC_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=0"
37+
LLVM_JIT_EAGER_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=0"
38+
LLVM_JIT_LAZY_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=1"
39+
# LLVM
3840
LLVM_CACHE_SUFFIX: "build-llvm_libraries_ex"
3941

4042
jobs:
@@ -119,8 +121,8 @@ jobs:
119121
$CLASSIC_INTERP_BUILD_OPTIONS,
120122
$FAST_INTERP_BUILD_OPTIONS,
121123
# doesn't support
122-
# $LAZY_JIT_BUILD_OPTIONS,
123-
# $MC_JIT_BUILD_OPTIONS,
124+
#$LLVM_JIT_EAGER_BUILD_OPTIONS,
125+
#$LLVM_JIT_LAZY_BUILD_OPTIONS,
124126
]
125127
make_options_feature: [
126128
# Features
@@ -250,9 +252,9 @@ jobs:
250252
$CLASSIC_INTERP_BUILD_OPTIONS,
251253
$FAST_INTERP_BUILD_OPTIONS,
252254
# doesn't support
253-
#$LAZY_JIT_BUILD_OPTIONS,
254-
#$MC_JIT_BUILD_OPTIONS,
255255
#$AOT_BUILD_OPTIONS,
256+
#$LLVM_JIT_EAGER_BUILD_OPTIONS,
257+
#$LLVM_JIT_LAZY_BUILD_OPTIONS,
256258
]
257259
os: [ubuntu-20.04]
258260
include:

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,6 @@ tests/wamr-test-suites/workspace
2727

2828
samples/socket-api/wasm-src/inc/pthread.h
2929

30-
**/__pycache__
30+
**/__pycache__
31+
32+
tests/benchmarks/coremark/coremark*

build-scripts/config_common.cmake

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,11 @@ endif ()
8686

8787
if (WAMR_BUILD_JIT EQUAL 1)
8888
if (WAMR_BUILD_AOT EQUAL 1)
89-
add_definitions("-DWASM_ENABLE_JIT=1")
90-
if (NOT WAMR_BUILD_LAZY_JIT EQUAL 0)
89+
if (NOT DEFINED WAMR_BUILD_LAZY_JIT)
9190
# Enable Lazy JIT by default
9291
set (WAMR_BUILD_LAZY_JIT 1)
93-
add_definitions("-DWASM_ENABLE_LAZY_JIT=1")
9492
endif ()
93+
9594
if (NOT DEFINED LLVM_DIR)
9695
set (LLVM_SRC_ROOT "${WAMR_ROOT_DIR}/core/deps/llvm")
9796
set (LLVM_BUILD_ROOT "${LLVM_SRC_ROOT}/build")
@@ -108,6 +107,10 @@ if (WAMR_BUILD_JIT EQUAL 1)
108107
add_definitions(${LLVM_DEFINITIONS})
109108
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
110109
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
110+
111+
if (${LLVM_PACKAGE_VERSION} VERSION_LESS 12.0.0 )
112+
message(FATAL_ERROR "The minimum required version of LLVM is 12.0.0")
113+
endif ()
111114
else ()
112115
set (WAMR_BUILD_JIT 0)
113116
message ("-- WAMR JIT disabled due to WAMR AOT is disabled")
@@ -151,15 +154,24 @@ else ()
151154
message (" WAMR AOT disabled")
152155
endif ()
153156
if (WAMR_BUILD_JIT EQUAL 1)
157+
add_definitions("-DWASM_ENABLE_JIT=1")
154158
if (WAMR_BUILD_LAZY_JIT EQUAL 1)
155-
message (" WAMR LLVM Orc Lazy JIT enabled")
159+
message (" WAMR LLVM ORC JIT enabled with Lazy Compilation")
160+
add_definitions("-DWASM_ENABLE_LAZY_JIT=1")
156161
else ()
157-
message (" WAMR LLVM MC JIT enabled")
162+
message (" WAMR LLVM ORC JIT enabled with Eager Compilation")
163+
add_definitions("-DWASM_ENABLE_LAZY_JIT=0")
158164
endif ()
159-
elseif (WAMR_BUILD_FAST_JIT EQUAL 1)
165+
else ()
166+
message (" WAMR LLVM ORC JIT disabled")
167+
add_definitions("-DWASM_ENABLE_JIT=0")
168+
endif ()
169+
if (WAMR_BUILD_FAST_JIT EQUAL 1)
160170
message (" WAMR Fast JIT enabled")
171+
add_definitions("-DWASM_ENABLE_FAST_JIT=1")
161172
else ()
162-
message (" WAMR JIT disabled")
173+
message (" WAMR Fast JIT disabled")
174+
add_definitions("-DWASM_ENABLE_FAST_JIT=0")
163175
endif ()
164176
if (WAMR_BUILD_LIBC_BUILTIN EQUAL 1)
165177
message (" Libc builtin enabled")

core/config.h

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@
8181
#define WASM_ENABLE_LAZY_JIT 0
8282
#endif
8383

84-
#ifndef WASM_LAZY_JIT_COMPILE_THREAD_NUM
85-
#define WASM_LAZY_JIT_COMPILE_THREAD_NUM 4
84+
#ifndef WASM_ORC_JIT_COMPILE_THREAD_NUM
85+
#define WASM_ORC_JIT_COMPILE_THREAD_NUM 4
8686
#endif
8787

8888
#if (WASM_ENABLE_AOT == 0) && (WASM_ENABLE_JIT != 0)
89-
/* LazyJIT or MCJIT can only be enabled when AOT is enabled */
89+
/* LLVM JIT can only be enabled when AOT is enabled */
9090
#undef WASM_ENABLE_JIT
9191
#define WASM_ENABLE_JIT 0
9292

@@ -110,14 +110,6 @@
110110
#define WASM_ENABLE_WAMR_COMPILER 0
111111
#endif
112112

113-
#if WASM_ENABLE_WAMR_COMPILER != 0
114-
#ifndef WASM_ENABLE_LLVM_LEGACY_PM
115-
/* Whether to use LLVM legacy pass manager when building wamrc,
116-
by default it is disabled and LLVM new pass manager is used */
117-
#define WASM_ENABLE_LLVM_LEGACY_PM 0
118-
#endif
119-
#endif
120-
121113
#ifndef WASM_ENABLE_LIBC_BUILTIN
122114
#define WASM_ENABLE_LIBC_BUILTIN 0
123115
#endif

0 commit comments

Comments
 (0)