From a3db2033d4e69db7d634d1b3a2f0c1da0af0d84e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Sat, 2 Oct 2021 09:06:58 +0200 Subject: [PATCH] deps: make V8 9.4 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. Revert "[api] Add API for off-thread code cache deserialization" This reverts commit f888f48e4c65e3ccfd9fd831c71c1832b957c945. Revert "[api] Implement signature checks using instance types" This reverts commit 7df6678c32255ec5a1b1470f1e5a7e56b3b192fa. Revert "[api] Remove deprecated APIs" This reverts commit 390456678a8261827cd9a1b5f0c4dc8e4328af07. PR-URL: https://github.com/nodejs/node/pull/40285 Reviewed-By: Anna Henningsen Reviewed-By: Jiawen Geng --- common.gypi | 2 +- deps/v8/include/v8-internal.h | 18 +- 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 | 460 +++++++++-- deps/v8/src/api/api-natives.cc | 14 +- deps/v8/src/api/api.cc | 718 +++++++++++++----- deps/v8/src/builtins/base.tq | 14 +- deps/v8/src/codegen/compiler.cc | 37 +- deps/v8/src/codegen/compiler.h | 25 +- deps/v8/src/d8/d8-test.cc | 3 +- deps/v8/src/d8/d8.cc | 7 +- deps/v8/src/debug/debug-interface.cc | 4 +- deps/v8/src/diagnostics/objects-debug.cc | 2 - deps/v8/src/diagnostics/objects-printer.cc | 1 - 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/flags/flag-definitions.h | 5 - deps/v8/src/heap/factory.cc | 4 +- deps/v8/src/heap/gc-tracer.cc | 15 - deps/v8/src/heap/heap.cc | 3 - deps/v8/src/heap/local-heap.h | 1 - .../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/objects/instance-type.h | 3 +- deps/v8/src/objects/js-objects.cc | 13 +- deps/v8/src/objects/map.cc | 4 - deps/v8/src/objects/object-list-macros.h | 1 - .../objects/objects-body-descriptors-inl.h | 3 - deps/v8/src/objects/templates-inl.h | 27 +- deps/v8/src/objects/templates.cc | 15 - deps/v8/src/objects/templates.h | 8 +- deps/v8/src/objects/templates.tq | 4 +- deps/v8/src/profiler/cpu-profiler.cc | 19 +- deps/v8/src/profiler/cpu-profiler.h | 20 +- deps/v8/src/profiler/profile-generator.cc | 34 +- 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/snapshot/code-serializer.cc | 304 +++----- deps/v8/src/snapshot/code-serializer.h | 46 +- deps/v8/src/wasm/module-compiler.cc | 2 - deps/v8/test/cctest/cctest.cc | 6 +- deps/v8/test/cctest/heap/test-heap.cc | 79 +- deps/v8/test/cctest/test-api-array-buffer.cc | 189 ++++- deps/v8/test/cctest/test-api.cc | 54 -- deps/v8/test/cctest/test-cpu-profiler.cc | 143 +--- deps/v8/test/cctest/test-heap-profiler.cc | 2 +- deps/v8/test/cctest/test-serialize.cc | 44 +- deps/v8/test/cctest/test-typedarrays.cc | 24 + deps/v8/test/unittests/BUILD.gn | 1 - .../unittests/api/deserialize-unittest.cc | 236 ------ deps/v8/tools/v8heapconst.py | 153 ++-- 61 files changed, 1454 insertions(+), 1525 deletions(-) delete mode 100644 deps/v8/test/unittests/api/deserialize-unittest.cc diff --git a/common.gypi b/common.gypi index c33f4429dbcb55..8120bed999992f 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.11', + 'v8_embedder_string': '-node.12', ##### V8 defaults for Node.js ##### diff --git a/deps/v8/include/v8-internal.h b/deps/v8/include/v8-internal.h index 0222ab2f7e1199..0b95c2cacf01f2 100644 --- a/deps/v8/include/v8-internal.h +++ b/deps/v8/include/v8-internal.h @@ -36,7 +36,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; @@ -188,8 +187,6 @@ V8_EXPORT internal::Isolate* IsolateFromNeverReadOnlySpaceObject(Address obj); // language mode is strict. V8_EXPORT bool ShouldThrowOnError(v8::internal::Isolate* isolate); -V8_EXPORT bool CanHaveInternalField(int instance_type); - /** * This class exports constants and functionality from within v8 that * is necessary to implement inline functions in the v8 api. Don't @@ -236,12 +233,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; @@ -268,9 +261,8 @@ class Internals { static const int kOddballType = 0x43; static const int kForeignType = 0x46; static const int kJSSpecialApiObjectType = 0x410; + static const int kJSApiObjectType = 0x420; static const int kJSObjectType = 0x421; - static const int kFirstJSApiObjectType = 0x422; - static const int kLastJSApiObjectType = 0x80A; static const int kUndefinedOddballKind = 5; static const int kNullOddballKind = 3; @@ -375,12 +367,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 8e664887bec911..eacdaae7f56dcd 100644 --- a/deps/v8/include/v8.h +++ b/deps/v8/include/v8.h @@ -128,7 +128,6 @@ template class PropertyCallbackInfo; template class ReturnValue; namespace internal { -class BackgroundDeserializeTask; class BasicTracedReferenceExtractor; class ExternalString; class FunctionCallbackArguments; @@ -1509,7 +1508,7 @@ class V8_EXPORT UnboundScript { */ Local