-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3,987 changed files
with
1,376,494 additions
and
45,706 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# The V8 public C++ API | ||
|
||
# Overview | ||
|
||
The V8 public C++ API aims to support four use cases: | ||
|
||
1. Enable applications that embed V8 (called the embedder) to configure and run | ||
one or more instances of V8. | ||
2. Expose ECMAScript-like capabilities to the embedder. | ||
3. Enable the embedder to interact with ECMAScript by exposing API objects. | ||
4. Provide access to the V8 debugger (inspector). | ||
|
||
# Configuring and running an instance of V8 | ||
|
||
V8 requires access to certain OS-level primitives such as the ability to | ||
schedule work on threads, or allocate memory. | ||
|
||
The embedder can define how to access those primitives via the v8::Platform | ||
interface. While V8 bundles a basic implementation, embedders are highly | ||
encouraged to implement v8::Platform themselves. | ||
|
||
Currently, the v8::ArrayBuffer::Allocator is passed to the v8::Isolate factory | ||
method, however, conceptually it should also be part of the v8::Platform since | ||
all instances of V8 should share one allocator. | ||
|
||
Once the v8::Platform is configured, an v8::Isolate can be created. All | ||
further interactions with V8 should explicitly reference the v8::Isolate they | ||
refer to. All API methods should eventually take an v8::Isolate parameter. | ||
|
||
When a given instance of V8 is no longer needed, it can be destroyed by | ||
disposing the respective v8::Isolate. If the embedder wishes to free all memory | ||
associated with the v8::Isolate, it has to first clear all global handles | ||
associated with that v8::Isolate. | ||
|
||
# ECMAScript-like capabilities | ||
|
||
In general, the C++ API shouldn't enable capabilities that aren't available to | ||
scripts running in V8. Experience has shown that it's not possible to maintain | ||
such API methods in the long term. However, capabilities also available to | ||
scripts, i.e., ones that are defined in the ECMAScript standard are there to | ||
stay, and we can safely expose them to embedders. | ||
|
||
The C++ API should also be pleasant to use, and not require learning new | ||
paradigms. Similarly to how the API exposed to scripts aims to provide good | ||
ergonomics, we should aim to provide a reasonable developer experience for this | ||
API surface. | ||
|
||
ECMAScript makes heavy use of exceptions, however, V8's C++ code doesn't use | ||
C++ exceptions. Therefore, all API methods that can throw exceptions should | ||
indicate so by returning a v8::Maybe<> or v8::MaybeLocal<> result, | ||
and by taking a v8::Local<v8::Context> parameter that indicates in which | ||
context a possible exception should be thrown. | ||
|
||
# API objects | ||
|
||
V8 allows embedders to define special objects that expose additional | ||
capabilities and APIs to scripts. The most prominent example is exposing the | ||
HTML DOM in Blink. Other examples are e.g. node.js. It is less clear what kind | ||
of capabilities we want to expose via this API surface. As a rule of thumb, we | ||
want to expose operations as defined in the WebIDL and HTML spec: we | ||
assume that those requirements are somewhat stable, and that they are a | ||
superset of the requirements of other embedders including node.js. | ||
|
||
Ideally, the API surfaces defined in those specs hook into the ECMAScript spec | ||
which in turn guarantees long-term stability of the API. | ||
|
||
# The V8 inspector | ||
|
||
All debugging capabilities of V8 should be exposed via the inspector protocol. | ||
The exception to this are profiling features exposed via v8-profiler.h. | ||
Changes to the inspector protocol need to ensure backwards compatibility and | ||
commitment to maintain. |
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,10 @@ | ||
include_rules = [ | ||
# v8-inspector-protocol.h depends on generated files under include/inspector. | ||
"+inspector", | ||
"+cppgc/common.h", | ||
# Used by v8-cppgc.h to bridge to cppgc. | ||
"+cppgc/custom-space.h", | ||
"+cppgc/heap-statistics.h", | ||
"+cppgc/internal/write-barrier.h", | ||
"+cppgc/visitor.h", | ||
] |
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,11 @@ | ||
# Metadata information for this directory. | ||
# | ||
# For more information on DIR_METADATA files, see: | ||
# https://source.chromium.org/chromium/infra/infra/+/master:go/src/infra/tools/dirmd/README.md | ||
# | ||
# For the schema of this file, see Metadata message: | ||
# https://source.chromium.org/chromium/infra/infra/+/master:go/src/infra/tools/dirmd/proto/dir_metadata.proto | ||
|
||
monorail { | ||
component: "Blink>JavaScript>API" | ||
} |
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,23 @@ | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
|
||
per-file *DEPS=file:../COMMON_OWNERS | ||
per-file v8-internal.h=file:../COMMON_OWNERS | ||
|
||
per-file v8-debug.h=file:../src/debug/OWNERS | ||
|
||
per-file js_protocol.pdl=file:../src/inspector/OWNERS | ||
per-file v8-inspector*=file:../src/inspector/OWNERS | ||
per-file v8-inspector*=file:../src/inspector/OWNERS | ||
|
||
# Needed by the auto_tag builder | ||
per-file v8-version.h=v8-ci-autoroll-builder@chops-service-accounts.iam.gserviceaccount.com | ||
|
||
# For branch updates: | ||
per-file v8-version.h=file:../INFRA_OWNERS | ||
per-file [email protected] | ||
per-file [email protected] |
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
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,48 @@ | ||
// Copyright 2022 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. | ||
|
||
#ifndef INCLUDE_CPPGC_HEAP_HANDLE_H_ | ||
#define INCLUDE_CPPGC_HEAP_HANDLE_H_ | ||
|
||
#include "v8config.h" // NOLINT(build/include_directory) | ||
|
||
namespace cppgc { | ||
|
||
namespace internal { | ||
class HeapBase; | ||
class WriteBarrierTypeForCagedHeapPolicy; | ||
class WriteBarrierTypeForNonCagedHeapPolicy; | ||
} // namespace internal | ||
|
||
/** | ||
* Opaque handle used for additional heap APIs. | ||
*/ | ||
class HeapHandle { | ||
public: | ||
// Deleted copy ctor to avoid treating the type by value. | ||
HeapHandle(const HeapHandle&) = delete; | ||
HeapHandle& operator=(const HeapHandle&) = delete; | ||
|
||
private: | ||
HeapHandle() = default; | ||
|
||
V8_INLINE bool is_incremental_marking_in_progress() const { | ||
return is_incremental_marking_in_progress_; | ||
} | ||
|
||
V8_INLINE bool is_young_generation_enabled() const { | ||
return is_young_generation_enabled_; | ||
} | ||
|
||
bool is_incremental_marking_in_progress_ = false; | ||
bool is_young_generation_enabled_ = false; | ||
|
||
friend class internal::HeapBase; | ||
friend class internal::WriteBarrierTypeForCagedHeapPolicy; | ||
friend class internal::WriteBarrierTypeForNonCagedHeapPolicy; | ||
}; | ||
|
||
} // namespace cppgc | ||
|
||
#endif // INCLUDE_CPPGC_HEAP_HANDLE_H_ |
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
Oops, something went wrong.