Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: improve embedded code-cache detection #27311

Merged
merged 1 commit into from
Apr 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
3 changes: 2 additions & 1 deletion lib/internal/bootstrap/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
refack marked this conversation as resolved.
Show resolved Hide resolved
}
});

Expand Down
3 changes: 2 additions & 1 deletion src/node_code_cache_stub.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#include "node_native_module_env.h"

// This is supposed to be generated by tools/generate_code_cache.js
Expand All @@ -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() {}
Expand Down
6 changes: 5 additions & 1 deletion src/node_config.cc
Original file line number Diff line number Diff line change
@@ -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"

Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/node_native_module_env.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-code-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
3 changes: 2 additions & 1 deletion test/parallel/test-process-features.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ assert.deepStrictEqual(keys, new Set([
'tls_alpn',
'tls_sni',
'tls_ocsp',
'tls'
'tls',
'cached_builtins',
]));

for (const key of keys) {
Expand Down
3 changes: 1 addition & 2 deletions test/sequential/test-cpu-prof.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
3 changes: 3 additions & 0 deletions tools/code_cache/cache_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ static std::string GenerateCodeCache(

namespace node {
namespace native_module {

const bool has_code_cache = true;

)";

size_t total = 0;
Expand Down