Skip to content

Commit

Permalink
[v20.x] backport vm-related memory fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed Nov 14, 2023
1 parent b5f115b commit 6210234
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions patches/v8/.patches
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
build_gn.patch
do_not_export_private_v8_symbols_on_windows.patch
chore_allow_customizing_microtask_policy_per_context.patch
deps_add_v8_object_setinternalfieldfornodecore.patch
47 changes: 47 additions & 0 deletions patches/v8/deps_add_v8_object_setinternalfieldfornodecore.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Tue, 14 Nov 2023 17:48:11 +0100
Subject: deps: add v8::Object::SetInternalFieldForNodeCore()

This is a non-ABI breaking solution added by Node.js in v20.x for:

* https://chromium-review.googlesource.com/c/v8/v8/+/4827307
* https://chromium-review.googlesource.com/c/v8/v8/+/4707972

which are necessary for backporting the vm-related memory fixes in https://github.com/nodejs/node/pull/48510.

diff --git a/include/v8-object.h b/include/v8-object.h
index 454458f9c28c840c5800ca841966812fc74884d2..36d774b015e4bb404b19dac50a9bac675d14abe0 100644
--- a/include/v8-object.h
+++ b/include/v8-object.h
@@ -20,6 +20,8 @@ class Function;
class FunctionTemplate;
template <typename T>
class PropertyCallbackInfo;
+class Module;
+class UnboundScript;

/**
* A private symbol
@@ -504,6 +506,21 @@ class V8_EXPORT Object : public Value {
*/
V8_INLINE void* GetAlignedPointerFromInternalField(int index);

+ /**
+ * Warning: These are Node.js-specific extentions used to avoid breaking
+ * changes in Node.js v20.x. They do not exist in V8 upstream and will
+ * not exist in Node.js v21.x. Node.js embedders and addon authors should
+ * not use them from v20.x.
+ */
+#ifndef NODE_WANT_INTERNALS
+ V8_DEPRECATED("This extention should only be used by Node.js core")
+#endif
+ void SetInternalFieldForNodeCore(int index, Local<Module> value);
+#ifndef NODE_WANT_INTERNALS
+ V8_DEPRECATED("This extention should only be used by Node.js core")
+#endif
+ void SetInternalFieldForNodeCore(int index, Local<UnboundScript> value);
+
/** Same as above, but works for PersistentBase. */
V8_INLINE static void* GetAlignedPointerFromInternalField(
const PersistentBase<Object>& object, int index) {

0 comments on commit 6210234

Please sign in to comment.