Skip to content

Commit 887ca3b

Browse files
targosaddaleax
authored 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: #30109 Backport-PR-URL: #29241 PR-URL: #28955
1 parent da3459b commit 887ca3b

13 files changed

+665
-224
lines changed

common.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
# Reset this number to 0 on major V8 upgrades.
4040
# Increment by one for each non-official patch applied to deps/v8.
41-
'v8_embedder_string': '-node.18',
41+
'v8_embedder_string': '-node.19',
4242

4343
##### V8 defaults for Node.js #####
4444

deps/v8/include/v8-internal.h

+2
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ class Internals {
181181
static const int kNodeStateMask = 0x7;
182182
static const int kNodeStateIsWeakValue = 2;
183183
static const int kNodeStateIsPendingValue = 3;
184+
static const int kNodeIsIndependentShift = 3;
185+
static const int kNodeIsActiveShift = 4;
184186

185187
static const int kFirstNonstringType = 0x40;
186188
static const int kOddballType = 0x43;

deps/v8/include/v8-profiler.h

+9-4
Original file line numberDiff line numberDiff line change
@@ -304,9 +304,12 @@ class V8_EXPORT CpuProfiler {
304304
* initialized. The profiler object must be disposed after use by calling
305305
* |Dispose| method.
306306
*/
307+
static CpuProfiler* New(Isolate* isolate);
307308
static CpuProfiler* New(Isolate* isolate,
308-
CpuProfilingNamingMode = kDebugNaming,
309-
CpuProfilingLoggingMode = kLazyLogging);
309+
CpuProfilingNamingMode mode);
310+
static CpuProfiler* New(Isolate* isolate,
311+
CpuProfilingNamingMode namingMode,
312+
CpuProfilingLoggingMode loggingMode);
310313

311314
/**
312315
* Synchronously collect current stack sample in all profilers attached to
@@ -355,8 +358,10 @@ class V8_EXPORT CpuProfiler {
355358
* discarded.
356359
*/
357360
void StartProfiling(
358-
Local<String> title, CpuProfilingMode mode, bool record_samples = false,
359-
unsigned max_samples = CpuProfilingOptions::kNoSampleLimit);
361+
Local<String> title, CpuProfilingMode mode, bool record_samples = false);
362+
void StartProfiling(
363+
Local<String> title, CpuProfilingMode mode, bool record_samples,
364+
unsigned max_samples);
360365
/**
361366
* The same as StartProfiling above, but the CpuProfilingMode defaults to
362367
* 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
@@ -123,6 +123,7 @@ class ExternalString;
123123
class Isolate;
124124
class LocalEmbedderHeapTracer;
125125
class MicrotaskQueue;
126+
class NeverReadOnlySpaceObject;
126127
struct ScriptStreamingData;
127128
template<typename T> class CustomArguments;
128129
class PropertyCallbackArguments;
@@ -546,6 +547,38 @@ template <class T> class PersistentBase {
546547
*/
547548
V8_INLINE void AnnotateStrongRetainer(const char* label);
548549

550+
/**
551+
* Allows the embedder to tell the v8 garbage collector that a certain object
552+
* is alive. Only allowed when the embedder is asked to trace its heap by
553+
* EmbedderHeapTracer.
554+
*/
555+
V8_DEPRECATED(
556+
"Used TracedGlobal and EmbedderHeapTracer::RegisterEmbedderReference",
557+
V8_INLINE void RegisterExternalReference(Isolate* isolate) const);
558+
559+
/**
560+
* Marks the reference to this object independent. Garbage collector is free
561+
* to ignore any object groups containing this object. Weak callback for an
562+
* independent handle should not assume that it will be preceded by a global
563+
* GC prologue callback or followed by a global GC epilogue callback.
564+
*/
565+
V8_DEPRECATED(
566+
"Weak objects are always considered independent. "
567+
"Use TracedGlobal when trying to use EmbedderHeapTracer. "
568+
"Use a strong handle when trying to keep an object alive.",
569+
V8_INLINE void MarkIndependent());
570+
571+
/**
572+
* Marks the reference to this object as active. The scavenge garbage
573+
* collection should not reclaim the objects marked as active, even if the
574+
* object held by the handle is otherwise unreachable.
575+
*
576+
* This bit is cleared after the each garbage collection pass.
577+
*/
578+
V8_DEPRECATED("Use TracedGlobal.", V8_INLINE void MarkActive());
579+
580+
V8_DEPRECATED("See MarkIndependent.", V8_INLINE bool IsIndependent() const);
581+
549582
/** Returns true if the handle's reference is weak. */
550583
V8_INLINE bool IsWeak() const;
551584

