f6057ff1e3
Sloppy eval extends the outer declaration scope's context. This is also true for sloppy eval inside of other sloppy evals -- the outer declaration scope's context is extended rather than the outer sloppy eval's declaration scope. However, we consider eval scopes to also be declaration scopes, for the purposes of strict eval and caching lookup variables. So, we need to make sure that we skip through sloppy eval scopes when marking a scope as calls_sloppy_eval. In fact, we implement this rather as never marking sloppy eval scopes as calls_sloppy_eval, under the assumption that the parent scope will already have been marked calls_sloppy_eval by the outer eval. As a drive-by, fix a TODO to move this logic from calls_sloppy_eval() to RecordEvalCall(), rename the variable to something more meaningful, and make Snapshotting to use a new calls_eval bit on Scope. Bug: chromium:996751 Change-Id: I27ccc7ef429a7ce60b3bb02bf64a3820ae4a2c36 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1773247 Commit-Queue: Toon Verwaest <verwaest@chromium.org> Reviewed-by: Toon Verwaest <verwaest@chromium.org> Auto-Submit: Leszek Swirski <leszeks@chromium.org> Cr-Commit-Position: refs/heads/master@{#63455}
27 lines
638 B
JavaScript
27 lines
638 B
JavaScript
// Copyright 2019 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: --stress-lazy-source-positions
|
|
|
|
eval(`
|
|
eval("");
|
|
(function f() {
|
|
// This undefined should always be known to be the global undefined value,
|
|
// even though there is a sloppy eval call inside the top eval scope.
|
|
return undefined;
|
|
})();
|
|
`);
|
|
|
|
// The above logic should work through multiple layers of eval nesting.
|
|
eval(`
|
|
eval(\`
|
|
eval(\\\`
|
|
eval("");
|
|
(function f() {
|
|
return undefined;
|
|
})();
|
|
\\\`);
|
|
\`);
|
|
`);
|