node/test/js-native-api
Gabriel Schulhof 7a216d5fd6
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: https://github.com/nodejs/node/pull/50060
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Vladimir Morozov <vmorozov@microsoft.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
2023-12-19 07:37:15 +00:00
..
2_function_arguments test: avoid copying test source files 2023-09-10 06:11:36 +00:00
3_callbacks test: avoid copying test source files 2023-09-10 06:11:36 +00:00
4_object_factory test: avoid copying test source files 2023-09-10 06:11:36 +00:00
5_function_factory test: avoid copying test source files 2023-09-10 06:11:36 +00:00
6_object_wrap test: avoid copying test source files 2023-09-10 06:11:36 +00:00
7_factory_wrap test: avoid copying test source files 2023-09-10 06:11:36 +00:00
8_passing_wrapped test: avoid copying test source files 2023-09-10 06:11:36 +00:00
test_array test: avoid copying test source files 2023-09-10 06:11:36 +00:00
test_bigint test: avoid copying test source files 2023-09-10 06:11:36 +00:00
test_cannot_run_js node-api: segregate nogc APIs from rest via type system 2023-12-19 07:37:15 +00:00
test_constructor test: avoid copying test source files 2023-09-10 06:11:36 +00:00
test_conversions test: avoid copying test source files 2023-09-10 06:11:36 +00:00
test_dataview test: avoid copying test source files 2023-09-10 06:11:36 +00:00
test_date test: avoid copying test source files 2023-09-10 06:11:36 +00:00
test_error test: avoid copying test source files 2023-09-10 06:11:36 +00:00
test_exception test: avoid copying test source files 2023-09-10 06:11:36 +00:00
test_finalizer node-api: segregate nogc APIs from rest via type system 2023-12-19 07:37:15 +00:00
test_function test: avoid copying test source files 2023-09-10 06:11:36 +00:00
test_general test: avoid copying test source files 2023-09-10 06:11:36 +00:00
test_handle_scope test: avoid copying test source files 2023-09-10 06:11:36 +00:00
test_instance_data test: avoid copying test source files 2023-09-10 06:11:36 +00:00
test_new_target test: avoid copying test source files 2023-09-10 06:11:36 +00:00
test_number test: avoid copying test source files 2023-09-10 06:11:36 +00:00
test_object node-api: return napi_exception_pending on proxy handlers 2023-10-23 18:17:49 -04:00
test_promise test: avoid copying test source files 2023-09-10 06:11:36 +00:00
test_properties test: avoid copying test source files 2023-09-10 06:11:36 +00:00
test_reference node-api: enable uncaught exceptions policy by default 2023-09-25 04:23:58 +00:00
test_reference_double_free test: avoid copying test source files 2023-09-10 06:11:36 +00:00
test_string node-api: segregate nogc APIs from rest via type system 2023-12-19 07:37:15 +00:00
test_symbol test: avoid copying test source files 2023-09-10 06:11:36 +00:00
test_typedarray test: avoid copying test source files 2023-09-10 06:11:36 +00:00
.gitignore Revert "test: ignore the copied entry_point.c" 2023-09-10 06:11:37 +00:00
common-inl.h node-api: return napi_exception_pending on proxy handlers 2023-10-23 18:17:49 -04:00
common.h node-api: segregate nogc APIs from rest via type system 2023-12-19 07:37:15 +00:00
entry_point.h test: avoid copying test source files 2023-09-10 06:11:36 +00:00
testcfg.py test: partition N-API tests 2018-12-04 13:58:17 -08:00