Skip to content

Commit 5a34d86

Browse files
committed
feat: support multiple versions of v8
1 parent d0b8a44 commit 5a34d86

File tree

907 files changed

+132626
-55
lines changed

Some content is hidden

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

907 files changed

+132626
-55
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def pVersion = "no package version was provided by build.gradle build"
3333
def arVersion = "no commit sha was provided by build.gradle build"
3434
def generateRegularRuntimePackage = !project.hasProperty("skipUnoptimized")
3535

36-
def jsEngine = engine ?: 'v8'
36+
def jsEngine = engine ?: 'V8-10'
3737

3838
def DIST_PATH = "$rootDir/dist_${jsEngine.toLowerCase()}"
3939
def TEST_APP_PATH = "$rootDir/test-app"

scripts/build.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ const { spawn } = require('child_process');
77
const path = require('path');
88
const readline = require('readline');
99

10-
const VALID_ENGINES = ['V8', 'QUICKJS', 'HERMES', 'JSC', 'SHERMES', 'PRIMJS'];
11-
const HOST_OBJECTS_SUPPORTED = new Set(['V8', 'QUICKJS', 'PRIMJS']);
10+
const VALID_ENGINES = ['V8-10',"V8-11","V8-13", 'QUICKJS', 'HERMES', 'JSC', 'SHERMES', 'PRIMJS'];
11+
const HOST_OBJECTS_SUPPORTED = new Set(['V8-10','V8-11',"V8-13", 'QUICKJS', 'PRIMJS']);
1212

