Skip to content

Commit e95f866

Browse files
targosaddaleax
andcommitted
deps: patch V8 to be API/ABI compatible with 7.4 (from 7.6)
Reverts v8/v8@4214933. Reverts v8/v8@c76f377. Reverts v8/v8@e0d7f81. Co-authored-by: Anna Henningsen <[email protected]> Backport-PR-URL: #29241 PR-URL: #28955
1 parent 4eeb2a9 commit e95f866

12 files changed

+657
-222
lines changed

deps/v8/include/v8-internal.h

+2
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ class Internals {
174174
static const int kNodeStateMask = 0x7;
175175
static const int kNodeStateIsWeakValue = 2;
176176
static const int kNodeStateIsPendingValue = 3;
177+
static const int kNodeIsIndependentShift = 3;
178+
static const int kNodeIsActiveShift = 4;
177179

178180
static const int kFirstNonstringType = 0x40;
179181
static const int kOddballType = 0x43;

deps/v8/include/v8-profiler.h

+6-3
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,9 @@ class V8_EXPORT CpuProfiler {
356356
* initialized. The profiler object must be disposed after use by calling
357357
* |Dispose| method.
358358
*/
359+
static CpuProfiler* New(Isolate* isolate);
359360
static CpuProfiler* New(Isolate* isolate,
360-
CpuProfilingNamingMode = kDebugNaming);
361+
CpuProfilingNamingMode mode);
361362

362363
/**
363364
* Synchronously collect current stack sample in all profilers attached to
@@ -406,8 +407,10 @@ class V8_EXPORT CpuProfiler {
406407
* discarded.
407408
*/
408409
void StartProfiling(
409-
Local<String> title, CpuProfilingMode mode, bool record_samples = false,
410-
unsigned max_samples = CpuProfilingOptions::kNoSampleLimit);
410+
Local<String> title, CpuProfilingMode mode, bool record_samples = false);
411+
void StartProfiling(
412+
Local<String> title, CpuProfilingMode mode, bool record_samples,
413+
unsigned max_samples);
411414
/**
412415
* The same as StartProfiling above, but the CpuProfilingMode defaults to
413416
* kLeafNodeLineNumbers mode, which was the previous default behavior of the

deps/v8/include/v8-util.h

+18
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,14 @@ class PersistentValueMapBase {
194194
return SetReturnValueFromVal(&returnValue, Traits::Get(&impl_, key));
195195
}
196196

197+
/**
198+
* Call V8::RegisterExternallyReferencedObject with the map value for given
199+
* key.
200+
*/
201+
V8_DEPRECATED(
202+
"Used TracedGlobal and EmbedderHeapTracer::RegisterEmbedderReference",
203+
inline void RegisterExternallyReferencedObject(K& key));
204+
197205
/**
198206
* Return value for key and remove it from the map.
199207
*/
@@ -344,6 +352,16 @@ class PersistentValueMapBase {
344352
const char* label_;
345353
};
346354

355+
template <typename K, typename V, typename Traits>
356+
inline void
357+
PersistentValueMapBase<K, V, Traits>::RegisterExternallyReferencedObject(
358+
K& key) {
359+
assert(Contains(key));
360+
V8::RegisterExternallyReferencedObject(
361+
reinterpret_cast<internal::Address*>(FromVal(Traits::Get(&impl_, key))),
362+
reinterpret_cast<internal::Isolate*>(GetIsolate()));
363+
}
364+
347365
template <typename K, typename V, typename Traits>
348366
class PersistentValueMap : public PersistentValueMapBase<K, V, Traits> {
349367
public:

deps/v8/include/v8.h

+177-9
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ class ExternalString;
122122
class Isolate;
123123
class LocalEmbedderHeapTracer;
124124
class MicrotaskQueue;
125+
class NeverReadOnlySpaceObject;
125126
struct ScriptStreamingData;
126127
template<typename T> class CustomArguments;
127128
class 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

@@ -2525,6 +2558,9 @@ class V8_EXPORT Value : public Data {
25252558

25262559
V8_WARN_UNUSED_RESULT MaybeLocal<BigInt> ToBigInt(
25272560
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);
25282564
V8_WARN_UNUSED_RESULT MaybeLocal<Number> ToNumber(
25292565
Local<Context> context) const;
25302566
V8_WARN_UNUSED_RESULT MaybeLocal<String> ToString(
@@ -2540,6 +2576,16 @@ class V8_EXPORT Value : public Data {
25402576
V8_WARN_UNUSED_RESULT MaybeLocal<Int32> ToInt32(Local<Context> context) const;
25412577

25422578
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);
25432589

25442590
/**
25452591
* Attempts to convert a string to an array index.
@@ -2550,6 +2596,9 @@ class V8_EXPORT Value : public Data {
25502596

25512597
bool BooleanValue(Isolate* isolate) const;
25522598

2599+
V8_DEPRECATED("BooleanValue can never throw. Use Isolate version.",
2600+
V8_WARN_UNUSED_RESULT Maybe<bool> BooleanValue(
2601+
Local<Context> context) const);
25532602
V8_WARN_UNUSED_RESULT Maybe<double> NumberValue(Local<Context> context) const;
25542603
V8_WARN_UNUSED_RESULT Maybe<int64_t> IntegerValue(
25552604
Local<Context> context) const;
@@ -2869,23 +2918,43 @@ class V8_EXPORT String : public Name {
28692918

28702919
V8_INLINE static String* Cast(v8::Value* obj);
28712920

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+
28722934
/** Allocates a new string from UTF-8 data. Only returns an empty value when
28732935
* length > kMaxLength. **/
28742936
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);
28772939

28782940
/** Allocates a new string from Latin-1 data. Only returns an empty value
28792941
* when length > kMaxLength. **/
28802942
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));
28832952

