Commit c08b6c39c5e for nodejs

commit c08b6c39c5e90df5d26a8441ca528e6a61b5b94b
Author: Chengzhong Wu <legendecas@gmail.com>
Date:   Thu Nov 26 03:18:25 2026 +0800

    src: migrate off ArrayBufferView::Buffer()

    V8 16.0 removes `ArrayBufferView::Buffer()`. Use `GetBuffer()` instead,
    which is already available in V8 15.8.

    Refs: https://crrev.com/c/8794471
    Co-Authored-By: Clemens Backes <post@clemens-backes.de>
    Co-Authored-By: Joyee Cheung <joyeec9h3@gmail.com>
    Signed-off-by: Chengzhong Wu <cwu631@bloomberg.net>
    PR-URL: https://github.com/nodejs/node/pull/67733
    Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
    Reviewed-By: Guilherme Araújo <arauujogui@gmail.com>
    Reviewed-By: Vladimir Morozov <vmorozov@microsoft.com>
    Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
    Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
    Reviewed-By: Anna Henningsen <anna@addaleax.net>

diff --git a/benchmark/napi/function_args/binding.cc b/benchmark/napi/function_args/binding.cc
index 5cdca8bd357..9174c61f2c3 100644
--- a/benchmark/napi/function_args/binding.cc
+++ b/benchmark/napi/function_args/binding.cc
@@ -3,7 +3,7 @@
 #include <assert.h>

 using v8::Array;
-using v8::ArrayBuffer;
+using v8::ArrayBufferBase;
 using v8::ArrayBufferView;
 using v8::BackingStore;
 using v8::Context;
