v8/test/mjsunit/lazy-inner-functions.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

30 lines
812 B
JavaScript
Raw Normal View History

Reland of Preparse inner functions (new try) (patchset #1 id:1 of https://codereview.chromium.org/2373443003/ ) Reason for revert: Stability thief found, relanding speculative reverts. Original issue's description: > Revert of Preparse inner functions (new try) (patchset #21 id:420001 of https://codereview.chromium.org/2352593002/ ) > > Reason for revert: > We currently have some stability issues on Canary. Let's reland this after we verified that we "fixed" Canary again. > > Original issue's description: > > Preparse inner functions (new try) > > > > This is an overly pessimistic approach where PreParser only keeps > > track of unresolved variables, but doesn't declare anything. This > > will result in context-allocating variables in the outer function > > unnecessarily, if the variable names clash with variable names > > used by the inner function (even if the variables are not the > > same). However, we have been unable to prove that this approach > > wouldn't be good enough for the practical purposes. > > > > Fixes after the previous try ( https://codereview.chromium.org/2322243002/ ): > > Keep the context-allocation decision stable when compiling fully eagerly. > > > > Tests which exercise this functionality: > > mjsunit/fixed-context-shapes-when-recompiling.js > > > > Design document (chromium): > > > > https://docs.google.com/a/chromium.org/document/d/1rRv5JJZ0JpOZAZN2CSUwZPFJiBAdRnTiSYhazseNHFg/edit?usp=sharing > > > > BUG= > > > > Committed: https://crrev.com/7c73cf32c60484cdf37c84f1d61b4640e87068d7 > > Cr-Commit-Position: refs/heads/master@{#39719} > > TBR=verwaest@chromium.org,adamk@chromium.org,marja@chromium.org > # Skipping CQ checks because original CL landed less than 1 days ago. > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG= > > Committed: https://crrev.com/1e6296b2a7cfc307fd9e722e619f42965da4a267 > Cr-Commit-Position: refs/heads/master@{#39730} TBR=verwaest@chromium.org,adamk@chromium.org,marja@chromium.org,hablich@chromium.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG= Review-Url: https://codereview.chromium.org/2377513006 Cr-Commit-Position: refs/heads/master@{#39755}
2016-09-27 09:48:17 +00:00
// 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: --lazy-inner-functions
Reland of Preparse inner functions (new try) (patchset #1 id:1 of https://codereview.chromium.org/2373443003/ ) Reason for revert: Stability thief found, relanding speculative reverts. Original issue's description: > Revert of Preparse inner functions (new try) (patchset #21 id:420001 of https://codereview.chromium.org/2352593002/ ) > > Reason for revert: > We currently have some stability issues on Canary. Let's reland this after we verified that we "fixed" Canary again. > > Original issue's description: > > Preparse inner functions (new try) > > > > This is an overly pessimistic approach where PreParser only keeps > > track of unresolved variables, but doesn't declare anything. This > > will result in context-allocating variables in the outer function > > unnecessarily, if the variable names clash with variable names > > used by the inner function (even if the variables are not the > > same). However, we have been unable to prove that this approach > > wouldn't be good enough for the practical purposes. > > > > Fixes after the previous try ( https://codereview.chromium.org/2322243002/ ): > > Keep the context-allocation decision stable when compiling fully eagerly. > > > > Tests which exercise this functionality: > > mjsunit/fixed-context-shapes-when-recompiling.js > > > > Design document (chromium): > > > > https://docs.google.com/a/chromium.org/document/d/1rRv5JJZ0JpOZAZN2CSUwZPFJiBAdRnTiSYhazseNHFg/edit?usp=sharing > > > > BUG= > > > > Committed: https://crrev.com/7c73cf32c60484cdf37c84f1d61b4640e87068d7 > > Cr-Commit-Position: refs/heads/master@{#39719} > > TBR=verwaest@chromium.org,adamk@chromium.org,marja@chromium.org > # Skipping CQ checks because original CL landed less than 1 days ago. > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG= > > Committed: https://crrev.com/1e6296b2a7cfc307fd9e722e619f42965da4a267 > Cr-Commit-Position: refs/heads/master@{#39730} TBR=verwaest@chromium.org,adamk@chromium.org,marja@chromium.org,hablich@chromium.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG= Review-Url: https://codereview.chromium.org/2377513006 Cr-Commit-Position: refs/heads/master@{#39755}
2016-09-27 09:48:17 +00:00
(function TestLazyInnerFunctionCallsEval() {
var i = (function eager_outer() {
var outer_var = 41; // Should be context-allocated
function lazy_inner() {
return eval("outer_var");
}
return lazy_inner;
})();
assertEquals(41, i());
})();
(function TestLazyInnerFunctionDestructuring() {
var i = (function eager_outer() {
var outer_var = 41; // Should be context-allocated
Reland of Preparse inner functions (new try) (patchset #1 id:1 of https://codereview.chromium.org/2373443003/ ) Reason for revert: Stability thief found, relanding speculative reverts. Original issue's description: > Revert of Preparse inner functions (new try) (patchset #21 id:420001 of https://codereview.chromium.org/2352593002/ ) > > Reason for revert: > We currently have some stability issues on Canary. Let's reland this after we verified that we "fixed" Canary again. > > Original issue's description: > > Preparse inner functions (new try) > > > > This is an overly pessimistic approach where PreParser only keeps > > track of unresolved variables, but doesn't declare anything. This > > will result in context-allocating variables in the outer function > > unnecessarily, if the variable names clash with variable names > > used by the inner function (even if the variables are not the > > same). However, we have been unable to prove that this approach > > wouldn't be good enough for the practical purposes. > > > > Fixes after the previous try ( https://codereview.chromium.org/2322243002/ ): > > Keep the context-allocation decision stable when compiling fully eagerly. > > > > Tests which exercise this functionality: > > mjsunit/fixed-context-shapes-when-recompiling.js > > > > Design document (chromium): > > > > https://docs.google.com/a/chromium.org/document/d/1rRv5JJZ0JpOZAZN2CSUwZPFJiBAdRnTiSYhazseNHFg/edit?usp=sharing > > > > BUG= > > > > Committed: https://crrev.com/7c73cf32c60484cdf37c84f1d61b4640e87068d7 > > Cr-Commit-Position: refs/heads/master@{#39719} > > TBR=verwaest@chromium.org,adamk@chromium.org,marja@chromium.org > # Skipping CQ checks because original CL landed less than 1 days ago. > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG= > > Committed: https://crrev.com/1e6296b2a7cfc307fd9e722e619f42965da4a267 > Cr-Commit-Position: refs/heads/master@{#39730} TBR=verwaest@chromium.org,adamk@chromium.org,marja@chromium.org,hablich@chromium.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG= Review-Url: https://codereview.chromium.org/2377513006 Cr-Commit-Position: refs/heads/master@{#39755}
2016-09-27 09:48:17 +00:00
function lazy_inner() {
// This introduces b and refers to outer_var.
var {outer_var : b} = {outer_var};
return b;
Reland of Preparse inner functions (new try) (patchset #1 id:1 of https://codereview.chromium.org/2373443003/ ) Reason for revert: Stability thief found, relanding speculative reverts. Original issue's description: > Revert of Preparse inner functions (new try) (patchset #21 id:420001 of https://codereview.chromium.org/2352593002/ ) > > Reason for revert: > We currently have some stability issues on Canary. Let's reland this after we verified that we "fixed" Canary again. > > Original issue's description: > > Preparse inner functions (new try) > > > > This is an overly pessimistic approach where PreParser only keeps > > track of unresolved variables, but doesn't declare anything. This > > will result in context-allocating variables in the outer function > > unnecessarily, if the variable names clash with variable names > > used by the inner function (even if the variables are not the > > same). However, we have been unable to prove that this approach > > wouldn't be good enough for the practical purposes. > > > > Fixes after the previous try ( https://codereview.chromium.org/2322243002/ ): > > Keep the context-allocation decision stable when compiling fully eagerly. > > > > Tests which exercise this functionality: > > mjsunit/fixed-context-shapes-when-recompiling.js > > > > Design document (chromium): > > > > https://docs.google.com/a/chromium.org/document/d/1rRv5JJZ0JpOZAZN2CSUwZPFJiBAdRnTiSYhazseNHFg/edit?usp=sharing > > > > BUG= > > > > Committed: https://crrev.com/7c73cf32c60484cdf37c84f1d61b4640e87068d7 > > Cr-Commit-Position: refs/heads/master@{#39719} > > TBR=verwaest@chromium.org,adamk@chromium.org,marja@chromium.org > # Skipping CQ checks because original CL landed less than 1 days ago. > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG= > > Committed: https://crrev.com/1e6296b2a7cfc307fd9e722e619f42965da4a267 > Cr-Commit-Position: refs/heads/master@{#39730} TBR=verwaest@chromium.org,adamk@chromium.org,marja@chromium.org,hablich@chromium.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG= Review-Url: https://codereview.chromium.org/2377513006 Cr-Commit-Position: refs/heads/master@{#39755}
2016-09-27 09:48:17 +00:00
}
return lazy_inner;
})();
assertEquals(41, i());
})();