Skip to content

Commit 3a84002

Browse files
darindvtrifonov
authored andcommitted
Upgrade V8 to 7.2.502.25
1 parent 1ace71e commit 3a84002

108 files changed

Lines changed: 73240 additions & 8513 deletions

File tree

Some content is hidden

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

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
env:
22
global:
33
- NODE_VERSION=6.11.1
4-
- NDK_VERSION=r18b
4+
- NDK_VERSION=r19
55
- DATE=$(date +%Y-%m-%d)
66
- PACKAGE_VERSION=next-$DATE-$TRAVIS_BUILD_NUMBER
77
- EMULATOR_API_LEVEL=21
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"v8Version": "7.1.302.32"
2+
"v8Version": "7.2.502.25",
3+
"mksnapshotParams": "--profile_deserialization --turbo_instruction_scheduling"
34
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
"version": "4.10.2",
1414
"android": "3.3.1"
1515
},
16-
"android_ndk_version": "18b"
16+
"android_ndk_version": "19"
1717
}
-424 KB
Binary file not shown.
-604 KB
Binary file not shown.
-413 KB
Binary file not shown.

test-app/runtime/CMakeLists.txt

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,17 @@ else ()
2222
set(ARCH_INCLUDE_DIR "arm-linux-androideabi")
2323
endif ()
2424

25-
set(COMMON_CMAKE_ARGUMENTS "-std=c++11 -Werror -Wno-unused-result -mstackrealign -fexceptions -fno-builtin-stpcpy -fno-rtti")
25+
set(COMMON_CMAKE_ARGUMENTS "-std=c++11 -stdlib=libc++ -Werror -Wno-unused-result -mstackrealign -fexceptions -fno-builtin-stpcpy -fno-rtti")
26+
27+
# AOSP has switched to using LLD by default and the NDK will use it by default in the next release.
28+
# BFD and Gold will be removed once LLD has been through a release cycle with no major unresolved issues (estimated r21)
29+
# Note: lld does not currently work on Windows: https://github.com/android-ndk/ndk/issues/888
30+
if (NOT CMAKE_HOST_SYSTEM_NAME MATCHES "Windows")
31+
MESSAGE(STATUS "## Using LLD linker")
32+
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=lld")
33+
else ()
34+
MESSAGE(STATUS "## Using default linker")
35+
endif ()
2636

2737
# Command info: https://cmake.org/cmake/help/v3.4/command/include_directories.html
2838
include_directories(
@@ -32,6 +42,8 @@ include_directories(
3242

3343
# hack to find some libraries from the ndk
3444
${ANDROID_NDK_ROOT}/sysroot/usr/include/${ARCH_INCLUDE_DIR}/
45+
46+
src/main/libs/${ANDROID_ABI}/include
3547
)
3648

3749
if (OPTIMIZED_BUILD OR OPTIMIZED_WITH_INSPECTOR_BUILD)
@@ -76,6 +88,7 @@ if (NOT OPTIMIZED_BUILD OR OPTIMIZED_WITH_INSPECTOR_BUILD)
7688
src/main/cpp/v8_inspector/src/inspector/v8-overlay-agent-impl.cpp
7789
src/main/cpp/v8_inspector/src/inspector/v8-page-agent-impl.cpp
7890

91+
src/main/cpp/v8_inspector/src/inspector/custom-preview.cc
7992
src/main/cpp/v8_inspector/src/inspector/injected-script.cc
8093
src/main/cpp/v8_inspector/src/inspector/inspected-context.cc
8194
src/main/cpp/v8_inspector/src/inspector/remote-object-id.cc
@@ -88,18 +101,16 @@ if (NOT OPTIMIZED_BUILD OR OPTIMIZED_WITH_INSPECTOR_BUILD)
88101
src/main/cpp/v8_inspector/src/inspector/v8-debugger.cc
89102
src/main/cpp/v8_inspector/src/inspector/v8-debugger-agent-impl.cc
90103
src/main/cpp/v8_inspector/src/inspector/v8-debugger-script.cc
91-
src/main/cpp/v8_inspector/src/inspector/v8-function-call.cc
92104
src/main/cpp/v8_inspector/src/inspector/v8-heap-profiler-agent-impl.cc
93-
src/main/cpp/v8_inspector/src/inspector/v8-injected-script-host.cc
94105
src/main/cpp/v8_inspector/src/inspector/v8-inspector-impl.cc
95106
src/main/cpp/v8_inspector/src/inspector/v8-inspector-session-impl.cc
96-
src/main/cpp/v8_inspector/src/inspector/v8-internal-value-type.cc
97107
src/main/cpp/v8_inspector/src/inspector/v8-profiler-agent-impl.cc
98108
src/main/cpp/v8_inspector/src/inspector/v8-regex.cc
99109
src/main/cpp/v8_inspector/src/inspector/v8-runtime-agent-impl.cc
100110
src/main/cpp/v8_inspector/src/inspector/v8-schema-agent-impl.cc
101111
src/main/cpp/v8_inspector/src/inspector/v8-stack-trace-impl.cc
102112
src/main/cpp/v8_inspector/src/inspector/v8-value-utils.cc
113+
src/main/cpp/v8_inspector/src/inspector/value-mirror.cc
103114
src/main/cpp/v8_inspector/src/inspector/wasm-translation.cc
104115
)
105116
else ()
@@ -162,10 +173,19 @@ add_library(
162173
${INSPECTOR_SOURCES}
163174
)
164175

