Commit 3df2d8dc authored by Jérémy Lal's avatar Jérémy Lal

New upstream version 6.12.0~dfsg

parent 00a9a3e1
This diff is collapsed.
......@@ -91,7 +91,7 @@ On macOS you will need to install the `Xcode Command Line Tools` by running
installed, you can find them under the menu `Xcode -> Open Developer Tool ->
More Developer Tools...`. This step will install `clang`, `clang++`, and
`make`.
* You may want to setup [firewall rules](tools/macosx-firewall.sh)
* After building, you may want to setup [firewall rules](tools/macosx-firewall.sh)
to avoid popups asking to accept incoming network connections when running tests:
If the path to your build directory contains a space, the build will likely fail.
......@@ -129,6 +129,9 @@ To run the tests:
$ make test
```
At this point you are ready to make code changes and re-run the tests!
Optionally, continue below.
To run the tests and generate code coverage reports:
```console
......@@ -145,7 +148,7 @@ and overwrites the `lib/` directory. To clean up after generating the coverage
reports:
```console
make coverage-clean
$ make coverage-clean
```
To build the documentation:
......
......@@ -26,7 +26,9 @@ release.
</tr>
<tr>
<td valign="top">
<b><a href="doc/changelogs/CHANGELOG_V6.md#6.11.4">6.11.4</a></b><br/>
<b><a href="doc/changelogs/CHANGELOG_V6.md#6.12.0">6.12.0</a></b><br/>
<a href="doc/changelogs/CHANGELOG_V6.md#6.11.5">6.11.5</a><br/>
<a href="doc/changelogs/CHANGELOG_V6.md#6.11.4">6.11.4</a><br/>
<a href="doc/changelogs/CHANGELOG_V6.md#6.11.3">6.11.3</a><br/>
<a href="doc/changelogs/CHANGELOG_V6.md#6.11.2">6.11.2</a><br/>
<a href="doc/changelogs/CHANGELOG_V6.md#6.11.1">6.11.1</a><br/>
......
This diff is collapsed.
......@@ -527,8 +527,8 @@ The externally maintained libraries used by Node.js are:
- stdint-msvc2008.h (from msinttypes), copyright Alexander Chemeris. Three
clause BSD license.
- pthread-fixes.h, pthread-fixes.c, copyright Google Inc. and Sony Mobile
Communications AB. Three clause BSD license.
- pthread-fixes.c, copyright Google Inc. and Sony Mobile Communications AB.
Three clause BSD license.
- android-ifaddrs.h, android-ifaddrs.c, copyright Berkeley Software Design
Inc, Kenneth MacKay and Emergya (Cloud4all, FP7/2007-2013, grant agreement
......
......@@ -753,23 +753,27 @@ bench-idle:
sleep 1
$(NODE) benchmark/idle_clients.js &
jslint:
lint-js:
@echo "Running JS linter..."
$(NODE) tools/eslint/bin/eslint.js --cache --rulesdir=tools/eslint-rules --ext=.js,.md \
benchmark doc lib test tools
jslint-ci:
jslint: lint-js
lint-js-ci:
@echo "Running JS linter..."
$(NODE) tools/jslint.js $(PARALLEL_ARGS) -f tap -o test-eslint.tap \
$(NODE) tools/lint-js.js $(PARALLEL_ARGS) -f tap -o test-eslint.tap \
benchmark doc lib test tools
CPPLINT_EXCLUDE ?=
CPPLINT_EXCLUDE += src/node_root_certs.h
CPPLINT_EXCLUDE += src/queue.h
CPPLINT_EXCLUDE += src/tree.h
CPPLINT_EXCLUDE += $(wildcard test/addons/??_*/*.cc test/addons/??_*/*.h)
jslint-ci: lint-js-ci
LINT_CPP_EXCLUDE ?=
LINT_CPP_EXCLUDE += src/node_root_certs.h
LINT_CPP_EXCLUDE += src/queue.h
LINT_CPP_EXCLUDE += src/tree.h
LINT_CPP_EXCLUDE += $(wildcard test/addons/??_*/*.cc test/addons/??_*/*.h)
CPPLINT_FILES = $(filter-out $(CPPLINT_EXCLUDE), $(wildcard \
LINT_CPP_FILES = $(filter-out $(LINT_CPP_EXCLUDE), $(wildcard \
src/*.c \
src/*.cc \
src/*.h \
......@@ -781,19 +785,21 @@ CPPLINT_FILES = $(filter-out $(CPPLINT_EXCLUDE), $(wildcard \
tools/icu/*.h \
))
cpplint:
lint-cpp:
@echo "Running C++ linter..."
@$(PYTHON) tools/cpplint.py $(CPPLINT_FILES)
@$(PYTHON) tools/cpplint.py $(LINT_CPP_FILES)
@$(PYTHON) tools/check-imports.py
ifneq ("","$(wildcard tools/eslint/bin/eslint.js)")
cpplint: lint-cpp
ifneq ("","$(wildcard tools/eslint/)")
lint:
@EXIT_STATUS=0 ; \
$(MAKE) jslint || EXIT_STATUS=$$? ; \
$(MAKE) cpplint || EXIT_STATUS=$$? ; \
$(MAKE) lint-js || EXIT_STATUS=$$? ; \
$(MAKE) lint-cpp || EXIT_STATUS=$$? ; \
exit $$EXIT_STATUS
CONFLICT_RE=^>>>>>>> [0-9A-Fa-f]+|^<<<<<<< [A-Za-z]+
lint-ci: jslint-ci cpplint
lint-ci: lint-js-ci lint-cpp
@if ! ( grep -IEqrs "$(CONFLICT_RE)" benchmark deps doc lib src test tools ) \
&& ! ( find . -maxdepth 1 -type f | xargs grep -IEqs "$(CONFLICT_RE)" ); then \
exit 0 ; \
......@@ -807,18 +813,17 @@ lint:
@echo "Linting is not available through the source tarball."
@echo "Use the git repo instead:" \
"$ git clone https://github.com/nodejs/node.git"
exit 1
lint-ci: lint
endif
.PHONY: lint cpplint jslint bench clean docopen docclean doc dist distclean \
.PHONY: lint lint-cpp lint-js bench clean docopen docclean doc dist distclean \
check uninstall install install-includes install-bin all staticlib \
dynamiclib test test-all test-addons test-addons-clean build-addons \
website-upload pkg blog blogclean tar binary release-only \
bench-http-simple bench-idle bench-all bench bench-misc bench-array \
bench-buffer bench-net bench-http bench-fs bench-tls cctest run-ci \
test-v8 test-v8-intl test-v8-benchmarks test-v8-all v8 lint-ci \
bench-ci jslint-ci doc-only $(TARBALL)-headers test-ci test-ci-native \
bench-ci lint-js-ci doc-only $(TARBALL)-headers test-ci test-ci-native \
test-ci-js build-ci test-hash-seed clear-stalled
......@@ -134,12 +134,12 @@ $ grep node-vx.y.z.tar.gz SHASUMS256.txt | sha256sum -c -
_(Where "node-vx.y.z.tar.gz" is the name of the file you have
downloaded)_
Additionally, Current and LTS releases (not Nightlies) have GPG signed
copies of SHASUMS256.txt files available as SHASUMS256.txt.asc. You can use
`gpg` to verify that the file has not been tampered with.
Additionally, Current and LTS releases (not Nightlies) have the GPG
detached signature of SHASUMS256.txt available as SHASUMS256.txt.sig.
You can use `gpg` to verify that SHASUMS256.txt has not been tampered with.
To verify a SHASUMS256.txt.asc, you will first need to import all of
the GPG keys of individuals authorized to create releases. They are
To verify SHASUMS256.txt has not been altered, you will first need to import
all of the GPG keys of individuals authorized to create releases. They are
listed at the bottom of this README under [Release Team](#release-team).
Use a command such as this to import the keys:
......@@ -150,10 +150,17 @@ $ gpg --keyserver pool.sks-keyservers.net --recv-keys DD8F2338BAE7501E3DD5AC78C2
_(See the bottom of this README for a full script to import active
release keys)_
You can then use `gpg --verify SHASUMS256.txt.asc` to verify that the
file has been signed by an authorized member of the Node.js team.
Next, download the SHASUMS256.txt.sig for the release:
Once verified, use the SHASUMS256.txt.asc file to get the checksum for
```console
$ curl -O https://nodejs.org/dist/vx.y.z/SHASUMS256.txt.sig
```
After downloading the appropriate SHASUMS256.txt and SHASUMS256.txt.sig files,
you can then use `gpg --verify SHASUMS256.txt.sig SHASUMS256.txt` to verify
that the file has been signed by an authorized member of the Node.js team.
Once verified, use the SHASUMS256.txt file to get the checksum for
the binary verification command above.
## Building Node.js
......@@ -228,8 +235,6 @@ For more information about the governance of the Node.js project, see
* [addaleax](https://github.com/addaleax) -
**Anna Henningsen** &lt;anna@addaleax.net&gt; (she/her)
* [bnoordhuis](https://github.com/bnoordhuis) -
**Ben Noordhuis** &lt;info@bnoordhuis.nl&gt;
* [ChALkeR](https://github.com/ChALkeR) -
**Сковорода Никита Андреевич** &lt;chalkerx@gmail.com&gt; (he/him)
* [cjihrig](https://github.com/cjihrig) -
......@@ -273,16 +278,18 @@ For more information about the governance of the Node.js project, see
### TSC Emeriti
* [bnoordhuis](https://github.com/bnoordhuis) -
**Ben Noordhuis** &lt;info@bnoordhuis.nl&gt;
* [chrisdickinson](https://github.com/chrisdickinson) -
**Chris Dickinson** &lt;christopher.s.dickinson@gmail.com&gt;
* [isaacs](https://github.com/isaacs) -
**Isaac Z. Schlueter** &lt;i@izs.me&gt;
* [nebrius](https://github.com/nebrius) -
**Bryan Hughes** &lt;bryan@nebri.us&gt;
* [orangemocha](https://github.com/orangemocha) -
**Alexis Campailla** &lt;orangemocha@nodejs.org&gt;
* [piscisaureus](https://github.com/piscisaureus) -
**Bert Belder** &lt;bertbelder@gmail.com&gt;
* [nebrius](https://github.com/nebrius) -
**Bryan Hughes** &lt;bryan@nebri.us&gt;
### Collaborators
......@@ -306,6 +313,8 @@ For more information about the governance of the Node.js project, see
**Benjamin Gruenbaum** &lt;benjamingr@gmail.com&gt;
* [bmeck](https://github.com/bmeck) -
**Bradley Farias** &lt;bradley.meck@gmail.com&gt;
* [bmeurer](https://github.com/bmeurer) -
**Benedikt Meurer** &lt;benedikt.meurer@gmail.com&gt;
* [bnoordhuis](https://github.com/bnoordhuis) -
**Ben Noordhuis** &lt;info@bnoordhuis.nl&gt;
* [brendanashworth](https://github.com/brendanashworth) -
......@@ -386,6 +395,8 @@ For more information about the governance of the Node.js project, see
**Julian Duque** &lt;julianduquej@gmail.com&gt; (he/him)
* [JungMinu](https://github.com/JungMinu) -
**Minwoo Jung** &lt;minwoo@nodesource.com&gt; (he/him)
* [kfarnung](https://github.com/kfarnung) -
**Kyle Farnung** &lt;kfarnung@microsoft.com&gt; (he/him)
* [kunalspathak](https://github.com/kunalspathak) -
**Kunal Pathak** &lt;kunal.pathak@microsoft.com&gt;
* [lance](https://github.com/lance) -
......@@ -462,6 +473,8 @@ For more information about the governance of the Node.js project, see
**Sam Roberts** &lt;vieuxtech@gmail.com&gt;
* [santigimeno](https://github.com/santigimeno) -
**Santiago Gimeno** &lt;santiago.gimeno@gmail.com&gt;
* [sebdeckers](https://github.com/sebdeckers) -
**Sebastiaan Deckers** &lt;sebdeckers83@gmail.com&gt;
* [seishun](https://github.com/seishun) -
**Nikolai Vavilov** &lt;vvnicholas@gmail.com&gt;
* [shigeki](https://github.com/shigeki) -
......
......@@ -18,7 +18,7 @@ keylen_list.forEach(function(key) {
var bench = common.createBenchmark(main, {
writes: [500],
algo: ['RSA-SHA1', 'RSA-SHA224', 'RSA-SHA256', 'RSA-SHA384', 'RSA-SHA512'],
algo: ['SHA1', 'SHA224', 'SHA256', 'SHA384', 'SHA512'],
keylen: keylen_list,
len: [1024, 102400, 2 * 102400, 3 * 102400, 1024 * 1024]
});
......
......@@ -27,7 +27,7 @@ const bench = common.createBenchmark(main, {
'foo\nbar',
'\x7F'
],
n: [5e8],
n: [1e6],
});
function main(conf) {
......
......@@ -37,7 +37,7 @@ const bench = common.createBenchmark(main, {
':alternate-protocol', // fast bailout
'alternate-protocol:' // slow bailout
],
n: [5e8],
n: [1e6],
});
function main(conf) {
......
......@@ -444,6 +444,11 @@ parser.add_option('--without-ssl',
dest='without_ssl',
help='build without SSL (disables crypto, https, inspector, etc.)')
parser.add_option('--without-node-options',
action='store_true',
dest='without_node_options',
help='build without NODE_OPTIONS support')
parser.add_option('--xcode',
action='store_true',
dest='use_xcode',
......@@ -975,6 +980,9 @@ def configure_openssl(o):
o['variables']['openssl_no_asm'] = 1 if options.openssl_no_asm else 0
if options.use_openssl_ca_store:
o['defines'] += ['NODE_OPENSSL_CERT_STORE']
o['variables']['node_without_node_options'] = b(options.without_node_options)
if options.without_node_options:
o['defines'] += ['NODE_WITHOUT_NODE_OPTIONS']
if options.openssl_fips:
o['variables']['openssl_fips'] = options.openssl_fips
fips_dir = os.path.join(root_dir, 'deps', 'openssl', 'fips')
......
......@@ -795,14 +795,18 @@ namespace {
*/
class ArrayConcatVisitor {
public:
ArrayConcatVisitor(Isolate* isolate, Handle<Object> storage,
ArrayConcatVisitor(Isolate* isolate, Handle<HeapObject> storage,
bool fast_elements)
: isolate_(isolate),
storage_(isolate->global_handles()->Create(*storage)),
index_offset_(0u),
bit_field_(FastElementsField::encode(fast_elements) |
ExceedsLimitField::encode(false) |
IsFixedArrayField::encode(storage->IsFixedArray())) {
bit_field_(
FastElementsField::encode(fast_elements) |
ExceedsLimitField::encode(false) |
IsFixedArrayField::encode(storage->IsFixedArray()) |
HasSimpleElementsField::encode(storage->IsFixedArray() ||
storage->map()->instance_type() >
LAST_CUSTOM_ELEMENTS_RECEIVER)) {
DCHECK(!(this->fast_elements() && !is_fixed_array()));
}
......@@ -891,12 +895,16 @@ class ArrayConcatVisitor {
// (otherwise)
Handle<FixedArray> storage_fixed_array() {
DCHECK(is_fixed_array());
DCHECK(has_simple_elements());
return Handle<FixedArray>::cast(storage_);
}
Handle<JSReceiver> storage_jsreceiver() {
DCHECK(!is_fixed_array());
return Handle<JSReceiver>::cast(storage_);
}
bool has_simple_elements() const {
return HasSimpleElementsField::decode(bit_field_);
}
private:
// Convert storage to dictionary mode.
......@@ -929,12 +937,14 @@ class ArrayConcatVisitor {
inline void set_storage(FixedArray* storage) {
DCHECK(is_fixed_array());
DCHECK(has_simple_elements());
storage_ = isolate_->global_handles()->Create(storage);
}
class FastElementsField : public BitField<bool, 0, 1> {};
class ExceedsLimitField : public BitField<bool, 1, 1> {};
class IsFixedArrayField : public BitField<bool, 2, 1> {};
class HasSimpleElementsField : public BitField<bool, 3, 1> {};
bool fast_elements() const { return FastElementsField::decode(bit_field_); }
void set_fast_elements(bool fast) {
......@@ -1166,8 +1176,6 @@ bool IterateElementsSlow(Isolate* isolate, Handle<JSReceiver> receiver,
visitor->increase_index_offset(length);
return true;
}
/**
* A helper function that visits "array" elements of a JSReceiver in numerical
* order.
......@@ -1201,7 +1209,8 @@ bool IterateElements(Isolate* isolate, Handle<JSReceiver> receiver,
return IterateElementsSlow(isolate, receiver, length, visitor);
}
if (!HasOnlySimpleElements(isolate, *receiver)) {
if (!HasOnlySimpleElements(isolate, *receiver) ||
!visitor->has_simple_elements()) {
return IterateElementsSlow(isolate, receiver, length, visitor);
}
Handle<JSObject> array = Handle<JSObject>::cast(receiver);
......@@ -1476,7 +1485,7 @@ Object* Slow_ArrayConcat(Arguments* args, Handle<Object> species,
// In case of failure, fall through.
}
Handle<Object> storage;
Handle<HeapObject> storage;
if (fast_case) {
// The backing storage array must have non-existing elements to preserve
// holes across concat operations.
......@@ -1494,7 +1503,7 @@ Object* Slow_ArrayConcat(Arguments* args, Handle<Object> species,
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, storage_object,
Execution::New(isolate, species, species, 1, &length));
storage = storage_object;
storage = Handle<HeapObject>::cast(storage_object);
}
ArrayConcatVisitor visitor(isolate, storage, fast_case);
......
......@@ -146,8 +146,11 @@ class SamplingAllocationObserver : public AllocationObserver {
void Step(int bytes_allocated, Address soon_object, size_t size) override {
USE(heap_);
DCHECK(heap_->gc_state() == Heap::NOT_IN_GC);
DCHECK(soon_object);
profiler_->SampleObject(soon_object, size);
if (soon_object) {
// TODO(ofrobots): it would be better to sample the next object rather
// than skipping this sample epoch if soon_object happens to be null.
profiler_->SampleObject(soon_object, size);
}
}
intptr_t GetNextStepSize() override { return GetNextSampleInterval(rate_); }
......
......@@ -31,7 +31,7 @@ enum CategoryGroupEnabledFlags {
kEnabledForETWExport_CategoryGroupEnabledFlags = 1 << 3,
};
// By default, const char* asrgument values are assumed to have long-lived scope
// By default, const char* argument values are assumed to have long-lived scope
// and will not be copied. Use this macro to force a const char* to be copied.
#define TRACE_STR_COPY(str) v8::internal::tracing::TraceStringWithCopy(str)
......
......@@ -6,8 +6,6 @@
topic the document will describe (e.g., `child_process`).
* Filenames should be **lowercase**.
* Some files, such as top-level markdown files, are exceptions.
* Older files may use the `.markdown` extension. These may be ported to `.md`
at will. **Prefer `.md` for all new documents.**
* Documents should be word-wrapped at 80 characters.
* The formatting described in `.editorconfig` is preferred.
* A [plugin][] is available for some editors to automatically apply these
......@@ -61,8 +59,16 @@
* References to constructor instances should use camelCase.
* References to methods should be used with parentheses: for example,
`socket.end()` instead of `socket.end`.
* Function arguments or object properties should use the following format:
* <code>* \`name\` {type|type2} Optional description. \*\*Default:\*\* \`defaultValue\`</code>
* E.g. <code>* `byteOffset` {integer} Index of first byte to expose. **Default:** `0`</code>
* The `type` should refer to a Node.js type or a [JavaScript type][]
* Function returns should use the following format:
* <code>* Returns: {type|type2} Optional description.</code>
* E.g. <code>* Returns: {AsyncHook} A reference to `asyncHook`.</code>
[plugin]: http://editorconfig.org/#download
[Oxford comma]: https://en.wikipedia.org/wiki/Serial_comma
[Em dashes]: https://en.wikipedia.org/wiki/Dash#Em_dash
[Javascript type]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Grammar_and_types#Data_structures_and_types
[Oxford comma]: https://en.wikipedia.org/wiki/Serial_comma
[The New York Times Manual of Style and Usage]: https://en.wikipedia.org/wiki/The_New_York_Times_Manual_of_Style_and_Usage
[plugin]: http://editorconfig.org/#download
......@@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
<title>Index | Node.js v6.11.4 Documentation</title>
<title>Index | Node.js v6.12.0 Documentation</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato:400,700,400italic">
<link rel="stylesheet" href="assets/style.css">
<link rel="stylesheet" href="assets/sh.css">
......@@ -73,7 +73,7 @@
<div id="column1" data-id="_toc" class="interior">
<header>
<h1>Node.js v6.11.4 Documentation</h1>
<h1>Node.js v6.12.0 Documentation</h1>
<div id="gtoc">
<ul>
<li>
......
......@@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
<title>C/C++ Addons | Node.js v6.11.4 Documentation</title>
<title>C/C++ Addons | Node.js v6.12.0 Documentation</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato:400,700,400italic">
<link rel="stylesheet" href="assets/style.css">
<link rel="stylesheet" href="assets/sh.css">
......@@ -73,7 +73,7 @@
<div id="column1" data-id="addons" class="interior">
<header>
<h1>Node.js v6.11.4 Documentation</h1>
<h1>Node.js v6.12.0 Documentation</h1>
<div id="gtoc">
<ul>
<li>
......@@ -88,7 +88,8 @@
<li class="version-picker">
<a href="#">View another version <span>&#x25bc;</span></a>
<ol class="version-picker"><li><a href="https://nodejs.org/docs/latest-v8.x/api/addons.html">8.x</a></li>
<ol class="version-picker"><li><a href="https://nodejs.org/docs/latest-v9.x/api/addons.html">9.x</a></li>
<li><a href="https://nodejs.org/docs/latest-v8.x/api/addons.html">8.x <b>LTS</b></a></li>
<li><a href="https://nodejs.org/docs/latest-v7.x/api/addons.html">7.x</a></li>
<li><a href="https://nodejs.org/docs/latest-v6.x/api/addons.html">6.x <b>LTS</b></a></li>
<li><a href="https://nodejs.org/docs/latest-v5.x/api/addons.html">5.x</a></li>
......@@ -1041,8 +1042,8 @@ has ended but before the JavaScript VM is terminated and Node.js shuts down.
&quot;AtExit&quot; hooks are registered using the <code>node::AtExit</code> API.</p>
<h4>void AtExit(callback, args)<span><a class="mark" href="#addons_void_atexit_callback_args" id="addons_void_atexit_callback_args">#</a></span></h4>
<div class="signature"><ul>
<li><code>callback</code>: <code>void (*)(void*)</code> - A pointer to the function to call at exit.</li>
<li><code>args</code>: <code>void*</code> - A pointer to pass to the callback at exit.</li>
<li><code>callback</code> <span class="type">&lt;void (*)(void*)&gt;</span> A pointer to the function to call at exit.</li>
<li><code>args</code> <span class="type">&lt;void*&gt;</span> A pointer to pass to the callback at exit.</li>
</ul>
</div><p>Registers exit hooks that run after the event loop has ended but before the VM
is killed.</p>
......
......@@ -99,7 +99,7 @@
{
"textRaw": "void AtExit(callback, args)",
"name": "void_atexit(callback,_args)",
"desc": "<ul>\n<li><code>callback</code>: <code>void (*)(void*)</code> - A pointer to the function to call at exit.</li>\n<li><code>args</code>: <code>void*</code> - A pointer to pass to the callback at exit.</li>\n</ul>\n<p>Registers exit hooks that run after the event loop has ended but before the VM\nis killed.</p>\n<p>AtExit takes two parameters: a pointer to a callback function to run at exit,\nand a pointer to untyped context data to be passed to that callback.</p>\n<p>Callbacks are run in last-in first-out order.</p>\n<p>The following <code>addon.cc</code> implements AtExit:</p>\n<pre><code class=\"lang-cpp\">// addon.cc\n#include &lt;assert.h&gt;\n#include &lt;stdlib.h&gt;\n#include &lt;node.h&gt;\n\nnamespace demo {\n\nusing node::AtExit;\nusing v8::HandleScope;\nusing v8::Isolate;\nusing v8::Local;\nusing v8::Object;\n\nstatic char cookie[] = &quot;yum yum&quot;;\nstatic int at_exit_cb1_called = 0;\nstatic int at_exit_cb2_called = 0;\n\nstatic void at_exit_cb1(void* arg) {\n Isolate* isolate = static_cast&lt;Isolate*&gt;(arg);\n HandleScope scope(isolate);\n Local&lt;Object&gt; obj = Object::New(isolate);\n assert(!obj.IsEmpty()); // assert VM is still alive\n assert(obj-&gt;IsObject());\n at_exit_cb1_called++;\n}\n\nstatic void at_exit_cb2(void* arg) {\n assert(arg == static_cast&lt;void*&gt;(cookie));\n at_exit_cb2_called++;\n}\n\nstatic void sanity_check(void*) {\n assert(at_exit_cb1_called == 1);\n assert(at_exit_cb2_called == 2);\n}\n\nvoid init(Local&lt;Object&gt; exports) {\n AtExit(at_exit_cb2, cookie);\n AtExit(at_exit_cb2, cookie);\n AtExit(at_exit_cb1, exports-&gt;GetIsolate());\n AtExit(sanity_check);\n}\n\nNODE_MODULE(addon, init)\n\n} // namespace demo\n</code></pre>\n<p>Test in JavaScript by running:</p>\n<pre><code class=\"lang-js\">// test.js\nrequire(&#39;./build/Release/addon&#39;);\n</code></pre>\n",
"desc": "<ul>\n<li><code>callback</code> {void (*)(void*)} A pointer to the function to call at exit.</li>\n<li><code>args</code> {void*} A pointer to pass to the callback at exit.</li>\n</ul>\n<p>Registers exit hooks that run after the event loop has ended but before the VM\nis killed.</p>\n<p>AtExit takes two parameters: a pointer to a callback function to run at exit,\nand a pointer to untyped context data to be passed to that callback.</p>\n<p>Callbacks are run in last-in first-out order.</p>\n<p>The following <code>addon.cc</code> implements AtExit:</p>\n<pre><code class=\"lang-cpp\">// addon.cc\n#include &lt;assert.h&gt;\n#include &lt;stdlib.h&gt;\n#include &lt;node.h&gt;\n\nnamespace demo {\n\nusing node::AtExit;\nusing v8::HandleScope;\nusing v8::Isolate;\nusing v8::Local;\nusing v8::Object;\n\nstatic char cookie[] = &quot;yum yum&quot;;\nstatic int at_exit_cb1_called = 0;\nstatic int at_exit_cb2_called = 0;\n\nstatic void at_exit_cb1(void* arg) {\n Isolate* isolate = static_cast&lt;Isolate*&gt;(arg);\n HandleScope scope(isolate);\n Local&lt;Object&gt; obj = Object::New(isolate);\n assert(!obj.IsEmpty()); // assert VM is still alive\n assert(obj-&gt;IsObject());\n at_exit_cb1_called++;\n}\n\nstatic void at_exit_cb2(void* arg) {\n assert(arg == static_cast&lt;void*&gt;(cookie));\n at_exit_cb2_called++;\n}\n\nstatic void sanity_check(void*) {\n assert(at_exit_cb1_called == 1);\n assert(at_exit_cb2_called == 2);\n}\n\nvoid init(Local&lt;Object&gt; exports) {\n AtExit(at_exit_cb2, cookie);\n AtExit(at_exit_cb2, cookie);\n AtExit(at_exit_cb1, exports-&gt;GetIsolate());\n AtExit(sanity_check);\n}\n\nNODE_MODULE(addon, init)\n\n} // namespace demo\n</code></pre>\n<p>Test in JavaScript by running:</p>\n<pre><code class=\"lang-js\">// test.js\nrequire(&#39;./build/Release/addon&#39;);\n</code></pre>\n",
"type": "module",
"displayName": "void AtExit(callback, args)"
}
......
......@@ -1040,8 +1040,8 @@ has ended but before the JavaScript VM is terminated and Node.js shuts down.
#### void AtExit(callback, args)
* `callback`: `void (*)(void*)` - A pointer to the function to call at exit.
* `args`: `void*` - A pointer to pass to the callback at exit.
* `callback` {void (\*)(void\*)} A pointer to the function to call at exit.
* `args` {void\*} A pointer to pass to the callback at exit.
Registers exit hooks that run after the event loop has ended but before the VM
is killed.
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.