Skip to content

Commit 5bda320

Browse files
authored
merge: v8 10.3.22 pull request #203 from NativeScript/dev
2 parents 8329e87 + af384af commit 5bda320

File tree

459 files changed

+41448
-59312
lines changed

Some content is hidden

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

459 files changed

+41448
-59312
lines changed

.gitattributes

Whitespace-only changes.

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ node_modules/
4242
package-lock.json
4343
*.pyc
4444
v8
45+
v8_build
4546
.npmrc
4647

4748
llvm/
4849

4950
# v8 build files...
50-
.gclient_entries
51-
.gclient
51+
.gclient*
5252
.cipd/

NativeScript/JSIRuntime.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// NSObject+JSIRuntime.h
3+
// NativeScript
4+
//
5+
// Created by Ammar Ahmed on 12/11/2022.
6+
// Copyright © 2022 Progress. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
#import "v8runtime/V8Runtime.h"
11+
#include "runtime/Runtime.h"
12+
13+
@interface JSIRuntime: NSObject
14+
+(std::shared_ptr<facebook::jsi::Runtime>) runtime;
15+
@end

NativeScript/JSIRuntime.m

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//
2+
// NSObject+JSIRuntime.m
3+
// NativeScript
4+
//
5+
// Created by Ammar Ahmed on 12/11/2022.
6+
// Copyright © 2022 Progress. All rights reserved.
7+
//
8+
9+
#import "JSIRuntime.h"
10+
@implementation JSIRuntime
11+
12+
static std::shared_ptr<facebook::jsi::Runtime> rt;
13+
14+
+(std::shared_ptr<facebook::jsi::Runtime>)runtime {
15+
if (!rt) {
16+
rt = std::make_shared<rnv8::V8Runtime>();
17+
}
18+
return rt;
19+
}
20+
21+
@end

NativeScript/NativeScript-Prefix.pch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef NativeScript_Prefix_pch
22
#define NativeScript_Prefix_pch
33

4-
#define NATIVESCRIPT_VERSION "8.4.1"
4+
#define NATIVESCRIPT_VERSION "8.5.0-beta.6"
55

66
#ifdef DEBUG
77
#define SIZEOF_OFF_T 8

NativeScript/NativeScript.mm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <Foundation/Foundation.h>
22
#include "NativeScript.h"
33
#include "inspector/JsV8InspectorClient.h"
4+
#include "runtime/Console.h"
45
#include "runtime/RuntimeConfig.h"
56
#include "runtime/Helpers.h"
67
#include "runtime/Runtime.h"
@@ -36,14 +37,17 @@ - (instancetype)initWithConfig:(Config*)config {
3637
RuntimeConfig.LogToSystemConsole = [config LogToSystemConsole];
3738

3839
Runtime::Initialize();
40+
runtime_ = nullptr;
3941
runtime_ = std::make_unique<Runtime>();
4042

4143
std::chrono::high_resolution_clock::time_point t1 = std::chrono::high_resolution_clock::now();
4244
Isolate* isolate = runtime_->CreateIsolate();
45+
v8::Locker l(isolate);
4346
runtime_->Init(isolate);
4447
std::chrono::high_resolution_clock::time_point t2 = std::chrono::high_resolution_clock::now();
4548
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(t2 - t1).count();
4649
printf("Runtime initialization took %llims\n", duration);
50+
printf("Runtime V8 Version %s\n", V8::GetVersion());
4751

4852
if (config.IsDebug) {
4953
Isolate::Scope isolate_scope(isolate);
@@ -52,6 +56,7 @@ - (instancetype)initWithConfig:(Config*)config {
5256
inspectorClient->init();
5357
inspectorClient->registerModules();
5458
inspectorClient->connect([config ArgumentsCount], [config Arguments]);
59+
Console::AttachInspectorClient(inspectorClient);
5560
}
5661
}
5762

NativeScript/include/APIDesign.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# The V8 public C++ API
2+
3+
# Overview
4+
5+
The V8 public C++ API aims to support four use cases:
6+
7+
1. Enable applications that embed V8 (called the embedder) to configure and run
8+
one or more instances of V8.
9+
2. Expose ECMAScript-like capabilities to the embedder.
10+
3. Enable the embedder to interact with ECMAScript by exposing API objects.
11+
4. Provide access to the V8 debugger (inspector).
12+
13+
# Configuring and running an instance of V8
14+
15+
V8 requires access to certain OS-level primitives such as the ability to
16+
schedule work on threads, or allocate memory.
17+
18+
The embedder can define how to access those primitives via the v8::Platform
19+
interface. While V8 bundles a basic implementation, embedders are highly
20+
encouraged to implement v8::Platform themselves.
21+
22+
Currently, the v8::ArrayBuffer::Allocator is passed to the v8::Isolate factory
23+
method, however, conceptually it should also be part of the v8::Platform since
24+
all instances of V8 should share one allocator.
25+
26+
Once the v8::Platform is configured, an v8::Isolate can be created. All
27+
further interactions with V8 should explicitly reference the v8::Isolate they
28+
refer to. All API methods should eventually take an v8::Isolate parameter.
29+
30+
When a given instance of V8 is no longer needed, it can be destroyed by
31+
disposing the respective v8::Isolate. If the embedder wishes to free all memory
32+
associated with the v8::Isolate, it has to first clear all global handles
33+
associated with that v8::Isolate.
34+
35+
# ECMAScript-like capabilities
36+
37+
In general, the C++ API shouldn't enable capabilities that aren't available to
38+
scripts running in V8. Experience has shown that it's not possible to maintain
39+
such API methods in the long term. However, capabilities also available to
40+
scripts, i.e., ones that are defined in the ECMAScript standard are there to
41+
stay, and we can safely expose them to embedders.
42+
43+
The C++ API should also be pleasant to use, and not require learning new
44+
paradigms. Similarly to how the API exposed to scripts aims to provide good
45+
ergonomics, we should aim to provide a reasonable developer experience for this
46+
API surface.
47+
48+
ECMAScript makes heavy use of exceptions, however, V8's C++ code doesn't use
49+
C++ exceptions. Therefore, all API methods that can throw exceptions should
50+
indicate so by returning a v8::Maybe&lt;&gt; or v8::MaybeLocal&lt;&gt; result,
51+
and by taking a v8::Local&lt;v8::Context&gt; parameter that indicates in which
52+
context a possible exception should be thrown.
53+
54+
# API objects
55+
56+
V8 allows embedders to define special objects that expose additional
57+
capabilities and APIs to scripts. The most prominent example is exposing the
58+
HTML DOM in Blink. Other examples are e.g. node.js. It is less clear what kind
59+
of capabilities we want to expose via this API surface. As a rule of thumb, we
60+
want to expose operations as defined in the WebIDL and HTML spec: we
61+
assume that those requirements are somewhat stable, and that they are a
62+
superset of the requirements of other embedders including node.js.
63+
64+
Ideally, the API surfaces defined in those specs hook into the ECMAScript spec
65+
which in turn guarantees long-term stability of the API.
66+
67+
# The V8 inspector
68+
69+
All debugging capabilities of V8 should be exposed via the inspector protocol.
70+
The exception to this are profiling features exposed via v8-profiler.h.
71+
Changes to the inspector protocol need to ensure backwards compatibility and
72+
commitment to maintain.

NativeScript/include/DEPS

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+
]

NativeScript/include/DIR_METADATA

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+
}

NativeScript/include/OWNERS

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)