Fix eval cache with --harmony-function-tostring

The code was using the "correct" cache key for lookups, but not for
creating new entries, leading to us never hitting the cache for
some Function-constructor cases.

Bug: v8:4958, chromium:801556, chromium:802400, chromium:807192
Change-Id: I4ac2234b97a9f5f71957ef936dc4b588d020916b
Reviewed-on: https://chromium-review.googlesource.com/898096
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Adam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51081}
This commit is contained in:
Adam Klein 2018-02-01 12:53:16 -08:00 committed by Commit Bot
parent ebeef1fcf2
commit 537e89a350

View File

@ -1063,17 +1063,16 @@ MaybeHandle<JSFunction> Compiler::GetFunctionFromEval(
// is unused (just 0), which means it's an available field to use to indicate
// this separation. But to make sure we're not causing other false hits, we
// negate the scope position.
int position = eval_scope_position;
if (FLAG_harmony_function_tostring &&
restriction == ONLY_SINGLE_FUNCTION_LITERAL &&
parameters_end_pos != kNoSourcePosition) {
// use the parameters_end_pos as the eval_scope_position in the eval cache.
DCHECK_EQ(eval_scope_position, 0);
position = -parameters_end_pos;
eval_scope_position = -parameters_end_pos;
}
CompilationCache* compilation_cache = isolate->compilation_cache();
InfoVectorPair eval_result = compilation_cache->LookupEval(
source, outer_info, context, language_mode, position);
source, outer_info, context, language_mode, eval_scope_position);
Handle<Cell> vector;
if (eval_result.has_vector()) {
vector = Handle<Cell>(eval_result.vector(), isolate);