1313
function parseArgs(argv) {
1414
const opts = {};
@@ -46,9 +46,9 @@ async function interactiveFill(opts) {
4646
if (!opts.engine) {
4747
console.log('Select JS engine:');
4848
VALID_ENGINES.forEach((e, i) => console.log(` ${i + 1}) ${e}`));
49-
const ans = await prompt('Choose number or name', rl, 'V8');
49+
const ans = await prompt('Choose number or name', rl, 'V8-10');
5050
const pick = /^\d+$/.test(ans) ? VALID_ENGINES[Number(ans) - 1] : ans;
51-
opts.engine = VALID_ENGINES.includes(pick) ? pick : 'V8';
51+
opts.engine = VALID_ENGINES.includes(pick) ? pick : 'V8-10';
5252
}
5353

5454
// Only prompt for host objects if the chosen engine supports it

test-app/.idea/caches/deviceStreaming.xml

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Added Properties 54
22
Ignored Properties 2 duplicates.
3-
Added Methods 81322
4-
Ignored Methods 3302 duplicates.
5-
Added Fields 54617
6-
Ignored Fields 16693 duplicates.
3+
Added Methods 81320
4+
Ignored Methods 3300 duplicates.
5+
Added Fields 54615
6+
Ignored Fields 16691 duplicates.

test-app/runtime/CMakeLists.txt

Lines changed: 85 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,23 @@ if (CCACHE_FOUND AND (USE_CCACHE))
1616
MESSAGE(STATUS "## Using CCache when building!")
1717
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
1818
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
19-
endif (CCACHE_FOUND AND (USE_CCACHE))
19+
endif ()
2020

21-
set(COMMON_CMAKE_ARGUMENTS "-std=c++20 -Wno-error -Wno-deprecated-declarations -Wno-unused-result -mstackrealign -fexceptions -fno-builtin-stpcpy -frtti")
21+
set(COMMON_CMAKE_ARGUMENTS "-Wno-error -Wno-deprecated-declarations -Wno-unused-result -mstackrealign -fexceptions -fno-builtin-stpcpy")
2222
set(MI_OVERRIDE OFF)
23+
24+
if (V8_13)
25+
set(COMMON_CMAKE_ARGUMENTS "${COMMON_CMAKE_ARGUMENTS} -std=c++20")
26+
elseif ()
27+
set(COMMON_CMAKE_ARGUMENTS "${COMMON_CMAKE_ARGUMENTS} -std=c++17")
28+
endif ()
29+
30+
if (SHERMES)
31+
set(COMMON_CMAKE_ARGUMENTS "${COMMON_CMAKE_ARGUMENTS} -frtti")
32+
else ()
33+
set(COMMON_CMAKE_ARGUMENTS "${COMMON_CMAKE_ARGUMENTS} -fno-rtti")
34+
endif ()
35+
2336
# AOSP has switched to using LLD by default and the NDK will use it by default in the next release.
2437
# BFD and Gold will be removed once LLD has been through a release cycle with no major unresolved issues (estimated r21)
2538
# Note: lld does not currently work on Windows: https://github.com/android-ndk/ndk/issues/888
@@ -78,7 +91,7 @@ file(GLOB_RECURSE RUNTIME_FILES
7891
"${PROJECT_SOURCE_DIR}/src/main/cpp/runtime/**/*.cpp"
7992
)
8093

81-
file (GLOB_RECURSE MODULE_FILES
94+
file(GLOB_RECURSE MODULE_FILES
8295
"${PROJECT_SOURCE_DIR}/src/main/cpp/modules/*.cpp"
8396
"${PROJECT_SOURCE_DIR}/src/main/cpp/modules/**/*.cpp"
8497
)
@@ -129,24 +142,24 @@ endif ()
129142

130143
if (HERMES)
131144
include_directories(
132-
src/main/cpp/napi/hermes
133-
src/main/cpp/napi/hermes/include
134-
src/main/cpp/napi/common
145+
src/main/cpp/napi/hermes
146+
src/main/cpp/napi/hermes/include
147+
src/main/cpp/napi/common
135148
)
136149
set(SOURCES ${SOURCES}
137-
src/main/cpp/napi/hermes/jsr.cpp
138-
)
150+
src/main/cpp/napi/hermes/jsr.cpp
151+
)
139152
endif ()
140153

141154
if (SHERMES)
142155
include_directories(
143-
src/main/cpp/napi/hermes
144-
src/main/cpp/napi/hermes/include_shermes
145-
src/main/cpp/napi/common
156+
src/main/cpp/napi/hermes
157+
src/main/cpp/napi/hermes/include_shermes
158+
src/main/cpp/napi/common
146159
)
147160
set(SOURCES ${SOURCES}
148-
src/main/cpp/napi/hermes/jsr.cpp
149-
)
161+
src/main/cpp/napi/hermes/jsr.cpp
162+
)
150163
endif ()
151164

152165
if (JSC)
@@ -162,16 +175,37 @@ if (JSC)
162175
endif ()
163176

164177
if (V8)
165-
include_directories(
166-
src/main/cpp/napi/v8
167-
src/main/cpp/napi/v8/include
168-
src/main/cpp/napi/common
169-
src/main/cpp/napi/v8/v8_inspector
170-
)
178+
if (V8_10)
179+
include_directories(
180+
src/main/cpp/napi/v8
181+
src/main/cpp/napi/v8-10
182+
src/main/cpp/napi/v8-10/include
183+
src/main/cpp/napi/common
184+
src/main/cpp/napi/v8/v8_inspector
185+
src/main/cpp/napi/v8-10/v8_inspector
186+
)
187+
elseif (V8_11)
188+
include_directories(
189+
src/main/cpp/napi/v8
190+
src/main/cpp/napi/v8-11
191+
src/main/cpp/napi/v8-11/include
192+
src/main/cpp/napi/common
193+
src/main/cpp/napi/v8/v8_inspector
194+
src/main/cpp/napi/v8-11/v8_inspector
195+
)
196+
else ()
197+
include_directories(
198+
src/main/cpp/napi/v8
199+
src/main/cpp/napi/v8-13
200+
src/main/cpp/napi/v8-13/include
201+
src/main/cpp/napi/common
202+
src/main/cpp/napi/v8/v8_inspector
203+
src/main/cpp/napi/v8-13/v8_inspector
204+
)
205+
endif ()
171206

172207
if (NOT OPTIMIZED_BUILD OR OPTIMIZED_WITH_INSPECTOR_BUILD)
173208
add_definitions(-DAPPLICATION_IN_DEBUG)
174-
# Debug builds will include the V8 inspector sources
175209
set(
176210
SOURCES
177211
${SOURCES}
@@ -186,15 +220,18 @@ if (V8)
186220
src/main/cpp/napi/v8/SimpleAllocator.cpp
187221
)
188222

189-
set(COMMON_CMAKE_ARGUMENTS "${COMMON_CMAKE_ARGUMENTS} -DV8_ENABLE_REGEXP_INTERPRETER_THREADED_DISPATCH -DV8_EMBEDDED_BUILTINS")
190-
# -DV8_31BIT_SMIS_ON_64BIT_ARCH
191-
# if("${ANDROID_ABI}" MATCHES "arm64-v8a$" OR "${ANDROID_ABI}" MATCHES "x86_64$")
192-
# # Enable pointer compression on 64 bit platforms
193-
# set(COMMON_CMAKE_ARGUMENTS "${COMMON_CMAKE_ARGUMENTS} -DV8_COMPRESS_POINTERS -DV8_ENABLE_SANDBOX")
194-
# message(STATUS "V8 pointer compression enabled for ${ANDROID_ABI}")
195-
# else()
196-
# message(STATUS "V8 pointer compression not enabled for ${ANDROID_ABI}")
197-
# endif()
223+
224+
if (V8_10)
225+
set(COMMON_CMAKE_ARGUMENTS "${COMMON_CMAKE_ARGUMENTS} -DV8_31BIT_SMIS_ON_64BIT_ARCH -DV8_31BIT_SMIS_ON_64BIT_ARCH -DV8_ENABLE_REGEXP_INTERPRETER_THREADED_DISPATCH -DV8_EMBEDDED_BUILTINS")
226+
# Enable pointer compression on 64 bit platforms
227+
if ("${ANDROID_ABI}" MATCHES "arm64-v8a$" OR "${ANDROID_ABI}" MATCHES "x86_64$")
228+
set(COMMON_CMAKE_ARGUMENTS "${COMMON_CMAKE_ARGUMENTS} -DV8_COMPRESS_POINTERS")
229+
endif ()
230+
else ()
231+
set(COMMON_CMAKE_ARGUMENTS "${COMMON_CMAKE_ARGUMENTS} -DV8_ENABLE_REGEXP_INTERPRETER_THREADED_DISPATCH -DV8_EMBEDDED_BUILTINS")
232+
endif ()
233+
234+
198235
endif ()
199236

200237

@@ -228,8 +265,8 @@ else ()
228265
NativeScript
229266
PROPERTIES LINK_FLAGS -Wl,--allow-multiple-definition
230267
)
231-
# target_compile_options(NativeScript PUBLIC -fsanitize=hwaddress -fno-omit-frame-pointer)
232-
# target_link_options(NativeScript PUBLIC -fsanitize=hwaddress)
268+
# target_compile_options(NativeScript PUBLIC -fsanitize=hwaddress -fno-omit-frame-pointer)
269+
# target_link_options(NativeScript PUBLIC -fsanitize=hwaddress)
233270
endif ()
234271

