mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
Instead of iterating over the bindings, iterate over the base
objects that are snapshottable. This allows us to snapshot
base objects that are not bindings. In addition this refactors
the InternalFieldInfo class to eliminate potential undefined
behaviors, and renames it to InternalFieldInfoBase.
The {de}serialize callbacks now expect a InternalFieldInfo struct
nested in Snapshotable classes that can be used to carry
serialization data around. This allows us to create structs
inheriting from InternalFieldInfo for Snapshotable objects
that need custom fields.
PR-URL: https://github.com/nodejs/node/pull/44192
Refs: https://github.com/nodejs/node/issues/37476
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
44 lines
1.1 KiB
C++
44 lines
1.1 KiB
C++
#ifndef SRC_NODE_V8_H_
|
|
#define SRC_NODE_V8_H_
|
|
|
|
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
|
|
#include "aliased_buffer.h"
|
|
#include "base_object.h"
|
|
#include "node_snapshotable.h"
|
|
#include "util.h"
|
|
#include "v8.h"
|
|
|
|
namespace node {
|
|
class Environment;
|
|
struct InternalFieldInfoBase;
|
|
|
|
namespace v8_utils {
|
|
class BindingData : public SnapshotableObject {
|
|
public:
|
|
BindingData(Environment* env, v8::Local<v8::Object> obj);
|
|
|
|
using InternalFieldInfo = InternalFieldInfoBase;
|
|
|
|
SERIALIZABLE_OBJECT_METHODS()
|
|
static constexpr FastStringKey type_name{"node::v8::BindingData"};
|
|
static constexpr EmbedderObjectType type_int =
|
|
EmbedderObjectType::k_v8_binding_data;
|
|
|
|
AliasedFloat64Array heap_statistics_buffer;
|
|
AliasedFloat64Array heap_space_statistics_buffer;
|
|
AliasedFloat64Array heap_code_statistics_buffer;
|
|
|
|
void MemoryInfo(MemoryTracker* tracker) const override;
|
|
SET_SELF_SIZE(BindingData)
|
|
SET_MEMORY_INFO_NAME(BindingData)
|
|
};
|
|
|
|
} // namespace v8_utils
|
|
|
|
} // namespace node
|
|
|
|
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
|
|
#endif // SRC_NODE_V8_H_
|