From 4fd71935795fa7c284f5ed621551b65a28b8271c Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Thu, 4 Apr 2019 06:29:02 +0800 Subject: tools: implement mkcodecache as an executable This patch implement a mkcodecache executable on top of the `NativeModuleLoader` singleton. This makes it possible to build a Node.js binary with embedded code cache without building itself using the code cache stub - the cache is now initialized by `NativeModuleEnv` instead which can be refactored out of the mkcodecache dependencies. PR-URL: https://github.com/nodejs/node/pull/27161 Reviewed-By: Joyee Cheung --- src/node_native_module_env.cc | 24 ------------------------ 1 file changed, 24 deletions(-) (limited to 'src/node_native_module_env.cc') diff --git a/src/node_native_module_env.cc b/src/node_native_module_env.cc index fc48436dc14..171c649a19d 100644 --- a/src/node_native_module_env.cc +++ b/src/node_native_module_env.cc @@ -4,7 +4,6 @@ namespace node { namespace native_module { -using v8::ArrayBuffer; using v8::Context; using v8::DEFAULT; using v8::Function; @@ -18,11 +17,9 @@ using v8::Name; using v8::None; using v8::Object; using v8::PropertyCallbackInfo; -using v8::ScriptCompiler; using v8::Set; using v8::SideEffectType; using v8::String; -using v8::Uint8Array; using v8::Value; // TODO(joyeecheung): make these more general and put them into util.h @@ -154,26 +151,6 @@ MaybeLocal NativeModuleEnv::LookupAndCompile( return maybe; } -// This is supposed to be run only by the main thread in -// tools/generate_code_cache.js -void NativeModuleEnv::GetCodeCache(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args); - Isolate* isolate = env->isolate(); - CHECK(env->is_main_thread()); - - CHECK(args[0]->IsString()); - node::Utf8Value id_v(isolate, args[0].As()); - const char* id = *id_v; - - ScriptCompiler::CachedData* cached_data = - NativeModuleLoader::GetInstance()->GetCodeCache(id); - if (cached_data != nullptr) { - Local buf = ArrayBuffer::New(isolate, cached_data->length); - memcpy(buf->GetContents().Data(), cached_data->data, cached_data->length); - args.GetReturnValue().Set(Uint8Array::New(buf, 0, cached_data->length)); - } -} - // TODO(joyeecheung): It is somewhat confusing that Class::Initialize // is used to initilaize to the binding, but it is the current convention. // Rename this across the code base to something that makes more sense. @@ -216,7 +193,6 @@ void NativeModuleEnv::Initialize(Local target, .Check(); env->SetMethod(target, "getCacheUsage", NativeModuleEnv::GetCacheUsage); - env->SetMethod(target, "getCodeCache", NativeModuleEnv::GetCodeCache); env->SetMethod(target, "compileFunction", NativeModuleEnv::CompileFunction); // internalBinding('native_module') should be frozen target->SetIntegrityLevel(context, IntegrityLevel::kFrozen).FromJust(); -- cgit v1.2.3