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:
-rw-r--r--src/aliased_buffer.h58
-rw-r--r--src/env-inl.h24
-rw-r--r--src/env.h38
-rw-r--r--src/memory_tracker-inl.h2
-rw-r--r--src/memory_tracker.h2
-rw-r--r--src/node_file.cc4
-rw-r--r--src/node_file.h9
-rw-r--r--src/node_http2.cc30
-rw-r--r--src/node_http2_state.h16
-rw-r--r--src/node_perf.cc12
-rw-r--r--src/node_perf_common.h6
-rw-r--r--test/cctest/test_aliased_buffer.cc27
12 files changed, 105 insertions, 123 deletions
diff --git a/src/aliased_buffer.h b/src/aliased_buffer.h
index 498bab4d232..868d495be9e 100644
--- a/src/aliased_buffer.h
+++ b/src/aliased_buffer.h
@@ -3,12 +3,16 @@
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
-#include "v8.h"
+#include <cinttypes>
#include "util-inl.h"
+#include "v8.h"
namespace node {
/**
+ * Do not use this class directly when creating instances of it - use the
+ * Aliased*Array defined at the end of this file instead.
+ *
* This class encapsulates the technique of having a native buffer mapped to
* a JS object. Writes to the native buffer can happen efficiently without
* going through JS, and the data is then available to user's via the exposed
@@ -22,18 +26,16 @@ namespace node {
* The encapsulation herein provides a placeholder where such writes can be
* observed. Any notification APIs will be left as a future exercise.
*/
-template <class NativeT, class V8T,
+template <class NativeT,
+ class V8T,
// SFINAE NativeT to be scalar
typename = std::enable_if_t<std::is_scalar<NativeT>::value>>
-class AliasedBuffer {
+class AliasedBufferBase {
public:
- AliasedBuffer(v8::Isolate* isolate, const size_t count)
- : isolate_(isolate),
- count_(count),
- byte_offset_(0) {
+ AliasedBufferBase(v8::Isolate* isolate, const size_t count)
+ : isolate_(isolate), count_(count), byte_offset_(0) {
CHECK_GT(count, 0);
const v8::HandleScope handle_scope(isolate_);
-
const size_t size_in_bytes =
MultiplyWithOverflowCheck(sizeof(NativeT), count);
@@ -48,22 +50,20 @@ class AliasedBuffer {
}
/**
- * Create an AliasedBuffer over a sub-region of another aliased buffer.
+ * Create an AliasedBufferBase over a sub-region of another aliased buffer.
* The two will share a v8::ArrayBuffer instance &
* a native buffer, but will each read/write to different sections of the
* native buffer.
*
* Note that byte_offset must by aligned by sizeof(NativeT).
*/
- // TODO(refack): refactor into a non-owning `AliasedBufferView`
- AliasedBuffer(v8::Isolate* isolate,
- const size_t byte_offset,
- const size_t count,
- const AliasedBuffer<uint8_t,
- v8::Uint8Array>& backing_buffer)
- : isolate_(isolate),
- count_(count),
- byte_offset_(byte_offset) {
+ // TODO(refack): refactor into a non-owning `AliasedBufferBaseView`
+ AliasedBufferBase(
+ v8::Isolate* isolate,
+ const size_t byte_offset,
+ const size_t count,
+ const AliasedBufferBase<uint8_t, v8::Uint8Array>& backing_buffer)
+ : isolate_(isolate), count_(count), byte_offset_(byte_offset) {
const v8::HandleScope handle_scope(isolate_);
v8::Local<v8::ArrayBuffer> ab = backing_buffer.GetArrayBuffer();
@@ -81,7 +81,7 @@ class AliasedBuffer {
js_array_ = v8::Global<V8T>(isolate, js_array);
}
- AliasedBuffer(const AliasedBuffer& that)
+ AliasedBufferBase(const AliasedBufferBase& that)
: isolate_(that.isolate_),
count_(that.count_),
byte_offset_(that.byte_offset_),
@@ -89,8 +89,8 @@ class AliasedBuffer {
js_array_ = v8::Global<V8T>(that.isolate_, that.GetJSArray());
}
- AliasedBuffer& operator=(AliasedBuffer&& that) noexcept {
- this->~AliasedBuffer();
+ AliasedBufferBase& operator=(AliasedBufferBase&& that) noexcept {
+ this->~AliasedBufferBase();
isolate_ = that.isolate_;
count_ = that.count_;
byte_offset_ = that.byte_offset_;
@@ -109,10 +109,8 @@ class AliasedBuffer {
*/
class Reference {
public:
- Reference(AliasedBuffer<NativeT, V8T>* aliased_buffer, size_t index)
- : aliased_buffer_(aliased_buffer),
- index_(index) {
- }
+ Reference(AliasedBufferBase<NativeT, V8T>* aliased_buffer, size_t index)
+ : aliased_buffer_(aliased_buffer), index_(index) {}
Reference(const Reference& that)
: aliased_buffer_(that.aliased_buffer_),
@@ -149,7 +147,7 @@ class AliasedBuffer {
}
private:
- AliasedBuffer<NativeT, V8T>* aliased_buffer_;
+ AliasedBufferBase<NativeT, V8T>* aliased_buffer_;
size_t index_;
};
@@ -216,7 +214,7 @@ class AliasedBuffer {
// Should only be used to extend the array.
// Should only be used on an owning array, not one created as a sub array of
- // an owning `AliasedBuffer`.
+ // an owning `AliasedBufferBase`.
void reserve(size_t new_capacity) {
DCHECK_GE(new_capacity, count_);
DCHECK_EQ(byte_offset_, 0);
@@ -251,6 +249,12 @@ class AliasedBuffer {
NativeT* buffer_;
v8::Global<V8T> js_array_;
};
+
+typedef AliasedBufferBase<int32_t, v8::Int32Array> AliasedInt32Array;
+typedef AliasedBufferBase<uint8_t, v8::Uint8Array> AliasedUint8Array;
+typedef AliasedBufferBase<uint32_t, v8::Uint32Array> AliasedUint32Array;
+typedef AliasedBufferBase<double, v8::Float64Array> AliasedFloat64Array;
+typedef AliasedBufferBase<uint64_t, v8::BigUint64Array> AliasedBigUint64Array;
} // namespace node
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
diff --git a/src/env-inl.h b/src/env-inl.h
index ee0503620cd..36f8506bafb 100644
--- a/src/env-inl.h
+++ b/src/env-inl.h
@@ -109,16 +109,15 @@ inline AsyncHooks::AsyncHooks()
NODE_ASYNC_PROVIDER_TYPES(V)
#undef V
}
-
-inline AliasedBuffer<uint32_t, v8::Uint32Array>& AsyncHooks::fields() {
+inline AliasedUint32Array& AsyncHooks::fields() {
return fields_;
}
-inline AliasedBuffer<double, v8::Float64Array>& AsyncHooks::async_id_fields() {
+inline AliasedFloat64Array& AsyncHooks::async_id_fields() {
return async_id_fields_;
}
-inline AliasedBuffer<double, v8::Float64Array>& AsyncHooks::async_ids_stack() {
+inline AliasedFloat64Array& AsyncHooks::async_ids_stack() {
return async_ids_stack_;
}
@@ -243,8 +242,7 @@ inline void Environment::PopAsyncCallbackScope() {
inline ImmediateInfo::ImmediateInfo(v8::Isolate* isolate)
: fields_(isolate, kFieldsCount) {}
-inline AliasedBuffer<uint32_t, v8::Uint32Array>&
- ImmediateInfo::fields() {
+inline AliasedUint32Array& ImmediateInfo::fields() {
return fields_;
}
@@ -279,7 +277,7 @@ inline void ImmediateInfo::ref_count_dec(uint32_t decrement) {
inline TickInfo::TickInfo(v8::Isolate* isolate)
: fields_(isolate, kFieldsCount) {}
-inline AliasedBuffer<uint8_t, v8::Uint8Array>& TickInfo::fields() {
+inline AliasedUint8Array& TickInfo::fields() {
return fields_;
}
@@ -486,13 +484,11 @@ inline void Environment::set_abort_on_uncaught_exception(bool value) {
options_->abort_on_uncaught_exception = value;
}
-inline AliasedBuffer<uint32_t, v8::Uint32Array>&
-Environment::should_abort_on_uncaught_toggle() {
+inline AliasedUint32Array& Environment::should_abort_on_uncaught_toggle() {
return should_abort_on_uncaught_toggle_;
}
-inline AliasedBuffer<int32_t, v8::Int32Array>&
-Environment::stream_base_state() {
+inline AliasedInt32Array& Environment::stream_base_state() {
return stream_base_state_;
}
@@ -622,13 +618,11 @@ void Environment::set_debug_enabled(DebugCategory category, bool enabled) {
debug_enabled_[static_cast<int>(category)] = enabled;
}
-inline AliasedBuffer<double, v8::Float64Array>*
-Environment::fs_stats_field_array() {
+inline AliasedFloat64Array* Environment::fs_stats_field_array() {
return &fs_stats_field_array_;
}
-inline AliasedBuffer<uint64_t, v8::BigUint64Array>*
-Environment::fs_stats_field_bigint_array() {
+inline AliasedBigUint64Array* Environment::fs_stats_field_bigint_array() {
return &fs_stats_field_bigint_array_;
}
diff --git a/src/env.h b/src/env.h
index 9e6892d1825..d4991535186 100644
--- a/src/env.h
+++ b/src/env.h
@@ -611,9 +611,9 @@ class AsyncHooks : public MemoryRetainer {
kUidFieldsCount,
};
- inline AliasedBuffer<uint32_t, v8::Uint32Array>& fields();
- inline AliasedBuffer<double, v8::Float64Array>& async_id_fields();
- inline AliasedBuffer<double, v8::Float64Array>& async_ids_stack();
+ inline AliasedUint32Array& fields();
+ inline AliasedFloat64Array& async_id_fields();
+ inline AliasedFloat64Array& async_ids_stack();
inline v8::Local<v8::String> provider_string(int idx);
@@ -652,12 +652,12 @@ class AsyncHooks : public MemoryRetainer {
// Keep a list of all Persistent strings used for Provider types.
std::array<v8::Eternal<v8::String>, AsyncWrap::PROVIDERS_LENGTH> providers_;
// Stores the ids of the current execution context stack.
- AliasedBuffer<double, v8::Float64Array> async_ids_stack_;
+ AliasedFloat64Array async_ids_stack_;
// Attached to a Uint32Array that tracks the number of active hooks for
// each type.
- AliasedBuffer<uint32_t, v8::Uint32Array> fields_;
+ AliasedUint32Array fields_;
// Attached to a Float64Array that tracks the state of async resources.
- AliasedBuffer<double, v8::Float64Array> async_id_fields_;
+ AliasedFloat64Array async_id_fields_;
void grow_async_ids_stack();
};
@@ -676,7 +676,7 @@ class AsyncCallbackScope {
class ImmediateInfo : public MemoryRetainer {
public:
- inline AliasedBuffer<uint32_t, v8::Uint32Array>& fields();
+ inline AliasedUint32Array& fields();
inline uint32_t count() const;
inline uint32_t ref_count() const;
inline bool has_outstanding() const;
@@ -698,12 +698,12 @@ class ImmediateInfo : public MemoryRetainer {
enum Fields { kCount, kRefCount, kHasOutstanding, kFieldsCount };
- AliasedBuffer<uint32_t, v8::Uint32Array> fields_;
+ AliasedUint32Array fields_;
};
class TickInfo : public MemoryRetainer {
public:
- inline AliasedBuffer<uint8_t, v8::Uint8Array>& fields();
+ inline AliasedUint8Array& fields();
inline bool has_tick_scheduled() const;
inline bool has_rejection_to_warn() const;
@@ -720,7 +720,7 @@ class TickInfo : public MemoryRetainer {
enum Fields { kHasTickScheduled = 0, kHasRejectionToWarn, kFieldsCount };
- AliasedBuffer<uint8_t, v8::Uint8Array> fields_;
+ AliasedUint8Array fields_;
};
class TrackingTraceStateObserver :
@@ -908,10 +908,9 @@ class Environment : public MemoryRetainer {
// This is a pseudo-boolean that keeps track of whether an uncaught exception
// should abort the process or not if --abort-on-uncaught-exception was
// passed to Node. If the flag was not passed, it is ignored.
- inline AliasedBuffer<uint32_t, v8::Uint32Array>&
- should_abort_on_uncaught_toggle();
+ inline AliasedUint32Array& should_abort_on_uncaught_toggle();
- inline AliasedBuffer<int32_t, v8::Int32Array>& stream_base_state();
+ inline AliasedInt32Array& stream_base_state();
// The necessary API for async_hooks.
inline double new_async_id();
@@ -957,9 +956,8 @@ class Environment : public MemoryRetainer {
inline void set_debug_enabled(DebugCategory category, bool enabled);
void set_debug_categories(const std::string& cats, bool enabled);
- inline AliasedBuffer<double, v8::Float64Array>* fs_stats_field_array();
- inline AliasedBuffer<uint64_t, v8::BigUint64Array>*
- fs_stats_field_bigint_array();
+ inline AliasedFloat64Array* fs_stats_field_array();
+ inline AliasedBigUint64Array* fs_stats_field_bigint_array();
inline std::vector<std::unique_ptr<fs::FileHandleReadWrap>>&
file_handle_read_wrap_freelist();
@@ -1204,12 +1202,12 @@ class Environment : public MemoryRetainer {
uint32_t script_id_counter_ = 0;
uint32_t function_id_counter_ = 0;
- AliasedBuffer<uint32_t, v8::Uint32Array> should_abort_on_uncaught_toggle_;
+ AliasedUint32Array should_abort_on_uncaught_toggle_;
int should_not_abort_scope_counter_ = 0;
std::unique_ptr<TrackingTraceStateObserver> trace_state_observer_;
- AliasedBuffer<int32_t, v8::Int32Array> stream_base_state_;
+ AliasedInt32Array stream_base_state_;
std::unique_ptr<performance::performance_state> performance_state_;
std::unordered_map<std::string, uint64_t> performance_marks_;
@@ -1252,8 +1250,8 @@ class Environment : public MemoryRetainer {
bool debug_enabled_[static_cast<int>(DebugCategory::CATEGORY_COUNT)] = {0};
- AliasedBuffer<double, v8::Float64Array> fs_stats_field_array_;
- AliasedBuffer<uint64_t, v8::BigUint64Array> fs_stats_field_bigint_array_;
+ AliasedFloat64Array fs_stats_field_array_;
+ AliasedBigUint64Array fs_stats_field_bigint_array_;
std::vector<std::unique_ptr<fs::FileHandleReadWrap>>
file_handle_read_wrap_freelist_;
diff --git a/src/memory_tracker-inl.h b/src/memory_tracker-inl.h
index 72117d2f6a0..b17b8fbab2c 100644
--- a/src/memory_tracker-inl.h
+++ b/src/memory_tracker-inl.h
@@ -226,7 +226,7 @@ void MemoryTracker::TrackField(const char* name,
template <class NativeT, class V8T>
void MemoryTracker::TrackField(const char* name,
- const AliasedBuffer<NativeT, V8T>& value,
+ const AliasedBufferBase<NativeT, V8T>& value,
const char* node_name) {
TrackField(name, value.GetJSArray(), "AliasedBuffer");
}
diff --git a/src/memory_tracker.h b/src/memory_tracker.h
index 6a5ab155117..032c9a984e5 100644
--- a/src/memory_tracker.h
+++ b/src/memory_tracker.h
@@ -215,7 +215,7 @@ class MemoryTracker {
const char* node_name = nullptr);
template <class NativeT, class V8T>
inline void TrackField(const char* edge_name,
- const AliasedBuffer<NativeT, V8T>& value,
+ const AliasedBufferBase<NativeT, V8T>& value,
const char* node_name = nullptr);
// Put a memory container into the graph, create an edge from
diff --git a/src/node_file.cc b/src/node_file.cc
index acdf01a5fea..85691a4ed12 100644
--- a/src/node_file.cc
+++ b/src/node_file.cc
@@ -756,9 +756,9 @@ inline FSReqBase* GetReqWrap(Environment* env, Local<Value> value,
return Unwrap<FSReqBase>(value.As<Object>());
} else if (value->StrictEquals(env->fs_use_promises_symbol())) {
if (use_bigint) {
- return FSReqPromise<uint64_t, BigUint64Array>::New(env, use_bigint);
+ return FSReqPromise<AliasedBigUint64Array>::New(env, use_bigint);
} else {
- return FSReqPromise<double, Float64Array>::New(env, use_bigint);
+ return FSReqPromise<AliasedFloat64Array>::New(env, use_bigint);
}
}
return nullptr;
diff --git a/src/node_file.h b/src/node_file.h
index 2c87f5e44d0..f5c523fb070 100644
--- a/src/node_file.h
+++ b/src/node_file.h
@@ -192,8 +192,9 @@ constexpr uint64_t ToNative(uv_timespec_t ts) {
#undef constexpr // end N3652 bug workaround
template <typename NativeT, typename V8T>
-constexpr void FillStatsArray(AliasedBuffer<NativeT, V8T>* fields,
- const uv_stat_t* s, const size_t offset = 0) {
+constexpr void FillStatsArray(AliasedBufferBase<NativeT, V8T>* fields,
+ const uv_stat_t* s,
+ const size_t offset = 0) {
fields->SetValue(offset + 0, static_cast<NativeT>(s->st_dev));
fields->SetValue(offset + 1, static_cast<NativeT>(s->st_mode));
fields->SetValue(offset + 2, static_cast<NativeT>(s->st_nlink));
@@ -227,7 +228,7 @@ inline Local<Value> FillGlobalStatsArray(Environment* env,
}
}
-template <typename NativeT = double, typename V8T = v8::Float64Array>
+template <typename AliasedBufferT>
class FSReqPromise : public FSReqBase {
public:
static FSReqPromise* New(Environment* env, bool use_bigint) {
@@ -304,7 +305,7 @@ class FSReqPromise : public FSReqBase {
stats_field_array_(env->isolate(), kFsStatsFieldsNumber) {}
bool finished_ = false;
- AliasedBuffer<NativeT, V8T> stats_field_array_;
+ AliasedBufferT stats_field_array_;
};
class FSReqAfterScope {
diff --git a/src/node_http2.cc b/src/node_http2.cc
index 17c87cd7273..55cee019b08 100644
--- a/src/node_http2.cc
+++ b/src/node_http2.cc
@@ -119,8 +119,7 @@ Http2Options::Http2Options(Environment* env, nghttp2_session_type type) {
nghttp2_option_set_builtin_recv_extension_type(options_, NGHTTP2_ORIGIN);
}
- AliasedBuffer<uint32_t, Uint32Array>& buffer =
- env->http2_state()->options_buffer;
+ AliasedUint32Array& buffer = env->http2_state()->options_buffer;
uint32_t flags = buffer[IDX_OPTIONS_FLAGS];
if (flags & (1 << IDX_OPTIONS_MAX_DEFLATE_DYNAMIC_TABLE_SIZE)) {
@@ -200,8 +199,7 @@ Http2Options::Http2Options(Environment* env, nghttp2_session_type type) {
}
void Http2Session::Http2Settings::Init() {
- AliasedBuffer<uint32_t, Uint32Array>& buffer =
- env()->http2_state()->settings_buffer;
+ AliasedUint32Array& buffer = env()->http2_state()->settings_buffer;
uint32_t flags = buffer[IDX_SETTINGS_COUNT];
size_t n = 0;
@@ -262,8 +260,7 @@ Local<Value> Http2Session::Http2Settings::Pack() {
void Http2Session::Http2Settings::Update(Environment* env,
Http2Session* session,
get_setting fn) {
- AliasedBuffer<uint32_t, Uint32Array>& buffer =
- env->http2_state()->settings_buffer;
+ AliasedUint32Array& buffer = env->http2_state()->settings_buffer;
buffer[IDX_SETTINGS_HEADER_TABLE_SIZE] =
fn(**session, NGHTTP2_SETTINGS_HEADER_TABLE_SIZE);
buffer[IDX_SETTINGS_MAX_CONCURRENT_STREAMS] =
@@ -282,8 +279,7 @@ void Http2Session::Http2Settings::Update(Environment* env,
// Initializes the shared TypedArray with the default settings values.
void Http2Session::Http2Settings::RefreshDefaults(Environment* env) {
- AliasedBuffer<uint32_t, Uint32Array>& buffer =
- env->http2_state()->settings_buffer;
+ AliasedUint32Array& buffer = env->http2_state()->settings_buffer;
buffer[IDX_SETTINGS_HEADER_TABLE_SIZE] =
DEFAULT_SETTINGS_HEADER_TABLE_SIZE;
@@ -648,8 +644,7 @@ std::string Http2Session::diagnostic_name() const {
}
inline bool HasHttp2Observer(Environment* env) {
- AliasedBuffer<uint32_t, Uint32Array>& observers =
- env->performance_state()->observers;
+ AliasedUint32Array& observers = env->performance_state()->observers;
return observers[performance::NODE_PERFORMANCE_ENTRY_TYPE_HTTP2] != 0;
}
@@ -665,8 +660,7 @@ void Http2Stream::EmitStatistics() {
if (!HasHttp2Observer(env))
return;
HandleScope handle_scope(env->isolate());
- AliasedBuffer<double, Float64Array>& buffer =
- env->http2_state()->stream_stats_buffer;
+ AliasedFloat64Array& buffer = env->http2_state()->stream_stats_buffer;
buffer[IDX_STREAM_STATS_ID] = entry->id();
if (entry->first_byte() != 0) {
buffer[IDX_STREAM_STATS_TIMETOFIRSTBYTE] =
@@ -705,8 +699,7 @@ void Http2Session::EmitStatistics() {
if (!HasHttp2Observer(env))
return;
HandleScope handle_scope(env->isolate());
- AliasedBuffer<double, Float64Array>& buffer =
- env->http2_state()->session_stats_buffer;
+ AliasedFloat64Array& buffer = env->http2_state()->session_stats_buffer;
buffer[IDX_SESSION_STATS_TYPE] = entry->type();
buffer[IDX_SESSION_STATS_PINGRTT] = entry->ping_rtt() / 1e6;
buffer[IDX_SESSION_STATS_FRAMESRECEIVED] = entry->frame_count();
@@ -839,8 +832,7 @@ ssize_t Http2Session::OnCallbackPadding(size_t frameLen,
Local<Context> context = env()->context();
Context::Scope context_scope(context);
- AliasedBuffer<uint32_t, Uint32Array>& buffer =
- env()->http2_state()->padding_buffer;
+ AliasedUint32Array& buffer = env()->http2_state()->padding_buffer;
buffer[PADDING_BUF_FRAME_LENGTH] = frameLen;
buffer[PADDING_BUF_MAX_PAYLOAD_LENGTH] = maxPayloadLen;
buffer[PADDING_BUF_RETURN_VALUE] = frameLen;
@@ -2387,8 +2379,7 @@ void Http2Session::RefreshState(const FunctionCallbackInfo<Value>& args) {
ASSIGN_OR_RETURN_UNWRAP(&session, args.Holder());
Debug(session, "refreshing state");
- AliasedBuffer<double, Float64Array>& buffer =
- env->http2_state()->session_state_buffer;
+ AliasedFloat64Array& buffer = env->http2_state()->session_state_buffer;
nghttp2_session* s = **session;
@@ -2670,8 +2661,7 @@ void Http2Stream::RefreshState(const FunctionCallbackInfo<Value>& args) {
Debug(stream, "refreshing state");
- AliasedBuffer<double, Float64Array>& buffer =
- env->http2_state()->stream_state_buffer;
+ AliasedFloat64Array& buffer = env->http2_state()->stream_state_buffer;
nghttp2_stream* str = **stream;
nghttp2_session* s = **(stream->session());
diff --git a/src/node_http2_state.h b/src/node_http2_state.h
index d21d0f90096..692299a187f 100644
--- a/src/node_http2_state.h
+++ b/src/node_http2_state.h
@@ -128,14 +128,14 @@ class Http2State {
root_buffer) {
}
- AliasedBuffer<uint8_t, v8::Uint8Array> root_buffer;
- AliasedBuffer<double, v8::Float64Array> session_state_buffer;
- AliasedBuffer<double, v8::Float64Array> stream_state_buffer;
- AliasedBuffer<double, v8::Float64Array> stream_stats_buffer;
- AliasedBuffer<double, v8::Float64Array> session_stats_buffer;
- AliasedBuffer<uint32_t, v8::Uint32Array> padding_buffer;
- AliasedBuffer<uint32_t, v8::Uint32Array> options_buffer;
- AliasedBuffer<uint32_t, v8::Uint32Array> settings_buffer;
+ AliasedUint8Array root_buffer;
+ AliasedFloat64Array session_state_buffer;
+ AliasedFloat64Array stream_state_buffer;
+ AliasedFloat64Array stream_stats_buffer;
+ AliasedFloat64Array session_stats_buffer;
+ AliasedUint32Array padding_buffer;
+ AliasedUint32Array options_buffer;
+ AliasedUint32Array settings_buffer;
private:
struct http2_state_internal {
diff --git a/src/node_perf.cc b/src/node_perf.cc
index b9e1c0cb9ca..8f982049c77 100644
--- a/src/node_perf.cc
+++ b/src/node_perf.cc
@@ -114,8 +114,7 @@ void PerformanceEntry::Notify(Environment* env,
PerformanceEntryType type,
Local<Value> object) {
Context::Scope scope(env->context());
- AliasedBuffer<uint32_t, Uint32Array>& observers =
- env->performance_state()->observers;
+ AliasedUint32Array& observers = env->performance_state()->observers;
if (type != NODE_PERFORMANCE_ENTRY_TYPE_INVALID &&
observers[type]) {
node::MakeCallback(env->isolate(),
@@ -173,8 +172,7 @@ void Measure(const FunctionCallbackInfo<Value>& args) {
Utf8Value startMark(env->isolate(), args[1]);
Utf8Value endMark(env->isolate(), args[2]);
- AliasedBuffer<double, v8::Float64Array>& milestones =
- env->performance_state()->milestones;
+ AliasedFloat64Array& milestones = env->performance_state()->milestones;
uint64_t startTimestamp = timeOrigin;
uint64_t start = GetPerformanceMark(env, *startMark);
@@ -235,8 +233,7 @@ void PerformanceGCCallback(Environment* env, void* ptr) {
HandleScope scope(env->isolate());
Local<Context> context = env->context();
- AliasedBuffer<uint32_t, Uint32Array>& observers =
- env->performance_state()->observers;
+ AliasedUint32Array& observers = env->performance_state()->observers;
if (observers[NODE_PERFORMANCE_ENTRY_TYPE_GC]) {
Local<Object> obj;
if (!entry->ToObject().ToLocal(&obj)) return;
@@ -342,8 +339,7 @@ void TimerFunctionCall(const FunctionCallbackInfo<Value>& args) {
return;
args.GetReturnValue().Set(ret.ToLocalChecked());
- AliasedBuffer<uint32_t, Uint32Array>& observers =
- env->performance_state()->observers;
+ AliasedUint32Array& observers = env->performance_state()->observers;
if (!observers[NODE_PERFORMANCE_ENTRY_TYPE_FUNCTION])
return;
diff --git a/src/node_perf_common.h b/src/node_perf_common.h
index 5c972c9841a..3d546193df2 100644
--- a/src/node_perf_common.h
+++ b/src/node_perf_common.h
@@ -71,9 +71,9 @@ class performance_state {
milestones[i] = -1.;
}
- AliasedBuffer<uint8_t, v8::Uint8Array> root;
- AliasedBuffer<double, v8::Float64Array> milestones;
- AliasedBuffer<uint32_t, v8::Uint32Array> observers;
+ AliasedUint8Array root;
+ AliasedFloat64Array milestones;
+ AliasedUint32Array observers;
uint64_t performance_last_gc_start_mark = 0;
diff --git a/test/cctest/test_aliased_buffer.cc b/test/cctest/test_aliased_buffer.cc
index bfbf7294db6..5421dd6d145 100644
--- a/test/cctest/test_aliased_buffer.cc
+++ b/test/cctest/test_aliased_buffer.cc
@@ -3,7 +3,7 @@
#include "aliased_buffer.h"
#include "node_test_fixture.h"
-using node::AliasedBuffer;
+using node::AliasedBufferBase;
class AliasBufferTest : public NodeTestFixture {};
@@ -15,7 +15,7 @@ void CreateOracleValues(std::vector<NativeT>* buf) {
}
template <class NativeT, class V8T>
-void WriteViaOperator(AliasedBuffer<NativeT, V8T>* aliasedBuffer,
+void WriteViaOperator(AliasedBufferBase<NativeT, V8T>* aliasedBuffer,
const std::vector<NativeT>& oracle) {
// write through the API
for (size_t i = 0; i < oracle.size(); i++) {
@@ -24,7 +24,7 @@ void WriteViaOperator(AliasedBuffer<NativeT, V8T>* aliasedBuffer,
}
template <class NativeT, class V8T>
-void WriteViaSetValue(AliasedBuffer<NativeT, V8T>* aliasedBuffer,
+void WriteViaSetValue(AliasedBufferBase<NativeT, V8T>* aliasedBuffer,
const std::vector<NativeT>& oracle) {
// write through the API
for (size_t i = 0; i < oracle.size(); i++) {
@@ -35,7 +35,7 @@ void WriteViaSetValue(AliasedBuffer<NativeT, V8T>* aliasedBuffer,
template <class NativeT, class V8T>
void ReadAndValidate(v8::Isolate* isolate,
v8::Local<v8::Context> context,
- AliasedBuffer<NativeT, V8T>* aliasedBuffer,
+ AliasedBufferBase<NativeT, V8T>* aliasedBuffer,
const std::vector<NativeT>& oracle) {
// read through the API
for (size_t i = 0; i < oracle.size(); i++) {
@@ -76,7 +76,7 @@ void ReadWriteTest(v8::Isolate* isolate) {
v8::Context::Scope context_scope(context);
const size_t size = 100;
- AliasedBuffer<NativeT, V8T> ab(isolate, size);
+ AliasedBufferBase<NativeT, V8T> ab(isolate, size);
std::vector<NativeT> oracle(size);
CreateOracleValues(&oracle);
WriteViaOperator(&ab, oracle);
@@ -86,7 +86,7 @@ void ReadWriteTest(v8::Isolate* isolate) {
// validate copy constructor
{
- AliasedBuffer<NativeT, V8T> ab2(ab);
+ AliasedBufferBase<NativeT, V8T> ab2(ab);
ReadAndValidate(isolate, context, &ab2, oracle);
}
ReadAndValidate(isolate, context, &ab, oracle);
@@ -110,13 +110,12 @@ void SharedBufferTest(
size_t sizeInBytes_B = count_B * sizeof(NativeT_B);
size_t sizeInBytes_C = count_C * sizeof(NativeT_C);
- AliasedBuffer<uint8_t, v8::Uint8Array> rootBuffer(
+ AliasedBufferBase<uint8_t, v8::Uint8Array> rootBuffer(
isolate, sizeInBytes_A + sizeInBytes_B + sizeInBytes_C);
- AliasedBuffer<NativeT_A, V8T_A> ab_A(
- isolate, 0, count_A, rootBuffer);
- AliasedBuffer<NativeT_B, V8T_B> ab_B(
+ AliasedBufferBase<NativeT_A, V8T_A> ab_A(isolate, 0, count_A, rootBuffer);
+ AliasedBufferBase<NativeT_B, V8T_B> ab_B(
isolate, sizeInBytes_A, count_B, rootBuffer);
- AliasedBuffer<NativeT_C, V8T_C> ab_C(
+ AliasedBufferBase<NativeT_C, V8T_C> ab_C(
isolate, sizeInBytes_A + sizeInBytes_B, count_C, rootBuffer);
std::vector<NativeT_A> oracle_A(count_A);
@@ -209,7 +208,7 @@ TEST_F(AliasBufferTest, OperatorOverloads) {
v8::Local<v8::Context> context = v8::Context::New(isolate_);
v8::Context::Scope context_scope(context);
const size_t size = 10;
- AliasedBuffer<uint32_t, v8::Uint32Array> ab{isolate_, size};
+ AliasedBufferBase<uint32_t, v8::Uint32Array> ab{isolate_, size};
EXPECT_EQ(static_cast<uint32_t>(1), ab[0] = 1);
EXPECT_EQ(static_cast<uint32_t>(4), ab[0] += 3);
@@ -222,8 +221,8 @@ TEST_F(AliasBufferTest, OperatorOverloadsRefs) {
v8::HandleScope handle_scope(isolate_);
v8::Local<v8::Context> context = v8::Context::New(isolate_);
v8::Context::Scope context_scope(context);
- AliasedBuffer<uint32_t, v8::Uint32Array> ab{isolate_, 2};
- using Reference = AliasedBuffer<uint32_t, v8::Uint32Array>::Reference;
+ AliasedBufferBase<uint32_t, v8::Uint32Array> ab{isolate_, 2};
+ using Reference = AliasedBufferBase<uint32_t, v8::Uint32Array>::Reference;
Reference ref = ab[0];
Reference ref_value = ab[1] = 2;