forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[vm/compiler] Check def/use relation for PushArguments in environment.
Fix an AOT call specialization that broke this relationship. When printing environments in the FlowGraphPrinter, also print the underlying value for any PushArguments. Change-Id: I39803b7d995abac720702ea4b9d6a78fcbc45d4c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/115981 Commit-Queue: Teagan Strickland <sstrickl@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
- Loading branch information
Showing
6 changed files
with
225 additions
and
19 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
runtime/tests/vm/dart/getter_closure_call_generic_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
// | ||
// This regression test targets AotCallSpecializer::TryExpandCallThroughGetter, | ||
// which previously would create bad references in environments to either | ||
// push arguments that came later than the environment's instruction or, worse, | ||
// references to push arguments whose values had not already been calculated at | ||
// the environment's instruction. | ||
|
||
final states = <int>[]; | ||
main() { | ||
final x = kTrue ? Sub1() : Sub2(); | ||
barbar(kTrue, x); | ||
print('states = $states'); | ||
} | ||
|
||
@pragma('vm:never-inline') | ||
void barbar(bool kTrue, Base base) { | ||
var a = foo(); | ||
var b = foo2(); | ||
var c = foo3(); | ||
var d = foo4(); | ||
|
||
try { | ||
// rotate | ||
final t = a; | ||
if (kTrue) a = b; | ||
if (kTrue) b = c; | ||
if (kTrue) c = d; | ||
if (kTrue) d = t; | ||
|
||
base.barGetter( | ||
a = addState(c), b = addState(d), c = addState(a), d = addState(b)); | ||
} catch (e) { | ||
print('got $e'); | ||
print('$a $b $c $d'); | ||
} | ||
} | ||
|
||
final bool kTrue = int.parse('1') == 1; | ||
|
||
@pragma('vm:never-inline') | ||
int foo() => kTrue ? 1 : 2; | ||
|
||
@pragma('vm:never-inline') | ||
int foo2() => kTrue ? 2 : 3; | ||
|
||
@pragma('vm:never-inline') | ||
int foo3() => kTrue ? 3 : 4; | ||
|
||
@pragma('vm:never-inline') | ||
int foo4() => kTrue ? 4 : 5; | ||
|
||
@pragma('vm:never-inline') | ||
int addState(int i) { | ||
states.add(i); | ||
return i; | ||
} | ||
|
||
@pragma('vm:never-inline') | ||
void doit<A>(A x, A x2, A x3, A x4) => throw 'a'; | ||
|
||
class Base { | ||
void Function<A>(A, A, A, A) get barGetter => doit; | ||
} | ||
|
||
class Sub1 extends Base {} | ||
|
||
class Sub2 extends Base {} |
51 changes: 51 additions & 0 deletions
51
runtime/tests/vm/dart/getter_closure_call_nongeneric_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
// | ||
// This regression test targets AotCallSpecializer::TryExpandCallThroughGetter, | ||
// which previously would create bad references in environments to either | ||
// push arguments that came later than the environment's instruction or, worse, | ||
// references to push arguments whose values had not already been calculated at | ||
// the environment's instruction. | ||
|
||
import 'getter_closure_call_generic_test.dart' as test; | ||
|
||
main() { | ||
final x = test.kTrue ? Sub1() : Sub2(); | ||
barbar(test.kTrue, x); | ||
print('states = ${test.states}'); | ||
} | ||
|
||
@pragma('vm:never-inline') | ||
barbar(bool kTrue, Base base) { | ||
var a = test.foo(); | ||
var b = test.foo2(); | ||
var c = test.foo3(); | ||
var d = test.foo4(); | ||
try { | ||
// rotate | ||
final t = a; | ||
if (kTrue) a = b; | ||
if (kTrue) b = c; | ||
if (kTrue) c = d; | ||
if (kTrue) d = t; | ||
|
||
if (!kTrue) b = test.foo(); | ||
|
||
base.barGetter(a = test.addState(1), b = test.addState(2), | ||
c = test.addState(3), d = test.addState(4)); | ||
} catch (e) { | ||
print('got $e'); | ||
print('$a $b $c $d'); | ||
} | ||
} | ||
|
||
class Base { | ||
FT get barGetter => test.doit; | ||
} | ||
|
||
class Sub1 extends Base {} | ||
|
||
class Sub2 extends Base {} | ||
|
||
typedef dynamic FT(dynamic a, dynamic b, dynamic c, dynamic d); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters