Skip to content

Commit 5ea7e4d

Browse files
author
Dart CI
committed
Version 2.12.0-42.0.dev
Merge commit '504e9a32f9187a59625d713cd5264cb8c93ab89f' into 'dev'
2 parents 7bbace2 + 504e9a3 commit 5ea7e4d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+219
-1512
lines changed

DEPS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ vars = {
6565
# Scripts that make 'git cl format' work.
6666
"clang_format_scripts_rev": "c09c8deeac31f05bd801995c475e7c8070f9ecda",
6767

68-
"gperftools_revision": "e9ab4c53041ac62feefbbb076d326e9a77dd1567",
68+
"gperftools_revision": "180bfa10d7cb38e8b3784d60943d50e8fcef0dcb",
6969

7070
# Revisions of /third_party/* dependencies.
7171
"args_tag": "1.6.0",

pkg/compiler/lib/src/kernel/transformations/list_factory_specializer.dart

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,22 @@ class ListGenerateLoopBodyInliner extends CloneVisitorNotMembers {
251251
if (function.namedParameters.isNotEmpty) return false;
252252

253253
final body = function.body;
254-
// For now, only arrow functions.
254+
255+
// Arrow functions.
255256
if (body is ReturnStatement) return true;
256257

258+
if (body is Block) {
259+
// Simple body containing just a return.
260+
final statements = body.statements;
261+
if (statements.length == 1 && statements.single is ReturnStatement) {
262+
return true;
263+
}
264+
265+
// TODO(sra): We can accept more complex closures but, with diminishing
266+
// returns. It would probably be best to handle more complex cases by
267+
// improving environment design and inlining.
268+
}
269+
257270
return false;
258271
}
259272

pkg/compiler/lib/src/ssa/invoke_dynamic_specializers.dart

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,13 @@ class InvokeDynamicSpecializer {
109109
return const InvokeDynamicSpecializer();
110110
}
111111

112+
bool requiresBoundsCheck(HInvokeDynamic node, JClosedWorld closedWorld) {
113+
if (node.isBoundsSafe) return false;
114+
return closedWorld.annotationsData
115+
.getIndexBoundsCheckPolicy(node.instructionContext)
116+
.isEmitted;
117+
}
118+
112119
HBoundsCheck insertBoundsCheck(HInstruction indexerNode, HInstruction array,
113120
HInstruction indexArgument, JClosedWorld closedWorld) {
114121
final abstractValueDomain = closedWorld.abstractValueDomain;
@@ -202,9 +209,7 @@ class IndexAssignSpecializer extends InvokeDynamicSpecializer {
202209
}
203210

204211
HInstruction checkedIndex = index;
205-
if (closedWorld.annotationsData
206-
.getIndexBoundsCheckPolicy(instruction.instructionContext)
207-
.isEmitted) {
212+
if (requiresBoundsCheck(instruction, closedWorld)) {
208213
checkedIndex =
209214
insertBoundsCheck(instruction, receiver, index, closedWorld);
210215
}
@@ -283,9 +288,7 @@ class IndexSpecializer extends InvokeDynamicSpecializer {
283288
}
284289

285290
HInstruction checkedIndex = index;
286-
if (closedWorld.annotationsData
287-
.getIndexBoundsCheckPolicy(instruction.instructionContext)
288-
.isEmitted) {
291+
if (requiresBoundsCheck(instruction, closedWorld)) {
289292
checkedIndex =
290293
insertBoundsCheck(instruction, receiver, index, closedWorld);
291294
}
@@ -315,9 +318,7 @@ class RemoveLastSpecializer extends InvokeDynamicSpecializer {
315318
// We are essentially inlining `result = a[a.length - 1]`. `0` is the only
316319
// index that can fail so we check zero directly, but we want to report the
317320
// error index as `-1`, so we add `-1` as an extra input that to the check.
318-
if (closedWorld.annotationsData
319-
.getIndexBoundsCheckPolicy(instruction.instructionContext)
320-
.isEmitted) {
321+
if (requiresBoundsCheck(instruction, closedWorld)) {
321322
HConstant zeroIndex = graph.addConstantInt(0, closedWorld);
322323
HBoundsCheck check =
323324
insertBoundsCheck(instruction, receiver, zeroIndex, closedWorld);
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Copyright (c) 2020, 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+
var list1 = List<int>.generate(10, (i) {
6+
return i;
7+
});
8+
9+
var list2 = List<int>.generate(10, (i) {
10+
return i;
11+
}, growable: true);
12+
13+
var list3 = List<int>.generate(10, (i) {
14+
return i;
15+
}, growable: false);
16+
17+
var list4 = List<int>.generate(10, (i) {
18+
return i;
19+
}, growable: someGrowable);
20+
21+
// Not expanded - complex closure.
22+
var list5 = List<int>.generate(10, (i) {
23+
if (i.isEven) return i + 1;
24+
return i - 1;
25+
});
26+
27+
// Not expanded - inscrutable closure.
28+
var list6 = List<int>.generate(10, foo);
29+
int foo(int i) => i;
30+
31+
// Not expanded - inscrutable closure.
32+
var list7 = List<int>.generate(10, bar);
33+
int Function(int) get bar => foo;
34+
35+
bool someGrowable = true;
36+
37+
void main() {
38+
someGrowable = !someGrowable;
39+
print([list1, list2, list3, list4, list5, list6, list7]);
40+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
library #lib;
2+
import self as self;
3+
import "dart:core" as core;
4+
import "dart:_interceptors" as _in;
5+
6+
static field core::List<core::int*>* list1 = block {
7+
final _in::JSArray<core::int*> _list = _in::JSArray::allocateGrowable<core::int*>(10);
8+
for (core::int i = 0; i.{core::num::<}(10); i = i.{core::num::+}(1)) {
9+
core::int* i = i;
10+
{
11+
_list.{_in::JSArray::[]=}{Invariant,BoundsSafe}(i, i);
12+
}
13+
}
14+
} =>_list;
15+
static field core::List<core::int*>* list2 = block {
16+
final _in::JSArray<core::int*> _list = _in::JSArray::allocateGrowable<core::int*>(10);
17+
for (core::int i = 0; i.{core::num::<}(10); i = i.{core::num::+}(1)) {
18+
core::int* i = i;
19+
{
20+
_list.{_in::JSArray::[]=}{Invariant,BoundsSafe}(i, i);
21+
}
22+
}
23+
} =>_list;
24+
static field core::List<core::int*>* list3 = block {
25+
final _in::JSArray<core::int*> _list = _in::JSArray::allocateFixed<core::int*>(10);
26+
for (core::int i = 0; i.{core::num::<}(10); i = i.{core::num::+}(1)) {
27+
core::int* i = i;
28+
{
29+
_list.{_in::JSArray::[]=}{Invariant,BoundsSafe}(i, i);
30+
}
31+
}
32+
} =>_list;
33+
static field core::List<core::int*>* list4 = core::List::generate<core::int*>(10, (core::int* i) → core::int* {
34+
return i;
35+
}, growable: self::someGrowable);
36+
static field core::List<core::int*>* list5 = core::List::generate<core::int*>(10, (core::int* i) → core::int* {
37+
if(i.{core::int::isEven})
38+
return i.{core::num::+}(1);
39+
return i.{core::num::-}(1);
40+
});
41+
static field core::List<core::int*>* list6 = core::List::generate<core::int*>(10, #C1);
42+
static field core::List<core::int*>* list7 = core::List::generate<core::int*>(10, self::bar);
43+
static field core::bool* someGrowable = true;
44+
static method foo(core::int* i) → core::int*
45+
return i;
46+
static get bar() → (core::int*) →* core::int*
47+
return #C1;
48+
static method main() → void {
49+
self::someGrowable = !self::someGrowable;
50+
core::print(<core::List<core::int*>*>[self::list1, self::list2, self::list3, self::list4, self::list5, self::list6, self::list7]);
51+
}

pkg/front_end/testcases/incremental_initialize_from_dill/await_in_non_async.yaml.world.1.expect

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ library from "org-dartlang-test:///main.dart" as main {
77
static method foo() → dynamic {}
88
}
99

10-
And 19 platform libraries:
10+
And 18 platform libraries:
1111
- dart:_http
1212
- dart:_builtin
1313
- dart:vmservice_io
@@ -26,4 +26,3 @@ And 19 platform libraries:
2626
- dart:mirrors
2727
- dart:typed_data
2828
- dart:_vmservice
29-
- dart:wasm

pkg/front_end/testcases/incremental_initialize_from_dill/await_in_non_async.yaml.world.2.expect

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ library from "org-dartlang-test:///main.dart" as main {
1414
static method foo() → dynamic {}
1515
}
1616

17-
And 19 platform libraries:
17+
And 18 platform libraries:
1818
- dart:_http
1919
- dart:_builtin
2020
- dart:vmservice_io
@@ -33,4 +33,3 @@ And 19 platform libraries:
3333
- dart:mirrors
3434
- dart:typed_data
3535
- dart:_vmservice
36-
- dart:wasm

pkg/front_end/testcases/incremental_initialize_from_dill/bad_sdk_uri.yaml.world.3.expect

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ library from "org-dartlang-test:///main.dart" as main {
2020
}
2121
}
2222

23-
And 18 platform libraries:
23+
And 17 platform libraries:
2424
- dart:_builtin
2525
- dart:_internal
2626
- dart:_vmservice
@@ -38,4 +38,3 @@ And 18 platform libraries:
3838
- dart:nativewrappers
3939
- dart:typed_data
4040
- dart:vmservice_io
41-
- dart:wasm

pkg/front_end/testcases/incremental_initialize_from_dill/load_from_component_explicitly_import_dart_core.yaml.world.1.expect

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ library from "org-dartlang-test:///main.dart" as main {
1616
}
1717
}
1818

19-
And 19 platform libraries:
19+
And 18 platform libraries:
2020
- dart:_http
2121
- dart:_builtin
2222
- dart:vmservice_io
@@ -35,4 +35,3 @@ And 19 platform libraries:
3535
- dart:mirrors
3636
- dart:typed_data
3737
- dart:_vmservice
38-
- dart:wasm

pkg/front_end/testcases/incremental_initialize_from_dill/load_from_component_explicitly_import_dart_core.yaml.world.2.expect

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ library from "org-dartlang-test:///main.dart" as main {
1616
}
1717
}
1818

19-
And 19 platform libraries:
19+
And 18 platform libraries:
2020
- dart:_http
2121
- dart:_builtin
2222
- dart:vmservice_io
@@ -35,4 +35,3 @@ And 19 platform libraries:
3535
- dart:mirrors
3636
- dart:typed_data
3737
- dart:_vmservice
38-
- dart:wasm

0 commit comments

Comments
 (0)