0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-29 23:16:30 +01:00
Commit Graph

350 Commits

Author SHA1 Message Date
Yihong Wang
8680bb9f1a
src: explicitly register built-in modules
Previously, built-in modules are registered before main() via
__attribute__((constructor)) mechanism in GCC and similiar
mechanism in MSVC. This causes some issues when node is built as
static library. Calling module registration function for built-in
modules in node::Init() helps to avoid the issues.

Signed-off-by: Yihong Wang <yh.wang@ibm.com>
PR-URL: https://github.com/nodejs/node/pull/16565
Refs: https://github.com/nodejs/node/pull/14986#issuecomment-332758206
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-11-13 23:17:34 +00:00
Daniel Bevenius
f5809d8e35 build: fix cctest compilation
Currently the cctest target compiles sources files even though they are
compiled for the node target. This is my fault as when I worked on the
task of getting the cctest to use the object files from the node target
I missed a few sources that were being included from node.gypi. This
also effects the build time as these sources are compiled twice.

This commit moves the conditions in question into the node target in
node.gyp. With this commit there should be no object files in
out/Release/obj.target/cctest/src/ (the path will vary depending on the
operating system being used).

PR-URL:https://github.com/nodejs/node/pull/16887
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2017-11-13 08:34:58 +01:00
Yihong Wang
b340c2d4dd
build: remove cctest extension
cctest has `so.59` extension when building node shared library in linux.
The appending is defined in node.gypi and the cctest target in node.gyp
includes node.gypi. Moving the appending from node.gypi to node target
in node.gyp fixes the issue.

Signed-off-by: Yihong Wang <yh.wang@ibm.com>

PR-URL: https://github.com/nodejs/node/pull/16680
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
2017-11-10 16:47:40 -05:00
Daniel Bevenius
cad1d1ff45 src: add openssl-system-ca-path configure option
The motivation for this commit is that we need to specify system CA
certificates when building node. While we are aware of the environment
variable NODE_EXTRA_CA_CERTS this is not a great solution as we build
an RPM and we also don't want users to be able to unset them.

The suggestion is to add a configure time property like this:

--openssl-system-ca-path=OPENSSL_SYSTEM_CA_PATH
             Use the specified path to system CA (PEM format) in
             addition to the OpenSSL supplied CA store or compiled-
             in Mozilla CA copy.

Usage example:
$ ./configure --openssl-system-ca-path=/etc/pki/tls/certs/ca-bundle.crt

This would add the specified CA certificates in addition to the ones
already being used.

PR-URL: https://github.com/nodejs/node/pull/16790
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2017-11-10 05:47:20 +01:00
Daniel Bevenius
18df171307 build: add missing comma in sources list
This commit adds a missing comma in the sources list. This effects at
least window which produces the following warning where trace_event.h
and src/util.h are concatenated:

Warning: Missing input files:
src\tracing\trace_event.hsrc\util.h

PR-URL: https://github.com/nodejs/node/pull/16613
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
2017-11-01 09:25:05 +01:00
Rich Trott
36732084db util,assert: expose util.isDeepStrictEqual()
Provide `util.isDeepStrictEqual()` that works like
`assert.deepStrictEqual()` but returns a boolean rather than throwing an
error.

Several userland modules have needed this functionality and implemented
it independently. This functionality already exists in Node.js core, so
this exposes it for use by modules. Modules that have needed this
functionality include `lodash`, `concordance` (used by `ava`), and
`qunit`.

PR-URL: https://github.com/nodejs/node/pull/16084
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2017-10-25 22:30:37 -07:00
Jon Moss
a82401e689
build: do not include deleted directory
`deps/uv/src/ares` hasn't existed since
libuv/libuv@41b1265af8 (mid 2012).

PR-URL: https://github.com/nodejs/node/pull/16384
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-10-24 22:30:31 -04:00
Anna Henningsen
542e94cdce
lib: move _stream_wrap into internals
This makes a subsequent possible deprecation easier.

PR-URL: https://github.com/nodejs/node/pull/16158
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2017-10-19 18:06:27 +02:00
guybedford
d21a11dc23 module: resolve and instantiate loader pipeline hooks
This enables a --loader flag for Node, which can provide custom
"resolve" and "dynamicInstantiate" methods for custom ES module
loading.

