@@ -105,9 +105,7 @@ Local<String> NativeModuleLoader::GetSource(Isolate* isolate,
105105
106106NativeModuleLoader::NativeModuleLoader () : config_(GetConfig()) {
107107 LoadJavaScriptSource ();
108- LoadJavaScriptHash ();
109108 LoadCodeCache ();
110- LoadCodeCacheHash ();
111109}
112110
113111void NativeModuleLoader::CompileCodeCache (
@@ -168,29 +166,6 @@ MaybeLocal<Value> NativeModuleLoader::CompileAsModule(
168166 env->context (), id, ¶meters, result, env);
169167}
170168
171- // Currently V8 only checks that the length of the source code is the
172- // same as the code used to generate the hash, so we add an additional
173- // check here:
174- // 1. During compile time, when generating node_javascript.cc and
175- // node_code_cache.cc, we compute and include the hash of the
176- // JavaScript source in both.
177- // 2. At runtime, we check that the hash of the code being compiled
178- // and the hash of the code used to generate the cache
179- // (without the parameters) is the same.
180- // This is based on the assumptions:
181- // 1. `code_cache_hash` must be in sync with `code_cache`
182- // (both defined in node_code_cache.cc)
183- // 2. `source_hash` must be in sync with `source`
184- // (both defined in node_javascript.cc)
185- // 3. If `source_hash` is in sync with `code_cache_hash`,
186- // then the source code used to generate `code_cache`
187- // should be in sync with the source code in `source`
188- // The only variable left, then, are the parameters passed to the
189- // CompileFunctionInContext. If the parameters used generate the cache
190- // is different from the one used to compile modules at run time, then
191- // there could be false postivies, but that should be rare and should fail
192- // early in the bootstrap process so it should be easy to detect and fix.
193-
194169// Returns nullptr if there is no code cache corresponding to the id
195170ScriptCompiler::CachedData* NativeModuleLoader::GetCachedData (
196171 const char * id) const {
@@ -204,22 +179,6 @@ ScriptCompiler::CachedData* NativeModuleLoader::GetCachedData(
204179 const uint8_t * code_cache_value = it->second .one_bytes_data ();
205180 size_t code_cache_length = it->second .length ();
206181
207- const auto it2 = code_cache_hash_.find (id);
208- CHECK_NE (it2, code_cache_hash_.end ());
209- const std::string& code_cache_hash_value = it2->second ;
210-
211- const auto it3 = source_hash_.find (id);
212- CHECK_NE (it3, source_hash_.end ());
213- const std::string& source_hash_value = it3->second ;
214-
215- // It may fail when any of the inputs of the `node_js2c` target in
216- // node.gyp is modified but the tools/generate_code_cache.js
217- // is not re run.
218- // FIXME(joyeecheung): Figure out how to resolve the dependency issue.
219- // When the code cache was introduced we were at a point where refactoring
220- // node.gyp may not be worth the effort.
221- CHECK_EQ (code_cache_hash_value, source_hash_value);
222-
223182 return new ScriptCompiler::CachedData (code_cache_value, code_cache_length);
224183}
225184
0 commit comments