diff --git a/ci/leak.supp b/ci/leak.supp index bc6dde4876..266aef1bf2 100644 --- a/ci/leak.supp +++ b/ci/leak.supp @@ -274,3 +274,24 @@ fun:_Z6pxMainiPPc fun:main } +{ + SnapshotBlobLeak + Memcheck:Leak + match-leak-kinds: definite + fun:_Znwm + fun:_ZN2v88internal7Sweeper31ScheduleIncrementalSweepingTaskEv + fun:_ZN2v88internal7Sweeper17StartSweeperTasksEv + fun:_ZN2v88internal20MarkCompactCollector6FinishEv + fun:_ZN2v88internal20MarkCompactCollector14CollectGarbageEv + fun:_ZN2v88internal4Heap11MarkCompactEv + fun:_ZN2v88internal4Heap24PerformGarbageCollectionENS0_16GarbageCollectorENS_15GCCallbackFlagsE + fun:_ZN2v88internal4Heap14CollectGarbageENS0_15AllocationSpaceENS0_23GarbageCollectionReasonENS_15GCCallbackFlagsE + fun:_ZN2v88internal4Heap26CollectAllAvailableGarbageENS0_23GarbageCollectionReasonE + fun:_ZN2v815SnapshotCreator10CreateBlobENS0_20FunctionCodeHandlingE + fun:_ZN2v82V822CreateSnapshotDataBlobEPKc + fun:_ZN12rtScriptNode5init2EiPPc + fun:_ZN12rtScriptNode4initEv + fun:_ZN8rtScript4initEv + fun:_Z6pxMainiPPc + fun:main +} diff --git a/examples/pxScene2d/VSCODE_DEBUG.md b/examples/pxScene2d/VSCODE_DEBUG.md index a9ad3661c5..ac57a46fc6 100644 --- a/examples/pxScene2d/VSCODE_DEBUG.md +++ b/examples/pxScene2d/VSCODE_DEBUG.md @@ -36,21 +36,25 @@ NOTE: From VSCode 1.25 and greater ... it is necessary to include `"protocol": "name": "DBG file in pxscene", "type": "node", "request": "launch", - "protocol": "legacy", + "protocol": "inspector", "cwd": "/Applications/Spark.app/Contents/MacOS", "runtimeExecutable": "/Applications/Spark.app/Contents/MacOS/Spark", + // Edit below as gl:${file} when running under webgl based apps "args":["${file}"], "env" : { + "BREAK_ON_SCRIPTSTART":"0", "LD_LIBRARY_PATH":"/Applications/Spark.app/Contents/MacOS/lib", "DYLD_LIBRARY_PATH":"/Applications/Spark.app/Contents/MacOS/lib" //,"BREAK_ON_SCRIPTSTART":1 - } + }, + "port":9229, + "stopOnEntry": true }, { "name": "DBG pxscene", "type": "node", "request": "launch", - "protocol": "legacy", + "protocol": "inspector", "cwd": "/Applications/Spark.app/Contents/MacOS", "runtimeExecutable": "/Applications/Spark.app/Contents/MacOS/Spark", "env" : { @@ -66,7 +70,7 @@ NOTE: From VSCode 1.25 and greater ... it is necessary to include `"protocol": // TCP/IP address. Default is "localhost". "address": "localhost", // Port to attach to. - "port": 5858, + "port": 9229, "sourceMaps": false } ] diff --git a/examples/pxScene2d/external/node-v10.15.3_mods.patch b/examples/pxScene2d/external/node-v10.15.3_mods.patch index f1112bee49..6ca7a3d630 100644 --- a/examples/pxScene2d/external/node-v10.15.3_mods.patch +++ b/examples/pxScene2d/external/node-v10.15.3_mods.patch @@ -1,3 +1,48 @@ +From 8bcd1f6461aad67e85dba5d093cc6bc4b1c61453 Mon Sep 17 00:00:00 2001 +From: mfiess200 +Date: Sat, 11 Apr 2020 18:00:36 -0400 +Subject: [PATCH] node patches + +--- + .../external/libnode-v10.15.3/common.gypi | 72 +++++++-- + .../external/libnode-v10.15.3/configure.py | 16 +- + .../deps/http_parser/http_parser.gyp | 8 +- + .../npm/node_modules/JSONStream/LICENSE.APACHE2 | 16 +- + .../deps/npm/node_modules/co/LICENSE | 4 +- + .../external/libnode-v10.15.3/deps/uv/common.gypi | 4 +- + .../external/libnode-v10.15.3/deps/uv/include/uv.h | 3 + + .../libnode-v10.15.3/deps/uv/src/unix/core.c | 44 ++++- + .../libnode-v10.15.3/deps/uv/src/win/handle.c | 5 + + .../external/libnode-v10.15.3/deps/v8/BUILD.gn | 10 +- + .../deps/v8/gypfiles/toolchain.gypi | 16 +- + .../libnode-v10.15.3/deps/v8/gypfiles/v8.gyp | 14 +- + .../libnode-v10.15.3/deps/v8/src/isolate.cc | 8 + + .../external/libnode-v10.15.3/lib/_tls_wrap.js | 6 +- + .../pxScene2d/external/libnode-v10.15.3/lib/dns.js | 27 +++- + .../lib/internal/bootstrap/node.js | 19 ++- + .../lib/internal/vm/source_text_module.js | 4 +- + .../pxScene2d/external/libnode-v10.15.3/lib/net.js | 179 ++++++++++++++++++++- + .../pxScene2d/external/libnode-v10.15.3/node.gyp | 20 --- + .../external/libnode-v10.15.3/src/bootstrapper.cc | 16 +- + .../external/libnode-v10.15.3/src/env-inl.h | 21 ++- + .../pxScene2d/external/libnode-v10.15.3/src/env.h | 14 +- + .../external/libnode-v10.15.3/src/module_wrap.cc | 8 + + .../external/libnode-v10.15.3/src/module_wrap.h | 2 + + .../external/libnode-v10.15.3/src/node.cc | 126 +++++++++++++-- + .../pxScene2d/external/libnode-v10.15.3/src/node.h | 22 ++- + .../libnode-v10.15.3/src/node_contextify.cc | 79 +++++++++ + .../libnode-v10.15.3/src/node_contextify_mods.h | 19 +++ + .../libnode-v10.15.3/src/node_http_parser.cc | 10 +- + .../external/libnode-v10.15.3/src/node_internals.h | 4 +- + .../external/libnode-v10.15.3/src/node_platform.cc | 38 +++-- + .../external/libnode-v10.15.3/src/node_watchdog.cc | 5 +- + .../external/libnode-v10.15.3/src/stream_wrap.h | 11 +- + .../external/libnode-v10.15.3/src/tcp_wrap.cc | 21 ++- + .../external/libnode-v10.15.3/src/tcp_wrap.h | 3 + + .../external/libnode-v10.15.3/vcbuild.bat | 12 ++ + 36 files changed, 755 insertions(+), 131 deletions(-) + create mode 100644 examples/pxScene2d/external/libnode-v10.15.3/src/node_contextify_mods.h + diff --git a/examples/pxScene2d/external/libnode-v10.15.3/common.gypi b/examples/pxScene2d/external/libnode-v10.15.3/common.gypi index 4c64339..6b40aec 100755 --- a/examples/pxScene2d/external/libnode-v10.15.3/common.gypi @@ -117,6 +162,47 @@ index 4c64339..6b40aec 100755 }, }], ], +diff --git a/examples/pxScene2d/external/libnode-v10.15.3/configure.py b/examples/pxScene2d/external/libnode-v10.15.3/configure.py +index 0ad986a..c215ee6 100755 +--- a/examples/pxScene2d/external/libnode-v10.15.3/configure.py ++++ b/examples/pxScene2d/external/libnode-v10.15.3/configure.py +@@ -566,6 +566,13 @@ parser.add_option('--without-bundled-v8', + help='do not use V8 includes from the bundled deps folder. ' + + '(This mode is not officially supported for regular applications)') + ++# MODIFIED CODE BEGIN ++parser.add_option('--no-optimization', ++ action='store_true', ++ dest='no_optimization', ++ help='build without optimization') ++# MODIFIED CODE END ++ + parser.add_option('--build-v8-with-gn', + action='store_true', + dest='build_v8_with_gn', +@@ -1237,8 +1244,10 @@ def configure_openssl(o): + of modern CPU cryptographic instructions and will therefore be slower. + Please refer to BUILDING.md''') + +- if options.openssl_no_asm and options.shared_openssl: +- error('--openssl-no-asm is incompatible with --shared-openssl') ++ #MODIFIED CODE BEGIN ++ #if options.openssl_no_asm and options.shared_openssl: ++ # warn('--openssl-no-asm is incompatible with --shared-openssl') ++ #MODIFIED CODE END + + if options.openssl_fips: + error('FIPS is not supported in this version of Node.js') +@@ -1608,6 +1617,9 @@ configure_openssl(output) + configure_intl(output) + configure_static(output) + configure_inspector(output) ++# MODIFIED CODE BEGIN ++output['variables']['no_optimization'] = 1 if options.no_optimization else 0 ++# MODIFIED CODE END + + # variables should be a root level element, + # move everything else to target_defaults diff --git a/examples/pxScene2d/external/libnode-v10.15.3/deps/http_parser/http_parser.gyp b/examples/pxScene2d/external/libnode-v10.15.3/deps/http_parser/http_parser.gyp index 4364f73..7137f82 100755 --- a/examples/pxScene2d/external/libnode-v10.15.3/deps/http_parser/http_parser.gyp @@ -143,6 +229,48 @@ index 4364f73..7137f82 100755 'msvs_settings': { 'VCCLCompilerTool': { 'RuntimeLibrary': 0, # static release +diff --git a/examples/pxScene2d/external/libnode-v10.15.3/deps/npm/node_modules/JSONStream/LICENSE.APACHE2 b/examples/pxScene2d/external/libnode-v10.15.3/deps/npm/node_modules/JSONStream/LICENSE.APACHE2 +index 2de6e09..6366c04 100755 +--- a/examples/pxScene2d/external/libnode-v10.15.3/deps/npm/node_modules/JSONStream/LICENSE.APACHE2 ++++ b/examples/pxScene2d/external/libnode-v10.15.3/deps/npm/node_modules/JSONStream/LICENSE.APACHE2 +@@ -1,17 +1,15 @@ +-/* +-pxCore Copyright 2005-2018 John Robinson ++Apache License, Version 2.0 ++ ++Copyright (c) 2011 Dominic Tarr ++ + 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 ++ ++ 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. +-*/ +- +-px.import({ +- scene: 'px:scene.1.js' +-}).then(function ready(imports) { +-}); +diff --git a/examples/pxScene2d/external/libnode-v10.15.3/deps/npm/node_modules/co/LICENSE b/examples/pxScene2d/external/libnode-v10.15.3/deps/npm/node_modules/co/LICENSE +index 9bb2e9c..92faba5 100755 +--- a/examples/pxScene2d/external/libnode-v10.15.3/deps/npm/node_modules/co/LICENSE ++++ b/examples/pxScene2d/external/libnode-v10.15.3/deps/npm/node_modules/co/LICENSE +@@ -1,6 +1,6 @@ +-The MIT License ++(The MIT License) + +-Copyright (C) 2013 Gábor Molnár , Google Inc ++Copyright (c) 2014 TJ Holowaychuk <tj@vision-media.ca> + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the diff --git a/examples/pxScene2d/external/libnode-v10.15.3/deps/uv/common.gypi b/examples/pxScene2d/external/libnode-v10.15.3/deps/uv/common.gypi index 2297bdf..8298bea 100755 --- a/examples/pxScene2d/external/libnode-v10.15.3/deps/uv/common.gypi @@ -158,6 +286,115 @@ index 2297bdf..8298bea 100755 ], 'msvs_settings': { 'VCCLCompilerTool': { +diff --git a/examples/pxScene2d/external/libnode-v10.15.3/deps/uv/include/uv.h b/examples/pxScene2d/external/libnode-v10.15.3/deps/uv/include/uv.h +index 717c2e5..d08e863 100755 +--- a/examples/pxScene2d/external/libnode-v10.15.3/deps/uv/include/uv.h ++++ b/examples/pxScene2d/external/libnode-v10.15.3/deps/uv/include/uv.h +@@ -449,6 +449,9 @@ UV_EXTERN void uv_print_all_handles(uv_loop_t* loop, FILE* stream); + UV_EXTERN void uv_print_active_handles(uv_loop_t* loop, FILE* stream); + + UV_EXTERN void uv_close(uv_handle_t* handle, uv_close_cb close_cb); ++/* MODIFIED CODE BEGIN */ ++UV_EXTERN void uv_close_immediate(uv_handle_t* handle, uv_close_cb close_cb); ++/* MODIFIED CODE END */ + + UV_EXTERN int uv_send_buffer_size(uv_handle_t* handle, int* value); + UV_EXTERN int uv_recv_buffer_size(uv_handle_t* handle, int* value); +diff --git a/examples/pxScene2d/external/libnode-v10.15.3/deps/uv/src/unix/core.c b/examples/pxScene2d/external/libnode-v10.15.3/deps/uv/src/unix/core.c +index f92446f..e71a205 100755 +--- a/examples/pxScene2d/external/libnode-v10.15.3/deps/uv/src/unix/core.c ++++ b/examples/pxScene2d/external/libnode-v10.15.3/deps/uv/src/unix/core.c +@@ -304,6 +304,24 @@ static void uv__run_closing_handles(uv_loop_t* loop) { + } + } + ++/* MODIFIED CODE BEGIN */ ++void uv_close_immediate(uv_handle_t* handle, uv_close_cb close_cb) { ++ assert(!uv__is_closing(handle)); ++ ++ handle->flags |= UV_HANDLE_CLOSING; ++ handle->close_cb = close_cb; ++ ++ switch (handle->type) { ++ case UV_TCP: ++ uv__tcp_close((uv_tcp_t*)handle); ++ uv__finish_close(handle); ++ break; ++ ++ default: ++ assert(1); ++ } ++} ++/* MODIFIED CODE END */ + + int uv_is_closing(const uv_handle_t* handle) { + return uv__is_closing(handle); +@@ -726,9 +744,12 @@ void uv_disable_stdio_inheritance(void) { + /* Set the CLOEXEC flag on all open descriptors. Unconditionally try the + * first 16 file descriptors. After that, bail out after the first error. + */ +- for (fd = 0; ; fd++) ++ /*MODIFIED CODE BEGIN */ ++ //for (fd = 0; ; fd++) ++ for (fd = 3; ; fd++) + if (uv__cloexec(fd, 1) && fd > 15) + break; ++ /*MODIFIED CODE END */ + } + + +@@ -1003,6 +1024,9 @@ int uv__open_cloexec(const char* path, int flags) { + + int uv__dup2_cloexec(int oldfd, int newfd) { + int r; ++ /*MODIFIED CODE BEGIN*/ ++ int flags = 0; ++ /*MODIFIED CODE END*/ + #if (defined(__FreeBSD__) && __FreeBSD__ >= 10) || defined(__NetBSD__) + r = dup3(oldfd, newfd, O_CLOEXEC); + if (r == -1) +@@ -1018,9 +1042,23 @@ int uv__dup2_cloexec(int oldfd, int newfd) { + #elif defined(__linux__) + static int no_dup3; + if (!no_dup3) { ++ /* MODIFIED CODE BEGIN */ ++ //do ++ // r = uv__dup3(oldfd, newfd, UV__O_CLOEXEC); ++ //while (r == -1 && errno == EBUSY); + do +- r = uv__dup3(oldfd, newfd, UV__O_CLOEXEC); +- while (r == -1 && errno == EBUSY); ++ { ++ if (newfd >=0 && newfd <= 2) ++ { ++ flags = 0; ++ } ++ else ++ { ++ flags = UV__O_CLOEXEC; ++ } ++ r = uv__dup3(oldfd, newfd, flags); ++ }while (r == -1 && (errno == EINTR || errno == EBUSY)); ++ /* MODIFIED CODE END */ + if (r != -1) + return r; + if (errno != ENOSYS) +diff --git a/examples/pxScene2d/external/libnode-v10.15.3/deps/uv/src/win/handle.c b/examples/pxScene2d/external/libnode-v10.15.3/deps/uv/src/win/handle.c +index 9d76c3f..ceb42f2 100755 +--- a/examples/pxScene2d/external/libnode-v10.15.3/deps/uv/src/win/handle.c ++++ b/examples/pxScene2d/external/libnode-v10.15.3/deps/uv/src/win/handle.c +@@ -148,6 +148,11 @@ void uv_close(uv_handle_t* handle, uv_close_cb cb) { + } + } + ++/* MODIFIED CODE BEGIN */ ++void uv_close_immediate(uv_handle_t* handle, uv_close_cb cb) { ++ uv_close(handle, cb); ++} ++/* MODIFIED CODE END */ + + int uv_is_closing(const uv_handle_t* handle) { + return !!(handle->flags & (UV_HANDLE_CLOSING | UV_HANDLE_CLOSED)); diff --git a/examples/pxScene2d/external/libnode-v10.15.3/deps/v8/BUILD.gn b/examples/pxScene2d/external/libnode-v10.15.3/deps/v8/BUILD.gn index 19ffdb3..ff82ac0 100755 --- a/examples/pxScene2d/external/libnode-v10.15.3/deps/v8/BUILD.gn @@ -283,6 +520,71 @@ index 0bdfef5..e79edfb 100755 if (FLAG_print_all_exceptions) { printf("=========================================================\n"); printf("Exception thrown:\n"); +diff --git a/examples/pxScene2d/external/libnode-v10.15.3/lib/_tls_wrap.js b/examples/pxScene2d/external/libnode-v10.15.3/lib/_tls_wrap.js +index 9bfdd40..0dc161a 100755 +--- a/examples/pxScene2d/external/libnode-v10.15.3/lib/_tls_wrap.js ++++ b/examples/pxScene2d/external/libnode-v10.15.3/lib/_tls_wrap.js +@@ -345,16 +345,16 @@ function TLSSocket(socket, opts) { + } + util.inherits(TLSSocket, net.Socket); + exports.TLSSocket = TLSSocket; +- ++/* MODIFIED CODE BEGIN */ + var proxiedMethods = [ +- 'ref', 'unref', 'open', 'bind', 'listen', 'connect', 'bind6', ++ 'ref', 'unref', 'open', 'bind', 'listen', 'connect', 'bind6', 'reset', + 'connect6', 'getsockname', 'getpeername', 'setNoDelay', 'setKeepAlive', + 'setSimultaneousAccepts', 'setBlocking', + + // PipeWrap + 'setPendingInstances' + ]; +- ++/* MODIFIED CODE END */ + // Proxy HandleWrap, PipeWrap and TCPWrap methods + function makeMethodProxy(name) { + return function methodProxy(...args) { +diff --git a/examples/pxScene2d/external/libnode-v10.15.3/lib/dns.js b/examples/pxScene2d/external/libnode-v10.15.3/lib/dns.js +index f90d7c1..b151f53 100755 +--- a/examples/pxScene2d/external/libnode-v10.15.3/lib/dns.js ++++ b/examples/pxScene2d/external/libnode-v10.15.3/lib/dns.js +@@ -69,15 +69,30 @@ function onlookupall(err, addresses) { + } + + var family = this.family; ++ /* MODIFIED CODE BEGIN */ ++ var ipV4Addresses = []; ++ var ipV4count = 0; ++ var ipV6Addresses = [] ++ var ipV6count = 0; ++ var result = {} + for (var i = 0; i < addresses.length; i++) { + const addr = addresses[i]; +- addresses[i] = { +- address: addr, +- family: family || (isIPv4(addr) ? 4 : 6) +- }; ++ var addrfamily = family || (isIPv4(addr) ? 4 : 6) ++ if (addrfamily == 4) { ++ ipV4Addresses[ipV4count] = {address: addr, family: addrfamily} ++ ipV4count++; ++ } ++ else { ++ ipV6Addresses[ipV6count] = {address: addr, family: addrfamily} ++ ipV6count++; ++ } + } +- +- this.callback(null, addresses); ++ result['v4address'] = ipV4Addresses ++ result['v4count'] = ipV4count ++ result['v6address'] = ipV6Addresses ++ result['v6count'] = ipV6count ++ this.callback(null, result); ++ /* MODIFIED CODE END */ + } + + diff --git a/examples/pxScene2d/external/libnode-v10.15.3/lib/internal/bootstrap/node.js b/examples/pxScene2d/external/libnode-v10.15.3/lib/internal/bootstrap/node.js index b168eb0..82cdec8 100755 --- a/examples/pxScene2d/external/libnode-v10.15.3/lib/internal/bootstrap/node.js @@ -334,699 +636,337 @@ index b168eb0..82cdec8 100755 } } } -diff --git a/examples/pxScene2d/external/libnode-v10.15.3/node.gyp b/examples/pxScene2d/external/libnode-v10.15.3/node.gyp -index a8de196..607a7db 100755 ---- a/examples/pxScene2d/external/libnode-v10.15.3/node.gyp -+++ b/examples/pxScene2d/external/libnode-v10.15.3/node.gyp -@@ -36,7 +36,6 @@ - 'lib/console.js', - 'lib/constants.js', - 'lib/crypto.js', -- 'lib/cluster.js', - 'lib/dgram.js', - 'lib/dns.js', - 'lib/domain.js', -@@ -89,12 +88,6 @@ - 'lib/internal/buffer.js', - 'lib/internal/cli_table.js', - 'lib/internal/child_process.js', -- 'lib/internal/cluster/child.js', -- 'lib/internal/cluster/master.js', -- 'lib/internal/cluster/round_robin_handle.js', -- 'lib/internal/cluster/shared_handle.js', -- 'lib/internal/cluster/utils.js', -- 'lib/internal/cluster/worker.js', - 'lib/internal/crypto/certificate.js', - 'lib/internal/crypto/cipher.js', - 'lib/internal/crypto/diffiehellman.js', -@@ -168,8 +161,6 @@ - 'lib/internal/http2/core.js', - 'lib/internal/http2/compat.js', - 'lib/internal/http2/util.js', -- 'lib/internal/v8_prof_polyfill.js', -- 'lib/internal/v8_prof_processor.js', - 'lib/internal/validators.js', - 'lib/internal/stream_base_commons.js', - 'lib/internal/vm/source_text_module.js', -@@ -184,17 +175,6 @@ - 'lib/internal/streams/pipeline.js', - 'lib/internal/streams/end-of-stream.js', - 'lib/internal/wrap_js_stream.js', -- 'deps/v8/tools/splaytree.js', -- 'deps/v8/tools/codemap.js', -- 'deps/v8/tools/consarray.js', -- 'deps/v8/tools/csvparser.js', -- 'deps/v8/tools/profile.js', -- 'deps/v8/tools/profile_view.js', -- 'deps/v8/tools/logreader.js', -- 'deps/v8/tools/arguments.js', -- 'deps/v8/tools/tickprocessor.js', -- 'deps/v8/tools/SourceMap.js', -- 'deps/v8/tools/tickprocessor-driver.js', - 'deps/node-inspect/lib/_inspect.js', - 'deps/node-inspect/lib/internal/inspect_client.js', - 'deps/node-inspect/lib/internal/inspect_repl.js', -diff --git a/examples/pxScene2d/external/libnode-v10.15.3/src/node.cc b/examples/pxScene2d/external/libnode-v10.15.3/src/node.cc -index 9fb5ab3..7c3c865 100755 ---- a/examples/pxScene2d/external/libnode-v10.15.3/src/node.cc -+++ b/examples/pxScene2d/external/libnode-v10.15.3/src/node.cc -@@ -173,7 +173,9 @@ using v8::V8; - using v8::Value; +diff --git a/examples/pxScene2d/external/libnode-v10.15.3/lib/internal/vm/source_text_module.js b/examples/pxScene2d/external/libnode-v10.15.3/lib/internal/vm/source_text_module.js +index 1898831..8468f94 100755 +--- a/examples/pxScene2d/external/libnode-v10.15.3/lib/internal/vm/source_text_module.js ++++ b/examples/pxScene2d/external/libnode-v10.15.3/lib/internal/vm/source_text_module.js +@@ -132,7 +132,9 @@ class SourceTextModule { - static bool v8_is_profiling = false; --static bool node_is_initialized = false; -+/* MODIFIED CODE BEGIN */ -+bool node_is_initialized = false; -+/* MODIFIED CODE END */ - static uv_once_t init_modpending_once = UV_ONCE_INIT; - static uv_key_t thread_local_modpending; - static node_module* modlist_builtin; -@@ -196,8 +198,10 @@ std::shared_ptr per_process_opts { - new PerProcessOptions() }; + Object.defineProperties(this, { + url: { value: url, enumerable: true }, +- context: { value: context, enumerable: true }, ++ // getter leaks... to prevent this make the property configurable and delete when necessary ++ //context: { value: context, enumerable: true }, ++ context: { value: context, enumerable: true, configurable: true}, + }); + } - static Mutex node_isolate_mutex; --static Isolate* node_isolate; -- -+/* MODIFIED CODE BEGIN */ -+Isolate* node_isolate; -+FILE* errorFile = NULL; -+/* MODIFIED CODE END */ - // Ensures that __metadata trace events are only emitted - // when tracing is enabled. - class NodeTraceStateObserver : -@@ -387,6 +391,29 @@ static struct { - static const unsigned kMaxSignal = 32; - #endif +diff --git a/examples/pxScene2d/external/libnode-v10.15.3/lib/net.js b/examples/pxScene2d/external/libnode-v10.15.3/lib/net.js +index e40aaa8..793014f 100755 +--- a/examples/pxScene2d/external/libnode-v10.15.3/lib/net.js ++++ b/examples/pxScene2d/external/libnode-v10.15.3/lib/net.js +@@ -812,6 +812,119 @@ function checkBindError(err, port, handle) { + return err; + } +/* MODIFIED CODE BEGIN */ -+void PrintErrorStringToFile(const char* format, ...) { -+ va_list filelog; -+ va_start(filelog, format); -+ const char* val = getenv("NODE_ERROR_FILE"); -+ if (val) { -+ errorFile = fopen(val,"w"); ++function internalConnectMultipleAddress( ++ self, address, port, localAddress, localPort) { ++ var ipV4addresses = address['v4address'] ++ var ipv4count = address['v4count'] ++ var ipV6addresses = address['v6address'] ++ var ipv6count = address['v6count'] ++ var tempLocalAddress = ""; ++ var bindSucceeded = true; ++ var connectSucceeded = false; ++ var err; ++ ++ // IPV6 bind ++ bindSucceeded = true; ++ if (localAddress || localPort) { ++ tempLocalAddress = localAddress || '::'; ++ err = self._handle.bind6(tempLocalAddress, localPort); ++ debug('binding to localAddress: %s and localPort: %d (addressType: 6)', ++ tempLocalAddress, localPort); ++ ++ err = checkBindError(err, localPort, self._handle); ++ if (err) { ++ console.log("Bind error for IPV6 : " + err + " happened for " + tempLocalAddress + " and port " + localPort); ++ bindSucceeded = false; ++ } + } -+ else -+ { -+ errorFile = fopen("/tmp/nodeerror.log","w"); ++ ++ // IPV6 connect ++ connectSucceeded = false; ++ if (true == bindSucceeded) { ++ for (var i=0; ishould_abort_on_uncaught_toggle()[0] && - !env->inside_should_not_abort_on_uncaught_scope(); - } -- --} // anonymous namespace -- -+/* MODIFIED CODE BEGIN */ -+//} // anonymous namespace ++ if (addressType === 6 || addressType === 4) { ++ const req = new TCPConnectWrap(); ++ req.oncomplete = afterConnectAll; ++ req.address = address; ++ req.port = port; ++ req.localAddress = localAddress; ++ req.localPort = localPort; ++ ++ if (addressType === 4) ++ err = self._handle.connect(req, address, port); ++ else ++ err = self._handle.connect6(req, address, port); ++ } ++ ++ if (err) { ++ var sockname = self._getsockname(); ++ var details; ++ ++ if (sockname) { ++ details = sockname.address + ':' + sockname.port; ++ } ++ ++ console.log("Connect error happened : " + err + " , " + details + " , " + address + ":" + port + " ,family: " + addressType); ++ } ++ else ++ { ++ ret = true; ++ } ++ return ret; ++} +/* MODIFIED CODE END */ - void AddPromiseHook(Isolate* isolate, promise_hook_func fn, void* arg) { - Environment* env = Environment::GetCurrent(isolate); -@@ -896,6 +924,9 @@ void AppendExceptionLine(Environment* env, - - uv_tty_reset_mode(); - PrintErrorString("\n%s", arrow); -+ /* MODIFIED CODE BEGIN */ -+ PrintErrorStringToFile("\n%s", arrow); -+ /* MODIFIED CODE END */ - return; - } - -@@ -939,9 +970,15 @@ void ReportException(Environment* env, - if (trace.length() > 0 && !trace_value->IsUndefined()) { - if (arrow.IsEmpty() || !arrow->IsString() || decorated) { - PrintErrorString("%s\n", *trace); -+ /* MODIFIED CODE BEGIN */ -+ PrintErrorStringToFile("%s\n", *trace); -+ /* MODIFIED CODE END */ - } else { - node::Utf8Value arrow_string(env->isolate(), arrow); - PrintErrorString("%s\n%s\n", *arrow_string, *trace); -+ /* MODIFIED CODE BEGIN */ -+ PrintErrorStringToFile("%s\n%s\n", *arrow_string, *trace); -+ /* MODIFIED CODE END */ - } - } else { - // this really only happens for RangeErrors, since they're the only -@@ -965,18 +1002,34 @@ void ReportException(Environment* env, + function internalConnect( + self, address, port, addressType, localAddress, localPort) { +@@ -974,11 +1087,13 @@ function lookupAndConnect(self, options) { - PrintErrorString("%s\n", *message ? *message : - ""); -+ /* MODIFIED CODE BEGIN */ -+ PrintErrorStringToFile("%s\n", *message ? *message : -+ ""); -+ /* MODIFIED CODE END */ -+ - } else { - node::Utf8Value name_string(env->isolate(), name); - node::Utf8Value message_string(env->isolate(), message); - if (arrow.IsEmpty() || !arrow->IsString() || decorated) { - PrintErrorString("%s: %s\n", *name_string, *message_string); + if (dns === undefined) dns = require('dns'); ++ /* MODIFIED CODE BEGIN */ + var dnsopts = { + family: options.family, +- hints: options.hints || 0 ++ hints: options.hints || 0, + }; +- ++ dnsopts.all = true; ++ /* MODIFIED CODE END */ + if (process.platform !== 'win32' && + dnsopts.family !== 4 && + dnsopts.family !== 6 && +@@ -1008,7 +1123,9 @@ function lookupAndConnect(self, options) { + err.port = options.port; + err.message = err.message + ' ' + options.host + ':' + options.port; + process.nextTick(connectErrorNT, self, err); +- } else if (addressType !== 4 && addressType !== 6) { + /* MODIFIED CODE BEGIN */ -+ PrintErrorStringToFile("%s: %s\n", *name_string, *message_string); ++ } else if ((false == dnsopts.all) && addressType !== 4 && addressType !== 6) { + /* MODIFIED CODE END */ -+ + err = new ERR_INVALID_ADDRESS_FAMILY(addressType); + err.host = options.host; + err.port = options.port; +@@ -1016,11 +1133,22 @@ function lookupAndConnect(self, options) { + process.nextTick(connectErrorNT, self, err); } else { - node::Utf8Value arrow_string(env->isolate(), arrow); - PrintErrorString("%s\n%s: %s\n", - *arrow_string, - *name_string, - *message_string); + self._unrefTimer(); +- defaultTriggerAsyncIdScope( +- self[async_id_symbol], +- internalConnect, +- self, ip, port, addressType, localAddress, localPort +- ); + /* MODIFIED CODE BEGIN */ -+ PrintErrorStringToFile("%s\n%s: %s\n", -+ *arrow_string, -+ *name_string, -+ *message_string); ++ if (dnsopts.all) { ++ defaultTriggerAsyncIdScope( ++ self[async_id_symbol], ++ internalConnectMultipleAddress, ++ self, ip, port, localAddress, localPort ++ ); ++ } ++ else { ++ defaultTriggerAsyncIdScope( ++ self[async_id_symbol], ++ internalConnect, ++ self, ip, port, addressType, localAddress, localPort ++ ); ++ } + /* MODIFIED CODE END */ -+ } - } - } -@@ -1340,14 +1393,20 @@ static void OnFatalError(const char* location, const char* message) { - PrintErrorString("FATAL ERROR: %s\n", message); + }); + }); +@@ -1107,6 +1235,41 @@ function afterConnect(status, handle, req, readable, writable) { } - fflush(stderr); -- ABORT(); -+ /* MODIFIED CODE BEGIN */ -+ //ABORT(); -+ /* MODIFIED CODE END */ } - --[[noreturn]] void FatalError(const char* location, const char* message) { -+/* MODIFIED CODE BEGIN */ -+/*[[noreturn]]*/ void FatalError(const char* location, const char* message) { -+/* MODIFIED CODE END */ - OnFatalError(location, message); - // to suppress compiler warning -- ABORT(); +/* MODIFIED CODE BEGIN */ -+ //ABORT(); -+/* MODIFIED CODE END */ - } - - -@@ -1355,7 +1414,9 @@ FatalTryCatch::~FatalTryCatch() { - if (HasCaught()) { - HandleScope scope(env_->isolate()); - ReportException(env_, *this); -- exit(7); -+ /* MODIFIED CODE BEGIN */ -+ //exit(7); -+ /* MODIFIED CODE END */ - } - } - -@@ -1376,7 +1437,9 @@ void FatalException(Isolate* isolate, - // Failed before the process._fatalException function was added! - // this is probably pretty bad. Nothing to do but report and exit. - ReportException(env, error, message); -- exit(6); -+ /* MODIFIED CODE BEGIN */ -+ //exit(6); -+ /* MODIFIED CODE END */ - } else { - TryCatch fatal_try_catch(isolate); - -@@ -1393,7 +1456,9 @@ void FatalException(Isolate* isolate, - if (fatal_try_catch.HasCaught()) { - // The fatal exception function threw, so we must exit - ReportException(env, fatal_try_catch); -- exit(7); -+ /* MODIFIED CODE BEGIN */ -+ //exit(7); -+ /* MODIFIED CODE END */ - } else if (caught.ToLocalChecked()->IsFalse()) { - ReportException(env, error, message); - -@@ -1403,9 +1468,13 @@ void FatalException(Isolate* isolate, - Local code; - if (!process_object->Get(env->context(), exit_code).ToLocal(&code) || - !code->IsInt32()) { -- exit(1); -+ /* MODIFIED CODE BEGIN */ -+ //exit(1); -+ /* MODIFIED CODE END */ - } -- exit(code.As()->Value()); -+ /* MODIFIED CODE BEGIN */ -+ //exit(code.As()->Value()); -+ /* MODIFIED CODE END */ - } - } - } -@@ -2805,6 +2874,14 @@ MultiIsolatePlatform* GetMainThreadMultiIsolatePlatform() { - MultiIsolatePlatform* CreatePlatform( - int thread_pool_size, - node::tracing::TracingController* tracing_controller) { -+ /* MODIFIED CODE BEGIN */ -+ if (0 == thread_pool_size) -+ { -+ v8_platform.Initialize( -+ per_process_opts->v8_thread_pool_size); -+ return v8_platform.Platform(); ++function afterConnectAll(status, handle, req, readable, writable) { ++ var self = handle[owner_symbol]; ++ ++ // callback may come after call to destroy ++ if (self.destroyed) { ++ return; + } -+ /* MODIFIED CODE END */ - return new NodePlatform(thread_pool_size, tracing_controller); - } - -@@ -3050,6 +3127,15 @@ void RegisterBuiltinModules() { - #undef V - } - -+/*MODIFIED CODE BEGIN*/ -+#if HAVE_INSPECTOR -+void InspectorStart(Environment* env, const char* path, MultiIsolatePlatform* platform) { -+ env->inspector_agent()->Start(path, env->options()->debug_options, true); -+} -+#endif -+/*MODIFIED CODE END*/ + ++ debug('afterConnectAll'); + - } // namespace node - - #if !HAVE_INSPECTOR -diff --git a/examples/pxScene2d/external/libnode-v10.15.3/src/node.h b/examples/pxScene2d/external/libnode-v10.15.3/src/node.h -index 2a6f5b5..6bf2b29 100755 ---- a/examples/pxScene2d/external/libnode-v10.15.3/src/node.h -+++ b/examples/pxScene2d/external/libnode-v10.15.3/src/node.h -@@ -204,6 +204,12 @@ typedef intptr_t ssize_t; - - namespace node { - ++ assert(self.connecting); + -+/*MODIFIED CODE BEGIN*/ -+NODE_EXTERN extern v8::Isolate* node_isolate; -+NODE_EXTERN extern bool node_is_initialized; -+/*MODIFIED CODE END*/ ++ if (status === 0) { ++ self.connecting = false; ++ self._sockname = null; ++ self.readable = readable; ++ if (!self._writableState.ended) ++ self.writable = writable; ++ self._unrefTimer(); + - // TODO(addaleax): Remove all of these. - NODE_DEPRECATED("use command-line flags", - NODE_EXTERN extern bool no_deprecation); -@@ -237,6 +243,10 @@ NODE_EXTERN void FreeArrayBufferAllocator(ArrayBufferAllocator* allocator); - class IsolateData; - class Environment; - -+/*MODIFIED CODE BEGIN*/ -+NODE_EXTERN bool ShouldAbortOnUncaughtException(v8::Isolate* isolate); -+/*MODIFIED CODE END*/ ++ self.emit('connect'); ++ self.emit('ready'); + - class NODE_EXTERN MultiIsolatePlatform : public v8::Platform { - public: - virtual ~MultiIsolatePlatform() { } -@@ -253,6 +263,12 @@ class NODE_EXTERN MultiIsolatePlatform : public v8::Platform { - virtual void UnregisterIsolate(IsolateData* isolate_data) = 0; - }; - -+/*MODIFIED CODE BEGIN*/ -+#if HAVE_INSPECTOR -+NODE_EXTERN void InspectorStart(Environment* env, const char* path, MultiIsolatePlatform* platform); -+#endif -+/*MODIFIED CODE END*/ ++ // start the first read, or get an immediate EOF. ++ // this doesn't actually consume any bytes, because len=0. ++ if (readable && !self.isPaused()) ++ self.read(0); + - // Creates a new isolate with Node.js-specific settings. - NODE_EXTERN v8::Isolate* NewIsolate(ArrayBufferAllocator* allocator); - -@@ -296,10 +312,11 @@ NODE_EXTERN void FreeEnvironment(Environment* env); - // If NODE_USE_V8_PLATFORM haven't been defined when Node.js was built, - // it returns nullptr. - NODE_EXTERN MultiIsolatePlatform* GetMainThreadMultiIsolatePlatform(); -- -+/* MODIFIED CODE BEGIN */ - NODE_EXTERN MultiIsolatePlatform* CreatePlatform( - int thread_pool_size, -- node::tracing::TracingController* tracing_controller); -+ node::tracing::TracingController* tracing_controller=NULL); ++ } else { ++ if (util === undefined) util = require('util'); ++ const code = util.getSystemErrorName(status); ++ } ++} +/* MODIFIED CODE END */ - MultiIsolatePlatform* InitializeV8Platform(int thread_pool_size); - NODE_EXTERN void FreePlatform(MultiIsolatePlatform* platform); - -diff --git a/examples/pxScene2d/external/libnode-v10.15.3/src/node_contextify.cc b/examples/pxScene2d/external/libnode-v10.15.3/src/node_contextify.cc -index a1903d9..70fd8ca 100755 ---- a/examples/pxScene2d/external/libnode-v10.15.3/src/node_contextify.cc -+++ b/examples/pxScene2d/external/libnode-v10.15.3/src/node_contextify.cc -@@ -796,6 +796,14 @@ void ContextifyScript::RunInThisContext( - - CHECK(args[2]->IsBoolean()); - bool break_on_sigint = args[2]->IsTrue(); -+ /* MODIFIED CODE BEGIN */ -+ // https://github.com/nodejs/node/issues/14757 -+ // without this doesn't run in the current context but rather the top level context -+ // We need to be careful about merging this in and side effects -+ auto context = args.GetIsolate()->GetEnteredContext(); -+ if (context.IsEmpty()) context = env->context(); -+ Context::Scope context_scope(context); -+ /* MODIFIED CODE END */ - - // Do the eval within this context - EvalMachine(env, timeout, display_errors, break_on_sigint, args); -@@ -1119,4 +1127,75 @@ void Initialize(Local target, - } // namespace contextify - } // namespace node -+/*MODIFIED CODE BEGIN*/ -+namespace node -+{ -+namespace contextify -+{ -+void deleteContextifyContext(void *ctx) -+{ -+ ContextifyContext* context = (ContextifyContext*)ctx; -+ if (nullptr != context) -+ delete context; -+} -+ -+v8::Handle makeContext(v8::Isolate *isolate, v8::Handle sandbox, const ContextOptions& options) // basically MakeContext() circa line 268 -+{ -+ if (!isolate) -+ { -+ printf("\nERROR: bad isolate pointer."); -+ return Local(); // NULL; -+ } -+ -+ Environment* env = Environment::GetCurrent(isolate); -+// HandleScope scope(env->isolate()); -+ -+ if (!sandbox->IsObject()) -+ { -+ env->ThrowTypeError("sandbox argument must be an object."); -+ return Local(); // NULL; -+ } -+ -+ EscapableHandleScope scope( isolate ); -+ -+ // Local sandbox = args[0].As(); -+ -+ Local symbol_name = -+ FIXED_ONE_BYTE_STRING(isolate, "_contextifyPrivate"); -+ -+ // Don't allow contextifying a sandbox multiple times. -+ Local private_symbol_name = v8::Private::ForApi(isolate, symbol_name); -+ CHECK( -+ !sandbox->HasPrivate( -+ env->context(), -+ private_symbol_name).FromJust()); -+ -+ TryCatch try_catch(isolate); -+ ContextifyContext* context = new ContextifyContext(env, sandbox, options); -+ -+ if (try_catch.HasCaught()) -+ { -+ try_catch.ReThrow(); -+ return Local(); // NULL; -+ } -+ -+ if (context->context().IsEmpty()) -+ { -+ return Local(); // NULL; -+ } -+ -+ Local hidden_context = External::New(isolate, context); -+ sandbox->SetPrivate( -+ env->context(), -+ private_symbol_name, -+ hidden_context); -+ -+ Local local_context = context->context(); // returns a local context -+ -+ return scope.Escape( local_context ); -+} -+} -+} // namespace node -+/*MODIFIED CODE END*/ -+ - NODE_BUILTIN_MODULE_CONTEXT_AWARE(contextify, node::contextify::Initialize) -diff --git a/examples/pxScene2d/external/libnode-v10.15.3/src/node_contextify_mods.h b/examples/pxScene2d/external/libnode-v10.15.3/src/node_contextify_mods.h -new file mode 100644 -index 0000000..aa9979a ---- /dev/null -+++ b/examples/pxScene2d/external/libnode-v10.15.3/src/node_contextify_mods.h -@@ -0,0 +1,19 @@ -+// This is not part of Node... added to expose needed methods. -+ -+#include "v8.h" -+ -+/*MODIFIED CODE BEGIN*/ -+ -+namespace node -+{ -+namespace contextify -+{ -+ class Environment; -+ -+ v8::Handle makeContext(v8::Isolate *isolate, v8::Handle sandbox, const ContextOptions& options); -+ void deleteContextifyContext(void*); -+} -+} -+/*MODIFIED CODE END*/ -+ -+ -diff --git a/examples/pxScene2d/external/libnode-v10.15.3/src/node_http_parser.cc b/examples/pxScene2d/external/libnode-v10.15.3/src/node_http_parser.cc -index b29cdf4..fbc49d8 100755 ---- a/examples/pxScene2d/external/libnode-v10.15.3/src/node_http_parser.cc -+++ b/examples/pxScene2d/external/libnode-v10.15.3/src/node_http_parser.cc -@@ -439,7 +439,15 @@ class Parser : public AsyncWrap, public StreamListener { - Parser* parser; - ASSIGN_OR_RETURN_UNWRAP(&parser, args.Holder()); - -- CHECK(parser->current_buffer_.IsEmpty()); -+ /* MODIFIED CODE BEGIN */ -+ //CHECK(parser->current_buffer_.IsEmpty()); -+ if (false == parser->current_buffer_.IsEmpty()) -+ { -+ parser->got_exception_ = true; -+ return; -+ } -+ /* MODIFIED CODE END */ -+ - parser->got_exception_ = false; - - int rv = http_parser_execute(&(parser->parser_), &settings, nullptr, 0); -diff --git a/examples/pxScene2d/external/libnode-v10.15.3/src/node_internals.h b/examples/pxScene2d/external/libnode-v10.15.3/src/node_internals.h -index 12089bc..7e8bf86 100755 ---- a/examples/pxScene2d/external/libnode-v10.15.3/src/node_internals.h -+++ b/examples/pxScene2d/external/libnode-v10.15.3/src/node_internals.h -@@ -253,7 +253,9 @@ void AppendExceptionLine(Environment* env, - v8::Local message, - enum ErrorHandlingMode mode); + function Server(options, connectionListener) { + if (!(this instanceof Server)) +diff --git a/examples/pxScene2d/external/libnode-v10.15.3/node.gyp b/examples/pxScene2d/external/libnode-v10.15.3/node.gyp +index a8de196..607a7db 100755 +--- a/examples/pxScene2d/external/libnode-v10.15.3/node.gyp ++++ b/examples/pxScene2d/external/libnode-v10.15.3/node.gyp +@@ -36,7 +36,6 @@ + 'lib/console.js', + 'lib/constants.js', + 'lib/crypto.js', +- 'lib/cluster.js', + 'lib/dgram.js', + 'lib/dns.js', + 'lib/domain.js', +@@ -89,12 +88,6 @@ + 'lib/internal/buffer.js', + 'lib/internal/cli_table.js', + 'lib/internal/child_process.js', +- 'lib/internal/cluster/child.js', +- 'lib/internal/cluster/master.js', +- 'lib/internal/cluster/round_robin_handle.js', +- 'lib/internal/cluster/shared_handle.js', +- 'lib/internal/cluster/utils.js', +- 'lib/internal/cluster/worker.js', + 'lib/internal/crypto/certificate.js', + 'lib/internal/crypto/cipher.js', + 'lib/internal/crypto/diffiehellman.js', +@@ -168,8 +161,6 @@ + 'lib/internal/http2/core.js', + 'lib/internal/http2/compat.js', + 'lib/internal/http2/util.js', +- 'lib/internal/v8_prof_polyfill.js', +- 'lib/internal/v8_prof_processor.js', + 'lib/internal/validators.js', + 'lib/internal/stream_base_commons.js', + 'lib/internal/vm/source_text_module.js', +@@ -184,17 +175,6 @@ + 'lib/internal/streams/pipeline.js', + 'lib/internal/streams/end-of-stream.js', + 'lib/internal/wrap_js_stream.js', +- 'deps/v8/tools/splaytree.js', +- 'deps/v8/tools/codemap.js', +- 'deps/v8/tools/consarray.js', +- 'deps/v8/tools/csvparser.js', +- 'deps/v8/tools/profile.js', +- 'deps/v8/tools/profile_view.js', +- 'deps/v8/tools/logreader.js', +- 'deps/v8/tools/arguments.js', +- 'deps/v8/tools/tickprocessor.js', +- 'deps/v8/tools/SourceMap.js', +- 'deps/v8/tools/tickprocessor-driver.js', + 'deps/node-inspect/lib/_inspect.js', + 'deps/node-inspect/lib/internal/inspect_client.js', + 'deps/node-inspect/lib/internal/inspect_repl.js', +diff --git a/examples/pxScene2d/external/libnode-v10.15.3/src/bootstrapper.cc b/examples/pxScene2d/external/libnode-v10.15.3/src/bootstrapper.cc +index d23a145..ee2f1a2 100755 +--- a/examples/pxScene2d/external/libnode-v10.15.3/src/bootstrapper.cc ++++ b/examples/pxScene2d/external/libnode-v10.15.3/src/bootstrapper.cc +@@ -8,6 +8,9 @@ + namespace node { --[[noreturn]] void FatalError(const char* location, const char* message); + using v8::Array; +/* MODIFIED CODE BEGIN */ -+/*[[noreturn]]*/ void FatalError(const char* location, const char* message); ++using v8::ArrayBuffer; +/* MODIFIED CODE END */ - - // Like a `TryCatch` but exits the process if an exception was caught. - class FatalTryCatch : public v8::TryCatch { -diff --git a/examples/pxScene2d/external/libnode-v10.15.3/src/node_watchdog.cc b/examples/pxScene2d/external/libnode-v10.15.3/src/node_watchdog.cc -index 4b902aa..382bf7b 100755 ---- a/examples/pxScene2d/external/libnode-v10.15.3/src/node_watchdog.cc -+++ b/examples/pxScene2d/external/libnode-v10.15.3/src/node_watchdog.cc -@@ -244,7 +244,10 @@ bool SigintWatchdogHelper::Stop() { - CHECK_EQ(0, pthread_join(thread_, nullptr)); - has_running_thread_ = false; - -- RegisterSignalHandler(SIGINT, SignalExit, true); -+ /* MODIFIED CODE BEGIN */ -+ // To make sure SIGINT signal is not caught by libnode -+ //RegisterSignalHandler(SIGINT, SignalExit, true); -+ /* MODIFIED CODE END */ - #else - watchdog_disabled_ = true; - #endif -diff --git a/examples/pxScene2d/external/libnode-v10.15.3/vcbuild.bat b/examples/pxScene2d/external/libnode-v10.15.3/vcbuild.bat -index 834db64..0c108bd 100755 ---- a/examples/pxScene2d/external/libnode-v10.15.3/vcbuild.bat -+++ b/examples/pxScene2d/external/libnode-v10.15.3/vcbuild.bat -@@ -55,6 +55,10 @@ set "common_test_suites=%js_test_suites% doctool addons addons-napi&set build_ad - set http2_debug= - set nghttp2_debug= - set link_module= -+@rem MODIFIED CODE BEGIN -+set no_optimization= -+set shared_openssl= -+@rem MODIFIED CODE END - set no_cctest= - set cctest= - set openssl_no_asm= -@@ -127,6 +131,10 @@ if /i "%1"=="static" set enable_static=1&goto arg-ok - if /i "%1"=="no-NODE-OPTIONS" set no_NODE_OPTIONS=1&goto arg-ok - if /i "%1"=="debug-nghttp2" set debug_nghttp2=1&goto arg-ok - if /i "%1"=="link-module" set "link_module= --link-module=%2%link_module%"&goto arg-ok-2 -+@rem MODIFIED CODE BEGIN -+if /i "%1"=="no-optimization" set no_optimization=1&goto arg-ok -+if /i "%1"=="shared-openssl" set shared_openssl=1&goto arg-ok -+@rem MODIFIED CODE END - if /i "%1"=="no-cctest" set no_cctest=1&goto arg-ok - if /i "%1"=="cctest" set cctest=1&goto arg-ok - if /i "%1"=="openssl-no-asm" set openssl_no_asm=1&goto arg-ok -@@ -182,6 +190,10 @@ if defined link_module set configure_flags=%configure_flags% %link_module% - if defined i18n_arg set configure_flags=%configure_flags% --with-intl=%i18n_arg% - if defined config_flags set configure_flags=%configure_flags% %config_flags% - if defined target_arch set configure_flags=%configure_flags% --dest-cpu=%target_arch% -+@rem MODIFIED CODE BEGIN -+if defined no_optimization set configure_flags=%configure_flags% --no-optimization -+if defined shared_openssl set configure_flags=%configure_flags% --shared-openssl --shared-openssl-libpath=%CD%\..\openssl-1.0.2o\lib\ --shared-openssl-libname=libeay32,ssleay32 --shared-openssl-includes=%CD%\..\openssl-1.0.2o\include -+@rem MODIFIED CODE END - if defined openssl_no_asm set configure_flags=%configure_flags% --openssl-no-asm - if defined DEBUG_HELPER set configure_flags=%configure_flags% --verbose - -diff --git a/examples/pxScene2d/external/libnode-v10.15.3/configure.py b/examples/pxScene2d/external/libnode-v10.15.3/configure.py -index 0ad986a..c215ee6 100755 ---- a/examples/pxScene2d/external/libnode-v10.15.3/configure.py -+++ b/examples/pxScene2d/external/libnode-v10.15.3/configure.py -@@ -566,6 +566,13 @@ parser.add_option('--without-bundled-v8', - help='do not use V8 includes from the bundled deps folder. ' + - '(This mode is not officially supported for regular applications)') - -+# MODIFIED CODE BEGIN -+parser.add_option('--no-optimization', -+ action='store_true', -+ dest='no_optimization', -+ help='build without optimization') -+# MODIFIED CODE END -+ - parser.add_option('--build-v8-with-gn', - action='store_true', - dest='build_v8_with_gn', -@@ -1237,8 +1244,10 @@ def configure_openssl(o): - of modern CPU cryptographic instructions and will therefore be slower. - Please refer to BUILDING.md''') - -- if options.openssl_no_asm and options.shared_openssl: -- error('--openssl-no-asm is incompatible with --shared-openssl') -+ #MODIFIED CODE BEGIN -+ #if options.openssl_no_asm and options.shared_openssl: -+ # warn('--openssl-no-asm is incompatible with --shared-openssl') -+ #MODIFIED CODE END - - if options.openssl_fips: - error('FIPS is not supported in this version of Node.js') -@@ -1608,6 +1617,9 @@ configure_openssl(output) - configure_intl(output) - configure_static(output) - configure_inspector(output) -+# MODIFIED CODE BEGIN -+output['variables']['no_optimization'] = 1 if options.no_optimization else 0 -+# MODIFIED CODE END - - # variables should be a root level element, - # move everything else to target_defaults -diff --git a/examples/pxScene2d/external/libnode-v10.15.3/lib/internal/vm/source_text_module.js b/examples/pxScene2d/external/libnode-v10.15.3/lib/internal/vm/source_text_module.js -index 1898831bf..8468f944e 100755 ---- a/examples/pxScene2d/external/libnode-v10.15.3/lib/internal/vm/source_text_module.js -+++ b/examples/pxScene2d/external/libnode-v10.15.3/lib/internal/vm/source_text_module.js -@@ -132,7 +132,9 @@ class SourceTextModule { - - Object.defineProperties(this, { - url: { value: url, enumerable: true }, -- context: { value: context, enumerable: true }, -+ // getter leaks... to prevent this make the property configurable and delete when necessary -+ //context: { value: context, enumerable: true }, -+ context: { value: context, enumerable: true, configurable: true}, - }); - } - -diff --git a/examples/pxScene2d/external/libnode-v10.15.3/src/module_wrap.cc b/examples/pxScene2d/external/libnode-v10.15.3/src/module_wrap.cc -index fe6a8e263..056a00d7b 100755 ---- a/examples/pxScene2d/external/libnode-v10.15.3/src/module_wrap.cc -+++ b/examples/pxScene2d/external/libnode-v10.15.3/src/module_wrap.cc -@@ -182,6 +182,9 @@ void ModuleWrap::New(const FunctionCallbackInfo& args) { - - that->SetIntegrityLevel(context, IntegrityLevel::kFrozen); - args.GetReturnValue().Set(that); -+ -+ // ModuleWrap leaks -+ obj->context_.SetWeak(obj, WeakCallback, v8::WeakCallbackType::kParameter); - } - - void ModuleWrap::Link(const FunctionCallbackInfo& args) { -@@ -818,6 +821,11 @@ void ModuleWrap::SetInitializeImportMetaObjectCallback( - HostInitializeImportMetaObjectCallback); - } - -+void ModuleWrap::WeakCallback(const v8::WeakCallbackInfo& data) { -+ ModuleWrap* wrap = data.GetParameter(); -+ delete wrap; -+} -+ - void ModuleWrap::Initialize(Local target, - Local unused, - Local context) { -diff --git a/examples/pxScene2d/external/libnode-v10.15.3/src/module_wrap.h b/examples/pxScene2d/external/libnode-v10.15.3/src/module_wrap.h -index 0e352c657..5599a52dd 100755 ---- a/examples/pxScene2d/external/libnode-v10.15.3/src/module_wrap.h -+++ b/examples/pxScene2d/external/libnode-v10.15.3/src/module_wrap.h -@@ -82,6 +82,8 @@ class ModuleWrap : public BaseObject { - v8::Local specifier, - v8::Local referrer); - static ModuleWrap* GetFromModule(node::Environment*, v8::Local); -+ static void WeakCallback( -+ const v8::WeakCallbackInfo& data); - - Persistent module_; - Persistent url_; -diff --git a/examples/pxScene2d/external/libnode-v10.15.3/src/env.h b/examples/pxScene2d/external/libnode-v10.15.3/src/env.h -index 66c69e8d0..e229a8fbd 100755 ---- a/examples/pxScene2d/external/libnode-v10.15.3/src/env.h -+++ b/examples/pxScene2d/external/libnode-v10.15.3/src/env.h -@@ -558,7 +558,12 @@ class Environment { - - class TickInfo { - public: -- inline AliasedBuffer& fields(); + using v8::Context; + using v8::Function; + using v8::FunctionCallbackInfo; +@@ -24,6 +27,10 @@ using v8::Promise; + using v8::PromiseRejectEvent; + using v8::PromiseRejectMessage; + using v8::String; +/* MODIFIED CODE BEGIN */ -+ //inline AliasedBuffer& fields(); -+ //inline AliasedBuffer& fields(); -+ inline uint32_t* fields(); -+ inline int fields_count() const; ++using v8::Uint32Array; ++using v8::Uint8Array; +/* MODIFIED CODE END */ - inline bool has_scheduled() const; - inline bool has_promise_rejections() const; - inline bool has_thrown() const; -@@ -576,9 +581,10 @@ class Environment { - kHasThrown, - kFieldsCount - }; -- -- AliasedBuffer fields_; -- + using v8::Value; + + void SetupProcessObject(const FunctionCallbackInfo& args) { +@@ -51,7 +58,14 @@ void SetupNextTick(const FunctionCallbackInfo& args) { + run_microtasks_fn->SetName(FIXED_ONE_BYTE_STRING(isolate, "runMicrotasks")); + + Local ret = Array::New(isolate, 2); +- ret->Set(context, 0, env->tick_info()->fields().GetJSArray()).FromJust(); +/* MODIFIED CODE BEGIN */ -+ //AliasedBuffer fields_; -+ uint32_t fields_[kFieldsCount]; ++ uint32_t* const fields = env->tick_info()->fields(); ++ uint32_t const fields_count = env->tick_info()->fields_count(); ++ Local array_buffer = ++ ArrayBuffer::New(env->isolate(), fields, sizeof(*fields) * fields_count); ++ ret->Set(context, 0, Uint32Array::New(array_buffer, 0, fields_count)).FromJust(); ++ //ret->Set(context, 0, env->tick_info()->fields().GetJSArray()).FromJust(); +/* MODIFIED CODE END */ - DISALLOW_COPY_AND_ASSIGN(TickInfo); - }; + ret->Set(context, 1, run_microtasks_fn).FromJust(); + args.GetReturnValue().Set(ret); diff --git a/examples/pxScene2d/external/libnode-v10.15.3/src/env-inl.h b/examples/pxScene2d/external/libnode-v10.15.3/src/env-inl.h -index 4af5add4c..89a4c0329 100755 +index 4af5add..89a4c03 100755 --- a/examples/pxScene2d/external/libnode-v10.15.3/src/env-inl.h +++ b/examples/pxScene2d/external/libnode-v10.15.3/src/env-inl.h @@ -156,13 +156,16 @@ inline bool Environment::AsyncHooks::pop_async_id(double async_id) { @@ -1074,402 +1014,637 @@ index 4af5add4c..89a4c0329 100755 inline bool Environment::TickInfo::has_scheduled() const { return fields_[kHasScheduled] == 1; } -diff --git a/examples/pxScene2d/external/libnode-v10.15.3/src/bootstrapper.cc b/examples/pxScene2d/external/libnode-v10.15.3/src/bootstrapper.cc -index d23a145ca..ee2f1a2e5 100755 ---- a/examples/pxScene2d/external/libnode-v10.15.3/src/bootstrapper.cc -+++ b/examples/pxScene2d/external/libnode-v10.15.3/src/bootstrapper.cc -@@ -8,6 +8,9 @@ - namespace node { +diff --git a/examples/pxScene2d/external/libnode-v10.15.3/src/env.h b/examples/pxScene2d/external/libnode-v10.15.3/src/env.h +index 66c69e8..e229a8f 100755 +--- a/examples/pxScene2d/external/libnode-v10.15.3/src/env.h ++++ b/examples/pxScene2d/external/libnode-v10.15.3/src/env.h +@@ -558,7 +558,12 @@ class Environment { - using v8::Array; + class TickInfo { + public: +- inline AliasedBuffer& fields(); +/* MODIFIED CODE BEGIN */ -+using v8::ArrayBuffer; ++ //inline AliasedBuffer& fields(); ++ //inline AliasedBuffer& fields(); ++ inline uint32_t* fields(); ++ inline int fields_count() const; +/* MODIFIED CODE END */ - using v8::Context; - using v8::Function; - using v8::FunctionCallbackInfo; -@@ -24,6 +27,10 @@ using v8::Promise; - using v8::PromiseRejectEvent; - using v8::PromiseRejectMessage; - using v8::String; + inline bool has_scheduled() const; + inline bool has_promise_rejections() const; + inline bool has_thrown() const; +@@ -576,9 +581,10 @@ class Environment { + kHasThrown, + kFieldsCount + }; +- +- AliasedBuffer fields_; +- +/* MODIFIED CODE BEGIN */ -+using v8::Uint32Array; -+using v8::Uint8Array; ++ //AliasedBuffer fields_; ++ uint32_t fields_[kFieldsCount]; +/* MODIFIED CODE END */ + DISALLOW_COPY_AND_ASSIGN(TickInfo); + }; + +diff --git a/examples/pxScene2d/external/libnode-v10.15.3/src/module_wrap.cc b/examples/pxScene2d/external/libnode-v10.15.3/src/module_wrap.cc +index fe6a8e2..056a00d 100755 +--- a/examples/pxScene2d/external/libnode-v10.15.3/src/module_wrap.cc ++++ b/examples/pxScene2d/external/libnode-v10.15.3/src/module_wrap.cc +@@ -182,6 +182,9 @@ void ModuleWrap::New(const FunctionCallbackInfo& args) { + + that->SetIntegrityLevel(context, IntegrityLevel::kFrozen); + args.GetReturnValue().Set(that); ++ ++ // ModuleWrap leaks ++ obj->context_.SetWeak(obj, WeakCallback, v8::WeakCallbackType::kParameter); + } + + void ModuleWrap::Link(const FunctionCallbackInfo& args) { +@@ -818,6 +821,11 @@ void ModuleWrap::SetInitializeImportMetaObjectCallback( + HostInitializeImportMetaObjectCallback); + } + ++void ModuleWrap::WeakCallback(const v8::WeakCallbackInfo& data) { ++ ModuleWrap* wrap = data.GetParameter(); ++ delete wrap; ++} ++ + void ModuleWrap::Initialize(Local target, + Local unused, + Local context) { +diff --git a/examples/pxScene2d/external/libnode-v10.15.3/src/module_wrap.h b/examples/pxScene2d/external/libnode-v10.15.3/src/module_wrap.h +index 0e352c6..5599a52 100755 +--- a/examples/pxScene2d/external/libnode-v10.15.3/src/module_wrap.h ++++ b/examples/pxScene2d/external/libnode-v10.15.3/src/module_wrap.h +@@ -82,6 +82,8 @@ class ModuleWrap : public BaseObject { + v8::Local specifier, + v8::Local referrer); + static ModuleWrap* GetFromModule(node::Environment*, v8::Local); ++ static void WeakCallback( ++ const v8::WeakCallbackInfo& data); + + Persistent module_; + Persistent url_; +diff --git a/examples/pxScene2d/external/libnode-v10.15.3/src/node.cc b/examples/pxScene2d/external/libnode-v10.15.3/src/node.cc +index 9fb5ab3..e86dd94 100755 +--- a/examples/pxScene2d/external/libnode-v10.15.3/src/node.cc ++++ b/examples/pxScene2d/external/libnode-v10.15.3/src/node.cc +@@ -173,7 +173,9 @@ using v8::V8; using v8::Value; - void SetupProcessObject(const FunctionCallbackInfo& args) { -@@ -51,7 +58,14 @@ void SetupNextTick(const FunctionCallbackInfo& args) { - run_microtasks_fn->SetName(FIXED_ONE_BYTE_STRING(isolate, "runMicrotasks")); + static bool v8_is_profiling = false; +-static bool node_is_initialized = false; ++/* MODIFIED CODE BEGIN */ ++bool node_is_initialized = false; ++/* MODIFIED CODE END */ + static uv_once_t init_modpending_once = UV_ONCE_INIT; + static uv_key_t thread_local_modpending; + static node_module* modlist_builtin; +@@ -196,8 +198,10 @@ std::shared_ptr per_process_opts { + new PerProcessOptions() }; - Local ret = Array::New(isolate, 2); -- ret->Set(context, 0, env->tick_info()->fields().GetJSArray()).FromJust(); + static Mutex node_isolate_mutex; +-static Isolate* node_isolate; +- +/* MODIFIED CODE BEGIN */ -+ uint32_t* const fields = env->tick_info()->fields(); -+ uint32_t const fields_count = env->tick_info()->fields_count(); -+ Local array_buffer = -+ ArrayBuffer::New(env->isolate(), fields, sizeof(*fields) * fields_count); -+ ret->Set(context, 0, Uint32Array::New(array_buffer, 0, fields_count)).FromJust(); -+ //ret->Set(context, 0, env->tick_info()->fields().GetJSArray()).FromJust(); ++Isolate* node_isolate; ++FILE* errorFile = NULL; +/* MODIFIED CODE END */ - ret->Set(context, 1, run_microtasks_fn).FromJust(); + // Ensures that __metadata trace events are only emitted + // when tracing is enabled. + class NodeTraceStateObserver : +@@ -387,6 +391,29 @@ static struct { + static const unsigned kMaxSignal = 32; + #endif - args.GetReturnValue().Set(ret); -diff --git a/examples/pxScene2d/external/libnode-v10.15.3/src/node_platform.cc b/examples/pxScene2d/external/libnode-v10.15.3/src/node_platform.cc -index fd8d04540..c4286d459 100755 ---- a/examples/pxScene2d/external/libnode-v10.15.3/src/node_platform.cc -+++ b/examples/pxScene2d/external/libnode-v10.15.3/src/node_platform.cc -@@ -329,6 +329,13 @@ void PerIsolatePlatformData::RunForegroundTask(std::unique_ptr task) { - Isolate* isolate = Isolate::GetCurrent(); - HandleScope scope(isolate); - Environment* env = Environment::GetCurrent(isolate); -+/*MODIFIED CODE BEGIN*/ -+ if (isolate->GetCurrentContext().IsEmpty() || (NULL == env)) ++/* MODIFIED CODE BEGIN */ ++void PrintErrorStringToFile(const char* format, ...) { ++ va_list filelog; ++ va_start(filelog, format); ++ const char* val = getenv("NODE_ERROR_FILE"); ++ if (val) { ++ errorFile = fopen(val,"w"); ++ } ++ else + { -+ task->Run(); -+ return; ++ errorFile = fopen("/tmp/nodeerror.log","w"); + } -+/*MODIFIED CODE END*/ - InternalCallbackScope cb_scope(env, Local(), { 0, 0 }, - InternalCallbackScope::kAllowEmptyResource); - task->Run(); -@@ -356,14 +363,18 @@ void PerIsolatePlatformData::CancelPendingDelayedTasks() { ++ if (NULL != errorFile) ++ { ++ vfprintf(errorFile, format, filelog); ++ fclose(errorFile); ++ errorFile = NULL; ++ } ++ va_end(filelog); ++} ++/* MODIFIED CODE END */ ++ ++ + void PrintErrorString(const char* format, ...) { + va_list ap; + va_start(ap, format); +@@ -610,8 +637,9 @@ void* ArrayBufferAllocator::Allocate(size_t size) { + return UncheckedMalloc(size); + } - void NodePlatform::DrainBackgroundTasks(Isolate* isolate) { - std::shared_ptr per_isolate = ForIsolate(isolate); +-namespace { - -- do { -- // Right now, there is no way to drain only background tasks associated -- // with a specific isolate, so this sometimes does more work than -- // necessary. In the long run, that functionality is probably going to -- // be available anyway, though. -- background_task_runner_->BlockingDrain(); -- } while (per_isolate->FlushForegroundTasksInternal()); ++/* MODIFIED CODE BEGIN */ ++//namespace { ++/* MODIFIED CODE END */ + bool ShouldAbortOnUncaughtException(Isolate* isolate) { + HandleScope scope(isolate); + Environment* env = Environment::GetCurrent(isolate); +@@ -619,9 +647,9 @@ bool ShouldAbortOnUncaughtException(Isolate* isolate) { + env->should_abort_on_uncaught_toggle()[0] && + !env->inside_should_not_abort_on_uncaught_scope(); + } +- +-} // anonymous namespace +- ++/* MODIFIED CODE BEGIN */ ++//} // anonymous namespace ++/* MODIFIED CODE END */ + + void AddPromiseHook(Isolate* isolate, promise_hook_func fn, void* arg) { + Environment* env = Environment::GetCurrent(isolate); +@@ -896,6 +924,9 @@ void AppendExceptionLine(Environment* env, + + uv_tty_reset_mode(); + PrintErrorString("\n%s", arrow); ++ /* MODIFIED CODE BEGIN */ ++ PrintErrorStringToFile("\n%s", arrow); ++ /* MODIFIED CODE END */ + return; + } + +@@ -939,9 +970,15 @@ void ReportException(Environment* env, + if (trace.length() > 0 && !trace_value->IsUndefined()) { + if (arrow.IsEmpty() || !arrow->IsString() || decorated) { + PrintErrorString("%s\n", *trace); ++ /* MODIFIED CODE BEGIN */ ++ PrintErrorStringToFile("%s\n", *trace); ++ /* MODIFIED CODE END */ + } else { + node::Utf8Value arrow_string(env->isolate(), arrow); + PrintErrorString("%s\n%s\n", *arrow_string, *trace); ++ /* MODIFIED CODE BEGIN */ ++ PrintErrorStringToFile("%s\n%s\n", *arrow_string, *trace); ++ /* MODIFIED CODE END */ + } + } else { + // this really only happens for RangeErrors, since they're the only +@@ -965,18 +1002,34 @@ void ReportException(Environment* env, + + PrintErrorString("%s\n", *message ? *message : + ""); ++ /* MODIFIED CODE BEGIN */ ++ PrintErrorStringToFile("%s\n", *message ? *message : ++ ""); ++ /* MODIFIED CODE END */ ++ + } else { + node::Utf8Value name_string(env->isolate(), name); + node::Utf8Value message_string(env->isolate(), message); + + if (arrow.IsEmpty() || !arrow->IsString() || decorated) { + PrintErrorString("%s: %s\n", *name_string, *message_string); ++ /* MODIFIED CODE BEGIN */ ++ PrintErrorStringToFile("%s: %s\n", *name_string, *message_string); ++ /* MODIFIED CODE END */ ++ + } else { + node::Utf8Value arrow_string(env->isolate(), arrow); + PrintErrorString("%s\n%s: %s\n", + *arrow_string, + *name_string, + *message_string); ++ /* MODIFIED CODE BEGIN */ ++ PrintErrorStringToFile("%s\n%s: %s\n", ++ *arrow_string, ++ *name_string, ++ *message_string); ++ /* MODIFIED CODE END */ ++ + } + } + } +@@ -1074,6 +1127,8 @@ static void WaitForInspectorDisconnect(Environment* env) { + + + static void Exit(const FunctionCallbackInfo& args) { ++ printf("Inside exit !!! \n"); ++ fflush(stdout); + Environment* env = Environment::GetCurrent(args); + WaitForInspectorDisconnect(env); + v8_platform.StopTracingAgent(); +@@ -1340,14 +1395,20 @@ static void OnFatalError(const char* location, const char* message) { + PrintErrorString("FATAL ERROR: %s\n", message); + } + fflush(stderr); +- ABORT(); + /* MODIFIED CODE BEGIN */ -+ if (NULL != per_isolate) -+ { -+ do { -+ // Right now, there is no way to drain only background tasks associated -+ // with a specific isolate, so this sometimes does more work than -+ // necessary. In the long run, that functionality is probably going to -+ // be available anyway, though. -+ background_task_runner_->BlockingDrain(); -+ } while (per_isolate->FlushForegroundTasksInternal()); -+ } ++ //ABORT(); + /* MODIFIED CODE END */ } - bool PerIsolatePlatformData::FlushForegroundTasksInternal() { -@@ -411,12 +422,19 @@ std::shared_ptr - NodePlatform::ForIsolate(Isolate* isolate) { - Mutex::ScopedLock lock(per_isolate_mutex_); - std::shared_ptr data = per_isolate_[isolate]; -- CHECK(data); -+ // MODIFIED CODE BEGIN -+ // CHECK(data); -+ // MODIFIED CODE END - return data; + +-[[noreturn]] void FatalError(const char* location, const char* message) { ++/* MODIFIED CODE BEGIN */ ++/*[[noreturn]]*/ void FatalError(const char* location, const char* message) { ++/* MODIFIED CODE END */ + OnFatalError(location, message); + // to suppress compiler warning +- ABORT(); ++/* MODIFIED CODE BEGIN */ ++ //ABORT(); ++/* MODIFIED CODE END */ } - void NodePlatform::CallOnForegroundThread(Isolate* isolate, Task* task) { -- ForIsolate(isolate)->PostTask(std::unique_ptr(task)); -+ /* MODIFIED CODE BEGIN */ -+ std::shared_ptr data = ForIsolate(isolate); -+ if (nullptr != data.get()) { -+ data->PostTask(std::unique_ptr(task)); + +@@ -1355,7 +1416,9 @@ FatalTryCatch::~FatalTryCatch() { + if (HasCaught()) { + HandleScope scope(env_->isolate()); + ReportException(env_, *this); +- exit(7); ++ /* MODIFIED CODE BEGIN */ ++ //exit(7); ++ /* MODIFIED CODE END */ + } + } + +@@ -1376,7 +1439,9 @@ void FatalException(Isolate* isolate, + // Failed before the process._fatalException function was added! + // this is probably pretty bad. Nothing to do but report and exit. + ReportException(env, error, message); +- exit(6); ++ /* MODIFIED CODE BEGIN */ ++ //exit(6); ++ /* MODIFIED CODE END */ + } else { + TryCatch fatal_try_catch(isolate); + +@@ -1393,7 +1458,9 @@ void FatalException(Isolate* isolate, + if (fatal_try_catch.HasCaught()) { + // The fatal exception function threw, so we must exit + ReportException(env, fatal_try_catch); +- exit(7); ++ /* MODIFIED CODE BEGIN */ ++ //exit(7); ++ /* MODIFIED CODE END */ + } else if (caught.ToLocalChecked()->IsFalse()) { + ReportException(env, error, message); + +@@ -1403,9 +1470,13 @@ void FatalException(Isolate* isolate, + Local code; + if (!process_object->Get(env->context(), exit_code).ToLocal(&code) || + !code->IsInt32()) { +- exit(1); ++ /* MODIFIED CODE BEGIN */ ++ //exit(1); ++ /* MODIFIED CODE END */ + } +- exit(code.As()->Value()); ++ /* MODIFIED CODE BEGIN */ ++ //exit(code.As()->Value()); ++ /* MODIFIED CODE END */ + } + } + } +@@ -2805,6 +2876,14 @@ MultiIsolatePlatform* GetMainThreadMultiIsolatePlatform() { + MultiIsolatePlatform* CreatePlatform( + int thread_pool_size, + node::tracing::TracingController* tracing_controller) { ++ /* MODIFIED CODE BEGIN */ ++ if (0 == thread_pool_size) ++ { ++ v8_platform.Initialize( ++ per_process_opts->v8_thread_pool_size); ++ return v8_platform.Platform(); + } + /* MODIFIED CODE END */ + return new NodePlatform(thread_pool_size, tracing_controller); } - void NodePlatform::CallDelayedOnForegroundThread(Isolate* isolate, -diff --git a/examples/pxScene2d/external/libnode-v10.15.3/lib/net.js b/examples/pxScene2d/external/libnode-v10.15.3/lib/net.js -index e40aaa870..793014f12 100755 ---- a/examples/pxScene2d/external/libnode-v10.15.3/lib/net.js -+++ b/examples/pxScene2d/external/libnode-v10.15.3/lib/net.js -@@ -812,6 +812,119 @@ function checkBindError(err, port, handle) { - return err; +@@ -3050,6 +3129,21 @@ void RegisterBuiltinModules() { + #undef V } -+/* MODIFIED CODE BEGIN */ -+function internalConnectMultipleAddress( -+ self, address, port, localAddress, localPort) { -+ var ipV4addresses = address['v4address'] -+ var ipv4count = address['v4count'] -+ var ipV6addresses = address['v6address'] -+ var ipv6count = address['v6count'] -+ var tempLocalAddress = ""; -+ var bindSucceeded = true; -+ var connectSucceeded = false; -+ var err; ++/*MODIFIED CODE BEGIN*/ ++#if HAVE_INSPECTOR ++void InspectorStart(Environment* env, const char* path, const char* address, int port) { ++ env->options()->debug_options->host_port.host_name = address; ++ env->options()->debug_options->host_port.port = port; ++ env->inspector_agent()->Start(path, env->options()->debug_options, true); ++} + -+ // IPV6 bind -+ bindSucceeded = true; -+ if (localAddress || localPort) { -+ tempLocalAddress = localAddress || '::'; -+ err = self._handle.bind6(tempLocalAddress, localPort); -+ debug('binding to localAddress: %s and localPort: %d (addressType: 6)', -+ tempLocalAddress, localPort); ++void InspectorStop(Environment* env) { ++ env->inspector_agent()->Stop(); ++} ++#endif ++/*MODIFIED CODE END*/ + -+ err = checkBindError(err, localPort, self._handle); -+ if (err) { -+ console.log("Bind error for IPV6 : " + err + " happened for " + tempLocalAddress + " and port " + localPort); -+ bindSucceeded = false; -+ } -+ } + -+ // IPV6 connect -+ connectSucceeded = false; -+ if (true == bindSucceeded) { -+ for (var i=0; iIsBoolean()); + bool break_on_sigint = args[2]->IsTrue(); ++ /* MODIFIED CODE BEGIN */ ++ // https://github.com/nodejs/node/issues/14757 ++ // without this doesn't run in the current context but rather the top level context ++ // We need to be careful about merging this in and side effects ++ auto context = args.GetIsolate()->GetEnteredContext(); ++ if (context.IsEmpty()) context = env->context(); ++ Context::Scope context_scope(context); ++ /* MODIFIED CODE END */ + + // Do the eval within this context + EvalMachine(env, timeout, display_errors, break_on_sigint, args); +@@ -1119,4 +1127,75 @@ void Initialize(Local target, + } // namespace contextify + } // namespace node + ++/*MODIFIED CODE BEGIN*/ ++namespace node ++{ ++namespace contextify ++{ ++void deleteContextifyContext(void *ctx) ++{ ++ ContextifyContext* context = (ContextifyContext*)ctx; ++ if (nullptr != context) ++ delete context; ++} ++ ++v8::Handle makeContext(v8::Isolate *isolate, v8::Handle sandbox, const ContextOptions& options) // basically MakeContext() circa line 268 ++{ ++ if (!isolate) ++ { ++ printf("\nERROR: bad isolate pointer."); ++ return Local(); // NULL; + } + -+ if ((false == bindSucceeded) || (false == connectSucceeded)) ++ Environment* env = Environment::GetCurrent(isolate); ++// HandleScope scope(env->isolate()); ++ ++ if (!sandbox->IsObject()) + { -+ var details = "Address: " + localAddress + ", port: " + localPort -+ console.log("Multiple address connection failed connect - " + address + ":" + port + " " + details); -+ self.destroy(); ++ env->ThrowTypeError("sandbox argument must be an object."); ++ return Local(); // NULL; + } -+} + -+function internalConnectWithReturn(self, address, port, addressType, localAddress, localPort) -+{ -+ assert(self.connecting); -+ var ret = false; -+ var err; ++ EscapableHandleScope scope( isolate ); + -+ if (addressType === 6 || addressType === 4) { -+ const req = new TCPConnectWrap(); -+ req.oncomplete = afterConnectAll; -+ req.address = address; -+ req.port = port; -+ req.localAddress = localAddress; -+ req.localPort = localPort; ++ // Local sandbox = args[0].As(); + -+ if (addressType === 4) -+ err = self._handle.connect(req, address, port); -+ else -+ err = self._handle.connect6(req, address, port); -+ } ++ Local symbol_name = ++ FIXED_ONE_BYTE_STRING(isolate, "_contextifyPrivate"); + -+ if (err) { -+ var sockname = self._getsockname(); -+ var details; ++ // Don't allow contextifying a sandbox multiple times. ++ Local private_symbol_name = v8::Private::ForApi(isolate, symbol_name); ++ CHECK( ++ !sandbox->HasPrivate( ++ env->context(), ++ private_symbol_name).FromJust()); + -+ if (sockname) { -+ details = sockname.address + ':' + sockname.port; -+ } ++ TryCatch try_catch(isolate); ++ ContextifyContext* context = new ContextifyContext(env, sandbox, options); + -+ console.log("Connect error happened : " + err + " , " + details + " , " + address + ":" + port + " ,family: " + addressType); -+ } -+ else ++ if (try_catch.HasCaught()) + { -+ ret = true; ++ try_catch.ReThrow(); ++ return Local(); // NULL; + } -+ return ret; -+} -+/* MODIFIED CODE END */ - - function internalConnect( - self, address, port, addressType, localAddress, localPort) { -@@ -974,11 +1087,13 @@ function lookupAndConnect(self, options) { - - - if (dns === undefined) dns = require('dns'); -+ /* MODIFIED CODE BEGIN */ - var dnsopts = { - family: options.family, -- hints: options.hints || 0 -+ hints: options.hints || 0, - }; -- -+ dnsopts.all = true; -+ /* MODIFIED CODE END */ - if (process.platform !== 'win32' && - dnsopts.family !== 4 && - dnsopts.family !== 6 && -@@ -1008,7 +1123,9 @@ function lookupAndConnect(self, options) { - err.port = options.port; - err.message = err.message + ' ' + options.host + ':' + options.port; - process.nextTick(connectErrorNT, self, err); -- } else if (addressType !== 4 && addressType !== 6) { -+ /* MODIFIED CODE BEGIN */ -+ } else if ((false == dnsopts.all) && addressType !== 4 && addressType !== 6) { -+ /* MODIFIED CODE END */ - err = new ERR_INVALID_ADDRESS_FAMILY(addressType); - err.host = options.host; - err.port = options.port; -@@ -1016,11 +1133,22 @@ function lookupAndConnect(self, options) { - process.nextTick(connectErrorNT, self, err); - } else { - self._unrefTimer(); -- defaultTriggerAsyncIdScope( -- self[async_id_symbol], -- internalConnect, -- self, ip, port, addressType, localAddress, localPort -- ); -+ /* MODIFIED CODE BEGIN */ -+ if (dnsopts.all) { -+ defaultTriggerAsyncIdScope( -+ self[async_id_symbol], -+ internalConnectMultipleAddress, -+ self, ip, port, localAddress, localPort -+ ); -+ } -+ else { -+ defaultTriggerAsyncIdScope( -+ self[async_id_symbol], -+ internalConnect, -+ self, ip, port, addressType, localAddress, localPort -+ ); -+ } -+ /* MODIFIED CODE END */ - } - }); - }); -@@ -1107,6 +1235,41 @@ function afterConnect(status, handle, req, readable, writable) { - } - } - -+/* MODIFIED CODE BEGIN */ -+function afterConnectAll(status, handle, req, readable, writable) { -+ var self = handle[owner_symbol]; + -+ // callback may come after call to destroy -+ if (self.destroyed) { -+ return; ++ if (context->context().IsEmpty()) ++ { ++ return Local(); // NULL; + } + -+ debug('afterConnectAll'); ++ Local hidden_context = External::New(isolate, context); ++ sandbox->SetPrivate( ++ env->context(), ++ private_symbol_name, ++ hidden_context); + -+ assert(self.connecting); ++ Local local_context = context->context(); // returns a local context + -+ if (status === 0) { -+ self.connecting = false; -+ self._sockname = null; -+ self.readable = readable; -+ if (!self._writableState.ended) -+ self.writable = writable; -+ self._unrefTimer(); ++ return scope.Escape( local_context ); ++} ++} ++} // namespace node ++/*MODIFIED CODE END*/ + -+ self.emit('connect'); -+ self.emit('ready'); + NODE_BUILTIN_MODULE_CONTEXT_AWARE(contextify, node::contextify::Initialize) +diff --git a/examples/pxScene2d/external/libnode-v10.15.3/src/node_contextify_mods.h b/examples/pxScene2d/external/libnode-v10.15.3/src/node_contextify_mods.h +new file mode 100644 +index 0000000..aa9979a +--- /dev/null ++++ b/examples/pxScene2d/external/libnode-v10.15.3/src/node_contextify_mods.h +@@ -0,0 +1,19 @@ ++// This is not part of Node... added to expose needed methods. + -+ // start the first read, or get an immediate EOF. -+ // this doesn't actually consume any bytes, because len=0. -+ if (readable && !self.isPaused()) -+ self.read(0); ++#include "v8.h" + -+ } else { -+ if (util === undefined) util = require('util'); -+ const code = util.getSystemErrorName(status); -+ } ++/*MODIFIED CODE BEGIN*/ ++ ++namespace node ++{ ++namespace contextify ++{ ++ class Environment; ++ ++ v8::Handle makeContext(v8::Isolate *isolate, v8::Handle sandbox, const ContextOptions& options); ++ void deleteContextifyContext(void*); +} -+/* MODIFIED CODE END */ - - function Server(options, connectionListener) { - if (!(this instanceof Server)) -diff --git a/examples/pxScene2d/external/libnode-v10.15.3/lib/dns.js b/examples/pxScene2d/external/libnode-v10.15.3/lib/dns.js -index f90d7c1a5..b151f530c 100755 ---- a/examples/pxScene2d/external/libnode-v10.15.3/lib/dns.js -+++ b/examples/pxScene2d/external/libnode-v10.15.3/lib/dns.js -@@ -69,15 +69,30 @@ function onlookupall(err, addresses) { - } ++} ++/*MODIFIED CODE END*/ ++ ++ +diff --git a/examples/pxScene2d/external/libnode-v10.15.3/src/node_http_parser.cc b/examples/pxScene2d/external/libnode-v10.15.3/src/node_http_parser.cc +index b29cdf4..fbc49d8 100755 +--- a/examples/pxScene2d/external/libnode-v10.15.3/src/node_http_parser.cc ++++ b/examples/pxScene2d/external/libnode-v10.15.3/src/node_http_parser.cc +@@ -439,7 +439,15 @@ class Parser : public AsyncWrap, public StreamListener { + Parser* parser; + ASSIGN_OR_RETURN_UNWRAP(&parser, args.Holder()); - var family = this.family; -+ /* MODIFIED CODE BEGIN */ -+ var ipV4Addresses = []; -+ var ipV4count = 0; -+ var ipV6Addresses = [] -+ var ipV6count = 0; -+ var result = {} - for (var i = 0; i < addresses.length; i++) { - const addr = addresses[i]; -- addresses[i] = { -- address: addr, -- family: family || (isIPv4(addr) ? 4 : 6) -- }; -+ var addrfamily = family || (isIPv4(addr) ? 4 : 6) -+ if (addrfamily == 4) { -+ ipV4Addresses[ipV4count] = {address: addr, family: addrfamily} -+ ipV4count++; -+ } -+ else { -+ ipV6Addresses[ipV6count] = {address: addr, family: addrfamily} -+ ipV6count++; +- CHECK(parser->current_buffer_.IsEmpty()); ++ /* MODIFIED CODE BEGIN */ ++ //CHECK(parser->current_buffer_.IsEmpty()); ++ if (false == parser->current_buffer_.IsEmpty()) ++ { ++ parser->got_exception_ = true; ++ return; + } - } ++ /* MODIFIED CODE END */ ++ + parser->got_exception_ = false; + + int rv = http_parser_execute(&(parser->parser_), &settings, nullptr, 0); +diff --git a/examples/pxScene2d/external/libnode-v10.15.3/src/node_internals.h b/examples/pxScene2d/external/libnode-v10.15.3/src/node_internals.h +index 12089bc..7e8bf86 100755 +--- a/examples/pxScene2d/external/libnode-v10.15.3/src/node_internals.h ++++ b/examples/pxScene2d/external/libnode-v10.15.3/src/node_internals.h +@@ -253,7 +253,9 @@ void AppendExceptionLine(Environment* env, + v8::Local message, + enum ErrorHandlingMode mode); + +-[[noreturn]] void FatalError(const char* location, const char* message); ++/* MODIFIED CODE BEGIN */ ++/*[[noreturn]]*/ void FatalError(const char* location, const char* message); ++/* MODIFIED CODE END */ + + // Like a `TryCatch` but exits the process if an exception was caught. + class FatalTryCatch : public v8::TryCatch { +diff --git a/examples/pxScene2d/external/libnode-v10.15.3/src/node_platform.cc b/examples/pxScene2d/external/libnode-v10.15.3/src/node_platform.cc +index fd8d045..c4286d4 100755 +--- a/examples/pxScene2d/external/libnode-v10.15.3/src/node_platform.cc ++++ b/examples/pxScene2d/external/libnode-v10.15.3/src/node_platform.cc +@@ -329,6 +329,13 @@ void PerIsolatePlatformData::RunForegroundTask(std::unique_ptr task) { + Isolate* isolate = Isolate::GetCurrent(); + HandleScope scope(isolate); + Environment* env = Environment::GetCurrent(isolate); ++/*MODIFIED CODE BEGIN*/ ++ if (isolate->GetCurrentContext().IsEmpty() || (NULL == env)) ++ { ++ task->Run(); ++ return; ++ } ++/*MODIFIED CODE END*/ + InternalCallbackScope cb_scope(env, Local(), { 0, 0 }, + InternalCallbackScope::kAllowEmptyResource); + task->Run(); +@@ -356,14 +363,18 @@ void PerIsolatePlatformData::CancelPendingDelayedTasks() { + + void NodePlatform::DrainBackgroundTasks(Isolate* isolate) { + std::shared_ptr per_isolate = ForIsolate(isolate); - -- this.callback(null, addresses); -+ result['v4address'] = ipV4Addresses -+ result['v4count'] = ipV4count -+ result['v6address'] = ipV6Addresses -+ result['v6count'] = ipV6count -+ this.callback(null, result); +- do { +- // Right now, there is no way to drain only background tasks associated +- // with a specific isolate, so this sometimes does more work than +- // necessary. In the long run, that functionality is probably going to +- // be available anyway, though. +- background_task_runner_->BlockingDrain(); +- } while (per_isolate->FlushForegroundTasksInternal()); ++ /* MODIFIED CODE BEGIN */ ++ if (NULL != per_isolate) ++ { ++ do { ++ // Right now, there is no way to drain only background tasks associated ++ // with a specific isolate, so this sometimes does more work than ++ // necessary. In the long run, that functionality is probably going to ++ // be available anyway, though. ++ background_task_runner_->BlockingDrain(); ++ } while (per_isolate->FlushForegroundTasksInternal()); ++ } + /* MODIFIED CODE END */ } + bool PerIsolatePlatformData::FlushForegroundTasksInternal() { +@@ -411,12 +422,19 @@ std::shared_ptr + NodePlatform::ForIsolate(Isolate* isolate) { + Mutex::ScopedLock lock(per_isolate_mutex_); + std::shared_ptr data = per_isolate_[isolate]; +- CHECK(data); ++ // MODIFIED CODE BEGIN ++ // CHECK(data); ++ // MODIFIED CODE END + return data; + } -diff --git a/examples/pxScene2d/external/libnode-v10.15.3/lib/_tls_wrap.js b/examples/pxScene2d/external/libnode-v10.15.3/lib/_tls_wrap.js -index 9bfdd4062..0dc161af9 100755 ---- a/examples/pxScene2d/external/libnode-v10.15.3/lib/_tls_wrap.js -+++ b/examples/pxScene2d/external/libnode-v10.15.3/lib/_tls_wrap.js -@@ -345,16 +345,16 @@ function TLSSocket(socket, opts) { + void NodePlatform::CallOnForegroundThread(Isolate* isolate, Task* task) { +- ForIsolate(isolate)->PostTask(std::unique_ptr(task)); ++ /* MODIFIED CODE BEGIN */ ++ std::shared_ptr data = ForIsolate(isolate); ++ if (nullptr != data.get()) { ++ data->PostTask(std::unique_ptr(task)); ++ } ++ /* MODIFIED CODE END */ } - util.inherits(TLSSocket, net.Socket); - exports.TLSSocket = TLSSocket; -- -+/* MODIFIED CODE BEGIN */ - var proxiedMethods = [ -- 'ref', 'unref', 'open', 'bind', 'listen', 'connect', 'bind6', -+ 'ref', 'unref', 'open', 'bind', 'listen', 'connect', 'bind6', 'reset', - 'connect6', 'getsockname', 'getpeername', 'setNoDelay', 'setKeepAlive', - 'setSimultaneousAccepts', 'setBlocking', - // PipeWrap - 'setPendingInstances' - ]; -- -+/* MODIFIED CODE END */ - // Proxy HandleWrap, PipeWrap and TCPWrap methods - function makeMethodProxy(name) { - return function methodProxy(...args) { + void NodePlatform::CallDelayedOnForegroundThread(Isolate* isolate, +diff --git a/examples/pxScene2d/external/libnode-v10.15.3/src/node_watchdog.cc b/examples/pxScene2d/external/libnode-v10.15.3/src/node_watchdog.cc +index 4b902aa..382bf7b 100755 +--- a/examples/pxScene2d/external/libnode-v10.15.3/src/node_watchdog.cc ++++ b/examples/pxScene2d/external/libnode-v10.15.3/src/node_watchdog.cc +@@ -244,7 +244,10 @@ bool SigintWatchdogHelper::Stop() { + CHECK_EQ(0, pthread_join(thread_, nullptr)); + has_running_thread_ = false; + +- RegisterSignalHandler(SIGINT, SignalExit, true); ++ /* MODIFIED CODE BEGIN */ ++ // To make sure SIGINT signal is not caught by libnode ++ //RegisterSignalHandler(SIGINT, SignalExit, true); ++ /* MODIFIED CODE END */ + #else + watchdog_disabled_ = true; + #endif diff --git a/examples/pxScene2d/external/libnode-v10.15.3/src/stream_wrap.h b/examples/pxScene2d/external/libnode-v10.15.3/src/stream_wrap.h -index 98f0ca4ac..7924678ca 100755 +index 98f0ca4..7924678 100755 --- a/examples/pxScene2d/external/libnode-v10.15.3/src/stream_wrap.h +++ b/examples/pxScene2d/external/libnode-v10.15.3/src/stream_wrap.h @@ -60,6 +60,12 @@ class LibuvStreamWrap : public HandleWrap, public StreamBase { @@ -1497,115 +1672,8 @@ index 98f0ca4ac..7924678ca 100755 #ifdef _WIN32 // We don't always have an FD that we could look up on the stream_ -diff --git a/examples/pxScene2d/external/libnode-v10.15.3/src/tcp_wrap.h b/examples/pxScene2d/external/libnode-v10.15.3/src/tcp_wrap.h -index 3cbeae6d6..67bf832a0 100755 ---- a/examples/pxScene2d/external/libnode-v10.15.3/src/tcp_wrap.h -+++ b/examples/pxScene2d/external/libnode-v10.15.3/src/tcp_wrap.h -@@ -79,6 +79,9 @@ class TCPWrap : public ConnectionWrap { - static void Connect(const v8::FunctionCallbackInfo& args, - std::function uv_ip_addr); - static void Open(const v8::FunctionCallbackInfo& args); -+/* MODIFIED CODE BEGIN */ -+ static void Reset(const v8::FunctionCallbackInfo& args); -+/* MODIFIED CODE END */ - - #ifdef _WIN32 - static void SetSimultaneousAccepts( -diff --git a/examples/pxScene2d/external/libnode-v10.15.3/deps/uv/include/uv.h b/examples/pxScene2d/external/libnode-v10.15.3/deps/uv/include/uv.h -index 717c2e570..d08e8632f 100755 ---- a/examples/pxScene2d/external/libnode-v10.15.3/deps/uv/include/uv.h -+++ b/examples/pxScene2d/external/libnode-v10.15.3/deps/uv/include/uv.h -@@ -449,6 +449,9 @@ UV_EXTERN void uv_print_all_handles(uv_loop_t* loop, FILE* stream); - UV_EXTERN void uv_print_active_handles(uv_loop_t* loop, FILE* stream); - - UV_EXTERN void uv_close(uv_handle_t* handle, uv_close_cb close_cb); -+/* MODIFIED CODE BEGIN */ -+UV_EXTERN void uv_close_immediate(uv_handle_t* handle, uv_close_cb close_cb); -+/* MODIFIED CODE END */ - - UV_EXTERN int uv_send_buffer_size(uv_handle_t* handle, int* value); - UV_EXTERN int uv_recv_buffer_size(uv_handle_t* handle, int* value); -diff --git a/examples/pxScene2d/external/libnode-v10.15.3/deps/uv/src/unix/core.c b/examples/pxScene2d/external/libnode-v10.15.3/deps/uv/src/unix/core.c -index f92446ff4..e71a20523 100755 ---- a/examples/pxScene2d/external/libnode-v10.15.3/deps/uv/src/unix/core.c -+++ b/examples/pxScene2d/external/libnode-v10.15.3/deps/uv/src/unix/core.c -@@ -304,6 +304,24 @@ static void uv__run_closing_handles(uv_loop_t* loop) { - } - } - -+/* MODIFIED CODE BEGIN */ -+void uv_close_immediate(uv_handle_t* handle, uv_close_cb close_cb) { -+ assert(!uv__is_closing(handle)); -+ -+ handle->flags |= UV_HANDLE_CLOSING; -+ handle->close_cb = close_cb; -+ -+ switch (handle->type) { -+ case UV_TCP: -+ uv__tcp_close((uv_tcp_t*)handle); -+ uv__finish_close(handle); -+ break; -+ -+ default: -+ assert(1); -+ } -+} -+/* MODIFIED CODE END */ - - int uv_is_closing(const uv_handle_t* handle) { - return uv__is_closing(handle); -@@ -726,9 +744,12 @@ void uv_disable_stdio_inheritance(void) { - /* Set the CLOEXEC flag on all open descriptors. Unconditionally try the - * first 16 file descriptors. After that, bail out after the first error. - */ -- for (fd = 0; ; fd++) -+ /*MODIFIED CODE BEGIN */ -+ //for (fd = 0; ; fd++) -+ for (fd = 3; ; fd++) - if (uv__cloexec(fd, 1) && fd > 15) - break; -+ /*MODIFIED CODE END */ - } - - -@@ -1003,6 +1024,9 @@ int uv__open_cloexec(const char* path, int flags) { - - int uv__dup2_cloexec(int oldfd, int newfd) { - int r; -+ /*MODIFIED CODE BEGIN*/ -+ int flags = 0; -+ /*MODIFIED CODE END*/ - #if (defined(__FreeBSD__) && __FreeBSD__ >= 10) || defined(__NetBSD__) - r = dup3(oldfd, newfd, O_CLOEXEC); - if (r == -1) -@@ -1018,9 +1042,23 @@ int uv__dup2_cloexec(int oldfd, int newfd) { - #elif defined(__linux__) - static int no_dup3; - if (!no_dup3) { -+ /* MODIFIED CODE BEGIN */ -+ //do -+ // r = uv__dup3(oldfd, newfd, UV__O_CLOEXEC); -+ //while (r == -1 && errno == EBUSY); - do -- r = uv__dup3(oldfd, newfd, UV__O_CLOEXEC); -- while (r == -1 && errno == EBUSY); -+ { -+ if (newfd >=0 && newfd <= 2) -+ { -+ flags = 0; -+ } -+ else -+ { -+ flags = UV__O_CLOEXEC; -+ } -+ r = uv__dup3(oldfd, newfd, flags); -+ }while (r == -1 && (errno == EINTR || errno == EBUSY)); -+ /* MODIFIED CODE END */ - if (r != -1) - return r; - if (errno != ENOSYS) diff --git a/examples/pxScene2d/external/libnode-v10.15.3/src/tcp_wrap.cc b/examples/pxScene2d/external/libnode-v10.15.3/src/tcp_wrap.cc -index a6cc01f12..ceee5e7ef 100755 +index a6cc01f..ceee5e7 100755 --- a/examples/pxScene2d/external/libnode-v10.15.3/src/tcp_wrap.cc +++ b/examples/pxScene2d/external/libnode-v10.15.3/src/tcp_wrap.cc @@ -33,7 +33,6 @@ @@ -1650,131 +1718,57 @@ index a6cc01f12..ceee5e7ef 100755 void TCPWrap::Listen(const FunctionCallbackInfo& args) { TCPWrap* wrap; ASSIGN_OR_RETURN_UNWRAP(&wrap, -diff --git a/examples/pxScene2d/external/libnode-v10.15.3/deps/uv/src/win/handle.c b/examples/pxScene2d/external/libnode-v10.15.3/deps/uv/src/win/handle.c -index 9d76c3f..8e9a6df 100755 ---- a/examples/pxScene2d/external/libnode-v10.15.3/deps/uv/src/win/handle.c -+++ b/examples/pxScene2d/external/libnode-v10.15.3/deps/uv/src/win/handle.c -@@ -148,6 +148,26 @@ void uv_close(uv_handle_t* handle, uv_close_cb cb) { - } - } - -+/* MODIFIED CODE BEGIN */ -+void uv_close_immediate(uv_handle_t* handle, uv_close_cb cb) { -+ uv_loop_t* loop = handle->loop; -+ -+ if (handle->flags & UV_HANDLE_CLOSING) { -+ assert(0); -+ return; -+ } -+ -+ handle->close_cb = cb; -+ switch (handle->type) { -+ case UV_TCP: -+ uv_tcp_close_immediate(loop, (uv_tcp_t*)handle); -+ return; -+ -+ default: -+ assert(1); -+ } -+} -+/* MODIFIED CODE END */ - - int uv_is_closing(const uv_handle_t* handle) { - return !!(handle->flags & (UV_HANDLE_CLOSING | UV_HANDLE_CLOSED)); -diff --git a/examples/pxScene2d/external/libnode-v10.15.3/deps/uv/src/win/internal.h b/examples/pxScene2d/external/libnode-v10.15.3/deps/uv/src/win/internal.h -index 634b9f7..d727c5e 100755 ---- a/examples/pxScene2d/external/libnode-v10.15.3/deps/uv/src/win/internal.h -+++ b/examples/pxScene2d/external/libnode-v10.15.3/deps/uv/src/win/internal.h -@@ -90,6 +90,9 @@ void uv_process_tcp_connect_req(uv_loop_t* loop, uv_tcp_t* handle, - uv_connect_t* req); - - void uv_tcp_close(uv_loop_t* loop, uv_tcp_t* tcp); -+/* MODIFIED CODE BEGIN */ -+void uv_tcp_close_immediate(uv_loop_t* loop, uv_tcp_t* tcp); -+/* MODIFIED CODE END */ - void uv_tcp_endgame(uv_loop_t* loop, uv_tcp_t* handle); - - int uv__tcp_xfer_export(uv_tcp_t* handle, -diff --git a/examples/pxScene2d/external/libnode-v10.15.3/deps/uv/src/win/tcp.c b/examples/pxScene2d/external/libnode-v10.15.3/deps/uv/src/win/tcp.c -index 8b6f0a5..7a601a6 100755 ---- a/examples/pxScene2d/external/libnode-v10.15.3/deps/uv/src/win/tcp.c -+++ b/examples/pxScene2d/external/libnode-v10.15.3/deps/uv/src/win/tcp.c -@@ -1444,6 +1444,78 @@ void uv_tcp_close(uv_loop_t* loop, uv_tcp_t* tcp) { - } - } - +diff --git a/examples/pxScene2d/external/libnode-v10.15.3/src/tcp_wrap.h b/examples/pxScene2d/external/libnode-v10.15.3/src/tcp_wrap.h +index 3cbeae6..67bf832 100755 +--- a/examples/pxScene2d/external/libnode-v10.15.3/src/tcp_wrap.h ++++ b/examples/pxScene2d/external/libnode-v10.15.3/src/tcp_wrap.h +@@ -79,6 +79,9 @@ class TCPWrap : public ConnectionWrap { + static void Connect(const v8::FunctionCallbackInfo& args, + std::function uv_ip_addr); + static void Open(const v8::FunctionCallbackInfo& args); +/* MODIFIED CODE BEGIN */ -+void uv_tcp_close_immediate(uv_loop_t* loop, uv_tcp_t* tcp) { -+ int close_socket = 1; -+ -+ if (tcp->flags & UV_HANDLE_READ_PENDING) { -+ /* In order for winsock to do a graceful close there must not be any any -+ * pending reads, or the socket must be shut down for writing */ -+ if (!(tcp->flags & UV_HANDLE_SHARED_TCP_SOCKET)) { -+ /* Just do shutdown on non-shared sockets, which ensures graceful close. */ -+ shutdown(tcp->socket, SD_SEND); -+ -+ } else if (uv_tcp_try_cancel_io(tcp) == 0) { -+ /* In case of a shared socket, we try to cancel all outstanding I/O,. If -+ * that works, don't close the socket yet - wait for the read req to -+ * return and close the socket in uv_tcp_endgame. */ -+ close_socket = 0; -+ -+ } else { -+ /* When cancelling isn't possible - which could happen when an LSP is -+ * present on an old Windows version, we will have to close the socket -+ * with a read pending. That is not nice because trailing sent bytes may -+ * not make it to the other side. */ -+ } -+ -+ } else if ((tcp->flags & UV_HANDLE_SHARED_TCP_SOCKET) && -+ tcp->tcp.serv.accept_reqs != NULL) { -+ /* Under normal circumstances closesocket() will ensure that all pending -+ * accept reqs are canceled. However, when the socket is shared the -+ * presence of another reference to the socket in another process will keep -+ * the accept reqs going, so we have to ensure that these are canceled. */ -+ if (uv_tcp_try_cancel_io(tcp) != 0) { -+ /* When cancellation is not possible, there is another option: we can -+ * close the incoming sockets, which will also cancel the accept -+ * operations. However this is not cool because we might inadvertently -+ * close a socket that just accepted a new connection, which will cause -+ * the connection to be aborted. */ -+ unsigned int i; -+ for (i = 0; i < uv_simultaneous_server_accepts; i++) { -+ uv_tcp_accept_t* req = &tcp->tcp.serv.accept_reqs[i]; -+ if (req->accept_socket != INVALID_SOCKET && -+ !HasOverlappedIoCompleted(&req->u.io.overlapped)) { -+ closesocket(req->accept_socket); -+ req->accept_socket = INVALID_SOCKET; -+ } -+ } -+ } -+ } -+ -+ if (tcp->flags & UV_HANDLE_READING) { -+ tcp->flags &= ~UV_HANDLE_READING; -+ DECREASE_ACTIVE_COUNT(loop, tcp); -+ } -+ -+ if (tcp->flags & UV_HANDLE_LISTENING) { -+ tcp->flags &= ~UV_HANDLE_LISTENING; -+ DECREASE_ACTIVE_COUNT(loop, tcp); -+ } -+ -+ if (close_socket) { -+ closesocket(tcp->socket); -+ tcp->socket = INVALID_SOCKET; -+ tcp->flags |= UV_HANDLE_TCP_SOCKET_CLOSED; -+ } -+ -+ tcp->flags &= ~(UV_HANDLE_READABLE | UV_HANDLE_WRITABLE); -+ uv__handle_closing(tcp); -+ -+ if (tcp->reqs_pending == 0) { -+ uv_tcp_endgame(tcp->loop, (uv_handle_t*)tcp); -+ } -+} ++ static void Reset(const v8::FunctionCallbackInfo& args); +/* MODIFIED CODE END */ - int uv_tcp_open(uv_tcp_t* handle, uv_os_sock_t sock) { - WSAPROTOCOL_INFOW protocol_info; + #ifdef _WIN32 + static void SetSimultaneousAccepts( +diff --git a/examples/pxScene2d/external/libnode-v10.15.3/vcbuild.bat b/examples/pxScene2d/external/libnode-v10.15.3/vcbuild.bat +index 834db64..0c108bd 100755 +--- a/examples/pxScene2d/external/libnode-v10.15.3/vcbuild.bat ++++ b/examples/pxScene2d/external/libnode-v10.15.3/vcbuild.bat +@@ -55,6 +55,10 @@ set "common_test_suites=%js_test_suites% doctool addons addons-napi&set build_ad + set http2_debug= + set nghttp2_debug= + set link_module= ++@rem MODIFIED CODE BEGIN ++set no_optimization= ++set shared_openssl= ++@rem MODIFIED CODE END + set no_cctest= + set cctest= + set openssl_no_asm= +@@ -127,6 +131,10 @@ if /i "%1"=="static" set enable_static=1&goto arg-ok + if /i "%1"=="no-NODE-OPTIONS" set no_NODE_OPTIONS=1&goto arg-ok + if /i "%1"=="debug-nghttp2" set debug_nghttp2=1&goto arg-ok + if /i "%1"=="link-module" set "link_module= --link-module=%2%link_module%"&goto arg-ok-2 ++@rem MODIFIED CODE BEGIN ++if /i "%1"=="no-optimization" set no_optimization=1&goto arg-ok ++if /i "%1"=="shared-openssl" set shared_openssl=1&goto arg-ok ++@rem MODIFIED CODE END + if /i "%1"=="no-cctest" set no_cctest=1&goto arg-ok + if /i "%1"=="cctest" set cctest=1&goto arg-ok + if /i "%1"=="openssl-no-asm" set openssl_no_asm=1&goto arg-ok +@@ -182,6 +190,10 @@ if defined link_module set configure_flags=%configure_flags% %link_module% + if defined i18n_arg set configure_flags=%configure_flags% --with-intl=%i18n_arg% + if defined config_flags set configure_flags=%configure_flags% %config_flags% + if defined target_arch set configure_flags=%configure_flags% --dest-cpu=%target_arch% ++@rem MODIFIED CODE BEGIN ++if defined no_optimization set configure_flags=%configure_flags% --no-optimization ++if defined shared_openssl set configure_flags=%configure_flags% --shared-openssl --shared-openssl-libpath=%CD%\..\openssl-1.0.2o\lib\ --shared-openssl-libname=libeay32,ssleay32 --shared-openssl-includes=%CD%\..\openssl-1.0.2o\include ++@rem MODIFIED CODE END + if defined openssl_no_asm set configure_flags=%configure_flags% --openssl-no-asm + if defined DEBUG_HELPER set configure_flags=%configure_flags% --verbose + +-- +1.9.1 + diff --git a/examples/pxScene2d/src/Spark.cpp b/examples/pxScene2d/src/Spark.cpp index 123b8a3659..24e3d351cd 100644 --- a/examples/pxScene2d/src/Spark.cpp +++ b/examples/pxScene2d/src/Spark.cpp @@ -95,12 +95,6 @@ pxEventLoop eventLoop; pxEventLoop* gLoop = &eventLoop; pxContext context; -#ifdef ENABLE_DEBUG_MODE -extern int g_argc; -extern char** g_argv; -char *nodeInput = NULL; -char** g_origArgv = NULL; -#endif bool gDumpMemUsage = false; extern bool gApplicationIsClosing; extern int pxObjectCount; @@ -289,9 +283,6 @@ class sceneWindow : public pxWindow, public pxIViewContainer #ifndef RUNINMAIN script.setNeedsToEnd(true); #endif - #ifdef ENABLE_DEBUG_MODE - free(g_origArgv); - #endif rtLogInfo("about to clear all the fonts during close"); fflush(stdout); @@ -680,6 +671,7 @@ if (s && (strcmp(s,"1") == 0)) } } +#if 0 #ifdef ENABLE_DEBUG_MODE #ifdef RTSCRIPT_SUPPORT_NODE bool isDebugging = false; @@ -735,6 +727,7 @@ if (s && (strcmp(s,"1") == 0)) } #endif #endif +#endif //0 #ifdef RUNINMAIN script.init(); diff --git a/examples/pxScene2d/src/macstuff/spark.sh b/examples/pxScene2d/src/macstuff/spark.sh index bcf02d47dc..eb031f0b1d 100755 --- a/examples/pxScene2d/src/macstuff/spark.sh +++ b/examples/pxScene2d/src/macstuff/spark.sh @@ -16,6 +16,8 @@ export GST_REGISTRY_FORK="no" export GST_PLUGIN_SCANNER=./lib/gst-plugin-scanner export GST_PLUGIN_PATH=./lib/ export GST_REGISTRY=/tmp/.spark_gst_registry.bin + +export SPARK_ENABLE_DEBUGGING=1 for i in $*; do if [[ $i == "-autoUpdateEdge="* ]] ; then diff --git a/examples/pxScene2d/src/rcvrcore/AppSceneContext.js b/examples/pxScene2d/src/rcvrcore/AppSceneContext.js index f5226a5548..214ce63a9e 100644 --- a/examples/pxScene2d/src/rcvrcore/AppSceneContext.js +++ b/examples/pxScene2d/src/rcvrcore/AppSceneContext.js @@ -470,17 +470,15 @@ AppSceneContext.prototype.runScriptInNewVMContext = function (packageUri, module moduleFunc(px, xModule_wrap, fname, this.basePackageUri); } else { + // Set breakpoint on module start + if (process.env.BREAK_ON_SCRIPTSTART == 1 && (packageUri.indexOf("shell.js") == -1)) + { + sourceCode = "debugger;\n" + sourceCode; + } var moduleFunc = vm.runInNewContext(sourceCode, newSandbox, { filename: path.normalize(fname), displayErrors: true }); - if (process._debugWaitConnect) { - // Set breakpoint on module start - if (process.env.BREAK_ON_SCRIPTSTART != 1) - delete process._debugWaitConnect; - const Debug = vm.runInDebugContext('Debug'); - Debug.setBreakPoint(moduleFunc, 0, 0); - } moduleFunc(px, xModule_wrap, fname, this.basePackageUri); } log.message(4, "vm.runInNewContext done"); diff --git a/examples/pxScene2d/src/rcvrcore/optimus.js b/examples/pxScene2d/src/rcvrcore/optimus.js index c27eb97c1a..e8998d3836 100644 --- a/examples/pxScene2d/src/rcvrcore/optimus.js +++ b/examples/pxScene2d/src/rcvrcore/optimus.js @@ -684,6 +684,9 @@ function Application(props) { this.applicationCreated(); } else if (cmd === "sparkInstance"){ + if (process.env.SPARK_DEBUGGER_PORT) { + process.env.SPARK_DEBUGGER_PORT++; + } this.type = ApplicationType.SPARK_INSTANCE; process.env.PXCORE_ESSOS_WAYLAND=1; process.env.WESTEROS_FAST_RENDER=0; diff --git a/examples/pxScene2d/src/spark.sh b/examples/pxScene2d/src/spark.sh index 0745e73f20..31ee03ffb5 100755 --- a/examples/pxScene2d/src/spark.sh +++ b/examples/pxScene2d/src/spark.sh @@ -20,6 +20,7 @@ export GST_REGISTRY_FORK="no" export GST_PLUGIN_SCANNER=$externalLibs/extlibs/libexec/gstreamer-1.0/gst-plugin-scanner export GST_PLUGIN_PATH=$externalLibs/extlibs/lib/ export GST_REGISTRY=/tmp/.spark_gst_registry.bin +export SPARK_ENABLE_DEBUGGING=1 #export RT_LOG_LEVEL=info diff --git a/src/rtScript.cpp b/src/rtScript.cpp index cd0e660149..82876eb531 100644 --- a/src/rtScript.cpp +++ b/src/rtScript.cpp @@ -34,6 +34,7 @@ #include "rtScriptDuk/rtScriptDuk.h" #endif +#include "rtSettings.h" #ifdef __APPLE__ static pthread_mutex_t sSceneLock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER; //PTHREAD_MUTEX_INITIALIZER; @@ -54,9 +55,10 @@ static pthread_mutex_t sObjectMapMutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; #endif //!RUNINMAIN #endif -#ifndef ENABLE_DEBUG_MODE args_t *s_gArgs; -#endif +rtString g_debuggerAddress; +bool g_debuggerEnabled = false; +int g_debuggerPort = 0; static int sLockCount; @@ -175,6 +177,7 @@ rtError rtScript::init() { if (false == mInitialized) { + populateDebuggerInfo(); #if defined(RTSCRIPT_SUPPORT_NODE) && defined(RTSCRIPT_SUPPORT_DUKTAPE) static int useDuktape = -1; @@ -240,3 +243,47 @@ void* rtScript::getParameter(rtString param) { return mScript->getParameter(param); } + +void rtScript::populateDebuggerInfo() +{ +#ifdef ENABLE_DEBUG_MODE + char const *debugenabled = getenv("SPARK_ENABLE_DEBUGGING"); + if (debugenabled) + { + if (1 == atoi(debugenabled)) + g_debuggerEnabled = true; + } + + rtLogInfo("Spark debugger enabled - [%d]",g_debuggerEnabled); + if (true == g_debuggerEnabled) + { + rtValue debuggerAddress; + if (RT_OK == rtSettings::instance()->value("sparkDebuggerAddress", debuggerAddress)) + { + g_debuggerAddress = debuggerAddress.toString(); + } + + rtValue debuggerPort; + if (RT_OK == rtSettings::instance()->value("sparkDebuggerPort", debuggerPort)) + { + g_debuggerPort = debuggerPort.toInt64(); + } + + char const *debugaddress = getenv("SPARK_DEBUGGER_ADDRESS"); + if (debugaddress) + { + g_debuggerAddress = debugaddress; + } + + rtLogInfo("Spark debugger address[%s]", g_debuggerAddress.cString()); + + char const *debugport = getenv("SPARK_DEBUGGER_PORT"); + if (debugport) + { + g_debuggerPort = atoi(debugport); + } + + rtLogInfo("Spark debugger port[%d]", g_debuggerPort); + } +#endif +} diff --git a/src/rtScript.h b/src/rtScript.h index c2f18f2783..c3c1f5cd22 100644 --- a/src/rtScript.h +++ b/src/rtScript.h @@ -29,7 +29,6 @@ bool rtWrapperSceneUpdateHasLock(); void rtWrapperSceneUpdateEnter(); void rtWrapperSceneUpdateExit(); -#ifndef ENABLE_DEBUG_MODE typedef struct args_ { int argc; @@ -39,7 +38,6 @@ typedef struct args_ args_(int n = 0, char** a = NULL) : argc(n), argv(a) {} } args_t; -#endif class rtIScriptContext { @@ -99,6 +97,7 @@ class rtScript void* getParameter(rtString param); private: + void populateDebuggerInfo(); bool mInitialized; rtScriptRef mScript; }; diff --git a/src/rtScriptV8/rtScriptNode.cpp b/src/rtScriptV8/rtScriptNode.cpp index 4700a4c8f8..74732a1d8e 100644 --- a/src/rtScriptV8/rtScriptNode.cpp +++ b/src/rtScriptV8/rtScriptNode.cpp @@ -109,6 +109,9 @@ bool gIsPumpingJavaScript = false; #define USE_NODE_PLATFORM #endif +extern rtString g_debuggerAddress; +extern int g_debuggerPort; +extern bool g_debuggerEnabled; namespace node { class Environment; @@ -119,6 +122,8 @@ class rtNodeContext; typedef rtRef rtNodeContextRef; +#define NODE_DEBUGGER_ADDRESS "127.0.0.1" +#define NODE_DEBUGGER_PORT 9229 class rtNodeContext: rtIScriptContext // V8 { public: @@ -256,11 +261,7 @@ class rtScriptNode: public rtIScript #ifndef RUNINMAIN bool mNeedsToEnd; #endif -#ifdef ENABLE_DEBUG_MODE - void init2(); -#else void init2(int argc, char** argv); -#endif int mRefCount; }; @@ -289,13 +290,7 @@ extern uv_loop_t *nodeLoop; using namespace v8; using namespace node; -#ifdef ENABLE_DEBUG_MODE -int g_argc = 0; -char** g_argv; -#endif -#ifndef ENABLE_DEBUG_MODE extern args_t *s_gArgs; -#endif namespace node { #if NODE_VERSION_AT_LEAST(8,9,4) @@ -416,13 +411,8 @@ void rtNodeContext::createEnvironment() uv_default_loop(), #endif local_context, -#ifdef ENABLE_DEBUG_MODE - g_argc, - g_argv, -#else s_gArgs->argc, s_gArgs->argv, -#endif exec_argc, exec_argv); @@ -455,13 +445,17 @@ void rtNodeContext::createEnvironment() #else #if HAVE_INSPECTOR #ifdef USE_NODE_PLATFORM - rtString currentPath; - rtGetCurrentDirectory(currentPath); - #ifdef WIN32 - node::InspectorStart(mEnv, currentPath.cString(), platform); - #else - node::InspectorStart(mEnv, currentPath.cString(), "", 0); - #endif + if (g_debuggerEnabled) { + if (0 == g_debuggerPort) { + g_debuggerPort = NODE_DEBUGGER_PORT; + } + if (0 == g_debuggerAddress.length()) { + g_debuggerAddress = NODE_DEBUGGER_ADDRESS; + } + rtString currentPath; + rtGetCurrentDirectory(currentPath); + node::InspectorStart(mEnv, currentPath.cString(), g_debuggerAddress, g_debuggerPort); + } #endif //USE_NODE_PLATFORM #endif #endif @@ -525,13 +519,8 @@ void rtNodeContext::createEnvironment() mEnv = CreateEnvironment(mIsolate, uv_default_loop(), local_context, -#ifdef ENABLE_DEBUG_MODE - g_argc, - g_argv, -#else s_gArgs->argc, s_gArgs->argv, -#endif exec_argc, exec_argv); @@ -1070,9 +1059,72 @@ rtError rtScriptNode::init() if (mTestGc) rtLogWarn("*** PERFORMANCE WARNING *** : gc being invoked in render thread"); + int argc = 0; // TODO Please make this better... less hard coded... //0123456 789ABCDEF012 345 67890ABCDEF +#ifdef ENABLE_DEBUG_MODE + static const char* debug_node69Config = "rtNode\0--inspect\0--experimental-vm-modules\0-e\0console.log(\"rtNode Initalized\");\0\0"; + static const char* debug_node69Configv[] = {&debug_node69Config[0], &debug_node69Config[7], &debug_node69Config[17], &debug_node69Config[43], &debug_node69Config[46], NULL}; + + static const char* debug_nodeHeapConfig = "rtNode\0--inspect\0--experimental-vm-modules\0--expose-gc\0--max_old_space_size=64\0-e\0console.log(\"rtNode Initalized\");\0\0"; + static const char* debug_nodeHeapConfigv[] = {&debug_nodeHeapConfig[0], &debug_nodeHeapConfig[7], &debug_nodeHeapConfig[17], &debug_nodeHeapConfig[43], &debug_nodeHeapConfig[55], &debug_nodeHeapConfig[79], &debug_nodeHeapConfig[82], NULL}; + + static const char* debug_exposeGcConfig = "rtNode\0--inspect\0--experimental-vm-modules\0--expose-gc\0-e\0console.log(\"rtNode Initalized\");\0\0"; + static const char* debug_exposeGcConfigv[] = {&debug_exposeGcConfig[0], &debug_exposeGcConfig[7], &debug_exposeGcConfig[17], &debug_exposeGcConfig[43], &debug_exposeGcConfig[55], &debug_exposeGcConfig[58], NULL}; + + static const char* node69Config = "rtNode\0--experimental-vm-modules\0-e\0console.log(\"rtNode Initalized\");\0\0"; + static const char* node69Configv[] = {&node69Config[0], &node69Config[7], &node69Config[33], &node69Config[36], NULL}; + + static const char* nodeHeapConfig = "rtNode\0--experimental-vm-modules\0--expose-gc\0--max_old_space_size=64\0-e\0console.log(\"rtNode Initalized\");\0\0"; + static const char* nodeHeapConfigv[] = {&nodeHeapConfig[0], &nodeHeapConfig[7], &nodeHeapConfig[33], &nodeHeapConfig[45], &nodeHeapConfig[69], &nodeHeapConfig[72], NULL}; + + static const char* exposeGcConfig = "rtNode\0--experimental-vm-modules\0--expose-gc\0-e\0console.log(\"rtNode Initalized\");\0\0"; + static const char* exposeGcConfigv[] = {&exposeGcConfig[0], &exposeGcConfig[7], &exposeGcConfig[33], &exposeGcConfig[45], &exposeGcConfig[48], NULL}; + + + static char** argv2 = NULL; + if (g_debuggerEnabled == true) { + #if ENABLE_V8_HEAP_PARAMS + #ifdef ENABLE_NODE_V_6_9 + argc = sizeof(debug_node69Configv)/sizeof(char*) - 1; + argv2 = (char**)debug_node69Configv; + #else + rtLogWarn("v8 old heap space configured to 64mb\n"); + argc = sizeof(debug_nodeHeapConfigv)/sizeof(char*) - 1; + argv2 = (char**)debug_nodeHeapConfigv; + #endif // ENABLE_NODE_V_6_9 + #else + #ifdef ENABLE_NODE_V_6_9 + argc = sizeof(debug_node69Configv)/sizeof(char*) - 1; + argv2 = (char**)debug_node69Configv; + #else + argc = sizeof(debug_exposeGcConfigv)/sizeof(char*) - 1; + argv2 = (char**)debug_exposeGcConfigv; + #endif // ENABLE_NODE_V_6_9 + #endif //ENABLE_V8_HEAP_PARAMS + } + else + { + #if ENABLE_V8_HEAP_PARAMS + #ifdef ENABLE_NODE_V_6_9 + argc = sizeof(node69Configv)/sizeof(char*) - 1; + argv2 = (char**)node69Configv; + #else + argc = sizeof(nodeHeapConfigv)/sizeof(char*) - 1; + argv2 = (char **) nodeHeapConfigv; + #endif // ENABLE_NODE_V_6_9 + #else + #ifdef ENABLE_NODE_V_6_9 + argc = sizeof(node69Configv)/sizeof(char*) - 1; + argv2 = (char**)node69Configv; + #else + argc = sizeof(exposeGcConfigv)/sizeof(char*) - 1; + argv2 = (char**)exposeGcConfigv; + #endif // ENABLE_NODE_V_6_9 + #endif //ENABLE_V8_HEAP_PARAMS + } +#else #if ENABLE_V8_HEAP_PARAMS #ifdef ENABLE_NODE_V_6_9 static const char *args2 = "rtNode\0--experimental-vm-modules\0-e\0console.log(\"rtNode Initalized\");\0\0"; @@ -1084,25 +1136,21 @@ rtError rtScriptNode::init() #endif // ENABLE_NODE_V_6_9 #else #ifdef ENABLE_NODE_V_6_9 -#ifndef ENABLE_DEBUG_MODE static const char *args2 = "rtNode\0--experimental-vm-modules\0-e\0console.log(\"rtNode Initalized\");\0\0"; static const char *argv2[] = {&args2[0], &args2[7], &args2[33], &args2[36], NULL}; -#endif //!ENABLE_DEBUG_MODE #else static const char *args2 = "rtNode\0--experimental-vm-modules\0--expose-gc\0-e\0console.log(\"rtNode Initalized\");\0\0"; static const char *argv2[] = {&args2[0], &args2[7], &args2[33], &args2[45], &args2[48], NULL}; #endif // ENABLE_NODE_V_6_9 #endif //ENABLE_V8_HEAP_PARAMS -#ifndef ENABLE_DEBUG_MODE - int argc = sizeof(argv2)/sizeof(char*) - 1; - + argc = sizeof(argv2)/sizeof(char*) - 1; +#endif //ENABLE_DEBUG_MODE static args_t aa(argc, (char**)argv2); s_gArgs = &aa; char **argv = aa.argv; -#endif #ifdef RUNINMAIN #ifdef WIN32 @@ -1116,20 +1164,12 @@ rtError rtScriptNode::init() #ifdef ENABLE_NODE_V_6_9 rtLogWarn("rtNode::rtNode() calling init \n"); -#ifdef ENABLE_DEBUG_MODE - init2(); -#else init2(argc, argv); -#endif #else mIsolate = Isolate::New(); node_isolate = mIsolate; // Must come first !! -#ifdef ENABLE_DEBUG_MODE - init2(); -#else init2(argc, argv); -#endif #endif // ENABLE_NODE_V_6_9 return RT_OK; } @@ -1251,18 +1291,10 @@ bool rtNode::isInitialized() #endif #if 1 -#ifdef ENABLE_DEBUG_MODE -void rtScriptNode::init2() -#else void rtScriptNode::init2(int argc, char** argv) -#endif { // Hack around with the argv pointer. Used for process.title = "blah". -#ifdef ENABLE_DEBUG_MODE - g_argv = uv_setup_args(g_argc, g_argv); -#else argv = uv_setup_args(argc, argv); -#endif rtLogInfo(__FUNCTION__); @@ -1274,20 +1306,12 @@ void rtScriptNode::init2(int argc, char** argv) if(node_is_initialized == false) { rtLogWarn("About to Init\n"); -#ifdef ENABLE_DEBUG_MODE - Init(&g_argc, const_cast(g_argv), &exec_argc, &exec_argv); -#else Init(&argc, const_cast(argv), &exec_argc, &exec_argv); -#endif #ifdef ENABLE_NODE_V_6_9 rtLogWarn("using node version %s\n", NODE_VERSION); v8::V8::InitializeICU(); -#ifdef ENABLE_DEBUG_MODE - V8::InitializeExternalStartupData(g_argv[0]); -#else V8::InitializeExternalStartupData(argv[0]); -#endif #ifdef USE_NODE_PLATFORM Platform* platform = node::CreatePlatform(0, NULL); diff --git a/tests/pxScene2d/pxscene2dtestsmain.cpp b/tests/pxScene2d/pxscene2dtestsmain.cpp index 4b8975ee92..019b16a089 100644 --- a/tests/pxScene2d/pxscene2dtestsmain.cpp +++ b/tests/pxScene2d/pxscene2dtestsmain.cpp @@ -30,13 +30,6 @@ extern "C" void __gcov_flush(); #endif pxContext context; -int gargc; -char** gargv; -#ifdef ENABLE_DEBUG_MODE -extern int g_argc; -extern char** g_argv; -char *nodeInput = NULL; -#endif extern rtScript script; void handleSegv(int) @@ -67,59 +60,6 @@ int main(int argc, char **argv) { signal(SIGSEGV, handleSegv); signal(SIGABRT, handleAbrt); } - gargc = argc; - gargv = argv; -#ifdef ENABLE_DEBUG_MODE - bool isDebugging = false; - g_argv = (char**)malloc((argc+2) * sizeof(char*)); - int size = 0; - for (int i=1;i