diff --git a/src/encoding_binding.cc b/src/encoding_binding.cc index 885a0d072312e9..0438afe6efd8b6 100644 --- a/src/encoding_binding.cc +++ b/src/encoding_binding.cc @@ -15,6 +15,7 @@ namespace encoding_binding { using v8::ArrayBuffer; using v8::BackingStore; +using v8::BackingStoreInitializationMode; using v8::Context; using v8::FunctionCallbackInfo; using v8::Isolate; @@ -124,9 +125,8 @@ void BindingData::EncodeUtf8String(const FunctionCallbackInfo& args) { Local ab; { - NoArrayBufferZeroFillScope no_zero_fill_scope(env->isolate_data()); - std::unique_ptr bs = - ArrayBuffer::NewBackingStore(isolate, length); + std::unique_ptr bs = ArrayBuffer::NewBackingStore( + isolate, length, BackingStoreInitializationMode::kUninitialized); CHECK(bs); diff --git a/src/env.cc b/src/env.cc index 0eda889802710d..cd7203ffda6e7c 100644 --- a/src/env.cc +++ b/src/env.cc @@ -39,6 +39,9 @@ namespace node { using errors::TryCatchScope; using v8::Array; +using v8::ArrayBuffer; +using v8::BackingStore; +using v8::BackingStoreInitializationMode; using v8::Boolean; using v8::Context; using v8::CppHeap; @@ -742,17 +745,18 @@ void Environment::add_refs(int64_t diff) { } uv_buf_t Environment::allocate_managed_buffer(const size_t suggested_size) { - NoArrayBufferZeroFillScope no_zero_fill_scope(isolate_data()); - std::unique_ptr bs = - v8::ArrayBuffer::NewBackingStore(isolate(), suggested_size); + std::unique_ptr bs = ArrayBuffer::NewBackingStore( + isolate(), + suggested_size, + BackingStoreInitializationMode::kUninitialized); uv_buf_t buf = uv_buf_init(static_cast(bs->Data()), bs->ByteLength()); released_allocated_buffers_.emplace(buf.base, std::move(bs)); return buf; } -std::unique_ptr Environment::release_managed_buffer( +std::unique_ptr Environment::release_managed_buffer( const uv_buf_t& buf) { - std::unique_ptr bs; + std::unique_ptr bs; if (buf.base != nullptr) { auto it = released_allocated_buffers_.find(buf.base); CHECK_NE(it, released_allocated_buffers_.end()); diff --git a/src/node_buffer.cc b/src/node_buffer.cc index 2e0e8d4746fb61..e8eae4eff51144 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -58,6 +58,7 @@ namespace Buffer { using v8::ArrayBuffer; using v8::ArrayBufferView; using v8::BackingStore; +using v8::BackingStoreInitializationMode; using v8::Context; using v8::EscapableHandleScope; using v8::FastApiTypedArray; @@ -372,9 +373,8 @@ MaybeLocal New(Environment* env, size_t length) { Local ab; { - NoArrayBufferZeroFillScope no_zero_fill_scope(env->isolate_data()); - std::unique_ptr bs = - ArrayBuffer::NewBackingStore(isolate, length); + std::unique_ptr bs = ArrayBuffer::NewBackingStore( + isolate, length, BackingStoreInitializationMode::kUninitialized); CHECK(bs); @@ -413,18 +413,14 @@ MaybeLocal Copy(Environment* env, const char* data, size_t length) { return Local(); } - Local ab; - { - NoArrayBufferZeroFillScope no_zero_fill_scope(env->isolate_data()); - std::unique_ptr bs = - ArrayBuffer::NewBackingStore(isolate, length); + std::unique_ptr bs = ArrayBuffer::NewBackingStore( + isolate, length, BackingStoreInitializationMode::kUninitialized); - CHECK(bs); + CHECK(bs); - memcpy(bs->Data(), data, length); + memcpy(bs->Data(), data, length); - ab = ArrayBuffer::New(isolate, std::move(bs)); - } + Local ab = ArrayBuffer::New(isolate, std::move(bs)); MaybeLocal obj = New(env, ab, 0, ab->ByteLength()) diff --git a/src/node_http2.cc b/src/node_http2.cc index bf0ce4fd20a008..dc271d4e6f6a23 100644 --- a/src/node_http2.cc +++ b/src/node_http2.cc @@ -27,6 +27,7 @@ using v8::Array; using v8::ArrayBuffer; using v8::ArrayBufferView; using v8::BackingStore; +using v8::BackingStoreInitializationMode; using v8::Boolean; using v8::Context; using v8::EscapableHandleScope; @@ -292,11 +293,10 @@ Local Http2Settings::Pack( size_t count, const nghttp2_settings_entry* entries) { EscapableHandleScope scope(env->isolate()); - std::unique_ptr bs; - { - NoArrayBufferZeroFillScope no_zero_fill_scope(env->isolate_data()); - bs = ArrayBuffer::NewBackingStore(env->isolate(), count * 6); - } + std::unique_ptr bs = ArrayBuffer::NewBackingStore( + env->isolate(), + count * 6, + BackingStoreInitializationMode::kUninitialized); if (nghttp2_pack_settings_payload(static_cast(bs->Data()), bs->ByteLength(), entries, @@ -457,13 +457,11 @@ Origins::Origins( return; } - { - NoArrayBufferZeroFillScope no_zero_fill_scope(env->isolate_data()); - bs_ = ArrayBuffer::NewBackingStore(env->isolate(), - alignof(nghttp2_origin_entry) - 1 + - count_ * sizeof(nghttp2_origin_entry) + - origin_string_len); - } + bs_ = ArrayBuffer::NewBackingStore( + env->isolate(), + alignof(nghttp2_origin_entry) - 1 + + count_ * sizeof(nghttp2_origin_entry) + origin_string_len, + BackingStoreInitializationMode::kUninitialized); // Make sure the start address is aligned appropriately for an nghttp2_nv*. char* start = nbytes::AlignUp(static_cast(bs_->Data()), @@ -2064,12 +2062,10 @@ void Http2Session::OnStreamRead(ssize_t nread, const uv_buf_t& buf_) { // happen, we concatenate the data we received with the already-stored // pending input data, slicing off the already processed part. size_t pending_len = stream_buf_.len - stream_buf_offset_; - std::unique_ptr new_bs; - { - NoArrayBufferZeroFillScope no_zero_fill_scope(env()->isolate_data()); - new_bs = ArrayBuffer::NewBackingStore(env()->isolate(), - pending_len + nread); - } + std::unique_ptr new_bs = ArrayBuffer::NewBackingStore( + env()->isolate(), + pending_len + nread, + BackingStoreInitializationMode::kUninitialized); memcpy(static_cast(new_bs->Data()), stream_buf_.base + stream_buf_offset_, pending_len); diff --git a/src/stream_base.cc b/src/stream_base.cc index 9d855c2992492d..518e723272dcbc 100644 --- a/src/stream_base.cc +++ b/src/stream_base.cc @@ -19,6 +19,7 @@ namespace node { using v8::Array; using v8::ArrayBuffer; using v8::BackingStore; +using v8::BackingStoreInitializationMode; using v8::ConstructorBehavior; using v8::Context; using v8::DontDelete; @@ -243,8 +244,8 @@ int StreamBase::Writev(const FunctionCallbackInfo& args) { std::unique_ptr bs; if (storage_size > 0) { - NoArrayBufferZeroFillScope no_zero_fill_scope(env->isolate_data()); - bs = ArrayBuffer::NewBackingStore(isolate, storage_size); + bs = ArrayBuffer::NewBackingStore( + isolate, storage_size, BackingStoreInitializationMode::kUninitialized); } offset = 0; @@ -398,14 +399,14 @@ int StreamBase::WriteString(const FunctionCallbackInfo& args) { if (try_write) { // Copy partial data - NoArrayBufferZeroFillScope no_zero_fill_scope(env->isolate_data()); - bs = ArrayBuffer::NewBackingStore(isolate, buf.len); + bs = ArrayBuffer::NewBackingStore( + isolate, buf.len, BackingStoreInitializationMode::kUninitialized); memcpy(static_cast(bs->Data()), buf.base, buf.len); data_size = buf.len; } else { // Write it - NoArrayBufferZeroFillScope no_zero_fill_scope(env->isolate_data()); - bs = ArrayBuffer::NewBackingStore(isolate, storage_size); + bs = ArrayBuffer::NewBackingStore( + isolate, storage_size, BackingStoreInitializationMode::kUninitialized); data_size = StringBytes::Write(isolate, static_cast(bs->Data()), storage_size,