[v12.x] Backport of deps: update V8 to 7.5
/cc @nodejs/v8-update @addaleax
Diff in `deps/v8/include`
diff --git a/deps/v8/include/v8-profiler.h b/deps/v8/include/v8-profiler.h
index ada2dbbe5c..672a694e07 100644
--- a/deps/v8/include/v8-profiler.h
+++ b/deps/v8/include/v8-profiler.h
@@ -48,7 +48,7 @@ template class V8_EXPORT std::vector<v8::CpuProfileDeoptInfo>;
namespace v8 {
// TickSample captures the information collected for each sample.
-struct TickSample {
+struct V8_EXPORT TickSample {
// Internal profiling (with --prof + tools/$OS-tick-processor) wants to
// include the runtime function we're calling. Externally exposed tick
// samples don't care.
@@ -129,6 +129,20 @@ class V8_EXPORT CpuProfileNode {
unsigned int hit_count;
};
+ // An annotation hinting at the source of a CpuProfileNode.
+ enum SourceType {
+ // User-supplied script with associated resource information.
+ kScript = 0,
+ // Native scripts and provided builtins.
+ kBuiltin = 1,
+ // Callbacks into native code.
+ kCallback = 2,
+ // VM-internal functions or state.
+ kInternal = 3,
+ // A node that failed to symbolize.
+ kUnresolved = 4,
+ };
+
/** Returns function name (empty string for anonymous functions.) */
Local<String> GetFunctionName() const;
@@ -152,6 +166,12 @@ class V8_EXPORT CpuProfileNode {
*/
const char* GetScriptResourceNameStr() const;
+ /**
+ * Return true if the script from where the function originates is flagged as
+ * being shared cross-origin.
+ */
+ bool IsScriptSharedCrossOrigin() const;
+
/**
* Returns the number, 1-based, of the line where the function originates.
* kNoLineNumberInfo if no line number information is available.
@@ -194,12 +214,20 @@ class V8_EXPORT CpuProfileNode {
/** Returns id of the node. The id is unique within the tree */
unsigned GetNodeId() const;
+ /**
+ * Gets the type of the source which the node was captured from.
+ */
+ SourceType GetSourceType() const;
+
/** Returns child nodes count of the node. */
int GetChildrenCount() const;
/** Retrieves a child node by index. */
const CpuProfileNode* GetChild(int index) const;
+ /** Retrieves the ancestor node, or null if the root. */
+ const CpuProfileNode* GetParent() const;
+
/** Retrieves deopt infos for the node. */
const std::vector<CpuProfileDeoptInfo>& GetDeoptInfos() const;
@@ -301,6 +329,15 @@ class V8_EXPORT CpuProfiler {
*/
void SetSamplingInterval(int us);
+ /**
+ * Sets whether or not the profiler should prioritize consistency of sample
+ * periodicity on Windows. Disabling this can greatly reduce CPU usage, but
+ * may result in greater variance in sample timings from the platform's
+ * scheduler. Defaults to enabled. This method must be called when there are
+ * no profiles being recorded.
+ */
+ void SetUsePreciseSampling(bool);
+
/**
* Starts collecting CPU profile. Title may be an empty string. It
* is allowed to have several profiles being collected at
diff --git a/deps/v8/include/v8-version.h b/deps/v8/include/v8-version.h
index 4093306dc8..dfcd5b467d 100644
--- a/deps/v8/include/v8-version.h
+++ b/deps/v8/include/v8-version.h
@@ -9,9 +9,9 @@
// NOTE these macros are used by some of the tool scripts and the build
// system so their names cannot be changed without changing the scripts.
#define V8_MAJOR_VERSION 7
-#define V8_MINOR_VERSION 4
+#define V8_MINOR_VERSION 5
#define V8_BUILD_NUMBER 288
-#define V8_PATCH_LEVEL 27
+#define V8_PATCH_LEVEL 22
// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
diff --git a/deps/v8/include/v8.h b/deps/v8/include/v8.h
index 7e48cd422d..b5b18a2985 100644
--- a/deps/v8/include/v8.h
+++ b/deps/v8/include/v8.h
@@ -2520,9 +2520,9 @@ class V8_EXPORT Value : public Data {
V8_WARN_UNUSED_RESULT MaybeLocal<BigInt> ToBigInt(
Local<Context> context) const;
- V8_DEPRECATE_SOON("ToBoolean can never throw. Use Local version.",
- V8_WARN_UNUSED_RESULT MaybeLocal<Boolean> ToBoolean(
- Local<Context> context) const);
+ V8_DEPRECATED("ToBoolean can never throw. Use Local version.",
+ V8_WARN_UNUSED_RESULT MaybeLocal<Boolean> ToBoolean(
+ Local<Context> context) const);
V8_WARN_UNUSED_RESULT MaybeLocal<Number> ToNumber(
Local<Context> context) const;
V8_WARN_UNUSED_RESULT MaybeLocal<String> ToString(
@@ -2538,16 +2538,16 @@ class V8_EXPORT Value : public Data {
V8_WARN_UNUSED_RESULT MaybeLocal<Int32> ToInt32(Local<Context> context) const;
Local<Boolean> ToBoolean(Isolate* isolate) const;
- V8_DEPRECATE_SOON("Use maybe version",
- Local<Number> ToNumber(Isolate* isolate) const);
- V8_DEPRECATE_SOON("Use maybe version",
- Local<String> ToString(Isolate* isolate) const);
- V8_DEPRECATE_SOON("Use maybe version",
- Local<Object> ToObject(Isolate* isolate) const);
- V8_DEPRECATE_SOON("Use maybe version",
- Local<Integer> ToInteger(Isolate* isolate) const);
- V8_DEPRECATE_SOON("Use maybe version",
- Local<Int32> ToInt32(Isolate* isolate) const);
+ V8_DEPRECATED("Use maybe version",
+ Local<Number> ToNumber(Isolate* isolate) const);
+ V8_DEPRECATED("Use maybe version",
+ Local<String> ToString(Isolate* isolate) const);
+ V8_DEPRECATED("Use maybe version",
+ Local<Object> ToObject(Isolate* isolate) const);
+ V8_DEPRECATED("Use maybe version",
+ Local<Integer> ToInteger(Isolate* isolate) const);
+ V8_DEPRECATED("Use maybe version",
+ Local<Int32> ToInt32(Isolate* isolate) const);
/**
* Attempts to convert a string to an array index.
@@ -2906,7 +2906,7 @@ class V8_EXPORT String : public Name {
int length = -1);
/** Allocates a new string from UTF-16 data.*/
- static V8_DEPRECATE_SOON(
+ static V8_DEPRECATED(
"Use maybe version",
Local<String> NewFromTwoByte(Isolate* isolate, const uint16_t* data,
NewStringType type = kNormalString,
@@ -2955,7 +2955,7 @@ class V8_EXPORT String : public Name {
* should the underlying buffer be deallocated or modified except through the
* destructor of the external string resource.
*/
- static V8_DEPRECATE_SOON(
+ static V8_DEPRECATED(
"Use maybe version",
Local<String> NewExternal(Isolate* isolate,
ExternalOneByteStringResource* resource));
@@ -5224,9 +5224,11 @@ class V8_EXPORT SharedArrayBuffer : public Object {
* Create a new SharedArrayBuffer over an existing memory block. Propagate
* flags to indicate whether the underlying buffer can be grown.
*/
- static Local<SharedArrayBuffer> New(
- Isolate* isolate, const SharedArrayBuffer::Contents&,
- ArrayBufferCreationMode mode = ArrayBufferCreationMode::kExternalized);
+ V8_DEPRECATED("Use New method with data, and byte_length instead.",
+ static Local<SharedArrayBuffer> New(
+ Isolate* isolate, const SharedArrayBuffer::Contents&,
+ ArrayBufferCreationMode mode =
+ ArrayBufferCreationMode::kExternalized));
/**
* Returns true if SharedArrayBuffer is externalized, that is, does not
@@ -5315,11 +5317,10 @@ class V8_EXPORT Date : public Object {
* This API should not be called more than needed as it will
* negatively impact the performance of date operations.
*/
- V8_DEPRECATE_SOON(
- "Use Isolate::DateTimeConfigurationChangeNotification",
- static void DateTimeConfigurationChangeNotification(
- Isolate* isolate,
- TimeZoneDetection time_zone_detection = TimeZoneDetection::kSkip));
+ V8_DEPRECATED("Use Isolate::DateTimeConfigurationChangeNotification",
+ static void DateTimeConfigurationChangeNotification(
+ Isolate* isolate, TimeZoneDetection time_zone_detection =
+ TimeZoneDetection::kSkip));
private:
static void CheckCast(Value* obj);
@@ -6681,7 +6682,7 @@ typedef void (*HostInitializeImportMetaObjectCallback)(Local<Context> context,
* first accessed. The return value will be used as the stack value. If this
* callback is registed, the |Error.prepareStackTrace| API will be disabled.
* |sites| is an array of call sites, specified in
- * https://github.com/v8/v8/wiki/Stack-Trace-API
+ * https://v8.dev/docs/stack-trace-api
*/
typedef MaybeLocal<Value> (*PrepareStackTraceCallback)(Local<Context> context,
Local<Value> error,
@@ -7165,6 +7166,13 @@ enum JitCodeEventOptions {
*/
typedef void (*JitCodeEventHandler)(const JitCodeEvent* event);
+/**
+ * Callback function passed to SetUnhandledExceptionCallback.
+ */
+#if defined(V8_OS_WIN)
+typedef int (*UnhandledExceptionCallback)(
+ _EXCEPTION_POINTERS* exception_pointers);
+#endif
/**
* Interface for iterating through all external resources in the heap.
@@ -8379,13 +8387,13 @@ class V8_EXPORT Isolate {
/**
* Returns a memory range that can potentially contain jitted code. Code for
* V8's 'builtins' will not be in this range if embedded builtins is enabled.
- * Instead, see GetEmbeddedCodeRange.
*
* On Win64, embedders are advised to install function table callbacks for
* these ranges, as default SEH won't be able to unwind through jitted code.
- *
* The first page of the code range is reserved for the embedder and is
- * committed, writable, and executable.
+ * committed, writable, and executable, to be used to store unwind data, as
+ * documented in
+ * https://docs.microsoft.com/en-us/cpp/build/exception-handling-x64.
*
* Might be empty on other platforms.
*
@@ -8785,6 +8793,20 @@ class V8_EXPORT V8 {
*/
static bool EnableWebAssemblyTrapHandler(bool use_v8_signal_handler);
+#if defined(V8_OS_WIN)
+ /**
+ * On Win64, by default V8 does not emit unwinding data for jitted code,
+ * which means the OS cannot walk the stack frames and the system Structured
+ * Exception Handling (SEH) cannot unwind through V8-generated code:
+ * https://code.google.com/p/v8/issues/detail?id=3598.
+ *
+ * This function allows embedders to register a custom exception handler for
+ * exceptions in V8-generated code.
+ */
+ static void SetUnhandledExceptionCallback(
+ UnhandledExceptionCallback unhandled_exception_callback);
+#endif
+
private:
V8();
diff --git a/deps/v8/include/v8config.h b/deps/v8/include/v8config.h
index e30a582e8f..5ec0480cf5 100644
--- a/deps/v8/include/v8config.h
+++ b/deps/v8/include/v8config.h
@@ -64,6 +64,7 @@
// V8_OS_FUCHSIA - Fuchsia
// V8_OS_LINUX - Linux
// V8_OS_MACOSX - Mac OS X
+// V8_OS_IOS - iOS
// V8_OS_NETBSD - NetBSD
// V8_OS_OPENBSD - OpenBSD
// V8_OS_POSIX - POSIX compatible (mostly everything except Windows)
@@ -80,6 +81,9 @@
# define V8_OS_BSD 1
# define V8_OS_MACOSX 1
# define V8_OS_POSIX 1
+# if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
+# define V8_OS_IOS 1
+# endif // defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
#elif defined(__CYGWIN__)
# define V8_OS_CYGWIN 1
# define V8_OS_POSIX 1