-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge d9502e2 into dev
- Loading branch information
Showing
14 changed files
with
320 additions
and
71 deletions.
There are no files selected for viewing
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
47 changes: 47 additions & 0 deletions
47
pkg/vm_service/test/forward_compile_expression_error_from_external_client_test_common.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,47 @@ | ||
// Copyright (c) 2024, 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. | ||
|
||
import 'package:test/test.dart'; | ||
import 'package:vm_service/vm_service.dart'; | ||
import 'package:vm_service/vm_service_io.dart' show vmServiceConnectUri; | ||
|
||
import 'common/service_test_common.dart'; | ||
|
||
final tests = <IsolateTest>[ | ||
hasStoppedAtExit, | ||
(VmService primaryClient, IsolateRef isolateRef) async { | ||
const expressionCompilationFailedMessage = 'Expresion compilation failed'; | ||
|
||
final secondaryClient = await vmServiceConnectUri(primaryClient.wsUri!); | ||
secondaryClient.registerServiceCallback('compileExpression', | ||
(params) async { | ||
return { | ||
'jsonrpc': '2.0', | ||
'id': 0, | ||
'error': { | ||
'code': RPCErrorKind.kExpressionCompilationError.code, | ||
'message': expressionCompilationFailedMessage, | ||
'data': {'details': expressionCompilationFailedMessage}, | ||
}, | ||
}; | ||
}); | ||
await secondaryClient.registerService( | ||
'compileExpression', | ||
'Custom Expression Compilation', | ||
); | ||
|
||
final isolateId = isolateRef.id!; | ||
try { | ||
final isolate = await primaryClient.getIsolate(isolateId); | ||
await primaryClient.evaluate(isolateId, isolate.rootLib!.id!, '123'); | ||
fail('Expected to catch an RPCError'); | ||
} on RPCError catch (e) { | ||
expect(e.code, RPCErrorKind.kExpressionCompilationError.code); | ||
// [e.details] used to be the string | ||
// "{code: 113, message: Expresion compilation failed, data: ...}", so we | ||
// want to avoid regressing to that behaviour. | ||
expect(e.details, expressionCompilationFailedMessage); | ||
} | ||
}, | ||
]; |
15 changes: 15 additions & 0 deletions
15
pkg/vm_service/test/forward_compile_expression_error_from_external_client_with_dds_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,15 @@ | ||
// Copyright (c) 2024, 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 is a regression test for https://dartbug.com/59603. | ||
|
||
import 'common/test_helper.dart'; | ||
import 'forward_compile_expression_error_from_external_client_test_common.dart'; | ||
|
||
void main([args = const <String>[]]) => runIsolateTests( | ||
args, | ||
tests, | ||
'forward_compile_expression_error_from_external_client_with_dds_test.dart', | ||
pauseOnExit: true, | ||
); |
16 changes: 16 additions & 0 deletions
16
..._service/test/forward_compile_expression_error_from_external_client_without_dds_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,16 @@ | ||
// Copyright (c) 2024, 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 is a regression test for https://dartbug.com/59603. | ||
|
||
import 'common/test_helper.dart'; | ||
import 'forward_compile_expression_error_from_external_client_test_common.dart'; | ||
|
||
void main([args = const <String>[]]) => runIsolateTests( | ||
args, | ||
tests, | ||
'forward_compile_expression_error_from_external_client_without_dds_test.dart', | ||
pauseOnExit: true, | ||
extraArgs: ['--no-dds'], | ||
); |
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,22 @@ | ||
// Copyright (c) 2024, 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. | ||
|
||
// The Dart Project Fuzz Tester (1.101). | ||
// Program generated as: | ||
// dart dartfuzz.dart --seed 1868073336 --no-fp --no-ffi --flat | ||
// @dart=2.14 | ||
|
||
// VMOptions=--optimization_counter_threshold=1 --use-slow-path --deterministic | ||
|
||
import "dart:typed_data"; | ||
|
||
Uint8ClampedList var9 = Uint8ClampedList(40); | ||
bool var109 = true; | ||
int var112 = 5; | ||
|
||
main() { | ||
for (int loc0 = 0; loc0 < 41; loc0++) { | ||
var112 = var9[27] >>> (var109 ? 38 : 255); | ||
} | ||
} |
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,97 @@ | ||
// Copyright (c) 2024, 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. | ||
|
||
// VMOptions=--optimization-counter-threshold=50 --no-background-compilation | ||
|
||
import "package:expect/expect.dart"; | ||
|
||
@pragma("vm:never-inline") | ||
dynamic smi_add(dynamic x, dynamic y) => x + y; | ||
|
||
@pragma("vm:never-inline") | ||
dynamic smi_sub(dynamic x, dynamic y) => x - y; | ||
|
||
@pragma("vm:never-inline") | ||
dynamic smi_mul(dynamic x, dynamic y) => x * y; | ||
|
||
@pragma("vm:never-inline") | ||
dynamic smi_and(dynamic x, dynamic y) => x & y; | ||
|
||
@pragma("vm:never-inline") | ||
dynamic smi_or(dynamic x, dynamic y) => x | y; | ||
|
||
@pragma("vm:never-inline") | ||
dynamic smi_xor(dynamic x, dynamic y) => x ^ y; | ||
|
||
@pragma("vm:never-inline") | ||
dynamic smi_div(dynamic x, dynamic y) => x ~/ y; | ||
|
||
@pragma("vm:never-inline") | ||
dynamic smi_mod(dynamic x, dynamic y) => x % y; | ||
|
||
@pragma("vm:never-inline") | ||
dynamic smi_sll(dynamic x, dynamic y) => x << y; | ||
|
||
@pragma("vm:never-inline") | ||
dynamic smi_sra(dynamic x, dynamic y) => x >> y; | ||
|
||
@pragma("vm:never-inline") | ||
dynamic smi_srl(dynamic x, dynamic y) => x >>> y; | ||
|
||
testSmi() { | ||
Expect.equals(7, smi_add(3, 4)); | ||
Expect.equals(-1, smi_sub(3, 4)); | ||
Expect.equals(12, smi_mul(3, 4)); | ||
Expect.equals(0, smi_and(3, 4)); | ||
Expect.equals(7, smi_or(3, 4)); | ||
Expect.equals(7, smi_xor(3, 4)); | ||
Expect.equals(0, smi_div(3, 4)); | ||
Expect.equals(3, smi_mod(3, 4)); | ||
Expect.equals(48, smi_sll(3, 4)); | ||
Expect.equals(0, smi_sra(3, 4)); | ||
Expect.equals(0, smi_srl(3, 4)); | ||
} | ||
|
||
const maxSmi32 = 0x3FFFFFFF; | ||
const maxSmi64 = 0x3FFFFFFFFFFFFFFF; | ||
const minSmi32 = -0x80000000; | ||
const minSmi64 = -0x8000000000000000; | ||
|
||
testSmiDeopt() { | ||
Expect.equals(0x40000000, smi_add(maxSmi32, 1)); | ||
Expect.equals(0x4000000000000000, smi_add(maxSmi64, 1)); | ||
|
||
Expect.equals(0x40000000, smi_sub(maxSmi32, -1)); | ||
Expect.equals(0x4000000000000000, smi_sub(maxSmi64, -1)); | ||
|
||
Expect.equals(0x7FFFFFFE, smi_mul(maxSmi32, 2)); | ||
Expect.equals(0x7FFFFFFFFFFFFFFE, smi_mul(maxSmi64, 2)); | ||
|
||
Expect.equals(0x80000000, smi_div(minSmi32, -1)); | ||
Expect.equals(0x8000000000000000, smi_div(minSmi64, -1)); | ||
|
||
Expect.throws(() => smi_mod(minSmi32, 0)); | ||
Expect.throws(() => smi_mod(minSmi64, 0)); | ||
|
||
Expect.equals(0x7FFFFFFE, smi_sll(maxSmi32, 1)); | ||
Expect.equals(0x7FFFFFFFFFFFFFFE, smi_sll(maxSmi64, 1)); | ||
|
||
Expect.equals(0, smi_sra(maxSmi32, 65)); | ||
Expect.equals(0, smi_sra(maxSmi64, 65)); | ||
|
||
Expect.equals(0, smi_srl(minSmi32, 65)); | ||
Expect.equals(0, smi_srl(minSmi64, 65)); | ||
} | ||
|
||
main() { | ||
for (int i = 0; i < 200; i++) { | ||
testSmi(); | ||
} | ||
|
||
print("================================="); | ||
|
||
for (int i = 0; i < 200; i++) { | ||
testSmiDeopt(); | ||
} | ||
} |
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
Oops, something went wrong.