diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2019-04-10 05:08:48 +0800 |
---|---|---|
committer | Joyee Cheung <joyeec9h3@gmail.com> | 2019-04-13 17:24:51 +0800 |
commit | dfd7e994258a36f3941c74295a8c037cb4850418 (patch) | |
tree | 03eaa022a99159912c97773a1b41952f3ee404b1 /tools | |
parent | 9b6b567bc4dd8f40bad12528eebf12dac8a8027f (diff) | |
download | android-node-v8-dfd7e994258a36f3941c74295a8c037cb4850418.tar.gz android-node-v8-dfd7e994258a36f3941c74295a8c037cb4850418.tar.bz2 android-node-v8-dfd7e994258a36f3941c74295a8c037cb4850418.zip |
src: make a Environment-independent proxy class for NativeModuleLoader
This patch splits `NativeModuleLoader` into two parts - a singleton
that only relies on v8 and `node::Mutex` and a proxy class for
the singleton (`NativeModuleEnv`) that provides limited access to
the singleton as well as C++ bindings for the Node.js binary.
`NativeModuleLoader` is then no longer aware of `Environment`.
PR-URL: https://github.com/nodejs/node/pull/27160
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/generate_code_cache.js | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/tools/generate_code_cache.js b/tools/generate_code_cache.js index f324c3d779..8afbc14a9b 100644 --- a/tools/generate_code_cache.js +++ b/tools/generate_code_cache.js @@ -63,7 +63,7 @@ function getInitalizer(key, cache) { `${defName}, static_cast<int>(arraysize(${defName})), ` + 'policy)'; const initializer = - 'code_cache_.emplace(\n' + + 'code_cache->emplace(\n' + ` "${key}",\n` + ` ${dataDef}\n` + ');'; @@ -107,8 +107,7 @@ for (const key of [...canBeRequired].sort(lexical)) { `, total = ${formatSize(totalCacheSize)}`); } -const result = `#include "node_native_module.h" -#include "node_internals.h" +const result = `#include "node_native_module_env.h" // This file is generated by tools/generate_code_cache.js // and is used when configure is run with \`--code-cache-path\` @@ -117,7 +116,13 @@ namespace node { namespace native_module { ${cacheDefinitions.join('\n\n')} -void NativeModuleLoader::LoadCodeCache() { +void NativeModuleEnv::InitializeCodeCache() { + NativeModuleCacheMap* code_cache = + NativeModuleLoader::GetInstance()->code_cache(); + if (!code_cache->empty()) { + return; + } + auto policy = v8::ScriptCompiler::CachedData::BufferPolicy::BufferNotOwned; ${cacheInitializers.join('\n ')} } |