build: improve embedded code-cache detection · nodejs/node@5aaf666 (original) (raw)
9 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1051,7 +1051,9 @@ def configure_node(o): | ||
1051 | 1051 | o['variables']['debug_nghttp2'] = 'false' |
1052 | 1052 | |
1053 | 1053 | o['variables']['node_no_browser_globals'] = b(options.no_browser_globals) |
1054 | -o['variables']['node_code_cache_path'] = 'yes' | |
1054 | +# TODO(refack): fix this when implementing embedded code-cache when cross-compiling. | |
1055 | +if o['variables']['want_separate_host_toolset'] == 0: | |
1056 | +o['variables']['node_code_cache_path'] = 'yes' | |
1055 | 1057 | o['variables']['node_shared'] = b(options.shared) |
1056 | 1058 | node_module_version = getmoduleversion.get_version() |
1057 | 1059 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -244,7 +244,8 @@ Object.defineProperty(process, 'features', { | ||
244 | 244 | tls_alpn: hasOpenSSL, |
245 | 245 | tls_sni: hasOpenSSL, |
246 | 246 | tls_ocsp: hasOpenSSL, |
247 | -tls: hasOpenSSL | |
247 | +tls: hasOpenSSL, | |
248 | +cached_builtins: config.hasCachedBuiltins, | |
248 | 249 | } |
249 | 250 | }); |
250 | 251 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
1 | - | |
2 | 1 | #include "node_native_module_env.h" |
3 | 2 | |
4 | 3 | // This is supposed to be generated by tools/generate_code_cache.js |
@@ -7,6 +6,8 @@ | ||
7 | 6 | namespace node { |
8 | 7 | namespace native_module { |
9 | 8 | |
9 | +const bool has_code_cache = false; | |
10 | + | |
10 | 11 | // The generated source code would insert <std::string, UnionString> pairs |
11 | 12 | // into NativeModuleLoader::instance.code_cache_. |
12 | 13 | void NativeModuleEnv::InitializeCodeCache() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
1 | 1 | #include "env-inl.h" |
2 | 2 | #include "node.h" |
3 | 3 | #include "node_i18n.h" |
4 | +#include "node_native_module_env.h" | |
4 | 5 | #include "node_options.h" |
5 | 6 | #include "util-inl.h" |
6 | 7 | |
@@ -73,11 +74,14 @@ static void Initialize(Local target, | ||
73 | 74 | |
74 | 75 | READONLY_PROPERTY(target, |
75 | 76 | "bits", |
76 | -Number::New(env->isolate(), 8 * sizeof(intptr_t))); | |
77 | +Number::New(isolate, 8 * sizeof(intptr_t))); | |
77 | 78 | |
78 | 79 | #if defined HAVE_DTRACE | |
79 | 80 | READONLY_TRUE_PROPERTY(target, "hasDtrace"); |
80 | 81 | #endif |
82 | + | |
83 | +READONLY_PROPERTY(target, "hasCachedBuiltins", | |
84 | +v8::Boolean::New(isolate, native_module::has_code_cache)); | |
81 | 85 | } // InitConfig |
82 | 86 | |
83 | 87 | } // namespace node |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -10,6 +10,8 @@ class Environment; | ||
10 | 10 | |
11 | 11 | namespace native_module { |
12 | 12 | |
13 | +extern const bool has_code_cache; | |
14 | + | |
13 | 15 | class NativeModuleEnv { |
14 | 16 | public: |
15 | 17 | static void Initialize(v8::Localv8::Object target, |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -31,7 +31,7 @@ const loadedModules = process.moduleLoadList | ||
31 | 31 | |
32 | 32 | // Cross-compiled binaries do not have code cache, verifies that the builtins |
33 | 33 | // are all compiled without cache and we are doing the bookkeeping right. |
34 | -if (process.config.variables.want_separate_host_toolset === 1) { | |
34 | +if (!process.features.cached_builtins) { | |
35 | 35 | console.log('The binary is not configured with code cache'); |
36 | 36 | if (isMainThread) { |
37 | 37 | assert.deepStrictEqual(compiledWithCache, new Set()); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -13,7 +13,8 @@ assert.deepStrictEqual(keys, new Set([ | ||
13 | 13 | 'tls_alpn', |
14 | 14 | 'tls_sni', |
15 | 15 | 'tls_ocsp', |
16 | -'tls' | |
16 | +'tls', | |
17 | +'cached_builtins', | |
17 | 18 | ])); |
18 | 19 | |
19 | 20 | for (const key of keys) { |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -3,8 +3,7 @@ | ||
3 | 3 | // This tests that --cpu-prof, --cpu-prof-dir and --cpu-prof-name works. |
4 | 4 | |
5 | 5 | const common = require('../common'); |
6 | -if (process.features.debug && | |
7 | -process.config.variables.node_code_cache_path === 'yes') { | |
6 | +if (process.features.debug && process.features.cached_builtins) { | |
8 | 7 | // FIXME(joyeecheung): the profiler crashes when code cache |
9 | 8 | // is enabled in debug builds. |
10 | 9 | common.skip('--cpu-prof does not work in debug builds with code cache'); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -78,6 +78,9 @@ static std::string GenerateCodeCache( | ||
78 | 78 | |
79 | 79 | namespace node { |
80 | 80 | namespace native_module { |
81 | + | |
82 | +const bool has_code_cache = true; | |
83 | + | |
81 | 84 | )"; |
82 | 85 | |
83 | 86 | size_t total = 0; |