From 81b15d41e6e202852402ac94ed81db971c3b60e3 Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Thu, 24 Jan 2019 20:56:33 +0200 Subject: [PATCH 1/4] bootstrap: experimental --frozen-intrinsics flag --- LICENSE | 18 ++ doc/api/cli.md | 18 ++ doc/node.1 | 3 + lib/internal/bootstrap/pre_execution.js | 10 + lib/internal/freeze_intrinsics.js | 242 ++++++++++++++++++++++++ lib/internal/main/worker_thread.js | 2 + node.gyp | 1 + src/node_options.cc | 4 + src/node_options.h | 1 + test/parallel/test-freeze-intrinsics.js | 10 + tools/license-builder.sh | 3 + 11 files changed, 312 insertions(+) create mode 100644 lib/internal/freeze_intrinsics.js create mode 100644 test/parallel/test-freeze-intrinsics.js diff --git a/LICENSE b/LICENSE index 53176c816407ec..2db8824ea9aabb 100644 --- a/LICENSE +++ b/LICENSE @@ -1349,6 +1349,24 @@ The externally maintained libraries used by Node.js are: OR OTHER DEALINGS IN THE SOFTWARE. """ +- caja, located at lib/internal/freeze_intrinsics.js, is licensed as follows: + """ + Adapted from SES/Caja - Copyright (C) 2011 Google Inc. + Copyright (C) 2018 Agoric + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + """ + - brotli, located at deps/brotli, is licensed as follows: """ Copyright (c) 2009, 2010, 2013-2016 by the Brotli Authors. diff --git a/doc/api/cli.md b/doc/api/cli.md index a4866e94d51e9c..1c55bcbf78bd23 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -177,6 +177,23 @@ added: v6.0.0 Force FIPS-compliant crypto on startup. (Cannot be disabled from script code.) (Same requirements as `--enable-fips`.) +### `--frozen-intrinsics` + + +Enable experimental frozen intrinsics like `Array` and `Object`. + +Support is currently only provided for the root context and no guarantees are +currently provided that `global.Array` is indeed the default intrinsic +reference. + +**Code breakage is highly likely with this flag**, especially since limited +support for subclassing builtins is provided currently due to ECMA-262 bug +https://github.com/tc39/ecma262/pull/1320. + +Both of the above may change in future updates, which will be breaking changes. + ### `--http-parser=library` +> Stability: 1 - Experimental + Enable experimental frozen intrinsics like `Array` and `Object`. Support is currently only provided for the root context and no guarantees are From a56903d6bed4c66fb43142165da1f7f3d8238607 Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Sun, 3 Mar 2019 17:17:43 +0200 Subject: [PATCH 4/4] conditional check Intl --- lib/internal/freeze_intrinsics.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/internal/freeze_intrinsics.js b/lib/internal/freeze_intrinsics.js index 2d0a78a6ff537f..effac318539270 100644 --- a/lib/internal/freeze_intrinsics.js +++ b/lib/internal/freeze_intrinsics.js @@ -132,13 +132,15 @@ module.exports = function() { // Other APIs console, - Intl, BigInt, Atomics, WebAssembly, SharedArrayBuffer ]; + if (typeof Intl !== 'undefined') + intrinsics.push(Intl); + intrinsics.forEach(deepFreeze); function deepFreeze(root) {