Skip to content

Commit

Permalink
deps: V8: cherry-pick semver-major commits from 10.2
Browse files Browse the repository at this point in the history
Includes the following commits:

commit b2978927d8a96ebc814cccbc5a9f1c35910ee621
    Remove dynamic map checks and custom deoptimization kinds

    This CL removes:

    - Dynamic map checks aka minimorphic property loads (TF support,
      builtins).
    - "Bailout" deopts (= drop to the interpreter once, but don't
      throw out optimized code).
    - "EagerWithResume" deopts (= part of dynamic map check
      functionality, we call a builtin for the deopt check and deopt
      or resume based on the result).

    Fixed: v8:12552
    Change-Id: I492cf1667e0f54586690b2f72a65ea804224b840
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3401585

commit f52f934119635058b179c2359fe070b8ee0f9233
    PPC/s390: Remove dynamic map checks and custom deoptimization kinds

    Port b2978927d8a96ebc814cccbc5a9f1c35910ee621

    Original Commit Message:

        This CL removes:

        - Dynamic map checks aka minimorphic property loads (TF support,
          builtins).
        - "Bailout" deopts (= drop to the interpreter once, but don't
          throw out optimized code).
        - "EagerWithResume" deopts (= part of dynamic map check
          functionality, we call a builtin for the deopt check and deopt
          or resume based on the result).

    R=jgruber@chromium.org, joransiu@ca.ibm.com, junyan@redhat.com, midawson@redhat.com
    BUG=
    LOG=N

    Change-Id: I64476f73810774c2c592231d82c4a2cbfa2bf94e
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3537881

commit 38940b70986da6b43d18cb8cf8f0a3be36ca9010
    [loong64][mips] Remove dynamic map checks and custom deoptimization kinds

    Port commit b2978927d8a96ebc814cccbc5a9f1c35910ee621

    Fixed: v8:12552
    Change-Id: Ic2fbded9a662ed840a0350e3ce049e147fbf03a0
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3541527

commit da5b5f66a6bd27df6249602378300c6961bc62b4
    [riscv64] Remove dynamic map checks and custom deoptimization kinds

    Port b2978927d8a96ebc814cccbc5a9f1c35910ee621

    Bug: v8:12552
    Change-Id: I73e76fc5cc8905a0fbfc801b2f794735866d19e8
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3544725

commit ffae028b37991566c080c5528463f7d16017668c
    Forward deprecation for resurrecting finalizer

    Bug: v8:12672
    Change-Id: Ib4f53086436e028b4ea32fbc960f57e91709d184
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3532256

commit f6386018d472665e36d662c8b159d95325999d69
    [api] Remove TracedGlobal<>

    Remove deprecated TracedGlobal<>, greatly simplifying handling of
    traced references in general.

    Also saves a word per v8::TracedReference as there's no need to keep a
    possible callback around.

    Bug: v8:12603
    Change-Id: Ice35d7906775b912d02e97a27a722b3e1cec28d9
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3532251

commit a8beac553b0a1639bc9790c2d6f82caf6b2e150f
    Deprecate some signature checks

    Deprecate signature checks in
    * Template::SetNativeDataProperty
    * ObjectTemplate::SetAccessor
    These are not used in Chrome and require some complicated check in the IC code, which we want to remove.

    Change-Id: I413fafc8658e922fd590e7fe200600a624f019a6
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3557253

commit cff2b5000a1aa417a9c4499bcfa3ffda4542f4f1
    Deprecate signature checks in Set{Accessor,NativeDataProperty}

    Change from V8_DEPRECATE_SOON to V8_DEPRECATED. It turned out that we
    don't have to make changes in chrome code, so we can go to deprecated
    right away.

    Bug: chromium:1310790
    Change-Id: I1bd529536d3a0098f11f13b3e44fe3dbc80eed04
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3571897

