Commit 2325ad7e authored by verwaest's avatar verwaest Committed by Commit bot

Allow lazy parsing of eval-created functions

I don't see a reason why we can't benefit from preparsing such functions. We don't necessarily compile them, so fully parsing them when unnecessary is just additional overhead.

BUG=v8:5501

Review-Url: https://codereview.chromium.org/2413213002
Cr-Commit-Position: refs/heads/master@{#40248}
parent 8ab50513
......@@ -1119,7 +1119,9 @@ bool Scope::AllowsLazyParsingWithoutUnresolvedVariables() const {
// inner scopes to find out how to allocate variables on the block scope. At
// this point, declarations may not have yet been parsed.
for (const Scope* s = this; s != nullptr; s = s->outer_scope_) {
if (s->is_block_scope() || s->is_function_scope()) return false;
if (s->is_block_scope()) return false;
if (s->is_function_scope()) return false;
if (s->is_eval_scope() && is_strict(s->language_mode())) return false;
}
return true;
}
......
......@@ -791,9 +791,6 @@ FunctionLiteral* Parser::DoParseProgram(ParseInfo* info) {
DCHECK_NOT_NULL(outer);
parsing_module_ = info->is_module();
if (info->is_eval()) {
if (!outer->is_script_scope() || is_strict(info->language_mode())) {
parsing_mode = PARSE_EAGERLY;
}
outer = NewEvalScope(outer);
} else if (parsing_module_) {
DCHECK_EQ(outer, info->script_scope());
......
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --min-preparse-length=0
"use strict";
var x = 1;
var g = eval("var y = 100; function h(s) { if (s) x = s; return x+y; }; h");
assertEquals(101, g());
assertEquals(102, g(2));
assertEquals(102, g(2));
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment