Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2021-01-28 19:04:22 +0300
committerJoyee Cheung <joyeec9h3@gmail.com>2021-02-05 15:18:47 +0300
commit2e769a92ff1e600f56deb3a65ff9823816aff330 (patch)
tree2711607c7aac8798151f3e35b2791d9a38421f40 /src/node_snapshotable.cc
parent9aeb83643486328cbdffb55a23efe953f6ee54e0 (diff)
src: put (de)serialization code into node_snapshotable.h/cc
So that it's easier to find the corresponding code. PR-URL: https://github.com/nodejs/node/pull/37114 Refs: https://github.com/nodejs/node/pull/36943 Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Diffstat (limited to 'src/node_snapshotable.cc')
-rw-r--r--src/node_snapshotable.cc39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/node_snapshotable.cc b/src/node_snapshotable.cc
new file mode 100644
index 00000000000..21de1086856
--- /dev/null
+++ b/src/node_snapshotable.cc
@@ -0,0 +1,39 @@
+
+#include "node_snapshotable.h"
+#include "base_object-inl.h"
+
+namespace node {
+
+using v8::Local;
+using v8::Object;
+using v8::StartupData;
+
+void DeserializeNodeInternalFields(Local<Object> holder,
+ int index,
+ v8::StartupData payload,
+ void* env) {
+ if (payload.raw_size == 0) {
+ holder->SetAlignedPointerInInternalField(index, nullptr);
+ return;
+ }
+ // No embedder object in the builtin snapshot yet.
+ UNREACHABLE();
+}
+
+StartupData SerializeNodeContextInternalFields(Local<Object> holder,
+ int index,
+ void* env) {
+ void* ptr = holder->GetAlignedPointerFromInternalField(index);
+ if (ptr == nullptr || ptr == env) {
+ return StartupData{nullptr, 0};
+ }
+ if (ptr == env && index == ContextEmbedderIndex::kEnvironment) {
+ return StartupData{nullptr, 0};
+ }
+
+ // No embedder objects in the builtin snapshot yet.
+ UNREACHABLE();
+ return StartupData{nullptr, 0};
+}
+
+} // namespace node