In the process, module providers have been converted from classes
into functions and the module APIs have been made to pass URL strings
over objects.

PR-URL: https://github.com/nodejs/node/pull/15445
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
2017-10-11 08:47:23 -05:00
Daniel Bevenius
0c9b267b1d src: rename perfctr_macros.py->noperfctr_macros.py
This commit renames perfctr_macros.py to be consistent with the other
macro python scripts nolttng_macros.py, and notrace_macros.py.

PR-URL: https://github.com/nodejs/node/pull/16100
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-10-11 07:42:02 +02:00
Timothy Gu
7907534a8d
lib: faster type checks for some types
PR-URL: https://github.com/nodejs/node/pull/15663
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Benedikt Meurer <benedikt.meurer@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-10-01 23:58:59 -03:00
Ben Noordhuis
3c777bb37f
deps: define BUILDING_NGHTTP2 during nghttp2 build
Define BUILDING_NGHTTP2 in order that NGHTTP2_EXTERN is properly defined
when building the nghttp2 static library.

Move NGHTTP2_STATICLIB out of node.gyp because it is a property of the
nghttp2 static library, not the node executable.

PR-URL: https://github.com/nodejs/node/pull/15487
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-09-24 12:17:03 -03:00
jBarz
c5eb5bfc2e
build: enable runtime linking
Enable runtime linking of shared objects. This will
allow loading of symbols using the RTLD_GLOBAL flag.

PR-URL: https://github.com/nodejs/node/pull/15286
Fixes: https://github.com/nodejs/node/issues/15243
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-09-20 09:12:14 -03:00
James M Snell
c75f87cc4c crypto: refactor the crypto module
* Split single monolithic file into multiple
* Make Certificate methods static
* Allow randomFill(Sync) to use any ArrayBufferView
* Use internal/errors throughout
* Improve arg validation in Hash/Hmac
* Doc updates

PR-URL: https://github.com/nodejs/node/pull/15231
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
2017-09-18 08:10:59 -07:00
XadillaX
468110b327
tls: deprecate parseCertString & move to internal
`tls.parseCertString()` exposed by accident. Now move this function to
`internal/tls` and mark the original one as deprecated.

PR-URL: https://github.com/nodejs/node/pull/14249
Refs: https://github.com/nodejs/node/issues/14193
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2017-09-13 16:54:35 -03:00
Mike Kaufman
35a526c1d4
http2,async-wrap: introduce AliasedBuffer class
This change introduces an AliasedBuffer class and updates asytnc-wrap
and http2 to use this class.

A common technique to optimize performance is to create a native buffer
and then map that native buffer to user space via JS array.  The runtime
can efficiently write to the native buffer without having to route
though JS, and the values being written are accessible from user space.

While efficient, this technique allows modifications to user
space memory w/out going through JS type system APIs, effectively
bypassing any monitoring the JS VM has in place to track program state
modifications.  The result is that monitors have an incorrect view
of prorgram state.

The AliasedBuffer class provides a future placeholder where this
technique can be used, but writes can still be observed.  To achieve
this, the node-chakra-core fork will add in appropriate tracking logic
in the AliasedBuffer's SetValue() method. Going forward, this class can
evolve to support more sophisticated mechanisms if necessary.

PR-URL: https://github.com/nodejs/node/pull/15077
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2017-09-13 17:44:24 +02:00
Bradley Farias
c8a389e19f module: Allow runMain to be ESM
This follows the EPS an allows the node CLI to have ESM as an entry point.
`node ./example.mjs`. A newer V8 is needed for `import()` so that is not
included. `import.meta` is still in specification stage so that also is not
included.

PR-URL: https://github.com/nodejs/node/pull/14369
Author: Bradley Farias <bradley.meck@gmail.com>
Author: Guy Bedford <guybedford@gmail.com>
Author: Jan Krems <jan.krems@groupon.com>
Author: Timothy Gu <timothygu99@gmail.com>
Author: Michaël Zasso <targos@protonmail.com>
Author: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2017-09-07 15:18:32 -05:00
Alexey Orlenko
689a643198 build: fix indentation in node.gyp
One line in node.gyp was indented using a mix of a tab and spaces,
convert it to all spaces.

