Skip to content

Commit

Permalink
Merge pull request #259 from altmp/ALTV-380
Browse files Browse the repository at this point in the history
ALTV-380 Bump v8 & nodejs versions
  • Loading branch information
OlegTrofimov authored Oct 1, 2024
2 parents fd1ed73 + d8bae68 commit 3bab7f5
Show file tree
Hide file tree
Showing 3,970 changed files with 1,201,535 additions and 45,690 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
72 changes: 72 additions & 0 deletions client/deps/v8/include/APIDesign.md
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.
10 changes: 10 additions & 0 deletions client/deps/v8/include/DEPS
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",
]
11 changes: 11 additions & 0 deletions client/deps/v8/include/DIR_METADATA
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"
}
23 changes: 23 additions & 0 deletions client/deps/v8/include/OWNERS
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]
1 change: 1 addition & 0 deletions client/deps/v8/include/cppgc/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ include_rules = [
"-include",
"+v8config.h",
"+v8-platform.h",
"+v8-source-location.h",
"+cppgc",
"-src",
"+libplatform/libplatform.h",
Expand Down
2 changes: 2 additions & 0 deletions client/deps/v8/include/cppgc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ This allows Oilpan to run garbage collection in parallel with mutators running i
References to objects belonging to another thread's heap are modeled using cross-thread roots.
This is even true for on-heap to on-heap references.

Oilpan heaps may generally not be accessed from different threads unless otherwise noted.

## Heap partitioning

Oilpan's heaps are partitioned into spaces.
Expand Down
1 change: 0 additions & 1 deletion client/deps/v8/include/cppgc/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#ifndef INCLUDE_CPPGC_COMMON_H_
#define INCLUDE_CPPGC_COMMON_H_

// TODO(chromium:1056170): Remove dependency on v8.
#include "v8config.h" // NOLINT(build/include_directory)

namespace cppgc {
Expand Down
21 changes: 11 additions & 10 deletions client/deps/v8/include/cppgc/cross-thread-persistent.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class BasicCrossThreadPersistent final : public CrossThreadPersistentBase,
if (!IsValid(raw)) return;
PersistentRegionLock guard;
CrossThreadPersistentRegion& region = this->GetPersistentRegion(raw);
SetNode(region.AllocateNode(this, &Trace));
SetNode(region.AllocateNode(this, &TraceAsRoot));
this->CheckPointer(raw);
}

Expand All @@ -138,7 +138,7 @@ class BasicCrossThreadPersistent final : public CrossThreadPersistentBase,
: CrossThreadPersistentBase(raw), LocationPolicy(loc) {
if (!IsValid(raw)) return;
CrossThreadPersistentRegion& region = this->GetPersistentRegion(raw);
SetNode(region.AllocateNode(this, &Trace));
SetNode(region.AllocateNode(this, &TraceAsRoot));
this->CheckPointer(raw);
}

Expand All @@ -148,10 +148,11 @@ class BasicCrossThreadPersistent final : public CrossThreadPersistentBase,

template <typename U, typename MemberBarrierPolicy,
typename MemberWeaknessTag, typename MemberCheckingPolicy,
typename MemberStorageType,
typename = std::enable_if_t<std::is_base_of<T, U>::value>>
BasicCrossThreadPersistent(
internal::BasicMember<U, MemberBarrierPolicy, MemberWeaknessTag,
MemberCheckingPolicy>
MemberCheckingPolicy, MemberStorageType>
member,
const SourceLocation& loc = SourceLocation::Current())
: BasicCrossThreadPersistent(member.Get(), loc) {}
Expand Down Expand Up @@ -230,10 +231,11 @@ class BasicCrossThreadPersistent final : public CrossThreadPersistentBase,
// Assignment from member.
template <typename U, typename MemberBarrierPolicy,
typename MemberWeaknessTag, typename MemberCheckingPolicy,
typename MemberStorageType,
typename = std::enable_if_t<std::is_base_of<T, U>::value>>
BasicCrossThreadPersistent& operator=(
internal::BasicMember<U, MemberBarrierPolicy, MemberWeaknessTag,
MemberCheckingPolicy>
MemberCheckingPolicy, MemberStorageType>
member) {
return operator=(member.Get());
}
Expand Down Expand Up @@ -349,9 +351,8 @@ class BasicCrossThreadPersistent final : public CrossThreadPersistentBase,
return ptr && ptr != kSentinelPointer;
}

static void Trace(Visitor* v, const void* ptr) {
const auto* handle = static_cast<const BasicCrossThreadPersistent*>(ptr);
v->TraceRoot(*handle, handle->Location());
static void TraceAsRoot(RootVisitor& root_visitor, const void* ptr) {
root_visitor.Trace(*static_cast<const BasicCrossThreadPersistent*>(ptr));
}

void AssignUnsafe(T* ptr) {
Expand All @@ -378,7 +379,7 @@ class BasicCrossThreadPersistent final : public CrossThreadPersistentBase,
SetValue(ptr);
if (!IsValid(ptr)) return;
PersistentRegionLock guard;
SetNode(this->GetPersistentRegion(ptr).AllocateNode(this, &Trace));
SetNode(this->GetPersistentRegion(ptr).AllocateNode(this, &TraceAsRoot));
this->CheckPointer(ptr);
}

Expand All @@ -398,7 +399,7 @@ class BasicCrossThreadPersistent final : public CrossThreadPersistentBase,
}
SetValue(ptr);
if (!IsValid(ptr)) return;
SetNode(this->GetPersistentRegion(ptr).AllocateNode(this, &Trace));
SetNode(this->GetPersistentRegion(ptr).AllocateNode(this, &TraceAsRoot));
this->CheckPointer(ptr);
}

