mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
src: make IsolateData store ArrayBufferAllocator
This enables us to identify whether we are using an allocator that we know more about than what the generic `ArrayBuffer::Allocator` API provides, in particular whether it is `malloc()`-compatible. PR-URL: https://github.com/nodejs/node/pull/26207 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Backport-PR-URL: https://github.com/nodejs/node/pull/26302 Reviewed-By: Michaël Zasso <targos@protonmail.com>
This commit is contained in:
4 files changed
+29
-16
No files matched your search
@@ -115,11 +115,7 @@ IsolateData* CreateIsolateData(Isolate* isolate,
|
||||
uv_loop_t* loop,
|
||||
MultiIsolatePlatform* platform,
|
||||
ArrayBufferAllocator* allocator) {
|
||||
return new IsolateData(
|
||||
isolate,
|
||||
loop,
|
||||
platform,
|
||||
allocator != nullptr ? allocator->zero_fill_field() : nullptr);
|
||||
return new IsolateData(isolate, loop, platform, allocator);
|
||||
}
|
||||
|
||||
void FreeIsolateData(IsolateData* isolate_data) {
|
||||
|
||||
+10
-2
@@ -49,8 +49,16 @@ inline uv_loop_t* IsolateData::event_loop() const {
|
||||
return event_loop_;
|
||||
}
|
||||
|
||||
inline uint32_t* IsolateData::zero_fill_field() const {
|
||||
return zero_fill_field_;
|
||||
inline bool IsolateData::uses_node_allocator() const {
|
||||
return uses_node_allocator_;
|
||||
}
|
||||
|
||||
inline v8::ArrayBuffer::Allocator* IsolateData::allocator() const {
|
||||
return allocator_;
|
||||
}
|
||||
|
||||
inline ArrayBufferAllocator* IsolateData::node_allocator() const {
|
||||
return node_allocator_;
|
||||
}
|
||||
|
||||
inline MultiIsolatePlatform* IsolateData::platform() const {
|
||||
|
||||
+8
-5
@@ -74,11 +74,14 @@ void* const Environment::kNodeContextTagPtr = const_cast<void*>(
|
||||
IsolateData::IsolateData(Isolate* isolate,
|
||||
uv_loop_t* event_loop,
|
||||
MultiIsolatePlatform* platform,
|
||||
uint32_t* zero_fill_field) :
|
||||
isolate_(isolate),
|
||||
event_loop_(event_loop),
|
||||
zero_fill_field_(zero_fill_field),
|
||||
platform_(platform) {
|
||||
ArrayBufferAllocator* node_allocator)
|
||||
: isolate_(isolate),
|
||||
event_loop_(event_loop),
|
||||
allocator_(isolate->GetArrayBufferAllocator()),
|
||||
node_allocator_(node_allocator),
|
||||
uses_node_allocator_(allocator_ == node_allocator_),
|
||||
platform_(platform) {
|
||||
CHECK_NOT_NULL(allocator_);
|
||||
if (platform_ != nullptr)
|
||||
platform_->RegisterIsolate(isolate_, event_loop);
|
||||
|
||||
|
||||
@@ -392,16 +392,20 @@ class Environment;
|
||||
|
||||
class IsolateData {
|
||||
public:
|
||||
IsolateData(v8::Isolate* isolate, uv_loop_t* event_loop,
|
||||
IsolateData(v8::Isolate* isolate,
|
||||
uv_loop_t* event_loop,
|
||||
MultiIsolatePlatform* platform = nullptr,
|
||||
uint32_t* zero_fill_field = nullptr);
|
||||
ArrayBufferAllocator* node_allocator = nullptr);
|
||||
~IsolateData();
|
||||
inline uv_loop_t* event_loop() const;
|
||||
inline uint32_t* zero_fill_field() const;
|
||||
inline MultiIsolatePlatform* platform() const;
|
||||
inline std::shared_ptr<PerIsolateOptions> options();
|
||||
inline void set_options(std::shared_ptr<PerIsolateOptions> options);
|
||||
|
||||
inline bool uses_node_allocator() const;
|
||||
inline v8::ArrayBuffer::Allocator* allocator() const;
|
||||
inline ArrayBufferAllocator* node_allocator() const;
|
||||
|
||||
#define VP(PropertyName, StringValue) V(v8::Private, PropertyName)
|
||||
#define VY(PropertyName, StringValue) V(v8::Symbol, PropertyName)
|
||||
#define VS(PropertyName, StringValue) V(v8::String, PropertyName)
|
||||
@@ -434,7 +438,9 @@ class IsolateData {
|
||||
|
||||
v8::Isolate* const isolate_;
|
||||
uv_loop_t* const event_loop_;
|
||||
uint32_t* const zero_fill_field_;
|
||||
v8::ArrayBuffer::Allocator* const allocator_;
|
||||
ArrayBufferAllocator* const node_allocator_;
|
||||
const bool uses_node_allocator_;
|
||||
MultiIsolatePlatform* platform_;
|
||||
std::shared_ptr<PerIsolateOptions> options_;
|
||||
|
||||
|
||||
Reference in new issue
Block a user