@@ -32,7 +32,6 @@ using v8::Local;
3232using v8::LocalVector;
3333using v8::Maybe;
3434using v8::MaybeLocal;
35- using v8::NewStringType;
3635using v8::Null;
3736using v8::Object;
3837using v8::PropertyAttribute;
@@ -256,8 +255,6 @@ MaybeLocal<Function> DynamicLibrary::CreateFunction(
256255 // The shared_ptr to the backing store keeps the memory alive while
257256 // FFIFunctionInfo still references it.
258257 info->sb_backing = ab->GetBackingStore ();
259- info->sb_data = static_cast <uint8_t *>(info->sb_backing ->Data ());
260- info->sb_size = sb_size;
261258
262259 if (!ret->DefineOwnProperty (
263260 context, env->ffi_sb_shared_buffer_symbol (), ab, internal_attrs)
@@ -288,19 +285,9 @@ MaybeLocal<Function> DynamicLibrary::CreateFunction(
288285 // rebuild the signature from a raw function when the caller did not
289286 // pass parameters and result explicitly. The `lib.functions` accessor
290287 // path relies on this.
291- Local<Array> params_arr =
292- Array::New (isolate, static_cast <int >(fn->arg_type_names .size ()));
293- for (size_t i = 0 ; i < fn->arg_type_names .size (); i++) {
294- Local<String> s;
295- if (!String::NewFromUtf8 (
296- isolate, fn->arg_type_names [i].c_str (), NewStringType::kNormal )
297- .ToLocal (&s)) {
298- return MaybeLocal<Function>();
299- }
300- if (!params_arr->Set (context, static_cast <uint32_t >(i), s)
301- .FromMaybe (false )) {
302- return MaybeLocal<Function>();
303- }
288+ Local<Value> params_arr;
289+ if (!ToV8Value (context, fn->arg_type_names , isolate).ToLocal (¶ms_arr)) {
290+ return MaybeLocal<Function>();
304291 }
305292 if (!ret->DefineOwnProperty (context,
306293 env->ffi_sb_params_symbol (),
@@ -310,9 +297,8 @@ MaybeLocal<Function> DynamicLibrary::CreateFunction(
310297 return MaybeLocal<Function>();
311298 }
312299
313- Local<String> result_name;
314- if (!String::NewFromUtf8 (
315- isolate, fn->return_type_name .c_str (), NewStringType::kNormal )
300+ Local<Value> result_name;
301+ if (!ToV8Value (context, fn->return_type_name , isolate)
316302 .ToLocal (&result_name)) {
317303 return MaybeLocal<Function>();
318304 }
@@ -326,10 +312,9 @@ MaybeLocal<Function> DynamicLibrary::CreateFunction(
326312 }
327313
328314 info->self .Reset (isolate, ret);
329- info->self .SetWeak (info.get (),
315+ info->self .SetWeak (info.release (),
330316 DynamicLibrary::CleanupFunctionInfo,
331317 WeakCallbackType::kParameter );
332- info.release ();
333318
334319 return ret;
335320}
@@ -481,10 +466,10 @@ void DynamicLibrary::InvokeFunctionSB(const FunctionCallbackInfo<Value>& args) {
481466 // that `CreateFunction` did not set up for the fast path, which is a
482467 // contract violation. They stay enabled in Release because each FFI call
483468 // is already dominated by `ffi_call` itself.
484- CHECK_NOT_NULL (info->sb_data );
485- CHECK_EQ (info->sb_size , 8u * (info->fn ->args .size () + 1 ));
469+ CHECK (info->sb_backing );
470+ CHECK_EQ (info->sb_backing -> ByteLength () , 8u * (info->fn ->args .size () + 1 ));
486471
487- uint8_t * buffer = info->sb_data ;
472+ uint8_t * buffer = static_cast < uint8_t *>( info->sb_backing -> Data ()) ;
488473 unsigned int nargs = fn->args .size ();
489474
490475 // Layout is 8 bytes per slot. The return value lives at offset 0 and
0 commit comments