PR-URL: https://github.com/nodejs/node/pull/15051
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-08-28 22:15:13 -07:00
James M Snell
67269fd7f3 perf_hooks: implementation of the perf timing API
An initial implementation of the Performance Timing API for Node.js.
This is the same Performance Timing API implemented by modern browsers
with a number of Node.js specific properties. The User Timing mark()
and measure() APIs are implemented, garbage collection timing, and
node startup milestone timing.

```js
const { performance } = require('perf_hooks');

performance.mark('A');
setTimeout(() => {
  performance.mark('B');
  performance.measure('A to B', 'A', 'B');
  const entry = performance.getEntriesByName('A to B', 'measure')[0];
  console.log(entry.duration);
}, 10000);
```

The implementation is at the native layer and makes use of uv_hrtime().
This should enable *eventual* integration with things like Tracing
and Inspection.

The implementation is extensible and should allow us to add new
performance entry types as we go (e.g. for measuring i/o perf,
etc).

Documentation and a test are provided.

PR-URL: https://github.com/nodejs/node/pull/14680
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2017-08-23 16:00:09 -07:00
Daniel Bevenius
58ca8c68c4 build: don't add libraries when --enable-static
Currently when building with --enabled-static the cctest target will
include libraries to be linked regardless. This commit adds a condition
to only add the libraries when dynamically linking.

This commit re-adds the previously reverted commit (be63c26e8c
"build: don't add libraries when --enable-static"). The reason that
commit failed was a mistake on my part where I moved the the list
into a variable (thinking that it was a simple change that would not
affect anything) and not re-running CI. But the list itself contains
variables used to enable differences in operating systems/compilers
where the object file locations vary.

PR-URL: https://github.com/nodejs/node/pull/14912
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Refael Ackermann <refack@gmail.com>
2017-08-21 10:02:35 +02:00
James M Snell
35f6e59dfc src: minor cleanup for node_revert
Make the revert related functions inline to eliminate the need
for node_revert.cc, prefix the constants and the def, other misc
cleanup

PR-URL: https://github.com/nodejs/node/pull/14864
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2017-08-18 15:02:12 -07:00
Anna Henningsen
491cc76871
src: use unordered_set instead of custom rb tree
Use a standard hash-based container instead of the custom included
red/black tree implementation. There is likely no noticeable
performance difference, and if there is one, it is very likely
to be an improvement.

PR-URL: https://github.com/nodejs/node/pull/14826
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2017-08-17 20:26:59 +02:00
Matt Loring
9e08695f85
src: Node implementation of v8::Platform
Node.js currently uses the V8 implementation of the DefaultPlatform
which schedules VM tasks on a V8 managed thread pool. Since the Node.js
event loop is not aware of these tasks, the Node.js process may exit
while there are outstanding VM tasks. This will become problematic once
asynchronous wasm compilation lands in V8.

This PR introduces a Node.js specific implementation of the v8::Platform
on top of libuv so that the event loop is aware of outstanding VM tasks.

PR-URL: https://github.com/nodejs/node/pull/14001
Fixes: https://github.com/nodejs/node/issues/3665
Fixes: https://github.com/nodejs/node/issues/8496
Fixes: https://github.com/nodejs/node/issues/12980
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2017-08-17 20:26:55 +02:00
Ben Noordhuis
aa011a111d Revert "build: don't add libraries when --enable-static"
Reverted for breaking the Windows build with the following error:

    LINK : fatal error LNK1181: cannot open input file
    'c:\workspace\node-compile-windows\label\win-vs2015\
    Release\obj\node\gen\node_javascript.o'

This reverts commit be63c26e8c.

PR-URL: https://github.com/nodejs/node/pull/14893
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
2017-08-17 16:11:29 +02:00
Miroslav Bajtoš
a0895ed6c4
inspector: enable async stack traces
Implement a special async_hooks listener that forwards information
about async tasks to V8Inspector asyncTask* API, thus enabling
DevTools feature "async stack traces".

The feature is enabled only on 64bit platforms due to a technical
limitation of V8 Inspector: inspector uses a pointer as a task id,
while async_hooks use 64bit numbers as ids.

