Closed
Description
- Version: master
- Platform: all
- Subsystem: n-api
Currently, N-API's object wrapping uses v8::External
with a const char*
as a brand check. However, v8::External
s are known to be inefficient, and the fact that one such External
is created for every wrapped object only worsens the problem. On the other hand, V8 provides the mechanism necessary for cross-napi_env
brand checks in v8::Private::ForApi
, which is like a C++-private version of Symbol.for()
, and v8::Object::HasPrivate
/SetPrivate
. Handles to these v8::Private
s can then be cached per napi_env
in a Persistent
. Similar features are also available in earlier V8 versions, as implemented in @kkoopa's NAN.
I'd be willing to cook up a PR for this.
/cc @nodejs/n-api @gabrielschulhof @jasongin