Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitee6d04f

Browse files
committed
[v20.x] backport vm-related memory fixes
nodejs/node#49874
1 parent966ba50 commitee6d04f

File tree

2 files changed

+88
-0
lines changed

2 files changed

+88
-0
lines changed

‎patches/v8/.patches

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
build_gn.patch
22
do_not_export_private_v8_symbols_on_windows.patch
33
chore_allow_customizing_microtask_policy_per_context.patch
4+
deps_add_v8_object_setinternalfieldfornodecore.patch
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Shelley Vohr <shelley.vohr@gmail.com>
3+
Date: Tue, 14 Nov 2023 17:48:11 +0100
4+
Subject: deps: add v8::Object::SetInternalFieldForNodeCore()
5+
6+
This is a non-ABI breaking solution added by Node.js in v20.x for:
7+
8+
* https://chromium-review.googlesource.com/c/v8/v8/+/4827307
9+
* https://chromium-review.googlesource.com/c/v8/v8/+/4707972
10+
11+
which are necessary for backporting the vm-related memory fixes in https://github.com/nodejs/node/pull/48510.
12+
13+
diff --git a/include/v8-object.h b/include/v8-object.h
14+
index 454458f9c28c840c5800ca841966812fc74884d2..36d774b015e4bb404b19dac50a9bac675d14abe0 100644
15+
--- a/include/v8-object.h
16+
+++ b/include/v8-object.h
17+
@@ -20,6 +20,8 @@ class Function;
18+
class FunctionTemplate;
19+
template <typename T>
20+
class PropertyCallbackInfo;
21+
+class Module;
22+
+class UnboundScript;
23+
24+
/**
25+
* A private symbol
26+
@@ -504,6 +506,21 @@ class V8_EXPORT Object : public Value {
27+
*/
28+
V8_INLINE void* GetAlignedPointerFromInternalField(int index);
29+
30+
+ /**
31+
+ * Warning: These are Node.js-specific extentions used to avoid breaking
32+
+ * changes in Node.js v20.x. They do not exist in V8 upstream and will
33+
+ * not exist in Node.js v21.x. Node.js embedders and addon authors should
34+
+ * not use them from v20.x.
35+
+ */
36+
+#ifndef NODE_WANT_INTERNALS
37+
+ V8_DEPRECATED("This extention should only be used by Node.js core")
38+
+#endif
39+
+ void SetInternalFieldForNodeCore(int index, Local<Module> value);
40+
+#ifndef NODE_WANT_INTERNALS
41+
+ V8_DEPRECATED("This extention should only be used by Node.js core")
42+
+#endif
43+
+ void SetInternalFieldForNodeCore(int index, Local<UnboundScript> value);
44+
+
45+
/** Same as above, but works for PersistentBase. */
46+
V8_INLINE static void* GetAlignedPointerFromInternalField(
47+
const PersistentBase<Object>& object, int index) {
48+
diff --git a/src/api/api.cc b/src/api/api.cc
49+
index 7fdd28a9303f16a9ae90395e15deb6286032e647..5367e063d3f793173ad754bd5639c1fef76baf5a 100644
50+
--- a/src/api/api.cc
51+
+++ b/src/api/api.cc
52+
@@ -6288,14 +6288,33 @@ Local<Data> v8::Object::SlowGetInternalField(int index) {
53+
isolate);
54+
}
55+
56+
-void v8::Object::SetInternalField(int index, v8::Local<Data> value) {
57+
- auto obj = Utils::OpenDirectHandle(this);
58+
+template<typename T>
59+
+void SetInternalFieldImpl(v8::Object* receiver, int index, v8::Local<T> value) {
60+
+ auto obj = Utils::OpenDirectHandle(receiver);
61+
const char* location = "v8::Object::SetInternalField()";
62+
if (!InternalFieldOK(obj, index, location)) return;
63+
auto val = Utils::OpenDirectHandle(*value);
64+
i::DirectHandle<i::JSObject>::cast(obj)->SetEmbedderField(index, *val);
65+
}
66+
67+
+void v8::Object::SetInternalField(int index, v8::Local<Data> value) {
68+
+ SetInternalFieldImpl(this, index, value);
69+
+}
70+
+
71+
+/**
72+
+ * These are Node.js-specific extentions used to avoid breaking changes in
73+
+ * Node.js v20.x.
74+
+ */
75+
+void v8::Object::SetInternalFieldForNodeCore(int index,
76+
+ v8::Local<Module> value) {
77+
+ SetInternalFieldImpl(this, index, value);
78+
+}
79+
+
80+
+void v8::Object::SetInternalFieldForNodeCore(int index,
81+
+ v8::Local<UnboundScript> value) {
82+
+ SetInternalFieldImpl(this, index, value);
83+
+}
84+
+
85+
void* v8::Object::SlowGetAlignedPointerFromInternalField(int index) {
86+
auto obj = Utils::OpenDirectHandle(this);
87+
const char* location = "v8::Object::GetAlignedPointerFromInternalField()";

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp