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

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

Issue 23660008: Fix a bug in the variable allocator: a pure instruction between an inlined if and its inlined expre… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ssa/variable_allocator.dart ('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) 2013, 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 // Regression test for dart2js. There was a bug in the variable
6 // allocator when a pure (side-effect free) instruction stand
7 // in-between an inlined `if` and its inlined expression.
8
9 import "package:expect/expect.dart";
10
11 var topLevel;
12
13 // Make [foo] an inlineable expression with a return type check.
14 Function foo(c) {
15 // Use [c] twice to make sure it is stored in a local.
16 return (c is Function ? null : c);
17 }
18
19 bar() {
20 var b = new Object();
21 f() {
22 // Inside a closure, locals that escape are stored in a closure
23 // class. By using [b] in both branches, the optimizers will move
24 // the fetching of [b] before the `if`. This puts the fetching
25 // instruction in between the `if` and the expression of the `if`.
26 // This instruction being pure, the variable allocator was dealing
27 // with it in a special way.
28 //
29 // Because the expression in the `if` is being recognized by the
30 // optimizers as being also a JavaScript expression, we do not
31 // allocate a name for it. But some expressions that it uses still
32 // can have a name, and our variable allocator did not handle live
33 // variables due to the inlining of the ternary expression in [foo].
34 if (foo(topLevel) == null) {
35 return b.toString();
36 } else {
37 return b.hashCode;
38 }
39 }
40 return f();
41 }
42
43 main() {
44 // Make sure the inferrer does not get an exact type for [topLevel].
45 topLevel = new Object();
46 topLevel = main;
47 var res = bar();
48 Expect.isTrue(res is String);
49 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ssa/variable_allocator.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698