235272
MESSAGE(STATUS "# General cmake Info")
@@ -264,10 +301,24 @@ if (JSC)
264301
endif ()
265302

266303
if (V8)
267-
target_link_libraries(NativeScript ${PROJECT_SOURCE_DIR}/src/main/libs/v8/${ANDROID_ABI}/libv8_monolith.a)
268304
add_compile_definitions(NativeScript, PRIVATE __V8__)
269305
endif ()
270306

307+
if (V8_10)
308+
target_link_libraries(NativeScript ${PROJECT_SOURCE_DIR}/src/main/libs/v8-10/${ANDROID_ABI}/libv8_monolith.a)
309+
add_compile_definitions(NativeScript, PRIVATE __V8_10__)
310+
endif ()
311+
312+
if (V8_11)
313+
target_link_libraries(NativeScript ${PROJECT_SOURCE_DIR}/src/main/libs/v8-11/${ANDROID_ABI}/libv8_monolith.a)
314+
add_compile_definitions(NativeScript, PRIVATE __V8_11__)
315+
endif ()
316+
317+
if (V8_13)
318+
target_link_libraries(NativeScript ${PROJECT_SOURCE_DIR}/src/main/libs/v8-13/${ANDROID_ABI}/libv8_monolith.a)
319+
add_compile_definitions(NativeScript, PRIVATE __V8_13__)
320+
endif ()
321+
271322
if (PRIMJS)
272323
# target_link_libraries(NativeScript ${PROJECT_SOURCE_DIR}/src/main/libs/primjs/${ANDROID_ABI}/libnapi.so)
273324
target_link_libraries(NativeScript ${PROJECT_SOURCE_DIR}/src/main/libs/primjs/${ANDROID_ABI}/libquick.so)
@@ -283,11 +334,11 @@ endif ()
283334