@@ -104,7 +104,7 @@ void CallWithTypedarray(const FunctionCallbackInfo<Value>& args) {
     const size_t byte_length = view->ByteLength();
     assert(byte_length > 0);
     assert(view->HasBuffer());
-    Local<ArrayBuffer> buffer = view->Buffer();
+    Local<ArrayBufferBase> buffer = view->GetBuffer();
     std::shared_ptr<BackingStore> bs = buffer->GetBackingStore();
     const uint32_t* data = reinterpret_cast<uint32_t*>(
         static_cast<uint8_t*>(bs->Data()) + byte_offset);
diff --git a/src/aliased_buffer-inl.h b/src/aliased_buffer-inl.h
index 5cb36e707ce..f3390fc367a 100644
--- a/src/aliased_buffer-inl.h
+++ b/src/aliased_buffer-inl.h
@@ -97,7 +97,7 @@ inline void AliasedBufferBase<NativeT, V8T>::Deserialize(
   // be removed when we expand the snapshot support.
   DCHECK_EQ(count_, arr->Length());
   DCHECK_EQ(byte_offset_, arr->ByteOffset());
-  uint8_t* raw = static_cast<uint8_t*>(arr->Buffer()->Data());
+  uint8_t* raw = static_cast<uint8_t*>(arr->GetBuffer()->Data());
   buffer_ = reinterpret_cast<NativeT*>(raw + byte_offset_);
   js_array_.Reset(isolate_, arr);
   index_ = nullptr;
@@ -146,7 +146,11 @@ template <typename NativeT, typename V8T>
   requires std::is_scalar_v<NativeT>
 v8::Local<v8::ArrayBuffer> AliasedBufferBase<NativeT, V8T>::GetArrayBuffer()
     const {
-  return GetJSArray()->Buffer();
+  // The JS array is always created over an ArrayBuffer allocated by
+  // AliasedBufferBase itself, never over a SharedArrayBuffer.
+  v8::Local<v8::ArrayBufferBase> buffer = GetJSArray()->GetBuffer();
+  DCHECK(buffer->IsArrayBuffer());
+  return buffer.As<v8::ArrayBuffer>();
 }

 template <typename NativeT, typename V8T>
diff --git a/src/crypto/crypto_random.cc b/src/crypto/crypto_random.cc
index 79c52a7d08c..9dd3722a945 100644
--- a/src/crypto/crypto_random.cc
+++ b/src/crypto/crypto_random.cc
@@ -33,7 +33,7 @@ namespace crypto {
 namespace {
 bool IsImmutableBufferSource(Local<Value> buffer) {
   if (buffer->IsArrayBufferView()) {
-    return buffer.As<ArrayBufferView>()->Buffer()->IsImmutable();
+    return buffer.As<ArrayBufferView>()->GetBuffer()->IsImmutable();
   }
   return buffer->IsArrayBuffer() && buffer.As<ArrayBuffer>()->IsImmutable();
 }
diff --git a/src/crypto/crypto_util.cc b/src/crypto/crypto_util.cc
index fe148c0a2c5..2997d3e61bc 100644
--- a/src/crypto/crypto_util.cc
+++ b/src/crypto/crypto_util.cc
@@ -1096,7 +1096,7 @@ MaybeLocal<Value> ToWebCryptoJobResult(Environment* env, Local<Value> value) {
   }

   if (Buffer::HasInstance(value)) {
-    return value.As<ArrayBufferView>()->Buffer();
+    return value.As<ArrayBufferView>()->GetBuffer();
   }

   CHECK(value->IsBoolean() || (value->IsObject() && !value->IsArray() &&
diff --git a/src/crypto/crypto_util.h b/src/crypto/crypto_util.h
index f39ae6feff7..c91724729a6 100644
--- a/src/crypto/crypto_util.h
+++ b/src/crypto/crypto_util.h
@@ -718,7 +718,7 @@ class ArrayBufferOrViewContents final {
       auto view = buf.As<v8::ArrayBufferView>();
       offset_ = view->ByteOffset();
       length_ = view->ByteLength();
-      data_ = view->Buffer()->Data();
+      data_ = view->GetBuffer()->Data();
     } else if (buf->IsArrayBuffer()) {
       auto ab = buf.As<v8::ArrayBuffer>();
       offset_ = 0;
diff --git a/src/dataqueue/queue.cc b/src/dataqueue/queue.cc
index 96a7956b874..ee00523bc4a 100644
--- a/src/dataqueue/queue.cc
+++ b/src/dataqueue/queue.cc
@@ -20,6 +20,8 @@

 namespace node {

+using v8::ArrayBuffer;
+using v8::ArrayBufferBase;
 using v8::ArrayBufferView;
 using v8::BackingStore;
 using v8::Local;
@@ -1163,13 +1165,17 @@ std::unique_ptr<DataQueue::Entry> DataQueue::CreateInMemoryEntryFromView(
   // the underlying buffer, something else could modify the buffer while we're
   // holding the reference, which means we cannot guarantee that reads will be
   // idempotent.
-  if (!view->Buffer()->IsDetachable()) {
+  Local<ArrayBufferBase> buffer = view->GetBuffer();
+  if (!buffer->IsDetachable()) {
     return nullptr;
   }
-  auto store = view->Buffer()->GetBackingStore();
+  auto store = buffer->GetBackingStore();
   auto offset = view->ByteOffset();
   auto length = view->ByteLength();
-  USE(view->Buffer()->Detach(Local<Value>()));
+  // A SharedArrayBuffer is never detachable, assuming this is an ArrayBuffer
+  // is safe.
+  DCHECK(buffer->IsArrayBuffer());
+  USE(buffer.As<ArrayBuffer>()->Detach(Local<Value>()));
   return CreateInMemoryEntryFromBackingStore(std::move(store), offset, length);
 }

diff --git a/src/encoding_binding.cc b/src/encoding_binding.cc
index 5b8f8f0bcdc..72fbaf21dab 100644
--- a/src/encoding_binding.cc
+++ b/src/encoding_binding.cc
@@ -15,6 +15,7 @@ namespace node {
 namespace encoding_binding {

 using v8::ArrayBuffer;
+using v8::ArrayBufferBase;
 using v8::BackingStore;
 using v8::BackingStoreInitializationMode;
 using v8::BackingStoreOnFailureMode;
@@ -197,7 +198,7 @@ void BindingData::EncodeInto(const FunctionCallbackInfo<Value>& args) {
   Local<String> source = args[0].As<String>();

   Local<Uint8Array> dest = args[1].As<Uint8Array>();
-  Local<ArrayBuffer> buf = dest->Buffer();
+  Local<ArrayBufferBase> buf = dest->GetBuffer();

   // Handle detached buffers - return {read: 0, written: 0}
   if (buf->Data() == nullptr) {
@@ -425,7 +426,7 @@ void BindingData::DecodeUTF8(const FunctionCallbackInfo<Value>& args) {

   if (args[0]->IsArrayBufferView()) {
     Local<v8::ArrayBufferView> view = args[0].As<v8::ArrayBufferView>();
-    isShared = view->Buffer()->IsSharedArrayBuffer();
+    isShared = view->GetBuffer()->IsSharedArrayBuffer();
   }

   ArrayBufferViewContents<char> buffer(args[0]);
diff --git a/src/ffi/data.cc b/src/ffi/data.cc
index ca3315d43a3..cf729414b74 100644
--- a/src/ffi/data.cc
+++ b/src/ffi/data.cc
@@ -793,7 +793,7 @@ void GetRawPointer(const FunctionCallbackInfo<Value>& args) {
     store = args[0].As<SharedArrayBuffer>()->GetBackingStore();
   } else if (args[0]->IsArrayBufferView()) {
     Local<ArrayBufferView> view = args[0].As<ArrayBufferView>();
-    if (view->Buffer()->WasDetached()) {
+    if (view->GetBuffer()->WasDetached()) {
       THROW_ERR_INVALID_ARG_VALUE(
           env, "ArrayBufferView is backed by a detached ArrayBuffer");
       return;
@@ -801,7 +801,7 @@ void GetRawPointer(const FunctionCallbackInfo<Value>& args) {
     // Access the store here to ensure that it exists. Small typed arrays
     // may not have a store until this point and can instead be stored
     // entirely in-heap.
-    store = view->Buffer()->GetBackingStore();
+    store = view->GetBuffer()->GetBackingStore();
     offset = view->ByteOffset();
   } else {
     THROW_ERR_INVALID_ARG_TYPE(
diff --git a/src/ffi/fast.cc b/src/ffi/fast.cc
index aaba55e07ba..f7d829a9c2a 100644
--- a/src/ffi/fast.cc
+++ b/src/ffi/fast.cc
@@ -125,7 +125,7 @@ uintptr_t PointerFromValue(v8::Local<v8::Value> value) {
   // ArrayBuffer and SharedArrayBuffer point at the start of their store.
   if (value->IsArrayBufferView()) {
     v8::Local<v8::ArrayBufferView> view = value.As<v8::ArrayBufferView>();
-    void* data = view->Buffer()->Data();
+    void* data = view->GetBuffer()->Data();
     return reinterpret_cast<uintptr_t>(static_cast<char*>(data) +
                                        view->ByteOffset());
   }
@@ -259,7 +259,7 @@ extern "C" uintptr_t node_ffi_fast_buffer_data(v8::Local<v8::Value> value,
   // lifetimes match the generic path.
   if (value->IsArrayBufferView()) {
     v8::Local<v8::ArrayBufferView> view = value.As<v8::ArrayBufferView>();
-    if (view->Buffer()->WasDetached()) {
+    if (view->GetBuffer()->WasDetached()) {
       THROW_ERR_INVALID_ARG_VALUE(
           isolate,
           "Argument %u is an ArrayBufferView backed by a detached "
diff --git a/src/ffi/types.cc b/src/ffi/types.cc
index 971ca8b6adb..89adf93c24e 100644
--- a/src/ffi/types.cc
+++ b/src/ffi/types.cc
@@ -717,7 +717,7 @@ Maybe<FFIArgumentCategory> ToFFIArgument(Environment* env,
       // invalidating that backing store during the active FFI call is
       // unsupported and dangerous.
       Local<ArrayBufferView> view = arg.As<ArrayBufferView>();
-      if (view->Buffer()->WasDetached()) {
+      if (view->GetBuffer()->WasDetached()) {
         THROW_ERR_INVALID_ARG_VALUE(
             env,
             "Argument %u is an ArrayBufferView backed by a detached "
@@ -725,7 +725,8 @@ Maybe<FFIArgumentCategory> ToFFIArgument(Environment* env,
             index);
         return {};
       }
-      std::shared_ptr<BackingStore> store = view->Buffer()->GetBackingStore();
+      std::shared_ptr<BackingStore> store =
+          view->GetBuffer()->GetBackingStore();

       if (!store) {
         THROW_ERR_INVALID_ARG_VALUE(
diff --git a/src/heap_utils.cc b/src/heap_utils.cc
index 72c1a73aa6c..fa9a9463d7e 100644
--- a/src/heap_utils.cc
+++ b/src/heap_utils.cc
@@ -429,7 +429,7 @@ HeapProfiler::HeapSnapshotOptions GetHeapSnapshotOptions(
   CHECK(options_value->IsUint8Array());
   Local<Uint8Array> arr = options_value.As<Uint8Array>();
   uint8_t* options =
-      static_cast<uint8_t*>(arr->Buffer()->Data()) + arr->ByteOffset();
+      static_cast<uint8_t*>(arr->GetBuffer()->Data()) + arr->ByteOffset();
   HeapProfiler::HeapSnapshotOptions result;
   result.snapshot_mode = options[0]
                              ? HeapProfiler::HeapSnapshotMode::kExposeInternals
diff --git a/src/histogram.cc b/src/histogram.cc
index ada84685f40..56d4091ef3e 100644
--- a/src/histogram.cc
+++ b/src/histogram.cc
@@ -3121,7 +3121,7 @@ void HistogramImpl::GetQrde(const FunctionCallbackInfo<Value>& args) {
   Local<Float64Array> input = args[0].As<Float64Array>();
   CHECK_GE(input->Length(), 2);
   CHECK_LE(input->Length(), 1001);
-  auto backing = input->Buffer()->GetBackingStore();
+  auto backing = input->GetBuffer()->GetBackingStore();
   const double* data = reinterpret_cast<const double*>(
       static_cast<const char*>(backing->Data()) + input->ByteOffset());
   std::vector<double> probabilities(data, data + input->Length());
@@ -3205,7 +3205,7 @@ void HistogramImpl::DoImport(const FunctionCallbackInfo<Value>& args) {
     return;
   }
   Local<Uint8Array> input = args[0].As<Uint8Array>();
-  auto backing = input->Buffer()->GetBackingStore();
+  auto backing = input->GetBuffer()->GetBackingStore();
   const uint8_t* data =
       static_cast<const uint8_t*>(backing->Data()) + input->ByteOffset();
   size_t len = input->ByteLength();
@@ -3278,7 +3278,7 @@ void HistogramImpl::GetPercentilesAt(const FunctionCallbackInfo<Value>& args) {
   CHECK(args[1]->IsFloat64Array());
   Local<Float64Array> input = args[1].As<Float64Array>();
   size_t length = input->Length();
-  auto backing = input->Buffer()->GetBackingStore();
+  auto backing = input->GetBuffer()->GetBackingStore();
   double* percentiles = reinterpret_cast<double*>(
       static_cast<char*>(backing->Data()) + input->ByteOffset());

diff --git a/src/js_native_api_v8.cc b/src/js_native_api_v8.cc
index 863b0f9e3ae..bb9cd0c6d1b 100644
--- a/src/js_native_api_v8.cc
+++ b/src/js_native_api_v8.cc
@@ -3394,11 +3394,11 @@ napi_status NAPI_CDECL napi_get_typedarray_info(napi_env env,
     *length = array->Length();
   }

-  v8::Local<v8::ArrayBuffer> buffer;
+  v8::Local<v8::ArrayBufferBase> buffer;
   if (data != nullptr || arraybuffer != nullptr) {
-    // Calling Buffer() may have the side effect of allocating the buffer,
+    // Calling GetBuffer() may have the side effect of allocating the buffer,
     // so only do this when it’s needed.
-    buffer = array->Buffer();
+    buffer = array->GetBuffer();
   }

   if (data != nullptr) {
@@ -3483,11 +3483,11 @@ napi_status NAPI_CDECL napi_get_dataview_info(napi_env env,
     *byte_length = array->ByteLength();
   }

-  v8::Local<v8::ArrayBuffer> buffer;
+  v8::Local<v8::ArrayBufferBase> buffer;
   if (data != nullptr || arraybuffer != nullptr) {
-    // Calling Buffer() may have the side effect of allocating the buffer,
+    // Calling GetBuffer() may have the side effect of allocating the buffer,
     // so only do this when it’s needed.
-    buffer = array->Buffer();
+    buffer = array->GetBuffer();
   }

   if (data != nullptr) {
diff --git a/src/module_wrap.cc b/src/module_wrap.cc
index 4b881209c39..96c83f37f57 100644
--- a/src/module_wrap.cc
+++ b/src/module_wrap.cc
@@ -359,7 +359,7 @@ void ModuleWrap::New(const FunctionCallbackInfo<Value>& args) {
         CHECK(!can_use_builtin_cache);  // We don't use this option internally.
         Local<ArrayBufferView> cached_data_buf = args[5].As<ArrayBufferView>();
         uint8_t* data =
-            static_cast<uint8_t*>(cached_data_buf->Buffer()->Data());
+            static_cast<uint8_t*>(cached_data_buf->GetBuffer()->Data());
         user_cached_data =
             new ScriptCompiler::CachedData(data + cached_data_buf->ByteOffset(),
                                            cached_data_buf->ByteLength());
diff --git a/src/node_blob.cc b/src/node_blob.cc
index bdc10ab2ad7..64c8a6668a1 100644
--- a/src/node_blob.cc
+++ b/src/node_blob.cc
@@ -19,6 +19,7 @@ namespace node {

 using v8::Array;
 using v8::ArrayBuffer;
+using v8::ArrayBufferBase;
 using v8::ArrayBufferView;
 using v8::BackingStore;
 using v8::BackingStoreInitializationMode;
@@ -77,7 +78,7 @@ void Concat(const FunctionCallbackInfo<Value>& args) {
     } else {
       CHECK(val->IsArrayBufferView());
       auto view = val.As<ArrayBufferView>();
-      views.push_back(View{view->Buffer()->GetBackingStore(),
+      views.push_back(View{view->GetBuffer()->GetBackingStore(),
                            view->ByteLength(),
                            view->ByteOffset()});
       total += view->ByteLength();
@@ -206,13 +207,16 @@ void Blob::New(const FunctionCallbackInfo<Value>& args) {
     Local<Value> entry = sources[i].Get(isolate);

     auto entryFromArrayBuffer =
-        [isolate](Local<ArrayBuffer> buf,
+        [isolate](Local<ArrayBufferBase> buf,
                   size_t byte_length,
                   size_t byte_offset =
                       0) mutable -> std::unique_ptr<DataQueue::Entry> {
       if (buf->IsDetachable()) {
         std::shared_ptr<BackingStore> store = buf->GetBackingStore();
-        if (buf->Detach(Local<Value>()).IsNothing()) {
+        // A SharedArrayBuffer is never detachable, assuming this is an
+        // ArrayBuffer is safe.
+        DCHECK(buf->IsArrayBuffer());
+        if (buf.As<ArrayBuffer>()->Detach(Local<Value>()).IsNothing()) {
           return nullptr;
         }
         return DataQueue::CreateInMemoryEntryFromBackingStore(
@@ -245,7 +249,7 @@ void Blob::New(const FunctionCallbackInfo<Value>& args) {
     } else if (entry->IsArrayBufferView()) {
       Local<ArrayBufferView> view = entry.As<ArrayBufferView>();
       auto ret = entryFromArrayBuffer(
-          view->Buffer(), view->ByteLength(), view->ByteOffset());
+          view->GetBuffer(), view->ByteLength(), view->ByteOffset());
       if (!ret) return;
       entries[i] = std::move(ret);
     } else if (Blob::HasInstance(env, entry)) {
diff --git a/src/node_buffer.cc b/src/node_buffer.cc
index e7accbbe8d3..6c2321d5f1b 100644
--- a/src/node_buffer.cc
+++ b/src/node_buffer.cc
@@ -56,6 +56,7 @@ namespace node {
 namespace Buffer {

 using v8::ArrayBuffer;
+using v8::ArrayBufferBase;
 using v8::ArrayBufferView;
 using v8::BackingStore;
 using v8::BackingStoreInitializationMode;
@@ -257,7 +258,7 @@ bool HasInstance(Local<Object> obj) {
 char* Data(Local<Value> val) {
   CHECK(val->IsArrayBufferView());
   Local<ArrayBufferView> ui = val.As<ArrayBufferView>();
-  return static_cast<char*>(ui->Buffer()->Data()) + ui->ByteOffset();
+  return static_cast<char*>(ui->GetBuffer()->Data()) + ui->ByteOffset();
 }


@@ -279,9 +280,8 @@ size_t Length(Local<Object> obj) {
   return ui->ByteLength();
 }

-
 MaybeLocal<Uint8Array> New(Environment* env,
-                           Local<ArrayBuffer> ab,
+                           Local<ArrayBufferBase> ab,
                            size_t byte_offset,
                            size_t length) {
   CHECK(!env->buffer_prototype_object().IsEmpty());
@@ -584,7 +584,7 @@ void StringSlice(const FunctionCallbackInfo<Value>& args) {
   size_t length = end - start;

   std::unique_ptr<char[]> data_copy;
-  if (view->Buffer()->IsSharedArrayBuffer()) {
+  if (view->GetBuffer()->IsSharedArrayBuffer()) {
     data_copy = std::make_unique_for_overwrite<char[]>(length);
     memcpy(data_copy.get(), data_ptr + start, length);
     data_ptr = data_copy.get();
@@ -609,8 +609,8 @@ size_t CopyImpl(Local<Value> source_obj,
   Local<ArrayBufferView> source = source_obj.As<ArrayBufferView>();
   Local<ArrayBufferView> target = target_obj.As<ArrayBufferView>();

-  Local<ArrayBuffer> source_ab = source->Buffer();
-  Local<ArrayBuffer> target_ab = target->Buffer();
+  Local<ArrayBufferBase> source_ab = source->GetBuffer();
+  Local<ArrayBufferBase> target_ab = target->GetBuffer();

   const size_t source_offset = source->ByteOffset() + source_start;
   const size_t target_offset = target->ByteOffset() + target_start;
@@ -1502,7 +1502,7 @@ static bool MaskArgs(Local<Value> source_obj,
                      uint32_t mask) {
   CHECK(destination_obj->IsArrayBufferView());
   Local<ArrayBufferView> destination = destination_obj.As<ArrayBufferView>();
-  Local<ArrayBuffer> destination_ab = destination->Buffer();
+  Local<ArrayBufferBase> destination_ab = destination->GetBuffer();
   if (destination_ab->IsImmutable()) return false;
   if (length == 0) return true;
   const size_t destination_length = destination->ByteLength();
diff --git a/src/node_contextify.cc b/src/node_contextify.cc
index ed76490bf28..5329315d354 100644
--- a/src/node_contextify.cc
+++ b/src/node_contextify.cc
@@ -1024,7 +1024,7 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {

   ScriptCompiler::CachedData* cached_data = nullptr;
   if (!cached_data_buf.IsEmpty()) {
-    uint8_t* data = static_cast<uint8_t*>(cached_data_buf->Buffer()->Data());
+    uint8_t* data = static_cast<uint8_t*>(cached_data_buf->GetBuffer()->Data());
     cached_data = new ScriptCompiler::CachedData(
         data + cached_data_buf->ByteOffset(), cached_data_buf->ByteLength());
   }
@@ -1435,7 +1435,7 @@ void ContextifyFunction::CompileFunction(
   // Read cache from cached data buffer
   ScriptCompiler::CachedData* cached_data = nullptr;
   if (!cached_data_buf.IsEmpty()) {
-    uint8_t* data = static_cast<uint8_t*>(cached_data_buf->Buffer()->Data());
+    uint8_t* data = static_cast<uint8_t*>(cached_data_buf->GetBuffer()->Data());
     cached_data = new ScriptCompiler::CachedData(
       data + cached_data_buf->ByteOffset(), cached_data_buf->ByteLength());
   }
diff --git a/src/node_file.cc b/src/node_file.cc
index e9423a378da..048d106227c 100644
--- a/src/node_file.cc
+++ b/src/node_file.cc
@@ -3997,7 +3997,7 @@ class WriteFileJob final : public AsyncWrap, public ThreadPoolWork {
     // detached or collected meanwhile; a resizable buffer can still have its
     // pages decommitted by a shrink, so its contents are copied instead.
     length_ = view->ByteLength();
-    backing_store_ = view->Buffer()->GetBackingStore();
+    backing_store_ = view->GetBuffer()->GetBackingStore();
     if (backing_store_->IsResizableByUserJavaScript()) {
       copy_.reset(new char[length_]);
       memcpy(copy_.get(),
diff --git a/src/node_internals.h b/src/node_internals.h
index 282c5fb533c..5b08da7831b 100644
--- a/src/node_internals.h
+++ b/src/node_internals.h
@@ -190,9 +190,9 @@ v8::MaybeLocal<v8::Object> New(Environment* env,
 v8::MaybeLocal<v8::Object> New(Environment* env,
                                char* data,
                                size_t length);
-// Creates a Buffer instance over an existing ArrayBuffer.
+// Creates a Buffer instance over an existing ArrayBuffer or SharedArrayBuffer.
 v8::MaybeLocal<v8::Uint8Array> New(Environment* env,
-                                   v8::Local<v8::ArrayBuffer> ab,
+                                   v8::Local<v8::ArrayBufferBase> ab,
                                    size_t byte_offset,
                                    size_t length);
 // Construct a Buffer from a MaybeStackBuffer (and also its subclasses like
diff --git a/src/node_ipc_serdes.cc b/src/node_ipc_serdes.cc
index 05d5ae7ccff..7d444814d8c 100644
--- a/src/node_ipc_serdes.cc
+++ b/src/node_ipc_serdes.cc
@@ -20,6 +20,7 @@
 namespace node {

 using v8::ArrayBuffer;
+using v8::ArrayBufferBase;
 using v8::ArrayBufferView;
 using v8::BackingStore;
 using v8::BigInt64Array;
@@ -103,7 +104,7 @@ static size_t BytesPerElement(uint32_t type_index) {

 static MaybeLocal<Object> MakeView(Environment* env,
                                    uint32_t type_index,
-                                   Local<ArrayBuffer> ab,
+                                   Local<ArrayBufferBase> ab,
                                    size_t byte_offset,
                                    size_t byte_length) {
   const size_t length = byte_length / BytesPerElement(type_index);
@@ -240,7 +241,7 @@ class IPCSerializerDelegate : public ValueSerializer::Delegate {

 class IPCDeserializerDelegate : public ValueDeserializer::Delegate {
  public:
-  IPCDeserializerDelegate(Environment* env, Local<ArrayBuffer> ab)
+  IPCDeserializerDelegate(Environment* env, Local<ArrayBufferBase> ab)
       : env_(env), ab_(ab) {}

   void set_deserializer(ValueDeserializer* deserializer) {
@@ -298,7 +299,7 @@ class IPCDeserializerDelegate : public ValueDeserializer::Delegate {

  private:
   Environment* env_;
-  Local<ArrayBuffer> ab_;
+  Local<ArrayBufferBase> ab_;
   ValueDeserializer* deserializer_ = nullptr;
 };

@@ -346,7 +347,7 @@ static void Deserialize(const FunctionCallbackInfo<Value>& args) {

   CHECK(args[0]->IsArrayBufferView());
   Local<ArrayBufferView> view = args[0].As<ArrayBufferView>();
-  Local<ArrayBuffer> ab = view->Buffer();
+  Local<ArrayBufferBase> ab = view->GetBuffer();
   const size_t byte_offset = view->ByteOffset();
   const size_t byte_length = view->ByteLength();
   const uint8_t* data = static_cast<const uint8_t*>(ab->Data()) + byte_offset;
diff --git a/src/node_os.cc b/src/node_os.cc
index 4c7ebde4644..ff73f7edecf 100644
--- a/src/node_os.cc
+++ b/src/node_os.cc
@@ -40,7 +40,7 @@ namespace node {
 namespace os {

 using v8::Array;
-using v8::ArrayBuffer;
+using v8::ArrayBufferBase;
 using v8::Boolean;
 using v8::Context;
 using v8::Float64Array;
@@ -186,7 +186,7 @@ static void GetLoadAvg(const FunctionCallbackInfo<Value>& args) {
   CHECK(args[0]->IsFloat64Array());
   Local<Float64Array> array = args[0].As<Float64Array>();
   CHECK_EQ(array->Length(), 3);
-  Local<ArrayBuffer> ab = array->Buffer();
+  Local<ArrayBufferBase> ab = array->GetBuffer();
   double* loadavg = static_cast<double*>(ab->Data());
   uv_loadavg(loadavg);
 }
diff --git a/src/node_process_methods.cc b/src/node_process_methods.cc
index 2db5e3678b5..7b915305f6a 100644
--- a/src/node_process_methods.cc
+++ b/src/node_process_methods.cc
@@ -40,7 +40,7 @@ typedef int mode_t;
 namespace node {

 using v8::Array;
-using v8::ArrayBuffer;
+using v8::ArrayBufferBase;
 using v8::CFunction;
 using v8::Context;
 using v8::Float64Array;
@@ -100,7 +100,7 @@ static void Chdir(const FunctionCallbackInfo<Value>& args) {
   }
 }

-inline Local<ArrayBuffer> get_fields_array_buffer(
+inline Local<ArrayBufferBase> get_fields_array_buffer(
     const FunctionCallbackInfo<Value>& args,
     size_t index,
     size_t array_length) {
@@ -108,7 +108,7 @@ inline Local<ArrayBuffer> get_fields_array_buffer(
   Local<Float64Array> arr = args[index].As<Float64Array>();
   CHECK_EQ(arr->Length(), array_length);
   CHECK_EQ(arr->ByteOffset(), 0);
-  return arr->Buffer();
+  return arr->GetBuffer();
 }

 // CPUUsage use libuv's uv_getrusage() this-process resource usage accessor,
@@ -126,7 +126,7 @@ static void CPUUsage(const FunctionCallbackInfo<Value>& args) {
     return env->ThrowUVException(err, "uv_getrusage");

   // Get the double array pointer from the Float64Array argument.
-  Local<ArrayBuffer> ab = get_fields_array_buffer(args, 0, 2);
+  Local<ArrayBufferBase> ab = get_fields_array_buffer(args, 0, 2);
   double* fields = static_cast<double*>(ab->Data());

   // Set the Float64Array elements to be user / system values in microseconds.
@@ -149,7 +149,7 @@ static void ThreadCPUUsage(const FunctionCallbackInfo<Value>& args) {
   if (err) return env->ThrowUVException(err, "uv_getrusage_thread");

   // Get the double array pointer from the Float64Array argument.
-  Local<ArrayBuffer> ab = get_fields_array_buffer(args, 0, 2);
+  Local<ArrayBufferBase> ab = get_fields_array_buffer(args, 0, 2);
   double* fields = static_cast<double*>(ab->Data());

   // Set the Float64Array elements to be user / system values in microseconds.
@@ -231,7 +231,7 @@ static void MemoryUsage(const FunctionCallbackInfo<Value>& args) {
       env->isolate_data()->node_allocator();

   // Get the double array pointer from the Float64Array argument.
-  Local<ArrayBuffer> ab = get_fields_array_buffer(args, 0, 5);
+  Local<ArrayBufferBase> ab = get_fields_array_buffer(args, 0, 5);
   double* fields = static_cast<double*>(ab->Data());

   size_t rss;
@@ -370,7 +370,7 @@ static void ResourceUsage(const FunctionCallbackInfo<Value>& args) {
   if (err)
     return env->ThrowUVException(err, "uv_getrusage");

-  Local<ArrayBuffer> ab = get_fields_array_buffer(args, 0, 16);
+  Local<ArrayBufferBase> ab = get_fields_array_buffer(args, 0, 16);
   double* fields = static_cast<double*>(ab->Data());

   fields[0] = MICROS_PER_SEC * rusage.ru_utime.tv_sec + rusage.ru_utime.tv_usec;
diff --git a/src/node_sqlite.cc b/src/node_sqlite.cc
index 1622916edc0..00b8f40ce99 100644
--- a/src/node_sqlite.cc
+++ b/src/node_sqlite.cc
@@ -1974,7 +1974,7 @@ std::optional<std::string> ValidateDatabasePath(Environment* env,
     size_t byteOffset = buffer->ByteOffset();
     size_t byteLength = buffer->ByteLength();
     auto data =
-        static_cast<const uint8_t*>(buffer->Buffer()->Data()) + byteOffset;
+        static_cast<const uint8_t*>(buffer->GetBuffer()->Data()) + byteOffset;
     if (std::find(data, data + byteLength, 0) == data + byteLength) {
       return reject_uri(
           std::string(reinterpret_cast<const char*>(data), byteLength));
diff --git a/src/node_wasi.cc b/src/node_wasi.cc
index 844221b8898..daa85ef9af3 100644
--- a/src/node_wasi.cc
+++ b/src/node_wasi.cc
@@ -27,7 +27,7 @@ inline void Debug(const WASI& wasi, Args&&... args) {
   } while (0)

 using v8::Array;
-using v8::ArrayBuffer;
+using v8::ArrayBufferBase;
 using v8::BigInt;
 using v8::CFunction;
 using v8::Context;
@@ -282,7 +282,7 @@ R WASI::WasiFunction<FT, F, R, Args...>::FastCallback(
     THROW_ERR_WASI_NOT_STARTED(isolate);
     return EinvalError<R>();
   }
-  Local<ArrayBuffer> ab = wasi->memory_.Get(isolate)->Buffer();
+  Local<ArrayBufferBase> ab = wasi->memory_.Get(isolate)->GetBuffer();
   size_t mem_size = ab->ByteLength();
   char* mem_data = static_cast<char*>(ab->Data());
   CHECK_NOT_NULL(mem_data);
@@ -408,7 +408,7 @@ void WASI::WasiFunction<FT, F, R, Args...>::SlowCallback(
   }

   Local<WasmMemoryObject> memory = PersistentToLocal::Strong(wasi->memory_);
-  Local<ArrayBuffer> ab = memory->Buffer();
+  Local<ArrayBufferBase> ab = memory->GetBuffer();
   size_t mem_size = ab->ByteLength();
   char* mem_data = static_cast<char*>(ab->Data());
   CHECK_NOT_NULL(mem_data);
diff --git a/src/node_wasm_web_api.cc b/src/node_wasm_web_api.cc
index d977793eb13..e372849e57f 100644
--- a/src/node_wasm_web_api.cc
+++ b/src/node_wasm_web_api.cc
@@ -107,7 +107,7 @@ void WasmStreamingObject::Push(const FunctionCallbackInfo<Value>& args) {

   if (chunk->IsArrayBufferView()) [[likely]] {
     Local<ArrayBufferView> view = chunk.As<ArrayBufferView>();
-    bytes = view->Buffer()->Data();
+    bytes = view->GetBuffer()->Data();
     offset = view->ByteOffset();
     size = view->ByteLength();
   } else if (chunk->IsArrayBuffer()) [[likely]] {
diff --git a/src/node_zlib.cc b/src/node_zlib.cc
index 89f8e8ad2cc..463b68c2150 100644
--- a/src/node_zlib.cc
+++ b/src/node_zlib.cc
@@ -58,7 +58,7 @@

 namespace node {

-using v8::ArrayBuffer;
+using v8::ArrayBufferBase;
 using v8::CFunction;
 using v8::Context;
 using v8::Function;
@@ -836,7 +836,7 @@ class ZlibStream final : public CompressionStream<ZlibContext> {
     CHECK(args[4]->IsUint32Array());
     Local<Uint32Array> array = args[4].As<Uint32Array>();
     CHECK_GE(array->Length(), 2);
-    Local<ArrayBuffer> ab = array->Buffer();
+    Local<ArrayBufferBase> ab = array->GetBuffer();
     uint32_t* write_result = static_cast<uint32_t*>(ab->Data());

     CHECK(args[5]->IsFunction());
diff --git a/src/quic/data.cc b/src/quic/data.cc
index 0de12774516..b080e52d08b 100644
--- a/src/quic/data.cc
+++ b/src/quic/data.cc
@@ -130,7 +130,7 @@ Maybe<Store> Store::From(Local<ArrayBufferView> view) {
   }
   if (length > 0) {
     memcpy(dest->Data(),
-           static_cast<const uint8_t*>(view->Buffer()->Data()) + offset,
+           static_cast<const uint8_t*>(view->GetBuffer()->Data()) + offset,
            length);
   }
   return Just(Store(std::move(dest), length, 0));
@@ -156,7 +156,7 @@ Store Store::CopyFrom(Local<ArrayBuffer> buffer) {

 Store Store::CopyFrom(Local<ArrayBufferView> view) {
   Isolate* isolate = Isolate::GetCurrent();
-  auto backing = view->Buffer()->GetBackingStore();
+  auto backing = view->GetBuffer()->GetBackingStore();
   auto length = view->ByteLength();
   auto offset = view->ByteOffset();
   auto dest = ArrayBuffer::NewBackingStore(
diff --git a/src/quic/streams.cc b/src/quic/streams.cc
index f29bab507a4..1951a7d3e1e 100644
--- a/src/quic/streams.cc
+++ b/src/quic/streams.cc
@@ -20,6 +20,7 @@ namespace node {

 using v8::Array;
 using v8::ArrayBuffer;
+using v8::ArrayBufferBase;
 using v8::ArrayBufferView;
 using v8::BackingStore;
 using v8::BackingStoreInitializationMode;
@@ -278,7 +279,10 @@ namespace {
 // QUIC API.
 // Returns nullptr on zero length or allocation failure.
 std::unique_ptr<DataQueue::Entry> CreateEntryFromBuffer(
-    Environment* env, Local<ArrayBuffer> buffer, size_t offset, size_t length) {
+    Environment* env,
+    Local<ArrayBufferBase> buffer,
+    size_t offset,
+    size_t length) {
   if (length == 0) return nullptr;
   JS_TRY_ALLOCATE_BACKING_OR_RETURN(env, copy, length, nullptr);
   memcpy(copy->Data(),
@@ -329,7 +333,8 @@ Maybe<std::shared_ptr<DataQueue>> Stream::GetDataQueueFromSource(
     auto offset = view->ByteOffset();
     auto length = view->ByteLength();
     if (length > 0) {
-      auto entry = CreateEntryFromBuffer(env, view->Buffer(), offset, length);
+      auto entry =
+          CreateEntryFromBuffer(env, view->GetBuffer(), offset, length);
       if (!entry) {
         return Nothing<std::shared_ptr<DataQueue>>();
       }
@@ -1368,8 +1373,8 @@ void Stream::WriteStreamData(const FunctionCallbackInfo<Value>& args) {
     auto view = value.As<Uint8Array>();
     auto length = view->ByteLength();
     if (length == 0) return true;
-    auto entry =
-        CreateEntryFromBuffer(env, view->Buffer(), view->ByteOffset(), length);
+    auto entry = CreateEntryFromBuffer(
+        env, view->GetBuffer(), view->ByteOffset(), length);
     if (!entry) {
       return false;
     }
diff --git a/src/stream_base.cc b/src/stream_base.cc
index fb16da9b5a9..e5ce7a587cb 100644
--- a/src/stream_base.cc
+++ b/src/stream_base.cc
@@ -805,7 +805,7 @@ void CustomBufferJSListener::SetBuffer(Local<Object> object,
                                        Local<ArrayBufferView> view) {
   // Keep the view's lifetime tied to the wrapper without a strong global root.
   object->SetInternalField(StreamBase::kUserBufferField, view);
-  backing_store_ = view->Buffer()->GetBackingStore();
+  backing_store_ = view->GetBuffer()->GetBackingStore();
 }

 uv_buf_t CustomBufferJSListener::OnStreamAlloc(size_t suggested_size) {
@@ -826,7 +826,7 @@ uv_buf_t CustomBufferJSListener::OnStreamAlloc(size_t suggested_size) {
     const auto contents = view->GetContents({});
     // An attached empty backing store can also have a null data pointer.
     if (contents.data() != nullptr || (backing_store_->MaxByteLength() == 0 &&
-                                       !view->Buffer()->WasDetached())) {
+                                       !view->GetBuffer()->WasDetached())) {
       buffer_ = uv_buf_init(reinterpret_cast<char*>(contents.data()),
                             contents.size());
       return buffer_;
diff --git a/src/util-inl.h b/src/util-inl.h
index cecc03be2c7..e61e56fb31a 100644
--- a/src/util-inl.h
+++ b/src/util-inl.h
@@ -615,10 +615,10 @@ ArrayBufferViewContents<T, S>::ArrayBufferViewContents(
 template <typename T, size_t S>
   requires(sizeof(T) == 1)
 void ArrayBufferViewContents<T, S>::Read(v8::Local<v8::ArrayBufferView> abv) {
-  was_detached_ = abv->Buffer()->WasDetached();
+  was_detached_ = abv->GetBuffer()->WasDetached();
   length_ = abv->ByteLength();
   if (length_ > sizeof(stack_storage_) || abv->HasBuffer()) {
-    auto buf_data = abv->Buffer()->Data();
+    auto buf_data = abv->GetBuffer()->Data();
     data_ = buf_data != nullptr ? static_cast<T*>(buf_data) + abv->ByteOffset()
                                 : stack_storage_;
   } else {
diff --git a/src/util.h b/src/util.h
index 6cb2d5e8900..15dc1dcaebd 100644
--- a/src/util.h
+++ b/src/util.h
@@ -695,7 +695,7 @@ class BufferValue : public MaybeStackBuffer<char> {
   const size_t name##_offset = name->ByteOffset();                             \
   const size_t name##_length = name->ByteLength();                             \
   char* const name##_data =                                                    \
-      static_cast<char*>(name->Buffer()->Data()) + name##_offset;              \
+      static_cast<char*>(name->GetBuffer()->Data()) + name##_offset;           \
   if (name##_length > 0) CHECK_NE(name##_data, nullptr);

 // Use this when a variable or parameter is unused in order to explicitly
diff --git a/test/addons/openssl-binding/binding.cc b/test/addons/openssl-binding/binding.cc
index 6c85f914097..a27152c9686 100644
--- a/test/addons/openssl-binding/binding.cc
+++ b/test/addons/openssl-binding/binding.cc
@@ -12,7 +12,7 @@ inline void RandomBytes(const v8::FunctionCallbackInfo<v8::Value>& info) {
   auto byte_offset = view->ByteOffset();
   auto byte_length = view->ByteLength();
   assert(view->HasBuffer());
-  auto buffer = view->Buffer();
+  auto buffer = view->GetBuffer();
   auto contents = buffer->GetBackingStore();
   auto data = static_cast<unsigned char*>(contents->Data()) + byte_offset;
   assert(RAND_poll());
@@ -26,7 +26,7 @@ inline void Hash(const v8::FunctionCallbackInfo<v8::Value>& info) {
   auto byte_offset = view->ByteOffset();
   auto len = view->ByteLength();
   assert(view->HasBuffer());
-  auto buffer = view->Buffer();
+  auto buffer = view->GetBuffer();
   auto contents = buffer->GetBackingStore();
   auto data = static_cast<unsigned char*>(contents->Data()) + byte_offset;
   unsigned char md[MD5_DIGEST_LENGTH];
diff --git a/test/addons/zlib-binding/binding.cc b/test/addons/zlib-binding/binding.cc
index 859b54564b6..3eb61422163 100644
--- a/test/addons/zlib-binding/binding.cc
+++ b/test/addons/zlib-binding/binding.cc
@@ -11,7 +11,7 @@ inline void CompressBytes(const v8::FunctionCallbackInfo<v8::Value>& info) {
   auto byte_offset = view->ByteOffset();
   auto byte_length = view->ByteLength();
   assert(view->HasBuffer());
-  auto buffer = view->Buffer();
+  auto buffer = view->GetBuffer();
   auto contents = buffer->GetBackingStore();
   auto data = static_cast<unsigned char*>(contents->Data()) + byte_offset;

diff --git a/test/cctest/test_environment.cc b/test/cctest/test_environment.cc
index cec49dac916..c4b546ad911 100644
--- a/test/cctest/test_environment.cc
+++ b/test/cctest/test_environment.cc
@@ -755,7 +755,7 @@ TEST_F(EnvironmentTest, BufferWithFreeCallbackIsDetached) {

   int callback_calls = 0;

-  v8::Local<v8::ArrayBuffer> ab;
+  v8::Local<v8::ArrayBufferBase> ab;
   {
     Env env {handle_scope, argv};
     v8::Local<v8::Object> buf_obj = node::Buffer::New(
@@ -768,7 +768,7 @@ TEST_F(EnvironmentTest, BufferWithFreeCallbackIsDetached) {
         },
         &callback_calls).ToLocalChecked();
     CHECK(buf_obj->IsUint8Array());
-    ab = buf_obj.As<v8::Uint8Array>()->Buffer();
+    ab = buf_obj.As<v8::Uint8Array>()->GetBuffer();
     CHECK_EQ(ab->ByteLength(), sizeof(hello));
   }

diff --git a/test/cctest/test_node_ipc_serdes.cc b/test/cctest/test_node_ipc_serdes.cc
index 6b2d9854a6d..0b837bb90e3 100644
--- a/test/cctest/test_node_ipc_serdes.cc
+++ b/test/cctest/test_node_ipc_serdes.cc
@@ -69,7 +69,7 @@ v8::Local<v8::Value> RoundTrip(v8::Local<v8::Context> context,
   EXPECT_EQ(payload_length, buf->ByteLength() - 4);

   v8::Local<v8::Value> payload = v8::Uint8Array::New(
-      buf->Buffer(), buf->ByteOffset() + 4, buf->ByteLength() - 4);
+      buf->GetBuffer(), buf->ByteOffset() + 4, buf->ByteLength() - 4);
   return deserialize->Call(context, v8::Undefined(isolate), 1, &payload)
       .ToLocalChecked();
 }