@@ -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;
@@ -257,8 +256,6 @@ MaybeLocal<Function> DynamicLibrary::CreateFunction(
257256 // The shared_ptr to the backing store keeps the memory alive while
258257 // FFIFunctionInfo still references it.
259258 info->sb_backing = ab->GetBackingStore ();
260- info->sb_data = static_cast <uint8_t *>(info->sb_backing ->Data ());
261- info->sb_size = sb_size;
262259
263260 if (!ret->DefineOwnProperty (
264261 context, env->ffi_sb_shared_buffer_symbol (), ab, internal_attrs)
@@ -289,19 +286,9 @@ MaybeLocal<Function> DynamicLibrary::CreateFunction(
289286 // rebuild the signature from a raw function when the caller did not
290287 // pass parameters and result explicitly. The `lib.functions` accessor
291288 // path relies on this.
292- Local<Array> params_arr =
293- Array::New (isolate, static_cast <int >(fn->arg_type_names .size ()));
294- for (size_t i = 0 ; i < fn->arg_type_names .size (); i++) {
295- Local<String> s;
296- if (!String::NewFromUtf8 (
297- isolate, fn->arg_type_names [i].c_str (), NewStringType::kNormal )
298- .ToLocal (&s)) {
299- return MaybeLocal<Function>();
300- }
301- if (!params_arr->Set (context, static_cast <uint32_t >(i), s)
302- .FromMaybe (false )) {
303- return MaybeLocal<Function>();
304- }
289+ Local<Value> params_arr;
290+ if (!ToV8Value (context, fn->arg_type_names , isolate).ToLocal (¶ms_arr)) {
291+ return MaybeLocal<Function>();
305292 }
306293 if (!ret->DefineOwnProperty (context,
307294 env->ffi_sb_params_symbol (),
@@ -311,9 +298,8 @@ MaybeLocal<Function> DynamicLibrary::CreateFunction(
311298 return MaybeLocal<Function>();
312299 }
313300
314- Local<String> result_name;
315- if (!String::NewFromUtf8 (
316- isolate, fn->return_type_name .c_str (), NewStringType::kNormal )
301+ Local<Value> result_name;
302+ if (!ToV8Value (context, fn->return_type_name , isolate)
317303 .ToLocal (&result_name)) {
318304 return MaybeLocal<Function>();
319305 }
@@ -327,10 +313,9 @@ MaybeLocal<Function> DynamicLibrary::CreateFunction(
327313 }
328314
329315 info->self .Reset (isolate, ret);
330- info->self .SetWeak (info.get (),
316+ info->self .SetWeak (info.release (),
331317 DynamicLibrary::CleanupFunctionInfo,
332318 WeakCallbackType::kParameter );
333- info.release ();
334319
335320 return ret;
336321}
@@ -482,10 +467,10 @@ void DynamicLibrary::InvokeFunctionSB(const FunctionCallbackInfo<Value>& args) {
482467 // that `CreateFunction` did not set up for the fast path, which is a
483468 // contract violation. They stay enabled in Release because each FFI call
484469 // is already dominated by `ffi_call` itself.
485- CHECK_NOT_NULL (info->sb_data );
486- CHECK_EQ (info->sb_size , 8u * (info->fn ->args .size () + 1 ));
470+ CHECK (info->sb_backing );
471+ CHECK_EQ (info->sb_backing -> ByteLength () , 8u * (info->fn ->args .size () + 1 ));
487472
488- uint8_t * buffer = info->sb_data ;
473+ uint8_t * buffer = static_cast < uint8_t *>( info->sb_backing -> Data ()) ;
489474 unsigned int nargs = fn->args .size ();
490475
491476 // Layout is 8 bytes per slot. The return value lives at offset 0 and
0 commit comments