-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
src: put (de)serialization code into node_snapshotable.h/cc
So that it's easier to find the corresponding code. PR-URL: #37114 Refs: #36943 Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
- Loading branch information
1 parent
9aeb836
commit 2e769a9
Showing
5 changed files
with
64 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
#ifndef SRC_NODE_SNAPSHOTABLE_H_ | ||
#define SRC_NODE_SNAPSHOTABLE_H_ | ||
|
||
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS | ||
|
||
#include "v8.h" | ||
namespace node { | ||
|
||
v8::StartupData SerializeNodeContextInternalFields(v8::Local<v8::Object> holder, | ||
int index, | ||
void* env); | ||
void DeserializeNodeInternalFields(v8::Local<v8::Object> holder, | ||
int index, | ||
v8::StartupData payload, | ||
void* env); | ||
} // namespace node | ||
|
||
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS | ||
|
||
#endif // SRC_NODE_SNAPSHOTABLE_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters