From 36daaf3917bb2957580cd604208111eb924867de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Mon, 30 Aug 2021 22:12:15 +0200 Subject: [PATCH] deps: make V8 9.3 abi-compatible with 9.0 Revert "[api] Avoid handles for const API functions" This reverts commit aee471b2ff5b1a9e622426454885b748d226535b. Revert "[api] Remove deprecated [Shared]ArrayBuffer API" This reverts commit 578f6be77fc5d8af975005c2baf918e7225abb62. Revert "[Jobs]: Cleanup in v8 platform." This reverts commit baf2b088dd9f585aa597459f30d71431171666e2. Revert "Skip global registration of [Shared]ArrayBuffer backing stores" This reverts commit fcdf35e6d70d51699ece063e25dc705e80673308. Revert "[api] Remove previously deprecated Function::GetDisplayName()." This reverts commit 6165fef8cc9dde52973e54c915e6905221b3f8fb. Revert "[api] Remove deprecated Symbol::Name()" This reverts commit bbc72ef6c7d6d8e2c4dd074d7713e5c841003163. Revert API change for HeapProfiler::TakeHeapSnapshot This reverts a small part of 7f52e4f92d3d3ded9a1701ee2f93966075ae5004. Revert "[cpu-profiler] Reintroduce support for context filtering" This reverts commit 0aacfb2a6ecbeda1d1d97ca113afd8253a1b9670. Restore new argument for TakeHeapSnapshot method This creates a new TakeHeapSnapshotV8_92 method with the signature from 7f52e4f92d3d3ded9a1701ee2f93966075ae5004. It is necessary because the API is used internall by V8. Silence irrelevant warning V8 triggers it in the Name method. Revert "[api] Add v8::metrics::LongTaskStats for the LongTasks UKM" This reverts commit 521ae93bf652b0cc1fec1fdd788e3b80fb72a349. Move cage_base isolate data field Makes 3ada6f27404b4ffd6d3e97cf15be76672f60c10d ABI-compatible. Revert ABI-breaking change in FunctionTemplate::SetCallHandler Reverts part of a7980d43e030ba4bdb36813d4bc99f85982bf4ee and ad4eab00e7ec96730eb2c1b6ddcef14ba2e4becd. Revert "[api] Support PropertyAttribute in v8::Template::Set" This reverts commit 22a32f11f7a39e4a73105608a51ebab0ad97960f. Revert API change for FunctionTemplate::New This reverts the API change of 5f82dbbe534635a8b1e93f27e8fd7e68c0eaf291. Fix some reverts - constness of internal APIs has not external effect - restored API function must but adapted to moved internal API. --- common.gypi | 2 +- deps/v8/include/v8-internal.h | 13 +- deps/v8/include/v8-metrics.h | 29 +- deps/v8/include/v8-platform.h | 18 +- deps/v8/include/v8-profiler.h | 16 +- deps/v8/include/v8.h | 316 ++++++++- deps/v8/src/api/api.cc | 598 ++++++++++++++---- deps/v8/src/execution/isolate-data.h | 15 +- deps/v8/src/execution/isolate.cc | 17 - deps/v8/src/execution/isolate.h | 6 - deps/v8/src/heap/gc-tracer.cc | 15 - deps/v8/src/heap/heap.cc | 3 - .../inspector/v8-heap-profiler-agent-impl.cc | 2 +- deps/v8/src/logging/code-events.h | 6 - deps/v8/src/logging/log.h | 3 - deps/v8/src/objects/backing-store.cc | 37 +- deps/v8/src/objects/backing-store.h | 11 +- deps/v8/src/profiler/cpu-profiler.cc | 19 +- deps/v8/src/profiler/cpu-profiler.h | 20 +- deps/v8/src/profiler/profile-generator.cc | 33 +- deps/v8/src/profiler/profile-generator.h | 33 +- deps/v8/src/profiler/profiler-listener.cc | 7 - deps/v8/src/profiler/profiler-listener.h | 1 - deps/v8/src/profiler/tick-sample.cc | 9 - deps/v8/src/profiler/tick-sample.h | 1 - deps/v8/src/runtime/runtime-test.cc | 1 - deps/v8/src/wasm/module-compiler.cc | 2 - deps/v8/test/cctest/heap/test-heap.cc | 79 +-- deps/v8/test/cctest/test-api-array-buffer.cc | 189 +++++- deps/v8/test/cctest/test-cpu-profiler.cc | 143 +---- deps/v8/test/cctest/test-heap-profiler.cc | 2 +- deps/v8/test/cctest/test-typedarrays.cc | 24 + 32 files changed, 1057 insertions(+), 613 deletions(-) diff --git a/common.gypi b/common.gypi index 85cccab37dfc6e..6c6d94b7ce4e10 100644 --- a/common.gypi +++ b/common.gypi @@ -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.9', + 'v8_embedder_string': '-node.10', ##### V8 defaults for Node.js ##### diff --git a/deps/v8/include/v8-internal.h b/deps/v8/include/v8-internal.h index 1826dd6fca2eb3..85471960006a08 100644 --- a/deps/v8/include/v8-internal.h +++ b/deps/v8/include/v8-internal.h @@ -33,7 +33,6 @@ const int kApiSystemPointerSize = sizeof(void*); const int kApiDoubleSize = sizeof(double); const int kApiInt32Size = sizeof(int32_t); const int kApiInt64Size = sizeof(int64_t); -const int kApiSizetSize = sizeof(size_t); // Tag information for HeapObject. const int kHeapObjectTag = 1; @@ -231,12 +230,8 @@ class Internals { kIsolateFastCCallCallerFpOffset + kApiSystemPointerSize; static const int kIsolateFastApiCallTargetOffset = kIsolateFastCCallCallerPcOffset + kApiSystemPointerSize; - static const int kIsolateCageBaseOffset = - kIsolateFastApiCallTargetOffset + kApiSystemPointerSize; - static const int kIsolateLongTaskStatsCounterOffset = - kIsolateCageBaseOffset + kApiSystemPointerSize; static const int kIsolateStackGuardOffset = - kIsolateLongTaskStatsCounterOffset + kApiSizetSize; + kIsolateFastApiCallTargetOffset + kApiSystemPointerSize; static const int kIsolateRootsOffset = kIsolateStackGuardOffset + 7 * kApiSystemPointerSize; @@ -369,12 +364,6 @@ class Internals { return *reinterpret_cast(addr); } - V8_INLINE static void IncrementLongTasksStatsCounter(v8::Isolate* isolate) { - internal::Address addr = reinterpret_cast(isolate) + - kIsolateLongTaskStatsCounterOffset; - ++(*reinterpret_cast(addr)); - } - V8_INLINE static internal::Address* GetRoot(v8::Isolate* isolate, int index) { internal::Address addr = reinterpret_cast(isolate) + kIsolateRootsOffset + diff --git a/deps/v8/include/v8-metrics.h b/deps/v8/include/v8-metrics.h index a6eea6a8645d0c..498ee25f6d25c3 100644 --- a/deps/v8/include/v8-metrics.h +++ b/deps/v8/include/v8-metrics.h @@ -5,8 +5,7 @@ #ifndef V8_METRICS_H_ #define V8_METRICS_H_ -#include "v8-internal.h" // NOLINT(build/include_directory) -#include "v8.h" // NOLINT(build/include_directory) +#include "v8.h" // NOLINT(build/include_directory) namespace v8 { namespace metrics { @@ -197,32 +196,6 @@ class V8_EXPORT Recorder { static ContextId GetContextId(Local context); }; -/** - * Experimental API intended for the LongTasks UKM (crbug.com/1173527). - * The Reset() method should be called at the start of a potential - * long task. The Get() method returns durations of V8 work that - * happened during the task. - * - * This API is experimental and may be removed/changed in the future. - */ -struct V8_EXPORT LongTaskStats { - /** - * Resets durations of V8 work for the new task. - */ - V8_INLINE static void Reset(Isolate* isolate) { - v8::internal::Internals::IncrementLongTasksStatsCounter(isolate); - } - - /** - * Returns durations of V8 work that happened since the last Reset(). - */ - static LongTaskStats Get(Isolate* isolate); - - int64_t gc_full_atomic_wall_clock_duration_us = 0; - int64_t gc_full_incremental_wall_clock_duration_us = 0; - int64_t gc_young_wall_clock_duration_us = 0; -}; - } // namespace metrics } // namespace v8 diff --git a/deps/v8/include/v8-platform.h b/deps/v8/include/v8-platform.h index fc9a357feb66cb..4c94d7fd392c0c 100644 --- a/deps/v8/include/v8-platform.h +++ b/deps/v8/include/v8-platform.h @@ -181,8 +181,9 @@ class JobDelegate { /** * Returns true if the current task is called from the thread currently * running JobHandle::Join(). + * TODO(etiennep): Make pure virtual once custom embedders implement it. */ - virtual bool IsJoiningThread() const = 0; + virtual bool IsJoiningThread() const { return false; } }; /** @@ -219,14 +220,19 @@ class JobHandle { * Forces all existing workers to yield ASAP but doesn’t wait for them. * Warning, this is dangerous if the Job's callback is bound to or has access * to state which may be deleted after this call. + * TODO(etiennep): Cleanup once implemented by all embedders. */ - virtual void CancelAndDetach() = 0; + virtual void CancelAndDetach() { Cancel(); } /** * Returns true if there's any work pending or any worker running. */ virtual bool IsActive() = 0; + // TODO(etiennep): Clean up once all overrides are removed. + V8_DEPRECATED("Use !IsActive() instead.") + virtual bool IsCompleted() { return !IsActive(); } + /** * Returns true if associated with a Job and other methods may be called. * Returns false after Join() or Cancel() was called. This may return true @@ -234,6 +240,10 @@ class JobHandle { */ virtual bool IsValid() = 0; + // TODO(etiennep): Clean up once all overrides are removed. + V8_DEPRECATED("Use IsValid() instead.") + virtual bool IsRunning() { return IsValid(); } + /** * Returns true if job priority can be changed. */ @@ -262,6 +272,10 @@ class JobTask { * it must not call back any JobHandle methods. */ virtual size_t GetMaxConcurrency(size_t worker_count) const = 0; + + // TODO(1114823): Clean up once all overrides are removed. + V8_DEPRECATED("Use the version that takes |worker_count|.") + virtual size_t GetMaxConcurrency() const { return 0; } }; /** diff --git a/deps/v8/include/v8-profiler.h b/deps/v8/include/v8-profiler.h index 9a40cfcf307e1d..49ada0a7bf68e5 100644 --- a/deps/v8/include/v8-profiler.h +++ b/deps/v8/include/v8-profiler.h @@ -289,8 +289,8 @@ class V8_EXPORT CpuProfilingOptions { * interval, set via SetSamplingInterval(). If * zero, the sampling interval will be equal to * the profiler's sampling interval. - * \param filter_context If specified, profiles will only contain frames - * using this context. Other frames will be elided. + * \param filter_context Deprecated option to filter by context, currently a + * no-op. */ CpuProfilingOptions( CpuProfilingMode mode = kLeafNodeLineNumbers, @@ -304,13 +304,9 @@ class V8_EXPORT CpuProfilingOptions { private: friend class internal::CpuProfile; - bool has_filter_context() const { return !filter_context_.IsEmpty(); } - void* raw_filter_context() const; - CpuProfilingMode mode_; unsigned max_samples_; int sampling_interval_us_; - CopyablePersistentTraits::CopyablePersistent filter_context_; }; /** @@ -900,6 +896,14 @@ class V8_EXPORT HeapProfiler { * Takes a heap snapshot and returns it. */ const HeapSnapshot* TakeHeapSnapshot( + ActivityControl* control = nullptr, + ObjectNameResolver* global_object_name_resolver = nullptr, + bool treat_global_objects_as_roots = true); + + /** + * Takes a heap snapshot and returns it. + */ + const HeapSnapshot* TakeHeapSnapshotV8_92( ActivityControl* control = nullptr, ObjectNameResolver* global_object_name_resolver = nullptr, bool treat_global_objects_as_roots = true, diff --git a/deps/v8/include/v8.h b/deps/v8/include/v8.h index 1cc78f63b8ee7e..796daba1fb06f5 100644 --- a/deps/v8/include/v8.h +++ b/deps/v8/include/v8.h @@ -1508,7 +1508,7 @@ class V8_EXPORT UnboundScript { */ Local