284335
if (USE_HOST_OBJECTS)
285336
add_compile_definitions(NativeScript, PRIVATE USE_HOST_OBJECT)
286-
endif()
337+
endif ()
287338

288339
if (IS_NAPI_MODULE)
289340
add_compile_definitions(NativeScript, PRIVATE IS_NAPI_MODULE)
290-
endif()
341+
endif ()
291342

292343
# if("${ANDROID_ABI}" MATCHES "armeabi-v7a$" OR "${ANDROID_ABI}" MATCHES "x86$")
293344
# # On API Level 19 and lower we need to link with android_support

test-app/runtime/build.gradle

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
apply plugin: 'com.android.library'
22

3-
// can be: "V8", "JSC", "HERMES", "QUICKJS", "SHERMES", "PRIMJS"
3+
// can be: "V8-11", "V8-10","V8-13", "JSC", "HERMES", "QUICKJS", "SHERMES", "PRIMJS"
44

5-
def jsEngine = "V8"
5+
def jsEngine = "V8-13"
66
def hasEngine = project.hasProperty("engine")
77
if (hasEngine) {
88
jsEngine = engine
@@ -144,12 +144,24 @@ android {
144144
arguments.add("-DPRIMJS=1")
145145
}else if (jsEngine == "JSC") {
146146
arguments.add("-DJSC=1")
147-
} else if (jsEngine == "V8") {
147+
} else if (jsEngine.contains("V8")) {
148148
arguments.add("-DV8=1")
149+
if (jsEngine == "V8-10") {
150+
arguments.add("-DV8_10=1")
151+
} else if (jsEngine == "V8-11") {
152+
arguments.add("-DV8_11=1")
153+
} else {
154+
arguments.add("-DV8_13=1")
155+
}
149156
}
150157

151158
// arguments "-DANDROID_TOOLCHAIN=clang", "-DANDROID_STL=c++_static", "-DANDROID_NDK_ROOT=${NDK_PATH}"
152-
cppFlags "-std=c++20"
159+
160+
if (jsEngine == "V8-13") {
161+
cppFlags "-std=c++20"
162+
} else {
163+
cppFlags "-std=c++17"
164+
}
153165
arguments "-DANDROID_STL=c++_shared",
154166
"-DANDROID_NDK_ROOT=${NDK_PATH}",
155167
"-DCMAKE_ANDROID_NDK=${NDK_PATH}",

test-app/runtime/src/main/cpp/napi/v8/include/APIDesign.md renamed to test-app/runtime/src/main/cpp/napi/v8-10/include/APIDesign.md

File renamed without changes.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
include_rules = [
2+
# v8-inspector-protocol.h depends on generated files under include/inspector.
3+
"+inspector",
4+
"+cppgc/common.h",
5+
# Used by v8-cppgc.h to bridge to cppgc.
6+
"+cppgc/custom-space.h",
7+
"+cppgc/heap-statistics.h",
8+
"+cppgc/internal/write-barrier.h",
9+
"+cppgc/visitor.h",
10+
]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Metadata information for this directory.
2+
#
3+
# For more information on DIR_METADATA files, see:
4+
# https://source.chromium.org/chromium/infra/infra/+/master:go/src/infra/tools/dirmd/README.md
5+
#
6+
# For the schema of this file, see Metadata message:
7+
# https://source.chromium.org/chromium/infra/infra/+/master:go/src/infra/tools/dirmd/proto/dir_metadata.proto
8+
9+
monorail {
10+
component: "Blink>JavaScript>API"
11+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
3+
4+
5+
6+
7+
8+
per-file *DEPS=file:../COMMON_OWNERS
9+
per-file v8-internal.h=file:../COMMON_OWNERS
10+
11+
per-file v8-debug.h=file:../src/debug/OWNERS
12+
13+
per-file js_protocol.pdl=file:../src/inspector/OWNERS
14+
per-file v8-inspector*=file:../src/inspector/OWNERS
15+
per-file v8-inspector*=file:../src/inspector/OWNERS
16+
17+
# Needed by the auto_tag builder
18+
per-file v8-version.h=v8-ci-autoroll-builder@chops-service-accounts.iam.gserviceaccount.com
19+
20+
# For branch updates:
21+
per-file v8-version.h=file:../INFRA_OWNERS
22+
23+

0 commit comments

Comments
 (0)