Unverified Commit 09c07067 authored by Alexander Aprelev's avatar Alexander Aprelev Committed by GitHub

Roll engine, patch expression evaluation (#128255)

Roll to engine to 4f4486b00be28183b482bbb74bbed25f4db153fe  pick up dart to 3.1.0-169.0.dev.
Changes since last roll
```
4f4486b00b Roll dart to 3.1.0-169.0.dev (#42602)
```

Manual roll since rolling to dart 3.1.0-169.0.dev requires patching to expression evaluation in flutter tools
parent 848d4f0e
59d5444cf06c7a1237ed2768d2056b102c5a702e
4f4486b00be28183b482bbb74bbed25f4db153fe
......@@ -396,17 +396,25 @@ class _CompileExpressionRequest extends _CompilationRequest {
super.completer,
this.expression,
this.definitions,
this.definitionTypes,
this.typeDefinitions,
this.typeBounds,
this.typeDefaults,
this.libraryUri,
this.klass,
this.method,
this.isStatic,
);
String expression;
List<String>? definitions;
List<String>? definitionTypes;
List<String>? typeDefinitions;
List<String>? typeBounds;
List<String>? typeDefaults;
String? libraryUri;
String? klass;
String? method;
bool isStatic;
@override
......@@ -506,9 +514,13 @@ abstract class ResidentCompiler {
Future<CompilerOutput?> compileExpression(
String expression,
List<String>? definitions,
List<String>? definitionTypes,
List<String>? typeDefinitions,
List<String>? typeBounds,
List<String>? typeDefaults,
String? libraryUri,
String? klass,
String? method,
bool isStatic,
);
......@@ -835,9 +847,13 @@ class DefaultResidentCompiler implements ResidentCompiler {
Future<CompilerOutput?> compileExpression(
String expression,
List<String>? definitions,
List<String>? definitionTypes,
List<String>? typeDefinitions,
List<String>? typeBounds,
List<String>? typeDefaults,
String? libraryUri,
String? klass,
String? method,
bool isStatic,
) async {
if (!_controller.hasListener) {
......@@ -846,7 +862,8 @@ class DefaultResidentCompiler implements ResidentCompiler {
final Completer<CompilerOutput?> completer = Completer<CompilerOutput?>();
final _CompileExpressionRequest request = _CompileExpressionRequest(
completer, expression, definitions, typeDefinitions, libraryUri, klass, isStatic);
completer, expression, definitions, definitionTypes, typeDefinitions,
typeBounds, typeDefaults, libraryUri, klass, method, isStatic);
_controller.add(request);
return completer.future;
}
......@@ -867,11 +884,18 @@ class DefaultResidentCompiler implements ResidentCompiler {
..writeln(request.expression);
request.definitions?.forEach(server.stdin.writeln);
server.stdin.writeln(inputKey);
request.definitionTypes?.forEach(server.stdin.writeln);
server.stdin.writeln(inputKey);
request.typeDefinitions?.forEach(server.stdin.writeln);
server.stdin.writeln(inputKey);
request.typeBounds?.forEach(server.stdin.writeln);
server.stdin.writeln(inputKey);
request.typeDefaults?.forEach(server.stdin.writeln);
server.stdin
..writeln(inputKey)
..writeln(request.libraryUri ?? '')
..writeln(request.klass ?? '')
..writeln(request.method ?? '')
..writeln(request.isStatic);
return _stdoutHandler.compilerOutput?.future;
......
......@@ -192,16 +192,21 @@ class HotRunner extends ResidentRunner {
String isolateId,
String expression,
List<String> definitions,
List<String> definitionTypes,
List<String> typeDefinitions,
List<String> typeBounds,
List<String> typeDefaults,
String libraryUri,
String? klass,
String? method,
bool isStatic,
) async {
for (final FlutterDevice? device in flutterDevices) {
if (device!.generator != null) {
final CompilerOutput? compilerOutput =
await device.generator!.compileExpression(expression, definitions,
typeDefinitions, libraryUri, klass, isStatic);
definitionTypes, typeDefinitions, typeBounds, typeDefaults,
libraryUri, klass, method, isStatic);
if (compilerOutput != null && compilerOutput.expressionData != null) {
return base64.encode(compilerOutput.expressionData!);
}
......
......@@ -392,9 +392,13 @@ class FlutterPlatform extends PlatformPlugin {
String isolateId,
String expression,
List<String> definitions,
List<String> definitionTypes,
List<String> typeDefinitions,
List<String> typeBounds,
List<String> typeDefaults,
String libraryUri,
String? klass,
String? method,
bool isStatic,
) async {
if (compiler == null || compiler!.compiler == null) {
......@@ -402,7 +406,8 @@ class FlutterPlatform extends PlatformPlugin {
}
final CompilerOutput? compilerOutput =
await compiler!.compiler!.compileExpression(expression, definitions,
typeDefinitions, libraryUri, klass, isStatic);
definitionTypes, typeDefinitions, typeBounds, typeDefaults, libraryUri,
klass, method, isStatic);
if (compilerOutput != null && compilerOutput.expressionData != null) {
return base64.encode(compilerOutput.expressionData!);
}
......
......@@ -108,9 +108,13 @@ typedef CompileExpression = Future<String> Function(
String isolateId,
String expression,
List<String> definitions,
List<String> definitionTypes,
List<String> typeDefinitions,
List<String> typeBounds,
List<String> typeDefaults,
String libraryUri,
String? klass,
String? method,
bool isStatic,
);
......@@ -256,14 +260,18 @@ Future<vm_service.VmService> setUpVmService({
final String isolateId = _validateRpcStringParam('compileExpression', params, 'isolateId');
final String expression = _validateRpcStringParam('compileExpression', params, 'expression');
final List<String> definitions = List<String>.from(params['definitions']! as List<Object?>);
final List<String> definitionTypes = List<String>.from(params['definitionTypes']! as List<Object?>);
final List<String> typeDefinitions = List<String>.from(params['typeDefinitions']! as List<Object?>);
final List<String> typeBounds = List<String>.from(params['typeBounds']! as List<Object?>);
final List<String> typeDefaults = List<String>.from(params['typeDefaults']! as List<Object?>);
final String libraryUri = params['libraryUri']! as String;
final String? klass = params['klass'] as String?;
final String? method = params['method'] as String?;
final bool isStatic = _validateRpcBoolParam('compileExpression', params, 'isStatic');
final String kernelBytesBase64 = await compileExpression(isolateId,
expression, definitions, typeDefinitions, libraryUri, klass,
isStatic);
expression, definitions, definitionTypes, typeDefinitions, typeBounds, typeDefaults,
libraryUri, klass, method, isStatic);
return <String, Object>{
kResultType: kResultTypeSuccess,
'result': <String, String>{'kernelBytes': kernelBytesBase64},
......
......@@ -50,7 +50,7 @@ void main() {
testWithoutContext('compile expression fails if not previously compiled', () async {
final CompilerOutput? result = await generator.compileExpression(
'2+2', null, null, null, null, false);
'2+2', null, null, null, null, null, null, null, null, false);
expect(result, isNull);
});
......@@ -93,7 +93,7 @@ void main() {
'result def\nline1\nline2\ndef\ndef /path/to/main.dart.dill.incremental 0\n'
)));
generator.compileExpression(
'2+2', null, null, null, null, false).then(
'2+2', null, null, null, null, null, null, null, null, false).then(
(CompilerOutput? outputExpression) {
expect(outputExpression, isNotNull);
expect(outputExpression!.expressionData, <int>[1, 2, 3, 4]);
......@@ -142,7 +142,8 @@ void main() {
// The test manages timing via completers.
final Completer<bool> lastExpressionCompleted = Completer<bool>();
unawaited(
generator.compileExpression('0+1', null, null, null, null, false).then(
generator.compileExpression('0+1', null, null, null, null, null, null,
null, null, false).then(
(CompilerOutput? outputExpression) {
expect(outputExpression, isNotNull);
expect(outputExpression!.expressionData, <int>[0, 1, 2, 3]);
......@@ -159,7 +160,8 @@ void main() {
// The test manages timing via completers.
unawaited(
generator.compileExpression('1+1', null, null, null, null, false).then(
generator.compileExpression('1+1', null, null, null, null, null, null,
null, null, false).then(
(CompilerOutput? outputExpression) {
expect(outputExpression, isNotNull);
expect(outputExpression!.expressionData, <int>[4, 5, 6, 7]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment