Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: tests/language/regress_26453_test.dart

Issue 2004373004: Revert "Fix capturing variables in optimized compilations" (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/parser.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 // The program crashed with segfault because we when we first compile foo
6 // and bar we allocate all four variables (a, b, c and d) to the context.
7 // When we compile foo the second time (with optimizations) we allocate
8 // only c and d to the context. This happened because parser folds away
9 // "${a}" and "${b}" as constant expressions when parsing bar on its own,
10 // i.e. the expressions were not parsed again and thus a and b were not
11 // marked as captured.
12 // This caused a mismatch between a context that bar expects and that
13 // the optimized version of foo produces.
14
15 foo() {
16 const a = 1;
17 const b = 2;
18 var c = 3;
19 var d = 4;
20
21 bar() {
22 if ("${a}" != "1") throw "failed";
23 if ("${b}" != "2") throw "failed";
24 if ("${c}" != "3") throw "failed";
25 if ("${d}" != "4") throw "failed";
26 }
27
28 bar();
29 }
30
31 main() {
32 for (var i = 0; i < 50000; i++) foo();
33 }
OLDNEW
« no previous file with comments | « runtime/vm/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698