@@ -2613,6 +2646,9 @@ class V8_EXPORT Value : public Data {
26132646

26142647
V8_WARN_UNUSED_RESULT MaybeLocal<BigInt> ToBigInt(
26152648
Local<Context> context) const;
2649+
V8_DEPRECATED("ToBoolean can never throw. Use Local version.",
2650+
V8_WARN_UNUSED_RESULT MaybeLocal<Boolean> ToBoolean(
2651+
Local<Context> context) const);
26162652
V8_WARN_UNUSED_RESULT MaybeLocal<Number> ToNumber(
26172653
Local<Context> context) const;
26182654
V8_WARN_UNUSED_RESULT MaybeLocal<String> ToString(
@@ -2628,6 +2664,16 @@ class V8_EXPORT Value : public Data {
26282664
V8_WARN_UNUSED_RESULT MaybeLocal<Int32> ToInt32(Local<Context> context) const;
26292665

26302666
Local<Boolean> ToBoolean(Isolate* isolate) const;
2667+
V8_DEPRECATED("Use maybe version",
2668+
Local<Number> ToNumber(Isolate* isolate) const);
2669+
V8_DEPRECATED("Use maybe version",
2670+
Local<String> ToString(Isolate* isolate) const);
2671+
V8_DEPRECATED("Use maybe version",
2672+
Local<Object> ToObject(Isolate* isolate) const);
2673+
V8_DEPRECATED("Use maybe version",
2674+
Local<Integer> ToInteger(Isolate* isolate) const);
2675+
V8_DEPRECATED("Use maybe version",
2676+
Local<Int32> ToInt32(Isolate* isolate) const);
26312677

26322678
/**
26332679
* Attempts to convert a string to an array index.
@@ -2638,6 +2684,9 @@ class V8_EXPORT Value : public Data {
26382684

26392685
bool BooleanValue(Isolate* isolate) const;
26402686

2687+
V8_DEPRECATED("BooleanValue can never throw. Use Isolate version.",
2688+
V8_WARN_UNUSED_RESULT Maybe<bool> BooleanValue(
2689+
Local<Context> context) const);
26412690
V8_WARN_UNUSED_RESULT Maybe<double> NumberValue(Local<Context> context) const;
26422691
V8_WARN_UNUSED_RESULT Maybe<int64_t> IntegerValue(
26432692
Local<Context> context) const;
@@ -2957,23 +3006,43 @@ class V8_EXPORT String : public Name {
29573006

29583007
V8_INLINE static String* Cast(v8::Value* obj);
29593008

3009+
// TODO(dcarney): remove with deprecation of New functions.
3010+
enum NewStringType {
3011+
kNormalString = static_cast<int>(v8::NewStringType::kNormal),
3012+
kInternalizedString = static_cast<int>(v8::NewStringType::kInternalized)
3013+
};
3014+
3015+
/** Allocates a new string from UTF-8 data.*/
3016+
static V8_DEPRECATED(
3017+
"Use maybe version",
3018+
Local<String> NewFromUtf8(Isolate* isolate, const char* data,
3019+
NewStringType type = kNormalString,
3020+
int length = -1));
3021+
29603022
/** Allocates a new string from UTF-8 data. Only returns an empty value when
29613023
* length > kMaxLength. **/
29623024
static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewFromUtf8(
2963-
Isolate* isolate, const char* data,
2964-
NewStringType type = NewStringType::kNormal, int length = -1);
3025+
Isolate* isolate, const char* data, v8::NewStringType type,
3026+
int length = -1);
29653027

29663028
/** Allocates a new string from Latin-1 data. Only returns an empty value
29673029
* when length > kMaxLength. **/
29683030
static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewFromOneByte(
2969-
Isolate* isolate, const uint8_t* data,
2970-
NewStringType type = NewStringType::kNormal, int length = -1);
3031+
Isolate* isolate, const uint8_t* data, v8::NewStringType type,
3032+
int length = -1);
3033+
3034+
/** Allocates a new string from UTF-16 data.*/
3035+
static V8_DEPRECATED(
3036+
"Use maybe version",
3037+
Local<String> NewFromTwoByte(Isolate* isolate, const uint16_t* data,
3038+
NewStringType type = kNormalString,
3039+
int length = -1));
29713040

29723041
/** Allocates a new string from UTF-16 data. Only returns an empty value when
29733042
* length > kMaxLength. **/
29743043
static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewFromTwoByte(
2975-
Isolate* isolate, const uint16_t* data,
2976-
NewStringType type = NewStringType::kNormal, int length = -1);
3044+
Isolate* isolate, const uint16_t* data, v8::NewStringType type,
3045+
int length = -1);
29773046

