From be4ff5ecead3461733ef5b9e1268faac4cfe3185 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 21 Mar 2023 07:17:39 +1100 Subject: [PATCH] Upgrade V8 binaries for 11.1.277.13 version (#373) --- deps/include/cppgc/internal/gc-info.h | 68 +++---- .../include/cppgc/internal/pointer-policies.h | 10 ++ deps/include/cppgc/internal/write-barrier.h | 8 + deps/include/cppgc/visitor.h | 3 +- deps/include/js_protocol.pdl | 11 +- deps/include/libplatform/v8-tracing.h | 4 +- deps/include/v8-array-buffer.h | 41 +++++ deps/include/v8-callbacks.h | 4 + deps/include/v8-cppgc.h | 9 + deps/include/v8-embedder-heap.h | 169 ------------------ deps/include/v8-fast-api-calls.h | 31 +++- deps/include/v8-inspector.h | 25 ++- deps/include/v8-internal.h | 141 +++++++-------- deps/include/v8-isolate.h | 35 ++-- deps/include/v8-local-handle.h | 2 + deps/include/v8-metrics.h | 74 ++++++++ deps/include/v8-platform.h | 12 +- deps/include/v8-profiler.h | 1 + deps/include/v8-script.h | 9 +- deps/include/v8-snapshot.h | 4 +- deps/include/v8-template.h | 4 +- deps/include/v8-traced-handle.h | 15 +- deps/include/v8-version.h | 8 +- deps/include/v8config.h | 43 +++++ deps/v8 | 2 +- deps/v8_version | 2 +- 26 files changed, 399 insertions(+), 336 deletions(-) diff --git a/deps/include/cppgc/internal/gc-info.h b/deps/include/cppgc/internal/gc-info.h index e8f90fed..08ffd411 100644 --- a/deps/include/cppgc/internal/gc-info.h +++ b/deps/include/cppgc/internal/gc-info.h @@ -10,6 +10,7 @@ #include #include "cppgc/internal/finalizer-trait.h" +#include "cppgc/internal/logging.h" #include "cppgc/internal/name-trait.h" #include "cppgc/trace-trait.h" #include "v8config.h" // NOLINT(build/include_directory) @@ -20,12 +21,12 @@ namespace internal { using GCInfoIndex = uint16_t; struct V8_EXPORT EnsureGCInfoIndexTrait final { - // Acquires a new GC info object and returns the index. In addition, also - // updates `registered_index` atomically. + // Acquires a new GC info object and updates `registered_index` with the index + // that identifies that new info accordingly. template - V8_INLINE static GCInfoIndex EnsureIndex( + V8_INLINE static void EnsureIndex( std::atomic& registered_index) { - return EnsureGCInfoIndexTraitDispatch{}(registered_index); + EnsureGCInfoIndexTraitDispatch{}(registered_index); } private: @@ -34,38 +35,32 @@ struct V8_EXPORT EnsureGCInfoIndexTrait final { bool = NameTrait::HasNonHiddenName()> struct EnsureGCInfoIndexTraitDispatch; - static GCInfoIndex EnsureGCInfoIndexPolymorphic(std::atomic&, - TraceCallback, - FinalizationCallback, - NameCallback); - static GCInfoIndex EnsureGCInfoIndexPolymorphic(std::atomic&, - TraceCallback, - FinalizationCallback); - static GCInfoIndex EnsureGCInfoIndexPolymorphic(std::atomic&, - TraceCallback, NameCallback); - static GCInfoIndex EnsureGCInfoIndexPolymorphic(std::atomic&, - TraceCallback); - static GCInfoIndex EnsureGCInfoIndexNonPolymorphic(std::atomic&, - TraceCallback, - FinalizationCallback, - NameCallback); - static GCInfoIndex EnsureGCInfoIndexNonPolymorphic(std::atomic&, - TraceCallback, - FinalizationCallback); - static GCInfoIndex EnsureGCInfoIndexNonPolymorphic(std::atomic&, - TraceCallback, - NameCallback); - static GCInfoIndex EnsureGCInfoIndexNonPolymorphic(std::atomic&, - TraceCallback); + static void V8_PRESERVE_MOST + EnsureGCInfoIndexPolymorphic(std::atomic&, TraceCallback, + FinalizationCallback, NameCallback); + static void V8_PRESERVE_MOST EnsureGCInfoIndexPolymorphic( + std::atomic&, TraceCallback, FinalizationCallback); + static void V8_PRESERVE_MOST EnsureGCInfoIndexPolymorphic( + std::atomic&, TraceCallback, NameCallback); + static void V8_PRESERVE_MOST + EnsureGCInfoIndexPolymorphic(std::atomic&, TraceCallback); + static void V8_PRESERVE_MOST + EnsureGCInfoIndexNonPolymorphic(std::atomic&, TraceCallback, + FinalizationCallback, NameCallback); + static void V8_PRESERVE_MOST EnsureGCInfoIndexNonPolymorphic( + std::atomic&, TraceCallback, FinalizationCallback); + static void V8_PRESERVE_MOST EnsureGCInfoIndexNonPolymorphic( + std::atomic&, TraceCallback, NameCallback); + static void V8_PRESERVE_MOST + EnsureGCInfoIndexNonPolymorphic(std::atomic&, TraceCallback); }; #define DISPATCH(is_polymorphic, has_finalizer, has_non_hidden_name, function) \ template \ struct EnsureGCInfoIndexTrait::EnsureGCInfoIndexTraitDispatch< \ T, is_polymorphic, has_finalizer, has_non_hidden_name> { \ - V8_INLINE GCInfoIndex \ - operator()(std::atomic& registered_index) { \ - return function; \ + V8_INLINE void operator()(std::atomic& registered_index) { \ + function; \ } \ }; @@ -143,9 +138,16 @@ struct GCInfoTrait final { static_assert(sizeof(T), "T must be fully defined"); static std::atomic registered_index; // Uses zero initialization. - const GCInfoIndex index = registered_index.load(std::memory_order_acquire); - return index ? index - : EnsureGCInfoIndexTrait::EnsureIndex(registered_index); + GCInfoIndex index = registered_index.load(std::memory_order_acquire); + if (V8_UNLIKELY(!index)) { + EnsureGCInfoIndexTrait::EnsureIndex(registered_index); + // Slow path call uses V8_PRESERVE_MOST which does not support return + // values (also preserves RAX). Avoid out parameter by just reloading the + // value here which at this point is guaranteed to be set. + index = registered_index.load(std::memory_order_acquire); + CPPGC_DCHECK(index != 0); + } + return index; } }; diff --git a/deps/include/cppgc/internal/pointer-policies.h b/deps/include/cppgc/internal/pointer-policies.h index 8455b3df..e67da040 100644 --- a/deps/include/cppgc/internal/pointer-policies.h +++ b/deps/include/cppgc/internal/pointer-policies.h @@ -34,18 +34,28 @@ struct DijkstraWriteBarrierPolicy { } V8_INLINE static void AssigningBarrier(const void* slot, const void* value) { +#ifdef CPPGC_SLIM_WRITE_BARRIER + if (V8_UNLIKELY(WriteBarrier::IsEnabled())) + WriteBarrier::CombinedWriteBarrierSlow(slot); +#else // !CPPGC_SLIM_WRITE_BARRIER WriteBarrier::Params params; const WriteBarrier::Type type = WriteBarrier::GetWriteBarrierType(slot, value, params); WriteBarrier(type, params, slot, value); +#endif // !CPPGC_SLIM_WRITE_BARRIER } V8_INLINE static void AssigningBarrier(const void* slot, MemberStorage storage) { +#ifdef CPPGC_SLIM_WRITE_BARRIER + if (V8_UNLIKELY(WriteBarrier::IsEnabled())) + WriteBarrier::CombinedWriteBarrierSlow(slot); +#else // !CPPGC_SLIM_WRITE_BARRIER WriteBarrier::Params params; const WriteBarrier::Type type = WriteBarrier::GetWriteBarrierType(slot, storage, params); WriteBarrier(type, params, slot, storage.Load()); +#endif // !CPPGC_SLIM_WRITE_BARRIER } private: diff --git a/deps/include/cppgc/internal/write-barrier.h b/deps/include/cppgc/internal/write-barrier.h index 37bc5c97..80c6ee33 100644 --- a/deps/include/cppgc/internal/write-barrier.h +++ b/deps/include/cppgc/internal/write-barrier.h @@ -79,6 +79,14 @@ class V8_EXPORT WriteBarrier final { // Returns the required write barrier for a given `value`. static V8_INLINE Type GetWriteBarrierType(const void* value, Params& params); +#ifdef CPPGC_SLIM_WRITE_BARRIER + // A write barrier that combines `GenerationalBarrier()` and + // `DijkstraMarkingBarrier()`. We only pass a single parameter here to clobber + // as few registers as possible. + static V8_NOINLINE void V8_PRESERVE_MOST + CombinedWriteBarrierSlow(const void* slot); +#endif // CPPGC_SLIM_WRITE_BARRIER + static V8_INLINE void DijkstraMarkingBarrier(const Params& params, const void* object); static V8_INLINE void DijkstraMarkingBarrierRange( diff --git a/deps/include/cppgc/visitor.h b/deps/include/cppgc/visitor.h index f7ebc1d0..704aabcd 100644 --- a/deps/include/cppgc/visitor.h +++ b/deps/include/cppgc/visitor.h @@ -229,7 +229,8 @@ class V8_EXPORT Visitor { } /** - * Trace method for retaining containers weakly. + * Trace method for retaining containers weakly. Note that weak containers + * should emit write barriers. * * \param object reference to the container. * \param callback to be invoked. diff --git a/deps/include/js_protocol.pdl b/deps/include/js_protocol.pdl index 6efcf787..d4102f5c 100644 --- a/deps/include/js_protocol.pdl +++ b/deps/include/js_protocol.pdl @@ -1402,6 +1402,13 @@ domain Runtime optional string objectGroup # Whether to throw an exception if side effect cannot be ruled out during evaluation. experimental optional boolean throwOnSideEffect + # An alternative way to specify the execution context to call function on. + # Compared to contextId that may be reused across processes, this is guaranteed to be + # system-unique, so it can be used to prevent accidental function call + # in context different than intended (e.g. as a result of navigation across process + # boundaries). + # This is mutually exclusive with `executionContextId`. + experimental optional string uniqueContextId # Whether the result should contain `webDriverValue`, serialized according to # https://w3c.github.io/webdriver-bidi. This is mutually exclusive with `returnByValue`, but # resulting `objectId` is still provided. @@ -1734,7 +1741,9 @@ domain Runtime event executionContextDestroyed parameters # Id of the destroyed context - ExecutionContextId executionContextId + deprecated ExecutionContextId executionContextId + # Unique Id of the destroyed context + experimental string executionContextUniqueId # Issued when all executionContexts were cleared in browser event executionContextsCleared diff --git a/deps/include/libplatform/v8-tracing.h b/deps/include/libplatform/v8-tracing.h index 12489327..6039a9c5 100644 --- a/deps/include/libplatform/v8-tracing.h +++ b/deps/include/libplatform/v8-tracing.h @@ -282,12 +282,12 @@ class V8_PLATFORM_EXPORT TracingController const char* name, uint64_t handle) override; static const char* GetCategoryGroupName(const uint8_t* category_enabled_flag); -#endif // !defined(V8_USE_PERFETTO) void AddTraceStateObserver( v8::TracingController::TraceStateObserver* observer) override; void RemoveTraceStateObserver( v8::TracingController::TraceStateObserver* observer) override; +#endif // !defined(V8_USE_PERFETTO) void StartTracing(TraceConfig* trace_config); void StopTracing(); @@ -307,7 +307,6 @@ class V8_PLATFORM_EXPORT TracingController std::unique_ptr mutex_; std::unique_ptr trace_config_; std::atomic_bool recording_{false}; - std::unordered_set observers_; #if defined(V8_USE_PERFETTO) std::ostream* output_stream_ = nullptr; @@ -316,6 +315,7 @@ class V8_PLATFORM_EXPORT TracingController TraceEventListener* listener_for_testing_ = nullptr; std::unique_ptr tracing_session_; #else // !defined(V8_USE_PERFETTO) + std::unordered_set observers_; std::unique_ptr trace_buffer_; #endif // !defined(V8_USE_PERFETTO) diff --git a/deps/include/v8-array-buffer.h b/deps/include/v8-array-buffer.h index 841bd02a..804fc42c 100644 --- a/deps/include/v8-array-buffer.h +++ b/deps/include/v8-array-buffer.h @@ -53,12 +53,28 @@ class V8_EXPORT BackingStore : public v8::internal::BackingStoreBase { */ size_t ByteLength() const; + /** + * The maximum length (in bytes) that this backing store may grow to. + * + * If this backing store was created for a resizable ArrayBuffer or a growable + * SharedArrayBuffer, it is >= ByteLength(). Otherwise it is == + * ByteLength(). + */ + size_t MaxByteLength() const; + /** * Indicates whether the backing store was created for an ArrayBuffer or * a SharedArrayBuffer. */ bool IsShared() const; + /** + * Indicates whether the backing store was created for a resizable ArrayBuffer + * or a growable SharedArrayBuffer, and thus may be resized by user JavaScript + * code. + */ + bool IsResizableByUserJavaScript() const; + /** * Prevent implicit instantiation of operator delete with size_t argument. * The size_t argument would be incorrect because ptr points to the @@ -189,6 +205,11 @@ class V8_EXPORT ArrayBuffer : public Object { */ size_t ByteLength() const; + /** + * Maximum length in bytes. + */ + size_t MaxByteLength() const; + /** * Create a new ArrayBuffer. Allocate |byte_length| bytes. * Allocated memory will be owned by a created ArrayBuffer and @@ -235,6 +256,21 @@ class V8_EXPORT ArrayBuffer : public Object { void* data, size_t byte_length, v8::BackingStore::DeleterCallback deleter, void* deleter_data); + /** + * Returns a new resizable standalone BackingStore that is allocated using the + * array buffer allocator of the isolate. The result can be later passed to + * ArrayBuffer::New. + * + * |byte_length| must be <= |max_byte_length|. + * + * This function is usable without an isolate. Unlike |NewBackingStore| calls + * with an isolate, GCs cannot be triggered, and there are no + * retries. Allocation failure will cause the function to crash with an + * out-of-memory error. + */ + static std::unique_ptr NewResizableBackingStore( + size_t byte_length, size_t max_byte_length); + /** * Returns true if this ArrayBuffer may be detached. */ @@ -392,6 +428,11 @@ class V8_EXPORT SharedArrayBuffer : public Object { */ size_t ByteLength() const; + /** + * Maximum length in bytes. + */ + size_t MaxByteLength() const; + /** * Create a new SharedArrayBuffer. Allocate |byte_length| bytes. * Allocated memory will be owned by a created SharedArrayBuffer and diff --git a/deps/include/v8-callbacks.h b/deps/include/v8-callbacks.h index 0ffdfb66..f3e96c37 100644 --- a/deps/include/v8-callbacks.h +++ b/deps/include/v8-callbacks.h @@ -328,6 +328,10 @@ using WasmSimdEnabledCallback = bool (*)(Local context); // --- Callback for checking if WebAssembly exceptions are enabled --- using WasmExceptionsEnabledCallback = bool (*)(Local context); +// --- Callback for checking if WebAssembly GC is enabled --- +// If the callback returns true, it will also enable Wasm stringrefs. +using WasmGCEnabledCallback = bool (*)(Local context); + // --- Callback for checking if the SharedArrayBuffer constructor is enabled --- using SharedArrayBufferConstructorEnabledCallback = bool (*)(Local context); diff --git a/deps/include/v8-cppgc.h b/deps/include/v8-cppgc.h index 139af8fd..4a457027 100644 --- a/deps/include/v8-cppgc.h +++ b/deps/include/v8-cppgc.h @@ -77,6 +77,15 @@ struct WrapperDescriptor final { }; struct V8_EXPORT CppHeapCreateParams { + CppHeapCreateParams( + std::vector> custom_spaces, + WrapperDescriptor wrapper_descriptor) + : custom_spaces(std::move(custom_spaces)), + wrapper_descriptor(wrapper_descriptor) {} + + CppHeapCreateParams(const CppHeapCreateParams&) = delete; + CppHeapCreateParams& operator=(const CppHeapCreateParams&) = delete; + std::vector> custom_spaces; WrapperDescriptor wrapper_descriptor; /** diff --git a/deps/include/v8-embedder-heap.h b/deps/include/v8-embedder-heap.h index f994cdfd..9e2e3ef5 100644 --- a/deps/include/v8-embedder-heap.h +++ b/deps/include/v8-embedder-heap.h @@ -5,27 +5,14 @@ #ifndef INCLUDE_V8_EMBEDDER_HEAP_H_ #define INCLUDE_V8_EMBEDDER_HEAP_H_ -#include -#include - -#include -#include - -#include "cppgc/common.h" -#include "v8-local-handle.h" // NOLINT(build/include_directory) #include "v8-traced-handle.h" // NOLINT(build/include_directory) #include "v8config.h" // NOLINT(build/include_directory) namespace v8 { -class Data; class Isolate; class Value; -namespace internal { -class LocalEmbedderHeapTracer; -} // namespace internal - /** * Handler for embedder roots on non-unified heap garbage collections. */ @@ -62,162 +49,6 @@ class V8_EXPORT EmbedderRootsHandler { virtual void ResetRoot(const v8::TracedReference& handle) = 0; }; -/** - * Interface for tracing through the embedder heap. During a V8 garbage - * collection, V8 collects hidden fields of all potential wrappers, and at the - * end of its marking phase iterates the collection and asks the embedder to - * trace through its heap and use reporter to report each JavaScript object - * reachable from any of the given wrappers. - */ -class V8_EXPORT -// GCC doesn't like combining __attribute__(()) with [[deprecated]]. -#ifdef __clang__ -V8_DEPRECATED("Use CppHeap when working with v8::TracedReference.") -#endif // __clang__ - EmbedderHeapTracer { - public: - using EmbedderStackState = cppgc::EmbedderStackState; - - enum TraceFlags : uint64_t { - kNoFlags = 0, - kReduceMemory = 1 << 0, - kForced = 1 << 2, - }; - - /** - * Interface for iterating through |TracedReference| handles. - */ - class V8_EXPORT TracedGlobalHandleVisitor { - public: - virtual ~TracedGlobalHandleVisitor() = default; - virtual void VisitTracedReference(const TracedReference& handle) {} - }; - - /** - * Summary of a garbage collection cycle. See |TraceEpilogue| on how the - * summary is reported. - */ - struct TraceSummary { - /** - * Time spent managing the retained memory in milliseconds. This can e.g. - * include the time tracing through objects in the embedder. - */ - double time = 0.0; - - /** - * Memory retained by the embedder through the |EmbedderHeapTracer| - * mechanism in bytes. - */ - size_t allocated_size = 0; - }; - - virtual ~EmbedderHeapTracer() = default; - - /** - * Iterates all |TracedReference| handles created for the |v8::Isolate| the - * tracer is attached to. - */ - void IterateTracedGlobalHandles(TracedGlobalHandleVisitor* visitor); - - /** - * Called by the embedder to set the start of the stack which is e.g. used by - * V8 to determine whether handles are used from stack or heap. - */ - void SetStackStart(void* stack_start); - - /** - * Called by v8 to register internal fields of found wrappers. - * - * The embedder is expected to store them somewhere and trace reachable - * wrappers from them when called through |AdvanceTracing|. - */ - virtual void RegisterV8References( - const std::vector>& embedder_fields) = 0; - - void RegisterEmbedderReference(const BasicTracedReference& ref); - - /** - * Called at the beginning of a GC cycle. - */ - virtual void TracePrologue(TraceFlags flags) {} - - /** - * Called to advance tracing in the embedder. - * - * The embedder is expected to trace its heap starting from wrappers reported - * by RegisterV8References method, and report back all reachable wrappers. - * Furthermore, the embedder is expected to stop tracing by the given - * deadline. A deadline of infinity means that tracing should be finished. - * - * Returns |true| if tracing is done, and false otherwise. - */ - virtual bool AdvanceTracing(double deadline_in_ms) = 0; - - /* - * Returns true if there no more tracing work to be done (see AdvanceTracing) - * and false otherwise. - */ - virtual bool IsTracingDone() = 0; - - /** - * Called at the end of a GC cycle. - * - * Note that allocation is *not* allowed within |TraceEpilogue|. Can be - * overriden to fill a |TraceSummary| that is used by V8 to schedule future - * garbage collections. - */ - virtual void TraceEpilogue(TraceSummary* trace_summary) {} - - /** - * Called upon entering the final marking pause. No more incremental marking - * steps will follow this call. - */ - virtual void EnterFinalPause(EmbedderStackState stack_state) = 0; - - /* - * Called by the embedder to request immediate finalization of the currently - * running tracing phase that has been started with TracePrologue and not - * yet finished with TraceEpilogue. - * - * Will be a noop when currently not in tracing. - * - * This is an experimental feature. - */ - void FinalizeTracing(); - - /** - * See documentation on EmbedderRootsHandler. - */ - virtual bool IsRootForNonTracingGC( - const v8::TracedReference& handle); - - /** - * See documentation on EmbedderRootsHandler. - */ - virtual void ResetHandleInNonTracingGC( - const v8::TracedReference& handle); - - /* - * Called by the embedder to signal newly allocated or freed memory. Not bound - * to tracing phases. Embedders should trade off when increments are reported - * as V8 may consult global heuristics on whether to trigger garbage - * collection on this change. - */ - void IncreaseAllocatedSize(size_t bytes); - void DecreaseAllocatedSize(size_t bytes); - - /* - * Returns the v8::Isolate this tracer is attached too and |nullptr| if it - * is not attached to any v8::Isolate. - */ - v8::Isolate* isolate() const { return v8_isolate_; } - - protected: - v8::Isolate* v8_isolate_ = nullptr; - - friend class internal::LocalEmbedderHeapTracer; -}; - } // namespace v8 #endif // INCLUDE_V8_EMBEDDER_HEAP_H_ diff --git a/deps/include/v8-fast-api-calls.h b/deps/include/v8-fast-api-calls.h index 1826f133..0fe7cd24 100644 --- a/deps/include/v8-fast-api-calls.h +++ b/deps/include/v8-fast-api-calls.h @@ -247,7 +247,9 @@ class CTypeInfo { kUint64, kFloat32, kFloat64, + kPointer, kV8Value, + kSeqOneByteString, kApiObject, // This will be deprecated once all users have // migrated from v8::ApiObject to v8::Local. kAny, // This is added to enable untyped representation of fast @@ -379,6 +381,11 @@ struct FastApiArrayBuffer { size_t byte_length; }; +struct FastOneByteString { + const char* data; + uint32_t length; +}; + class V8_EXPORT CFunctionInfo { public: // Construct a struct to hold a CFunction's type information. @@ -429,6 +436,7 @@ struct AnyCType { uint64_t uint64_value; float float_value; double double_value; + void* pointer_value; Local object_value; Local sequence_value; const FastApiTypedArray* uint8_ta_value; @@ -438,6 +446,7 @@ struct AnyCType { const FastApiTypedArray* uint64_ta_value; const FastApiTypedArray* float_ta_value; const FastApiTypedArray* double_ta_value; + const FastOneByteString* string_value; FastApiCallbackOptions* options_value; }; }; @@ -613,8 +622,9 @@ class CFunctionInfoImpl : public CFunctionInfo { kReturnType == CTypeInfo::Type::kUint32 || kReturnType == CTypeInfo::Type::kFloat32 || kReturnType == CTypeInfo::Type::kFloat64 || + kReturnType == CTypeInfo::Type::kPointer || kReturnType == CTypeInfo::Type::kAny, - "64-bit int and api object values are not currently " + "64-bit int, string and api object values are not currently " "supported return types."); } @@ -651,13 +661,14 @@ struct CTypeInfoTraits {}; #define PRIMITIVE_C_TYPES(V) \ V(bool, kBool) \ + V(uint8_t, kUint8) \ V(int32_t, kInt32) \ V(uint32_t, kUint32) \ V(int64_t, kInt64) \ V(uint64_t, kUint64) \ V(float, kFloat32) \ V(double, kFloat64) \ - V(uint8_t, kUint8) + V(void*, kPointer) // Same as above, but includes deprecated types for compatibility. #define ALL_C_TYPES(V) \ @@ -691,13 +702,13 @@ PRIMITIVE_C_TYPES(DEFINE_TYPE_INFO_TRAITS) }; #define TYPED_ARRAY_C_TYPES(V) \ + V(uint8_t, kUint8) \ V(int32_t, kInt32) \ V(uint32_t, kUint32) \ V(int64_t, kInt64) \ V(uint64_t, kUint64) \ V(float, kFloat32) \ - V(double, kFloat64) \ - V(uint8_t, kUint8) + V(double, kFloat64) TYPED_ARRAY_C_TYPES(SPECIALIZE_GET_TYPE_INFO_HELPER_FOR_TA) @@ -735,6 +746,18 @@ struct TypeInfoHelper { } }; +template <> +struct TypeInfoHelper { + static constexpr CTypeInfo::Flags Flags() { return CTypeInfo::Flags::kNone; } + + static constexpr CTypeInfo::Type Type() { + return CTypeInfo::Type::kSeqOneByteString; + } + static constexpr CTypeInfo::SequenceType SequenceType() { + return CTypeInfo::SequenceType::kScalar; + } +}; + #define STATIC_ASSERT_IMPLIES(COND, ASSERTION, MSG) \ static_assert(((COND) == 0) || (ASSERTION), MSG) diff --git a/deps/include/v8-inspector.h b/deps/include/v8-inspector.h index aa5a044a..563ad196 100644 --- a/deps/include/v8-inspector.h +++ b/deps/include/v8-inspector.h @@ -32,19 +32,19 @@ namespace Debugger { namespace API { class SearchMatch; } -} +} // namespace Debugger namespace Runtime { namespace API { class RemoteObject; class StackTrace; class StackTraceId; -} -} +} // namespace API +} // namespace Runtime namespace Schema { namespace API { class Domain; } -} +} // namespace Schema } // namespace protocol class V8_EXPORT StringView { @@ -134,6 +134,13 @@ class V8_EXPORT V8DebuggerId { int64_t m_second = 0; }; +struct V8_EXPORT V8StackFrame { + StringView sourceURL; + StringView functionName; + int lineNumber; + int columnNumber; +}; + class V8_EXPORT V8StackTrace { public: virtual StringView firstNonEmptySourceURL() const = 0; @@ -151,6 +158,8 @@ class V8_EXPORT V8StackTrace { // Safe to pass between threads, drops async chain. virtual std::unique_ptr clone() = 0; + + virtual std::vector frames() const = 0; }; class V8_EXPORT V8InspectorSession { @@ -203,6 +212,9 @@ class V8_EXPORT V8InspectorSession { std::unique_ptr* objectGroup) = 0; virtual void releaseObjectGroup(StringView) = 0; virtual void triggerPreciseCoverageDeltaUpdate(StringView occasion) = 0; + + // Prepare for shutdown (disables debugger pausing, etc.). + virtual void stop() = 0; }; class V8_EXPORT WebDriverValue { @@ -365,9 +377,12 @@ class V8_EXPORT V8Inspector { virtual void flushProtocolNotifications() = 0; }; enum ClientTrustLevel { kUntrusted, kFullyTrusted }; + enum SessionPauseState { kWaitingForDebugger, kNotWaitingForDebugger }; + // TODO(chromium:1352175): remove default value once downstream change lands. virtual std::unique_ptr connect( int contextGroupId, Channel*, StringView state, - ClientTrustLevel client_trust_level) { + ClientTrustLevel client_trust_level, + SessionPauseState = kNotWaitingForDebugger) { return nullptr; } diff --git a/deps/include/v8-internal.h b/deps/include/v8-internal.h index 704e89e2..53837aa5 100644 --- a/deps/include/v8-internal.h +++ b/deps/include/v8-internal.h @@ -242,6 +242,7 @@ static_assert(1ULL << (64 - kBoundedSizeShift) == #ifdef V8_COMPRESS_POINTERS +#ifdef V8_TARGET_OS_ANDROID // The size of the virtual memory reservation for an external pointer table. // This determines the maximum number of entries in a table. Using a maximum // size allows omitting bounds checks on table accesses if the indices are @@ -249,14 +250,18 @@ static_assert(1ULL << (64 - kBoundedSizeShift) == // value must be a power of two. static const size_t kExternalPointerTableReservationSize = 512 * MB; -// The maximum number of entries in an external pointer table. -static const size_t kMaxExternalPointers = - kExternalPointerTableReservationSize / kApiSystemPointerSize; - // The external pointer table indices stored in HeapObjects as external // pointers are shifted to the left by this amount to guarantee that they are // smaller than the maximum table size. static const uint32_t kExternalPointerIndexShift = 6; +#else +static const size_t kExternalPointerTableReservationSize = 1024 * MB; +static const uint32_t kExternalPointerIndexShift = 5; +#endif // V8_TARGET_OS_ANDROID + +// The maximum number of entries in an external pointer table. +static const size_t kMaxExternalPointers = + kExternalPointerTableReservationSize / kApiSystemPointerSize; static_assert((1 << (32 - kExternalPointerIndexShift)) == kMaxExternalPointers, "kExternalPointerTableReservationSize and " "kExternalPointerIndexShift don't match"); @@ -345,6 +350,14 @@ using ExternalPointer_t = Address; // that the Embedder is not using this byte (really only this one bit) for any // other purpose. This bit also does not collide with the memory tagging // extension (MTE) which would use bits [56, 60). +// +// External pointer tables are also available even when the sandbox is off but +// pointer compression is on. In that case, the mechanism can be used to easy +// alignment requirements as it turns unaligned 64-bit raw pointers into +// aligned 32-bit indices. To "opt-in" to the external pointer table mechanism +// for this purpose, instead of using the ExternalPointer accessors one needs to +// use ExternalPointerHandles directly and use them to access the pointers in an +// ExternalPointerTable. constexpr uint64_t kExternalPointerMarkBit = 1ULL << 62; constexpr uint64_t kExternalPointerTagMask = 0x40ff000000000000; constexpr uint64_t kExternalPointerTagShift = 48; @@ -367,70 +380,58 @@ constexpr uint64_t kAllExternalPointerTypeTags[] = { 0b11001100, 0b11010001, 0b11010010, 0b11010100, 0b11011000, 0b11100001, 0b11100010, 0b11100100, 0b11101000, 0b11110000}; +#define TAG(i) \ + ((kAllExternalPointerTypeTags[i] << kExternalPointerTagShift) | \ + kExternalPointerMarkBit) + // clang-format off -// New entries should be added with state "sandboxed". + // When adding new tags, please ensure that the code using these tags is // "substitution-safe", i.e. still operate safely if external pointers of the // same type are swapped by an attacker. See comment above for more details. -#define TAG(i) (kAllExternalPointerTypeTags[i]) // Shared external pointers are owned by the shared Isolate and stored in the // shared external pointer table associated with that Isolate, where they can // be accessed from multiple threads at the same time. The objects referenced // in this way must therefore always be thread-safe. -#define SHARED_EXTERNAL_POINTER_TAGS(V) \ - V(kFirstSharedTag, sandboxed, TAG(0)) \ - V(kWaiterQueueNodeTag, sandboxed, TAG(0)) \ - V(kExternalStringResourceTag, sandboxed, TAG(1)) \ - V(kExternalStringResourceDataTag, sandboxed, TAG(2)) \ - V(kLastSharedTag, sandboxed, TAG(2)) +#define SHARED_EXTERNAL_POINTER_TAGS(V) \ + V(kFirstSharedTag, TAG(0)) \ + V(kWaiterQueueNodeTag, TAG(0)) \ + V(kExternalStringResourceTag, TAG(1)) \ + V(kExternalStringResourceDataTag, TAG(2)) \ + V(kLastSharedTag, TAG(2)) // External pointers using these tags are kept in a per-Isolate external // pointer table and can only be accessed when this Isolate is active. -#define PER_ISOLATE_EXTERNAL_POINTER_TAGS(V) \ - V(kForeignForeignAddressTag, sandboxed, TAG(10)) \ - V(kNativeContextMicrotaskQueueTag, sandboxed, TAG(11)) \ - V(kEmbedderDataSlotPayloadTag, sandboxed, TAG(12)) \ - V(kExternalObjectValueTag, sandboxed, TAG(13)) \ - V(kCallHandlerInfoCallbackTag, sandboxed, TAG(14)) \ - V(kAccessorInfoGetterTag, sandboxed, TAG(15)) \ - V(kAccessorInfoSetterTag, sandboxed, TAG(16)) \ - V(kWasmInternalFunctionCallTargetTag, sandboxed, TAG(17)) \ - V(kWasmTypeInfoNativeTypeTag, sandboxed, TAG(18)) \ - V(kWasmExportedFunctionDataSignatureTag, sandboxed, TAG(19)) \ - V(kWasmContinuationJmpbufTag, sandboxed, TAG(20)) +#define PER_ISOLATE_EXTERNAL_POINTER_TAGS(V) \ + V(kForeignForeignAddressTag, TAG(10)) \ + V(kNativeContextMicrotaskQueueTag, TAG(11)) \ + V(kEmbedderDataSlotPayloadTag, TAG(12)) \ +/* This tag essentially stands for a `void*` pointer in the V8 API, and */ \ +/* it is the Embedder's responsibility to ensure type safety (against */ \ +/* substitution) and lifetime validity of these objects. */ \ + V(kExternalObjectValueTag, TAG(13)) \ + V(kCallHandlerInfoCallbackTag, TAG(14)) \ + V(kAccessorInfoGetterTag, TAG(15)) \ + V(kAccessorInfoSetterTag, TAG(16)) \ + V(kWasmInternalFunctionCallTargetTag, TAG(17)) \ + V(kWasmTypeInfoNativeTypeTag, TAG(18)) \ + V(kWasmExportedFunctionDataSignatureTag, TAG(19)) \ + V(kWasmContinuationJmpbufTag, TAG(20)) \ + V(kArrayBufferExtensionTag, TAG(21)) // All external pointer tags. #define ALL_EXTERNAL_POINTER_TAGS(V) \ SHARED_EXTERNAL_POINTER_TAGS(V) \ PER_ISOLATE_EXTERNAL_POINTER_TAGS(V) -// When the sandbox is enabled, external pointers marked as "sandboxed" above -// use the external pointer table (i.e. are sandboxed). This allows a gradual -// rollout of external pointer sandboxing. If the sandbox is off, no external -// pointers are sandboxed. -// -// Sandboxed external pointer tags are available when compressing pointers even -// when the sandbox is off. Some tags (e.g. kWaiterQueueNodeTag) are used -// manually with the external pointer table even when the sandbox is off to ease -// alignment requirements. -#define sandboxed(X) (X << kExternalPointerTagShift) | kExternalPointerMarkBit -#define unsandboxed(X) kUnsandboxedExternalPointerTag -#if defined(V8_COMPRESS_POINTERS) -#define EXTERNAL_POINTER_TAG_ENUM(Name, State, Bits) Name = State(Bits), -#else -#define EXTERNAL_POINTER_TAG_ENUM(Name, State, Bits) Name = unsandboxed(Bits), -#endif - +#define EXTERNAL_POINTER_TAG_ENUM(Name, Tag) Name = Tag, #define MAKE_TAG(HasMarkBit, TypeTag) \ ((static_cast(TypeTag) << kExternalPointerTagShift) | \ (HasMarkBit ? kExternalPointerMarkBit : 0)) enum ExternalPointerTag : uint64_t { // Empty tag value. Mostly used as placeholder. kExternalPointerNullTag = MAKE_TAG(0, 0b00000000), - // Tag to use for unsandboxed external pointers, which are still stored as - // raw pointers on the heap. - kUnsandboxedExternalPointerTag = MAKE_TAG(0, 0b00000000), // External pointer tag that will match any external pointer. Use with care! kAnyExternalPointerTag = MAKE_TAG(1, 0b11111111), // The free entry tag has all type bits set so every type check with a @@ -444,20 +445,11 @@ enum ExternalPointerTag : uint64_t { }; #undef MAKE_TAG -#undef unsandboxed -#undef sandboxed #undef TAG #undef EXTERNAL_POINTER_TAG_ENUM // clang-format on -// True if the external pointer is sandboxed and so must be referenced through -// an external pointer table. -V8_INLINE static constexpr bool IsSandboxedExternalPointerType( - ExternalPointerTag tag) { - return tag != kUnsandboxedExternalPointerTag; -} - // True if the external pointer must be accessed from the shared isolate's // external pointer table. V8_INLINE static constexpr bool IsSharedExternalPointerType( @@ -466,12 +458,10 @@ V8_INLINE static constexpr bool IsSharedExternalPointerType( } // Sanity checks. -#define CHECK_SHARED_EXTERNAL_POINTER_TAGS(Tag, ...) \ - static_assert(!IsSandboxedExternalPointerType(Tag) || \ - IsSharedExternalPointerType(Tag)); +#define CHECK_SHARED_EXTERNAL_POINTER_TAGS(Tag, ...) \ + static_assert(IsSharedExternalPointerType(Tag)); #define CHECK_NON_SHARED_EXTERNAL_POINTER_TAGS(Tag, ...) \ - static_assert(!IsSandboxedExternalPointerType(Tag) || \ - !IsSharedExternalPointerType(Tag)); + static_assert(!IsSharedExternalPointerType(Tag)); SHARED_EXTERNAL_POINTER_TAGS(CHECK_SHARED_EXTERNAL_POINTER_TAGS) PER_ISOLATE_EXTERNAL_POINTER_TAGS(CHECK_NON_SHARED_EXTERNAL_POINTER_TAGS) @@ -544,7 +534,7 @@ class Internals { static const int kVariousBooleanFlagsOffset = kIsolateStackGuardOffset + kStackGuardSize; static const int kBuiltinTier0EntryTableOffset = - kVariousBooleanFlagsOffset + kApiSystemPointerSize; + kVariousBooleanFlagsOffset + 8; static const int kBuiltinTier0TableOffset = kBuiltinTier0EntryTableOffset + kBuiltinTier0EntryTableSize; static const int kIsolateEmbedderDataOffset = @@ -792,24 +782,23 @@ class Internals { V8_INLINE static internal::Address ReadExternalPointerField( v8::Isolate* isolate, internal::Address heap_object_ptr, int offset) { #ifdef V8_ENABLE_SANDBOX - if (IsSandboxedExternalPointerType(tag)) { - // See src/sandbox/external-pointer-table-inl.h. Logic duplicated here so - // it can be inlined and doesn't require an additional call. - internal::Address* table = - IsSharedExternalPointerType(tag) - ? GetSharedExternalPointerTableBase(isolate) - : GetExternalPointerTableBase(isolate); - internal::ExternalPointerHandle handle = - ReadRawField(heap_object_ptr, offset); - uint32_t index = handle >> kExternalPointerIndexShift; - std::atomic* ptr = - reinterpret_cast*>(&table[index]); - internal::Address entry = - std::atomic_load_explicit(ptr, std::memory_order_relaxed); - return entry & ~tag; - } -#endif + static_assert(tag != kExternalPointerNullTag); + // See src/sandbox/external-pointer-table-inl.h. Logic duplicated here so + // it can be inlined and doesn't require an additional call. + internal::Address* table = IsSharedExternalPointerType(tag) + ? GetSharedExternalPointerTableBase(isolate) + : GetExternalPointerTableBase(isolate); + internal::ExternalPointerHandle handle = + ReadRawField(heap_object_ptr, offset); + uint32_t index = handle >> kExternalPointerIndexShift; + std::atomic* ptr = + reinterpret_cast*>(&table[index]); + internal::Address entry = + std::atomic_load_explicit(ptr, std::memory_order_relaxed); + return entry & ~tag; +#else return ReadRawField
(heap_object_ptr, offset); +#endif // V8_ENABLE_SANDBOX } #ifdef V8_COMPRESS_POINTERS diff --git a/deps/include/v8-isolate.h b/deps/include/v8-isolate.h index e9f53197..4571b2c3 100644 --- a/deps/include/v8-isolate.h +++ b/deps/include/v8-isolate.h @@ -233,7 +233,7 @@ class V8_EXPORT Isolate { * Explicitly specify a startup snapshot blob. The embedder owns the blob. * The embedder *must* ensure that the snapshot is from a trusted source. */ - StartupData* snapshot_blob = nullptr; + const StartupData* snapshot_blob = nullptr; /** * Enables the host application to provide a mechanism for recording @@ -537,6 +537,7 @@ class V8_EXPORT Isolate { kTurboFanOsrCompileStarted = 115, kAsyncStackTaggingCreateTaskCall = 116, kDurationFormat = 117, + kInvalidatedNumberStringPrototypeNoReplaceProtector = 118, // If you add new values here, you'll also need to update Chromium's: // web_feature.mojom, use_counter_callback.cc, and enums.xml. V8 changes to @@ -924,27 +925,10 @@ class V8_EXPORT Isolate { void RemoveGCPrologueCallback(GCCallbackWithData, void* data = nullptr); void RemoveGCPrologueCallback(GCCallback callback); - START_ALLOW_USE_DEPRECATED() - /** - * Sets the embedder heap tracer for the isolate. - * SetEmbedderHeapTracer cannot be used simultaneously with AttachCppHeap. - */ - void SetEmbedderHeapTracer(EmbedderHeapTracer* tracer); - - /* - * Gets the currently active heap tracer for the isolate that was set with - * SetEmbedderHeapTracer. - */ - EmbedderHeapTracer* GetEmbedderHeapTracer(); - END_ALLOW_USE_DEPRECATED() - /** * Sets an embedder roots handle that V8 should consider when performing - * non-unified heap garbage collections. - * - * Using only EmbedderHeapTracer automatically sets up a default handler. - * The intended use case is for setting a custom handler after invoking - * `AttachCppHeap()`. + * non-unified heap garbage collections. The intended use case is for setting + * a custom handler after invoking `AttachCppHeap()`. * * V8 does not take ownership of the handler. */ @@ -955,8 +939,6 @@ class V8_EXPORT Isolate { * embedder maintains ownership of the CppHeap. At most one C++ heap can be * attached to V8. * - * AttachCppHeap cannot be used simultaneously with SetEmbedderHeapTracer. - * * Multi-threaded use requires the use of v8::Locker/v8::Unlocker, see * CppHeap. */ @@ -1346,11 +1328,13 @@ class V8_EXPORT Isolate { * V8 uses this notification to guide heuristics which may result in a * smaller memory footprint at the cost of reduced runtime performance. */ + V8_DEPRECATED("Use IsolateInBackgroundNotification() instead") void EnableMemorySavingsMode(); /** * Optional notification which will disable the memory savings mode. */ + V8_DEPRECATED("Use IsolateInBackgroundNotification() instead") void DisableMemorySavingsMode(); /** @@ -1530,6 +1514,13 @@ class V8_EXPORT Isolate { V8_DEPRECATED("Wasm exceptions are always enabled") void SetWasmExceptionsEnabledCallback(WasmExceptionsEnabledCallback callback); + /** + * Register callback to control whehter Wasm GC is enabled. + * The callback overwrites the value of the flag. + * If the callback returns true, it will also enable Wasm stringrefs. + */ + void SetWasmGCEnabledCallback(WasmGCEnabledCallback callback); + void SetSharedArrayBufferConstructorEnabledCallback( SharedArrayBufferConstructorEnabledCallback callback); diff --git a/deps/include/v8-local-handle.h b/deps/include/v8-local-handle.h index cbf87f94..633c5633 100644 --- a/deps/include/v8-local-handle.h +++ b/deps/include/v8-local-handle.h @@ -53,6 +53,7 @@ class Utils; namespace internal { template class CustomArguments; +class SamplingHeapProfiler; } // namespace internal namespace api_internal { @@ -313,6 +314,7 @@ class Local { friend class BasicTracedReference; template friend class TracedReference; + friend class v8::internal::SamplingHeapProfiler; explicit V8_INLINE Local(T* that) : val_(that) {} V8_INLINE static Local New(Isolate* isolate, T* that) { diff --git a/deps/include/v8-metrics.h b/deps/include/v8-metrics.h index 887012ac..418531e2 100644 --- a/deps/include/v8-metrics.h +++ b/deps/include/v8-metrics.h @@ -12,6 +12,7 @@ #include "v8-internal.h" // NOLINT(build/include_directory) #include "v8-local-handle.h" // NOLINT(build/include_directory) +#include "v8config.h" // NOLINT(build/include_directory) namespace v8 { @@ -96,16 +97,88 @@ struct GarbageCollectionYoungCycle { }; struct WasmModuleDecoded { + WasmModuleDecoded() = default; + WasmModuleDecoded(bool async, bool streamed, bool success, + size_t module_size_in_bytes, size_t function_count, + int64_t wall_clock_duration_in_us) + : async(async), + streamed(streamed), + success(success), + module_size_in_bytes(module_size_in_bytes), + function_count(function_count), + wall_clock_duration_in_us(wall_clock_duration_in_us) {} + + V8_DEPRECATED("Use the version without cpu_duration_in_us") + WasmModuleDecoded(bool async, bool streamed, bool success, + size_t module_size_in_bytes, size_t function_count, + int64_t wall_clock_duration_in_us, + int64_t cpu_duration_in_us) + : async(async), + streamed(streamed), + success(success), + module_size_in_bytes(module_size_in_bytes), + function_count(function_count), + wall_clock_duration_in_us(wall_clock_duration_in_us), + cpu_duration_in_us(cpu_duration_in_us) {} + + START_ALLOW_USE_DEPRECATED() + // Copy constructor and copy assignment operator are allowed to copy the + // {cpu_duration_in_us} field. + WasmModuleDecoded(const WasmModuleDecoded&) = default; + WasmModuleDecoded& operator=(const WasmModuleDecoded&) = default; + END_ALLOW_USE_DEPRECATED() + bool async = false; bool streamed = false; bool success = false; size_t module_size_in_bytes = 0; size_t function_count = 0; int64_t wall_clock_duration_in_us = -1; + V8_DEPRECATED("We do not collect cpu times any more") int64_t cpu_duration_in_us = -1; }; struct WasmModuleCompiled { + WasmModuleCompiled() = default; + + WasmModuleCompiled(bool async, bool streamed, bool cached, bool deserialized, + bool lazy, bool success, size_t code_size_in_bytes, + size_t liftoff_bailout_count, + int64_t wall_clock_duration_in_us) + : async(async), + streamed(streamed), + cached(cached), + deserialized(deserialized), + lazy(lazy), + success(success), + code_size_in_bytes(code_size_in_bytes), + liftoff_bailout_count(liftoff_bailout_count), + wall_clock_duration_in_us(wall_clock_duration_in_us) {} + + V8_DEPRECATED("Use the version without cpu_duration_in_us") + WasmModuleCompiled(bool async, bool streamed, bool cached, bool deserialized, + bool lazy, bool success, size_t code_size_in_bytes, + size_t liftoff_bailout_count, + int64_t wall_clock_duration_in_us, + int64_t cpu_duration_in_us) + : async(async), + streamed(streamed), + cached(cached), + deserialized(deserialized), + lazy(lazy), + success(success), + code_size_in_bytes(code_size_in_bytes), + liftoff_bailout_count(liftoff_bailout_count), + wall_clock_duration_in_us(wall_clock_duration_in_us), + cpu_duration_in_us(cpu_duration_in_us) {} + + START_ALLOW_USE_DEPRECATED() + // Copy constructor and copy assignment operator are allowed to copy the + // {cpu_duration_in_us} field. + WasmModuleCompiled(const WasmModuleCompiled&) = default; + WasmModuleCompiled& operator=(const WasmModuleCompiled&) = default; + END_ALLOW_USE_DEPRECATED() + bool async = false; bool streamed = false; bool cached = false; @@ -115,6 +188,7 @@ struct WasmModuleCompiled { size_t code_size_in_bytes = 0; size_t liftoff_bailout_count = 0; int64_t wall_clock_duration_in_us = -1; + V8_DEPRECATED("We do not collect cpu times any more") int64_t cpu_duration_in_us = -1; }; diff --git a/deps/include/v8-platform.h b/deps/include/v8-platform.h index 32a82f88..32898e7e 100644 --- a/deps/include/v8-platform.h +++ b/deps/include/v8-platform.h @@ -285,6 +285,8 @@ class ConvertableToTraceFormat { * V8 Tracing controller. * * Can be implemented by an embedder to record trace events from V8. + * + * Will become obsolete in Perfetto SDK build (v8_use_perfetto = true). */ class TracingController { public: @@ -348,10 +350,16 @@ class TracingController { virtual void OnTraceDisabled() = 0; }; - /** Adds tracing state change observer. */ + /** + * Adds tracing state change observer. + * Does nothing in Perfetto SDK build (v8_use_perfetto = true). + */ virtual void AddTraceStateObserver(TraceStateObserver*) {} - /** Removes tracing state change observer. */ + /** + * Removes tracing state change observer. + * Does nothing in Perfetto SDK build (v8_use_perfetto = true). + */ virtual void RemoveTraceStateObserver(TraceStateObserver*) {} }; diff --git a/deps/include/v8-profiler.h b/deps/include/v8-profiler.h index 6b73fc60..d3941512 100644 --- a/deps/include/v8-profiler.h +++ b/deps/include/v8-profiler.h @@ -596,6 +596,7 @@ class V8_EXPORT HeapGraphNode { kBigInt = 13, // BigInt. kObjectShape = 14, // Internal data used for tracking the shapes (or // "hidden classes") of JS objects. + kWasmObject = 15, // A WasmGC struct or array. }; /** Returns node type (see HeapGraphNode::Type). */ diff --git a/deps/include/v8-script.h b/deps/include/v8-script.h index e2ba8452..ea4933dc 100644 --- a/deps/include/v8-script.h +++ b/deps/include/v8-script.h @@ -347,6 +347,12 @@ class V8_EXPORT Script { * ScriptOrigin. This can be either a v8::String or v8::Undefined. */ Local GetResourceName(); + + /** + * If the script was compiled, returns the positions of lazy functions which + * were eventually compiled and executed. + */ + std::vector GetProducedCompileHints() const; }; enum class ScriptType { kClassic, kModule }; @@ -562,7 +568,8 @@ class V8_EXPORT ScriptCompiler { enum CompileOptions { kNoCompileOptions = 0, kConsumeCodeCache, - kEagerCompile + kEagerCompile, + kProduceCompileHints }; /** diff --git a/deps/include/v8-snapshot.h b/deps/include/v8-snapshot.h index 2400357c..b15a2b19 100644 --- a/deps/include/v8-snapshot.h +++ b/deps/include/v8-snapshot.h @@ -91,7 +91,7 @@ class V8_EXPORT SnapshotCreator { */ SnapshotCreator(Isolate* isolate, const intptr_t* external_references = nullptr, - StartupData* existing_blob = nullptr); + const StartupData* existing_blob = nullptr); /** * Create and enter an isolate, and set it up for serialization. @@ -102,7 +102,7 @@ class V8_EXPORT SnapshotCreator { * that must be equivalent to CreateParams::external_references. */ SnapshotCreator(const intptr_t* external_references = nullptr, - StartupData* existing_blob = nullptr); + const StartupData* existing_blob = nullptr); /** * Destroy the snapshot creator, and exit and dispose of the Isolate diff --git a/deps/include/v8-template.h b/deps/include/v8-template.h index 669012a9..11296cd4 100644 --- a/deps/include/v8-template.h +++ b/deps/include/v8-template.h @@ -30,7 +30,9 @@ class Signature; F(AsyncIteratorPrototype, initial_async_iterator_prototype) \ F(ErrorPrototype, initial_error_prototype) \ F(IteratorPrototype, initial_iterator_prototype) \ - F(ObjProto_valueOf, object_value_of_function) + F(MapIteratorPrototype, initial_map_iterator_prototype) \ + F(ObjProto_valueOf, object_value_of_function) \ + F(SetIteratorPrototype, initial_set_iterator_prototype) enum Intrinsic { #define V8_DECL_INTRINSIC(name, iname) k##name, diff --git a/deps/include/v8-traced-handle.h b/deps/include/v8-traced-handle.h index e0fd57c4..784016b3 100644 --- a/deps/include/v8-traced-handle.h +++ b/deps/include/v8-traced-handle.h @@ -117,11 +117,11 @@ class TracedReferenceBase { /** * A traced handle with copy and move semantics. The handle is to be used - * together with |v8::EmbedderHeapTracer| or as part of GarbageCollected objects - * (see v8-cppgc.h) and specifies edges from C++ objects to JavaScript. + * together as part of GarbageCollected objects (see v8-cppgc.h) or from stack + * and specifies edges from C++ objects to JavaScript. * * The exact semantics are: - * - Tracing garbage collections use |v8::EmbedderHeapTracer| or cppgc. + * - Tracing garbage collections using CppHeap. * - Non-tracing garbage collections refer to * |v8::EmbedderRootsHandler::IsRoot()| whether the handle should * be treated as root or not. @@ -166,7 +166,6 @@ class BasicTracedReference : public TracedReferenceBase { Isolate* isolate, T* that, void* slot, internal::GlobalHandleStoreMode store_mode); - friend class EmbedderHeapTracer; template friend class Local; friend class Object; @@ -181,13 +180,7 @@ class BasicTracedReference : public TracedReferenceBase { /** * A traced handle without destructor that clears the handle. The embedder needs * to ensure that the handle is not accessed once the V8 object has been - * reclaimed. This can happen when the handle is not passed through the - * EmbedderHeapTracer. For more details see BasicTracedReference. - * - * The reference assumes the embedder has precise knowledge about references at - * all times. In case V8 needs to separately handle on-stack references, the - * embedder is required to set the stack start through - * |EmbedderHeapTracer::SetStackStart|. + * reclaimed. For more details see BasicTracedReference. */ template class TracedReference : public BasicTracedReference { diff --git a/deps/include/v8-version.h b/deps/include/v8-version.h index a9d6f92a..38f164b9 100644 --- a/deps/include/v8-version.h +++ b/deps/include/v8-version.h @@ -8,10 +8,10 @@ // These macros define the version number for the current version. // NOTE these macros are used by some of the tool scripts and the build // system so their names cannot be changed without changing the scripts. -#define V8_MAJOR_VERSION 10 -#define V8_MINOR_VERSION 9 -#define V8_BUILD_NUMBER 194 -#define V8_PATCH_LEVEL 9 +#define V8_MAJOR_VERSION 11 +#define V8_MINOR_VERSION 1 +#define V8_BUILD_NUMBER 277 +#define V8_PATCH_LEVEL 13 // Use 1 for candidates and 0 otherwise. // (Boolean macro values are not supported by all preprocessors.) diff --git a/deps/include/v8config.h b/deps/include/v8config.h index 2ac27b36..b44995e7 100644 --- a/deps/include/v8config.h +++ b/deps/include/v8config.h @@ -308,6 +308,9 @@ path. Add it with -I to the command line // V8_HAS_BUILTIN_EXPECT - __builtin_expect() supported // V8_HAS_BUILTIN_FRAME_ADDRESS - __builtin_frame_address() supported // V8_HAS_BUILTIN_POPCOUNT - __builtin_popcount() supported +// V8_HAS_BUILTIN_ADD_OVERFLOW - __builtin_add_overflow() supported +// V8_HAS_BUILTIN_SUB_OVERFLOW - __builtin_sub_overflow() supported +// V8_HAS_BUILTIN_MUL_OVERFLOW - __builtin_mul_overflow() supported // V8_HAS_BUILTIN_SADD_OVERFLOW - __builtin_sadd_overflow() supported // V8_HAS_BUILTIN_SSUB_OVERFLOW - __builtin_ssub_overflow() supported // V8_HAS_BUILTIN_UADD_OVERFLOW - __builtin_uadd_overflow() supported @@ -339,9 +342,21 @@ path. Add it with -I to the command line # define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (__has_attribute(always_inline)) # define V8_HAS_ATTRIBUTE_CONSTINIT \ (__has_attribute(require_constant_initialization)) +# define V8_HAS_ATTRIBUTE_CONST (__has_attribute(const)) # define V8_HAS_ATTRIBUTE_NONNULL (__has_attribute(nonnull)) # define V8_HAS_ATTRIBUTE_NOINLINE (__has_attribute(noinline)) # define V8_HAS_ATTRIBUTE_UNUSED (__has_attribute(unused)) +// Support for the "preserve_most" attribute is limited: +// - 32-bit platforms do not implement it, +// - component builds fail because _dl_runtime_resolve clobbers registers, +// - we see crashes on arm64 on Windows (https://crbug.com/1409934), which can +// hopefully be fixed in the future. +#if (defined(_M_X64) || defined(__x86_64__) /* x64 (everywhere) */ \ + || ((defined(__AARCH64EL__) || defined(_M_ARM64)) /* arm64, but ... */ \ + && !defined(_WIN32))) /* not on windows */ \ + && !defined(COMPONENT_BUILD) /* no component build */ +# define V8_HAS_ATTRIBUTE_PRESERVE_MOST (__has_attribute(preserve_most)) +#endif # define V8_HAS_ATTRIBUTE_VISIBILITY (__has_attribute(visibility)) # define V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT \ (__has_attribute(warn_unused_result)) @@ -360,6 +375,9 @@ path. Add it with -I to the command line # define V8_HAS_BUILTIN_EXPECT (__has_builtin(__builtin_expect)) # define V8_HAS_BUILTIN_FRAME_ADDRESS (__has_builtin(__builtin_frame_address)) # define V8_HAS_BUILTIN_POPCOUNT (__has_builtin(__builtin_popcount)) +# define V8_HAS_BUILTIN_ADD_OVERFLOW (__has_builtin(__builtin_add_overflow)) +# define V8_HAS_BUILTIN_SUB_OVERFLOW (__has_builtin(__builtin_sub_overflow)) +# define V8_HAS_BUILTIN_MUL_OVERFLOW (__has_builtin(__builtin_mul_overflow)) # define V8_HAS_BUILTIN_SADD_OVERFLOW (__has_builtin(__builtin_sadd_overflow)) # define V8_HAS_BUILTIN_SSUB_OVERFLOW (__has_builtin(__builtin_ssub_overflow)) # define V8_HAS_BUILTIN_UADD_OVERFLOW (__has_builtin(__builtin_uadd_overflow)) @@ -455,6 +473,16 @@ path. Add it with -I to the command line #endif +// A macro to mark functions whose values don't change (e.g. across calls) +// and thereby compiler is free to hoist and fold multiple calls together. +// Use like: +// V8_CONST int foo() { ... } +#if V8_HAS_ATTRIBUTE_CONST +# define V8_CONST __attribute__((const)) +#else +# define V8_CONST +#endif + // A macro to mark a declaration as requiring constant initialization. // Use like: // int* foo V8_CONSTINIT; @@ -487,6 +515,21 @@ path. Add it with -I to the command line #endif +// A macro used to change the calling conventions to preserve all registers (no +// caller-saved registers). Use this for cold functions called from hot +// functions. +// Note: The attribute is considered experimental, so apply with care. Also, +// "preserve_most" is currently not handling the return value correctly, so only +// use it for functions returning void (see https://reviews.llvm.org/D141020). +// Use like: +// V8_NOINLINE V8_PRESERVE_MOST void UnlikelyMethod(); +#if V8_HAS_ATTRIBUTE_PRESERVE_MOST +# define V8_PRESERVE_MOST __attribute__((preserve_most)) +#else +# define V8_PRESERVE_MOST /* NOT SUPPORTED */ +#endif + + // A macro (V8_DEPRECATED) to mark classes or functions as deprecated. #if defined(V8_DEPRECATION_WARNINGS) # define V8_DEPRECATED(message) [[deprecated(message)]] diff --git a/deps/v8 b/deps/v8 index 4b4e4733..1cee7477 160000 --- a/deps/v8 +++ b/deps/v8 @@ -1 +1 @@ -Subproject commit 4b4e473387ed62f7fcbc95a3bf05244ea0e76a0a +Subproject commit 1cee747760b14aa78503a22ba1a3ab97b968fa28 diff --git a/deps/v8_version b/deps/v8_version index ff8f5c65..bc4fa3d1 100644 --- a/deps/v8_version +++ b/deps/v8_version @@ -1 +1 @@ -10.9.194.9 \ No newline at end of file +11.1.277.13 \ No newline at end of file