Update jump, side effect and inlining tests to test strong mode

Change-Id: I0c8073f5bc72fae63b012033dc23b15c1913fec7
Reviewed-on: https://dart-review.googlesource.com/52223
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
This commit is contained in:
Johnni Winther 2018-04-24 08:37:24 +00:00 committed by commit-bot@chromium.org
parent bcc5e6ed42
commit e5a2fe6435
8 changed files with 133 additions and 13 deletions

View file

@ -223,6 +223,29 @@ class JumpVisitor extends ir.Visitor {
JJumpTarget target;
ir.TreeNode body = node.target.body;
ir.TreeNode parent = node.target.parent;
// TODO(johnniwinther): Coordinate with CFE-team to avoid such arbitrary
// reverse engineering mismatches:
if (parent is ir.Block && parent.statements.last == node.target) {
// In strong mode for code like this:
//
// for (int i in list) {
// continue;
// }
//
// an implicit cast may be inserted before the label statement, resulting
// in code like this:
//
// for (var i in list) {
// var #1 = i as int;
// l1: {
// break l1:
// }
// }
//
// for which we should still use the for loop as a continue target.
parent = parent.parent;
}
if (canBeBreakTarget(body)) {
// We have code like
//

View file

@ -48,7 +48,6 @@ runTests(List<String> args, [int shardIndex]) {
await checkTests(
dataDir, computeMemberAstTypeMasks, computeMemberIrTypeMasks,
libDirectory: new Directory.fromUri(Platform.script.resolve('libs')),
testStrongMode: true,
forUserLibrariesOnly: true,
args: args,
options: [stopAfterTypeInference],

View file

@ -2,8 +2,11 @@
// 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.
/*element: method:SideEffects(reads nothing; writes nothing)*/
method() {}
/*element: callExpression:SideEffects(reads anything; writes anything)*/
callExpression() => (null)();
callExpression() => (method)();
/*element: Super.:SideEffects(reads nothing; writes nothing)*/
class Super {

View file

@ -26,8 +26,7 @@ main(List<String> args) {
dataDir, computeMemberAstSideEffects, computeMemberIrSideEffects,
args: args,
options: [stopAfterTypeInference],
// TODO(johnniwinther): Run tests with strong mode.
testStrongMode: false);
skipForStrong: ['closure_call.dart']);
});
}

View file

@ -22,7 +22,7 @@ main() {
/*element: _method1:[_conditionalField]*/
_method1() => 42;
var _field1;
bool _field1;
/*element: _conditionalField:[]*/
_conditionalField() {
@ -49,7 +49,7 @@ conditionalField() {
_method2() => 42;
/*element: _conditionalParameter:[conditionalParameter]*/
_conditionalParameter(o) {
_conditionalParameter(bool o) {
return o
? _method2() + _method2() + _method2()
: _method2() + _method2() + _method2();

View file

@ -28,10 +28,7 @@ main(List<String> args) {
Directory dataDir = new Directory.fromUri(Platform.script.resolve('data'));
await checkTests(
dataDir, computeMemberAstInlinings, computeMemberIrInlinings,
args: args,
skipForAst: ['external.dart'],
// TODO(johnniwinther): Run tests with strong mode.
testStrongMode: false);
args: args, skipForAst: ['external.dart']);
});
}

View file

@ -0,0 +1,101 @@
// Copyright (c) 2017, 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.
simpleForInLoopWithContinue(list) {
/*0@continue*/ for (int i in list) {
if (i % 2 == 0) /*target=0*/ continue;
print(i);
}
}
complexForInLoopWithContinueLookalike1(list) {
for (int i in list) {
label:
/*0@break*/
{
if (i % 2 == 0) /*target=0*/ break label;
print(i);
}
print(i);
}
}
complexForInLoopWithContinueLookalike2(list) {
/*kernel.0@continue*/
/*strong.0@continue*/
for (int i in list) {
label:
/*ast.0@break*/
{
if (i % 2 == 0) /*target=0*/ break label;
print(i);
}
}
}
labelledBreakInNestedWhileLoop(bool condition()) {
int i = 111;
/*0@break*/ while (condition()) {
label:
/*1@break*/ {
while (condition()) {
/*target=1*/ break label;
}
i--;
}
/*target=0*/ break;
}
return i;
}
nestedLoopsWithInnerBreak(list) {
for (int i in list) {
/*0@break*/ for (int j in list) {
if (i % j == 0) /*target=0*/ break;
print(i);
}
}
}
nestedLoopsWithInnerContinue(list) {
for (int i in list) {
/*0@continue*/ for (int j in list) {
if (i % j == 0) /*target=0*/ continue;
print(i);
}
}
}
nestedLoopsWithLabelledBreak(list) {
outer:
/*0@break*/
for (int i in list) {
for (int j in list) {
if (i % j == 0) /*target=0*/ break outer;
print(i);
}
}
}
nestedLoopsWithLabelledContinue(list) {
outer:
/*0@continue*/
for (int i in list) {
for (int j in list) {
if (i % j == 0) /*target=0*/ continue outer;
print(i);
}
}
}
main() {
simpleForInLoopWithContinue([1, 2, 3, 4]);
complexForInLoopWithContinueLookalike1([1, 2, 3, 4]);
complexForInLoopWithContinueLookalike2([1, 2, 3, 4]);
labelledBreakInNestedWhileLoop(() => true);
nestedLoopsWithInnerBreak([1, 2, 3, 4]);
nestedLoopsWithInnerContinue([1, 2, 3, 4]);
nestedLoopsWithLabelledBreak([1, 2, 3, 4]);
nestedLoopsWithLabelledContinue([1, 2, 3, 4]);
}

View file

@ -24,9 +24,7 @@ main(List<String> args) {
Directory dataDir = new Directory.fromUri(Platform.script.resolve('data'));
await checkTests(dataDir, computeJumpsData, computeKernelJumpsData,
options: [Flags.disableTypeInference, stopAfterTypeInference],
args: args,
// TODO(johnniwinther): Run tests with strong mode.
testStrongMode: false);
args: args);
});
}