commit 9238afb0c0ee52c9111a7e9f2f055137628771ad
    Allow embedder to set global OOM handler

    Embedders can currently specify a callback for OOM errors during
    Isolate initialization. However, there are cases where an OOM error can
    be thrown in a context where we don't have access to an Isolate, for
    example on a task posted to a worker thread. This CL introduces an
    initialization API to allow the embedder to specify a process-wide OOM
    callback.

    Bug: chromium:614440
    Change-Id: I326753d80767679f677e85104d9edeef92e19086
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3561916

commit ca51ae3ac8b468509603633adb6ee3b3be9306ec
    [api][profiler] Get StartProfiling, StopProfiling to accept integer ID rather than string

    This CL adds support for interacting with CpuProfile with their integer
    id.
    A String ID is problematic because it forces an allocation when stopping
    or cancelling a Profiler which can happen during a GC when this
    is not allowed.

    Change-Id: I9a8e754bd67214be0bbc5ca051bcadf52bf71a68
    Bug: chromium:1297283
    Co-Authored-By: Nicolas Dubus <nicodubus@fb.com>
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3522896

Refs: v8/v8@b297892
Refs: v8/v8@f52f934
Refs: v8/v8@38940b7
Refs: v8/v8@da5b5f6
Refs: v8/v8@ffae028
Refs: v8/v8@f638601
Refs: v8/v8@a8beac5
Refs: v8/v8@cff2b50
Refs: v8/v8@9238afb
Refs: v8/v8@ca51ae3

PR-URL: #42657
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
  • Loading branch information
targos committed Apr 12, 2022
1 parent eba7d2d commit 58f3fdc
Show file tree
Hide file tree
Showing 116 changed files with 935 additions and 3,418 deletions.
2 changes: 1 addition & 1 deletion common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

# Reset this number to 0 on major V8 upgrades.
# Increment by one for each non-official patch applied to deps/v8.
'v8_embedder_string': '-node.12',
'v8_embedder_string': '-node.13',

##### V8 defaults for Node.js #####

