@@ -122,6 +122,7 @@ class ExternalString;
122
122
class Isolate ;
123
123
class LocalEmbedderHeapTracer ;
124
124
class MicrotaskQueue ;
125
+ class NeverReadOnlySpaceObject ;
125
126
struct ScriptStreamingData ;
126
127
template <typename T> class CustomArguments ;
127
128
class PropertyCallbackArguments ;
@@ -544,6 +545,38 @@ template <class T> class PersistentBase {
544
545
*/
545
546
V8_INLINE void AnnotateStrongRetainer (const char * label);
546
547
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
+
547
580
/* * Returns true if the handle's reference is weak. */
548
581
V8_INLINE bool IsWeak () const ;
549
582
@@ -2500,6 +2533,9 @@ class V8_EXPORT Value : public Data {
2500
2533
2501
2534
V8_WARN_UNUSED_RESULT MaybeLocal<BigInt> ToBigInt (
2502
2535
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 );
2503
2539
V8_WARN_UNUSED_RESULT MaybeLocal<Number> ToNumber (
2504
2540
Local<Context> context) const ;
2505
2541
V8_WARN_UNUSED_RESULT MaybeLocal<String> ToString (
@@ -2515,6 +2551,16 @@ class V8_EXPORT Value : public Data {
2515
2551
V8_WARN_UNUSED_RESULT MaybeLocal<Int32> ToInt32 (Local<Context> context) const ;
2516
2552
2517
2553
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 );
2518
2564
2519
2565
/* *
2520
2566
* Attempts to convert a string to an array index.
@@ -2525,6 +2571,9 @@ class V8_EXPORT Value : public Data {
2525
2571
2526
2572
bool BooleanValue (Isolate* isolate) const ;
2527
2573
2574
+ V8_DEPRECATED (" BooleanValue can never throw. Use Isolate version." ,
2575
+ V8_WARN_UNUSED_RESULT Maybe<bool > BooleanValue (
2576
+ Local<Context> context) const );
2528
2577
V8_WARN_UNUSED_RESULT Maybe<double > NumberValue (Local<Context> context) const ;
2529
2578
V8_WARN_UNUSED_RESULT Maybe<int64_t > IntegerValue (
2530
2579
Local<Context> context) const ;
@@ -2844,23 +2893,43 @@ class V8_EXPORT String : public Name {
2844
2893
2845
2894
V8_INLINE static String* Cast (v8::Value* obj);
2846
2895
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
+
2847
2909
/* * Allocates a new string from UTF-8 data. Only returns an empty value when
2848
2910
* length > kMaxLength. **/
2849
2911
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 );
2852
2914
2853
2915
/* * Allocates a new string from Latin-1 data. Only returns an empty value
2854
2916
* when length > kMaxLength. **/
2855
2917
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 ));
2858
2927
2859
2928
/* * Allocates a new string from UTF-16 data. Only returns an empty value when
2860
2929
* length > kMaxLength. **/
2861
2930
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 );
2864
2933
2865
2934
/* *
2866
2935
* Creates a new string by concatenating the left and the right strings
@@ -2899,6 +2968,10 @@ class V8_EXPORT String : public Name {
2899
2968
* should the underlying buffer be deallocated or modified except through the
2900
2969
* destructor of the external string resource.
2901
2970
*/
2971
+ static V8_DEPRECATED (
2972
+ " Use maybe version" ,
2973
+ Local<String> NewExternal (Isolate* isolate,
2974
+ ExternalOneByteStringResource* resource));
2902
2975
static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewExternalOneByte (
2903
2976
Isolate* isolate, ExternalOneByteStringResource* resource);
2904
2977
@@ -3837,6 +3910,9 @@ class ReturnValue {
3837
3910
}
3838
3911
// Local setters
3839
3912
template <typename S>
3913
+ V8_INLINE V8_DEPRECATED (" Use Global<> instead" ,
3914
+ void Set (const Persistent<S>& handle));
3915
+ template <typename S>
3840
3916
V8_INLINE void Set (const Global<S>& handle);
3841
3917
template <typename S>
3842
3918
V8_INLINE void Set (const TracedGlobal<S>& handle);
@@ -5227,6 +5303,38 @@ class V8_EXPORT Date : public Object {
5227
5303
5228
5304
V8_INLINE static Date* Cast (Value* obj);
5229
5305
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
+
5230
5338
private:
5231
5339
static void CheckCast (Value* obj);
5232
5340
};
@@ -5912,6 +6020,21 @@ class V8_EXPORT FunctionTemplate : public Template {
5912
6020
*/
5913
6021
void SetAcceptAnyReceiver (bool value);
5914
6022
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
+
5915
6038
/* *
5916
6039
* Sets the ReadOnly flag in the attributes of the 'prototype' property
5917
6040
* of functions created from this FunctionTemplate to true.
@@ -8594,9 +8717,7 @@ class V8_EXPORT V8 {
8594
8717
* Sets V8 flags from a string.
8595
8718
*/
8596
8719
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);
8600
8721
8601
8722
/* *
8602
8723
* Sets V8 flags from the command line.
@@ -8767,6 +8888,9 @@ class V8_EXPORT V8 {
8767
8888
const char * label);
8768
8889
static Value* Eternalize (Isolate* isolate, Value* handle);
8769
8890
8891
+ static void RegisterExternallyReferencedObject (internal::Address* location,
8892
+ internal::Isolate* isolate);
8893
+
8770
8894
template <class K , class V , class T >
8771
8895
friend class PersistentValueMapBase ;
8772
8896
@@ -9713,6 +9837,14 @@ void Persistent<T, M>::Copy(const Persistent<S, M2>& that) {
9713
9837
M::Copy (that, this );
9714
9838
}
9715
9839
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
+
9716
9848
template <class T >
9717
9849
bool PersistentBase<T>::IsWeak() const {
9718
9850
typedef internal::Internals I;
@@ -9779,6 +9911,31 @@ void PersistentBase<T>::AnnotateStrongRetainer(const char* label) {
9779
9911
label);
9780
9912
}
9781
9913
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
+
9782
9939
template <class T >
9783
9940
void PersistentBase<T>::SetWrapperClassId(uint16_t class_id) {
9784
9941
typedef internal::Internals I;
@@ -9904,6 +10061,17 @@ void TracedGlobal<T>::SetFinalizationCallback(
9904
10061
template <typename T>
9905
10062
ReturnValue<T>::ReturnValue(internal::Address* slot) : value_(slot) {}
9906
10063
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
+
9907
10075
template <typename T>
9908
10076
template <typename S>
9909
10077
void ReturnValue<T>::Set(const Global<S>& handle) {
0 commit comments