To avoid performance penalty of async_hooks when not debugging,
the new listener is enabled only when the process enters a debug mode:

 - When the process is started with `--inspect` or `--inspect-brk`,
   the listener is enabled immediately and async stack traces
   lead all the way to the first tick of the event loop.

 - When the debug mode is enabled via SIGUSR1 or `_debugProcess()`,
   the listener is enabled together with the debugger. As a result,
   only async operations started after the signal was received
   will be correctly observed and reported to V8 Inspector. For example,
   a `setInterval()` called in the first tick of the event will not be
   shown in the async stack trace when the callback is invoked. This
   behaviour is consistent with Chrome DevTools.

Last but not least, this commit fixes handling of InspectorAgent's
internal property `enabled_` to ensure it's set back to `false`
after the debugger is deactivated (typically via `process._debugEnd()`).

Fixes: https://github.com/nodejs/node/issues/11370
PR-URL: https://github.com/nodejs/node/pull/13870
Reviewed-by: Timothy Gu <timothygu99@gmail.com>
Reviewed-by: Anna Henningsen <anna@addaleax.net>
2017-08-17 20:52:39 +08:00
Daniel Bevenius
be63c26e8c build: don't add libraries when --enable-static
Currently when building with --enabled-static the cctest target will
include libraries to be linked regardless. This commit adds a condition
to only add the libraries when dynamically linking.

PR-URL: https://github.com/nodejs/node/pull/14837
Fixes: https://github.com/nodejs/node/issues/13500
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-08-17 07:15:17 +02:00
James M Snell
949aec5c32 http2: handful of http/2 src cleanups
* inline more stuff. remove a node_http2_core.cc
* clean up debug messages
* simplify options code, and cleanup

PR-URL: https://github.com/nodejs/node/pull/14825
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2017-08-16 07:27:32 -07:00
Mudit Ameta
4a6b678070
os: add CIDR support
This patch adds support for CIDR notation to the output of the
`networkInterfaces()` method

PR-URL: https://github.com/nodejs/node/pull/14307
Fixes: https://github.com/nodejs/node/issues/14006
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
2017-08-14 15:43:10 -04:00
James M Snell
e71e71b513 http2: introducing HTTP/2
At long last: The initial *experimental* implementation of HTTP/2.

This is an accumulation of the work that has been done in the nodejs/http2
repository, squashed down to a couple of commits. The original commit
history has been preserved in the nodejs/http2 repository.

This PR introduces the nghttp2 C library as a new dependency. This library
provides the majority of the HTTP/2 protocol implementation, with the rest
of the code here providing the mapping of the library into a usable JS API.

Within src, a handful of new node_http2_*.c and node_http2_*.h files are
introduced. These provide the internal mechanisms that interface with nghttp
and define the `process.binding('http2')` interface.

The JS API is defined within `internal/http2/*.js`.

There are two APIs provided: Core and Compat.

The Core API is HTTP/2 specific and is designed to be as minimal and as
efficient as possible.

The Compat API is intended to be as close to the existing HTTP/1 API as
possible, with some exceptions.

Tests, documentation and initial benchmarks are included.

The `http2` module is gated by a new `--expose-http2` command line flag.
When used, `require('http2')` will be exposed to users. Note that there
is an existing `http2` module on npm that would be impacted by the introduction
of this module, which is the main reason for gating this behind a flag.

When using `require('http2')` the first time, a process warning will be
emitted indicating that an experimental feature is being used.

To run the benchmarks, the `h2load` tool (part of the nghttp project) is
required: `./node benchmarks/http2/simple.js benchmarker=h2load`. Only
two benchmarks are currently available.

Additional configuration options to enable verbose debugging are provided:

```
$ ./configure --debug-http2 --debug-nghttp2
$ NODE_DEBUG=http2 ./node
```

The `--debug-http2` configuration option enables verbose debug statements
from the `src/node_http2_*` files. The `--debug-nghttp2` enables the nghttp
library's own verbose debug output. The `NODE_DEBUG=http2` enables JS-level
debug output.

The following illustrates as simple HTTP/2 server and client interaction:

(The HTTP/2 client and server support both plain text and TLS connections)

