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

Commit

Permalink
meta: merge node/master into node-chakracore/master
Browse files Browse the repository at this point in the history
Merge b3127cd as of 2017-11-16
This commit was automatically generated. For any problems, please contact jackhorton

Reviewed-By: Jack Horton <[email protected]>
  • Loading branch information
chakrabot committed Nov 17, 2017
2 parents 1bbca33 + b3127cd commit 2515ee1
Show file tree
Hide file tree
Showing 37 changed files with 893 additions and 173 deletions.
17 changes: 17 additions & 0 deletions CPP_STYLE_GUIDE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# C++ Style Guide

## Table of Contents

* [Left-leaning (C++ style) asterisks for pointer declarations](#left-leaning-c-style-asterisks-for-pointer-declarations)
* [2 spaces of indentation for blocks or bodies of conditionals](#2-spaces-of-indentation-for-blocks-or-bodies-of-conditionals)
* [4 spaces of indentation for statement continuations](#4-spaces-of-indentation-for-statement-continuations)
* [Align function arguments vertically](#align-function-arguments-vertically)
* [Initialization lists](#initialization-lists)
* [CamelCase for methods, functions and classes](#camelcase-for-methods-functions-and-classes)
* [snake\_case for local variables and parameters](#snake_case-for-local-variables-and-parameters)
* [snake\_case\_ for private class fields](#snake_case_-for-private-class-fields)
* [Space after `template`](#space-after-template)
* [Type casting](#type-casting)
* [Memory allocation](#memory-allocation)
* [`nullptr` instead of `NULL` or `0`](#nullptr-instead-of-null-or-0)
* [Do not include `*.h` if `*-inl.h` has already been included](#do-not-include-h-if--inlh-has-already-been-included)
* [Avoid throwing JavaScript errors in nested C++ methods](#avoid-throwing-javascript-errors-in-nested-c-methods)

Unfortunately, the C++ linter (based on
[Google’s `cpplint`](https://github.com/google/styleguide)), which can be run
explicitly via `make lint-cpp`, does not currently catch a lot of rules that are
Expand Down
15 changes: 5 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -205,23 +205,18 @@ v8:
tools/make-v8.sh
$(MAKE) -C deps/v8 $(V8_ARCH).$(BUILDTYPE_LOWER) $(V8_BUILD_OPTIONS)

ifeq ($(NODE_TARGET_TYPE),static_library)
test: all
$(MAKE) cctest
else
test: all
$(MAKE) build-addons
$(MAKE) build-addons-napi
$(MAKE) doc-only
$(MAKE) lint
$(MAKE) cctest
$(MAKE) -s build-addons
$(MAKE) -s build-addons-napi
$(MAKE) -s doc-only
$(MAKE) -s lint
$(MAKE) -s cctest
$(PYTHON) tools/test.py --mode=release --flaky-tests=$(FLAKY_TESTS) -J \
$(CI_ASYNC_HOOKS) \
$(CI_JS_SUITES) \
$(CI_NATIVE_SUITES) \
$(CI_DOC) \
known_issues
endif

# For a quick test, does not run linter or build doc
test-only: all
Expand Down
4 changes: 2 additions & 2 deletions common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@
'V8_BASE': '<(PRODUCT_DIR)/libv8_base.a',
}],
['openssl_fips != ""', {
'OPENSSL_PRODUCT': 'libcrypto.a',
'OPENSSL_PRODUCT': '<(STATIC_LIB_PREFIX)crypto<(STATIC_LIB_SUFFIX)',
}, {
'OPENSSL_PRODUCT': 'libopenssl.a',
'OPENSSL_PRODUCT': '<(STATIC_LIB_PREFIX)openssl<(STATIC_LIB_SUFFIX)',
}],
['OS=="mac"', {
'clang%': 1,
Expand Down
2 changes: 0 additions & 2 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -1512,8 +1512,6 @@ config = {
'BUILDTYPE': 'Debug' if options.debug else 'Release',
'USE_XCODE': str(int(options.use_xcode or 0)),
'PYTHON': sys.executable,
'NODE_TARGET_TYPE': variables['node_target_type'] if options.enable_static \
else '',
}

if options.prefix:
Expand Down
79 changes: 75 additions & 4 deletions doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -2028,8 +2028,21 @@ changes:
* `err` {Error}
* `resolvedPath` {string|Buffer}

Asynchronous realpath(3). The `callback` gets two arguments `(err,
resolvedPath)`. May use `process.cwd` to resolve relative paths.
Asynchronously computes the canonical pathname by resolving `.`, `..` and
symbolic links.

Note that "canonical" does not mean "unique": hard links and bind mounts can
expose a file system entity through many pathnames.

This function behaves like realpath(3), with some exceptions:

1. No case conversion is performed on case-insensitive file systems.

2. The maximum number of symbolic links is platform-independent and generally
(much) higher than what the native realpath(3) implementation supports.

The `callback` gets two arguments `(err, resolvedPath)`. May use `process.cwd`
to resolve relative paths.

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

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

## fs.realpath.native(path[, options], callback)
<!-- YAML
added: v9.2.0
-->

* `path` {string|Buffer|URL}
* `options` {string|Object}
* `encoding` {string} **Default:** `'utf8'`
* `callback` {Function}
* `err` {Error}
* `resolvedPath` {string|Buffer}

Asynchronous realpath(3).

The `callback` gets two arguments `(err, resolvedPath)`.

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

The optional `options` argument can be a string specifying an encoding, or an
object with an `encoding` property specifying the character encoding to use for
the path passed to the callback. If the `encoding` is set to `'buffer'`,
the path returned will be passed as a `Buffer` object.

*Note*: On Linux, when Node.js is linked against musl libc, the procfs file
system must be mounted on `/proc` in order for this function to work. Glibc
does not have this restriction.

## fs.realpathSync(path[, options])
<!-- YAML
added: v0.1.31
Expand All @@ -2065,9 +2105,18 @@ changes:
* `options` {string|Object}
* `encoding` {string} **Default:** `'utf8'`

Synchronous realpath(3). Returns the resolved path.
Synchronously computes the canonical pathname by resolving `.`, `..` and
symbolic links.

Only paths that can be converted to UTF8 strings are supported.
Note that "canonical" does not mean "unique": hard links and bind mounts can
expose a file system entity through many pathnames.

This function behaves like realpath(3), with some exceptions:

1. No case conversion is performed on case-insensitive file systems.

2. The maximum number of symbolic links is platform-independent and generally
(much) higher than what the native realpath(3) implementation supports.

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

## fs.realpathSync.native(path[, options])
<!-- YAML
added: v9.2.0
-->

* `path` {string|Buffer|URL}
* `options` {string|Object}
* `encoding` {string} **Default:** `'utf8'`

Synchronous realpath(3).

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

The optional `options` argument can be a string specifying an encoding, or an
object with an `encoding` property specifying the character encoding to use for
the path passed to the callback. If the `encoding` is set to `'buffer'`,
the path returned will be passed as a `Buffer` object.

*Note*: On Linux, when Node.js is linked against musl libc, the procfs file
system must be mounted on `/proc` in order for this function to work. Glibc
does not have this restriction.

## fs.rename(oldPath, newPath, callback)
<!-- YAML
added: v0.0.2
Expand Down
4 changes: 2 additions & 2 deletions doc/api/tracing.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ Node.js application.

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

```txt
node --trace-events-enabled --trace-event-categories v8,node server.js
node --trace-events-enabled --trace-event-categories v8,node,node.async_hooks server.js
```

Running Node.js with tracing enabled will produce log files that can be opened
Expand Down
3 changes: 1 addition & 2 deletions lib/_http_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const { methods, HTTPParser } = binding;
const FreeList = require('internal/freelist');
const { ondrain } = require('internal/http');
const incoming = require('_http_incoming');
const { emitDestroy } = require('async_hooks');
const {
IncomingMessage,
readStart,
Expand Down Expand Up @@ -218,7 +217,7 @@ function freeParser(parser, req, socket) {
} else {
// Since the Parser destructor isn't going to run the destroy() callbacks
// it needs to be triggered manually.
emitDestroy(parser.getAsyncId());
parser.free();
}
}
if (req) {
Expand Down
4 changes: 2 additions & 2 deletions lib/_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,13 +373,13 @@ function connectionListener(socket) {
function updateOutgoingData(socket, state, delta) {
state.outgoingData += delta;
if (socket._paused &&
state.outgoingData < socket.writeHWM) {
state.outgoingData < socket.writableHighWaterMark) {
return socketOnDrain(socket, state);
}
}

function socketOnDrain(socket, state) {
var needPause = state.outgoingData > socket.writeHWM;
var needPause = state.outgoingData > socket.writableHighWaterMark;

// If we previously paused, then start reading again.
if (socket._paused && !needPause) {
Expand Down
1 change: 1 addition & 0 deletions lib/internal/bootstrap_node.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
if (global.__coverage__)
NativeModule.require('internal/process/write-coverage').setup();

NativeModule.require('internal/trace_events_async_hooks').setup();
NativeModule.require('internal/inspector_async_hook').setup();
NativeModule.require('trace_mgr'); //ENABLE_TTD;

Expand Down
67 changes: 67 additions & 0 deletions lib/internal/trace_events_async_hooks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
'use strict';

const trace_events = process.binding('trace_events');
const async_wrap = process.binding('async_wrap');
const async_hooks = require('async_hooks');

// Use small letters such that chrome://traceing groups by the name.
// The behaviour is not only useful but the same as the events emitted using
// the specific C++ macros.
const BEFORE_EVENT = 'b'.charCodeAt(0);
const END_EVENT = 'e'.charCodeAt(0);

// In trace_events it is not only the id but also the name that needs to be
// repeated. Since async_hooks doesn't expose the provider type in the
// non-init events, use a map to manually map the asyncId to the type name.
const typeMemory = new Map();

// It is faster to emit trace_events directly from C++. Thus, this happens in
// async_wrap.cc. However, events emitted from the JavaScript API or the
// Embedder C++ API can't be emitted from async_wrap.cc. Thus they are
// emitted using the JavaScript API. To prevent emitting the same event
// twice the async_wrap.Providers list is used to filter the events.
const nativeProviders = new Set(Object.keys(async_wrap.Providers));

const hook = async_hooks.createHook({
init(asyncId, type, triggerAsyncId, resource) {
if (nativeProviders.has(type)) return;

typeMemory.set(asyncId, type);
trace_events.emit(BEFORE_EVENT, 'node.async_hooks',
type, asyncId, 'triggerAsyncId', triggerAsyncId);
},

before(asyncId) {
const type = typeMemory.get(asyncId);
if (type === undefined) return;

trace_events.emit(BEFORE_EVENT, 'node.async_hooks',
type + '_CALLBACK', asyncId);
},

after(asyncId) {
const type = typeMemory.get(asyncId);
if (type === undefined) return;

trace_events.emit(END_EVENT, 'node.async_hooks',
type + '_CALLBACK', asyncId);
},

destroy(asyncId) {
const type = typeMemory.get(asyncId);
if (type === undefined) return;

trace_events.emit(END_EVENT, 'node.async_hooks',
type, asyncId);

// cleanup asyncId to type map
typeMemory.delete(asyncId);
}
});


exports.setup = function() {
if (trace_events.categoryGroupEnabled('node.async_hooks')) {
hook.enable();
}
};
Loading

0 comments on commit 2515ee1

Please sign in to comment.