Expand Down
1 change: 0 additions & 1 deletion deps/v8/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,6 @@ filegroup(
"src/builtins/function.tq",
"src/builtins/growable-fixed-array.tq",
"src/builtins/ic-callable.tq",
"src/builtins/ic-dynamic-check-maps.tq",
"src/builtins/ic.tq",
"src/builtins/internal-coverage.tq",
"src/builtins/internal.tq",
Expand Down
1 change: 0 additions & 1 deletion deps/v8/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -1670,7 +1670,6 @@ torque_files = [
"src/builtins/function.tq",
"src/builtins/growable-fixed-array.tq",
"src/builtins/ic-callable.tq",
"src/builtins/ic-dynamic-check-maps.tq",
"src/builtins/ic.tq",
"src/builtins/internal-coverage.tq",
"src/builtins/internal.tq",
Expand Down
31 changes: 10 additions & 21 deletions deps/v8/include/v8-embedder-heap.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,22 @@ class V8_EXPORT EmbedderRootsHandler {
virtual ~EmbedderRootsHandler() = default;

/**
* Returns true if the TracedGlobal handle should be considered as root for
* the currently running non-tracing garbage collection and false otherwise.
* The default implementation will keep all TracedGlobal references as roots.
* Returns true if the |TracedReference| handle should be considered as root
* for the currently running non-tracing garbage collection and false
* otherwise. The default implementation will keep all |TracedReference|
* references as roots.
*
* If this returns false, then V8 may decide that the object referred to by
* such a handle is reclaimed. In that case:
* - No action is required if handles are used with destructors, i.e., by just
* using |TracedGlobal|.
* - When run without destructors, i.e., by using |TracedReference|, V8 calls
* |ResetRoot|.
* such a handle is reclaimed. In that case, V8 calls |ResetRoot()| for the
* |TracedReference|.
*
* Note that the |handle| is different from the handle that the embedder holds
* Note that the `handle` is different from the handle that the embedder holds
* for retaining the object. The embedder may use |WrapperClassId()| to
* distinguish cases where it wants handles to be treated as roots from not
* being treated as roots.
*/
virtual bool IsRoot(const v8::TracedReference<v8::Value>& handle) = 0;

V8_DEPRECATED("See v8::TracedGlobal class comment.")
virtual bool IsRoot(const v8::TracedGlobal<v8::Value>& handle) {
return true;
}

/**
* Used in combination with |IsRoot|. Called by V8 when an
* object that is backed by a handle is reclaimed by a non-tracing garbage
Expand Down Expand Up @@ -87,13 +80,11 @@ class V8_EXPORT EmbedderHeapTracer {
};

/**
* Interface for iterating through TracedGlobal handles.
* Interface for iterating through |TracedReference| handles.
*/
class V8_EXPORT TracedGlobalHandleVisitor {
public:
virtual ~TracedGlobalHandleVisitor() = default;
V8_DEPRECATED("See v8::TracedGlobal class comment.")
virtual void VisitTracedGlobalHandle(const TracedGlobal<Value>& handle) {}
virtual void VisitTracedReference(const TracedReference<Value>& handle) {}
};

Expand All @@ -118,8 +109,8 @@ class V8_EXPORT EmbedderHeapTracer {
virtual ~EmbedderHeapTracer() = default;

/**
* Iterates all TracedGlobal handles created for the v8::Isolate the tracer is
* attached to.
* Iterates all |TracedReference| handles created for the |v8::Isolate| the
* tracer is attached to.
*/
void IterateTracedGlobalHandles(TracedGlobalHandleVisitor* visitor);

Expand Down Expand Up @@ -194,8 +185,6 @@ class V8_EXPORT EmbedderHeapTracer {
*/
virtual bool IsRootForNonTracingGC(
const v8::TracedReference<v8::Value>& handle);
V8_DEPRECATED("See v8::TracedGlobal class comment.")
virtual bool IsRootForNonTracingGC(const v8::TracedGlobal<v8::Value>& handle);

/**
* See documentation on EmbedderRootsHandler.
Expand Down
17 changes: 13 additions & 4 deletions deps/v8/include/v8-initialization.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
#include <stddef.h>
#include <stdint.h>

#include "v8-internal.h" // NOLINT(build/include_directory)
#include "v8-isolate.h" // NOLINT(build/include_directory)
#include "v8-platform.h" // NOLINT(build/include_directory)
#include "v8config.h" // NOLINT(build/include_directory)
#include "v8-callbacks.h" // NOLINT(build/include_directory)
#include "v8-internal.h" // NOLINT(build/include_directory)
#include "v8-isolate.h" // NOLINT(build/include_directory)
#include "v8-platform.h" // NOLINT(build/include_directory)
#include "v8config.h" // NOLINT(build/include_directory)

// We reserve the V8_* prefix for macros defined in V8 public API and
// assume there are no name conflicts with the embedder's code.
Expand Down Expand Up @@ -275,6 +276,14 @@ class V8_EXPORT V8 {
UnhandledExceptionCallback unhandled_exception_callback);
#endif

/**
* Allows the host application to provide a callback that will be called when
* v8 has encountered a fatal failure to allocate memory and is about to
* terminate.
*/

static void SetFatalMemoryErrorCallback(OOMErrorCallback oom_error_callback);

/**
* Get statistics about the shared memory usage.
*/
Expand Down
4 changes: 2 additions & 2 deletions deps/v8/include/v8-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,8 @@ class Internals {

static const uint32_t kNumIsolateDataSlots = 4;
static const int kStackGuardSize = 7 * kApiSystemPointerSize;
static const int kBuiltinTier0EntryTableSize = 13 * kApiSystemPointerSize;
static const int kBuiltinTier0TableSize = 13 * kApiSystemPointerSize;
static const int kBuiltinTier0EntryTableSize = 10 * kApiSystemPointerSize;
static const int kBuiltinTier0TableSize = 10 * kApiSystemPointerSize;

// IsolateData layout guarantees.
static const int kIsolateCageBaseOffset = 0;
Expand Down
4 changes: 0 additions & 4 deletions deps/v8/include/v8-local-handle.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ class String;
template <class F>
class Traced;
template <class F>
class TracedGlobal;
template <class F>
class TracedReference;
class TracedReferenceBase;
class Utils;
Expand Down Expand Up @@ -312,8 +310,6 @@ class Local {
template <class F>
friend class Traced;
template <class F>
friend class TracedGlobal;
template <class F>
friend class BasicTracedReference;
template <class F>
friend class TracedReference;
Expand Down
2 changes: 1 addition & 1 deletion deps/v8/include/v8-object.h
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ class V8_EXPORT Object : public Value {
return object.val_->GetAlignedPointerFromInternalField(index);
}

/** Same as above, but works for TracedGlobal. */
/** Same as above, but works for TracedReference. */
V8_INLINE static void* GetAlignedPointerFromInternalField(
const BasicTracedReference<Object>& object, int index) {
return object->GetAlignedPointerFromInternalField(index);
Expand Down
66 changes: 65 additions & 1 deletion deps/v8/include/v8-profiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ enum StateTag : int;

using NativeObject = void*;
using SnapshotObjectId = uint32_t;
using ProfilerId = uint32_t;

struct CpuProfileDeoptFrame {
int script_id;
Expand Down Expand Up @@ -273,15 +274,33 @@ enum class CpuProfilingStatus {
kErrorTooManyProfilers
};

/**
* Result from StartProfiling returning the Profiling Status, and
* id of the started profiler, or 0 if profiler is not started
*/
struct CpuProfilingResult {
const ProfilerId id;
const CpuProfilingStatus status;
};

/**
* Delegate for when max samples reached and samples are discarded.
*/
class V8_EXPORT DiscardedSamplesDelegate {
public:
DiscardedSamplesDelegate() {}
DiscardedSamplesDelegate() = default;

virtual ~DiscardedSamplesDelegate() = default;
virtual void Notify() = 0;

ProfilerId GetId() const { return profiler_id_; }

private:
friend internal::CpuProfile;

void SetId(ProfilerId id) { profiler_id_ = id; }

ProfilerId profiler_id_;
};

/**
Expand Down Expand Up @@ -371,6 +390,45 @@ class V8_EXPORT CpuProfiler {
*/
void SetUsePreciseSampling(bool);

/**
* Starts collecting a CPU profile. Several profiles may be collected at once.
* Generates an anonymous profiler, without a String identifier.
*/
CpuProfilingResult Start(
CpuProfilingOptions options,
std::unique_ptr<DiscardedSamplesDelegate> delegate = nullptr);

/**
* Starts collecting a CPU profile. Title may be an empty string. Several
* profiles may be collected at once. Attempts to start collecting several
* profiles with the same title are silently ignored.
*/
CpuProfilingResult Start(
Local<String> title, CpuProfilingOptions options,
std::unique_ptr<DiscardedSamplesDelegate> delegate = nullptr);

/**
* Starts profiling with the same semantics as above, except with expanded
* parameters.
*
* |record_samples| parameter controls whether individual samples should
* be recorded in addition to the aggregated tree.
*
* |max_samples| controls the maximum number of samples that should be
* recorded by the profiler. Samples obtained after this limit will be
* discarded.
*/
CpuProfilingResult Start(
Local<String> title, CpuProfilingMode mode, bool record_samples = false,
unsigned max_samples = CpuProfilingOptions::kNoSampleLimit);

/**
* The same as StartProfiling above, but the CpuProfilingMode defaults to
* kLeafNodeLineNumbers mode, which was the previous default behavior of the
* profiler.
*/
CpuProfilingResult Start(Local<String> title, bool record_samples = false);

/**
* Starts collecting a CPU profile. Title may be an empty string. Several
* profiles may be collected at once. Attempts to start collecting several
Expand All @@ -394,6 +452,7 @@ class V8_EXPORT CpuProfiler {
CpuProfilingStatus StartProfiling(
Local<String> title, CpuProfilingMode mode, bool record_samples = false,
unsigned max_samples = CpuProfilingOptions::kNoSampleLimit);

/**
* The same as StartProfiling above, but the CpuProfilingMode defaults to
* kLeafNodeLineNumbers mode, which was the previous default behavior of the
Expand All @@ -402,6 +461,11 @@ class V8_EXPORT CpuProfiler {
CpuProfilingStatus StartProfiling(Local<String> title,
bool record_samples = false);

/**
* Stops collecting CPU profile with a given id and returns it.
*/
CpuProfile* Stop(ProfilerId id);

/**
* Stops collecting CPU profile with a given title and returns it.
* If the title given is empty, finishes the last profile started.
Expand Down
35 changes: 31 additions & 4 deletions deps/v8/include/v8-template.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,33 @@ class V8_EXPORT Template : public Data {
* defined by FunctionTemplate::HasInstance()), an implicit TypeError is
* thrown and no callback is invoked.
*/
V8_DEPRECATED("Do signature check in accessor")
void SetNativeDataProperty(
Local<String> name, AccessorGetterCallback getter,
AccessorSetterCallback setter, Local<Value> data,
PropertyAttribute attribute, Local<AccessorSignature> signature,
AccessControl settings = DEFAULT,
SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
V8_DEPRECATED("Do signature check in accessor")
void SetNativeDataProperty(
Local<Name> name, AccessorNameGetterCallback getter,
AccessorNameSetterCallback setter, Local<Value> data,
PropertyAttribute attribute, Local<AccessorSignature> signature,
AccessControl settings = DEFAULT,
SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
void SetNativeDataProperty(
Local<String> name, AccessorGetterCallback getter,
AccessorSetterCallback setter = nullptr,
Local<Value> data = Local<Value>(), PropertyAttribute attribute = None,
Local<AccessorSignature> signature = Local<AccessorSignature>(),
AccessControl settings = DEFAULT,
SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
void SetNativeDataProperty(
Local<Name> name, AccessorNameGetterCallback getter,
AccessorNameSetterCallback setter = nullptr,
Local<Value> data = Local<Value>(), PropertyAttribute attribute = None,
Local<AccessorSignature> signature = Local<AccessorSignature>(),
AccessControl settings = DEFAULT,
SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
Expand Down Expand Up @@ -813,20 +827,33 @@ class V8_EXPORT ObjectTemplate : public Template {
* defined by FunctionTemplate::HasInstance()), an implicit TypeError is
* thrown and no callback is invoked.
*/
V8_DEPRECATED("Do signature check in accessor")
void SetAccessor(
Local<String> name, AccessorGetterCallback getter,
AccessorSetterCallback setter, Local<Value> data, AccessControl settings,
PropertyAttribute attribute, Local<AccessorSignature> signature,
SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
V8_DEPRECATED("Do signature check in accessor")
void SetAccessor(
Local<Name> name, AccessorNameGetterCallback getter,
AccessorNameSetterCallback setter, Local<Value> data,
AccessControl settings, PropertyAttribute attribute,
Local<AccessorSignature> signature,
SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
void SetAccessor(
Local<String> name, AccessorGetterCallback getter,
AccessorSetterCallback setter = nullptr,
Local<Value> data = Local<Value>(), AccessControl settings = DEFAULT,
PropertyAttribute attribute = None,
Local<AccessorSignature> signature = Local<AccessorSignature>(),
SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
void SetAccessor(
Local<Name> name, AccessorNameGetterCallback getter,
AccessorNameSetterCallback setter = nullptr,
Local<Value> data = Local<Value>(), AccessControl settings = DEFAULT,
PropertyAttribute attribute = None,
Local<AccessorSignature> signature = Local<AccessorSignature>(),
SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);

Expand Down
Loading

0 comments on commit 58f3fdc

Please sign in to comment.