Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2018-12-03 03:23:34 +0300
committerJoyee Cheung <joyeec9h3@gmail.com>2018-12-18 13:02:08 +0300
commitceb66352236240498a9263500c7bde74e58c71fa (patch)
tree8f3c1e50ef535cba057f0916e6925c5dab2a6d23 /src/node_native_module.cc
parent8828426af45adc29847d0d20717c8fa3eb9bb523 (diff)
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 'src/node_native_module.cc')
-rw-r--r--src/node_native_module.cc41
1 files changed, 0 insertions, 41 deletions
diff --git a/src/node_native_module.cc b/src/node_native_module.cc
index 85f8d83d63a..98cc128b735 100644
--- a/src/node_native_module.cc
+++ b/src/node_native_module.cc
@@ -105,9 +105,7 @@ Local<String> NativeModuleLoader::GetSource(Isolate* isolate,
NativeModuleLoader::NativeModuleLoader() : config_(GetConfig()) {
LoadJavaScriptSource();
- LoadJavaScriptHash();
LoadCodeCache();
- LoadCodeCacheHash();
}
void NativeModuleLoader::CompileCodeCache(
@@ -168,29 +166,6 @@ MaybeLocal<Value> NativeModuleLoader::CompileAsModule(
env->context(), id, &parameters, result, env);
}
-// Currently V8 only checks that the length of the source code is the
-// same as the code used to generate the hash, so we add an additional
-// check here:
-// 1. During compile time, when generating node_javascript.cc and
-// node_code_cache.cc, we compute and include the hash of the
-// JavaScript source in both.
-// 2. At runtime, we check that the hash of the code being compiled
-// and the hash of the code used to generate the cache
-// (without the parameters) is the same.
-// This is based on the assumptions:
-// 1. `code_cache_hash` must be in sync with `code_cache`
-// (both defined in node_code_cache.cc)
-// 2. `source_hash` must be in sync with `source`
-// (both defined in node_javascript.cc)
-// 3. If `source_hash` is in sync with `code_cache_hash`,
-// then the source code used to generate `code_cache`
-// should be in sync with the source code in `source`
-// The only variable left, then, are the parameters passed to the
-// CompileFunctionInContext. If the parameters used generate the cache
-// is different from the one used to compile modules at run time, then
-// there could be false postivies, but that should be rare and should fail
-// early in the bootstrap process so it should be easy to detect and fix.
-
// Returns nullptr if there is no code cache corresponding to the id
ScriptCompiler::CachedData* NativeModuleLoader::GetCachedData(
const char* id) const {
@@ -204,22 +179,6 @@ ScriptCompiler::CachedData* NativeModuleLoader::GetCachedData(
const uint8_t* code_cache_value = it->second.one_bytes_data();
size_t code_cache_length = it->second.length();
- const auto it2 = code_cache_hash_.find(id);
- CHECK_NE(it2, code_cache_hash_.end());
- const std::string& code_cache_hash_value = it2->second;
-
- const auto it3 = source_hash_.find(id);
- CHECK_NE(it3, source_hash_.end());
- const std::string& source_hash_value = it3->second;
-
- // It may fail when any of the inputs of the `node_js2c` target in
- // node.gyp is modified but the tools/generate_code_cache.js
- // is not re run.
- // FIXME(joyeecheung): Figure out how to resolve the dependency issue.
- // When the code cache was introduced we were at a point where refactoring
- // node.gyp may not be worth the effort.
- CHECK_EQ(code_cache_hash_value, source_hash_value);
-
return new ScriptCompiler::CachedData(code_cache_value, code_cache_length);
}