Skip to content
This repository was archived by the owner on Oct 15, 2020. It is now read-only.

Commit 2515ee1

Browse files
committed
meta: merge node/master into node-chakracore/master
Merge b3127cd as of 2017-11-16 This commit was automatically generated. For any problems, please contact jackhorton Reviewed-By: Jack Horton <jahorto@microsoft.com>
2 parents 1bbca33 + b3127cd commit 2515ee1

37 files changed

+893
-173
lines changed

CPP_STYLE_GUIDE.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
# C++ Style Guide
22

3+
## Table of Contents
4+
5+
* [Left-leaning (C++ style) asterisks for pointer declarations](#left-leaning-c-style-asterisks-for-pointer-declarations)
6+
* [2 spaces of indentation for blocks or bodies of conditionals](#2-spaces-of-indentation-for-blocks-or-bodies-of-conditionals)
7+
* [4 spaces of indentation for statement continuations](#4-spaces-of-indentation-for-statement-continuations)
8+
* [Align function arguments vertically](#align-function-arguments-vertically)
9+
* [Initialization lists](#initialization-lists)
10+
* [CamelCase for methods, functions and classes](#camelcase-for-methods-functions-and-classes)
11+
* [snake\_case for local variables and parameters](#snake_case-for-local-variables-and-parameters)
12+
* [snake\_case\_ for private class fields](#snake_case_-for-private-class-fields)
13+
* [Space after `template`](#space-after-template)
14+
* [Type casting](#type-casting)
15+
* [Memory allocation](#memory-allocation)
16+
* [`nullptr` instead of `NULL` or `0`](#nullptr-instead-of-null-or-0)
17+
* [Do not include `*.h` if `*-inl.h` has already been included](#do-not-include-h-if--inlh-has-already-been-included)
18+
* [Avoid throwing JavaScript errors in nested C++ methods](#avoid-throwing-javascript-errors-in-nested-c-methods)
19+
320
Unfortunately, the C++ linter (based on
421
[Google’s `cpplint`](https://github.com/google/styleguide)), which can be run
522
explicitly via `make lint-cpp`, does not currently catch a lot of rules that are

Makefile

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -205,23 +205,18 @@ v8:
205205
tools/make-v8.sh
206206
$(MAKE) -C deps/v8 $(V8_ARCH).$(BUILDTYPE_LOWER) $(V8_BUILD_OPTIONS)
207207

208-
ifeq ($(NODE_TARGET_TYPE),static_library)
209208
test: all
210-
$(MAKE) cctest
211-
else
212-
test: all
213-
$(MAKE) build-addons
214-
$(MAKE) build-addons-napi
215-
$(MAKE) doc-only
216-
$(MAKE) lint
217-
$(MAKE) cctest
209+
$(MAKE) -s build-addons
210+
$(MAKE) -s build-addons-napi
211+
$(MAKE) -s doc-only
212+
$(MAKE) -s lint
213+
$(MAKE) -s cctest
218214
$(PYTHON) tools/test.py --mode=release --flaky-tests=$(FLAKY_TESTS) -J \
219215
$(CI_ASYNC_HOOKS) \
220216
$(CI_JS_SUITES) \
221217
$(CI_NATIVE_SUITES) \
222218
$(CI_DOC) \
223219
known_issues
224-
endif
225220

226221
# For a quick test, does not run linter or build doc
227222
test-only: all

common.gypi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@
6969
'V8_BASE': '<(PRODUCT_DIR)/libv8_base.a',
7070
}],
7171
['openssl_fips != ""', {
72-
'OPENSSL_PRODUCT': 'libcrypto.a',
72+
'OPENSSL_PRODUCT': '<(STATIC_LIB_PREFIX)crypto<(STATIC_LIB_SUFFIX)',
7373
}, {
74-
'OPENSSL_PRODUCT': 'libopenssl.a',
74+
'OPENSSL_PRODUCT': '<(STATIC_LIB_PREFIX)openssl<(STATIC_LIB_SUFFIX)',
7575
}],
7676
['OS=="mac"', {
7777
'clang%': 1,

configure

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,8 +1512,6 @@ config = {
15121512
'BUILDTYPE': 'Debug' if options.debug else 'Release',
15131513
'USE_XCODE': str(int(options.use_xcode or 0)),
15141514
'PYTHON': sys.executable,
1515-
'NODE_TARGET_TYPE': variables['node_target_type'] if options.enable_static \
1516-
else '',
15171515
}
15181516

15191517
if options.prefix:

doc/api/fs.md

Lines changed: 75 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2028,8 +2028,21 @@ changes:
20282028
* `err` {Error}
20292029
* `resolvedPath` {string|Buffer}
20302030

2031-
Asynchronous realpath(3). The `callback` gets two arguments `(err,
2032-
resolvedPath)`. May use `process.cwd` to resolve relative paths.
2031+
Asynchronously computes the canonical pathname by resolving `.`, `..` and
2032+
symbolic links.
2033+
2034+
Note that "canonical" does not mean "unique": hard links and bind mounts can
2035+
expose a file system entity through many pathnames.
2036+
2037+
This function behaves like realpath(3), with some exceptions:
2038+
2039+
1. No case conversion is performed on case-insensitive file systems.
2040+
2041+
2. The maximum number of symbolic links is platform-independent and generally
2042+
(much) higher than what the native realpath(3) implementation supports.
2043+
2044+
The `callback` gets two arguments `(err, resolvedPath)`. May use `process.cwd`
2045+
to resolve relative paths.
20332046

20342047
Only paths that can be converted to UTF8 strings are supported.
20352048

@@ -2041,6 +2054,33 @@ the path returned will be passed as a `Buffer` object.
20412054
*Note*: If `path` resolves to a socket or a pipe, the function will return a
20422055
system dependent name for that object.
20432056

2057+
## fs.realpath.native(path[, options], callback)
2058+
<!-- YAML
2059+
added: v9.2.0
2060+
-->
2061+
2062+
* `path` {string|Buffer|URL}
2063+
* `options` {string|Object}
2064+
* `encoding` {string} **Default:** `'utf8'`
2065+
* `callback` {Function}
2066+
* `err` {Error}
2067+
* `resolvedPath` {string|Buffer}
2068+
2069+
Asynchronous realpath(3).
2070+
2071+
The `callback` gets two arguments `(err, resolvedPath)`.
2072+
2073+
Only paths that can be converted to UTF8 strings are supported.
2074+
2075+
The optional `options` argument can be a string specifying an encoding, or an
2076+
object with an `encoding` property specifying the character encoding to use for
2077+
the path passed to the callback. If the `encoding` is set to `'buffer'`,
2078+
the path returned will be passed as a `Buffer` object.
2079+
2080+
*Note*: On Linux, when Node.js is linked against musl libc, the procfs file
2081+
system must be mounted on `/proc` in order for this function to work. Glibc
2082+
does not have this restriction.
2083+
20442084
## fs.realpathSync(path[, options])
20452085
<!-- YAML
20462086
added: v0.1.31
@@ -2065,9 +2105,18 @@ changes:
20652105
* `options` {string|Object}
20662106
* `encoding` {string} **Default:** `'utf8'`
20672107

2068-
Synchronous realpath(3). Returns the resolved path.
2108+
Synchronously computes the canonical pathname by resolving `.`, `..` and
2109+
symbolic links.
20692110

2070-
Only paths that can be converted to UTF8 strings are supported.
2111+
Note that "canonical" does not mean "unique": hard links and bind mounts can
2112+
expose a file system entity through many pathnames.
2113+
2114+
This function behaves like realpath(3), with some exceptions:
2115+
2116+
1. No case conversion is performed on case-insensitive file systems.
2117+
2118+
2. The maximum number of symbolic links is platform-independent and generally
2119+
(much) higher than what the native realpath(3) implementation supports.
20712120

20722121
The optional `options` argument can be a string specifying an encoding, or an
20732122
object with an `encoding` property specifying the character encoding to use for
@@ -2077,6 +2126,28 @@ will be passed as a `Buffer` object.
20772126
*Note*: If `path` resolves to a socket or a pipe, the function will return a
20782127
system dependent name for that object.
20792128

2129+
## fs.realpathSync.native(path[, options])
2130+
<!-- YAML
2131+
added: v9.2.0
2132+
-->
2133+
2134+
* `path` {string|Buffer|URL}
2135+
* `options` {string|Object}
2136+
* `encoding` {string} **Default:** `'utf8'`
2137+
2138+
Synchronous realpath(3).
2139+
2140+
Only paths that can be converted to UTF8 strings are supported.
2141+
2142+
The optional `options` argument can be a string specifying an encoding, or an
2143+
object with an `encoding` property specifying the character encoding to use for
2144+
the path passed to the callback. If the `encoding` is set to `'buffer'`,
2145+
the path returned will be passed as a `Buffer` object.
2146+
2147+
*Note*: On Linux, when Node.js is linked against musl libc, the procfs file
2148+
system must be mounted on `/proc` in order for this function to work. Glibc
2149+
does not have this restriction.
2150+
20802151
## fs.rename(oldPath, newPath, callback)
20812152
<!-- YAML
20822153
added: v0.0.2

doc/api/tracing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ Node.js application.
88

99
The set of categories for which traces are recorded can be specified using the
1010
`--trace-event-categories` flag followed by a list of comma separated category names.
11-
By default the `node` and `v8` categories are enabled.
11+
By default the `node`, `node.async_hooks`, and `v8` categories are enabled.
1212

1313
```txt
14-
node --trace-events-enabled --trace-event-categories v8,node server.js
14+
node --trace-events-enabled --trace-event-categories v8,node,node.async_hooks server.js
1515
```
1616

1717
Running Node.js with tracing enabled will produce log files that can be opened

lib/_http_common.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ const { methods, HTTPParser } = binding;
2727
const FreeList = require('internal/freelist');
2828
const { ondrain } = require('internal/http');
2929
const incoming = require('_http_incoming');
30-
const { emitDestroy } = require('async_hooks');
3130
const {
3231
IncomingMessage,
3332
readStart,
@@ -218,7 +217,7 @@ function freeParser(parser, req, socket) {
218217
} else {
219218
// Since the Parser destructor isn't going to run the destroy() callbacks
220219
// it needs to be triggered manually.
221-
emitDestroy(parser.getAsyncId());
220+
parser.free();
222221
}
223222
}
224223
if (req) {

lib/_http_server.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,13 +373,13 @@ function connectionListener(socket) {
373373
function updateOutgoingData(socket, state, delta) {
374374
state.outgoingData += delta;
375375
if (socket._paused &&
376-
state.outgoingData < socket.writeHWM) {
376+
state.outgoingData < socket.writableHighWaterMark) {
377377
return socketOnDrain(socket, state);
378378
}
379379
}
380380

381381
function socketOnDrain(socket, state) {
382-
var needPause = state.outgoingData > socket.writeHWM;
382+
var needPause = state.outgoingData > socket.writableHighWaterMark;
383383

384384
// If we previously paused, then start reading again.
385385
if (socket._paused && !needPause) {

lib/internal/bootstrap_node.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
if (global.__coverage__)
6060
NativeModule.require('internal/process/write-coverage').setup();
6161

62+
NativeModule.require('internal/trace_events_async_hooks').setup();
6263
NativeModule.require('internal/inspector_async_hook').setup();
6364
NativeModule.require('trace_mgr'); //ENABLE_TTD;
6465

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
'use strict';
2+
3+
const trace_events = process.binding('trace_events');
4+
const async_wrap = process.binding('async_wrap');
5+
const async_hooks = require('async_hooks');
6+
7+
// Use small letters such that chrome://traceing groups by the name.
8+
// The behaviour is not only useful but the same as the events emitted using
9+
// the specific C++ macros.
10+
const BEFORE_EVENT = 'b'.charCodeAt(0);
11+
const END_EVENT = 'e'.charCodeAt(0);
12+
13+
// In trace_events it is not only the id but also the name that needs to be
14+
// repeated. Since async_hooks doesn't expose the provider type in the
15+
// non-init events, use a map to manually map the asyncId to the type name.
16+
const typeMemory = new Map();
17+
18+
// It is faster to emit trace_events directly from C++. Thus, this happens in
19+
// async_wrap.cc. However, events emitted from the JavaScript API or the
20+
// Embedder C++ API can't be emitted from async_wrap.cc. Thus they are
21+
// emitted using the JavaScript API. To prevent emitting the same event
22+
// twice the async_wrap.Providers list is used to filter the events.
23+
const nativeProviders = new Set(Object.keys(async_wrap.Providers));
24+
25+
const hook = async_hooks.createHook({
26+
init(asyncId, type, triggerAsyncId, resource) {
27+
if (nativeProviders.has(type)) return;
28+
29+
typeMemory.set(asyncId, type);
30+
trace_events.emit(BEFORE_EVENT, 'node.async_hooks',
31+
type, asyncId, 'triggerAsyncId', triggerAsyncId);
32+
},
33+
34+
before(asyncId) {
35+
const type = typeMemory.get(asyncId);
36+
if (type === undefined) return;
37+
38+
trace_events.emit(BEFORE_EVENT, 'node.async_hooks',
39+
type + '_CALLBACK', asyncId);
40+
},
41+
42+
after(asyncId) {
43+
const type = typeMemory.get(asyncId);
44+
if (type === undefined) return;
45+
46+
trace_events.emit(END_EVENT, 'node.async_hooks',
47+
type + '_CALLBACK', asyncId);
48+
},
49+
50+
destroy(asyncId) {
51+
const type = typeMemory.get(asyncId);
52+
if (type === undefined) return;
53+
54+
trace_events.emit(END_EVENT, 'node.async_hooks',
55+
type, asyncId);
56+
57+
// cleanup asyncId to type map
58+
typeMemory.delete(asyncId);
59+
}
60+
});
61+
62+
63+
exports.setup = function() {
64+
if (trace_events.categoryGroupEnabled('node.async_hooks')) {
65+
hook.enable();
66+
}
67+
};

0 commit comments

Comments
 (0)