Expand All @@ -416,7 +417,7 @@ class BasicCrossThreadPersistent final : public CrossThreadPersistentBase,
return static_cast<T*>(const_cast<void*>(GetValueFromGC()));
}

friend class cppgc::Visitor;
friend class internal::RootVisitor;
};

template <typename T, typename LocationPolicy, typename CheckingPolicy>
Expand Down
49 changes: 46 additions & 3 deletions client/deps/v8/include/cppgc/heap-consistency.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include "cppgc/internal/write-barrier.h"
#include "cppgc/macros.h"
#include "cppgc/member.h"
#include "cppgc/trace-trait.h"
#include "v8config.h" // NOLINT(build/include_directory)

Expand Down Expand Up @@ -47,6 +48,29 @@ class HeapConsistency final {
return internal::WriteBarrier::GetWriteBarrierType(slot, value, params);
}

/**
* Gets the required write barrier type for a specific write. This override is
* only used for all the BasicMember types.
*
* \param slot Slot containing the pointer to the object. The slot itself
* must reside in an object that has been allocated using
* `MakeGarbageCollected()`.
* \param value The pointer to the object held via `BasicMember`.
* \param params Parameters that may be used for actual write barrier calls.
* Only filled if return value indicates that a write barrier is needed. The
* contents of the `params` are an implementation detail.
* \returns whether a write barrier is needed and which barrier to invoke.
*/
template <typename T, typename WeaknessTag, typename WriteBarrierPolicy,
typename CheckingPolicy, typename StorageType>
static V8_INLINE WriteBarrierType GetWriteBarrierType(
const internal::BasicMember<T, WeaknessTag, WriteBarrierPolicy,
CheckingPolicy, StorageType>& value,
WriteBarrierParams& params) {
return internal::WriteBarrier::GetWriteBarrierType(
value.GetRawSlot(), value.GetRawStorage(), params);
}

/**
* Gets the required write barrier type for a specific write.
*
Expand Down Expand Up @@ -146,7 +170,25 @@ class HeapConsistency final {
*/
static V8_INLINE void GenerationalBarrier(const WriteBarrierParams& params,
const void* slot) {
internal::WriteBarrier::GenerationalBarrier(params, slot);
internal::WriteBarrier::GenerationalBarrier<
internal::WriteBarrier::GenerationalBarrierType::kPreciseSlot>(params,
slot);
}

/**
* Generational barrier for maintaining consistency when running with multiple
* generations. This version is used when slot contains uncompressed pointer.
*
* \param params The parameters retrieved from `GetWriteBarrierType()`.
* \param slot Uncompressed slot containing the direct pointer to the object.
* The slot itself must reside in an object that has been allocated using
* `MakeGarbageCollected()`.
*/
static V8_INLINE void GenerationalBarrierForUncompressedSlot(
const WriteBarrierParams& params, const void* uncompressed_slot) {
internal::WriteBarrier::GenerationalBarrier<
internal::WriteBarrier::GenerationalBarrierType::
kPreciseUncompressedSlot>(params, uncompressed_slot);
}

/**
Expand All @@ -158,8 +200,9 @@ class HeapConsistency final {
*/
static V8_INLINE void GenerationalBarrierForSourceObject(
const WriteBarrierParams& params, const void* inner_pointer) {
internal::WriteBarrier::GenerationalBarrierForSourceObject(params,
inner_pointer);
internal::WriteBarrier::GenerationalBarrier<
internal::WriteBarrier::GenerationalBarrierType::kImpreciseSlot>(
params, inner_pointer);
}

private:
Expand Down
48 changes: 48 additions & 0 deletions client/deps/v8/include/cppgc/heap-handle.h
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_
4 changes: 2 additions & 2 deletions client/deps/v8/include/cppgc/heap-statistics.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ struct HeapStatistics final {
/** Amount of memory actually used on the page. */
size_t used_size_bytes = 0;
/** Statistics for object allocated on the page. Filled only when
* NameProvider::HideInternalNames() is false. */
* NameProvider::SupportsCppClassNamesAsObjectNames() is true. */
std::vector<ObjectStatsEntry> object_statistics;
};

Expand Down Expand Up @@ -98,7 +98,7 @@ struct HeapStatistics final {

/** Overall committed amount of memory for the heap. */
size_t committed_size_bytes = 0;
/** Resident amount of memory help by the heap. */
/** Resident amount of memory held by the heap. */
size_t resident_size_bytes = 0;
/** Amount of memory actually used on the heap. */
size_t used_size_bytes = 0;
Expand Down
Loading

0 comments on commit 3bab7f5

Please sign in to comment.