Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node-api: segregate nogc APIs from rest via type system #50060

Commits on Dec 9, 2023

  1. node-api: segregate nogc APIs from rest via type system

    We define a new type called `node_api_nogc_env` as the `const` version
    of `napi_env` and `node_api_nogc_finalize` as a variant of
    `napi_finalize` that accepts a `node_api_nogc_env` as its first
    argument.
    
    We then modify those APIs which do not affect GC state as accepting a
    `node_api_nogc_env`. APIs accepting finalizer callbacks are modified to
    accept `node_api_nogc_finalize` callbacks. Thus, the only way to attach
    a `napi_finalize` callback, wherein Node-APIs affecting GC state may be
    called is to call `node_api_post_finalizer` from a
    `node_api_nogc_finalize` callback.
    
    In keeping with the process of introducing new Node-APIs, this feature
    is guarded by `NAPI_EXPERIMENTAL`. Since this feature modifies APIs
    already marked as stable, it is additionally guared by
    `NODE_API_EXPERIMENTAL_NOGC_ENV`, so as to provide a further buffer to
    adoption. Nevertheless, both guards must be removed upon releasing a
    new version of Node-API.
    gabrielschulhof committed Dec 9, 2023
    Configuration menu
    Copy the full SHA
    2eda855 View commit details
    Browse the repository at this point in the history