```jt client = http2.connect('http://localhost:80');
const req = client.request({ ':path': '/some/path' });
req.on('data', (chunk) => { /* do something with the data */ });
req.on('end', () => {
  client.destroy();
});

// Plain text (non-TLS server)
const server = http2.createServer();
server.on('stream', (stream, requestHeaders) => {
  stream.respond({ ':status': 200 });
  stream.write('hello ');
  stream.end('world');
});
server.listen(80);
```

```js
const http2 = require('http2');
const client = http2.connect('http://localhost');

```

Author: Anna Henningsen <anna@addaleax.net>
Author: Colin Ihrig <cjihrig@gmail.com>
Author: Daniel Bevenius <daniel.bevenius@gmail.com>
Author: James M Snell <jasnell@gmail.com>
Author: Jun Mukai
Author: Kelvin Jin
Author: Matteo Collina <matteo.collina@gmail.com>
Author: Robert Kowalski <rok@kowalski.gd>
Author: Santiago Gimeno <santiago.gimeno@gmail.com>
Author: Sebastiaan Deckers <sebdeckers83@gmail.com>
Author: Yosuke Furukawa <yosuke.furukawa@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/14239
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2017-08-04 12:55:44 -07:00
Ben Noordhuis
1b7372f2fb src: replace ASSERT with CHECK
Builds always have asserts enabled so there is no point distinguishing
between debug-only checks and run-time checks.  Replace calls to ASSERT
and friends with their CHECK counterparts.

Fixes: https://github.com/nodejs/node/issues/14461
PR-URL: https://github.com/nodejs/node/pull/14474
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Nikolai Vavilov <vvnicholas@gmail.com>
Reviewed-By: XadillaX <admin@xcoder.in>
2017-07-27 17:11:08 +02:00
James M Snell
ed21cb1774 util: implement WHATWG Encoding Standard API
Provide an (initially experimental) implementation of the WHATWG Encoding
Standard API (`TextDecoder` and `TextEncoder`). The is the same API
implemented on the browser side.

By default, with small-icu, only the UTF-8, UTF-16le and UTF-16be decoders
are supported. With full-icu enabled, every encoding other than iso-8859-16
is supported.

This provides a basic test, but does not include the full web platform
tests. Note: many of the web platform tests for this would fail by default
because we ship with small-icu by default.

A process warning will be emitted on first use to indicate that the
API is still experimental. No runtime flag is required to use the
feature.

Refs: https://encoding.spec.whatwg.org/
PR-URL: https://github.com/nodejs/node/pull/13644
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2017-07-24 14:04:13 -07:00
Evan Lucas
49d13a17b1 build: allow enabling the --trace-maps flag in V8
This can be useful for tracing map creation.

PR-URL: https://github.com/nodejs/node/pull/14018
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Refael Ackermann <refack@gmail.com>
2017-07-07 09:18:08 -05:00
Bradley T. Hughes
f84666f923 build: support dtrace on ARM
Use the same dtrace command on ARM as on i386. Patch obtained from
FreeBSD PR 218081 [1].

1. https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=218081

PR-URL: https://github.com/nodejs/node/pull/12193
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-05-27 14:17:20 +02:00
Daniel Bevenius
1cde375763 build: fix openssl link error on windows
This commit attempts to fix an issue when building on windows using the
following command line options:
.\vcbuild.bat dll debug x64 vc2015

This will result in the following options passed to configure:
configure --debug --shared --dest-cpu=x64 --tag=

This commit excludes the dependency to openssl if node is configured
with --shared.

Also, FP_API to the categories to export in mkssldef when generating
the module definition (openssl.def) allowing the build to compile and
link successfully.

Fixes: https://github.com/nodejs/node/issues/12952
PR-URL: https://github.com/nodejs/node/pull/13078
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Refael Ackermann <refack@gmail.com>
2017-05-25 18:39:49 +02:00
Eugene Ostroukhov
60390cd7fb
inspector: JavaScript bindings for the inspector
PR-URL: https://github.com/nodejs/node/pull/12263
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Josh Gavant <josh.gavant@outlook.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2017-05-23 19:45:48 +02:00
Matteo Collina
330c8d743e stream: add destroy and _destroy methods.
Adds destroy() and _destroy() methods to Readable, Writable, Duplex
and Transform. It also standardizes the behavior and the implementation
of destroy(), which has been inconsistent in userland and core.
This PR also updates all the subsystems of core to use the new
destroy().

