Skip to content

Commit 992ad9f

Browse files
joyeecheungbackes
authored andcommitted
src: migrate off deprecated V8 15.8 APIs
Migrate ArrayBufferView::Buffer() and WasmMemoryObject::Buffer() calls to GetBuffer() (returning Local<ArrayBufferBase>), RegExp::Exec() to RegExp::ExecV2(), and OwnedBuffer::buffer/size to OwnedBuffer::as_span(). V8 16.0 removes ArrayBufferView::Buffer(), WasmMemoryObject::Buffer(), and the public OwnedBuffer fields, and changes RegExp::Exec() to return MaybeLocal<Value>. Refs: https://crrev.com/c/8714721 Refs: https://crrev.com/c/8794471 Co-Authored-By: Clemens Backes <post@clemens-backes.de> Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com> Signed-off-by: Chengzhong Wu <cwu631@bloomberg.net>
1 parent fdb4553 commit 992ad9f

4 files changed

Lines changed: 16 additions & 11 deletions

File tree

‎src/compile_cache.cc‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "compile_cache.h"
2+
#include <span>
23
#include <string>
34
#include "debug_utils-inl.h"
45
#include "env-inl.h"
@@ -336,10 +337,13 @@ ScriptCompiler::CachedData* SerializeCodeCache(Local<Module> mod) {
336337
// with the baseline tier so far.
337338
ScriptCompiler::CachedData* SerializeCodeCache(Local<WasmModuleObject> mod) {
338339
v8::OwnedBuffer code = mod->GetCompiledModule().Serialize();
339-
if (code.size == 0) return nullptr;
340+
if (code.empty()) return nullptr;
341+
std::span<const uint8_t> span = code.as_span();
342+
uint8_t* buffer = new uint8_t[span.size()];
343+
memcpy(buffer, span.data(), span.size());
340344
return new ScriptCompiler::CachedData(
341-
code.buffer.release(),
342-
static_cast<int>(code.size),
345+
buffer,
346+
static_cast<int>(span.size()),
343347
ScriptCompiler::CachedData::BufferOwned);
344348
}
345349

‎src/ffi/fast.cc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ extern "C" uintptr_t node_ffi_fast_buffer_data(v8::Local<v8::Value> value,
247247
constexpr uintptr_t kInvalidBuffer = std::numeric_limits<uintptr_t>::max();
248248
// The trampoline always passes the FastApiCallbackOptions declared in the
249249
// CFunctionInfo. No HandleScope is active during a Fast API call, and both
250-
// ArrayBufferView::Buffer() and the error paths below create handles, so
250+
// ArrayBufferView::GetBuffer() and the error paths below create handles, so
251251
// open one for the whole helper. Otherwise every call leaks handles into
252252
// the caller's scope.
253253
v8::Isolate* isolate = options->isolate;

‎src/node_ipc_serdes.cc‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,9 @@ class IPCDeserializerDelegate : public ValueDeserializer::Delegate {
287287
// Reuse the backing ArrayBuffer when the data is suitably aligned,
288288
// otherwise copy into a fresh aligned buffer. Mirrors _readHostObject()
289289
// in lib/v8.js.
290-
if (offset_in_ab % bytes_per_element == 0) {
291-
return MakeView(env_, type_index, ab_, offset_in_ab, byte_length);
290+
if (ab_->IsArrayBuffer() && offset_in_ab % bytes_per_element == 0) {
291+
return MakeView(
292+
env_, type_index, ab_.As<ArrayBuffer>(), offset_in_ab, byte_length);
292293
}
293294
std::shared_ptr<BackingStore> store =
294295
ArrayBuffer::NewBackingStore(isolate, byte_length);

‎src/node_url_pattern.cc‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,13 @@ bool URLPatternRegexProvider::regex_match(std::string_view input,
108108
.ToLocal(&local_input)) {
109109
return false;
110110
}
111-
Local<Object> result_object;
111+
Local<Value> result_object;
112112
if (!pattern.Get(isolate)
113-
->Exec(env->context(), local_input)
113+
->ExecV2(env->context(), local_input)
114114
.ToLocal(&result_object)) {
115115
return false;
116116
}
117-
// RegExp::Exec returns null if there is no match.
117+
// RegExp::ExecV2 returns null if there is no match.
118118
return !result_object->IsNull();
119119
}
120120

@@ -129,9 +129,9 @@ URLPatternRegexProvider::regex_search(std::string_view input,
129129
.ToLocal(&local_input)) {
130130
return std::nullopt;
131131
}
132-
Local<Object> exec_result_object;
132+
Local<Value> exec_result_object;
133133
auto pattern = global_pattern.Get(isolate);
134-
if (!pattern->Exec(env->context(), local_input)
134+
if (!pattern->ExecV2(env->context(), local_input)
135135
.ToLocal(&exec_result_object) ||
136136
exec_result_object->IsNull()) {
137137
return std::nullopt;

0 commit comments

Comments
 (0)