176+
set(NATIVES_BLOB_INCLUDE_DIRECTORIES ${PROJECT_SOURCE_DIR}/src/main/libs/${ANDROID_ABI}/include)
177+
165178
if (OPTIMIZED_BUILD OR OPTIMIZED_WITH_INSPECTOR_BUILD)
166-
set_target_properties(NativeScript PROPERTIES LINK_FLAGS -Wl,--allow-multiple-definition -Wl,--exclude-libs=ALL -Wl,--gc-sections)
179+
set_target_properties(
180+
NativeScript
181+
PROPERTIES LINK_FLAGS -Wl,--allow-multiple-definition -Wl,--exclude-libs=ALL -Wl,--gc-sections
182+
INTERFACE_INCLUDE_DIRECTORIES NATIVES_BLOB_INCLUDE_DIRECTORIES
183+
)
167184
else ()
168-
set_target_properties(NativeScript PROPERTIES LINK_FLAGS -Wl,--allow-multiple-definition)
185+
set_target_properties(
186+
NativeScript PROPERTIES LINK_FLAGS -Wl,--allow-multiple-definition
187+
INTERFACE_INCLUDE_DIRECTORIES NATIVES_BLOB_INCLUDE_DIRECTORIES
188+
)
169189
endif ()
170190

171191
MESSAGE(STATUS "# General cmake Info")
@@ -180,7 +200,7 @@ MESSAGE(STATUS "# CMAKE_CXX_FLAGS: " ${CMAKE_CXX_FLAGS})
180200
# linking v8 and inspector libraries to runtime(NativeScript library)
181201
target_link_libraries(NativeScript ${PROJECT_SOURCE_DIR}/src/main/libs/${ANDROID_ABI}/libzip.a)
182202
target_link_libraries(NativeScript ${PROJECT_SOURCE_DIR}/src/main/libs/${ANDROID_ABI}/libv8_base.a)
183-
target_link_libraries(NativeScript ${PROJECT_SOURCE_DIR}/src/main/libs/${ANDROID_ABI}/libv8_snapshot.a)
203+
target_link_libraries(NativeScript ${PROJECT_SOURCE_DIR}/src/main/libs/${ANDROID_ABI}/libv8_external_snapshot.a)
184204
target_link_libraries(NativeScript ${PROJECT_SOURCE_DIR}/src/main/libs/${ANDROID_ABI}/libv8_init.a)
185205
target_link_libraries(NativeScript ${PROJECT_SOURCE_DIR}/src/main/libs/${ANDROID_ABI}/libv8_initializers.a)
186206
target_link_libraries(NativeScript ${PROJECT_SOURCE_DIR}/src/main/libs/${ANDROID_ABI}/libv8_libplatform.a)
@@ -194,10 +214,8 @@ target_link_libraries(NativeScript ${PROJECT_SOURCE_DIR}/src/main/libs/${ANDROID
194214
# you want to add. CMake verifies that the library exists before
195215
# completing its build.
196216
find_library(system-log log)
197-
find_library(system-android android)
198-
find_library(system-dl dl)
199217
find_library(system-z z)
200218

201219
# Command info: https://cmake.org/cmake/help/v3.4/command/target_link_libraries.html
202220
# Specifies libraries CMake should link to your target library.
203-
target_link_libraries(NativeScript ${system-log} ${system-android} ${system-dl} ${system-z})
221+
target_link_libraries(NativeScript ${system-log} ${system-z})

test-app/runtime/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ android {
3737

3838
defaultConfig {
3939
minSdkVersion 17
40-
targetSdkVersion 26
40+
targetSdkVersion 28
4141
versionCode 1
4242
versionName "1.0"
4343

test-app/runtime/src/main/cpp/Runtime.cpp

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,11 @@ Isolate* Runtime::PrepareV8Runtime(const string& filesPath, const string& native
451451

452452
m_startupData = new StartupData();
453453

454+
auto* nativesBlobStartupData = new StartupData();
455+
nativesBlobStartupData->data = reinterpret_cast<const char*>(&natives_blob_bin[0]);
456+
nativesBlobStartupData->raw_size = natives_blob_bin_len;
457+
V8::SetNativesDataBlob(nativesBlobStartupData);
458+
454459
void* snapshotPtr = nullptr;
455460
string snapshotPath;
456461

@@ -460,7 +465,7 @@ Isolate* Runtime::PrepareV8Runtime(const string& filesPath, const string& native
460465
} else {
461466
// If device is running on android Sdk 17
462467
// dlopen reads relative path to dynamic libraries or reads from folder different than the nativeLibsDirs on the android device
463-
string snapshotPath = nativeLibDir + "/libsnapshot.so";
468+
snapshotPath = nativeLibDir + "/libsnapshot.so";
464469
}
465470

466471
snapshotPtr = dlopen(snapshotPath.c_str(), RTLD_LAZY | RTLD_LOCAL);
@@ -473,18 +478,19 @@ Isolate* Runtime::PrepareV8Runtime(const string& filesPath, const string& native
473478
}
474479
}
475480

481+
bool isCustomSnapshotFound = false;
476482
if (snapshotPtr) {
477483
m_startupData->data = static_cast<const char*>(dlsym(snapshotPtr, "TNSSnapshot_blob"));
478484
m_startupData->raw_size = *static_cast<const unsigned int*>(dlsym(snapshotPtr, "TNSSnapshot_blob_len"));
479-
create_params.snapshot_blob = m_startupData;
485+
V8::SetSnapshotDataBlob(m_startupData);
486+
isCustomSnapshotFound = true;
480487
DEBUG_WRITE_FORCE("Snapshot library read %p (%dB).", m_startupData->data, m_startupData->raw_size);
481488
} else if (!Constants::V8_HEAP_SNAPSHOT_BLOB.empty() || !Constants::V8_HEAP_SNAPSHOT_SCRIPT.empty()) {
482489
DEBUG_WRITE_FORCE("Snapshot enabled.");
483490

484-
string snapshotPath;
485491
bool saveSnapshot = true;
486492
// we have a precompiled snapshot blob provided - try to load it directly
487-
if (Constants::V8_HEAP_SNAPSHOT_BLOB.size() > 0) {
493+
if (!Constants::V8_HEAP_SNAPSHOT_BLOB.empty()) {
488494
snapshotPath = Constants::V8_HEAP_SNAPSHOT_BLOB;
489495
saveSnapshot = false;
490496
} else {
@@ -495,8 +501,8 @@ Isolate* Runtime::PrepareV8Runtime(const string& filesPath, const string& native
495501
m_heapSnapshotBlob = new MemoryMappedFile(MemoryMappedFile::Open(snapshotPath.c_str()));
496502
m_startupData->data = static_cast<const char*>(m_heapSnapshotBlob->memory);
497503
m_startupData->raw_size = m_heapSnapshotBlob->size;
498-
create_params.snapshot_blob = m_startupData;
499-
504+
V8::SetSnapshotDataBlob(m_startupData);
505+
isCustomSnapshotFound = true;
500506
DEBUG_WRITE_FORCE("Snapshot read %s (%zuB).", snapshotPath.c_str(), m_heapSnapshotBlob->size);
501507
} else if (!saveSnapshot) {
502508
DEBUG_WRITE_FORCE("No snapshot file found at %s", snapshotPath.c_str());
@@ -509,7 +515,7 @@ Isolate* Runtime::PrepareV8Runtime(const string& filesPath, const string& native
509515
string customScript;
510516

511517
// check for custom script to include in the snapshot
512-
if (Constants::V8_HEAP_SNAPSHOT_SCRIPT.size() > 0 && File::Exists(Constants::V8_HEAP_SNAPSHOT_SCRIPT)) {
518+
if (!Constants::V8_HEAP_SNAPSHOT_SCRIPT.empty() && File::Exists(Constants::V8_HEAP_SNAPSHOT_SCRIPT)) {
513519
customScript = ReadFileText(Constants::V8_HEAP_SNAPSHOT_SCRIPT);
514520
}
515521

@@ -530,10 +536,19 @@ Isolate* Runtime::PrepareV8Runtime(const string& filesPath, const string& native
530536
}
531537
}
532538

533-
create_params.snapshot_blob = m_startupData;
539+
V8::SetSnapshotDataBlob(m_startupData);
540+
isCustomSnapshotFound = true;
534541
}
535542
}
536543

544+
if (!isCustomSnapshotFound) {
545+
// Load V8's built-in snapshot
546+
auto* snapshotBlobStartupData = new StartupData();
547+
snapshotBlobStartupData->data = reinterpret_cast<const char*>(&snapshot_blob_bin[0]);
548+
snapshotBlobStartupData->raw_size = snapshot_blob_bin_len;
549+
V8::SetSnapshotDataBlob(snapshotBlobStartupData);
550+
}
551+
537552
/*
538553
* Setup the V8Platform only once per process - once for the application lifetime
539554
* Don't execute again if main thread has already been initialized
@@ -552,7 +567,7 @@ Isolate* Runtime::PrepareV8Runtime(const string& filesPath, const string& native
552567
m_objectManager->SetInstanceIsolate(isolate);
553568

554569
// Sets a structure with v8 String constants on the isolate object at slot 1
555-
V8StringConstants::PerIsolateV8Constants* consts = new V8StringConstants::PerIsolateV8Constants(isolate);
570+
auto consts = new V8StringConstants::PerIsolateV8Constants(isolate);
556571
isolate->SetData((uint32_t)Runtime::IsolateData::CONSTANTS, consts);
557572

558573
V8::SetFlagsFromString(Constants::V8_STARTUP_FLAGS.c_str(), Constants::V8_STARTUP_FLAGS.size());

test-app/runtime/src/main/cpp/Runtime.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#include "ModuleInternal.h"
1212
#include "File.h"
1313
#include <mutex>
14+
#include <natives_blob.h>
15+
#include <snapshot_blob.h>
1416

1517
jobject ConvertJsValueToJavaObject(tns::JEnv& env, const v8::Local<v8::Value>& value, int classReturnType);
1618

0 commit comments

Comments
 (0)