From e03b92ab65c8a5ee1bbef388fa10790a41849191 Mon Sep 17 00:00:00 2001 From: auto user Date: Thu, 23 May 2024 10:55:03 +0000 Subject: [PATCH] Auto update version to 12.5.227.13 --- V8_DEFAULT_VERSION.txt | 2 +- .../v8include/cppgc/internal/member-storage.h | 6 + v8_c_api/src/v8include/v8-array-buffer.h | 8 +- v8_c_api/src/v8include/v8-context.h | 30 +++- v8_c_api/src/v8include/v8-function-callback.h | 26 ++- v8_c_api/src/v8include/v8-function.h | 3 - v8_c_api/src/v8include/v8-initialization.h | 10 +- v8_c_api/src/v8include/v8-internal.h | 118 +++++++++--- v8_c_api/src/v8include/v8-isolate.h | 2 +- v8_c_api/src/v8include/v8-object.h | 169 ++++++++++++++++-- v8_c_api/src/v8include/v8-persistent-handle.h | 15 -- v8_c_api/src/v8include/v8-sandbox.h | 63 +++++++ v8_c_api/src/v8include/v8-script.h | 9 - v8_c_api/src/v8include/v8-snapshot.h | 40 ++++- v8_c_api/src/v8include/v8-template.h | 76 +++++--- v8_c_api/src/v8include/v8-unwinder.h | 3 +- v8_c_api/src/v8include/v8-version.h | 6 +- v8_c_api/src/v8include/v8-wasm.h | 3 + v8_c_api/src/v8include/v8config.h | 15 +- 19 files changed, 487 insertions(+), 117 deletions(-) create mode 100644 v8_c_api/src/v8include/v8-sandbox.h diff --git a/V8_DEFAULT_VERSION.txt b/V8_DEFAULT_VERSION.txt index 1e78a91..bed1e84 100644 --- a/V8_DEFAULT_VERSION.txt +++ b/V8_DEFAULT_VERSION.txt @@ -1 +1 @@ -12.4.254.17 +12.5.227.13 diff --git a/v8_c_api/src/v8include/cppgc/internal/member-storage.h b/v8_c_api/src/v8include/cppgc/internal/member-storage.h index 61b255b..2b5bfec 100644 --- a/v8_c_api/src/v8include/cppgc/internal/member-storage.h +++ b/v8_c_api/src/v8include/cppgc/internal/member-storage.h @@ -158,6 +158,12 @@ class V8_TRIVIAL_ABI CompressedPointer final { static V8_INLINE void* Decompress(IntegralType ptr) { CPPGC_DCHECK(CageBaseGlobal::IsSet()); const uintptr_t base = CageBaseGlobal::Get(); + return Decompress(ptr, base); + } + + static V8_INLINE void* Decompress(IntegralType ptr, uintptr_t base) { + CPPGC_DCHECK(CageBaseGlobal::IsSet()); + CPPGC_DCHECK(base == CageBaseGlobal::Get()); // Treat compressed pointer as signed and cast it to uint64_t, which will // sign-extend it. #if defined(CPPGC_2GB_CAGE) diff --git a/v8_c_api/src/v8include/v8-array-buffer.h b/v8_c_api/src/v8include/v8-array-buffer.h index ea6f5b5..5d85544 100644 --- a/v8_c_api/src/v8include/v8-array-buffer.h +++ b/v8_c_api/src/v8include/v8-array-buffer.h @@ -87,6 +87,9 @@ class V8_EXPORT BackingStore : public v8::internal::BackingStoreBase { * Assumes that the backing_store was allocated by the ArrayBuffer allocator * of the given isolate. */ + V8_DEPRECATED( + "Reallocate is unsafe, please do not use. Please allocate a new " + "BackingStore and copy instead.") static std::unique_ptr Reallocate( v8::Isolate* isolate, std::unique_ptr backing_store, size_t byte_length); @@ -179,6 +182,9 @@ class V8_EXPORT ArrayBuffer : public Object { * * The default implementation allocates a new block and copies data. */ + V8_DEPRECATE_SOON( + "Reallocate is unsafe, please do not use. Please allocate new memory " + "and copy instead.") virtual void* Reallocate(void* data, size_t old_length, size_t new_length); /** @@ -287,7 +293,7 @@ class V8_EXPORT ArrayBuffer : public Object { * preventing JavaScript from ever accessing underlying backing store. * ArrayBuffer should have been externalized and must be detachable. */ - V8_DEPRECATE_SOON( + V8_DEPRECATED( "Use the version which takes a key parameter (passing a null handle is " "ok).") void Detach(); diff --git a/v8_c_api/src/v8include/v8-context.h b/v8_c_api/src/v8include/v8-context.h index 4849c92..f65aa9a 100644 --- a/v8_c_api/src/v8include/v8-context.h +++ b/v8_c_api/src/v8include/v8-context.h @@ -107,6 +107,10 @@ class V8_EXPORT Context : public Data { * configured if the default context snapshot contains no pointer embedder * data, or if no custom startup snapshot is configured in the * v8::CreateParams used to create the isolate. + * + * \param api_wrapper_deserializer An optional callback used to deserialize + * API wrapper objects that was initially set with v8::Object::Wrap() and then + * serialized using SerializeAPIWrapperCallback. */ static Local New( Isolate* isolate, ExtensionConfiguration* extensions = nullptr, @@ -116,17 +120,19 @@ class V8_EXPORT Context : public Data { DeserializeInternalFieldsCallback(), MicrotaskQueue* microtask_queue = nullptr, DeserializeContextDataCallback context_data_deserializer = - DeserializeContextDataCallback()); + DeserializeContextDataCallback(), + DeserializeAPIWrapperCallback api_wrapper_deserializer = + DeserializeAPIWrapperCallback()); /** * Create a new context from a (non-default) context snapshot. There * is no way to provide a global object template since we do not create * a new global object from template, but we can reuse a global object. * - * \param isolate See v8::Context::New. + * \param isolate See v8::Context::New(). * * \param context_snapshot_index The index of the context snapshot to - * deserialize from. Use v8::Context::New for the default snapshot. + * deserialize from. Use v8::Context::New() for the default snapshot. * * \param internal_fields_deserializer An optional callback used * to deserialize fields set by @@ -136,19 +142,23 @@ class V8_EXPORT Context : public Data { * pointer fields in the default context snapshot or if no startup * snapshot is configured when the isolate is created. * - * \param extensions See v8::Context::New. + * \param extensions See v8::Context::New(). * - * \param global_object See v8::Context::New. + * \param global_object See v8::Context::New(). * * \param internal_fields_deserializer Similar to - * internal_fields_deserializer in v8::Context::New but applies to + * internal_fields_deserializer in v8::Context::New() but applies to * the context specified by the context_snapshot_index. * - * \param microtask_queue See v8::Context::New. + * \param microtask_queue See v8::Context::New(). * * \param context_data_deserializer Similar to - * context_data_deserializer in v8::Context::New but applies to + * context_data_deserializer in v8::Context::New() but applies to * the context specified by the context_snapshot_index. + * + *\param api_wrapper_deserializer Similar to api_wrapper_deserializer in + * v8::Context::New() but applies to the context specified by the + * context_snapshot_index. */ static MaybeLocal FromSnapshot( Isolate* isolate, size_t context_snapshot_index, @@ -158,7 +168,9 @@ class V8_EXPORT Context : public Data { MaybeLocal global_object = MaybeLocal(), MicrotaskQueue* microtask_queue = nullptr, DeserializeContextDataCallback context_data_deserializer = - DeserializeContextDataCallback()); + DeserializeContextDataCallback(), + DeserializeAPIWrapperCallback api_wrapper_deserializer = + DeserializeAPIWrapperCallback()); /** * Returns an global object that isn't backed by an actual context. diff --git a/v8_c_api/src/v8include/v8-function-callback.h b/v8_c_api/src/v8include/v8-function-callback.h index 86a3ea7..cd5b079 100644 --- a/v8_c_api/src/v8include/v8-function-callback.h +++ b/v8_c_api/src/v8include/v8-function-callback.h @@ -127,6 +127,12 @@ class FunctionCallbackInfo { * referencing this callback was found (which in V8 internally is often * referred to as holder [sic]). */ + V8_DEPRECATE_SOON( + "V8 will stop providing access to hidden prototype (i.e. " + "JSGlobalObject). Use This() instead. \n" + "DO NOT try to workaround this by accessing JSGlobalObject via " + "v8::Object::GetPrototype() - it'll be deprecated soon too. \n" + "See http://crbug.com/333672197. ") V8_INLINE Local Holder() const; /** For construct calls, this returns the "new.target" value. */ V8_INLINE Local NewTarget() const; @@ -139,6 +145,11 @@ class FunctionCallbackInfo { /** The ReturnValue for the call. */ V8_INLINE ReturnValue GetReturnValue() const; + // This is a temporary replacement for Holder() added just for the purpose + // of testing the deprecated Holder() machinery until it's removed for real. + // DO NOT use it. + V8_INLINE Local HolderSoonToBeDeprecated() const; + private: friend class internal::FunctionCallbackArguments; friend class internal::CustomArguments; @@ -265,7 +276,15 @@ class PropertyCallbackInfo { */ V8_INLINE bool ShouldThrowOnError() const; + V8_DEPRECATE_SOON( + "This is a temporary workaround to ease migration of Chromium bindings " + "code to the new interceptors Api") + explicit PropertyCallbackInfo(const PropertyCallbackInfo& info) + : PropertyCallbackInfo(info.args_) {} + private: + template + friend class PropertyCallbackInfo; friend class MacroAssembler; friend class internal::PropertyCallbackArguments; friend class internal::CustomArguments; @@ -532,10 +551,15 @@ Local FunctionCallbackInfo::This() const { } template -Local FunctionCallbackInfo::Holder() const { +Local FunctionCallbackInfo::HolderSoonToBeDeprecated() const { return Local::FromSlot(&implicit_args_[kHolderIndex]); } +template +Local FunctionCallbackInfo::Holder() const { + return HolderSoonToBeDeprecated(); +} + template Local FunctionCallbackInfo::NewTarget() const { return Local::FromSlot(&implicit_args_[kNewTargetIndex]); diff --git a/v8_c_api/src/v8include/v8-function.h b/v8_c_api/src/v8include/v8-function.h index 30a9fcf..50f730f 100644 --- a/v8_c_api/src/v8include/v8-function.h +++ b/v8_c_api/src/v8include/v8-function.h @@ -59,9 +59,6 @@ class V8_EXPORT Function : public Object { void SetName(Local name); Local GetName() const; - V8_DEPRECATED("No direct replacement") - MaybeLocal GetUnboundScript() const; - /** * Name inferred from variable or property assignment of this function. * Used to facilitate debugging and profiling of JavaScript code written diff --git a/v8_c_api/src/v8include/v8-initialization.h b/v8_c_api/src/v8include/v8-initialization.h index d3e35d6..6f12e3d 100644 --- a/v8_c_api/src/v8include/v8-initialization.h +++ b/v8_c_api/src/v8include/v8-initialization.h @@ -97,10 +97,17 @@ class V8_EXPORT V8 { * is created. It always returns true. */ V8_INLINE static bool Initialize() { +#ifdef V8_TARGET_OS_ANDROID + const bool kV8TargetOsIsAndroid = true; +#else + const bool kV8TargetOsIsAndroid = false; +#endif + const int kBuildConfiguration = (internal::PointerCompressionIsEnabled() ? kPointerCompression : 0) | (internal::SmiValuesAre31Bits() ? k31BitSmis : 0) | - (internal::SandboxIsEnabled() ? kSandbox : 0); + (internal::SandboxIsEnabled() ? kSandbox : 0) | + (kV8TargetOsIsAndroid ? kTargetOsIsAndroid : 0); return Initialize(kBuildConfiguration); } @@ -271,6 +278,7 @@ class V8_EXPORT V8 { kPointerCompression = 1 << 0, k31BitSmis = 1 << 1, kSandbox = 1 << 2, + kTargetOsIsAndroid = 1 << 3, }; /** diff --git a/v8_c_api/src/v8include/v8-internal.h b/v8_c_api/src/v8include/v8-internal.h index 322b22d..14120ce 100644 --- a/v8_c_api/src/v8include/v8-internal.h +++ b/v8_c_api/src/v8include/v8-internal.h @@ -253,15 +253,15 @@ static_assert(1ULL << (64 - kBoundedSizeShift) == // size allows omitting bounds checks on table accesses if the indices are // guaranteed (e.g. through shifting) to be below the maximum index. This // value must be a power of two. -constexpr size_t kExternalPointerTableReservationSize = 512 * MB; +constexpr size_t kExternalPointerTableReservationSize = 256 * MB; // 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. -constexpr uint32_t kExternalPointerIndexShift = 6; +constexpr uint32_t kExternalPointerIndexShift = 7; #else -constexpr size_t kExternalPointerTableReservationSize = 1024 * MB; -constexpr uint32_t kExternalPointerIndexShift = 5; +constexpr size_t kExternalPointerTableReservationSize = 512 * MB; +constexpr uint32_t kExternalPointerIndexShift = 6; #endif // V8_TARGET_OS_ANDROID // The maximum number of entries in an external pointer table. @@ -301,6 +301,26 @@ using ExternalPointer_t = Address; constexpr ExternalPointer_t kNullExternalPointer = 0; constexpr ExternalPointerHandle kNullExternalPointerHandle = 0; +// See `ExternalPointerHandle` for the main documentation. The difference to +// `ExternalPointerHandle` is that the handle does not represent an arbitrary +// external pointer but always refers to an object managed by `CppHeap`. The +// handles are using in combination with a dedicated table for `CppHeap` +// references. +using CppHeapPointerHandle = uint32_t; + +// The actual pointer to objects located on the `CppHeap`. When pointer +// compression is enabled these pointers are stored as `CppHeapPointerHandle`. +// In non-compressed configurations the pointers are simply stored as raw +// pointers. +#ifdef V8_COMPRESS_POINTERS +using CppHeapPointer_t = CppHeapPointerHandle; +#else +using CppHeapPointer_t = Address; +#endif + +constexpr CppHeapPointer_t kNullCppHeapPointer = 0; +constexpr CppHeapPointerHandle kNullCppHeapPointerHandle = 0; + // // External Pointers. // @@ -418,22 +438,46 @@ constexpr uint64_t kAllExternalPointerTypeTags[] = { // 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, TAG(10)) \ - V(kNativeContextMicrotaskQueueTag, TAG(11)) \ - V(kEmbedderDataSlotPayloadTag, TAG(12)) \ + V(kNativeContextMicrotaskQueueTag, TAG(10)) \ + V(kEmbedderDataSlotPayloadTag, TAG(11)) \ /* 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(kFunctionTemplateInfoCallbackTag, 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(kWasmIndirectFunctionTargetTag, TAG(21)) \ - V(kArrayBufferExtensionTag, TAG(22)) + V(kExternalObjectValueTag, TAG(12)) \ + V(kFunctionTemplateInfoCallbackTag, TAG(13)) \ + V(kAccessorInfoGetterTag, TAG(14)) \ + V(kAccessorInfoSetterTag, TAG(15)) \ + V(kWasmInternalFunctionCallTargetTag, TAG(16)) \ + V(kWasmTypeInfoNativeTypeTag, TAG(17)) \ + V(kWasmExportedFunctionDataSignatureTag, TAG(18)) \ + V(kWasmContinuationJmpbufTag, TAG(19)) \ + V(kWasmIndirectFunctionTargetTag, TAG(20)) \ + /* Foreigns */ \ + V(kGenericForeignTag, TAG(30)) \ + /* Managed */ \ + V(kFirstManagedResourceTag, TAG(40)) \ + V(kGenericManagedTag, TAG(40)) \ + V(kWasmWasmStreamingTag, TAG(41)) \ + V(kWasmFuncDataTag, TAG(42)) \ + V(kWasmManagedDataTag, TAG(43)) \ + V(kWasmNativeModuleTag, TAG(44)) \ + V(kWasmStackMemoryTag, TAG(45)) \ + V(kIcuBreakIteratorTag, TAG(46)) \ + V(kIcuUnicodeStringTag, TAG(47)) \ + V(kIcuListFormatterTag, TAG(48)) \ + V(kIcuLocaleTag, TAG(49)) \ + V(kIcuSimpleDateFormatTag, TAG(50)) \ + V(kIcuDateIntervalFormatTag, TAG(51)) \ + V(kIcuRelativeDateTimeFormatterTag, TAG(52)) \ + V(kIcuLocalizedNumberFormatterTag, TAG(53)) \ + V(kIcuPluralRulesTag, TAG(54)) \ + V(kIcuCollatorTag, TAG(55)) \ + V(kDisplayNamesInternalTag, TAG(56)) \ + /* External resources whose lifetime is tied to */ \ + /* their entry in the external pointer table but */ \ + /* which are not referenced via a Managed */ \ + V(kLastManagedResourceTag, TAG(56)) \ + V(kArrayBufferExtensionTag, TAG(57)) // All external pointer tags. #define ALL_EXTERNAL_POINTER_TAGS(V) \ @@ -449,12 +493,18 @@ enum ExternalPointerTag : uint64_t { kExternalPointerNullTag = MAKE_TAG(1, 0b00000000), // External pointer tag that will match any external pointer. Use with care! kAnyExternalPointerTag = MAKE_TAG(1, 0b11111111), + // External pointer tag that will match any external pointer in a Foreign. + // Use with care! If desired, this could be made more fine-granular. + kAnyForeignTag = kAnyExternalPointerTag, // The free entry tag has all type bits set so every type check with a // different type fails. It also doesn't have the mark bit set as free // entries are (by definition) not alive. kExternalPointerFreeEntryTag = MAKE_TAG(0, 0b11111111), // Evacuation entries are used during external pointer table compaction. - kExternalPointerEvacuationEntryTag = MAKE_TAG(1, 0b11100111), + kExternalPointerEvacuationEntryTag = MAKE_TAG(1, 0b11111110), + // Tag for zapped/invalidated entries. Those are considered to no longer be + // in use and so have the marking bit cleared. + kExternalPointerZappedEntryTag = MAKE_TAG(0, 0b11111101), ALL_EXTERNAL_POINTER_TAGS(EXTERNAL_POINTER_TAG_ENUM) }; @@ -481,6 +531,15 @@ V8_INLINE static constexpr bool IsMaybeReadOnlyExternalPointerType( tag == kFunctionTemplateInfoCallbackTag; } +// True if the external pointer references an external object whose lifetime is +// tied to the entry in the external pointer table. +// In this case, the entry in the ExternalPointerTable always points to an +// object derived from ExternalPointerTable::ManagedResource. +V8_INLINE static constexpr bool IsManagedExternalPointerType( + ExternalPointerTag tag) { + return tag >= kFirstManagedResourceTag && tag <= kLastManagedResourceTag; +} + // Sanity checks. #define CHECK_SHARED_EXTERNAL_POINTER_TAGS(Tag, ...) \ static_assert(IsSharedExternalPointerType(Tag)); @@ -576,11 +635,11 @@ using CodePointerHandle = IndirectPointerHandle; // The size of the virtual memory reservation for the code pointer table. // As with the other tables, a maximum table size in combination with shifted // indices allows omitting bounds checks. -constexpr size_t kCodePointerTableReservationSize = 16 * MB; +constexpr size_t kCodePointerTableReservationSize = 128 * MB; // Code pointer handles are shifted by a different amount than indirect pointer // handles as the tables have a different maximum size. -constexpr uint32_t kCodePointerHandleShift = 12; +constexpr uint32_t kCodePointerHandleShift = 9; // A null handle always references an entry that contains nullptr. constexpr CodePointerHandle kNullCodePointerHandle = kNullIndirectPointerHandle; @@ -647,6 +706,13 @@ class Internals { static const int kOddballKindOffset = 4 * kApiTaggedSize + kApiDoubleSize; static const int kJSObjectHeaderSize = 3 * kApiTaggedSize; +#ifdef V8_COMPRESS_POINTERS + static const int kJSAPIObjectWithEmbedderSlotsHeaderSize = + kJSObjectHeaderSize + kApiInt32Size; +#else // !V8_COMPRESS_POINTERS + static const int kJSAPIObjectWithEmbedderSlotsHeaderSize = + kJSObjectHeaderSize + kApiTaggedSize; +#endif // !V8_COMPRESS_POINTERS static const int kFixedArrayHeaderSize = 2 * kApiTaggedSize; static const int kEmbedderDataArrayHeaderSize = 2 * kApiTaggedSize; static const int kEmbedderDataSlotSize = kApiSystemPointerSize; @@ -719,16 +785,18 @@ class Internals { kIsolateEmbedderDataOffset + kNumIsolateDataSlots * kApiSystemPointerSize; static const int kIsolateSharedExternalPointerTableAddressOffset = kIsolateExternalPointerTableOffset + kExternalPointerTableSize; + static const int kIsolateCppHeapPointerTableOffset = + kIsolateSharedExternalPointerTableAddressOffset + kApiSystemPointerSize; #ifdef V8_ENABLE_SANDBOX static const int kIsolateTrustedCageBaseOffset = - kIsolateSharedExternalPointerTableAddressOffset + kApiSystemPointerSize; + kIsolateCppHeapPointerTableOffset + kExternalPointerTableSize; static const int kIsolateTrustedPointerTableOffset = kIsolateTrustedCageBaseOffset + kApiSystemPointerSize; static const int kIsolateApiCallbackThunkArgumentOffset = kIsolateTrustedPointerTableOffset + kTrustedPointerTableSize; #else static const int kIsolateApiCallbackThunkArgumentOffset = - kIsolateSharedExternalPointerTableAddressOffset + kApiSystemPointerSize; + kIsolateCppHeapPointerTableOffset + kExternalPointerTableSize; #endif // V8_ENABLE_SANDBOX #else static const int kIsolateApiCallbackThunkArgumentOffset = @@ -753,7 +821,7 @@ class Internals { V(TrueValue, 0xc9) \ V(FalseValue, 0xad) \ V(EmptyString, 0xa1) \ - V(TheHoleValue, 0x719) + V(TheHoleValue, 0x741) using Tagged_t = uint32_t; struct StaticReadOnlyRoot { @@ -1383,10 +1451,6 @@ class HandleHelper final { if (rhs.IsEmpty()) return false; return lhs.ptr() == rhs.ptr(); } - - static V8_EXPORT bool IsOnStack(const void* ptr); - static V8_EXPORT void VerifyOnStack(const void* ptr); - static V8_EXPORT void VerifyOnMainThread(); }; V8_EXPORT void VerifyHandleIsNonEmpty(bool is_empty); diff --git a/v8_c_api/src/v8include/v8-isolate.h b/v8_c_api/src/v8include/v8-isolate.h index 585b513..9e49d77 100644 --- a/v8_c_api/src/v8include/v8-isolate.h +++ b/v8_c_api/src/v8include/v8-isolate.h @@ -1656,7 +1656,7 @@ class V8_EXPORT Isolate { * heap. GC is not invoked prior to iterating, therefore there is no * guarantee that visited objects are still alive. */ - V8_DEPRECATE_SOON("Will be removed without replacement. crbug.com/v8/14172") + V8_DEPRECATED("Will be removed without replacement. crbug.com/v8/14172") void VisitExternalResources(ExternalResourceVisitor* visitor); /** diff --git a/v8_c_api/src/v8include/v8-object.h b/v8_c_api/src/v8include/v8-object.h index 6cdf53b..0d09ee7 100644 --- a/v8_c_api/src/v8include/v8-object.h +++ b/v8_c_api/src/v8include/v8-object.h @@ -5,10 +5,12 @@ #ifndef INCLUDE_V8_OBJECT_H_ #define INCLUDE_V8_OBJECT_H_ +#include "v8-internal.h" // NOLINT(build/include_directory) #include "v8-local-handle.h" // NOLINT(build/include_directory) #include "v8-maybe.h" // NOLINT(build/include_directory) #include "v8-persistent-handle.h" // NOLINT(build/include_directory) #include "v8-primitive.h" // NOLINT(build/include_directory) +#include "v8-sandbox.h" // NOLINT(build/include_directory) #include "v8-traced-handle.h" // NOLINT(build/include_directory) #include "v8-value.h" // NOLINT(build/include_directory) #include "v8config.h" // NOLINT(build/include_directory) @@ -146,18 +148,20 @@ enum PropertyAttribute { }; /** - * Accessor[Getter|Setter] are used as callback functions when - * setting|getting a particular property. See Object and ObjectTemplate's - * method SetAccessor. + * Accessor[Getter|Setter] are used as callback functions when setting|getting + * a particular data property. See Object::SetNativeDataProperty and + * ObjectTemplate::SetNativeDataProperty methods. */ -using AccessorGetterCallback = +using AccessorGetterCallback V8_DEPRECATE_SOON( + "Use AccessorNameGetterCallback signature instead") = void (*)(Local property, const PropertyCallbackInfo& info); using AccessorNameGetterCallback = void (*)(Local property, const PropertyCallbackInfo& info); -using AccessorSetterCallback = void (*)(Local property, - Local value, - const PropertyCallbackInfo& info); +using AccessorSetterCallback V8_DEPRECATE_SOON( + "Use AccessorNameSetterCallback signature instead") = + void (*)(Local property, Local value, + const PropertyCallbackInfo& info); using AccessorNameSetterCallback = void (*)(Local property, Local value, const PropertyCallbackInfo& info); @@ -429,16 +433,41 @@ class V8_EXPORT Object : public Value { * be skipped by __proto__ and it does not consult the security * handler. */ + // V8_DEPRECATE_SOON( + // "V8 will stop providing access to hidden prototype (i.e. " + // "JSGlobalObject). Use GetPrototypeV2() instead. " + // "See http://crbug.com/333672197.") Local GetPrototype(); + /** + * Get the prototype object (same as getting __proto__ property). This does + * not consult the security handler. + * TODO(333672197): rename back to GetPrototype() once the old version goes + * through the deprecation process and is removed. + */ + Local GetPrototypeV2(); + /** * Set the prototype object. This does not skip objects marked to * be skipped by __proto__ and it does not consult the security * handler. */ + // V8_DEPRECATE_SOON( + // "V8 will stop providing access to hidden prototype (i.e. " + // "JSGlobalObject). Use SetPrototypeV2() instead. " + // "See http://crbug.com/333672197.") V8_WARN_UNUSED_RESULT Maybe SetPrototype(Local context, Local prototype); + /** + * Set the prototype object (same as setting __proto__ property). This does + * does not consult the security handler. + * TODO(333672197): rename back to SetPrototype() once the old version goes + * through the deprecation process and is removed. + */ + V8_WARN_UNUSED_RESULT Maybe SetPrototypeV2(Local context, + Local prototype); + /** * Finds an instance of the given function template in the prototype * chain. @@ -526,7 +555,50 @@ class V8_EXPORT Object : public Value { void* values[]); /** - * HasOwnProperty() is like JavaScript's Object.prototype.hasOwnProperty(). + * Unwraps a JS wrapper object. + * + * \param tag The tag for retrieving the wrappable instance. Must match the + * tag that has been used for a previous `Wrap()` operation. + * \param isolate The Isolate for the `wrapper` object. + * \param wrapper The JS wrapper object that should be unwrapped. + * \returns the C++ wrappable instance, or nullptr if the JS object has never + * been wrapped. + */ + template + static V8_INLINE T* Unwrap(v8::Isolate* isolate, + const v8::Local& wrapper); + template + static V8_INLINE T* Unwrap(v8::Isolate* isolate, + const PersistentBase& wrapper); + template + static V8_INLINE T* Unwrap(v8::Isolate* isolate, + const BasicTracedReference& wrapper); + + /** + * Wraps a JS wrapper with a C++ instance. + * + * \param tag The pointer tag that should be used for storing this object. + * Future `Unwrap()` operations must provide a matching tag. + * \param isolate The Isolate for the `wrapper` object. + * \param wrapper The JS wrapper object. + * \param wrappable The C++ object instance that is wrapped by the JS object. + */ + template + static V8_INLINE void Wrap(v8::Isolate* isolate, + const v8::Local& wrapper, + void* wrappable); + template + static V8_INLINE void Wrap(v8::Isolate* isolate, + const PersistentBase& wrapper, + void* wrappable); + template + static V8_INLINE void Wrap(v8::Isolate* isolate, + const BasicTracedReference& wrapper, + void* wrappable); + + /** + * HasOwnProperty() is like JavaScript's + * Object.prototype.hasOwnProperty(). * * See also v8::Object::Has() and v8::Object::HasRealNamedProperty(). */ @@ -729,6 +801,11 @@ class V8_EXPORT Object : public Value { bool IsCodeLike(Isolate* isolate) const; private: + static void* Unwrap(v8::Isolate* isolate, internal::Address wrapper_obj, + CppHeapPointerTag tag); + static void Wrap(v8::Isolate* isolate, internal::Address wrapper_obj, + CppHeapPointerTag tag, void* wrappable); + Object(); static void CheckCast(Value* obj); Local SlowGetInternalField(int index); @@ -747,7 +824,8 @@ Local Object::GetInternalField(int index) { // know where to find the internal fields and can return the value directly. int instance_type = I::GetInstanceType(obj); if (I::CanHaveInternalField(instance_type)) { - int offset = I::kJSObjectHeaderSize + (I::kEmbedderDataSlotSize * index); + int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize + + (I::kEmbedderDataSlotSize * index); A value = I::ReadRawField(obj, offset); #ifdef V8_COMPRESS_POINTERS // We read the full pointer value and then decompress it in order to avoid @@ -773,7 +851,8 @@ void* Object::GetAlignedPointerFromInternalField(v8::Isolate* isolate, // know where to find the internal fields and can return the value directly. auto instance_type = I::GetInstanceType(obj); if (V8_LIKELY(I::CanHaveInternalField(instance_type))) { - int offset = I::kJSObjectHeaderSize + (I::kEmbedderDataSlotSize * index) + + int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize + + (I::kEmbedderDataSlotSize * index) + I::kEmbedderDataSlotExternalPointerOffset; A value = I::ReadExternalPointerField( @@ -793,7 +872,8 @@ void* Object::GetAlignedPointerFromInternalField(int index) { // know where to find the internal fields and can return the value directly. auto instance_type = I::GetInstanceType(obj); if (V8_LIKELY(I::CanHaveInternalField(instance_type))) { - int offset = I::kJSObjectHeaderSize + (I::kEmbedderDataSlotSize * index) + + int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize + + (I::kEmbedderDataSlotSize * index) + I::kEmbedderDataSlotExternalPointerOffset; Isolate* isolate = I::GetIsolateForSandbox(obj); A value = @@ -805,6 +885,73 @@ void* Object::GetAlignedPointerFromInternalField(int index) { return SlowGetAlignedPointerFromInternalField(index); } +// static +template +T* Object::Unwrap(v8::Isolate* isolate, const v8::Local& wrapper) { + auto obj = internal::ValueHelper::ValueAsAddress(*wrapper); +#if !defined(V8_ENABLE_CHECKS) + return internal::ReadCppHeapPointerField( + isolate, obj, internal::Internals::kJSObjectHeaderSize); +#else // defined(V8_ENABLE_CHECKS) + return reinterpret_cast(Unwrap(isolate, obj, tag)); +#endif // defined(V8_ENABLE_CHECKS) +} + +// static +template +T* Object::Unwrap(v8::Isolate* isolate, const PersistentBase& wrapper) { + auto obj = + internal::ValueHelper::ValueAsAddress(wrapper.template value()); +#if !defined(V8_ENABLE_CHECKS) + return internal::ReadCppHeapPointerField( + isolate, obj, internal::Internals::kJSObjectHeaderSize); +#else // defined(V8_ENABLE_CHECKS) + + return reinterpret_cast(Unwrap(isolate, obj, tag)); +#endif // defined(V8_ENABLE_CHECKS) +} + +// static +template +T* Object::Unwrap(v8::Isolate* isolate, + const BasicTracedReference& wrapper) { + auto obj = + internal::ValueHelper::ValueAsAddress(wrapper.template value()); +#if !defined(V8_ENABLE_CHECKS) + return internal::ReadCppHeapPointerField( + isolate, obj, internal::Internals::kJSObjectHeaderSize); +#else // defined(V8_ENABLE_CHECKS) + return reinterpret_cast(Unwrap(isolate, obj, tag)); +#endif // defined(V8_ENABLE_CHECKS) +} + +// static +template +void Object::Wrap(v8::Isolate* isolate, const v8::Local& wrapper, + void* wrappable) { + auto obj = internal::ValueHelper::ValueAsAddress(*wrapper); + Wrap(isolate, obj, tag, wrappable); +} + +// static +template +void Object::Wrap(v8::Isolate* isolate, const PersistentBase& wrapper, + void* wrappable) { + auto obj = + internal::ValueHelper::ValueAsAddress(wrapper.template value()); + Wrap(isolate, obj, tag, wrappable); +} + +// static +template +void Object::Wrap(v8::Isolate* isolate, + const BasicTracedReference& wrapper, + void* wrappable) { + auto obj = + internal::ValueHelper::ValueAsAddress(wrapper.template value()); + Wrap(isolate, obj, tag, wrappable); +} + Private* Private::Cast(Data* data) { #ifdef V8_ENABLE_CHECKS CheckCast(data); diff --git a/v8_c_api/src/v8include/v8-persistent-handle.h b/v8_c_api/src/v8include/v8-persistent-handle.h index 49518fe..e08747a 100644 --- a/v8_c_api/src/v8include/v8-persistent-handle.h +++ b/v8_c_api/src/v8include/v8-persistent-handle.h @@ -236,21 +236,6 @@ class NonCopyablePersistentTraits { } }; -/** - * Helper class traits to allow copying and assignment of Persistent. - * This will clone the contents of storage cell, but not any of the flags, etc. - */ -template -struct V8_DEPRECATED("Use v8::Global instead") CopyablePersistentTraits { - using CopyablePersistent = Persistent>; - static const bool kResetInDestructor = true; - template - static V8_INLINE void Copy(const Persistent& source, - CopyablePersistent* dest) { - // do nothing, just allow copy - } -}; - /** * A PersistentBase which allows copy and assignment. * diff --git a/v8_c_api/src/v8include/v8-sandbox.h b/v8_c_api/src/v8include/v8-sandbox.h new file mode 100644 index 0000000..f5f91cb --- /dev/null +++ b/v8_c_api/src/v8include/v8-sandbox.h @@ -0,0 +1,63 @@ +// Copyright 2024 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef INCLUDE_V8_SANDBOX_H_ +#define INCLUDE_V8_SANDBOX_H_ + +#include + +#include "v8-internal.h" // NOLINT(build/include_directory) +#include "v8config.h" // NOLINT(build/include_directory) + +namespace v8 { + +/** + * A pointer tag used for wrapping and unwrapping `CppHeap` pointers as used + * with JS API wrapper objects that rely on `v8::Object::Wrap()` and + * `v8::Object::Unwrap()`. + */ +enum class CppHeapPointerTag : uint64_t { + kDefaultTag = internal::ExternalPointerTag::kExternalObjectValueTag, +}; + +namespace internal { + +#ifdef V8_COMPRESS_POINTERS +V8_INLINE static Address* GetCppHeapPointerTableBase(v8::Isolate* isolate) { + Address addr = reinterpret_cast
(isolate) + + Internals::kIsolateCppHeapPointerTableOffset + + Internals::kExternalPointerTableBasePointerOffset; + return *reinterpret_cast(addr); +} +#endif // V8_COMPRESS_POINTERS + +template +V8_INLINE static T* ReadCppHeapPointerField(v8::Isolate* isolate, + Address heap_object_ptr, + int offset) { +#ifdef V8_COMPRESS_POINTERS + static_assert(tag != static_cast(kExternalPointerNullTag)); + // See src/sandbox/external-pointer-table-inl.h. Logic duplicated here so + // it can be inlined and doesn't require an additional call. + const CppHeapPointerHandle handle = + Internals::ReadRawField(heap_object_ptr, offset); + if (handle == 0) { + return reinterpret_cast(kNullAddress); + } + const uint32_t index = handle >> kExternalPointerIndexShift; + const Address* table = GetCppHeapPointerTableBase(isolate); + const std::atomic
* ptr = + reinterpret_cast*>(&table[index]); + Address entry = std::atomic_load_explicit(ptr, std::memory_order_relaxed); + return reinterpret_cast(entry & ~static_cast(tag)); +#else // !V8_COMPRESS_POINTERS + return reinterpret_cast( + Internals::ReadRawField
(heap_object_ptr, offset)); +#endif // !V8_COMPRESS_POINTERS +} + +} // namespace internal +} // namespace v8 + +#endif // INCLUDE_V8_SANDBOX_H_ diff --git a/v8_c_api/src/v8include/v8-script.h b/v8_c_api/src/v8include/v8-script.h index 7558986..d4b626f 100644 --- a/v8_c_api/src/v8include/v8-script.h +++ b/v8_c_api/src/v8include/v8-script.h @@ -787,15 +787,6 @@ class V8_EXPORT ScriptCompiler { * It is possible to specify multiple context extensions (obj in the above * example). */ - V8_DEPRECATED("Use CompileFunction") - static V8_WARN_UNUSED_RESULT MaybeLocal CompileFunctionInContext( - Local context, Source* source, size_t arguments_count, - Local arguments[], size_t context_extension_count, - Local context_extensions[], - CompileOptions options = kNoCompileOptions, - NoCacheReason no_cache_reason = kNoCacheNoReason, - Local* script_or_module_out = nullptr); - static V8_WARN_UNUSED_RESULT MaybeLocal CompileFunction( Local context, Source* source, size_t arguments_count = 0, Local arguments[] = nullptr, size_t context_extension_count = 0, diff --git a/v8_c_api/src/v8include/v8-snapshot.h b/v8_c_api/src/v8include/v8-snapshot.h index 9e5a53f..8c8390b 100644 --- a/v8_c_api/src/v8include/v8-snapshot.h +++ b/v8_c_api/src/v8include/v8-snapshot.h @@ -68,6 +68,22 @@ struct SerializeContextDataCallback { void* data; }; +/** + * Similar to `SerializeInternalFieldsCallback`, but is used exclusively to + * serialize API wrappers. The pointers for API wrappers always point into the + * CppHeap. + */ +struct SerializeAPIWrapperCallback { + using CallbackFunction = StartupData (*)(Local holder, + void* cpp_heap_pointer, void* data); + explicit SerializeAPIWrapperCallback(CallbackFunction function = nullptr, + void* data = nullptr) + : callback(function), data(data) {} + + CallbackFunction callback; + void* data; +}; + /** * Callback and supporting data used to implement embedder logic to deserialize * internal fields of v8::Objects. @@ -97,6 +113,17 @@ struct DeserializeContextDataCallback { void* data; }; +struct DeserializeAPIWrapperCallback { + using CallbackFunction = void (*)(Local holder, StartupData payload, + void* data); + explicit DeserializeAPIWrapperCallback(CallbackFunction function = nullptr, + void* data = nullptr) + : callback(function), data(data) {} + + CallbackFunction callback; + void* data; +}; + /** * Helper class to create a snapshot data blob. * @@ -187,13 +214,17 @@ class V8_EXPORT SnapshotCreator { * context embedder data set by * v8::Context::SetAlignedPointerInEmbedderData(). * + * \param api_wrapper_serializer An optional callback used to serialize API + * wrapper references set via `v8::Object::Wrap()`. */ void SetDefaultContext( Local context, SerializeInternalFieldsCallback internal_fields_serializer = SerializeInternalFieldsCallback(), SerializeContextDataCallback context_data_serializer = - SerializeContextDataCallback()); + SerializeContextDataCallback(), + SerializeAPIWrapperCallback api_wrapper_serializer = + SerializeAPIWrapperCallback()); /** * Add additional context to be included in the snapshot blob. @@ -204,12 +235,17 @@ class V8_EXPORT SnapshotCreator { * * \param context_data_serializer Similar to context_data_serializer * in SetDefaultContext() but only applies to the context being added. + * + * \param api_wrapper_serializer Similar to api_wrapper_serializer + * in SetDefaultContext() but only applies to the context being added. */ size_t AddContext(Local context, SerializeInternalFieldsCallback internal_fields_serializer = SerializeInternalFieldsCallback(), SerializeContextDataCallback context_data_serializer = - SerializeContextDataCallback()); + SerializeContextDataCallback(), + SerializeAPIWrapperCallback api_wrapper_serializer = + SerializeAPIWrapperCallback()); /** * Attach arbitrary V8::Data to the context snapshot, which can be retrieved diff --git a/v8_c_api/src/v8include/v8-template.h b/v8_c_api/src/v8include/v8-template.h index 6a0c898..f143554 100644 --- a/v8_c_api/src/v8include/v8-template.h +++ b/v8_c_api/src/v8include/v8-template.h @@ -80,21 +80,21 @@ class V8_EXPORT Template : public Data { * \param attribute The attributes of the property for which an accessor * is added. */ - V8_DEPRECATE_SOON("Use SetNativeDataProperty without AccessControl instead") + V8_DEPRECATED("Use SetNativeDataProperty without AccessControl instead") void SetNativeDataProperty( Local name, AccessorGetterCallback getter, AccessorSetterCallback setter, Local data, PropertyAttribute attribute, AccessControl settings, SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect, SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect); - V8_DEPRECATE_SOON("Use SetNativeDataProperty without AccessControl instead") + V8_DEPRECATED("Use SetNativeDataProperty without AccessControl instead") void SetNativeDataProperty( Local name, AccessorNameGetterCallback getter, AccessorNameSetterCallback setter, Local data, PropertyAttribute attribute, AccessControl settings, SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect, SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect); - V8_DEPRECATE_SOON("Use SetNativeDataProperty with Local instead") + V8_DEPRECATED("Use SetNativeDataProperty with Local instead") void SetNativeDataProperty( Local name, AccessorGetterCallback getter, AccessorSetterCallback setter = nullptr, @@ -142,7 +142,8 @@ enum class Intercepted : uint8_t { kNo = 0, kYes = 1 }; * Interceptor for get requests on an object. * * If the interceptor handles the request (i.e. the property should not be - * looked up beyond the interceptor) it should + * looked up beyond the interceptor or in case an exception was thrown) it + * should * - (optionally) use info.GetReturnValue().Set()` to set the return value * (by default the result is set to v8::Undefined), * - return `Intercepted::kYes`. @@ -194,7 +195,8 @@ using GenericNamedPropertyGetterCallback = * Interceptor for set requests on an object. * * If the interceptor handles the request (i.e. the property should not be - * looked up beyond the interceptor) it should return `Intercepted::kYes`. + * looked up beyond the interceptor or in case an exception was thrown) it + * should return `Intercepted::kYes`. * If the interceptor does not handle the request it must return * `Intercepted::kNo` and it must not produce side effects. * @@ -229,9 +231,10 @@ using GenericNamedPropertySetterCallback = * defineProperty(). * * If the interceptor handles the request (i.e. the property should not be - * looked up beyond the interceptor) it should - * - use `info.GetReturnValue().Set()` to set to an Integer value encoding - * a `v8::PropertyAttribute` bits, + * looked up beyond the interceptor or in case an exception was thrown) it + * should + * - (optionally) use `info.GetReturnValue().Set()` to set to an Integer + * value encoding a `v8::PropertyAttribute` bits, * - return `Intercepted::kYes`. * If the interceptor does not handle the request it must return * `Intercepted::kNo` and it must not produce side effects. @@ -263,9 +266,10 @@ using GenericNamedPropertyQueryCallback = * Interceptor for delete requests on an object. * * If the interceptor handles the request (i.e. the property should not be - * looked up beyond the interceptor) it should - * - use `info.GetReturnValue().Set()` to set to a Boolean value indicating - * whether the property deletion was successful or not, + * looked up beyond the interceptor or in case an exception was thrown) it + * should + * - (optionally) use `info.GetReturnValue().Set()` to set to a Boolean value + * indicating whether the property deletion was successful or not, * - return `Intercepted::kYes`. * If the interceptor does not handle the request it must return * `Intercepted::kNo` and it must not produce side effects. @@ -311,7 +315,8 @@ using GenericNamedPropertyEnumeratorCallback = NamedPropertyEnumeratorCallback; * Interceptor for defineProperty requests on an object. * * If the interceptor handles the request (i.e. the property should not be - * looked up beyond the interceptor) it should return `Intercepted::kYes`. + * looked up beyond the interceptor or in case an exception was thrown) it + * should return `Intercepted::kYes`. * If the interceptor does not handle the request it must return * `Intercepted::kNo` and it must not produce side effects. * @@ -344,10 +349,11 @@ using GenericNamedPropertyDefinerCallback = * Interceptor for getOwnPropertyDescriptor requests on an object. * * If the interceptor handles the request (i.e. the property should not be - * looked up beyond the interceptor) it should - * - use `info.GetReturnValue().Set()` to set the return value which must be - * object that can be converted to a PropertyDescriptor (for example, - * a value returned by `v8::Object::getOwnPropertyDescriptor`), + * looked up beyond the interceptor or in case an exception was thrown) it + * should + * - (optionally) use `info.GetReturnValue().Set()` to set the return value + * which must be object that can be converted to a PropertyDescriptor (for + * example, a value returned by `v8::Object::getOwnPropertyDescriptor`), * - return `Intercepted::kYes`. * If the interceptor does not handle the request it must return * `Intercepted::kNo` and it must not produce side effects. @@ -379,7 +385,7 @@ using GenericNamedPropertyDescriptorCallback = // removed. /** - * See `v8::GenericNamedPropertyGetterCallback`. + * See `v8::NamedPropertyGetterCallback`. */ using IndexedPropertyGetterCallbackV2 = Intercepted (*)(uint32_t index, const PropertyCallbackInfo& info); @@ -388,7 +394,7 @@ using IndexedPropertyGetterCallback = void (*)(uint32_t index, const PropertyCallbackInfo& info); /** - * See `v8::GenericNamedPropertySetterCallback`. + * See `v8::NamedPropertySetterCallback`. */ using IndexedPropertySetterCallbackV2 = Intercepted (*)( uint32_t index, Local value, const PropertyCallbackInfo& info); @@ -398,7 +404,7 @@ using IndexedPropertySetterCallback = const PropertyCallbackInfo& info); /** - * See `v8::GenericNamedPropertyQueryCallback`. + * See `v8::NamedPropertyQueryCallback`. */ using IndexedPropertyQueryCallbackV2 = Intercepted (*)(uint32_t index, const PropertyCallbackInfo& info); @@ -407,7 +413,7 @@ using IndexedPropertyQueryCallback = void (*)(uint32_t index, const PropertyCallbackInfo& info); /** - * See `v8::GenericNamedPropertyDeleterCallback`. + * See `v8::NamedPropertyDeleterCallback`. */ using IndexedPropertyDeleterCallbackV2 = Intercepted (*)(uint32_t index, const PropertyCallbackInfo& info); @@ -425,7 +431,7 @@ using IndexedPropertyEnumeratorCallback = void (*)(const PropertyCallbackInfo& info); /** - * See `v8::GenericNamedPropertyDefinerCallback`. + * See `v8::NamedPropertyDefinerCallback`. */ using IndexedPropertyDefinerCallbackV2 = Intercepted (*)(uint32_t index, const PropertyDescriptor& desc, @@ -436,7 +442,7 @@ using IndexedPropertyDefinerCallback = const PropertyCallbackInfo& info); /** - * See `v8::GenericNamedPropertyDescriptorCallback`. + * See `v8::NamedPropertyDescriptorCallback`. */ using IndexedPropertyDescriptorCallbackV2 = Intercepted (*)(uint32_t index, const PropertyCallbackInfo& info); @@ -762,7 +768,9 @@ struct NamedPropertyHandlerConfiguration { data(data), flags(WithNewSignatureFlag(flags)) {} - // This variant will be deprecated soon. + V8_DEPRECATE_SOON( + "Provide interceptor callbacks with new signatures instead " + "(NamedPropertyXxxCallback)") NamedPropertyHandlerConfiguration( GenericNamedPropertyGetterCallback getter, GenericNamedPropertySetterCallback setter, @@ -801,7 +809,9 @@ struct NamedPropertyHandlerConfiguration { data(data), flags(WithNewSignatureFlag(flags)) {} - // This variant will be deprecated soon. + V8_DEPRECATE_SOON( + "Provide interceptor callbacks with new signatures instead " + "(NamedPropertyXxxCallback)") explicit NamedPropertyHandlerConfiguration( GenericNamedPropertyGetterCallback getter, GenericNamedPropertySetterCallback setter = nullptr, @@ -839,7 +849,9 @@ struct NamedPropertyHandlerConfiguration { data(data), flags(WithNewSignatureFlag(flags)) {} - // This variant will be deprecated soon. + V8_DEPRECATE_SOON( + "Provide interceptor callbacks with new signatures instead " + "(NamedPropertyXxxCallback)") NamedPropertyHandlerConfiguration( GenericNamedPropertyGetterCallback getter, GenericNamedPropertySetterCallback setter, @@ -901,7 +913,9 @@ struct IndexedPropertyHandlerConfiguration { data(data), flags(WithNewSignatureFlag(flags)) {} - // This variant will be deprecated soon. + V8_DEPRECATE_SOON( + "Provide interceptor callbacks with new signatures instead " + "(IndexedPropertyXxxCallbackV2)") IndexedPropertyHandlerConfiguration( IndexedPropertyGetterCallback getter, // IndexedPropertySetterCallback setter, // @@ -940,7 +954,9 @@ struct IndexedPropertyHandlerConfiguration { data(data), flags(WithNewSignatureFlag(flags)) {} - // This variant will be deprecated soon. + V8_DEPRECATE_SOON( + "Provide interceptor callbacks with new signatures instead " + "(IndexedPropertyXxxCallbackV2)") explicit IndexedPropertyHandlerConfiguration( IndexedPropertyGetterCallback getter, IndexedPropertySetterCallback setter = nullptr, @@ -978,7 +994,9 @@ struct IndexedPropertyHandlerConfiguration { data(data), flags(WithNewSignatureFlag(flags)) {} - // This variant will be deprecated soon. + V8_DEPRECATE_SOON( + "Provide interceptor callbacks with new signatures instead " + "(IndexedPropertyXxxCallbackV2)") IndexedPropertyHandlerConfiguration( IndexedPropertyGetterCallback getter, IndexedPropertySetterCallback setter, @@ -1045,7 +1063,7 @@ class V8_EXPORT ObjectTemplate : public Template { * \param attribute The attributes of the property for which an accessor * is added. */ - V8_DEPRECATE_SOON("Use SetAccessor with Local instead") + V8_DEPRECATED("Use SetAccessor with Local instead") void SetAccessor( Local name, AccessorGetterCallback getter, AccessorSetterCallback setter = nullptr, diff --git a/v8_c_api/src/v8include/v8-unwinder.h b/v8_c_api/src/v8include/v8-unwinder.h index 8b71bb3..5771eb0 100644 --- a/v8_c_api/src/v8include/v8-unwinder.h +++ b/v8_c_api/src/v8include/v8-unwinder.h @@ -42,7 +42,8 @@ enum StateTag : uint16_t { OTHER, EXTERNAL, ATOMICS_WAIT, - IDLE + IDLE, + LOGGING, }; // The output structure filled up by GetStackSample API function. diff --git a/v8_c_api/src/v8include/v8-version.h b/v8_c_api/src/v8include/v8-version.h index e769d42..d471810 100644 --- a/v8_c_api/src/v8include/v8-version.h +++ b/v8_c_api/src/v8include/v8-version.h @@ -9,9 +9,9 @@ // 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 12 -#define V8_MINOR_VERSION 4 -#define V8_BUILD_NUMBER 254 -#define V8_PATCH_LEVEL 17 +#define V8_MINOR_VERSION 5 +#define V8_BUILD_NUMBER 227 +#define V8_PATCH_LEVEL 13 // Use 1 for candidates and 0 otherwise. // (Boolean macro values are not supported by all preprocessors.) diff --git a/v8_c_api/src/v8include/v8-wasm.h b/v8_c_api/src/v8include/v8-wasm.h index 7151461..f8e406c 100644 --- a/v8_c_api/src/v8include/v8-wasm.h +++ b/v8_c_api/src/v8include/v8-wasm.h @@ -9,6 +9,7 @@ #include #include +#include "v8-internal.h" // NOLINT(build/include_directory) #include "v8-local-handle.h" // NOLINT(build/include_directory) #include "v8-memory-span.h" // NOLINT(build/include_directory) #include "v8-object.h" // NOLINT(build/include_directory) @@ -129,6 +130,8 @@ class V8_EXPORT WasmModuleObject : public Object { */ class V8_EXPORT WasmStreaming final { public: + static constexpr internal::ExternalPointerTag kManagedTag = + internal::kWasmWasmStreamingTag; class WasmStreamingImpl; explicit WasmStreaming(std::unique_ptr impl); diff --git a/v8_c_api/src/v8include/v8config.h b/v8_c_api/src/v8include/v8config.h index e649d8c..7565ebf 100644 --- a/v8_c_api/src/v8include/v8config.h +++ b/v8_c_api/src/v8include/v8config.h @@ -477,14 +477,23 @@ path. Add it with -I to the command line # define V8_INLINE inline #endif +#if V8_HAS_BUILTIN_ASSUME #ifdef DEBUG -// In debug mode, check assumptions instead of actually adding annotations. -# define V8_ASSUME DCHECK -#elif V8_HAS_BUILTIN_ASSUME +// In debug mode, check assumptions in addition to adding annotations. +// This helps GCC (and maybe other compilers) figure out that certain +// situations are unreachable. +# define V8_ASSUME(condition) \ + do { \ + DCHECK(condition); \ + __builtin_assume(condition); \ + } while (false) +#else // DEBUG # define V8_ASSUME __builtin_assume +#endif // DEBUG #elif V8_HAS_BUILTIN_UNREACHABLE # define V8_ASSUME(condition) \ do { \ + DCHECK(condition); \ if (!(condition)) __builtin_unreachable(); \ } while (false) #else