@@ -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
@@ -2525,6 +2558,9 @@ class V8_EXPORT Value : public Data {
2525
2558
2526
2559
V8_WARN_UNUSED_RESULT MaybeLocal<BigInt> ToBigInt (
2527
2560
Local<Context> context) const ;
2561
+ V8_DEPRECATED (" ToBoolean can never throw. Use Local version." ,
2562
+ V8_WARN_UNUSED_RESULT MaybeLocal<Boolean > ToBoolean (
2563
+ Local<Context> context) const );
2528
2564
V8_WARN_UNUSED_RESULT MaybeLocal<Number> ToNumber (
2529
2565
Local<Context> context) const ;
2530
2566
V8_WARN_UNUSED_RESULT MaybeLocal<String> ToString (
@@ -2540,6 +2576,16 @@ class V8_EXPORT Value : public Data {
2540
2576
V8_WARN_UNUSED_RESULT MaybeLocal<Int32> ToInt32 (Local<Context> context) const ;
2541
2577
2542
2578
Local<Boolean > ToBoolean (Isolate* isolate) const ;
2579
+ V8_DEPRECATED (" Use maybe version" ,
2580
+ Local<Number> ToNumber (Isolate* isolate) const );
2581
+ V8_DEPRECATED (" Use maybe version" ,
2582
+ Local<String> ToString (Isolate* isolate) const );
2583
+ V8_DEPRECATED (" Use maybe version" ,
2584
+ Local<Object> ToObject (Isolate* isolate) const );
2585
+ V8_DEPRECATED (" Use maybe version" ,
2586
+ Local<Integer> ToInteger (Isolate* isolate) const );
2587
+ V8_DEPRECATED (" Use maybe version" ,
2588
+ Local<Int32> ToInt32 (Isolate* isolate) const );
2543
2589
2544
2590
/* *
2545
2591
* Attempts to convert a string to an array index.
@@ -2550,6 +2596,9 @@ class V8_EXPORT Value : public Data {
2550
2596
2551
2597
bool BooleanValue (Isolate* isolate) const ;
2552
2598
2599
+ V8_DEPRECATED (" BooleanValue can never throw. Use Isolate version." ,
2600
+ V8_WARN_UNUSED_RESULT Maybe<bool > BooleanValue (
2601
+ Local<Context> context) const );
2553
2602
V8_WARN_UNUSED_RESULT Maybe<double > NumberValue (Local<Context> context) const ;
2554
2603
V8_WARN_UNUSED_RESULT Maybe<int64_t > IntegerValue (
2555
2604
Local<Context> context) const ;
@@ -2869,23 +2918,43 @@ class V8_EXPORT String : public Name {
2869
2918
2870
2919
V8_INLINE static String* Cast (v8::Value* obj);
2871
2920
2921
+ // TODO(dcarney): remove with deprecation of New functions.
2922
+ enum NewStringType {
2923
+ kNormalString = static_cast <int >(v8::NewStringType::kNormal ),
2924
+ kInternalizedString = static_cast <int >(v8::NewStringType::kInternalized )
2925
+ };
2926
+
2927
+ /* * Allocates a new string from UTF-8 data.*/
2928
+ static V8_DEPRECATED (
2929
+ " Use maybe version" ,
2930
+ Local<String> NewFromUtf8 (Isolate* isolate, const char * data,
2931
+ NewStringType type = kNormalString ,
2932
+ int length = -1 ));
2933
+
2872
2934
/* * Allocates a new string from UTF-8 data. Only returns an empty value when
2873
2935
* length > kMaxLength. **/
2874
2936
static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewFromUtf8 (
2875
- Isolate* isolate, const char * data,
2876
- NewStringType type = NewStringType:: kNormal , int length = -1 );
2937
+ Isolate* isolate, const char * data, v8::NewStringType type,
2938
+ int length = -1 );
2877
2939
2878
2940
/* * Allocates a new string from Latin-1 data. Only returns an empty value
2879
2941
* when length > kMaxLength. **/
2880
2942
static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewFromOneByte (
2881
- Isolate* isolate, const uint8_t * data,
2882
- NewStringType type = NewStringType::kNormal , int length = -1 );
2943
+ Isolate* isolate, const uint8_t * data, v8::NewStringType type,
2944
+ int length = -1 );
2945
+
2946
+ /* * Allocates a new string from UTF-16 data.*/
2947
+ static V8_DEPRECATED (
2948
+ " Use maybe version" ,
2949
+ Local<String> NewFromTwoByte (Isolate* isolate, const uint16_t * data,
2950
+ NewStringType type = kNormalString ,
2951
+ int length = -1 ));
2883
2952
2884
2953
/* * Allocates a new string from UTF-16 data. Only returns an empty value when
2885
2954
* length > kMaxLength. **/
2886
2955
static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewFromTwoByte (
2887
- Isolate* isolate, const uint16_t * data,
2888
- NewStringType type = NewStringType:: kNormal , int length = -1 );
2956
+ Isolate* isolate, const uint16_t * data, v8::NewStringType type,
2957
+ int length = -1 );
2889
2958
2890
2959
/* *
2891
2960
* Creates a new string by concatenating the left and the right strings
@@ -2924,6 +2993,10 @@ class V8_EXPORT String : public Name {
2924
2993
* should the underlying buffer be deallocated or modified except through the
2925
2994
* destructor of the external string resource.
2926
2995
*/
2996
+ static V8_DEPRECATED (
2997
+ " Use maybe version" ,
2998
+ Local<String> NewExternal (Isolate* isolate,
2999
+ ExternalOneByteStringResource* resource));
2927
3000
static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewExternalOneByte (
2928
3001
Isolate* isolate, ExternalOneByteStringResource* resource);
2929
3002
@@ -3857,6 +3930,9 @@ class ReturnValue {
3857
3930
}
3858
3931
// Local setters
3859
3932
template <typename S>
3933
+ V8_INLINE V8_DEPRECATED (" Use Global<> instead" ,
3934
+ void Set (const Persistent<S>& handle));
3935
+ template <typename S>
3860
3936
V8_INLINE void Set (const Global<S>& handle);
3861
3937
template <typename S>
3862
3938
V8_INLINE void Set (const TracedGlobal<S>& handle);
@@ -5247,6 +5323,38 @@ class V8_EXPORT Date : public Object {
5247
5323
5248
5324
V8_INLINE static Date* Cast (Value* obj);
5249
5325
5326
+ /* *
5327
+ * Time zone redetection indicator for
5328
+ * DateTimeConfigurationChangeNotification.
5329
+ *
5330
+ * kSkip indicates V8 that the notification should not trigger redetecting
5331
+ * host time zone. kRedetect indicates V8 that host time zone should be
5332
+ * redetected, and used to set the default time zone.
5333
+ *
5334
+ * The host time zone detection may require file system access or similar
5335
+ * operations unlikely to be available inside a sandbox. If v8 is run inside a
5336
+ * sandbox, the host time zone has to be detected outside the sandbox before
5337
+ * calling DateTimeConfigurationChangeNotification function.
5338
+ */
5339
+ enum class TimeZoneDetection { kSkip , kRedetect };
5340
+
5341
+ /* *
5342
+ * Notification that the embedder has changed the time zone,
5343
+ * daylight savings time, or other date / time configuration
5344
+ * parameters. V8 keeps a cache of various values used for
5345
+ * date / time computation. This notification will reset
5346
+ * those cached values for the current context so that date /
5347
+ * time configuration changes would be reflected in the Date
5348
+ * object.
5349
+ *
5350
+ * This API should not be called more than needed as it will
5351
+ * negatively impact the performance of date operations.
5352
+ */
5353
+ V8_DEPRECATED (" Use Isolate::DateTimeConfigurationChangeNotification" ,
5354
+ static void DateTimeConfigurationChangeNotification (
5355
+ Isolate* isolate, TimeZoneDetection time_zone_detection =
5356
+ TimeZoneDetection::kSkip ));
5357
+
5250
5358
private:
5251
5359
static void CheckCast (Value* obj);
5252
5360
};
@@ -5934,6 +6042,21 @@ class V8_EXPORT FunctionTemplate : public Template {
5934
6042
*/
5935
6043
void SetAcceptAnyReceiver (bool value);
5936
6044
6045
+ /* *
6046
+ * Determines whether the __proto__ accessor ignores instances of
6047
+ * the function template. If instances of the function template are
6048
+ * ignored, __proto__ skips all instances and instead returns the
6049
+ * next object in the prototype chain.
6050
+ *
6051
+ * Call with a value of true to make the __proto__ accessor ignore
6052
+ * instances of the function template. Call with a value of false
6053
+ * to make the __proto__ accessor not ignore instances of the
6054
+ * function template. By default, instances of a function template
6055
+ * are not ignored.
6056
+ */
6057
+ V8_DEPRECATED (" This feature is incompatible with ES6+." ,
6058
+ void SetHiddenPrototype (bool value));
6059
+
5937
6060
/* *
5938
6061
* Sets the ReadOnly flag in the attributes of the 'prototype' property
5939
6062
* of functions created from this FunctionTemplate to true.
@@ -8690,9 +8813,7 @@ class V8_EXPORT V8 {
8690
8813
* Sets V8 flags from a string.
8691
8814
*/
8692
8815
static void SetFlagsFromString (const char * str);
8693
- static void SetFlagsFromString (const char * str, size_t length);
8694
- V8_DEPRECATED (" use size_t version" ,
8695
- static void SetFlagsFromString (const char * str, int length));
8816
+ static void SetFlagsFromString (const char * str, int length);
8696
8817
8697
8818
/* *
8698
8819
* Sets V8 flags from the command line.
@@ -8863,6 +8984,9 @@ class V8_EXPORT V8 {
8863
8984
const char * label);
8864
8985
static Value* Eternalize (Isolate* isolate, Value* handle);
8865
8986
8987
+ static void RegisterExternallyReferencedObject (internal::Address* location,
8988
+ internal::Isolate* isolate);
8989
+
8866
8990
template <class K , class V , class T >
8867
8991
friend class PersistentValueMapBase ;
8868
8992
@@ -9818,6 +9942,14 @@ void Persistent<T, M>::Copy(const Persistent<S, M2>& that) {
9818
9942
M::Copy (that, this );
9819
9943
}
9820
9944
9945
+ template <class T >
9946
+ bool PersistentBase<T>::IsIndependent() const {
9947
+ typedef internal::Internals I;
9948
+ if (this ->IsEmpty ()) return false ;
9949
+ return I::GetNodeFlag (reinterpret_cast <internal::Address*>(this ->val_ ),
9950
+ I::kNodeIsIndependentShift );
9951
+ }
9952
+
9821
9953
template <class T >
9822
9954
bool PersistentBase<T>::IsWeak() const {
9823
9955
typedef internal::Internals I;
@@ -9884,6 +10016,31 @@ void PersistentBase<T>::AnnotateStrongRetainer(const char* label) {
9884
10016
label);
9885
10017
}
9886
10018
10019
+ template <class T >
10020
+ void PersistentBase<T>::RegisterExternalReference(Isolate* isolate) const {
10021
+ if (IsEmpty ()) return ;
10022
+ V8::RegisterExternallyReferencedObject (
10023
+ reinterpret_cast <internal::Address*>(this ->val_ ),
10024
+ reinterpret_cast <internal::Isolate*>(isolate));
10025
+ }
10026
+
10027
+ template <class T >
10028
+ void PersistentBase<T>::MarkIndependent() {
10029
+ typedef internal::Internals I;
10030
+ if (this ->IsEmpty ()) return ;
10031
+ I::UpdateNodeFlag (reinterpret_cast <internal::Address*>(this ->val_ ), true ,
10032
+ I::kNodeIsIndependentShift );
10033
+ }
10034
+
10035
+ template <class T >
10036
+ void PersistentBase<T>::MarkActive() {
10037
+ typedef internal::Internals I;
10038
+ if (this ->IsEmpty ()) return ;
10039
+ I::UpdateNodeFlag (reinterpret_cast <internal::Address*>(this ->val_ ), true ,
10040
+ I::kNodeIsActiveShift );
10041
+ }
10042
+
10043
+
9887
10044
template <class T >
9888
10045
void PersistentBase<T>::SetWrapperClassId(uint16_t class_id) {
9889
10046
typedef internal::Internals I;
@@ -10009,6 +10166,17 @@ void TracedGlobal<T>::SetFinalizationCallback(
10009
10166
template <typename T>
10010
10167
ReturnValue<T>::ReturnValue(internal::Address* slot) : value_(slot) {}
10011
10168
10169
+ template <typename T>
10170
+ template <typename S>
10171
+ void ReturnValue<T>::Set(const Persistent<S>& handle) {
10172
+ TYPE_CHECK (T, S);
10173
+ if (V8_UNLIKELY (handle.IsEmpty ())) {
10174
+ *value_ = GetDefaultValue ();
10175
+ } else {
10176
+ *value_ = *reinterpret_cast <internal::Address*>(*handle);
10177
+ }
10178
+ }
10179
+
10012
10180
template <typename T>
10013
10181
template <typename S>
10014
10182
void ReturnValue<T>::Set(const Global<S>& handle) {
0 commit comments