PR-URL: https://github.com/nodejs/node/pull/12925
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Calvin Metcalf <calvin.metcalf@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-05-22 08:34:14 +02:00
Daniel Bevenius
bb88caec06 build: fix ninja build failure
When working on commit 6a09a69ec9
("build: enable cctest to use generated objects") I did not take into
account building with ninja:

$ ./configure
$ tools/gyp_node.py -f ninja
$ ninja -C out/Release
$ ln -fs out/Release/node node

When ninja generated the ninja build files, src files that are
relative to the src directory will be named with a dot instead of a
path separator, for example:

out/Release/obj/src/node/node.o
would instead become:
out/Release/obj/src/node.node.o

This commit adds an additional variable for the type of object separator
used for this case.

Currently the check for if ninja is being used is a normal if statement
as are the following os checks (win and aix). But the win and aix ones
should only be evaluated if the build is not generated by ninja.
This commit turns this logic into an if ninja else statement.

PR-URL: https://github.com/nodejs/node/pull/12484
Fixes: https://github.com/nodejs/node/issues/12448
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
2017-05-11 08:10:16 -04:00
Trevor Norris
7e3a3c962f
async_hooks: initial async_hooks implementation
Fill this commit messsage with more details about the change once all
changes are rebased.

* Add lib/async_hooks.js

* Add JS methods to AsyncWrap for handling the async id stack

* Introduce AsyncReset() so that JS functions can reset the id and again
  trigger the init hooks, allow AsyncWrap::Reset() to be called from JS
  via asyncReset().

* Add env variable to test additional things in test/common.js

PR-URL: https://github.com/nodejs/node/pull/12892
Ref: https://github.com/nodejs/node/pull/11883
Ref: https://github.com/nodejs/node/pull/8531
Reviewed-By: Andreas Madsen <amwebdk@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2017-05-10 22:22:26 +02:00
Michaël Zasso
719247ff95
src: remove debugger dead code
PR-URL: https://github.com/nodejs/node/pull/12621
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2017-04-29 17:20:00 +02:00
Rich Trott
549e81bfa1 debugger: remove obsolete _debug_agent.js
With _debugger.js removed, _debug_agent.js appears to be unnecessary.

PR-URL: https://github.com/nodejs/node/pull/12582
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
2017-04-24 10:19:24 -07:00
Ben Noordhuis
90476ac6ee lib: remove _debugger.js
The file no longer works after the removal of the --debug/--debug-brk
switches in commit 47f8f74 ("src: remove support for --debug".)

This commit also removes several tests that still referenced the
old debugger but were either unit-testing its internals or passing
for the wrong reason (like expecting an operation to fail, which
it did because the debugger is gone.)

PR-URL: https://github.com/nodejs/node/pull/12495
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-04-21 10:35:49 +02:00
Anna Henningsen
9d522225e7
src: reduce number of exported symbols
Use `static` definitions and anonymous namespaces to reduce the
number of symbols that are exported from the `node` binary.

PR-URL: https://github.com/nodejs/node/pull/12366
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-04-14 22:47:29 +02:00
Daniel Bevenius
ec53921d2e src: make AtExit callback's per Environment
This commit attempts to address one of the TODOs in
https://github.com/nodejs/node/issues/4641 regarding making the
AtExit callback's per environment, instead of the current global.

bnoordhuis provided a few options for solving this, and one was to
use a thread-local which is what this commit attempts to do.

PR-URL: https://github.com/nodejs/node/pull/9163
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl>
2017-04-12 13:11:39 +02:00
Alexey Orlenko
b03f1f0c01
test: add basic cctest for base64.h
This commit adds C++ tests for `base64_encode()` and `base64_decode()`
functions defined in `base64.h`.  The functionality is already being
tested indirectly in JavaScript tests for Buffer, but it won't hurt to
test the low-level functions too, especially given that they aren't only
used in the internal Buffer implementation, Chrome inspector protocol
support relies upon them too.

PR-URL: https://github.com/nodejs/node/pull/12238
Refs: https://github.com/nodejs/node/pull/12146#issuecomment-291559685
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
2017-04-08 11:57:40 +03:00
Alexey Orlenko
f4e8a6f1f0 test: add Unicode characters regression test
This test ensures that UTF-8 characters can be used in core JavaScript
modules built into Node's binary.

