@@ -122,6 +122,7 @@ class ExternalString;
122122class Isolate ;
123123class LocalEmbedderHeapTracer ;
124124class MicrotaskQueue ;
125+ class NeverReadOnlySpaceObject ;
125126struct ScriptStreamingData ;
126127template <typename T> class CustomArguments ;
127128class PropertyCallbackArguments ;
@@ -544,6 +545,38 @@ template <class T> class PersistentBase {
544545 */
545546 V8_INLINE void AnnotateStrongRetainer (const char * label);
546547
548+ /* *
549+ * Allows the embedder to tell the v8 garbage collector that a certain object
550+ * is alive. Only allowed when the embedder is asked to trace its heap by
551+ * EmbedderHeapTracer.
552+ */
553+ V8_DEPRECATED (
554+ " Used TracedGlobal and EmbedderHeapTracer::RegisterEmbedderReference" ,
555+ V8_INLINE void RegisterExternalReference (Isolate* isolate) const );
556+
557+ /* *
558+ * Marks the reference to this object independent. Garbage collector is free
559+ * to ignore any object groups containing this object. Weak callback for an
560+ * independent handle should not assume that it will be preceded by a global
561+ * GC prologue callback or followed by a global GC epilogue callback.
562+ */
563+ V8_DEPRECATED (
564+ " Weak objects are always considered independent. "
565+ " Use TracedGlobal when trying to use EmbedderHeapTracer. "
566+ " Use a strong handle when trying to keep an object alive." ,
567+ V8_INLINE void MarkIndependent ());
568+
569+ /* *
570+ * Marks the reference to this object as active. The scavenge garbage
571+ * collection should not reclaim the objects marked as active, even if the
572+ * object held by the handle is otherwise unreachable.
573+ *
574+ * This bit is cleared after the each garbage collection pass.
575+ */
576+ V8_DEPRECATED (" Use TracedGlobal." , V8_INLINE void MarkActive ());
577+
578+ V8_DEPRECATED (" See MarkIndependent." , V8_INLINE bool IsIndependent () const );
579+
547580 /* * Returns true if the handle's reference is weak. */
548581 V8_INLINE bool IsWeak () const ;
549582
@@ -2500,6 +2533,9 @@ class V8_EXPORT Value : public Data {
25002533
25012534 V8_WARN_UNUSED_RESULT MaybeLocal<BigInt> ToBigInt (
25022535 Local<Context> context) const ;
2536+ V8_DEPRECATED (" ToBoolean can never throw. Use Local version." ,
2537+ V8_WARN_UNUSED_RESULT MaybeLocal<Boolean> ToBoolean (
2538+ Local<Context> context) const );
25032539 V8_WARN_UNUSED_RESULT MaybeLocal<Number> ToNumber (
25042540 Local<Context> context) const ;
25052541 V8_WARN_UNUSED_RESULT MaybeLocal<String> ToString (
@@ -2515,6 +2551,16 @@ class V8_EXPORT Value : public Data {
25152551 V8_WARN_UNUSED_RESULT MaybeLocal<Int32> ToInt32 (Local<Context> context) const ;
25162552
25172553 Local<Boolean> ToBoolean (Isolate* isolate) const ;
2554+ V8_DEPRECATED (" Use maybe version" ,
2555+ Local<Number> ToNumber (Isolate* isolate) const );
2556+ V8_DEPRECATED (" Use maybe version" ,
2557+ Local<String> ToString (Isolate* isolate) const );
2558+ V8_DEPRECATED (" Use maybe version" ,
2559+ Local<Object> ToObject (Isolate* isolate) const );
2560+ V8_DEPRECATED (" Use maybe version" ,
2561+ Local<Integer> ToInteger (Isolate* isolate) const );
2562+ V8_DEPRECATED (" Use maybe version" ,
2563+ Local<Int32> ToInt32 (Isolate* isolate) const );
25182564
25192565 /* *
25202566 * Attempts to convert a string to an array index.
@@ -2525,6 +2571,9 @@ class V8_EXPORT Value : public Data {
25252571
25262572 bool BooleanValue (Isolate* isolate) const ;
25272573
2574+ V8_DEPRECATED (" BooleanValue can never throw. Use Isolate version." ,
2575+ V8_WARN_UNUSED_RESULT Maybe<bool > BooleanValue (
2576+ Local<Context> context) const );
25282577 V8_WARN_UNUSED_RESULT Maybe<double > NumberValue (Local<Context> context) const ;
25292578 V8_WARN_UNUSED_RESULT Maybe<int64_t > IntegerValue (
25302579 Local<Context> context) const ;
@@ -2844,23 +2893,43 @@ class V8_EXPORT String : public Name {
28442893
28452894 V8_INLINE static String* Cast (v8::Value* obj);
28462895
2896+ // TODO(dcarney): remove with deprecation of New functions.
2897+ enum NewStringType {
2898+ kNormalString = static_cast <int >(v8::NewStringType::kNormal ),
2899+ kInternalizedString = static_cast <int >(v8::NewStringType::kInternalized )
2900+ };
2901+
2902+ /* * Allocates a new string from UTF-8 data.*/
2903+ static V8_DEPRECATED (
2904+ " Use maybe version" ,
2905+ Local<String> NewFromUtf8 (Isolate* isolate, const char * data,
2906+ NewStringType type = kNormalString ,
2907+ int length = -1 ));
2908+
28472909 /* * Allocates a new string from UTF-8 data. Only returns an empty value when
28482910 * length > kMaxLength. **/
28492911 static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewFromUtf8 (
2850- Isolate* isolate, const char * data,
2851- NewStringType type = NewStringType:: kNormal , int length = -1 );
2912+ Isolate* isolate, const char * data, v8::NewStringType type,
2913+ int length = -1 );
28522914
28532915 /* * Allocates a new string from Latin-1 data. Only returns an empty value
28542916 * when length > kMaxLength. **/
28552917 static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewFromOneByte (
2856- Isolate* isolate, const uint8_t * data,
2857- NewStringType type = NewStringType::kNormal , int length = -1 );
2918+ Isolate* isolate, const uint8_t * data, v8::NewStringType type,
2919+ int length = -1 );
2920+
2921+ /* * Allocates a new string from UTF-16 data.*/
2922+ static V8_DEPRECATED (
2923+ " Use maybe version" ,
2924+ Local<String> NewFromTwoByte (Isolate* isolate, const uint16_t * data,
2925+ NewStringType type = kNormalString ,
2926+ int length = -1 ));
28582927
28592928 /* * Allocates a new string from UTF-16 data. Only returns an empty value when
28602929 * length > kMaxLength. **/
28612930 static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewFromTwoByte (
2862- Isolate* isolate, const uint16_t * data,
2863- NewStringType type = NewStringType:: kNormal , int length = -1 );
2931+ Isolate* isolate, const uint16_t * data, v8::NewStringType type,
2932+ int length = -1 );
28642933
28652934 /* *
28662935 * Creates a new string by concatenating the left and the right strings
@@ -2899,6 +2968,10 @@ class V8_EXPORT String : public Name {
28992968 * should the underlying buffer be deallocated or modified except through the
29002969 * destructor of the external string resource.
29012970 */
2971+ static V8_DEPRECATED (
2972+ " Use maybe version" ,
2973+ Local<String> NewExternal (Isolate* isolate,
2974+ ExternalOneByteStringResource* resource));
29022975 static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewExternalOneByte (
29032976 Isolate* isolate, ExternalOneByteStringResource* resource);
29042977
@@ -3837,6 +3910,9 @@ class ReturnValue {
38373910 }
38383911 // Local setters
38393912 template <typename S>
3913+ V8_INLINE V8_DEPRECATED (" Use Global<> instead" ,
3914+ void Set (const Persistent<S>& handle));
3915+ template <typename S>
38403916 V8_INLINE void Set (const Global<S>& handle);
38413917 template <typename S>
38423918 V8_INLINE void Set (const TracedGlobal<S>& handle);
@@ -5227,6 +5303,38 @@ class V8_EXPORT Date : public Object {
52275303
52285304 V8_INLINE static Date* Cast (Value* obj);
52295305
5306+ /* *
5307+ * Time zone redetection indicator for
5308+ * DateTimeConfigurationChangeNotification.
5309+ *
5310+ * kSkip indicates V8 that the notification should not trigger redetecting
5311+ * host time zone. kRedetect indicates V8 that host time zone should be
5312+ * redetected, and used to set the default time zone.
5313+ *
5314+ * The host time zone detection may require file system access or similar
5315+ * operations unlikely to be available inside a sandbox. If v8 is run inside a
5316+ * sandbox, the host time zone has to be detected outside the sandbox before
5317+ * calling DateTimeConfigurationChangeNotification function.
5318+ */
5319+ enum class TimeZoneDetection { kSkip , kRedetect };
5320+
5321+ /* *
5322+ * Notification that the embedder has changed the time zone,
5323+ * daylight savings time, or other date / time configuration
5324+ * parameters. V8 keeps a cache of various values used for
5325+ * date / time computation. This notification will reset
5326+ * those cached values for the current context so that date /
5327+ * time configuration changes would be reflected in the Date
5328+ * object.
5329+ *
5330+ * This API should not be called more than needed as it will
5331+ * negatively impact the performance of date operations.
5332+ */
5333+ V8_DEPRECATED (" Use Isolate::DateTimeConfigurationChangeNotification" ,
5334+ static void DateTimeConfigurationChangeNotification (
5335+ Isolate* isolate, TimeZoneDetection time_zone_detection =
5336+ TimeZoneDetection::kSkip ));
5337+
52305338 private:
52315339 static void CheckCast (Value* obj);
52325340};
@@ -5912,6 +6020,21 @@ class V8_EXPORT FunctionTemplate : public Template {
59126020 */
59136021 void SetAcceptAnyReceiver (bool value);
59146022
6023+ /* *
6024+ * Determines whether the __proto__ accessor ignores instances of
6025+ * the function template. If instances of the function template are
6026+ * ignored, __proto__ skips all instances and instead returns the
6027+ * next object in the prototype chain.
6028+ *
6029+ * Call with a value of true to make the __proto__ accessor ignore
6030+ * instances of the function template. Call with a value of false
6031+ * to make the __proto__ accessor not ignore instances of the
6032+ * function template. By default, instances of a function template
6033+ * are not ignored.
6034+ */
6035+ V8_DEPRECATED (" This feature is incompatible with ES6+." ,
6036+ void SetHiddenPrototype (bool value));
6037+
59156038 /* *
59166039 * Sets the ReadOnly flag in the attributes of the 'prototype' property
59176040 * of functions created from this FunctionTemplate to true.
@@ -8594,9 +8717,7 @@ class V8_EXPORT V8 {
85948717 * Sets V8 flags from a string.
85958718 */
85968719 static void SetFlagsFromString (const char * str);
8597- static void SetFlagsFromString (const char * str, size_t length);
8598- V8_DEPRECATED (" use size_t version" ,
8599- static void SetFlagsFromString (const char * str, int length));
8720+ static void SetFlagsFromString (const char * str, int length);
86008721
86018722 /* *
86028723 * Sets V8 flags from the command line.
@@ -8767,6 +8888,9 @@ class V8_EXPORT V8 {
87678888 const char * label);
87688889 static Value* Eternalize (Isolate* isolate, Value* handle);
87698890
8891+ static void RegisterExternallyReferencedObject (internal::Address* location,
8892+ internal::Isolate* isolate);
8893+
87708894 template <class K , class V , class T >
87718895 friend class PersistentValueMapBase ;
87728896
@@ -9713,6 +9837,14 @@ void Persistent<T, M>::Copy(const Persistent<S, M2>& that) {
97139837 M::Copy (that, this );
97149838}
97159839
9840+ template <class T >
9841+ bool PersistentBase<T>::IsIndependent() const {
9842+ typedef internal::Internals I;
9843+ if (this ->IsEmpty ()) return false ;
9844+ return I::GetNodeFlag (reinterpret_cast <internal::Address*>(this ->val_ ),
9845+ I::kNodeIsIndependentShift );
9846+ }
9847+
97169848template <class T >
97179849bool PersistentBase<T>::IsWeak() const {
97189850 typedef internal::Internals I;
@@ -9779,6 +9911,31 @@ void PersistentBase<T>::AnnotateStrongRetainer(const char* label) {
97799911 label);
97809912}
97819913
9914+ template <class T >
9915+ void PersistentBase<T>::RegisterExternalReference(Isolate* isolate) const {
9916+ if (IsEmpty ()) return ;
9917+ V8::RegisterExternallyReferencedObject (
9918+ reinterpret_cast <internal::Address*>(this ->val_ ),
9919+ reinterpret_cast <internal::Isolate*>(isolate));
9920+ }
9921+
9922+ template <class T >
9923+ void PersistentBase<T>::MarkIndependent() {
9924+ typedef internal::Internals I;
9925+ if (this ->IsEmpty ()) return ;
9926+ I::UpdateNodeFlag (reinterpret_cast <internal::Address*>(this ->val_ ), true ,
9927+ I::kNodeIsIndependentShift );
9928+ }
9929+
9930+ template <class T >
9931+ void PersistentBase<T>::MarkActive() {
9932+ typedef internal::Internals I;
9933+ if (this ->IsEmpty ()) return ;
9934+ I::UpdateNodeFlag (reinterpret_cast <internal::Address*>(this ->val_ ), true ,
9935+ I::kNodeIsActiveShift );
9936+ }
9937+
9938+
97829939template <class T >
97839940void PersistentBase<T>::SetWrapperClassId(uint16_t class_id) {
97849941 typedef internal::Internals I;
@@ -9904,6 +10061,17 @@ void TracedGlobal<T>::SetFinalizationCallback(
990410061template <typename T>
990510062ReturnValue<T>::ReturnValue(internal::Address* slot) : value_(slot) {}
990610063
10064+ template <typename T>
10065+ template <typename S>
10066+ void ReturnValue<T>::Set(const Persistent<S>& handle) {
10067+ TYPE_CHECK (T, S);
10068+ if (V8_UNLIKELY (handle.IsEmpty ())) {
10069+ *value_ = GetDefaultValue ();
10070+ } else {
10071+ *value_ = *reinterpret_cast <internal::Address*>(*handle);
10072+ }
10073+ }
10074+
990710075template <typename T>
990810076template <typename S>
990910077void ReturnValue<T>::Set(const Global<S>& handle) {
0 commit comments