summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRefael Ackermann <refack@gmail.com>2019-04-19 09:43:02 -0400
committerRefael Ackermann <refack@gmail.com>2019-04-22 14:48:50 -0400
commit5aaf666b3b82a66485bea6a6b59fbfc838192e2f (patch)
tree7311dbad032093a9bd0a4a7cb8b5f7678a60cf43
parent49d3d11ba7975b2c6df4ecab55b4619da46fcb95 (diff)
downloadandroid-node-v8-5aaf666b3b82a66485bea6a6b59fbfc838192e2f.tar.gz
android-node-v8-5aaf666b3b82a66485bea6a6b59fbfc838192e2f.tar.bz2
android-node-v8-5aaf666b3b82a66485bea6a6b59fbfc838192e2f.zip
build: improve embedded code-cache detection
PR-URL: https://github.com/nodejs/node/pull/27311 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
-rwxr-xr-xconfigure.py4
-rw-r--r--lib/internal/bootstrap/node.js3
-rw-r--r--src/node_code_cache_stub.cc3
-rw-r--r--src/node_config.cc6
-rw-r--r--src/node_native_module_env.h2
-rw-r--r--test/parallel/test-code-cache.js2
-rw-r--r--test/parallel/test-process-features.js3
-rw-r--r--test/sequential/test-cpu-prof.js3
-rw-r--r--tools/code_cache/cache_builder.cc3
9 files changed, 21 insertions, 8 deletions
diff --git a/configure.py b/configure.py
index a3a412e3a7..1a0819e741 100755
--- a/configure.py
+++ b/configure.py
@@ -1051,7 +1051,9 @@ def configure_node(o):
o['variables']['debug_nghttp2'] = 'false'
o['variables']['node_no_browser_globals'] = b(options.no_browser_globals)
- o['variables']['node_code_cache_path'] = 'yes'
+ # TODO(refack): fix this when implementing embedded code-cache when cross-compiling.
+ if o['variables']['want_separate_host_toolset'] == 0:
+ o['variables']['node_code_cache_path'] = 'yes'
o['variables']['node_shared'] = b(options.shared)
node_module_version = getmoduleversion.get_version()
diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js
index a9fff28937..65b9c403af 100644
--- a/lib/internal/bootstrap/node.js
+++ b/lib/internal/bootstrap/node.js
@@ -244,7 +244,8 @@ Object.defineProperty(process, 'features', {
tls_alpn: hasOpenSSL,
tls_sni: hasOpenSSL,
tls_ocsp: hasOpenSSL,
- tls: hasOpenSSL
+ tls: hasOpenSSL,
+ cached_builtins: config.hasCachedBuiltins,
}
});
diff --git a/src/node_code_cache_stub.cc b/src/node_code_cache_stub.cc
index 021910e829..2dd6d8beb9 100644
--- a/src/node_code_cache_stub.cc
+++ b/src/node_code_cache_stub.cc
@@ -1,4 +1,3 @@
-
#include "node_native_module_env.h"
// This is supposed to be generated by tools/generate_code_cache.js
@@ -7,6 +6,8 @@
namespace node {
namespace native_module {
+const bool has_code_cache = false;
+
// The generated source code would insert <std::string, UnionString> pairs
// into NativeModuleLoader::instance.code_cache_.
void NativeModuleEnv::InitializeCodeCache() {}
diff --git a/src/node_config.cc b/src/node_config.cc
index c3c962bd88..389bd5aa56 100644
--- a/src/node_config.cc
+++ b/src/node_config.cc
@@ -1,6 +1,7 @@
#include "env-inl.h"
#include "node.h"
#include "node_i18n.h"
+#include "node_native_module_env.h"
#include "node_options.h"
#include "util-inl.h"
@@ -73,11 +74,14 @@ static void Initialize(Local<Object> target,
READONLY_PROPERTY(target,
"bits",
- Number::New(env->isolate(), 8 * sizeof(intptr_t)));
+ Number::New(isolate, 8 * sizeof(intptr_t)));
#if defined HAVE_DTRACE || defined HAVE_ETW
READONLY_TRUE_PROPERTY(target, "hasDtrace");
#endif
+
+ READONLY_PROPERTY(target, "hasCachedBuiltins",
+ v8::Boolean::New(isolate, native_module::has_code_cache));
} // InitConfig
} // namespace node
diff --git a/src/node_native_module_env.h b/src/node_native_module_env.h
index 1852d9b139..f662c67be5 100644
--- a/src/node_native_module_env.h
+++ b/src/node_native_module_env.h
@@ -10,6 +10,8 @@ class Environment;
namespace native_module {
+extern const bool has_code_cache;
+
class NativeModuleEnv {
public:
static void Initialize(v8::Local<v8::Object> target,
diff --git a/test/parallel/test-code-cache.js b/test/parallel/test-code-cache.js
index f120b76af2..626fbfb518 100644
--- a/test/parallel/test-code-cache.js
+++ b/test/parallel/test-code-cache.js
@@ -31,7 +31,7 @@ const loadedModules = process.moduleLoadList
// Cross-compiled binaries do not have code cache, verifies that the builtins
// are all compiled without cache and we are doing the bookkeeping right.
-if (process.config.variables.want_separate_host_toolset === 1) {
+if (!process.features.cached_builtins) {
console.log('The binary is not configured with code cache');
if (isMainThread) {
assert.deepStrictEqual(compiledWithCache, new Set());
diff --git a/test/parallel/test-process-features.js b/test/parallel/test-process-features.js
index a24d366ba8..3b4677c561 100644
--- a/test/parallel/test-process-features.js
+++ b/test/parallel/test-process-features.js
@@ -13,7 +13,8 @@ assert.deepStrictEqual(keys, new Set([
'tls_alpn',
'tls_sni',
'tls_ocsp',
- 'tls'
+ 'tls',
+ 'cached_builtins',
]));
for (const key of keys) {
diff --git a/test/sequential/test-cpu-prof.js b/test/sequential/test-cpu-prof.js
index ffaa0e9b1b..726f99b799 100644
--- a/test/sequential/test-cpu-prof.js
+++ b/test/sequential/test-cpu-prof.js
@@ -3,8 +3,7 @@
// This tests that --cpu-prof, --cpu-prof-dir and --cpu-prof-name works.
const common = require('../common');
-if (process.features.debug &&
- process.config.variables.node_code_cache_path === 'yes') {
+if (process.features.debug && process.features.cached_builtins) {
// FIXME(joyeecheung): the profiler crashes when code cache
// is enabled in debug builds.
common.skip('--cpu-prof does not work in debug builds with code cache');
diff --git a/tools/code_cache/cache_builder.cc b/tools/code_cache/cache_builder.cc
index 8d0fb26d7e..92755245ad 100644
--- a/tools/code_cache/cache_builder.cc
+++ b/tools/code_cache/cache_builder.cc
@@ -78,6 +78,9 @@ static std::string GenerateCodeCache(
namespace node {
namespace native_module {
+
+const bool has_code_cache = true;
+
)";
size_t total = 0;