diff --git a/ios/include/v8/libplatform/DEPS b/ios/include/v8/libplatform/DEPS deleted file mode 100644 index d8bcf998..00000000 --- a/ios/include/v8/libplatform/DEPS +++ /dev/null @@ -1,9 +0,0 @@ -include_rules = [ - "+libplatform/libplatform-export.h", -] - -specific_include_rules = { - "libplatform\.h": [ - "+libplatform/v8-tracing.h", - ], -} diff --git a/ios/include/v8/libplatform/v8-tracing.h b/ios/include/v8/libplatform/v8-tracing.h index 0eb7f4be..bc249cb9 100644 --- a/ios/include/v8/libplatform/v8-tracing.h +++ b/ios/include/v8/libplatform/v8-tracing.h @@ -23,8 +23,6 @@ class Mutex; namespace platform { namespace tracing { -class PerfettoTracingController; - const int kTraceMaxNumArgs = 2; class V8_PLATFORM_EXPORT TraceObject { @@ -240,11 +238,6 @@ class V8_PLATFORM_EXPORT TracingController TracingController(); ~TracingController() override; void Initialize(TraceBuffer* trace_buffer); -#ifdef V8_USE_PERFETTO - // Must be called before StartTracing() if V8_USE_PERFETTO is true. Provides - // the output stream for the JSON trace data. - void InitializeForPerfetto(std::ostream* output_stream); -#endif // v8::TracingController implementation. const uint8_t* GetCategoryGroupEnabled(const char* category_group) override; @@ -287,11 +280,6 @@ class V8_PLATFORM_EXPORT TracingController std::unique_ptr mutex_; std::unordered_set observers_; std::atomic_bool recording_{false}; -#ifdef V8_USE_PERFETTO - std::atomic_bool perfetto_recording_{false}; - std::unique_ptr perfetto_tracing_controller_; - std::ostream* output_stream_ = nullptr; -#endif // Disallow copy and assign TracingController(const TracingController&) = delete; diff --git a/ios/include/v8/v8-inspector.h b/ios/include/v8/v8-inspector.h index b96a6e29..70201358 100644 --- a/ios/include/v8/v8-inspector.h +++ b/ios/include/v8/v8-inspector.h @@ -87,6 +87,7 @@ class V8_EXPORT V8ContextInfo { static int executionContextId(v8::Local context); + private: // Disallow copying and allocating this one. enum NotNullTagEnum { NotNullLiteral }; void* operator new(size_t) = delete; @@ -130,11 +131,7 @@ class V8_EXPORT V8InspectorSession { // Dispatching protocol messages. static bool canDispatchMethod(const StringView& method); virtual void dispatchProtocolMessage(const StringView& message) = 0; - virtual V8_DEPRECATED("Use state() instead", - std::unique_ptr stateJSON()) { - return nullptr; - } - virtual std::vector state() = 0; + virtual std::unique_ptr stateJSON() = 0; virtual std::vector> supportedDomains() = 0; diff --git a/ios/include/v8/v8-internal.h b/ios/include/v8/v8-internal.h index ef13006d..8e700a4d 100644 --- a/ios/include/v8/v8-internal.h +++ b/ios/include/v8/v8-internal.h @@ -48,32 +48,28 @@ const intptr_t kSmiTagMask = (1 << kSmiTagSize) - 1; template struct SmiTagging; -constexpr intptr_t kIntptrAllBitsSet = intptr_t{-1}; -constexpr uintptr_t kUintptrAllBitsSet = - static_cast(kIntptrAllBitsSet); - // Smi constants for systems where tagged pointer is a 32-bit value. template <> struct SmiTagging<4> { enum { kSmiShiftSize = 0, kSmiValueSize = 31 }; - - static constexpr intptr_t kSmiMinValue = - static_cast(kUintptrAllBitsSet << (kSmiValueSize - 1)); - static constexpr intptr_t kSmiMaxValue = -(kSmiMinValue + 1); - V8_INLINE static int SmiToInt(const internal::Address value) { int shift_bits = kSmiTagSize + kSmiShiftSize; // Shift down (requires >> to be sign extending). return static_cast(static_cast(value)) >> shift_bits; } V8_INLINE static constexpr bool IsValidSmi(intptr_t value) { - // Is value in range [kSmiMinValue, kSmiMaxValue]. - // Use unsigned operations in order to avoid undefined behaviour in case of - // signed integer overflow. - return (static_cast(value) - - static_cast(kSmiMinValue)) <= - (static_cast(kSmiMaxValue) - - static_cast(kSmiMinValue)); + // To be representable as an tagged small integer, the two + // most-significant bits of 'value' must be either 00 or 11 due to + // sign-extension. To check this we add 01 to the two + // most-significant bits, and check if the most-significant bit is 0. + // + // CAUTION: The original code below: + // bool result = ((value + 0x40000000) & 0x80000000) == 0; + // may lead to incorrect results according to the C language spec, and + // in fact doesn't work correctly with gcc4.1.1 in some cases: The + // compiler may produce undefined results in case of signed integer + // overflow. The computation must be done w/ unsigned ints. + return static_cast(value) + 0x40000000U < 0x80000000U; } }; @@ -81,11 +77,6 @@ struct SmiTagging<4> { template <> struct SmiTagging<8> { enum { kSmiShiftSize = 31, kSmiValueSize = 32 }; - - static constexpr intptr_t kSmiMinValue = - static_cast(kUintptrAllBitsSet << (kSmiValueSize - 1)); - static constexpr intptr_t kSmiMaxValue = -(kSmiMinValue + 1); - V8_INLINE static int SmiToInt(const internal::Address value) { int shift_bits = kSmiTagSize + kSmiShiftSize; // Shift down and throw away top 32 bits. @@ -107,15 +98,15 @@ const int kApiTaggedSize = kApiSystemPointerSize; #endif #ifdef V8_31BIT_SMIS_ON_64BIT_ARCH -using PlatformSmiTagging = SmiTagging; +typedef SmiTagging PlatformSmiTagging; #else -using PlatformSmiTagging = SmiTagging; +typedef SmiTagging PlatformSmiTagging; #endif const int kSmiShiftSize = PlatformSmiTagging::kSmiShiftSize; const int kSmiValueSize = PlatformSmiTagging::kSmiValueSize; -const int kSmiMinValue = static_cast(PlatformSmiTagging::kSmiMinValue); -const int kSmiMaxValue = static_cast(PlatformSmiTagging::kSmiMaxValue); +const int kSmiMinValue = (static_cast(-1)) << (kSmiValueSize - 1); +const int kSmiMaxValue = -(kSmiMinValue + 1); constexpr bool SmiValuesAre31Bits() { return kSmiValueSize == 31; } constexpr bool SmiValuesAre32Bits() { return kSmiValueSize == 32; } @@ -174,6 +165,8 @@ class Internals { static const int kNodeStateMask = 0x7; static const int kNodeStateIsWeakValue = 2; static const int kNodeStateIsPendingValue = 3; + static const int kNodeIsIndependentShift = 3; + static const int kNodeIsActiveShift = 4; static const int kFirstNonstringType = 0x40; static const int kOddballType = 0x43; diff --git a/ios/include/v8/v8-platform.h b/ios/include/v8/v8-platform.h index b707fafc..556407d8 100644 --- a/ios/include/v8/v8-platform.h +++ b/ios/include/v8/v8-platform.h @@ -109,6 +109,7 @@ class TaskRunner { TaskRunner() = default; virtual ~TaskRunner() = default; + private: TaskRunner(const TaskRunner&) = delete; TaskRunner& operator=(const TaskRunner&) = delete; }; diff --git a/ios/include/v8/v8-profiler.h b/ios/include/v8/v8-profiler.h index 46d3eb8a..672a694e 100644 --- a/ios/include/v8/v8-profiler.h +++ b/ios/include/v8/v8-profiler.h @@ -5,7 +5,6 @@ #ifndef V8_V8_PROFILER_H_ #define V8_V8_PROFILER_H_ -#include #include #include #include "v8.h" // NOLINT(build/include) @@ -298,53 +297,6 @@ enum CpuProfilingMode { kCallerLineNumbers, }; -// Determines how names are derived for functions sampled. -enum CpuProfilingNamingMode { - // Use the immediate name of functions at compilation time. - kStandardNaming, - // Use more verbose naming for functions without names, inferred from scope - // where possible. - kDebugNaming, -}; - -/** - * Optional profiling attributes. - */ -class V8_EXPORT CpuProfilingOptions { - public: - // Indicates that the sample buffer size should not be explicitly limited. - static const unsigned kNoSampleLimit = UINT_MAX; - - /** - * \param mode Type of computation of stack frame line numbers. - * \param max_samples The maximum number of samples that should be recorded by - * the profiler. Samples obtained after this limit will be - * discarded. - * \param sampling_interval_us controls the profile-specific target - * sampling interval. The provided sampling - * interval will be snapped to the next lowest - * non-zero multiple of the profiler's sampling - * interval, set via SetSamplingInterval(). If - * zero, the sampling interval will be equal to - * the profiler's sampling interval. - */ - CpuProfilingOptions(CpuProfilingMode mode = kLeafNodeLineNumbers, - unsigned max_samples = kNoSampleLimit, - int sampling_interval_us = 0) - : mode_(mode), - max_samples_(max_samples), - sampling_interval_us_(sampling_interval_us) {} - - CpuProfilingMode mode() const { return mode_; } - unsigned max_samples() const { return max_samples_; } - int sampling_interval_us() const { return sampling_interval_us_; } - - private: - CpuProfilingMode mode_; - unsigned max_samples_; - int sampling_interval_us_; -}; - /** * Interface for controlling CPU profiling. Instance of the * profiler can be created using v8::CpuProfiler::New method. @@ -356,8 +308,7 @@ class V8_EXPORT CpuProfiler { * initialized. The profiler object must be disposed after use by calling * |Dispose| method. */ - static CpuProfiler* New(Isolate* isolate, - CpuProfilingNamingMode = kDebugNaming); + static CpuProfiler* New(Isolate* isolate); /** * Synchronously collect current stack sample in all profilers attached to @@ -388,26 +339,18 @@ class V8_EXPORT CpuProfiler { void SetUsePreciseSampling(bool); /** - * Starts collecting a CPU profile. Title may be an empty string. Several - * profiles may be collected at once. Attempts to start collecting several - * profiles with the same title are silently ignored. - */ - void StartProfiling(Local title, CpuProfilingOptions options); - - /** - * Starts profiling with the same semantics as above, except with expanded - * parameters. + * Starts collecting CPU profile. Title may be an empty string. It + * is allowed to have several profiles being collected at + * once. Attempts to start collecting several profiles with the same + * title are silently ignored. While collecting a profile, functions + * from all security contexts are included in it. The token-based + * filtering is only performed when querying for a profile. * * |record_samples| parameter controls whether individual samples should * be recorded in addition to the aggregated tree. - * - * |max_samples| controls the maximum number of samples that should be - * recorded by the profiler. Samples obtained after this limit will be - * discarded. */ - void StartProfiling( - Local title, CpuProfilingMode mode, bool record_samples = false, - unsigned max_samples = CpuProfilingOptions::kNoSampleLimit); + void StartProfiling(Local title, CpuProfilingMode mode, + bool record_samples = false); /** * The same as StartProfiling above, but the CpuProfilingMode defaults to * kLeafNodeLineNumbers mode, which was the previous default behavior of the @@ -448,6 +391,7 @@ class V8_EXPORT CpuProfiler { CpuProfiler& operator=(const CpuProfiler&); }; + /** * HeapSnapshotEdge represents a directed connection between heap * graph nodes: from retainers to retained nodes. @@ -798,6 +742,7 @@ class V8_EXPORT EmbedderGraph { */ virtual const char* NamePrefix() { return nullptr; } + private: Node(const Node&) = delete; Node& operator=(const Node&) = delete; }; diff --git a/ios/include/v8/v8-util.h b/ios/include/v8/v8-util.h index 29d813e4..24962607 100644 --- a/ios/include/v8/v8-util.h +++ b/ios/include/v8/v8-util.h @@ -194,6 +194,14 @@ class PersistentValueMapBase { return SetReturnValueFromVal(&returnValue, Traits::Get(&impl_, key)); } + /** + * Call V8::RegisterExternallyReferencedObject with the map value for given + * key. + */ + V8_DEPRECATED( + "Used TracedGlobal and EmbedderHeapTracer::RegisterEmbedderReference", + inline void RegisterExternallyReferencedObject(K& key)); + /** * Return value for key and remove it from the map. */ @@ -344,6 +352,16 @@ class PersistentValueMapBase { const char* label_; }; +template +inline void +PersistentValueMapBase::RegisterExternallyReferencedObject( + K& key) { + assert(Contains(key)); + V8::RegisterExternallyReferencedObject( + reinterpret_cast(FromVal(Traits::Get(&impl_, key))), + reinterpret_cast(GetIsolate())); +} + template class PersistentValueMap : public PersistentValueMapBase { public: diff --git a/ios/include/v8/v8-version.h b/ios/include/v8/v8-version.h index 21f0a793..dfcd5b46 100644 --- a/ios/include/v8/v8-version.h +++ b/ios/include/v8/v8-version.h @@ -9,12 +9,12 @@ // 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 7 -#define V8_MINOR_VERSION 6 -#define V8_BUILD_NUMBER 0 -#define V8_PATCH_LEVEL 0 +#define V8_MINOR_VERSION 5 +#define V8_BUILD_NUMBER 288 +#define V8_PATCH_LEVEL 22 // Use 1 for candidates and 0 otherwise. // (Boolean macro values are not supported by all preprocessors.) -#define V8_IS_CANDIDATE_VERSION 1 +#define V8_IS_CANDIDATE_VERSION 0 #endif // V8_INCLUDE_VERSION_H_ diff --git a/ios/include/v8/v8.h b/ios/include/v8/v8.h index c54b0884..b4b92055 100644 --- a/ios/include/v8/v8.h +++ b/ios/include/v8/v8.h @@ -122,6 +122,7 @@ class ExternalString; class Isolate; class LocalEmbedderHeapTracer; class MicrotaskQueue; +class NeverReadOnlySpaceObject; struct ScriptStreamingData; template class CustomArguments; class PropertyCallbackArguments; @@ -544,6 +545,38 @@ template class PersistentBase { */ V8_INLINE void AnnotateStrongRetainer(const char* label); + /** + * Allows the embedder to tell the v8 garbage collector that a certain object + * is alive. Only allowed when the embedder is asked to trace its heap by + * EmbedderHeapTracer. + */ + V8_DEPRECATED( + "Used TracedGlobal and EmbedderHeapTracer::RegisterEmbedderReference", + V8_INLINE void RegisterExternalReference(Isolate* isolate) const); + + /** + * Marks the reference to this object independent. Garbage collector is free + * to ignore any object groups containing this object. Weak callback for an + * independent handle should not assume that it will be preceded by a global + * GC prologue callback or followed by a global GC epilogue callback. + */ + V8_DEPRECATED( + "Weak objects are always considered independent. " + "Use TracedGlobal when trying to use EmbedderHeapTracer. " + "Use a strong handle when trying to keep an object alive.", + V8_INLINE void MarkIndependent()); + + /** + * Marks the reference to this object as active. The scavenge garbage + * collection should not reclaim the objects marked as active, even if the + * object held by the handle is otherwise unreachable. + * + * This bit is cleared after the each garbage collection pass. + */ + V8_DEPRECATED("Use TracedGlobal.", V8_INLINE void MarkActive()); + + V8_DEPRECATED("See MarkIndependent.", V8_INLINE bool IsIndependent() const); + /** Returns true if the handle's reference is weak. */ V8_INLINE bool IsWeak() const; @@ -1900,11 +1933,6 @@ class V8_EXPORT StackFrame { * Returns whether or not the associated functions is defined in wasm. */ bool IsWasm() const; - - /** - * Returns whether or not the associated function is defined by the user. - */ - bool IsUserJavaScript() const; }; @@ -1923,11 +1951,10 @@ enum StateTag { // A RegisterState represents the current state of registers used // by the sampling profiler API. struct RegisterState { - RegisterState() : pc(nullptr), sp(nullptr), fp(nullptr), lr(nullptr) {} + RegisterState() : pc(nullptr), sp(nullptr), fp(nullptr) {} void* pc; // Instruction pointer. void* sp; // Stack pointer. void* fp; // Frame pointer. - void* lr; // Link register (or nullptr on platforms without a link register). }; // The output structure filled up by GetStackSample API function. @@ -2093,10 +2120,10 @@ class V8_EXPORT ValueSerializer { void WriteDouble(double value); void WriteRawBytes(const void* source, size_t length); + private: ValueSerializer(const ValueSerializer&) = delete; void operator=(const ValueSerializer&) = delete; - private: struct PrivateData; PrivateData* private_; }; @@ -2195,10 +2222,10 @@ class V8_EXPORT ValueDeserializer { V8_WARN_UNUSED_RESULT bool ReadDouble(double* value); V8_WARN_UNUSED_RESULT bool ReadRawBytes(size_t length, const void** data); + private: ValueDeserializer(const ValueDeserializer&) = delete; void operator=(const ValueDeserializer&) = delete; - private: struct PrivateData; PrivateData* private_; }; @@ -2493,6 +2520,9 @@ class V8_EXPORT Value : public Data { V8_WARN_UNUSED_RESULT MaybeLocal ToBigInt( Local context) const; + V8_DEPRECATED("ToBoolean can never throw. Use Local version.", + V8_WARN_UNUSED_RESULT MaybeLocal ToBoolean( + Local context) const); V8_WARN_UNUSED_RESULT MaybeLocal ToNumber( Local context) const; V8_WARN_UNUSED_RESULT MaybeLocal ToString( @@ -2508,6 +2538,16 @@ class V8_EXPORT Value : public Data { V8_WARN_UNUSED_RESULT MaybeLocal ToInt32(Local context) const; Local ToBoolean(Isolate* isolate) const; + V8_DEPRECATED("Use maybe version", + Local ToNumber(Isolate* isolate) const); + V8_DEPRECATED("Use maybe version", + Local ToString(Isolate* isolate) const); + V8_DEPRECATED("Use maybe version", + Local ToObject(Isolate* isolate) const); + V8_DEPRECATED("Use maybe version", + Local ToInteger(Isolate* isolate) const); + V8_DEPRECATED("Use maybe version", + Local ToInt32(Isolate* isolate) const); /** * Attempts to convert a string to an array index. @@ -2518,6 +2558,9 @@ class V8_EXPORT Value : public Data { bool BooleanValue(Isolate* isolate) const; + V8_DEPRECATED("BooleanValue can never throw. Use Isolate version.", + V8_WARN_UNUSED_RESULT Maybe BooleanValue( + Local context) const); V8_WARN_UNUSED_RESULT Maybe NumberValue(Local context) const; V8_WARN_UNUSED_RESULT Maybe IntegerValue( Local context) const; @@ -2721,10 +2764,6 @@ class V8_EXPORT String : public Name { */ virtual bool IsCacheable() const { return true; } - // Disallow copying and assigning. - ExternalStringResourceBase(const ExternalStringResourceBase&) = delete; - void operator=(const ExternalStringResourceBase&) = delete; - protected: ExternalStringResourceBase() = default; @@ -2754,6 +2793,10 @@ class V8_EXPORT String : public Name { */ virtual void Unlock() const {} + // Disallow copying and assigning. + ExternalStringResourceBase(const ExternalStringResourceBase&) = delete; + void operator=(const ExternalStringResourceBase&) = delete; + private: friend class internal::ExternalString; friend class v8::String; @@ -2837,23 +2880,43 @@ class V8_EXPORT String : public Name { V8_INLINE static String* Cast(v8::Value* obj); + // TODO(dcarney): remove with deprecation of New functions. + enum NewStringType { + kNormalString = static_cast(v8::NewStringType::kNormal), + kInternalizedString = static_cast(v8::NewStringType::kInternalized) + }; + + /** Allocates a new string from UTF-8 data.*/ + static V8_DEPRECATED( + "Use maybe version", + Local NewFromUtf8(Isolate* isolate, const char* data, + NewStringType type = kNormalString, + int length = -1)); + /** Allocates a new string from UTF-8 data. Only returns an empty value when * length > kMaxLength. **/ static V8_WARN_UNUSED_RESULT MaybeLocal NewFromUtf8( - Isolate* isolate, const char* data, - NewStringType type = NewStringType::kNormal, int length = -1); + Isolate* isolate, const char* data, v8::NewStringType type, + int length = -1); /** Allocates a new string from Latin-1 data. Only returns an empty value * when length > kMaxLength. **/ static V8_WARN_UNUSED_RESULT MaybeLocal NewFromOneByte( - Isolate* isolate, const uint8_t* data, - NewStringType type = NewStringType::kNormal, int length = -1); + Isolate* isolate, const uint8_t* data, v8::NewStringType type, + int length = -1); + + /** Allocates a new string from UTF-16 data.*/ + static V8_DEPRECATED( + "Use maybe version", + Local NewFromTwoByte(Isolate* isolate, const uint16_t* data, + NewStringType type = kNormalString, + int length = -1)); /** Allocates a new string from UTF-16 data. Only returns an empty value when * length > kMaxLength. **/ static V8_WARN_UNUSED_RESULT MaybeLocal NewFromTwoByte( - Isolate* isolate, const uint16_t* data, - NewStringType type = NewStringType::kNormal, int length = -1); + Isolate* isolate, const uint16_t* data, v8::NewStringType type, + int length = -1); /** * Creates a new string by concatenating the left and the right strings @@ -2892,6 +2955,10 @@ class V8_EXPORT String : public Name { * should the underlying buffer be deallocated or modified except through the * destructor of the external string resource. */ + static V8_DEPRECATED( + "Use maybe version", + Local NewExternal(Isolate* isolate, + ExternalOneByteStringResource* resource)); static V8_WARN_UNUSED_RESULT MaybeLocal NewExternalOneByte( Isolate* isolate, ExternalOneByteStringResource* resource); @@ -3288,8 +3355,8 @@ enum class IntegrityLevel { kFrozen, kSealed }; */ class V8_EXPORT Object : public Value { public: - V8_DEPRECATED("Use maybe version", - bool Set(Local key, Local value)); + V8_DEPRECATE_SOON("Use maybe version", + bool Set(Local key, Local value)); /** * Set only return Just(true) or Empty(), so if it should never fail, use * result.Check(). @@ -3297,8 +3364,8 @@ class V8_EXPORT Object : public Value { V8_WARN_UNUSED_RESULT Maybe Set(Local context, Local key, Local value); - V8_DEPRECATED("Use maybe version", - bool Set(uint32_t index, Local value)); + V8_DEPRECATE_SOON("Use maybe version", + bool Set(uint32_t index, Local value)); V8_WARN_UNUSED_RESULT Maybe Set(Local context, uint32_t index, Local value); @@ -3342,11 +3409,11 @@ class V8_EXPORT Object : public Value { V8_WARN_UNUSED_RESULT Maybe DefineProperty( Local context, Local key, PropertyDescriptor& descriptor); - V8_DEPRECATED("Use maybe version", Local Get(Local key)); + V8_DEPRECATE_SOON("Use maybe version", Local Get(Local key)); V8_WARN_UNUSED_RESULT MaybeLocal Get(Local context, Local key); - V8_DEPRECATED("Use maybe version", Local Get(uint32_t index)); + V8_DEPRECATE_SOON("Use maybe version", Local Get(uint32_t index)); V8_WARN_UNUSED_RESULT MaybeLocal Get(Local context, uint32_t index); @@ -3830,6 +3897,9 @@ class ReturnValue { } // Local setters template + V8_INLINE V8_DEPRECATED("Use Global<> instead", + void Set(const Persistent& handle)); + template V8_INLINE void Set(const Global& handle); template V8_INLINE void Set(const TracedGlobal& handle); @@ -5217,6 +5287,38 @@ class V8_EXPORT Date : public Object { V8_INLINE static Date* Cast(Value* obj); + /** + * Time zone redetection indicator for + * DateTimeConfigurationChangeNotification. + * + * kSkip indicates V8 that the notification should not trigger redetecting + * host time zone. kRedetect indicates V8 that host time zone should be + * redetected, and used to set the default time zone. + * + * The host time zone detection may require file system access or similar + * operations unlikely to be available inside a sandbox. If v8 is run inside a + * sandbox, the host time zone has to be detected outside the sandbox before + * calling DateTimeConfigurationChangeNotification function. + */ + enum class TimeZoneDetection { kSkip, kRedetect }; + + /** + * Notification that the embedder has changed the time zone, + * daylight savings time, or other date / time configuration + * parameters. V8 keeps a cache of various values used for + * date / time computation. This notification will reset + * those cached values for the current context so that date / + * time configuration changes would be reflected in the Date + * object. + * + * This API should not be called more than needed as it will + * negatively impact the performance of date operations. + */ + V8_DEPRECATED("Use Isolate::DateTimeConfigurationChangeNotification", + static void DateTimeConfigurationChangeNotification( + Isolate* isolate, TimeZoneDetection time_zone_detection = + TimeZoneDetection::kSkip)); + private: static void CheckCast(Value* obj); }; @@ -5902,6 +6004,21 @@ class V8_EXPORT FunctionTemplate : public Template { */ void SetAcceptAnyReceiver(bool value); + /** + * Determines whether the __proto__ accessor ignores instances of + * the function template. If instances of the function template are + * ignored, __proto__ skips all instances and instead returns the + * next object in the prototype chain. + * + * Call with a value of true to make the __proto__ accessor ignore + * instances of the function template. Call with a value of false + * to make the __proto__ accessor not ignore instances of the + * function template. By default, instances of a function template + * are not ignored. + */ + V8_DEPRECATED("This feature is incompatible with ES6+.", + void SetHiddenPrototype(bool value)); + /** * Sets the ReadOnly flag in the attributes of the 'prototype' property * of functions created from this FunctionTemplate to true. @@ -6706,12 +6823,11 @@ class V8_EXPORT MicrotaskQueue { */ virtual int GetMicrotasksScopeDepth() const = 0; - MicrotaskQueue(const MicrotaskQueue&) = delete; - MicrotaskQueue& operator=(const MicrotaskQueue&) = delete; - private: friend class internal::MicrotaskQueue; MicrotaskQueue() = default; + MicrotaskQueue(const MicrotaskQueue&) = delete; + MicrotaskQueue& operator=(const MicrotaskQueue&) = delete; }; /** @@ -7102,11 +7218,6 @@ enum class MemoryPressureLevel { kNone, kModerate, kCritical }; */ class V8_EXPORT EmbedderHeapTracer { public: - enum TraceFlags : uint64_t { - kNoFlags = 0, - kReduceMemory = 1 << 0, - }; - // Indicator for the stack state of the embedder. enum EmbedderStackState { kUnknown, @@ -7123,24 +7234,6 @@ class V8_EXPORT EmbedderHeapTracer { virtual void VisitTracedGlobalHandle(const TracedGlobal& value) = 0; }; - /** - * 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; /** @@ -7163,8 +7256,7 @@ class V8_EXPORT EmbedderHeapTracer { /** * Called at the beginning of a GC cycle. */ - V8_DEPRECATE_SOON("Use version with flags.", virtual void TracePrologue()) {} - virtual void TracePrologue(TraceFlags flags); + virtual void TracePrologue() = 0; /** * Called to advance tracing in the embedder. @@ -7187,12 +7279,9 @@ class V8_EXPORT EmbedderHeapTracer { /** * 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. + * Note that allocation is *not* allowed within |TraceEpilogue|. */ - virtual void TraceEpilogue() {} - virtual void TraceEpilogue(TraceSummary* trace_summary) { TraceEpilogue(); } + virtual void TraceEpilogue() = 0; /** * Called upon entering the final marking pause. No more incremental marking @@ -7229,14 +7318,6 @@ class V8_EXPORT EmbedderHeapTracer { */ void GarbageCollectionForTesting(EmbedderStackState stack_state); - /* - * Called by the embedder to signal newly allocated 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); - /* * Returns the v8::Isolate this tracer is attached too and |nullptr| if it * is not attached to any v8::Isolate. @@ -8529,13 +8610,6 @@ class V8_EXPORT Isolate { class V8_EXPORT StartupData { public: - /** - * Whether the data created can be rehashed and and the hash seed can be - * recomputed when deserialized. - * Only valid for StartupData returned by SnapshotCreator::CreateBlob(). - */ - bool CanBeRehashed() const; - const char* data; int raw_size; }; @@ -8594,10 +8668,7 @@ class V8_EXPORT V8 { /** * Sets V8 flags from a string. */ - static void SetFlagsFromString(const char* str); - static void SetFlagsFromString(const char* str, size_t length); - V8_DEPRECATED("use size_t version", - static void SetFlagsFromString(const char* str, int length)); + static void SetFlagsFromString(const char* str, int length); /** * Sets V8 flags from the command line. @@ -8768,6 +8839,9 @@ class V8_EXPORT V8 { const char* label); static Value* Eternalize(Isolate* isolate, Value* handle); + static void RegisterExternallyReferencedObject(internal::Address* location, + internal::Isolate* isolate); + template friend class PersistentValueMapBase; @@ -9714,6 +9788,14 @@ void Persistent::Copy(const Persistent& that) { M::Copy(that, this); } +template +bool PersistentBase::IsIndependent() const { + typedef internal::Internals I; + if (this->IsEmpty()) return false; + return I::GetNodeFlag(reinterpret_cast(this->val_), + I::kNodeIsIndependentShift); +} + template bool PersistentBase::IsWeak() const { typedef internal::Internals I; @@ -9780,6 +9862,31 @@ void PersistentBase::AnnotateStrongRetainer(const char* label) { label); } +template +void PersistentBase::RegisterExternalReference(Isolate* isolate) const { + if (IsEmpty()) return; + V8::RegisterExternallyReferencedObject( + reinterpret_cast(this->val_), + reinterpret_cast(isolate)); +} + +template +void PersistentBase::MarkIndependent() { + typedef internal::Internals I; + if (this->IsEmpty()) return; + I::UpdateNodeFlag(reinterpret_cast(this->val_), true, + I::kNodeIsIndependentShift); +} + +template +void PersistentBase::MarkActive() { + typedef internal::Internals I; + if (this->IsEmpty()) return; + I::UpdateNodeFlag(reinterpret_cast(this->val_), true, + I::kNodeIsActiveShift); +} + + template void PersistentBase::SetWrapperClassId(uint16_t class_id) { typedef internal::Internals I; @@ -9905,6 +10012,17 @@ void TracedGlobal::SetFinalizationCallback( template ReturnValue::ReturnValue(internal::Address* slot) : value_(slot) {} +template +template +void ReturnValue::Set(const Persistent& handle) { + TYPE_CHECK(T, S); + if (V8_UNLIKELY(handle.IsEmpty())) { + *value_ = GetDefaultValue(); + } else { + *value_ = *reinterpret_cast(*handle); + } +} + template template void ReturnValue::Set(const Global& handle) { @@ -10824,8 +10942,7 @@ int64_t Isolate::AdjustAmountOfExternalAllocatedMemory( *external_memory = amount; int64_t allocation_diff_since_last_mc = - static_cast(static_cast(*external_memory) - - static_cast(*external_memory_at_last_mc)); + *external_memory - *external_memory_at_last_mc; // Only check memory pressure and potentially trigger GC if the amount of // external memory increased. if (allocation_diff_since_last_mc > kMemoryReducerActivationLimit) { diff --git a/mac/include/v8/libplatform/DEPS b/mac/include/v8/libplatform/DEPS deleted file mode 100644 index d8bcf998..00000000 --- a/mac/include/v8/libplatform/DEPS +++ /dev/null @@ -1,9 +0,0 @@ -include_rules = [ - "+libplatform/libplatform-export.h", -] - -specific_include_rules = { - "libplatform\.h": [ - "+libplatform/v8-tracing.h", - ], -} diff --git a/mac/include/v8/libplatform/v8-tracing.h b/mac/include/v8/libplatform/v8-tracing.h index 0eb7f4be..bc249cb9 100644 --- a/mac/include/v8/libplatform/v8-tracing.h +++ b/mac/include/v8/libplatform/v8-tracing.h @@ -23,8 +23,6 @@ class Mutex; namespace platform { namespace tracing { -class PerfettoTracingController; - const int kTraceMaxNumArgs = 2; class V8_PLATFORM_EXPORT TraceObject { @@ -240,11 +238,6 @@ class V8_PLATFORM_EXPORT TracingController TracingController(); ~TracingController() override; void Initialize(TraceBuffer* trace_buffer); -#ifdef V8_USE_PERFETTO - // Must be called before StartTracing() if V8_USE_PERFETTO is true. Provides - // the output stream for the JSON trace data. - void InitializeForPerfetto(std::ostream* output_stream); -#endif // v8::TracingController implementation. const uint8_t* GetCategoryGroupEnabled(const char* category_group) override; @@ -287,11 +280,6 @@ class V8_PLATFORM_EXPORT TracingController std::unique_ptr mutex_; std::unordered_set observers_; std::atomic_bool recording_{false}; -#ifdef V8_USE_PERFETTO - std::atomic_bool perfetto_recording_{false}; - std::unique_ptr perfetto_tracing_controller_; - std::ostream* output_stream_ = nullptr; -#endif // Disallow copy and assign TracingController(const TracingController&) = delete; diff --git a/mac/include/v8/v8-inspector.h b/mac/include/v8/v8-inspector.h index b96a6e29..70201358 100644 --- a/mac/include/v8/v8-inspector.h +++ b/mac/include/v8/v8-inspector.h @@ -87,6 +87,7 @@ class V8_EXPORT V8ContextInfo { static int executionContextId(v8::Local context); + private: // Disallow copying and allocating this one. enum NotNullTagEnum { NotNullLiteral }; void* operator new(size_t) = delete; @@ -130,11 +131,7 @@ class V8_EXPORT V8InspectorSession { // Dispatching protocol messages. static bool canDispatchMethod(const StringView& method); virtual void dispatchProtocolMessage(const StringView& message) = 0; - virtual V8_DEPRECATED("Use state() instead", - std::unique_ptr stateJSON()) { - return nullptr; - } - virtual std::vector state() = 0; + virtual std::unique_ptr stateJSON() = 0; virtual std::vector> supportedDomains() = 0; diff --git a/mac/include/v8/v8-internal.h b/mac/include/v8/v8-internal.h index ef13006d..8e700a4d 100644 --- a/mac/include/v8/v8-internal.h +++ b/mac/include/v8/v8-internal.h @@ -48,32 +48,28 @@ const intptr_t kSmiTagMask = (1 << kSmiTagSize) - 1; template struct SmiTagging; -constexpr intptr_t kIntptrAllBitsSet = intptr_t{-1}; -constexpr uintptr_t kUintptrAllBitsSet = - static_cast(kIntptrAllBitsSet); - // Smi constants for systems where tagged pointer is a 32-bit value. template <> struct SmiTagging<4> { enum { kSmiShiftSize = 0, kSmiValueSize = 31 }; - - static constexpr intptr_t kSmiMinValue = - static_cast(kUintptrAllBitsSet << (kSmiValueSize - 1)); - static constexpr intptr_t kSmiMaxValue = -(kSmiMinValue + 1); - V8_INLINE static int SmiToInt(const internal::Address value) { int shift_bits = kSmiTagSize + kSmiShiftSize; // Shift down (requires >> to be sign extending). return static_cast(static_cast(value)) >> shift_bits; } V8_INLINE static constexpr bool IsValidSmi(intptr_t value) { - // Is value in range [kSmiMinValue, kSmiMaxValue]. - // Use unsigned operations in order to avoid undefined behaviour in case of - // signed integer overflow. - return (static_cast(value) - - static_cast(kSmiMinValue)) <= - (static_cast(kSmiMaxValue) - - static_cast(kSmiMinValue)); + // To be representable as an tagged small integer, the two + // most-significant bits of 'value' must be either 00 or 11 due to + // sign-extension. To check this we add 01 to the two + // most-significant bits, and check if the most-significant bit is 0. + // + // CAUTION: The original code below: + // bool result = ((value + 0x40000000) & 0x80000000) == 0; + // may lead to incorrect results according to the C language spec, and + // in fact doesn't work correctly with gcc4.1.1 in some cases: The + // compiler may produce undefined results in case of signed integer + // overflow. The computation must be done w/ unsigned ints. + return static_cast(value) + 0x40000000U < 0x80000000U; } }; @@ -81,11 +77,6 @@ struct SmiTagging<4> { template <> struct SmiTagging<8> { enum { kSmiShiftSize = 31, kSmiValueSize = 32 }; - - static constexpr intptr_t kSmiMinValue = - static_cast(kUintptrAllBitsSet << (kSmiValueSize - 1)); - static constexpr intptr_t kSmiMaxValue = -(kSmiMinValue + 1); - V8_INLINE static int SmiToInt(const internal::Address value) { int shift_bits = kSmiTagSize + kSmiShiftSize; // Shift down and throw away top 32 bits. @@ -107,15 +98,15 @@ const int kApiTaggedSize = kApiSystemPointerSize; #endif #ifdef V8_31BIT_SMIS_ON_64BIT_ARCH -using PlatformSmiTagging = SmiTagging; +typedef SmiTagging PlatformSmiTagging; #else -using PlatformSmiTagging = SmiTagging; +typedef SmiTagging PlatformSmiTagging; #endif const int kSmiShiftSize = PlatformSmiTagging::kSmiShiftSize; const int kSmiValueSize = PlatformSmiTagging::kSmiValueSize; -const int kSmiMinValue = static_cast(PlatformSmiTagging::kSmiMinValue); -const int kSmiMaxValue = static_cast(PlatformSmiTagging::kSmiMaxValue); +const int kSmiMinValue = (static_cast(-1)) << (kSmiValueSize - 1); +const int kSmiMaxValue = -(kSmiMinValue + 1); constexpr bool SmiValuesAre31Bits() { return kSmiValueSize == 31; } constexpr bool SmiValuesAre32Bits() { return kSmiValueSize == 32; } @@ -174,6 +165,8 @@ class Internals { static const int kNodeStateMask = 0x7; static const int kNodeStateIsWeakValue = 2; static const int kNodeStateIsPendingValue = 3; + static const int kNodeIsIndependentShift = 3; + static const int kNodeIsActiveShift = 4; static const int kFirstNonstringType = 0x40; static const int kOddballType = 0x43; diff --git a/mac/include/v8/v8-platform.h b/mac/include/v8/v8-platform.h index b707fafc..556407d8 100644 --- a/mac/include/v8/v8-platform.h +++ b/mac/include/v8/v8-platform.h @@ -109,6 +109,7 @@ class TaskRunner { TaskRunner() = default; virtual ~TaskRunner() = default; + private: TaskRunner(const TaskRunner&) = delete; TaskRunner& operator=(const TaskRunner&) = delete; }; diff --git a/mac/include/v8/v8-profiler.h b/mac/include/v8/v8-profiler.h index 46d3eb8a..672a694e 100644 --- a/mac/include/v8/v8-profiler.h +++ b/mac/include/v8/v8-profiler.h @@ -5,7 +5,6 @@ #ifndef V8_V8_PROFILER_H_ #define V8_V8_PROFILER_H_ -#include #include #include #include "v8.h" // NOLINT(build/include) @@ -298,53 +297,6 @@ enum CpuProfilingMode { kCallerLineNumbers, }; -// Determines how names are derived for functions sampled. -enum CpuProfilingNamingMode { - // Use the immediate name of functions at compilation time. - kStandardNaming, - // Use more verbose naming for functions without names, inferred from scope - // where possible. - kDebugNaming, -}; - -/** - * Optional profiling attributes. - */ -class V8_EXPORT CpuProfilingOptions { - public: - // Indicates that the sample buffer size should not be explicitly limited. - static const unsigned kNoSampleLimit = UINT_MAX; - - /** - * \param mode Type of computation of stack frame line numbers. - * \param max_samples The maximum number of samples that should be recorded by - * the profiler. Samples obtained after this limit will be - * discarded. - * \param sampling_interval_us controls the profile-specific target - * sampling interval. The provided sampling - * interval will be snapped to the next lowest - * non-zero multiple of the profiler's sampling - * interval, set via SetSamplingInterval(). If - * zero, the sampling interval will be equal to - * the profiler's sampling interval. - */ - CpuProfilingOptions(CpuProfilingMode mode = kLeafNodeLineNumbers, - unsigned max_samples = kNoSampleLimit, - int sampling_interval_us = 0) - : mode_(mode), - max_samples_(max_samples), - sampling_interval_us_(sampling_interval_us) {} - - CpuProfilingMode mode() const { return mode_; } - unsigned max_samples() const { return max_samples_; } - int sampling_interval_us() const { return sampling_interval_us_; } - - private: - CpuProfilingMode mode_; - unsigned max_samples_; - int sampling_interval_us_; -}; - /** * Interface for controlling CPU profiling. Instance of the * profiler can be created using v8::CpuProfiler::New method. @@ -356,8 +308,7 @@ class V8_EXPORT CpuProfiler { * initialized. The profiler object must be disposed after use by calling * |Dispose| method. */ - static CpuProfiler* New(Isolate* isolate, - CpuProfilingNamingMode = kDebugNaming); + static CpuProfiler* New(Isolate* isolate); /** * Synchronously collect current stack sample in all profilers attached to @@ -388,26 +339,18 @@ class V8_EXPORT CpuProfiler { void SetUsePreciseSampling(bool); /** - * Starts collecting a CPU profile. Title may be an empty string. Several - * profiles may be collected at once. Attempts to start collecting several - * profiles with the same title are silently ignored. - */ - void StartProfiling(Local title, CpuProfilingOptions options); - - /** - * Starts profiling with the same semantics as above, except with expanded - * parameters. + * Starts collecting CPU profile. Title may be an empty string. It + * is allowed to have several profiles being collected at + * once. Attempts to start collecting several profiles with the same + * title are silently ignored. While collecting a profile, functions + * from all security contexts are included in it. The token-based + * filtering is only performed when querying for a profile. * * |record_samples| parameter controls whether individual samples should * be recorded in addition to the aggregated tree. - * - * |max_samples| controls the maximum number of samples that should be - * recorded by the profiler. Samples obtained after this limit will be - * discarded. */ - void StartProfiling( - Local title, CpuProfilingMode mode, bool record_samples = false, - unsigned max_samples = CpuProfilingOptions::kNoSampleLimit); + void StartProfiling(Local title, CpuProfilingMode mode, + bool record_samples = false); /** * The same as StartProfiling above, but the CpuProfilingMode defaults to * kLeafNodeLineNumbers mode, which was the previous default behavior of the @@ -448,6 +391,7 @@ class V8_EXPORT CpuProfiler { CpuProfiler& operator=(const CpuProfiler&); }; + /** * HeapSnapshotEdge represents a directed connection between heap * graph nodes: from retainers to retained nodes. @@ -798,6 +742,7 @@ class V8_EXPORT EmbedderGraph { */ virtual const char* NamePrefix() { return nullptr; } + private: Node(const Node&) = delete; Node& operator=(const Node&) = delete; }; diff --git a/mac/include/v8/v8-util.h b/mac/include/v8/v8-util.h index 29d813e4..24962607 100644 --- a/mac/include/v8/v8-util.h +++ b/mac/include/v8/v8-util.h @@ -194,6 +194,14 @@ class PersistentValueMapBase { return SetReturnValueFromVal(&returnValue, Traits::Get(&impl_, key)); } + /** + * Call V8::RegisterExternallyReferencedObject with the map value for given + * key. + */ + V8_DEPRECATED( + "Used TracedGlobal and EmbedderHeapTracer::RegisterEmbedderReference", + inline void RegisterExternallyReferencedObject(K& key)); + /** * Return value for key and remove it from the map. */ @@ -344,6 +352,16 @@ class PersistentValueMapBase { const char* label_; }; +template +inline void +PersistentValueMapBase::RegisterExternallyReferencedObject( + K& key) { + assert(Contains(key)); + V8::RegisterExternallyReferencedObject( + reinterpret_cast(FromVal(Traits::Get(&impl_, key))), + reinterpret_cast(GetIsolate())); +} + template class PersistentValueMap : public PersistentValueMapBase { public: diff --git a/mac/include/v8/v8-version.h b/mac/include/v8/v8-version.h index 21f0a793..dfcd5b46 100644 --- a/mac/include/v8/v8-version.h +++ b/mac/include/v8/v8-version.h @@ -9,12 +9,12 @@ // 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 7 -#define V8_MINOR_VERSION 6 -#define V8_BUILD_NUMBER 0 -#define V8_PATCH_LEVEL 0 +#define V8_MINOR_VERSION 5 +#define V8_BUILD_NUMBER 288 +#define V8_PATCH_LEVEL 22 // Use 1 for candidates and 0 otherwise. // (Boolean macro values are not supported by all preprocessors.) -#define V8_IS_CANDIDATE_VERSION 1 +#define V8_IS_CANDIDATE_VERSION 0 #endif // V8_INCLUDE_VERSION_H_ diff --git a/mac/include/v8/v8.h b/mac/include/v8/v8.h index c54b0884..b4b92055 100644 --- a/mac/include/v8/v8.h +++ b/mac/include/v8/v8.h @@ -122,6 +122,7 @@ class ExternalString; class Isolate; class LocalEmbedderHeapTracer; class MicrotaskQueue; +class NeverReadOnlySpaceObject; struct ScriptStreamingData; template class CustomArguments; class PropertyCallbackArguments; @@ -544,6 +545,38 @@ template class PersistentBase { */ V8_INLINE void AnnotateStrongRetainer(const char* label); + /** + * Allows the embedder to tell the v8 garbage collector that a certain object + * is alive. Only allowed when the embedder is asked to trace its heap by + * EmbedderHeapTracer. + */ + V8_DEPRECATED( + "Used TracedGlobal and EmbedderHeapTracer::RegisterEmbedderReference", + V8_INLINE void RegisterExternalReference(Isolate* isolate) const); + + /** + * Marks the reference to this object independent. Garbage collector is free + * to ignore any object groups containing this object. Weak callback for an + * independent handle should not assume that it will be preceded by a global + * GC prologue callback or followed by a global GC epilogue callback. + */ + V8_DEPRECATED( + "Weak objects are always considered independent. " + "Use TracedGlobal when trying to use EmbedderHeapTracer. " + "Use a strong handle when trying to keep an object alive.", + V8_INLINE void MarkIndependent()); + + /** + * Marks the reference to this object as active. The scavenge garbage + * collection should not reclaim the objects marked as active, even if the + * object held by the handle is otherwise unreachable. + * + * This bit is cleared after the each garbage collection pass. + */ + V8_DEPRECATED("Use TracedGlobal.", V8_INLINE void MarkActive()); + + V8_DEPRECATED("See MarkIndependent.", V8_INLINE bool IsIndependent() const); + /** Returns true if the handle's reference is weak. */ V8_INLINE bool IsWeak() const; @@ -1900,11 +1933,6 @@ class V8_EXPORT StackFrame { * Returns whether or not the associated functions is defined in wasm. */ bool IsWasm() const; - - /** - * Returns whether or not the associated function is defined by the user. - */ - bool IsUserJavaScript() const; }; @@ -1923,11 +1951,10 @@ enum StateTag { // A RegisterState represents the current state of registers used // by the sampling profiler API. struct RegisterState { - RegisterState() : pc(nullptr), sp(nullptr), fp(nullptr), lr(nullptr) {} + RegisterState() : pc(nullptr), sp(nullptr), fp(nullptr) {} void* pc; // Instruction pointer. void* sp; // Stack pointer. void* fp; // Frame pointer. - void* lr; // Link register (or nullptr on platforms without a link register). }; // The output structure filled up by GetStackSample API function. @@ -2093,10 +2120,10 @@ class V8_EXPORT ValueSerializer { void WriteDouble(double value); void WriteRawBytes(const void* source, size_t length); + private: ValueSerializer(const ValueSerializer&) = delete; void operator=(const ValueSerializer&) = delete; - private: struct PrivateData; PrivateData* private_; }; @@ -2195,10 +2222,10 @@ class V8_EXPORT ValueDeserializer { V8_WARN_UNUSED_RESULT bool ReadDouble(double* value); V8_WARN_UNUSED_RESULT bool ReadRawBytes(size_t length, const void** data); + private: ValueDeserializer(const ValueDeserializer&) = delete; void operator=(const ValueDeserializer&) = delete; - private: struct PrivateData; PrivateData* private_; }; @@ -2493,6 +2520,9 @@ class V8_EXPORT Value : public Data { V8_WARN_UNUSED_RESULT MaybeLocal ToBigInt( Local context) const; + V8_DEPRECATED("ToBoolean can never throw. Use Local version.", + V8_WARN_UNUSED_RESULT MaybeLocal ToBoolean( + Local context) const); V8_WARN_UNUSED_RESULT MaybeLocal ToNumber( Local context) const; V8_WARN_UNUSED_RESULT MaybeLocal ToString( @@ -2508,6 +2538,16 @@ class V8_EXPORT Value : public Data { V8_WARN_UNUSED_RESULT MaybeLocal ToInt32(Local context) const; Local ToBoolean(Isolate* isolate) const; + V8_DEPRECATED("Use maybe version", + Local ToNumber(Isolate* isolate) const); + V8_DEPRECATED("Use maybe version", + Local ToString(Isolate* isolate) const); + V8_DEPRECATED("Use maybe version", + Local ToObject(Isolate* isolate) const); + V8_DEPRECATED("Use maybe version", + Local ToInteger(Isolate* isolate) const); + V8_DEPRECATED("Use maybe version", + Local ToInt32(Isolate* isolate) const); /** * Attempts to convert a string to an array index. @@ -2518,6 +2558,9 @@ class V8_EXPORT Value : public Data { bool BooleanValue(Isolate* isolate) const; + V8_DEPRECATED("BooleanValue can never throw. Use Isolate version.", + V8_WARN_UNUSED_RESULT Maybe BooleanValue( + Local context) const); V8_WARN_UNUSED_RESULT Maybe NumberValue(Local context) const; V8_WARN_UNUSED_RESULT Maybe IntegerValue( Local context) const; @@ -2721,10 +2764,6 @@ class V8_EXPORT String : public Name { */ virtual bool IsCacheable() const { return true; } - // Disallow copying and assigning. - ExternalStringResourceBase(const ExternalStringResourceBase&) = delete; - void operator=(const ExternalStringResourceBase&) = delete; - protected: ExternalStringResourceBase() = default; @@ -2754,6 +2793,10 @@ class V8_EXPORT String : public Name { */ virtual void Unlock() const {} + // Disallow copying and assigning. + ExternalStringResourceBase(const ExternalStringResourceBase&) = delete; + void operator=(const ExternalStringResourceBase&) = delete; + private: friend class internal::ExternalString; friend class v8::String; @@ -2837,23 +2880,43 @@ class V8_EXPORT String : public Name { V8_INLINE static String* Cast(v8::Value* obj); + // TODO(dcarney): remove with deprecation of New functions. + enum NewStringType { + kNormalString = static_cast(v8::NewStringType::kNormal), + kInternalizedString = static_cast(v8::NewStringType::kInternalized) + }; + + /** Allocates a new string from UTF-8 data.*/ + static V8_DEPRECATED( + "Use maybe version", + Local NewFromUtf8(Isolate* isolate, const char* data, + NewStringType type = kNormalString, + int length = -1)); + /** Allocates a new string from UTF-8 data. Only returns an empty value when * length > kMaxLength. **/ static V8_WARN_UNUSED_RESULT MaybeLocal NewFromUtf8( - Isolate* isolate, const char* data, - NewStringType type = NewStringType::kNormal, int length = -1); + Isolate* isolate, const char* data, v8::NewStringType type, + int length = -1); /** Allocates a new string from Latin-1 data. Only returns an empty value * when length > kMaxLength. **/ static V8_WARN_UNUSED_RESULT MaybeLocal NewFromOneByte( - Isolate* isolate, const uint8_t* data, - NewStringType type = NewStringType::kNormal, int length = -1); + Isolate* isolate, const uint8_t* data, v8::NewStringType type, + int length = -1); + + /** Allocates a new string from UTF-16 data.*/ + static V8_DEPRECATED( + "Use maybe version", + Local NewFromTwoByte(Isolate* isolate, const uint16_t* data, + NewStringType type = kNormalString, + int length = -1)); /** Allocates a new string from UTF-16 data. Only returns an empty value when * length > kMaxLength. **/ static V8_WARN_UNUSED_RESULT MaybeLocal NewFromTwoByte( - Isolate* isolate, const uint16_t* data, - NewStringType type = NewStringType::kNormal, int length = -1); + Isolate* isolate, const uint16_t* data, v8::NewStringType type, + int length = -1); /** * Creates a new string by concatenating the left and the right strings @@ -2892,6 +2955,10 @@ class V8_EXPORT String : public Name { * should the underlying buffer be deallocated or modified except through the * destructor of the external string resource. */ + static V8_DEPRECATED( + "Use maybe version", + Local NewExternal(Isolate* isolate, + ExternalOneByteStringResource* resource)); static V8_WARN_UNUSED_RESULT MaybeLocal NewExternalOneByte( Isolate* isolate, ExternalOneByteStringResource* resource); @@ -3288,8 +3355,8 @@ enum class IntegrityLevel { kFrozen, kSealed }; */ class V8_EXPORT Object : public Value { public: - V8_DEPRECATED("Use maybe version", - bool Set(Local key, Local value)); + V8_DEPRECATE_SOON("Use maybe version", + bool Set(Local key, Local value)); /** * Set only return Just(true) or Empty(), so if it should never fail, use * result.Check(). @@ -3297,8 +3364,8 @@ class V8_EXPORT Object : public Value { V8_WARN_UNUSED_RESULT Maybe Set(Local context, Local key, Local value); - V8_DEPRECATED("Use maybe version", - bool Set(uint32_t index, Local value)); + V8_DEPRECATE_SOON("Use maybe version", + bool Set(uint32_t index, Local value)); V8_WARN_UNUSED_RESULT Maybe Set(Local context, uint32_t index, Local value); @@ -3342,11 +3409,11 @@ class V8_EXPORT Object : public Value { V8_WARN_UNUSED_RESULT Maybe DefineProperty( Local context, Local key, PropertyDescriptor& descriptor); - V8_DEPRECATED("Use maybe version", Local Get(Local key)); + V8_DEPRECATE_SOON("Use maybe version", Local Get(Local key)); V8_WARN_UNUSED_RESULT MaybeLocal Get(Local context, Local key); - V8_DEPRECATED("Use maybe version", Local Get(uint32_t index)); + V8_DEPRECATE_SOON("Use maybe version", Local Get(uint32_t index)); V8_WARN_UNUSED_RESULT MaybeLocal Get(Local context, uint32_t index); @@ -3830,6 +3897,9 @@ class ReturnValue { } // Local setters template + V8_INLINE V8_DEPRECATED("Use Global<> instead", + void Set(const Persistent& handle)); + template V8_INLINE void Set(const Global& handle); template V8_INLINE void Set(const TracedGlobal& handle); @@ -5217,6 +5287,38 @@ class V8_EXPORT Date : public Object { V8_INLINE static Date* Cast(Value* obj); + /** + * Time zone redetection indicator for + * DateTimeConfigurationChangeNotification. + * + * kSkip indicates V8 that the notification should not trigger redetecting + * host time zone. kRedetect indicates V8 that host time zone should be + * redetected, and used to set the default time zone. + * + * The host time zone detection may require file system access or similar + * operations unlikely to be available inside a sandbox. If v8 is run inside a + * sandbox, the host time zone has to be detected outside the sandbox before + * calling DateTimeConfigurationChangeNotification function. + */ + enum class TimeZoneDetection { kSkip, kRedetect }; + + /** + * Notification that the embedder has changed the time zone, + * daylight savings time, or other date / time configuration + * parameters. V8 keeps a cache of various values used for + * date / time computation. This notification will reset + * those cached values for the current context so that date / + * time configuration changes would be reflected in the Date + * object. + * + * This API should not be called more than needed as it will + * negatively impact the performance of date operations. + */ + V8_DEPRECATED("Use Isolate::DateTimeConfigurationChangeNotification", + static void DateTimeConfigurationChangeNotification( + Isolate* isolate, TimeZoneDetection time_zone_detection = + TimeZoneDetection::kSkip)); + private: static void CheckCast(Value* obj); }; @@ -5902,6 +6004,21 @@ class V8_EXPORT FunctionTemplate : public Template { */ void SetAcceptAnyReceiver(bool value); + /** + * Determines whether the __proto__ accessor ignores instances of + * the function template. If instances of the function template are + * ignored, __proto__ skips all instances and instead returns the + * next object in the prototype chain. + * + * Call with a value of true to make the __proto__ accessor ignore + * instances of the function template. Call with a value of false + * to make the __proto__ accessor not ignore instances of the + * function template. By default, instances of a function template + * are not ignored. + */ + V8_DEPRECATED("This feature is incompatible with ES6+.", + void SetHiddenPrototype(bool value)); + /** * Sets the ReadOnly flag in the attributes of the 'prototype' property * of functions created from this FunctionTemplate to true. @@ -6706,12 +6823,11 @@ class V8_EXPORT MicrotaskQueue { */ virtual int GetMicrotasksScopeDepth() const = 0; - MicrotaskQueue(const MicrotaskQueue&) = delete; - MicrotaskQueue& operator=(const MicrotaskQueue&) = delete; - private: friend class internal::MicrotaskQueue; MicrotaskQueue() = default; + MicrotaskQueue(const MicrotaskQueue&) = delete; + MicrotaskQueue& operator=(const MicrotaskQueue&) = delete; }; /** @@ -7102,11 +7218,6 @@ enum class MemoryPressureLevel { kNone, kModerate, kCritical }; */ class V8_EXPORT EmbedderHeapTracer { public: - enum TraceFlags : uint64_t { - kNoFlags = 0, - kReduceMemory = 1 << 0, - }; - // Indicator for the stack state of the embedder. enum EmbedderStackState { kUnknown, @@ -7123,24 +7234,6 @@ class V8_EXPORT EmbedderHeapTracer { virtual void VisitTracedGlobalHandle(const TracedGlobal& value) = 0; }; - /** - * 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; /** @@ -7163,8 +7256,7 @@ class V8_EXPORT EmbedderHeapTracer { /** * Called at the beginning of a GC cycle. */ - V8_DEPRECATE_SOON("Use version with flags.", virtual void TracePrologue()) {} - virtual void TracePrologue(TraceFlags flags); + virtual void TracePrologue() = 0; /** * Called to advance tracing in the embedder. @@ -7187,12 +7279,9 @@ class V8_EXPORT EmbedderHeapTracer { /** * 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. + * Note that allocation is *not* allowed within |TraceEpilogue|. */ - virtual void TraceEpilogue() {} - virtual void TraceEpilogue(TraceSummary* trace_summary) { TraceEpilogue(); } + virtual void TraceEpilogue() = 0; /** * Called upon entering the final marking pause. No more incremental marking @@ -7229,14 +7318,6 @@ class V8_EXPORT EmbedderHeapTracer { */ void GarbageCollectionForTesting(EmbedderStackState stack_state); - /* - * Called by the embedder to signal newly allocated 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); - /* * Returns the v8::Isolate this tracer is attached too and |nullptr| if it * is not attached to any v8::Isolate. @@ -8529,13 +8610,6 @@ class V8_EXPORT Isolate { class V8_EXPORT StartupData { public: - /** - * Whether the data created can be rehashed and and the hash seed can be - * recomputed when deserialized. - * Only valid for StartupData returned by SnapshotCreator::CreateBlob(). - */ - bool CanBeRehashed() const; - const char* data; int raw_size; }; @@ -8594,10 +8668,7 @@ class V8_EXPORT V8 { /** * Sets V8 flags from a string. */ - static void SetFlagsFromString(const char* str); - static void SetFlagsFromString(const char* str, size_t length); - V8_DEPRECATED("use size_t version", - static void SetFlagsFromString(const char* str, int length)); + static void SetFlagsFromString(const char* str, int length); /** * Sets V8 flags from the command line. @@ -8768,6 +8839,9 @@ class V8_EXPORT V8 { const char* label); static Value* Eternalize(Isolate* isolate, Value* handle); + static void RegisterExternallyReferencedObject(internal::Address* location, + internal::Isolate* isolate); + template friend class PersistentValueMapBase; @@ -9714,6 +9788,14 @@ void Persistent::Copy(const Persistent& that) { M::Copy(that, this); } +template +bool PersistentBase::IsIndependent() const { + typedef internal::Internals I; + if (this->IsEmpty()) return false; + return I::GetNodeFlag(reinterpret_cast(this->val_), + I::kNodeIsIndependentShift); +} + template bool PersistentBase::IsWeak() const { typedef internal::Internals I; @@ -9780,6 +9862,31 @@ void PersistentBase::AnnotateStrongRetainer(const char* label) { label); } +template +void PersistentBase::RegisterExternalReference(Isolate* isolate) const { + if (IsEmpty()) return; + V8::RegisterExternallyReferencedObject( + reinterpret_cast(this->val_), + reinterpret_cast(isolate)); +} + +template +void PersistentBase::MarkIndependent() { + typedef internal::Internals I; + if (this->IsEmpty()) return; + I::UpdateNodeFlag(reinterpret_cast(this->val_), true, + I::kNodeIsIndependentShift); +} + +template +void PersistentBase::MarkActive() { + typedef internal::Internals I; + if (this->IsEmpty()) return; + I::UpdateNodeFlag(reinterpret_cast(this->val_), true, + I::kNodeIsActiveShift); +} + + template void PersistentBase::SetWrapperClassId(uint16_t class_id) { typedef internal::Internals I; @@ -9905,6 +10012,17 @@ void TracedGlobal::SetFinalizationCallback( template ReturnValue::ReturnValue(internal::Address* slot) : value_(slot) {} +template +template +void ReturnValue::Set(const Persistent& handle) { + TYPE_CHECK(T, S); + if (V8_UNLIKELY(handle.IsEmpty())) { + *value_ = GetDefaultValue(); + } else { + *value_ = *reinterpret_cast(*handle); + } +} + template template void ReturnValue::Set(const Global& handle) { @@ -10824,8 +10942,7 @@ int64_t Isolate::AdjustAmountOfExternalAllocatedMemory( *external_memory = amount; int64_t allocation_diff_since_last_mc = - static_cast(static_cast(*external_memory) - - static_cast(*external_memory_at_last_mc)); + *external_memory - *external_memory_at_last_mc; // Only check memory pressure and potentially trigger GC if the amount of // external memory increased. if (allocation_diff_since_last_mc > kMemoryReducerActivationLimit) {