Skip to content

Commit

Permalink
Merge pull request #906 from dart-lang/if-element-comment-split
Browse files Browse the repository at this point in the history
Don't add unneeded splits on if elements near comments.
  • Loading branch information
munificent authored Mar 20, 2020
2 parents 2fbd00e + 84adcf7 commit 71c3833
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Add `--verbose` to hide advanced options in `--help` output.
* Split outer nested control flow elements (#869).
* Always place a blank line after script tags (#782).
* Don't add unneeded splits on if elements near comments (#888).

# 1.3.3

Expand Down
2 changes: 1 addition & 1 deletion lib/src/source_visitor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1899,7 +1899,7 @@ class SourceVisitor extends ThrowingAstVisitor {

// Wrap the whole thing in a single rule. If a split happens inside the
// condition or the then clause, we want the then and else clauses to split.
builder.startRule();
builder.startLazyRule();

var hasInnerControlFlow = false;
for (var element in ifElements) {
Expand Down
85 changes: 85 additions & 0 deletions test/regression/0800/0888.unit
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
>>>
main() {
final args = [
if (_configuration.useBlobs) ...[
"--snapshot-kind=app-aot-blobs",
"--blobs_container_filename=$tempDir/out.aotsnapshot"
] else if (_configuration.useElf) ...[
"--snapshot-kind=app-aot-elf",
"--elf=$tempDir/out.aotsnapshot"
] else ...[
"--snapshot-kind=app-aot-assembly",
"--assembly=$tempDir/out.S"
],
if (_isAndroid && _isArm) '--no-sim-use-hardfp',
if (_configuration.isMinified) '--obfuscate',
if (_configuration.useQemu) '--no-use-integer-division',
..._replaceDartFiles(arguments, tempKernelFile(tempDir)),
];

final args2 = [
if (_configuration.useBlobs) ...[
"--snapshot-kind=app-aot-blobs",
"--blobs_container_filename=$tempDir/out.aotsnapshot"
] else if (_configuration.useElf) ...[
"--snapshot-kind=app-aot-elf",
"--elf=$tempDir/out.aotsnapshot"
] else ...[
"--snapshot-kind=app-aot-assembly",
"--assembly=$tempDir/out.S"
],
if (_isAndroid && _isArm)
'--no-sim-use-hardfp',
if (_configuration.isMinified)
'--obfuscate',
// The SIMARM precompiler assumes support for integer division, but the
// Qemu arm cpus do not support integer division.
if (_configuration.useQemu)
'--no-use-integer-division',
..._replaceDartFiles(arguments, tempKernelFile(tempDir)),
];

print(args);
print(args2);
}
<<<
main() {
final args = [
if (_configuration.useBlobs) ...[
"--snapshot-kind=app-aot-blobs",
"--blobs_container_filename=$tempDir/out.aotsnapshot"
] else if (_configuration.useElf) ...[
"--snapshot-kind=app-aot-elf",
"--elf=$tempDir/out.aotsnapshot"
] else ...[
"--snapshot-kind=app-aot-assembly",
"--assembly=$tempDir/out.S"
],
if (_isAndroid && _isArm) '--no-sim-use-hardfp',
if (_configuration.isMinified) '--obfuscate',
if (_configuration.useQemu) '--no-use-integer-division',
..._replaceDartFiles(arguments, tempKernelFile(tempDir)),
];

final args2 = [
if (_configuration.useBlobs) ...[
"--snapshot-kind=app-aot-blobs",
"--blobs_container_filename=$tempDir/out.aotsnapshot"
] else if (_configuration.useElf) ...[
"--snapshot-kind=app-aot-elf",
"--elf=$tempDir/out.aotsnapshot"
] else ...[
"--snapshot-kind=app-aot-assembly",
"--assembly=$tempDir/out.S"
],
if (_isAndroid && _isArm) '--no-sim-use-hardfp',
if (_configuration.isMinified) '--obfuscate',
// The SIMARM precompiler assumes support for integer division, but the
// Qemu arm cpus do not support integer division.
if (_configuration.useQemu) '--no-use-integer-division',
..._replaceDartFiles(arguments, tempKernelFile(tempDir)),
];

print(args);
print(args2);
}

0 comments on commit 71c3833

Please sign in to comment.