summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2020-02-20 17:57:55 +0800
committerJoyee Cheung <joyeec9h3@gmail.com>2020-03-10 05:52:39 +0800
commit192cb7288ab608a5d17be060aa6127df1f7bbdb0 (patch)
treeac254409ab55c6dafb2eb41f0f56a7ab4d156278 /tools
parent51bc55f2a2424d6eb805dace43604906ed9946a8 (diff)
downloadnode-new-192cb7288ab608a5d17be060aa6127df1f7bbdb0.tar.gz
tools: use per-process native Debug() printer in mkcodecache
PR-URL: https://github.com/nodejs/node/pull/31884 Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'tools')
-rw-r--r--tools/code_cache/cache_builder.cc25
-rw-r--r--tools/code_cache/mkcodecache.cc3
2 files changed, 13 insertions, 15 deletions
diff --git a/tools/code_cache/cache_builder.cc b/tools/code_cache/cache_builder.cc
index 8210355c4c..28d61a6c70 100644
--- a/tools/code_cache/cache_builder.cc
+++ b/tools/code_cache/cache_builder.cc
@@ -1,4 +1,5 @@
#include "cache_builder.h"
+#include "debug_utils-inl.h"
#include "node_native_module.h"
#include "util.h"
@@ -67,8 +68,7 @@ static void GetInitializer(const std::string& id, std::stringstream& ss) {
}
static std::string GenerateCodeCache(
- const std::map<std::string, ScriptCompiler::CachedData*>& data,
- bool log_progress) {
+ const std::map<std::string, ScriptCompiler::CachedData*>& data) {
std::stringstream ss;
ss << R"(#include <cinttypes>
#include "node_native_module_env.h"
@@ -89,11 +89,13 @@ const bool has_code_cache = true;
total += cached_data->length;
std::string def = GetDefinition(id, cached_data->length, cached_data->data);
ss << def << "\n\n";
- if (log_progress) {
- std::cout << "Generated cache for " << id
- << ", size = " << FormatSize(cached_data->length)
- << ", total = " << FormatSize(total) << "\n";
- }
+ std::string size_str = FormatSize(cached_data->length);
+ std::string total_str = FormatSize(total);
+ per_process::Debug(DebugCategory::CODE_CACHE,
+ "Generated cache for %s, size = %s, total = %s\n",
+ id.c_str(),
+ size_str.c_str(),
+ total_str.c_str());
}
ss << R"(void NativeModuleEnv::InitializeCodeCache() {
@@ -142,14 +144,7 @@ std::string CodeCacheBuilder::Generate(Local<Context> context) {
}
}
- char env_buf[32];
- size_t env_size = sizeof(env_buf);
- int ret = uv_os_getenv("NODE_DEBUG", env_buf, &env_size);
- bool log_progress = false;
- if (ret == 0 && strcmp(env_buf, "mkcodecache") == 0) {
- log_progress = true;
- }
- return GenerateCodeCache(data, log_progress);
+ return GenerateCodeCache(data);
}
} // namespace native_module
diff --git a/tools/code_cache/mkcodecache.cc b/tools/code_cache/mkcodecache.cc
index e5b43a44b8..34af7bc61b 100644
--- a/tools/code_cache/mkcodecache.cc
+++ b/tools/code_cache/mkcodecache.cc
@@ -6,6 +6,7 @@
#include <vector>
#include "cache_builder.h"
+#include "debug_utils-inl.h"
#include "libplatform/libplatform.h"
#include "v8.h"
@@ -40,6 +41,8 @@ int main(int argc, char* argv[]) {
return 1;
}
+ node::per_process::enabled_debug_list.Parse(nullptr);
+
std::unique_ptr<v8::Platform> platform = v8::platform::NewDefaultPlatform();
v8::V8::InitializePlatform(platform.get());
v8::V8::Initialize();