summaryrefslogtreecommitdiff
path: root/tools/generate_code_cache.js
diff options
context:
space:
mode:
Diffstat (limited to 'tools/generate_code_cache.js')
-rw-r--r--tools/generate_code_cache.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/tools/generate_code_cache.js b/tools/generate_code_cache.js
index 3e21743f2c..a434f640c2 100644
--- a/tools/generate_code_cache.js
+++ b/tools/generate_code_cache.js
@@ -9,6 +9,7 @@
const {
getCodeCache,
+ compileFunction,
cachableBuiltins
} = require('internal/bootstrap/cache');
@@ -57,10 +58,13 @@ function getInitalizer(key, cache) {
const defName = `${key.replace(/\//g, '_').replace(/-/g, '_')}_raw`;
const definition = `static const uint8_t ${defName}[] = {\n` +
`${cache.join(',')}\n};`;
+ const dataDef = 'std::make_unique<v8::ScriptCompiler::CachedData>(' +
+ `${defName}, static_cast<int>(arraysize(${defName})), ` +
+ 'policy)';
const initializer =
'code_cache_.emplace(\n' +
` "${key}",\n` +
- ` UnionBytes(${defName}, arraysize(${defName}))\n` +
+ ` ${dataDef}\n` +
');';
return {
definition, initializer
@@ -82,6 +86,7 @@ function lexical(a, b) {
}
for (const key of cachableBuiltins.sort(lexical)) {
+ compileFunction(key); // compile it
const cachedData = getCodeCache(key);
if (!isUint8Array(cachedData)) {
console.error(`Failed to generate code cache for '${key}'`);
@@ -110,7 +115,7 @@ namespace native_module {
${cacheDefinitions.join('\n\n')}
void NativeModuleLoader::LoadCodeCache() {
- has_code_cache_ = true;
+ auto policy = v8::ScriptCompiler::CachedData::BufferPolicy::BufferNotOwned;
${cacheInitializers.join('\n ')}
}