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