29783047
/**
29793048
* Creates a new string by concatenating the left and the right strings
@@ -3012,6 +3081,10 @@ class V8_EXPORT String : public Name {
30123081
* should the underlying buffer be deallocated or modified except through the
30133082
* destructor of the external string resource.
30143083
*/
3084+
static V8_DEPRECATED(
3085+
"Use maybe version",
3086+
Local<String> NewExternal(Isolate* isolate,
3087+
ExternalOneByteStringResource* resource));
30153088
static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewExternalOneByte(
30163089
Isolate* isolate, ExternalOneByteStringResource* resource);
30173090

@@ -3954,6 +4027,9 @@ class ReturnValue {
39544027
}
39554028
// Local setters
39564029
template <typename S>
4030+
V8_INLINE V8_DEPRECATED("Use Global<> instead",
4031+
void Set(const Persistent<S>& handle));
4032+
template <typename S>
39574033
V8_INLINE void Set(const Global<S>& handle);
39584034
template <typename S>
39594035
V8_INLINE void Set(const TracedGlobal<S>& handle);
@@ -5344,6 +5420,38 @@ class V8_EXPORT Date : public Object {
53445420

53455421
V8_INLINE static Date* Cast(Value* obj);
53465422

5423+
/**
5424+
* Time zone redetection indicator for
5425+
* DateTimeConfigurationChangeNotification.
5426+
*
5427+
* kSkip indicates V8 that the notification should not trigger redetecting
5428+
* host time zone. kRedetect indicates V8 that host time zone should be
5429+
* redetected, and used to set the default time zone.
5430+
*
5431+
* The host time zone detection may require file system access or similar
5432+
* operations unlikely to be available inside a sandbox. If v8 is run inside a
5433+
* sandbox, the host time zone has to be detected outside the sandbox before
5434+
* calling DateTimeConfigurationChangeNotification function.
5435+
*/
5436+
enum class TimeZoneDetection { kSkip, kRedetect };
5437+
5438+
/**
5439+
* Notification that the embedder has changed the time zone,
5440+
* daylight savings time, or other date / time configuration
5441+
* parameters. V8 keeps a cache of various values used for
5442+
* date / time computation. This notification will reset
5443+
* those cached values for the current context so that date /
5444+
* time configuration changes would be reflected in the Date
5445+
* object.
5446+
*
5447+
* This API should not be called more than needed as it will
5448+
* negatively impact the performance of date operations.
5449+
*/
5450+
V8_DEPRECATED("Use Isolate::DateTimeConfigurationChangeNotification",
5451+
static void DateTimeConfigurationChangeNotification(
5452+
Isolate* isolate, TimeZoneDetection time_zone_detection =
5453+
TimeZoneDetection::kSkip));
5454+
53475455
private:
53485456
static void CheckCast(Value* obj);
53495457
};
@@ -6057,6 +6165,21 @@ class V8_EXPORT FunctionTemplate : public Template {
60576165
*/
60586166
void SetAcceptAnyReceiver(bool value);
60596167

6168+
/**
6169+
* Determines whether the __proto__ accessor ignores instances of
6170+
* the function template. If instances of the function template are
6171+
* ignored, __proto__ skips all instances and instead returns the
6172+
* next object in the prototype chain.
6173+
*
6174+
* Call with a value of true to make the __proto__ accessor ignore
6175+
* instances of the function template. Call with a value of false
6176+
* to make the __proto__ accessor not ignore instances of the
6177+
* function template. By default, instances of a function template
6178+
* are not ignored.
6179+
*/
6180+
V8_DEPRECATED("This feature is incompatible with ES6+.",
6181+
void SetHiddenPrototype(bool value));
6182+
60606183
/**
60616184
* Sets the ReadOnly flag in the attributes of the 'prototype' property
60626185
* of functions created from this FunctionTemplate to true.
@@ -8905,9 +9028,7 @@ class V8_EXPORT V8 {
89059028
* Sets V8 flags from a string.
89069029
*/
89079030
static void SetFlagsFromString(const char* str);
8908-
static void SetFlagsFromString(const char* str, size_t length);
8909-
V8_DEPRECATED("use size_t version",
8910-
static void SetFlagsFromString(const char* str, int length));
9031+
static void SetFlagsFromString(const char* str, int length);
89119032

89129033
/**
89139034
* Sets V8 flags from the command line.
@@ -9081,6 +9202,9 @@ class V8_EXPORT V8 {
90819202
const char* label);
90829203
static Value* Eternalize(Isolate* isolate, Value* handle);
90839204

9205+
static void RegisterExternallyReferencedObject(internal::Address* location,
9206+
internal::Isolate* isolate);
9207+
90849208
template <class K, class V, class T>
90859209
friend class PersistentValueMapBase;
90869210

@@ -10036,6 +10160,14 @@ void Persistent<T, M>::Copy(const Persistent<S, M2>& that) {
1003610160
M::Copy(that, this);
1003710161
}
1003810162

10163+
template <class T>
10164+
bool PersistentBase<T>::IsIndependent() const {
10165+
typedef internal::Internals I;
10166+
if (this->IsEmpty()) return false;
10167+
return I::GetNodeFlag(reinterpret_cast<internal::Address*>(this->val_),
10168+
I::kNodeIsIndependentShift);
10169+
}
10170+
1003910171
template <class T>
1004010172
bool PersistentBase<T>::IsWeak() const {
1004110173
typedef internal::Internals I;
@@ -10102,6 +10234,31 @@ void PersistentBase<T>::AnnotateStrongRetainer(const char* label) {
1010210234
label);
1010310235
}
1010410236

10237+
template <class T>
10238+
void PersistentBase<T>::RegisterExternalReference(Isolate* isolate) const {
10239+
if (IsEmpty()) return;
10240+
V8::RegisterExternallyReferencedObject(
10241+
reinterpret_cast<internal::Address*>(this->val_),
10242+
reinterpret_cast<internal::Isolate*>(isolate));
10243+
}
10244+
10245+
template <class T>
10246+
void PersistentBase<T>::MarkIndependent() {
10247+
typedef internal::Internals I;
10248+
if (this->IsEmpty()) return;
10249+
I::UpdateNodeFlag(reinterpret_cast<internal::Address*>(this->val_), true,
10250+
I::kNodeIsIndependentShift);
10251+
}
10252+
10253+
template <class T>
10254+
void PersistentBase<T>::MarkActive() {
10255+
typedef internal::Internals I;
10256+
if (this->IsEmpty()) return;
10257+
I::UpdateNodeFlag(reinterpret_cast<internal::Address*>(this->val_), true,
10258+
I::kNodeIsActiveShift);
10259+
}
10260+
10261+
1010510262
template <class T>
1010610263
void PersistentBase<T>::SetWrapperClassId(uint16_t class_id) {
1010710264
typedef internal::Internals I;
@@ -10252,6 +10409,17 @@ void TracedGlobal<T>::SetFinalizationCallback(
1025210409
template <typename T>
1025310410
ReturnValue<T>::ReturnValue(internal::Address* slot) : value_(slot) {}
1025410411

10412+
template<typename T>
10413+
template<typename S>
10414+
void ReturnValue<T>::Set(const Persistent<S>& handle) {
10415+
TYPE_CHECK(T, S);
10416+
if (V8_UNLIKELY(handle.IsEmpty())) {
10417+
*value_ = GetDefaultValue();
10418+
} else {
10419+
*value_ = *reinterpret_cast<internal::Address*>(*handle);
10420+
}
10421+
}
10422+
1025510423
template <typename T>
1025610424
template <typename S>
1025710425
void ReturnValue<T>::Set(const Global<S>& handle) {

0 commit comments

Comments
 (0)