From d58b4e12f8fc31b8cf32b0413cd9cb5dff3c36ca Mon Sep 17 00:00:00 2001 From: Keyhan Vakil Date: Thu, 21 Jul 2022 04:41:22 +0000 Subject: [PATCH] src: remove usages of GetBackingStore This removes all usages of GetBackingStore in `node-api`. See the linked issue for an explanation. Refs: https://github.com/nodejs/node/issues/32226 Refs: https://github.com/nodejs/node/pull/43921 --- src/js_native_api_v8.cc | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/js_native_api_v8.cc b/src/js_native_api_v8.cc index 5f8e21e0b58c8a..db0cd6eb01e4a6 100644 --- a/src/js_native_api_v8.cc +++ b/src/js_native_api_v8.cc @@ -2780,7 +2780,7 @@ napi_status NAPI_CDECL napi_create_arraybuffer(napi_env env, // Optionally return a pointer to the buffer's data, to avoid another call to // retrieve it. if (data != nullptr) { - *data = buffer->GetBackingStore()->Data(); + *data = buffer->Data(); } *result = v8impl::JsValueFromV8LocalValue(buffer); @@ -2814,15 +2814,14 @@ napi_status NAPI_CDECL napi_get_arraybuffer_info(napi_env env, v8::Local value = v8impl::V8LocalValueFromJsValue(arraybuffer); RETURN_STATUS_IF_FALSE(env, value->IsArrayBuffer(), napi_invalid_arg); - std::shared_ptr backing_store = - value.As()->GetBackingStore(); + v8::Local ab = value.As(); if (data != nullptr) { - *data = backing_store->Data(); + *data = ab->Data(); } if (byte_length != nullptr) { - *byte_length = backing_store->ByteLength(); + *byte_length = ab->ByteLength(); } return napi_clear_last_error(env); @@ -2963,8 +2962,7 @@ napi_status NAPI_CDECL napi_get_typedarray_info(napi_env env, } if (data != nullptr) { - *data = static_cast(buffer->GetBackingStore()->Data()) + - array->ByteOffset(); + *data = static_cast(buffer->Data()) + array->ByteOffset(); } if (arraybuffer != nullptr) { @@ -3044,8 +3042,7 @@ napi_status NAPI_CDECL napi_get_dataview_info(napi_env env, } if (data != nullptr) { - *data = static_cast(buffer->GetBackingStore()->Data()) + - array->ByteOffset(); + *data = static_cast(buffer->Data()) + array->ByteOffset(); } if (arraybuffer != nullptr) { @@ -3255,8 +3252,8 @@ napi_status NAPI_CDECL napi_is_detached_arraybuffer(napi_env env, v8::Local value = v8impl::V8LocalValueFromJsValue(arraybuffer); - *result = value->IsArrayBuffer() && - value.As()->GetBackingStore()->Data() == nullptr; + *result = + value->IsArrayBuffer() && value.As()->Data() == nullptr; return napi_clear_last_error(env); }