Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit f1d4c7c

Browse files
author
Dart CI
committed
Version 2.19.0-326.0.dev
Merge 8c0df46 into dev
2 parents cda4d45 + 8c0df46 commit f1d4c7c

Some content is hidden

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

45 files changed

+1597
-135
lines changed

DEPS

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ vars = {
9494

9595
"args_rev": "80d4abbd6b38b79bcdbc411b4b517628c7611232",
9696
"async_rev": "f3ed5f690e2ec9dbe1bfc5184705575b4f6480e5",
97-
"bazel_worker_rev": "75a947fad63925fb441932af651819132b5ca450",
97+
"bazel_worker_rev": "03717ca4c2bbf1d74f26c89673426e076288242a",
9898
"benchmark_harness_rev": "6a116758f2b96e92659194bcda990f42106a01d3",
9999
"boolean_selector_rev": "1d3565e2651d16566bb556955b96ea75018cbd0c",
100100
"boringssl_gen_rev": "ced85ef0a00bbca77ce5a91261a5f2ae61b1e62f",
@@ -128,7 +128,7 @@ vars = {
128128
"file_rev": "b2e31cb6ef40b223701dbfa0b907fe58468484d7",
129129
"fixnum_rev": "e0b17cc1f639c55a9c24947392c64b5a68992535",
130130
"glob_rev": "ee812790f4d98587a363e65d5af484ed9c6943f8",
131-
"html_rev": "0740fc737350959cfdb5f8a34425a29d0dc0d285",
131+
"html_rev": "0bf601959ac98e6cdf1925a1cdab70bd6a5ddc45",
132132
"http_multi_server_rev": "20bf079c8955d1250a45afb9cb096472a724a551",
133133
"http_parser_rev": "c73967535ce31120e218120f70ef98cc22688c82",
134134
"http_rev": "738a55b20e391c5a526b86bf4b02af6b7745b494",
@@ -139,7 +139,7 @@ vars = {
139139
"linter_rev": "f2c55484e8ebda0aec8c2fea637b3bd5b17258ca", # 1.28.0
140140
"lints_rev": "8294e5648ab49474541527e2911e72e4c5aefe55",
141141
"logging_rev": "f322480fb9d9e83e677c08db6d09067059f7ff74",
142-
"markdown_rev": "d72ae07c8290b3780044170eda28eda5a9fb342e", # b/254513467
142+
"markdown_rev": "93d0eee771f6355be6737c2a865f613f6b105bf1",
143143
"markupsafe_rev": "8f45f5cfa0009d2a70589bcda0349b8cb2b72783",
144144
"matcher_rev": "6a9b83bbd73e50df2058b3e8e4aa301df49569c6",
145145
"mime_rev": "bf041aa372a27aae6f94e185aa0af3932b9de98b",
@@ -155,7 +155,7 @@ vars = {
155155
"root_certificates_rev": "692f6d6488af68e0121317a9c2c9eb393eb0ee50",
156156
"shelf_rev": "39d820d4e32fc99c65f562786097487d597dcee1",
157157
"source_map_stack_trace_rev": "8d8078fcc81c8f7936805cd277198493e0b7fc62",
158-
"source_maps_rev": "c7e89635a7651974feb78e3ce272fac5aa3f4334",
158+
"source_maps_rev": "b031e2cdbef5675ab9a92025202d323a5e7cc526",
159159
"source_span_rev": "ff03af16474ce91c89eb3bc28182866f4cb6dfb0",
160160
"sse_rev": "283568dd4865cc51e25370ed107fcbdb68759c22",
161161
"stack_trace_rev": "dce00134f6558086e8963e37d0b1ba0830862c01",
@@ -174,7 +174,7 @@ vars = {
174174
"web_components_rev": "8f57dac273412a7172c8ade6f361b407e2e4ed02",
175175
"web_socket_channel_rev": "4b46c0c4196a5e76c2b0e2589ed37de247d35938",
176176
"WebCore_rev": "bcb10901266c884e7b3740abc597ab95373ab55c",
177-
"webdev_rev": "5343edbab54ecee37af9d18062847614b91a4bd6",
177+
"webdev_rev": "a02f073aecb4c4e7befdf4c1fcc4c83e67af8bf2",
178178
"webdriver_rev": "f56cc6a2f9612a0a13fec4282dc61b90df384033",
179179
"webkit_inspection_protocol_rev": "b825c8f6a12200d619729903207ac826cce278da",
180180
"yaml_edit_rev": "01589b3ce447b03aed991db49f1ec6445ad5476d",

pkg/analysis_server/lib/src/services/correction/dart/remove_dead_code.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ class RemoveDeadCode extends CorrectionProducer {
7474
});
7575
}
7676
} else if (coveredNode is Statement) {
77+
if (coveredNode is EmptyStatement) {
78+
return;
79+
}
7780
if (coveredNode is DoStatement &&
7881
await _computeDoStatement(builder, coveredNode)) {
7982
return;

pkg/analysis_server/test/src/services/correction/fix/remove_dead_code_test.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,15 @@ void f(bool c) {
185185
''', errorFilter: (err) => err.problemMessage.length == 10);
186186
}
187187

188+
Future<void> test_emptyStatement() async {
189+
await resolveTestCode('''
190+
void f() {
191+
for (var i = 0; false; i++);
192+
}
193+
''');
194+
await assertNoFix();
195+
}
196+
188197
@failingTest
189198
Future<void> test_for_returnInBody() async {
190199
// https://github.com/dart-lang/sdk/issues/43511

pkg/analysis_server_client/pubspec.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,5 @@ dependencies:
1919
# See also https://dart.dev/tools/pub/dependencies.
2020
dev_dependencies:
2121
analyzer: any
22-
analysis_server: any
23-
analyzer_utilities: any
2422
lints: any
2523
test: any

pkg/analysis_server_client/test/verify_sorted_test.dart

Lines changed: 102 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -2,75 +2,122 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
import 'package:analysis_server/src/services/correction/sort_members.dart';
6-
import 'package:analyzer/dart/analysis/analysis_context_collection.dart';
7-
import 'package:analyzer/dart/analysis/results.dart';
8-
import 'package:analyzer/dart/analysis/session.dart';
5+
import 'dart:async';
6+
import 'dart:io';
7+
8+
import 'package:analysis_server_client/handler/connection_handler.dart';
9+
import 'package:analysis_server_client/handler/notification_handler.dart';
10+
import 'package:analysis_server_client/protocol.dart';
11+
import 'package:analysis_server_client/server.dart';
912
import 'package:analyzer/file_system/file_system.dart';
1013
import 'package:analyzer/file_system/physical_file_system.dart';
11-
import 'package:analyzer_utilities/package_root.dart';
14+
import 'package:path/path.dart' as pathos;
1215
import 'package:test/test.dart';
1316

14-
void main() {
17+
void main() async {
1518
var provider = PhysicalResourceProvider.INSTANCE;
1619
var normalizedRoot = provider.pathContext.normalize(packageRoot);
1720
var packagePath =
1821
provider.pathContext.join(normalizedRoot, 'analysis_server_client');
19-
// TODO(brianwilkerson) Fix the generator to sort the generated files and
20-
// remove these exclusions.
21-
var generatedFilePaths = [
22-
provider.pathContext
23-
.join(packagePath, 'lib', 'src', 'protocol', 'protocol_common.dart'),
24-
provider.pathContext
25-
.join(packagePath, 'lib', 'src', 'protocol', 'protocol_constants.dart'),
26-
provider.pathContext
27-
.join(packagePath, 'lib', 'src', 'protocol', 'protocol_generated.dart'),
28-
];
29-
30-
var collection = AnalysisContextCollection(
31-
includedPaths: <String>[packagePath],
32-
excludedPaths: generatedFilePaths,
33-
resourceProvider: provider);
34-
var contexts = collection.contexts;
35-
if (contexts.length != 1) {
36-
fail('The directory $packagePath contains multiple analysis contexts.');
22+
23+
group('validate member sort order', () {
24+
late Server server;
25+
26+
setUpAll(() async {
27+
server = await connectToServer(packagePath);
28+
});
29+
30+
tearDownAll(() async {
31+
await server.stop();
32+
});
33+
34+
// define tests
35+
for (var file in listPackageDartFiles(provider.getFolder(packagePath))) {
36+
var relativePath =
37+
provider.pathContext.relative(file.path, from: packagePath);
38+
39+
test(relativePath, () async {
40+
var response = await server.send(EDIT_REQUEST_SORT_MEMBERS,
41+
EditSortMembersParams(file.path).toJson());
42+
var result = EditSortMembersResult.fromJson(
43+
ResponseDecoder(null), 'result', response);
44+
45+
expect(result.edit.edits, isEmpty);
46+
});
47+
}
48+
});
49+
}
50+
51+
/// Returns a path to the pkg directory.
52+
String get packageRoot {
53+
var scriptPath = pathos.fromUri(Platform.script);
54+
var parts = pathos.split(scriptPath);
55+
var pkgIndex = parts.indexOf('pkg');
56+
return pathos.joinAll(parts.sublist(0, pkgIndex + 1)) + pathos.separator;
57+
}
58+
59+
Future<Server> connectToServer(String packagePath) async {
60+
// start the server
61+
var server = Server();
62+
await server.start();
63+
64+
// connect to the server
65+
var handler = StatusHandler(server);
66+
server.listenToOutput(notificationProcessor: handler.handleEvent);
67+
if (!await handler.serverConnected(timeLimit: const Duration(seconds: 15))) {
68+
stderr.writeln('server failed to start');
69+
exit(1);
3770
}
3871

39-
buildTestsIn(contexts[0].currentSession, packagePath, generatedFilePaths,
40-
provider.getFolder(packagePath));
72+
// start analysis
73+
await server.send(SERVER_REQUEST_SET_SUBSCRIPTIONS,
74+
ServerSetSubscriptionsParams([ServerService.STATUS]).toJson());
75+
await server.send(ANALYSIS_REQUEST_SET_ANALYSIS_ROOTS,
76+
AnalysisSetAnalysisRootsParams([packagePath], const []).toJson());
77+
78+
// wait for analysis to complete
79+
await handler.analysisFinshed.future;
80+
81+
return server;
4182
}
4283

43-
void buildTestsIn(AnalysisSession session, String testDirPath,
44-
List<String> generatedFilePaths, Folder directory) {
45-
var pathContext = session.resourceProvider.pathContext;
46-
var children = directory.getChildren();
47-
children.sort((first, second) => first.shortName.compareTo(second.shortName));
84+
Iterable<File> listPackageDartFiles(Folder folder) sync* {
85+
// TODO(brianwilkerson) Fix the generator to sort the generated files and
86+
// remove these exclusions.
87+
const exclusions = <String>{
88+
'protocol_common.dart',
89+
'protocol_constants.dart',
90+
'protocol_generated.dart',
91+
};
92+
93+
var children = folder.getChildren()
94+
..sort((a, b) => a.shortName.compareTo(b.shortName));
95+
4896
for (var child in children) {
49-
if (child is Folder) {
50-
buildTestsIn(session, testDirPath, generatedFilePaths, child);
51-
} else if (child is File && child.shortName.endsWith('.dart')) {
52-
var path = child.path;
53-
if (generatedFilePaths.contains(path)) {
54-
continue;
97+
if (child is File && child.shortName.endsWith('.dart')) {
98+
if (!exclusions.contains(child.shortName)) {
99+
yield child;
100+
}
101+
} else if (child is Folder) {
102+
yield* listPackageDartFiles(child);
103+
}
104+
}
105+
}
106+
107+
class StatusHandler with NotificationHandler, ConnectionHandler {
108+
@override
109+
final Server server;
110+
111+
final Completer<bool> analysisFinshed = Completer();
112+
113+
StatusHandler(this.server);
114+
115+
@override
116+
void onServerStatus(ServerStatusParams params) {
117+
if (params.analysis != null) {
118+
if (!params.analysis!.isAnalyzing) {
119+
analysisFinshed.complete(true);
55120
}
56-
var relativePath = pathContext.relative(path, from: testDirPath);
57-
test(relativePath, () async {
58-
var result = session.getParsedUnit(path);
59-
if (result is! ParsedUnitResult) {
60-
fail('Could not parse $path');
61-
}
62-
var code = result.content;
63-
var unit = result.unit;
64-
var errors = result.errors;
65-
if (errors.isNotEmpty) {
66-
fail('Errors found when parsing $path');
67-
}
68-
var sorter = MemberSorter(code, unit, result.lineInfo);
69-
var edits = sorter.sort();
70-
if (edits.isNotEmpty) {
71-
fail('Unsorted file $path');
72-
}
73-
});
74121
}
75122
}
76123
}

runtime/lib/double.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
#include "lib/integers.h"
6+
57
#include "vm/bootstrap_natives.h"
68

79
#include <math.h> // NOLINT
@@ -76,7 +78,7 @@ DEFINE_NATIVE_ENTRY(Double_hashCode, 0, 1) {
7678
(val <= kMaxInt64RepresentableAsDouble)) {
7779
int64_t ival = static_cast<int64_t>(val);
7880
if (static_cast<double>(ival) == val) {
79-
return Integer::New(ival);
81+
return Integer::New(Multiply64Hash(ival));
8082
}
8183
}
8284

runtime/lib/integers.cc

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
#include "lib/integers.h"
56
#include "vm/bootstrap_natives.h"
67

78
#include "include/dart_api.h"
@@ -271,6 +272,37 @@ DEFINE_NATIVE_ENTRY(Smi_bitLength, 0, 1) {
271272
return Smi::New(result);
272273
}
273274

275+
// Should be kept in sync with
276+
// - il_(x64/arm64/...).cc HashIntegerOpInstr,
277+
// - asm_intrinsifier(...).cc Multiply64Hash
278+
uint32_t Multiply64Hash(int64_t ivalue) {
279+
const uint64_t magic_constant = /*0x1b873593cc9e*/ 0x2d51;
280+
uint64_t value = static_cast<uint64_t>(ivalue);
281+
#if defined(ARCH_IS_64_BIT)
282+
#ifdef _MSC_VER
283+
__int64 hi = __umulh(value, magic_constant);
284+
uint64_t lo = value * magic_constant;
285+
uint64_t hash = lo ^ hi;
286+
#else
287+
const __int128 res = static_cast<__int128>(value) * magic_constant;
288+
uint64_t hash = res ^ static_cast<int64_t>(res >> 64);
289+
#endif
290+
hash = hash ^ (hash >> 32);
291+
#else
292+
uint64_t prod_lo64 = value * magic_constant;
293+
294+
uint64_t value_lo32 = value & 0xffffffff;
295+
uint64_t value_hi32 = value >> 32;
296+
uint64_t carry = (((value_hi32 * magic_constant) & 0xffffffff) +
297+
((value_lo32 * magic_constant) >> 32)) >>
298+
32;
299+
uint64_t prod_hi64 = ((value_hi32 * magic_constant) >> 32) + carry;
300+
uint64_t hash = prod_hi64 ^ prod_lo64;
301+
hash = hash ^ (hash >> 32);
302+
#endif
303+
return hash & 0x3fffffff;
304+
}
305+
274306
// Mint natives.
275307

276308
DEFINE_NATIVE_ENTRY(Mint_bitNegate, 0, 1) {

runtime/lib/integers.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright (c) 2022, 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+
#ifndef RUNTIME_LIB_INTEGERS_H_
6+
#define RUNTIME_LIB_INTEGERS_H_
7+
8+
#include "platform/globals.h"
9+
10+
namespace dart {
11+
12+
uint32_t Multiply64Hash(int64_t value);
13+
14+
} // namespace dart
15+
16+
#endif // RUNTIME_LIB_INTEGERS_H_

runtime/tests/vm/dart/generic_field_invocation_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ class C {
1616
main() {
1717
var c = C();
1818
c.field = <T>(T x) => x.hashCode;
19-
Expect.equals(3, c.field<dynamic>(3));
19+
Expect.equals(3.hashCode, c.field<dynamic>(3));
2020
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright (c) 2022, 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+
// VMOptions=--intrinsify
6+
// VMOptions=--no_intrinsify
7+
8+
import 'package:expect/expect.dart';
9+
10+
main() {
11+
// We do not guarantee any particular hash function for integers,
12+
// but our implementation relies on the hash function being the same
13+
// across architectures.
14+
<int, int>{
15+
0: 0x0,
16+
-0: 0x0,
17+
1: 0x2d51,
18+
-1: 0x0,
19+
0xffff: 0x2d50d2af,
20+
-0xffff: 0x2d50fffe,
21+
0xffffffff: 0x3fffffff,
22+
-0xffffffff: 0x3fffd2ae,
23+
0x111111111111: 0x25630507,
24+
-0x111111111111: 0x25632856,
25+
0xffffffffffff: 0x12af2d50,
26+
-0xffffffffffff: 0x12af0001,
27+
9007199254840856: 0x2f2da59d,
28+
144115188075954880: 0x26761e9a,
29+
936748722493162112: 0x196ac8cd,
30+
}.forEach((value, expected) {
31+
Expect.equals(expected, value.hashCode, "${value}.hashCode");
32+
});
33+
}

runtime/tests/vm/dart/splay_ephemeron_test.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
// VMOptions=--verify_after_gc
2828
// VMOptions=--verify_before_gc --verify_after_gc
2929
// VMOptions=--verify_store_buffer
30-
// VMOptions=--verify_after_marking
3130
// VMOptions=--stress_write_barrier_elimination
3231
// VMOptions=--old_gen_heap_size=150
3332

runtime/tests/vm/dart/splay_test.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
// VMOptions=--verify_after_gc
2626
// VMOptions=--verify_before_gc --verify_after_gc
2727
// VMOptions=--verify_store_buffer
28-
// VMOptions=--verify_after_marking
2928
// VMOptions=--stress_write_barrier_elimination
3029
// VMOptions=--old_gen_heap_size=100
3130
// VMOptions=--mark_when_idle

0 commit comments

Comments
 (0)