PR-URL: https://github.com/nodejs/node/pull/11423
Ref: https://github.com/nodejs/node/pull/11129
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-04-04 11:14:14 -07:00
Brian White
84a23391f6 linkedlist: remove public module
PR-URL: https://github.com/nodejs/node/pull/12113
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
2017-04-04 10:05:04 -07:00
Jason Ginchereau
56e881d0b0
n-api: add support for abi stable module API
Add support for abi stable module API (N-API) as "Experimental feature".
The goal of this API is to provide a stable Node API for native
module developers. N-API aims to provide ABI compatibility guarantees
across different Node versions and also across different
Node VMs - allowing N-API enabled native modules to just work
across different versions and flavors of Node.js without recompilation.

A more detailed introduction is provided in:
https://github.com/nodejs/node-eps/blob/master/005-ABI-Stable-Module-API.md
and https://github.com/nodejs/abi-stable-node/blob/doc/VM%20Summit.pdf.

The feature, during its experimental state, will be guarded by a runtime
flag "--napi-modules". Only when this flag is added to the command line
will N-API modules along with regular non N-API modules be supported.

The API is defined by the methods in "src/node_api.h" and
"src/node_api_types.h". This is the best
starting point to review the API surface. More documentation will follow.

In addition to the implementation of the API using V8, which is included
in this PR, the API has also been validated against chakracore and that
port is available in
https://github.com/nodejs/abi-stable-node/tree/api-prototype-chakracore-8.x.

The current plan is to provide N-API support in versions 8.X and 6.X
directly. For older versions, such as 4.X or pre N-API versions of 6.X,
we plan to create an external npm module to provide a migration path
that will allow modules targeting older Node.js versions to use the API,
albeit without getting the advantage of not having to recompile.

In addition, we also plan an external npm package with C++ sugar to
simplify the use of the API. The sugar will be in-line only and will
only use the exported N-API methods but is not part of the N-API
itself. The current version is in:
https://github.com/nodejs/node-api.

This PR is a result of work in the abi-stable-node repo:
https://github.com/nodejs/abi-stable-node/tree/doc,
with this PR being the cumulative work on the api-prototype-8.x
branch with the following contributors in alphabetical order:

Author: Arunesh Chandra <arunesh.chandra@microsoft.com>
Author: Gabriel Schulhof <gabriel.schulhof@intel.com>
Author: Hitesh Kanwathirtha <hiteshk@microsoft.com>
Author: Ian Halliday <ianhall@microsoft.com>
Author: Jason Ginchereau <jasongin@microsoft.com>
Author: Michael Dawson <michael_dawson@ca.ibm.com>
Author: Sampson Gao <sampsong@ca.ibm.com>
Author: Taylor Woll <taylor.woll@microsoft.com>
PR-URL: https://github.com/nodejs/node/pull/11975
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-04-03 10:31:25 +02:00
Anna Henningsen
1fde98bb4f
v8: expose new V8 serialization API
Expose the new serialization API that was added in V8 5.5 to userland.
The JS API is virtually a direct copy of what V8 provides on the
C++ level.

This is useful Node as a possible replacement for some internals
that currently use JSON, like IPC, but is likely to be useful to
general userland code as well.

PR-URL: https://github.com/nodejs/node/pull/11048
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2017-03-29 05:14:55 +02:00
James M Snell
51b007aaa7 test: add cctest for native URL class
PR-URL: https://github.com/nodejs/node/pull/12042
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
2017-03-27 10:12:44 -07:00
Daniel Bevenius
6a09a69ec9 build: enable cctest to use generated objects
This commit tries to make it simpler to add unit tests (cctest) for
code that needs to test node core funtionality but that might not be
appropriate as an addon or a JavaScript test. An example of this could
be adding functionality targeted for situations when Node itself is
embedded.

Currently it was not as easy, or efficient, as one would have hoped to
add such tests. The object output directories vary for different
operating systems which we need to link to so that we don't have an
additional compilation step.

PR-URL: https://github.com/nodejs/node/pull/11956
Ref: https://github.com/nodejs/node/pull/9163
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-03-24 08:28:43 -07:00