summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2019-01-30report: split up osVersion and machine valuescjihrig
Prior to this commit, on non-Windows platforms, the "osVersion" value was prepended to the "machine" value. PR-URL: https://github.com/nodejs/node/pull/25755 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-01-30inspector, trace_events: make sure messages are sent on a main threadEugene Ostroukhov
Fixes: https://github.com/nodejs/node/issues/23185 PR-URL: https://github.com/nodejs/node/pull/24814 Reviewed-By: James M Snell <jasnell@gmail.com>
2019-01-30process: split execution into main scriptsJoyee Cheung
This patch splits the execution mode selection from the environment setup in `lib/internal/bootstrap/node.js`, and split the entry point of different execution mode into main scripts under `lib/internal/main`: - `check_syntax.js`: used when `-c`/`--check` which only checks the syntax of the input instead of executing it. - `eval_stdin.js`: used when `-e` is passed without value and stdin is not a TTY (e.g. something is piped). - `eval_string`: used when `-e` is passed along with a string argument - `inspect.js`: for `node inspect`/`node debug` - `print_bash_completion.js`: for `--completion-bash` - `print_help.js`: for `--help` - `prof_process.js`: for `--prof-process` - `repl.js`: for the REPL - `run_main_module.js`: used when a main module is passed - `run_third_party_main.js`: for the legacy `_third_party_main.js` support - `worker_thread.js`: for workers This makes the entry points easier to navigate and paves the way for customized v8 snapshots (that do not need to deserialize execution mode setup) and better embedder APIs. As an example, after this patch, for the most common case where Node.js executes a user module as an entry point, it essentially goes through: - `lib/internal/per_context.js` to setup the v8 Context (which is also run when setting up contexts for the `vm` module) - `lib/internal/bootstrap/loaders.js` to set up internal binding and builtin module loaders (that are separate from the loaders accessible in the user land). - `lib/internal/bootstrap/node.js`: to set up the rest of the environment, including various globals and the process object - `lib/internal/main/run_main_module.js`: which is selected from C++ to prepare execution of the user module. This patch also removes `NativeModuleLoader::CompileAndCall` and exposes `NativeModuleLoader::LookupAndCompile` directly so that we can handle syntax errors and runtime errors of bootstrap scripts differently. PR-URL: https://github.com/nodejs/node/pull/25667 Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-01-30src: remove unused env_ field from env.hDaniel Bevenius
Currently the following compiler warnings is generated: In file included from ../src/env-inl.h:28: ../src/env.h:521:18: warning: private field 'env_' is not used [-Wunused-private-field] Environment* env_; ^ 1 warning generated. This commit removes this unused field. PR-URL: https://github.com/nodejs/node/pull/25784 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
2019-01-29src: pass along errors from i18n converter instantiationAnna Henningsen
PR-URL: https://github.com/nodejs/node/pull/25734 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gus Caplan <me@gus.host>
2019-01-29src: pass along errors from vm data wrapper creationAnna Henningsen
PR-URL: https://github.com/nodejs/node/pull/25734 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gus Caplan <me@gus.host>
2019-01-29src: pass along errors from KeyObject instantiationAnna Henningsen
PR-URL: https://github.com/nodejs/node/pull/25734 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gus Caplan <me@gus.host>
2019-01-29src: pass along errors from perf obj instantiationAnna Henningsen
PR-URL: https://github.com/nodejs/node/pull/25734 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gus Caplan <me@gus.host>
2019-01-29src: pass along errors from process obj instantiationAnna Henningsen
PR-URL: https://github.com/nodejs/node/pull/25734 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gus Caplan <me@gus.host>
2019-01-29src: pass along errors from stream obj instantiationAnna Henningsen
PR-URL: https://github.com/nodejs/node/pull/25734 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gus Caplan <me@gus.host>
2019-01-29src: pass along errors from PromiseWrap instantiationAnna Henningsen
PR-URL: https://github.com/nodejs/node/pull/25734 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gus Caplan <me@gus.host>
2019-01-29tls: fix malloc mismatch in SSL_set_tlsext_status_ocsp_resp callDavid Benjamin
SSL_set_tlsext_status_ocsp_resp expects the data to be allocated with OPENSSL_malloc, not libc malloc, so use OpenSSLMalloc. Additionally, though OpenSSL doesn't type-check due to it being a macro, the function is documented to take an unsigned char pointer: https://www.openssl.org/docs/man1.1.0/ssl/SSL_set_tlsext_status_ocsp_resp.html (By default, OPENSSL_malloc is the same as libc malloc, but it is possible to customize this.) PR-URL: https://github.com/nodejs/node/pull/25706 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-01-29src: remove unused field in node_http2.hgengjiawen
Signed-off-by: gengjiawen <technicalcute@gmail.com> PR-URL: https://github.com/nodejs/node/pull/25727 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-01-29src: in-source comments and minor TLS cleanupsSam Roberts
Renamed some internal C++ methods and properties for consistency, and commented SSL I/O. - Rename waiting_new_session_ after is_waiting_new_session(), instead of using reverse naming (new_session_wait_), and change "waiting" to "awaiting". - Make TLSWrap::ClearIn() return void, the value is never used. - Fix a getTicketKeys() cut-n-paste error. Since it doesn't use the arguments, remove them from the js wrapper. - Remove call of setTicketKeys(getTicketKeys()), its a no-op. PR-URL: https://github.com/nodejs/node/pull/25713 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-01-29src: remove unnecessary call to SSL_get_modeSam Roberts
SSL_set_mode() bit-ORs its argument into the current mode, its not necessary for to do it ourself (though it doesn't cause harm). See: - https://www.openssl.org/docs/man1.1.0/ssl/SSL_set_mode.html - https://github.com/nodejs/node/blob/0ce615c4af/deps/openssl/openssl/ssl/ssl_lib.c#L2176-L2177 PR-URL: https://github.com/nodejs/node/pull/25711 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-01-29src: remove unused and unimplemented method in env.hgengjiawen
Signed-off-by: gengjiawen <technicalcute@gmail.com> PR-URL: https://github.com/nodejs/node/pull/25699 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-01-29vm: mark scripts as shareable cross-originJeremy Apthorp
PR-URL: https://github.com/nodejs/node/pull/25380 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com> Reviewed-By: Yang Guo <yangguo@chromium.org> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-01-28src: fix macro duplicate declaration in env.hgengjiawen
Signed-off-by: gengjiawen <technicalcute@gmail.com> PR-URL: https://github.com/nodejs/node/pull/25703 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-01-28perf_hooks: clean up GC listenersAnna Henningsen
Add Environment cleanup hooks to remove GC listeners when the `Environment` is torn down. PR-URL: https://github.com/nodejs/node/pull/25647 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-01-27src: simplify inspector initialization in node::Start()Joyee Cheung
Remove the `StartInspector` and `InspectorStarted` abstraction out of `v8_platform`, and error out early and directly in the option parser if Node is configured with NODE_USE_V8_PLATFORM and inspector enabled but the user still tries to use inspector options. PR-URL: https://github.com/nodejs/node/pull/25612 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-01-27src: avoid race condition in tracing codeAnna Henningsen
`json_trace_writer_` is protected by `stream_mutex_`, but one access to it was not guarded by a lock on said mutex. Refs: https://github.com/nodejs/node/issues/25512 PR-URL: https://github.com/nodejs/node/pull/25624 Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-01-27report: represent numbers as numbersAnna Henningsen
Do not stringify numbers and boolean values when writing JSON. PR-URL: https://github.com/nodejs/node/pull/25651 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Matheus Marchini <mat@mmarchini.me> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2019-01-27report: refactor JSON writerAnna Henningsen
- Support non-string entry types - Prefer single-character writes over string writes - Rename the state constants and adjust style to match more common Node.js style PR-URL: https://github.com/nodejs/node/pull/25651 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Matheus Marchini <mat@mmarchini.me> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2019-01-27report: do not use `uv_default_loop()` as fallbackAnna Henningsen
Not seeing an associated `Environment` is a rare condition anyway, but using `uv_default_loop()` as a fallback is not thread-safe. PR-URL: https://github.com/nodejs/node/pull/25652 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
2019-01-27src: ensure no more platform foreground tasks after DeinitClemens Hammacher
Node first calls `Isolate::Dispose`, then `NodePlatform::UnregisterIsolate`. This again calls `PerIsolatePlatformData::Shutdown`, which (before this patch) called `FlushForegroundTasksInternal`, which might call `RunForegroundTask` if it finds foreground tasks to be executed. This will fail however, since `Isolate::GetCurrent` was already reset during `Isolate::Dispose`. Hence remove the check to `FlushForegroundTasksInternal` and add checks instead that no more foreground tasks are scheduled. Refs: https://github.com/v8/node/pull/86 PR-URL: https://github.com/nodejs/node/pull/25653 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-01-25os: implement os.type() using uv_os_uname()cjihrig
The happy path behavior should be identical on all platforms except MinGW, which now identifies MinGW separately from Windows. PR-URL: https://github.com/nodejs/node/pull/25659 Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Minwoo Jung <minwoo@nodesource.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2019-01-25src,test: fix JSON escaping in node-reportDenys Otrishko
Previously only simple escape sequences were handled (i.e. \n, \t, r etc.). This commit adds escaping of other control symbols in the range of 0x00 to 0x20. Also, this replaces multiple find+replace calls with a single pass replacer. PR-URL: https://github.com/nodejs/node/pull/25626 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-01-25src: remove has_experimental_policy optionAnna Henningsen
This would be set when `--experimental-policy` was set, but since an empty string does not refer to a valid file, we can just check the value of `--experimental-policy` directly. PR-URL: https://github.com/nodejs/node/pull/25628 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
2019-01-24report: use `uv_handle_type_name()` to get handle typeAnna Henningsen
PR-URL: https://github.com/nodejs/node/pull/25610 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-01-24report: downgrade reinterpret_cast to static_castAnna Henningsen
PR-URL: https://github.com/nodejs/node/pull/25610 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-01-24report: roll extra loop iteration in `PrintNativeStack()`Anna Henningsen
PR-URL: https://github.com/nodejs/node/pull/25610 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-01-24src: remove unnecessary `filename` variableAnna Henningsen
PR-URL: https://github.com/nodejs/node/pull/25610 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-01-24report: remove `internalBinding('config').hasReport`Anna Henningsen
The `setup()` method is only called when the `--experimental-report` option is set. `getOptionValue()` returns `undefined` when the flag is not defined, so the extra check inside of `setup()` is redundant. PR-URL: https://github.com/nodejs/node/pull/25610 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-01-24src: remove using v8::Function in node_os.cccjihrig
PR-URL: https://github.com/nodejs/node/pull/25640 Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
2019-01-23report: remove `InitializeReport()`Anna Henningsen
PR-URL: https://github.com/nodejs/node/pull/25598 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-01-23http2: allow fully synchronous `_final()`Anna Henningsen
HTTP/2 streams do not use the fact that the native `StreamBase::Shutdown()` is asynchronous by default and always finish synchronously. Adding a status code for this scenario allows skipping an expensive `MakeCallback()` C++/JS boundary crossing. PR-URL: https://github.com/nodejs/node/pull/25609 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2019-01-23console: refactor inspector console extension installationJoyee Cheung
- Instead of creating the console extensions eagerly during bootstrap and storing them on an object, wrap the code into a function to be called during `installAdditionalCommandLineAPI` only when the extensions are actually needed, which may not even happen if the user do not use the console in an inspector session, and does not need to happen during bootstrap unconditionally. - Simplify the console methods wrapping and move the `consoleFromVM` storage to `internal/util/inspector.js` PR-URL: https://github.com/nodejs/node/pull/25450 Reviewed-By: John-David Dalton <john.david.dalton@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-01-23os: implement os.release() using uv_os_uname()cjihrig
For non-Windows platforms, the happy path behavior should be identical. On Windows, uv_os_uname() attempts to use RtlGetVersion() before falling back to the deprecated GetVersionExW() that Node was previously using. PR-URL: https://github.com/nodejs/node/pull/25600 Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-01-23src: restrict unloading addons to Worker threadsAnna Henningsen
Unloading native addons from the main thread was an (presumably unintended) significant breaking change, because addons may rely on their memory being available after an `Environment` exits. This patch only restricts this to Worker threads, at least for the time being, and thus matches the behaviour from https://github.com/nodejs/node/pull/23319. PR-URL: https://github.com/nodejs/node/pull/25577 Refs: https://github.com/nodejs/node/pull/24861 Refs: https://github.com/nodejs/node/pull/23319 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-01-23n-api: change #ifdef to #if in node_api_typesDaniel Bevenius
Currently, there are a number of compiler warnings like the following: In file included from ../src/node_api.h:11: ../src/node_api_types.h:13:21:x warning: extra tokens at end of #ifdef directive [-Wextra-tokens] #ifdef NAPI_VERSION >= 4 This commit changes the #ifdef macros to #if. PR-URL: https://github.com/nodejs/node/pull/25635 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-01-22report: simplify rlimit to JSON logiccjihrig
PR-URL: https://github.com/nodejs/node/pull/25597 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com>
2019-01-22report: simplify option checkingcjihrig
Also update the code for house style. PR-URL: https://github.com/nodejs/node/pull/25597 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com>
2019-01-22report: use uv_pid_t instead of custom PID_TYPEcjihrig
PR-URL: https://github.com/nodejs/node/pull/25597 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com>
2019-01-22report: remove unnecessary includescjihrig
PR-URL: https://github.com/nodejs/node/pull/25597 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com>
2019-01-22report: remove unnecessary intermediate variablecjihrig
PR-URL: https://github.com/nodejs/node/pull/25597 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com>
2019-01-22src: pass along errors from `--security-reverts`Anna Henningsen
Pass along errors from `Revert()` when a security revert is unknown (which currently applies to all possible values). Previously, we would unconditionally call `exit()`, which is not nice for embedding use cases, and could crash because we were holding a lock for a mutex in `ProcessGlobalArgs()` that would be destroyed by calling `exit()`. Also, add a regression test that makes sure that the process exits with the right exit code and not a crash. PR-URL: https://github.com/nodejs/node/pull/25466 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-01-22tls: workaround handshakedone in renegotiationShigeki Ohtsu
`SSL_CB_HANDSHAKE_START` and `SSL_CB_HANDSHAKE_DONE` are called sending HelloRequest in OpenSSL-1.1.1. We need to check whether this is in a renegotiation state or not. PR-URL: https://github.com/nodejs/node/pull/25381 Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Shigeki Ohtsu <ohtsu@ohtsu.org>
2019-01-22tls: make ossl 1.1.1 cipher list throw errorSam Roberts
Make OpenSSL 1.1.1 error during cipher list setting if it would have errored with OpenSSL 1.1.0. Can be dropped after our OpenSSL fixes this upstream. See: https://github.com/openssl/openssl/pull/7759 PR-URL: https://github.com/nodejs/node/pull/25381 Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Shigeki Ohtsu <ohtsu@ohtsu.org>
2019-01-22build: remove erroneous duplicate declaration from node_inspector.gypiRefael Ackermann
PR-URL: https://github.com/nodejs/node/pull/25586 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-01-21n-api: mark thread-safe function as stableGabriel Schulhof
Fixes: https://github.com/nodejs/node/issues/24249 PR-URL: https://github.com/nodejs/node/pull/25556 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>