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

[v18.x-backport] Backport feature flags and nogc types 2 #51804

Commits on Mar 1, 2024

  1. node-api: introduce experimental feature flags

    Add a flag for each experimental feature to indicate its presence.
    That way, if we compile with `NAPI_EXPERIMENTAL` turned on, we'll be
    able to distinguish between what `NAPI_EXPERIMENTAL` used to mean on an
    old version of the headers when compiling against such an old version,
    and what it means on a new version of Node.js.
    
    PR-URL: nodejs#50991
    Reviewed-By: Michael Dawson <midawson@redhat.com>
    Reviewed-By: Vladimir Morozov <vmorozov@microsoft.com>
    Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
    Backport-PR-URL: nodejs#51804
    (cherry picked from commit 727dd28)
    gabrielschulhof committed Mar 1, 2024
    Configuration menu
    Copy the full SHA
    86e3bb0 View commit details
    Browse the repository at this point in the history
  2. node-api: factor out common code into macros

        * Create macro for checking new string arguments.
        * Create macro for combining env check and inside-gc check.
    
    PR-URL: nodejs#50664
    Reviewed-By: Vladimir Morozov <vmorozov@microsoft.com>
    Reviewed-By: James M Snell <jasnell@gmail.com>
    Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
    Backport-PR-URL: nodejs#51804
    (cherry picked from commit 5e250bd)
    gabrielschulhof committed Mar 1, 2024
    Configuration menu
    Copy the full SHA
    ebbfcfa View commit details
    Browse the repository at this point in the history
  3. 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.
    
    PR-URL: nodejs#50060
    Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
    Reviewed-By: Vladimir Morozov <vmorozov@microsoft.com>
    Reviewed-By: Michael Dawson <midawson@redhat.com>
    Backport-PR-URL: nodejs#51804
    (cherry picked from commit 7a216d5)
    gabrielschulhof committed Mar 1, 2024
    Configuration menu
    Copy the full SHA
    344099d View commit details
    Browse the repository at this point in the history