diff --git a/src/aliased_buffer.h b/src/aliased_buffer.h index 498bab4d2323a3..868d495be9e04c 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 #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 ::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& 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& backing_buffer) + : isolate_(isolate), count_(count), byte_offset_(byte_offset) { const v8::HandleScope handle_scope(isolate_); v8::Local ab = backing_buffer.GetArrayBuffer(); @@ -81,7 +81,7 @@ class AliasedBuffer { js_array_ = v8::Global(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(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* aliased_buffer, size_t index) - : aliased_buffer_(aliased_buffer), - index_(index) { - } + Reference(AliasedBufferBase* 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* aliased_buffer_; + AliasedBufferBase* 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 js_array_; }; + +typedef AliasedBufferBase AliasedInt32Array; +typedef AliasedBufferBase AliasedUint8Array; +typedef AliasedBufferBase AliasedUint32Array; +typedef AliasedBufferBase AliasedFloat64Array; +typedef AliasedBufferBase AliasedBigUint64Array; } // namespace node #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS diff --git a/src/env-inl.h b/src/env-inl.h index ee0503620cd66d..36f8506bafb5a7 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& AsyncHooks::fields() { +inline AliasedUint32Array& AsyncHooks::fields() { return fields_; } -inline AliasedBuffer& AsyncHooks::async_id_fields() { +inline AliasedFloat64Array& AsyncHooks::async_id_fields() { return async_id_fields_; } -inline AliasedBuffer& 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& - 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& 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& -Environment::should_abort_on_uncaught_toggle() { +inline AliasedUint32Array& Environment::should_abort_on_uncaught_toggle() { return should_abort_on_uncaught_toggle_; } -inline AliasedBuffer& -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(category)] = enabled; } -inline AliasedBuffer* -Environment::fs_stats_field_array() { +inline AliasedFloat64Array* Environment::fs_stats_field_array() { return &fs_stats_field_array_; } -inline AliasedBuffer* -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 9e6892d18259ce..d4991535186d51 100644 --- a/src/env.h +++ b/src/env.h @@ -611,9 +611,9 @@ class AsyncHooks : public MemoryRetainer { kUidFieldsCount, }; - inline AliasedBuffer& fields(); - inline AliasedBuffer& async_id_fields(); - inline AliasedBuffer& async_ids_stack(); + inline AliasedUint32Array& fields(); + inline AliasedFloat64Array& async_id_fields(); + inline AliasedFloat64Array& async_ids_stack(); inline v8::Local 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, AsyncWrap::PROVIDERS_LENGTH> providers_; // Stores the ids of the current execution context stack. - AliasedBuffer async_ids_stack_; + AliasedFloat64Array async_ids_stack_; // Attached to a Uint32Array that tracks the number of active hooks for // each type. - AliasedBuffer fields_; + AliasedUint32Array fields_; // Attached to a Float64Array that tracks the state of async resources. - AliasedBuffer 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& 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 fields_; + AliasedUint32Array fields_; }; class TickInfo : public MemoryRetainer { public: - inline AliasedBuffer& 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 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& - should_abort_on_uncaught_toggle(); + inline AliasedUint32Array& should_abort_on_uncaught_toggle(); - inline AliasedBuffer& 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* fs_stats_field_array(); - inline AliasedBuffer* - fs_stats_field_bigint_array(); + inline AliasedFloat64Array* fs_stats_field_array(); + inline AliasedBigUint64Array* fs_stats_field_bigint_array(); inline std::vector>& 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 should_abort_on_uncaught_toggle_; + AliasedUint32Array should_abort_on_uncaught_toggle_; int should_not_abort_scope_counter_ = 0; std::unique_ptr trace_state_observer_; - AliasedBuffer stream_base_state_; + AliasedInt32Array stream_base_state_; std::unique_ptr performance_state_; std::unordered_map performance_marks_; @@ -1252,8 +1250,8 @@ class Environment : public MemoryRetainer { bool debug_enabled_[static_cast(DebugCategory::CATEGORY_COUNT)] = {0}; - AliasedBuffer fs_stats_field_array_; - AliasedBuffer fs_stats_field_bigint_array_; + AliasedFloat64Array fs_stats_field_array_; + AliasedBigUint64Array fs_stats_field_bigint_array_; std::vector> file_handle_read_wrap_freelist_; diff --git a/src/memory_tracker-inl.h b/src/memory_tracker-inl.h index 72117d2f6a0c30..b17b8fbab2cada 100644 --- a/src/memory_tracker-inl.h +++ b/src/memory_tracker-inl.h @@ -226,7 +226,7 @@ void MemoryTracker::TrackField(const char* name, template void MemoryTracker::TrackField(const char* name, - const AliasedBuffer& value, + const AliasedBufferBase& value, const char* node_name) { TrackField(name, value.GetJSArray(), "AliasedBuffer"); } diff --git a/src/memory_tracker.h b/src/memory_tracker.h index 6a5ab155117297..032c9a984e51d6 100644 --- a/src/memory_tracker.h +++ b/src/memory_tracker.h @@ -215,7 +215,7 @@ class MemoryTracker { const char* node_name = nullptr); template inline void TrackField(const char* edge_name, - const AliasedBuffer& value, + const AliasedBufferBase& 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 acdf01a5fea5a7..85691a4ed12258 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -756,9 +756,9 @@ inline FSReqBase* GetReqWrap(Environment* env, Local value, return Unwrap(value.As()); } else if (value->StrictEquals(env->fs_use_promises_symbol())) { if (use_bigint) { - return FSReqPromise::New(env, use_bigint); + return FSReqPromise::New(env, use_bigint); } else { - return FSReqPromise::New(env, use_bigint); + return FSReqPromise::New(env, use_bigint); } } return nullptr; diff --git a/src/node_file.h b/src/node_file.h index 2c87f5e44d0d90..f5c523fb0708cc 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 -constexpr void FillStatsArray(AliasedBuffer* fields, - const uv_stat_t* s, const size_t offset = 0) { +constexpr void FillStatsArray(AliasedBufferBase* fields, + const uv_stat_t* s, + const size_t offset = 0) { fields->SetValue(offset + 0, static_cast(s->st_dev)); fields->SetValue(offset + 1, static_cast(s->st_mode)); fields->SetValue(offset + 2, static_cast(s->st_nlink)); @@ -227,7 +228,7 @@ inline Local FillGlobalStatsArray(Environment* env, } } -template +template 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 stats_field_array_; + AliasedBufferT stats_field_array_; }; class FSReqAfterScope { diff --git a/src/node_http2.cc b/src/node_http2.cc index 17c87cd7273f48..55cee019b0898b 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& 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& 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 Http2Session::Http2Settings::Pack() { void Http2Session::Http2Settings::Update(Environment* env, Http2Session* session, get_setting fn) { - AliasedBuffer& 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& 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& 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& 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& 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 = env()->context(); Context::Scope context_scope(context); - AliasedBuffer& 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& args) { ASSIGN_OR_RETURN_UNWRAP(&session, args.Holder()); Debug(session, "refreshing state"); - AliasedBuffer& 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& args) { Debug(stream, "refreshing state"); - AliasedBuffer& 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 d21d0f90096074..692299a187f60a 100644 --- a/src/node_http2_state.h +++ b/src/node_http2_state.h @@ -128,14 +128,14 @@ class Http2State { root_buffer) { } - AliasedBuffer root_buffer; - AliasedBuffer session_state_buffer; - AliasedBuffer stream_state_buffer; - AliasedBuffer stream_stats_buffer; - AliasedBuffer session_stats_buffer; - AliasedBuffer padding_buffer; - AliasedBuffer options_buffer; - AliasedBuffer 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 b9e1c0cb9ca487..8f982049c77d7e 100644 --- a/src/node_perf.cc +++ b/src/node_perf.cc @@ -114,8 +114,7 @@ void PerformanceEntry::Notify(Environment* env, PerformanceEntryType type, Local object) { Context::Scope scope(env->context()); - AliasedBuffer& 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& args) { Utf8Value startMark(env->isolate(), args[1]); Utf8Value endMark(env->isolate(), args[2]); - AliasedBuffer& 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 = env->context(); - AliasedBuffer& observers = - env->performance_state()->observers; + AliasedUint32Array& observers = env->performance_state()->observers; if (observers[NODE_PERFORMANCE_ENTRY_TYPE_GC]) { Local obj; if (!entry->ToObject().ToLocal(&obj)) return; @@ -342,8 +339,7 @@ void TimerFunctionCall(const FunctionCallbackInfo& args) { return; args.GetReturnValue().Set(ret.ToLocalChecked()); - AliasedBuffer& 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 5c972c9841ad50..3d546193df2b52 100644 --- a/src/node_perf_common.h +++ b/src/node_perf_common.h @@ -71,9 +71,9 @@ class performance_state { milestones[i] = -1.; } - AliasedBuffer root; - AliasedBuffer milestones; - AliasedBuffer 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 bfbf7294db612b..5421dd6d14582e 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* buf) { } template -void WriteViaOperator(AliasedBuffer* aliasedBuffer, +void WriteViaOperator(AliasedBufferBase* aliasedBuffer, const std::vector& oracle) { // write through the API for (size_t i = 0; i < oracle.size(); i++) { @@ -24,7 +24,7 @@ void WriteViaOperator(AliasedBuffer* aliasedBuffer, } template -void WriteViaSetValue(AliasedBuffer* aliasedBuffer, +void WriteViaSetValue(AliasedBufferBase* aliasedBuffer, const std::vector& oracle) { // write through the API for (size_t i = 0; i < oracle.size(); i++) { @@ -35,7 +35,7 @@ void WriteViaSetValue(AliasedBuffer* aliasedBuffer, template void ReadAndValidate(v8::Isolate* isolate, v8::Local context, - AliasedBuffer* aliasedBuffer, + AliasedBufferBase* aliasedBuffer, const std::vector& 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 ab(isolate, size); + AliasedBufferBase ab(isolate, size); std::vector oracle(size); CreateOracleValues(&oracle); WriteViaOperator(&ab, oracle); @@ -86,7 +86,7 @@ void ReadWriteTest(v8::Isolate* isolate) { // validate copy constructor { - AliasedBuffer ab2(ab); + AliasedBufferBase 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 rootBuffer( + AliasedBufferBase rootBuffer( isolate, sizeInBytes_A + sizeInBytes_B + sizeInBytes_C); - AliasedBuffer ab_A( - isolate, 0, count_A, rootBuffer); - AliasedBuffer ab_B( + AliasedBufferBase ab_A(isolate, 0, count_A, rootBuffer); + AliasedBufferBase ab_B( isolate, sizeInBytes_A, count_B, rootBuffer); - AliasedBuffer ab_C( + AliasedBufferBase ab_C( isolate, sizeInBytes_A + sizeInBytes_B, count_C, rootBuffer); std::vector oracle_A(count_A); @@ -209,7 +208,7 @@ TEST_F(AliasBufferTest, OperatorOverloads) { v8::Local context = v8::Context::New(isolate_); v8::Context::Scope context_scope(context); const size_t size = 10; - AliasedBuffer ab{isolate_, size}; + AliasedBufferBase ab{isolate_, size}; EXPECT_EQ(static_cast(1), ab[0] = 1); EXPECT_EQ(static_cast(4), ab[0] += 3); @@ -222,8 +221,8 @@ TEST_F(AliasBufferTest, OperatorOverloadsRefs) { v8::HandleScope handle_scope(isolate_); v8::Local context = v8::Context::New(isolate_); v8::Context::Scope context_scope(context); - AliasedBuffer ab{isolate_, 2}; - using Reference = AliasedBuffer::Reference; + AliasedBufferBase ab{isolate_, 2}; + using Reference = AliasedBufferBase::Reference; Reference ref = ab[0]; Reference ref_value = ab[1] = 2;