-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade to v8 10.0.139.9 with tools support (#29)
- upgrade to v8 10.0.139.9 - add mkcodecache tools - archive mksnapshot tools
- Loading branch information
Showing
33 changed files
with
854 additions
and
238 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: v8-android tools builder for macos host | ||
|
||
on: [push] | ||
|
||
env: | ||
CACHE_KEY_SUFFIX: v2 | ||
|
||
jobs: | ||
macos: | ||
runs-on: macOS-latest | ||
|
||
strategy: | ||
matrix: | ||
variant: [intl, nointl, jit-intl, jit-nointl] | ||
|
||
env: | ||
NO_INTL: ${{ contains(matrix.variant, 'nointl') }} | ||
NO_JIT: ${{ !contains(matrix.variant, 'jit') }} | ||
TOOLS_ONLY: true | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Export settings from npm package | ||
run: npm run export_npm_env | ||
|
||
- name: Setup V8 build environment | ||
run: | | ||
brew install coreutils | ||
scripts/setup.sh -r ${{ env.V8_VERSION }} macos_android | ||
- name: Patch V8 | ||
run: scripts/patch.sh macos_android | ||
|
||
# - name: Build arm | ||
# run: | | ||
# scripts/build.sh macos_android arm | ||
# | ||
# - name: Build x86 | ||
# run: | | ||
# scripts/build.sh macos_android x86 | ||
|
||
- name: Build arm64 | ||
run: | | ||
scripts/build.sh macos_android arm64 | ||
- name: Build x64 | ||
run: | | ||
scripts/build.sh macos_android x64 | ||
- name: Archive | ||
run: | | ||
scripts/archive.sh macos_android | ||
tar -cvf dist.tar dist | ||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: macos-tools-${{ matrix.variant }} | ||
path: dist.tar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -448,3 +448,9 @@ gradle-app.setting | |
.cipd/* | ||
.gclient | ||
.gclient_entries | ||
|
||
# publish archives | ||
mkcodecache | ||
mksnapshot | ||
*.bin | ||
*.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"python.formatting.provider": "black" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
// Copyright 2006-2008 the V8 project authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "include/libplatform/libplatform.h" | ||
#include "include/v8-initialization.h" | ||
#include "include/v8-message.h" | ||
#include "include/v8-script.h" | ||
#include "src/base/platform/platform.h" | ||
|
||
#include <chrono> | ||
|
||
namespace v8 { | ||
|
||
namespace { | ||
|
||
// Reads a file into a v8 string. | ||
Local<String> ReadFile(Isolate* isolate, const char* name, | ||
bool should_throw) { | ||
std::unique_ptr<base::OS::MemoryMappedFile> file( | ||
base::OS::MemoryMappedFile::open( | ||
name, base::OS::MemoryMappedFile::FileMode::kReadOnly)); | ||
if (!file) { | ||
if (should_throw) { | ||
std::ostringstream oss; | ||
oss << "Error loading file: \"" << name << '"'; | ||
isolate->ThrowError( | ||
v8::String::NewFromUtf8(isolate, oss.str().c_str()).ToLocalChecked()); | ||
} | ||
return Local<String>(); | ||
} | ||
|
||
int size = static_cast<int>(file->size()); | ||
char* chars = static_cast<char*>(file->memory()); | ||
Local<String> result = String::NewFromUtf8(isolate, chars, NewStringType::kNormal, size) | ||
.ToLocalChecked(); | ||
return result; | ||
} | ||
|
||
} // namespace | ||
|
||
} // namespace v8 | ||
|
||
int main(int argc, char** argv) { | ||
if (argc < 2) { | ||
::printf("Usage: %s script_file\n", argv[0]); | ||
exit(1); | ||
} | ||
|
||
v8::base::EnsureConsoleOutput(); | ||
v8::V8::InitializeICUDefaultLocation(argv[0]); | ||
std::unique_ptr<v8::Platform> platform = v8::platform::NewDefaultPlatform(); | ||
v8::V8::InitializePlatform(platform.get()); | ||
v8::V8::SetFlagsFromString("--nolazy"); | ||
v8::V8::Initialize(); | ||
v8::V8::InitializeExternalStartupData(argv[0]); | ||
|
||
v8::Isolate::CreateParams createParams; | ||
auto arrayBufferAllocator = | ||
std::unique_ptr<v8::ArrayBuffer::Allocator>(v8::ArrayBuffer::Allocator::NewDefaultAllocator()); | ||
createParams.array_buffer_allocator = arrayBufferAllocator.get(); | ||
v8::Isolate* isolate = v8::Isolate::New(createParams); | ||
v8::HandleScope handle_scope(isolate); | ||
|
||
|
||
v8::Local<v8::String> source = v8::ReadFile(isolate, argv[1], false); | ||
|
||
if (argc == 2) { | ||
v8::ScriptOrigin origin = v8::ScriptOrigin(isolate, v8::String::NewFromUtf8Literal(isolate, "(mkcodecache)")); | ||
|
||
v8::ScriptCompiler::Source scriptSource(source, origin); | ||
// v8::Local<v8::UnboundScript> unboundScript = v8::ScriptCompiler::CompileUnboundScript(isolate, &scriptSource, v8::ScriptCompiler::kEagerCompile).ToLocalChecked(); | ||
v8::Local<v8::UnboundScript> unboundScript = v8::ScriptCompiler::CompileUnboundScript(isolate, &scriptSource, v8::ScriptCompiler::kNoCompileOptions).ToLocalChecked(); | ||
v8::ScriptCompiler::CachedData *cachedData = v8::ScriptCompiler::CreateCodeCache(unboundScript); | ||
::printf("cache data size %d\n", cachedData->length); | ||
|
||
FILE* file = v8::base::Fopen("v8codecache.bin", "wb"); | ||
if (file) { | ||
fwrite(cachedData->data, 1, cachedData->length, file); | ||
v8::base::Fclose(file); | ||
} | ||
} else { | ||
v8::ScriptOrigin origin = v8::ScriptOrigin(isolate, v8::String::NewFromUtf8Literal(isolate, "(mkcodecache)")); | ||
std::unique_ptr<v8::ScriptCompiler::CachedData> cachedData; | ||
FILE* file = v8::base::Fopen("v8codecache.bin", "rb"); | ||
if (file) { | ||
fseek(file, 0, SEEK_END); | ||
size_t size = ftell(file); | ||
uint8_t *buffer = new uint8_t[size]; | ||
rewind(file); | ||
|
||
if (fread(buffer, 1, size, file) != size) { | ||
::printf("ooxx fread error\n"); | ||
} | ||
v8::base::Fclose(file); | ||
|
||
cachedData = std::make_unique<v8::ScriptCompiler::CachedData>( | ||
buffer, | ||
static_cast<int>(size), | ||
v8::ScriptCompiler::CachedData::BufferPolicy::BufferOwned); | ||
} | ||
|
||
auto begin = std::chrono::high_resolution_clock::now(); | ||
|
||
v8::Local<v8::Context> context = v8::Context::New(isolate); | ||
v8::Context::Scope context_scope(context); | ||
|
||
v8::ScriptCompiler::CachedData *cachedDataPtr = cachedData.release(); | ||
v8::ScriptCompiler::Source scriptSource(source, origin, cachedDataPtr); | ||
// v8::ScriptCompiler::Source scriptSource(source, origin, nullptr); | ||
v8::Local<v8::Script> compiledScript; | ||
if (!v8::ScriptCompiler::Compile(context, &scriptSource, v8::ScriptCompiler::kConsumeCodeCache).ToLocal(&compiledScript)) { | ||
// if (!v8::ScriptCompiler::Compile(context, &scriptSource, v8::ScriptCompiler::kNoCompileOptions).ToLocal(&compiledScript)) { | ||
::printf("ooxx error\n"); | ||
} | ||
|
||
if (cachedDataPtr->rejected) { | ||
::printf("ooxx rejected\n"); | ||
} | ||
|
||
auto end = std::chrono::high_resolution_clock::now(); | ||
auto duration = std::chrono::duration_cast<std::chrono::microseconds>(end - begin); | ||
::printf("ooxx compile time: %lld\n", static_cast<long long int>(duration.count())); | ||
} | ||
|
||
v8::V8::Dispose(); | ||
v8::V8::DisposePlatform(); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
{ | ||
"private": true, | ||
"version": "9.93.0", | ||
"version": "10.100.0", | ||
"workspaces": [ | ||
"packages/*" | ||
], | ||
"scripts": { | ||
"clean": "rm -rf dist; rm -rf build; rm -rf v8/out.v8.*", | ||
"export_npm_env": "./scripts/export_npm_env.sh", | ||
"setup": "bash -c '. ./scripts/export_npm_env.sh && ./scripts/setup.sh android'", | ||
"start": "bash -c '. ./scripts/export_npm_env.sh && ./scripts/start.sh android'", | ||
"setup_mksnapshot": "bash -c '. ./scripts/export_npm_env.sh && MKSNAPSHOT_ONLY=1 ./scripts/setup.sh android'", | ||
"start_mksnapshot": "bash -c '. ./scripts/export_npm_env.sh && MKSNAPSHOT_ONLY=1 ./scripts/start.sh android'", | ||
"setup_ios": "bash -c '. ./scripts/export_npm_env.sh && ./scripts/setup.sh ios'", | ||
"start_ios": "bash -c '. ./scripts/export_npm_env.sh && ./scripts/start.sh ios'" | ||
"setup_macos_android": "bash -c '. ./scripts/export_npm_env.sh && ./scripts/setup.sh macos_android'", | ||
"start": "bash -c '. ./scripts/export_npm_env.sh && ./scripts/start.sh android'", | ||
"start_ios": "bash -c '. ./scripts/export_npm_env.sh && ./scripts/start.sh ios'", | ||
"start_tools_macos_android": "bash -c '. ./scripts/export_npm_env.sh && TOOLS_ONLY=true ./scripts/start.sh macos_android'" | ||
}, | ||
"config": { | ||
"V8": "9.3.345.16" | ||
"V8": "10.0.139.9" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "v8-android-tools-linux", | ||
"version": "10.100.0", | ||
"description": "Tools for v8-android", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/Kudo/v8-android-buildscripts.git", | ||
"directory": "packages/v8-android-tools-linux" | ||
}, | ||
"keywords": [ | ||
"react-native", | ||
"android", | ||
"v8", | ||
"tools" | ||
], | ||
"license": "BSD-2-Clause", | ||
"bugs": { | ||
"url": "https://github.com/Kudo/v8-android-buildscripts/issues" | ||
}, | ||
"homepage": "https://github.com/Kudo/v8-android-buildscripts#readme", | ||
"files": [ | ||
"v8-android*" | ||
] | ||
} |
Oops, something went wrong.