summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2018-12-03 08:23:34 +0800
committerJoyee Cheung <joyeec9h3@gmail.com>2018-12-18 18:02:08 +0800
commitceb66352236240498a9263500c7bde74e58c71fa (patch)
tree8f3c1e50ef535cba057f0916e6925c5dab2a6d23 /tools
parent8828426af45adc29847d0d20717c8fa3eb9bb523 (diff)
downloadandroid-node-v8-ceb66352236240498a9263500c7bde74e58c71fa.tar.gz
android-node-v8-ceb66352236240498a9263500c7bde74e58c71fa.tar.bz2
android-node-v8-ceb66352236240498a9263500c7bde74e58c71fa.zip
src: remove code cache integrity check
In preparation of sharing code cache among different threads - we simply rely on v8 to reject invalid cache, since there isn't any serious consequence when the cache is invalid anyway. PR-URL: https://github.com/nodejs/node/pull/24950 Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'tools')
-rw-r--r--tools/generate_code_cache.js27
-rwxr-xr-xtools/js2c.py21
2 files changed, 4 insertions, 44 deletions
diff --git a/tools/generate_code_cache.js b/tools/generate_code_cache.js
index b185f6246d..3e21743f2c 100644
--- a/tools/generate_code_cache.js
+++ b/tools/generate_code_cache.js
@@ -8,7 +8,6 @@
// of `configure`.
const {
- getSource,
getCodeCache,
cachableBuiltins
} = require('internal/bootstrap/cache');
@@ -19,13 +18,6 @@ const {
}
} = require('util');
-function hash(str) {
- if (process.versions.openssl) {
- return require('crypto').createHash('sha256').update(str).digest('hex');
- }
- return '';
-}
-
const fs = require('fs');
const resultPath = process.argv[2];
@@ -65,26 +57,18 @@ function getInitalizer(key, cache) {
const defName = `${key.replace(/\//g, '_').replace(/-/g, '_')}_raw`;
const definition = `static const uint8_t ${defName}[] = {\n` +
`${cache.join(',')}\n};`;
- const source = getSource(key);
- const sourceHash = hash(source);
const initializer =
'code_cache_.emplace(\n' +
` "${key}",\n` +
` UnionBytes(${defName}, arraysize(${defName}))\n` +
');';
- const hashIntializer =
- 'code_cache_hash_.emplace(\n' +
- ` "${key}",\n` +
- ` "${sourceHash}"\n` +
- ');';
return {
- definition, initializer, hashIntializer, sourceHash
+ definition, initializer
};
}
const cacheDefinitions = [];
const cacheInitializers = [];
-const cacheHashInitializers = [];
let totalCacheSize = 0;
function lexical(a, b) {
@@ -107,13 +91,12 @@ for (const key of cachableBuiltins.sort(lexical)) {
const size = cachedData.byteLength;
totalCacheSize += size;
const {
- definition, initializer, hashIntializer, sourceHash
+ definition, initializer,
} = getInitalizer(key, cachedData);
cacheDefinitions.push(definition);
cacheInitializers.push(initializer);
- cacheHashInitializers.push(hashIntializer);
console.log(`Generated cache for '${key}', size = ${formatSize(size)}` +
- `, hash = ${sourceHash}, total = ${formatSize(totalCacheSize)}`);
+ `, total = ${formatSize(totalCacheSize)}`);
}
const result = `#include "node_native_module.h"
@@ -131,10 +114,6 @@ void NativeModuleLoader::LoadCodeCache() {
${cacheInitializers.join('\n ')}
}
-void NativeModuleLoader::LoadCodeCacheHash() {
- ${cacheHashInitializers.join('\n ')}
-}
-
} // namespace native_module
} // namespace node
`;
diff --git a/tools/js2c.py b/tools/js2c.py
index d103a3d236..46cf918ba9 100755
--- a/tools/js2c.py
+++ b/tools/js2c.py
@@ -189,10 +189,6 @@ void NativeModuleLoader::LoadJavaScriptSource() {{
{initializers}
}}
-void NativeModuleLoader::LoadJavaScriptHash() {{
- {hash_initializers}
-}}
-
UnionBytes NativeModuleLoader::GetConfig() {{
return UnionBytes(config_raw, arraysize(config_raw)); // config.gypi
}}
@@ -218,13 +214,6 @@ source_.emplace(
);
"""
-HASH_INITIALIZER = """\
-source_hash_.emplace(
- "{module}",
- "{hash_value}"
-);
-"""
-
DEPRECATED_DEPS = """\
'use strict';
process.emitWarning(
@@ -251,8 +240,6 @@ def JS2C(source, target):
# Build source code lines
definitions = []
initializers = []
- hash_initializers = []
- config_initializers = []
def GetDefinition(var, source):
# Treat non-ASCII as UTF-8 and convert it to UTF-16.
@@ -267,15 +254,11 @@ def JS2C(source, target):
def AddModule(module, source):
var = '%s_raw' % (module.replace('-', '_').replace('/', '_'))
- source_hash = hashlib.sha256(source).hexdigest()
definition = GetDefinition(var, source)
initializer = INITIALIZER.format(module=module,
var=var)
- hash_initializer = HASH_INITIALIZER.format(module=module,
- hash_value=source_hash)
definitions.append(definition)
initializers.append(initializer)
- hash_initializers.append(hash_initializer)
for name in modules:
lines = ReadFile(str(name))
@@ -320,9 +303,7 @@ def JS2C(source, target):
output = open(str(target[0]), "w")
output.write(
TEMPLATE.format(definitions=''.join(definitions),
- initializers=''.join(initializers),
- hash_initializers=''.join(hash_initializers),
- config_initializers=''.join(config_initializers)))
+ initializers=''.join(initializers)))
output.close()
def main():