28842953
/** Allocates a new string from UTF-16 data. Only returns an empty value when
28852954
* length > kMaxLength. **/
28862955
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);
28892958

28902959
/**
28912960
* Creates a new string by concatenating the left and the right strings
@@ -2924,6 +2993,10 @@ class V8_EXPORT String : public Name {
29242993
* should the underlying buffer be deallocated or modified except through the
29252994
* destructor of the external string resource.
29262995
*/
2996+
static V8_DEPRECATED(
2997+
"Use maybe version",
2998+
Local<String> NewExternal(Isolate* isolate,
2999+
ExternalOneByteStringResource* resource));
29273000
static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewExternalOneByte(
29283001
Isolate* isolate, ExternalOneByteStringResource* resource);
29293002

@@ -3857,6 +3930,9 @@ class ReturnValue {
38573930
}
38583931
// Local setters
38593932
template <typename S>
3933+
V8_INLINE V8_DEPRECATED("Use Global<> instead",
3934+
void Set(const Persistent<S>& handle));
3935+
template <typename S>
38603936
V8_INLINE void Set(const Global<S>& handle);
38613937
template <typename S>
38623938
V8_INLINE void Set(const TracedGlobal<S>& handle);
@@ -5247,6 +5323,38 @@ class V8_EXPORT Date : public Object {
52475323

52485324
V8_INLINE static Date* Cast(Value* obj);
52495325

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+
52505358
private:
52515359
static void CheckCast(Value* obj);
52525360
};
@@ -5934,6 +6042,21 @@ class V8_EXPORT FunctionTemplate : public Template {
59346042
*/
59356043
void SetAcceptAnyReceiver(bool value);
59366044

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+
59376060
/**
59386061
* Sets the ReadOnly flag in the attributes of the 'prototype' property
59396062
* of functions created from this FunctionTemplate to true.
@@ -8690,9 +8813,7 @@ class V8_EXPORT V8 {
86908813
* Sets V8 flags from a string.
86918814
*/
86928815
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);
86968817

86978818
/**
86988819
* Sets V8 flags from the command line.
@@ -8863,6 +8984,9 @@ class V8_EXPORT V8 {
88638984
const char* label);
88648985
static Value* Eternalize(Isolate* isolate, Value* handle);
88658986

8987+
static void RegisterExternallyReferencedObject(internal::Address* location,
8988+
internal::Isolate* isolate);
8989+
88668990
template <class K, class V, class T>
88678991
friend class PersistentValueMapBase;
88688992

@@ -9818,6 +9942,14 @@ void Persistent<T, M>::Copy(const Persistent<S, M2>& that) {
98189942
M::Copy(that, this);
98199943
}
98209944

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+
98219953
template <class T>
98229954
bool PersistentBase<T>::IsWeak() const {
98239955
typedef internal::Internals I;
@@ -9884,6 +10016,31 @@ void PersistentBase<T>::AnnotateStrongRetainer(const char* label) {
988410016
label);
988510017
}
988610018

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+
988710044
template <class T>
988810045
void PersistentBase<T>::SetWrapperClassId(uint16_t class_id) {
988910046
typedef internal::Internals I;
@@ -10009,6 +10166,17 @@ void TracedGlobal<T>::SetFinalizationCallback(
1000910166
template <typename T>
1001010167
ReturnValue<T>::ReturnValue(internal::Address* slot) : value_(slot) {}
1001110168

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+
1001210180
template <typename T>
1001310181
template <typename S>
1001410182
void ReturnValue<T>::Set(const Global<S>& handle) {

0 commit comments

Comments
 (0)