From 74cf86cbbb79fbdf6de8e4441b22e54ba97be553 Mon Sep 17 00:00:00 2001 From: Kevin Millikin Date: Wed, 11 Apr 2018 07:43:41 +0000 Subject: [PATCH] Remove Kernel's DispatchCategory It complicates the intermediate language, none of the back ends are using it, and it's not something that we want transformation writers and code generators to deal with. Change-Id: Ic79f7935dd8619bd233346bb25947e864f38a104 Reviewed-on: https://dart-review.googlesource.com/50440 Commit-Queue: Kevin Millikin Reviewed-by: Samir Jindel --- .../src/fasta/kernel/kernel_shadow_ast.dart | 5 +- .../testing/validating_instrumentation.dart | 1 - .../fasta/type_inference/type_inferrer.dart | 132 +++---------- .../testcases/runtime_checks/call_kinds.dart | 22 +-- .../runtime_checks/call_kinds_get.dart | 10 +- .../runtime_checks/call_kinds_set.dart | 10 +- .../runtime_checks/contravariant_field.dart | 2 +- .../contravariant_generic_return.dart | 6 +- ...ntravariant_generic_return_null_aware.dart | 6 +- ...contravariant_generic_return_tear_off.dart | 2 +- .../runtime_checks/contravariant_getter.dart | 4 +- .../contravariant_getter_return.dart | 6 +- ...ontravariant_getter_return_null_aware.dart | 6 +- ...variant_generic_method_type_parameter.dart | 2 +- ...c_method_type_parameter.dart.strong.expect | 6 +- ...e_parameter.dart.strong.transformed.expect | 6 +- .../covariant_generic_parameter_tear_off.dart | 4 +- .../runtime_checks/covariant_setter.dart | 4 +- .../runtime_checks/dynamic_invocation.dart | 4 +- .../dynamic_invocation_generic.dart | 4 +- .../dynamic_invocation_of_getter.dart | 2 +- .../forwarding_stub_with_default_values.dart | 8 +- .../runtime_checks_new/call_through_this.dart | 8 +- ...ith_compound_assign_implicit_downcast.dart | 12 +- .../runtime_checks_new/for_in_call_kinds.dart | 4 +- .../mixin_forwarding_stub_field.dart | 2 +- .../mixin_forwarding_stub_getter.dart | 6 +- .../mixin_forwarding_stub_setter.dart | 2 +- .../stub_checked_via_target.dart | 2 +- pkg/kernel/binary.md | 6 - pkg/kernel/lib/ast.dart | 176 ------------------ pkg/kernel/lib/binary/ast_from_binary.dart | 24 +-- pkg/kernel/lib/binary/ast_to_binary.dart | 6 - pkg/kernel/lib/clone.dart | 18 +- .../no_dynamic_invocations_annotator.dart | 40 ++-- .../frontend/kernel_binary_flowgraph.cc | 28 --- .../frontend/kernel_binary_flowgraph.h | 2 - 37 files changed, 124 insertions(+), 464 deletions(-) diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart index 11440d48764..ecd17f96149 100644 --- a/pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart +++ b/pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart @@ -1588,10 +1588,7 @@ class ShadowPropertyAssign extends ShadowComplexAssignmentWithReceiver { Object _handleWriteContravariance( ShadowTypeInferrer inferrer, DartType receiverType) { - var writeMember = inferrer.findPropertySetMember(receiverType, write); - inferrer.handlePropertySetContravariance( - receiver, writeMember, write is PropertySet ? write : null, write); - return writeMember; + return inferrer.findPropertySetMember(receiverType, write); } @override diff --git a/pkg/front_end/lib/src/fasta/testing/validating_instrumentation.dart b/pkg/front_end/lib/src/fasta/testing/validating_instrumentation.dart index f16d6af6a2b..e392ed6adad 100644 --- a/pkg/front_end/lib/src/fasta/testing/validating_instrumentation.dart +++ b/pkg/front_end/lib/src/fasta/testing/validating_instrumentation.dart @@ -39,7 +39,6 @@ class ValidatingInstrumentation implements Instrumentation { 'target', ], 'checks': const [ - 'callKind', 'covariance', 'checkGetterReturn', 'checkReturn', diff --git a/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart b/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart index 25adbdc4ca9..47471e5d4c5 100644 --- a/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart +++ b/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart @@ -12,7 +12,6 @@ import 'package:kernel/ast.dart' ConditionalExpression, ConstructorInvocation, DartType, - DispatchCategory, DynamicType, Expression, Field, @@ -59,8 +58,7 @@ import '../../base/instrumentation.dart' Instrumentation, InstrumentationValueForMember, InstrumentationValueForType, - InstrumentationValueForTypeArgs, - InstrumentationValueLiteral; + InstrumentationValueForTypeArgs; import '../fasta_codes.dart'; @@ -853,8 +851,7 @@ abstract class TypeInferrerImpl extends TypeInferrer { return expressionToReplace; } - /// Determines the dispatch category of a [PropertyGet] and adds an "as" check - /// if necessary due to contravariance. + /// Add an "as" check if necessary due to contravariance. /// /// Returns the "as" check if it was added; otherwise returns the original /// expression. @@ -865,17 +862,10 @@ abstract class TypeInferrerImpl extends TypeInferrer { Expression expression, DartType inferredType, int fileOffset) { - DispatchCategory callKind; - if (receiver is ThisExpression || receiver == null) { - callKind = DispatchCategory.viaThis; - } else if (interfaceMember == null) { - callKind = DispatchCategory.dynamicDispatch; - } else { - callKind = DispatchCategory.interface; - } - desugaredGet?.dispatchCategory = callKind; bool checkReturn = false; - if (callKind == DispatchCategory.interface) { + if (receiver != null && + interfaceMember != null && + receiver is! ThisExpression) { if (interfaceMember is Procedure) { checkReturn = interfaceMember.isGenericContravariant; } else if (interfaceMember is Field) { @@ -891,57 +881,13 @@ abstract class TypeInferrerImpl extends TypeInferrer { ..fileOffset = fileOffset; parent.replaceChild(expressionToReplace, replacedExpression); } - if (instrumentation != null) { - int offset = expression.fileOffset; - switch (callKind) { - case DispatchCategory.dynamicDispatch: - instrumentation.record(uri, offset, 'callKind', - new InstrumentationValueLiteral('dynamic')); - break; - case DispatchCategory.viaThis: - instrumentation.record( - uri, offset, 'callKind', new InstrumentationValueLiteral('this')); - break; - default: - break; - } - if (checkReturn) { - instrumentation.record(uri, offset, 'checkReturn', - new InstrumentationValueForType(inferredType)); - } + if (instrumentation != null && checkReturn) { + instrumentation.record(uri, expression.fileOffset, 'checkReturn', + new InstrumentationValueForType(inferredType)); } return replacedExpression; } - /// Determines the dispatch category of a [PropertySet]. - void handlePropertySetContravariance(Expression receiver, - Object interfaceMember, PropertySet desugaredSet, Expression expression) { - DispatchCategory callKind; - if (receiver is ThisExpression || receiver == null) { - callKind = DispatchCategory.viaThis; - } else if (interfaceMember == null) { - callKind = DispatchCategory.dynamicDispatch; - } else { - callKind = DispatchCategory.interface; - } - desugaredSet?.dispatchCategory = callKind; - if (instrumentation != null) { - int offset = expression.fileOffset; - switch (callKind) { - case DispatchCategory.dynamicDispatch: - instrumentation.record(uri, offset, 'callKind', - new InstrumentationValueLiteral('dynamic')); - break; - case DispatchCategory.viaThis: - instrumentation.record( - uri, offset, 'callKind', new InstrumentationValueLiteral('this')); - break; - default: - break; - } - } - } - /// Modifies a type as appropriate when inferring a declared variable's type. DartType inferDeclarationType(DartType initializerType) { if (initializerType is BottomType || @@ -1461,62 +1407,28 @@ abstract class TypeInferrerImpl extends TypeInferrer { MethodInvocation desugaredInvocation, Arguments arguments, Expression expression) { - DispatchCategory callKind; - var checkKind = MethodContravarianceCheckKind.none; if (interfaceMember is Field || interfaceMember is Procedure && interfaceMember.kind == ProcedureKind.Getter) { var getType = getCalleeType(interfaceMember, receiverType); if (getType is DynamicType) { - callKind = DispatchCategory.dynamicDispatch; - } else { - callKind = DispatchCategory.closure; - if (receiver is! ThisExpression && receiver != null) { - if (interfaceMember is Field && - interfaceMember.isGenericContravariant) { - checkKind = MethodContravarianceCheckKind.checkGetterReturn; - } else if (interfaceMember is Procedure && - interfaceMember.isGenericContravariant) { - checkKind = MethodContravarianceCheckKind.checkGetterReturn; - } + return MethodContravarianceCheckKind.none; + } + if (receiver != null && receiver is! ThisExpression) { + if ((interfaceMember is Field && + interfaceMember.isGenericContravariant) || + (interfaceMember is Procedure && + interfaceMember.isGenericContravariant)) { + return MethodContravarianceCheckKind.checkGetterReturn; } } - } else if (receiver is ThisExpression || receiver == null) { - callKind = DispatchCategory.viaThis; - } else if (identical(interfaceMember, 'call')) { - callKind = DispatchCategory.closure; - } else if (interfaceMember == null) { - callKind = DispatchCategory.dynamicDispatch; - } else { - callKind = DispatchCategory.interface; - if (interfaceMember is Procedure && - interfaceMember.isGenericContravariant) { - checkKind = MethodContravarianceCheckKind.checkMethodReturn; - } + } else if (receiver != null && + receiver is! ThisExpression && + interfaceMember is Procedure && + interfaceMember.isGenericContravariant) { + return MethodContravarianceCheckKind.checkMethodReturn; } - desugaredInvocation?.dispatchCategory = callKind; - if (instrumentation != null) { - int offset = arguments.fileOffset == -1 - ? expression.fileOffset - : arguments.fileOffset; - switch (callKind) { - case DispatchCategory.closure: - instrumentation.record(uri, offset, 'callKind', - new InstrumentationValueLiteral('closure')); - break; - case DispatchCategory.dynamicDispatch: - instrumentation.record(uri, offset, 'callKind', - new InstrumentationValueLiteral('dynamic')); - break; - case DispatchCategory.viaThis: - instrumentation.record( - uri, offset, 'callKind', new InstrumentationValueLiteral('this')); - break; - default: - break; - } - } - return checkKind; + return MethodContravarianceCheckKind.none; } /// If the given [type] is a [TypeParameterType], resolve it to its bound. diff --git a/pkg/front_end/testcases/runtime_checks/call_kinds.dart b/pkg/front_end/testcases/runtime_checks/call_kinds.dart index 3a11fdf478c..b0006ce4086 100644 --- a/pkg/front_end/testcases/runtime_checks/call_kinds.dart +++ b/pkg/front_end/testcases/runtime_checks/call_kinds.dart @@ -13,16 +13,16 @@ class C { dynamic get h => null; void test() { // Call via this - f /*@callKind=this*/ (); - this.f /*@callKind=this*/ (); + f(); + this.f(); // Get via this, then closure invocation - g /*@callKind=closure*/ (); - this.g /*@callKind=closure*/ (); + g(); + this.g(); // Get via this, then dynamic invocation - h /*@callKind=dynamic*/ (); - this.h /*@callKind=dynamic*/ (); + h(); + this.h(); } } @@ -31,19 +31,19 @@ void test(C c, F f, dynamic d) { c.f(); // Closure invocation - f /*@callKind=closure*/ (); + f(); // Dynamic call - d /*@callKind=dynamic*/ (); + d(); // Dynamic call - d.f /*@callKind=dynamic*/ (); + d.f(); // Get via interface, then closure invocation - c.g /*@callKind=closure*/ (); + c.g(); // Get via interface, then dynamic invocation - c.h /*@callKind=dynamic*/ (); + c.h(); } main() {} diff --git a/pkg/front_end/testcases/runtime_checks/call_kinds_get.dart b/pkg/front_end/testcases/runtime_checks/call_kinds_get.dart index 17701d55a64..ed8556e3b03 100644 --- a/pkg/front_end/testcases/runtime_checks/call_kinds_get.dart +++ b/pkg/front_end/testcases/runtime_checks/call_kinds_get.dart @@ -10,10 +10,10 @@ class C { dynamic y; void test() { // Get via this - var v1 = /*@callKind=this*/ x; - var v2 = this. /*@callKind=this*/ x; - var v3 = /*@callKind=this*/ y; - var v4 = this. /*@callKind=this*/ y; + var v1 = x; + var v2 = this.x; + var v3 = y; + var v4 = this.y; } } @@ -23,7 +23,7 @@ void test(C c, dynamic d) { var v2 = c.y; // Dynamic get - var v3 = d. /*@callKind=dynamic*/ x; + var v3 = d.x; } main() {} diff --git a/pkg/front_end/testcases/runtime_checks/call_kinds_set.dart b/pkg/front_end/testcases/runtime_checks/call_kinds_set.dart index 7b2a695a823..2072ab6b963 100644 --- a/pkg/front_end/testcases/runtime_checks/call_kinds_set.dart +++ b/pkg/front_end/testcases/runtime_checks/call_kinds_set.dart @@ -10,10 +10,10 @@ class C { dynamic y; void test() { // Set via this - /*@callKind=this*/ x = null; - this. /*@callKind=this*/ x = null; - /*@callKind=this*/ y = null; - this. /*@callKind=this*/ y = null; + x = null; + this.x = null; + y = null; + this.y = null; } } @@ -23,7 +23,7 @@ void test(C c, dynamic d) { c.y = null; // Dynamic set - d. /*@callKind=dynamic*/ x = null; + d.x = null; } main() {} diff --git a/pkg/front_end/testcases/runtime_checks/contravariant_field.dart b/pkg/front_end/testcases/runtime_checks/contravariant_field.dart index 73392ad9eff..c7309014b14 100644 --- a/pkg/front_end/testcases/runtime_checks/contravariant_field.dart +++ b/pkg/front_end/testcases/runtime_checks/contravariant_field.dart @@ -10,7 +10,7 @@ typedef void F(T x); class C { F /*@genericContravariant=true*/ y; void f() { - var x = this. /*@callKind=this*/ y; + var x = this.y; } } diff --git a/pkg/front_end/testcases/runtime_checks/contravariant_generic_return.dart b/pkg/front_end/testcases/runtime_checks/contravariant_generic_return.dart index 2909fad025f..12df74a6f7f 100644 --- a/pkg/front_end/testcases/runtime_checks/contravariant_generic_return.dart +++ b/pkg/front_end/testcases/runtime_checks/contravariant_generic_return.dart @@ -10,19 +10,19 @@ typedef void F(T x); class C { F /*@genericContravariant=true*/ f1() {} List> /*@genericContravariant=true*/ f2() { - return [this.f1 /*@callKind=this*/ ()]; + return [this.f1()]; } } void g1(C c) { var x = c.f1 /*@checkReturn=(num) -> void*/ (); print('hello'); - x /*@callKind=closure*/ (1.5); + x(1.5); } void g2(C c) { F x = c.f1 /*@checkReturn=(num) -> void*/ (); - x /*@callKind=closure*/ (1); + x(1); } void g3(C c) { diff --git a/pkg/front_end/testcases/runtime_checks/contravariant_generic_return_null_aware.dart b/pkg/front_end/testcases/runtime_checks/contravariant_generic_return_null_aware.dart index 1a307942d4b..0531ccfa3a7 100644 --- a/pkg/front_end/testcases/runtime_checks/contravariant_generic_return_null_aware.dart +++ b/pkg/front_end/testcases/runtime_checks/contravariant_generic_return_null_aware.dart @@ -10,19 +10,19 @@ typedef void F(T x); class C { F /*@genericContravariant=true*/ f1() {} List> /*@genericContravariant=true*/ f2() { - return [this?.f1 /*@callKind=this*/ ()]; + return [this?.f1()]; } } void g1(C c) { var x = c?.f1 /*@checkReturn=(num) -> void*/ (); print('hello'); - x /*@callKind=closure*/ (1.5); + x(1.5); } void g2(C c) { F x = c?.f1 /*@checkReturn=(num) -> void*/ (); - x /*@callKind=closure*/ (1); + x(1); } void g3(C c) { diff --git a/pkg/front_end/testcases/runtime_checks/contravariant_generic_return_tear_off.dart b/pkg/front_end/testcases/runtime_checks/contravariant_generic_return_tear_off.dart index 18a5a6c8269..e0de24f5922 100644 --- a/pkg/front_end/testcases/runtime_checks/contravariant_generic_return_tear_off.dart +++ b/pkg/front_end/testcases/runtime_checks/contravariant_generic_return_tear_off.dart @@ -11,7 +11,7 @@ typedef F G(); class C { F /*@genericContravariant=true*/ _x; C(this._x); - F /*@genericContravariant=true*/ f() => /*@callKind=this*/ _x; + F /*@genericContravariant=true*/ f() => _x; } G g(C c) { diff --git a/pkg/front_end/testcases/runtime_checks/contravariant_getter.dart b/pkg/front_end/testcases/runtime_checks/contravariant_getter.dart index fd31eb28298..cebae23a7ca 100644 --- a/pkg/front_end/testcases/runtime_checks/contravariant_getter.dart +++ b/pkg/front_end/testcases/runtime_checks/contravariant_getter.dart @@ -10,12 +10,12 @@ typedef void F(T x); class C { F /*@genericContravariant=true*/ y; void f(T /*@covariance=genericInterface, genericImpl*/ value) { - this.y /*@callKind=closure*/ (value); + this.y(value); } } void g(C c) { - c.y /*@checkGetterReturn=(num) -> void*/ /*@callKind=closure*/ (1.5); + c.y /*@checkGetterReturn=(num) -> void*/ (1.5); } void main() {} diff --git a/pkg/front_end/testcases/runtime_checks/contravariant_getter_return.dart b/pkg/front_end/testcases/runtime_checks/contravariant_getter_return.dart index cd22b0e5800..9f1f536be7a 100644 --- a/pkg/front_end/testcases/runtime_checks/contravariant_getter_return.dart +++ b/pkg/front_end/testcases/runtime_checks/contravariant_getter_return.dart @@ -10,19 +10,19 @@ typedef void F(T x); class C { F get /*@genericContravariant=true*/ f1 => null; List> get /*@genericContravariant=true*/ f2 { - return [this. /*@callKind=this*/ f1]; + return [this.f1]; } } void g1(C c) { var x = c. /*@checkReturn=(num) -> void*/ f1; print('hello'); - x /*@callKind=closure*/ (1.5); + x(1.5); } void g2(C c) { F x = c. /*@checkReturn=(num) -> void*/ f1; - x /*@callKind=closure*/ (1); + x(1); } void g3(C c) { diff --git a/pkg/front_end/testcases/runtime_checks/contravariant_getter_return_null_aware.dart b/pkg/front_end/testcases/runtime_checks/contravariant_getter_return_null_aware.dart index 183818d7ace..546563d2c04 100644 --- a/pkg/front_end/testcases/runtime_checks/contravariant_getter_return_null_aware.dart +++ b/pkg/front_end/testcases/runtime_checks/contravariant_getter_return_null_aware.dart @@ -10,19 +10,19 @@ typedef void F(T x); class C { F get /*@genericContravariant=true*/ f1 => null; List> get /*@genericContravariant=true*/ f2 { - return [this?. /*@callKind=this*/ f1]; + return [this?.f1]; } } void g1(C c) { var x = c?. /*@checkReturn=(num) -> void*/ f1; print('hello'); - x /*@callKind=closure*/ (1.5); + x(1.5); } void g2(C c) { F x = c?. /*@checkReturn=(num) -> void*/ f1; - x /*@callKind=closure*/ (1); + x(1); } void g3(C c) { diff --git a/pkg/front_end/testcases/runtime_checks/covariant_generic_method_type_parameter.dart b/pkg/front_end/testcases/runtime_checks/covariant_generic_method_type_parameter.dart index 4c737198cc0..c3749e65cef 100644 --- a/pkg/front_end/testcases/runtime_checks/covariant_generic_method_type_parameter.dart +++ b/pkg/front_end/testcases/runtime_checks/covariant_generic_method_type_parameter.dart @@ -8,7 +8,7 @@ library test; class C { void f< /*@covariance=genericInterface, genericImpl*/ U extends T>(U x) {} void g1< /*@covariance=genericInterface, genericImpl*/ U extends T>() { - this.f /*@callKind=this*/ (1.5); + this.f(1.5); } } diff --git a/pkg/front_end/testcases/runtime_checks/covariant_generic_method_type_parameter.dart.strong.expect b/pkg/front_end/testcases/runtime_checks/covariant_generic_method_type_parameter.dart.strong.expect index 2c32b1942f6..a0a99976dd1 100644 --- a/pkg/front_end/testcases/runtime_checks/covariant_generic_method_type_parameter.dart.strong.expect +++ b/pkg/front_end/testcases/runtime_checks/covariant_generic_method_type_parameter.dart.strong.expect @@ -8,10 +8,10 @@ class C extends core::Object { ; method f(self::C::f::U x) → void {} method g1() → void { - this.{self::C::f}(let final dynamic #t1 = 1.5 in let dynamic _ = null in invalid-expression "pkg/front_end/testcases/runtime_checks/covariant_generic_method_type_parameter.dart:11:35: Error: A value of type 'dart.core::double' can't be assigned to a variable of type 'test::C::g1::U'. + this.{self::C::f}(let final dynamic #t1 = 1.5 in let dynamic _ = null in invalid-expression "pkg/front_end/testcases/runtime_checks/covariant_generic_method_type_parameter.dart:11:15: Error: A value of type 'dart.core::double' can't be assigned to a variable of type 'test::C::g1::U'. Try changing the type of the left hand side, or casting the right hand side to 'test::C::g1::U'. - this.f /*@callKind=this*/ (1.5); - ^"); + this.f(1.5); + ^"); } } static method g2(self::C c) → void { diff --git a/pkg/front_end/testcases/runtime_checks/covariant_generic_method_type_parameter.dart.strong.transformed.expect b/pkg/front_end/testcases/runtime_checks/covariant_generic_method_type_parameter.dart.strong.transformed.expect index f17aa3602e4..087b7a07176 100644 --- a/pkg/front_end/testcases/runtime_checks/covariant_generic_method_type_parameter.dart.strong.transformed.expect +++ b/pkg/front_end/testcases/runtime_checks/covariant_generic_method_type_parameter.dart.strong.transformed.expect @@ -8,10 +8,10 @@ class C extends core::Object { ; method f(self::C::f::U x) → void {} method g1() → void { - this.{self::C::f}(let final core::double #t1 = 1.5 in let _ = null in invalid-expression "pkg/front_end/testcases/runtime_checks/covariant_generic_method_type_parameter.dart:11:35: Error: A value of type 'dart.core::double' can't be assigned to a variable of type 'test::C::g1::U'. + this.{self::C::f}(let final core::double #t1 = 1.5 in let _ = null in invalid-expression "pkg/front_end/testcases/runtime_checks/covariant_generic_method_type_parameter.dart:11:15: Error: A value of type 'dart.core::double' can't be assigned to a variable of type 'test::C::g1::U'. Try changing the type of the left hand side, or casting the right hand side to 'test::C::g1::U'. - this.f /*@callKind=this*/ (1.5); - ^"); + this.f(1.5); + ^"); } } static method g2(self::C c) → void { diff --git a/pkg/front_end/testcases/runtime_checks/covariant_generic_parameter_tear_off.dart b/pkg/front_end/testcases/runtime_checks/covariant_generic_parameter_tear_off.dart index 7a326e82664..4c4138d178c 100644 --- a/pkg/front_end/testcases/runtime_checks/covariant_generic_parameter_tear_off.dart +++ b/pkg/front_end/testcases/runtime_checks/covariant_generic_parameter_tear_off.dart @@ -20,7 +20,7 @@ F g1(C c) { void g2(C c, Object x) { F f = g1(c) as F; - f /*@callKind=closure*/ (x); + f(x); } G, num> g3(C c) { @@ -29,7 +29,7 @@ G, num> g3(C c) { void test() { var x = g1(new C()); - x /*@callKind=closure*/ (1.5); + x(1.5); g3(new C()); } diff --git a/pkg/front_end/testcases/runtime_checks/covariant_setter.dart b/pkg/front_end/testcases/runtime_checks/covariant_setter.dart index bd9c2890d1c..219d7151d78 100644 --- a/pkg/front_end/testcases/runtime_checks/covariant_setter.dart +++ b/pkg/front_end/testcases/runtime_checks/covariant_setter.dart @@ -11,8 +11,8 @@ class C { T /*@covariance=genericInterface, genericImpl*/ x; void set y(T /*@covariance=genericInterface, genericImpl*/ value) {} void f(T /*@covariance=genericInterface, genericImpl*/ value) { - this. /*@callKind=this*/ x = value; - this. /*@callKind=this*/ y = value; + this.x = value; + this.y = value; } } diff --git a/pkg/front_end/testcases/runtime_checks/dynamic_invocation.dart b/pkg/front_end/testcases/runtime_checks/dynamic_invocation.dart index 79e90e89510..e8d1ea9cd61 100644 --- a/pkg/front_end/testcases/runtime_checks/dynamic_invocation.dart +++ b/pkg/front_end/testcases/runtime_checks/dynamic_invocation.dart @@ -15,11 +15,11 @@ class D extends C { } void g1(dynamic d) { - d.f1 /*@callKind=dynamic*/ (1.5); + d.f1(1.5); } void g2(dynamic d) { - d.f2 /*@callKind=dynamic*/ (1.5); + d.f2(1.5); } void test() { diff --git a/pkg/front_end/testcases/runtime_checks/dynamic_invocation_generic.dart b/pkg/front_end/testcases/runtime_checks/dynamic_invocation_generic.dart index 5da529b6623..803cd004317 100644 --- a/pkg/front_end/testcases/runtime_checks/dynamic_invocation_generic.dart +++ b/pkg/front_end/testcases/runtime_checks/dynamic_invocation_generic.dart @@ -10,11 +10,11 @@ class C { } void g1(dynamic d) { - d.f /*@callKind=dynamic*/ (1.5); + d.f(1.5); } void g2(dynamic d) { - d.f /*@callKind=dynamic*/ (1.5); + d.f(1.5); } void test() { diff --git a/pkg/front_end/testcases/runtime_checks/dynamic_invocation_of_getter.dart b/pkg/front_end/testcases/runtime_checks/dynamic_invocation_of_getter.dart index 0cd7fbe2e8e..7c7fe48161b 100644 --- a/pkg/front_end/testcases/runtime_checks/dynamic_invocation_of_getter.dart +++ b/pkg/front_end/testcases/runtime_checks/dynamic_invocation_of_getter.dart @@ -11,7 +11,7 @@ class C { } void g(C c) { - c.f /*@callKind=dynamic*/ (1.5); + c.f(1.5); } void h(int i) {} diff --git a/pkg/front_end/testcases/runtime_checks/forwarding_stub_with_default_values.dart b/pkg/front_end/testcases/runtime_checks/forwarding_stub_with_default_values.dart index 6adf6613509..89615d886b1 100644 --- a/pkg/front_end/testcases/runtime_checks/forwarding_stub_with_default_values.dart +++ b/pkg/front_end/testcases/runtime_checks/forwarding_stub_with_default_values.dart @@ -8,16 +8,16 @@ library test; class B { Object _x; void f([num x = 10]) { - /*@callKind=this*/ _x = x; + _x = x; } void g({num x = 20}) { - /*@callKind=this*/ _x = x; + _x = x; } void check(Object expectedValue) { - if (/*@callKind=this*/ _x != expectedValue) { - throw 'Expected _x == $expectedValue; got ${/*@callKind=this*/_x}'; + if (_x != expectedValue) { + throw 'Expected _x == $expectedValue; got ${_x}'; } } } diff --git a/pkg/front_end/testcases/runtime_checks_new/call_through_this.dart b/pkg/front_end/testcases/runtime_checks_new/call_through_this.dart index 17066cbfff1..4f773784caf 100644 --- a/pkg/front_end/testcases/runtime_checks_new/call_through_this.dart +++ b/pkg/front_end/testcases/runtime_checks_new/call_through_this.dart @@ -10,11 +10,11 @@ typedef F(T x); class C { void f(T /*@covariance=genericInterface, genericImpl*/ x) {} void g1(T /*@covariance=genericInterface, genericImpl*/ x) { - this.f /*@callKind=this*/ (x); + this.f(x); } void g2(T /*@covariance=genericInterface, genericImpl*/ x) { - f /*@callKind=this*/ (x); + f(x); } void g3(C /*@covariance=genericInterface, genericImpl*/ c, @@ -22,7 +22,7 @@ class C { c.f(x); } - F /*@genericContravariant=true*/ g4() => this. /*@callKind=this*/ f; + F /*@genericContravariant=true*/ g4() => this.f; } class @@ -43,7 +43,7 @@ class /*@forwardingStub=abstract void g1(covariance=(genericImpl) num x)*/ test() { var x = new D().g4() as F; - x /*@callKind=closure*/ ('hi'); + x('hi'); new E().g1(1.5); } diff --git a/pkg/front_end/testcases/runtime_checks_new/contravariant_generic_return_with_compound_assign_implicit_downcast.dart b/pkg/front_end/testcases/runtime_checks_new/contravariant_generic_return_with_compound_assign_implicit_downcast.dart index 5ac5bbb3d4e..ea84715ad40 100644 --- a/pkg/front_end/testcases/runtime_checks_new/contravariant_generic_return_with_compound_assign_implicit_downcast.dart +++ b/pkg/front_end/testcases/runtime_checks_new/contravariant_generic_return_with_compound_assign_implicit_downcast.dart @@ -7,7 +7,7 @@ library test; void expectTypeError(void callback()) { try { - callback /*@callKind=closure*/ (); + callback(); throw 'Expected TypeError, did not occur'; } on TypeError {} } @@ -21,17 +21,17 @@ void expect(Object value, Object expected) { class C { C(this.plusResult); final num Function(T) /*@genericContravariant=true*/ plusResult; - num Function(T) operator /*@genericContravariant=true*/ +( - int i) => /*@callKind=this*/ plusResult; + num Function(T) operator /*@genericContravariant=true*/ +(int i) => + plusResult; } class D { D(this.getValue); final C getValue; - C get value => /*@callKind=this*/ getValue; + C get value => getValue; int Function(int) setValue; void set value(int Function(int) value) { - /*@callKind=this*/ setValue = value; + setValue = value; } } @@ -48,7 +48,7 @@ void main() { // (num)->num D d = new D(new C(numToInt)); d.value /*@checkReturn=(num) -> num*/ += 1; - expect(d.setValue /*@callKind=closure*/ (0), 1); + expect(d.setValue(0), 1); d = new D(new C(numToNum)); expectTypeError(() { d.value /*@checkReturn=(num) -> num*/ += 1; diff --git a/pkg/front_end/testcases/runtime_checks_new/for_in_call_kinds.dart b/pkg/front_end/testcases/runtime_checks_new/for_in_call_kinds.dart index a7ea1ebdd89..fcb5d833c4d 100644 --- a/pkg/front_end/testcases/runtime_checks_new/for_in_call_kinds.dart +++ b/pkg/front_end/testcases/runtime_checks_new/for_in_call_kinds.dart @@ -19,8 +19,8 @@ class C { for (topLevelSetter in []) {} for (staticField in []) {} for (staticSetter in []) {} - for (/*@callKind=this*/ instanceField in []) {} - for (/*@callKind=this*/ instanceSetter in []) {} + for (instanceField in []) {} + for (instanceSetter in []) {} for (localVar in []) {} } } diff --git a/pkg/front_end/testcases/runtime_checks_new/mixin_forwarding_stub_field.dart b/pkg/front_end/testcases/runtime_checks_new/mixin_forwarding_stub_field.dart index 2b594d75edc..17749bb7854 100644 --- a/pkg/front_end/testcases/runtime_checks_new/mixin_forwarding_stub_field.dart +++ b/pkg/front_end/testcases/runtime_checks_new/mixin_forwarding_stub_field.dart @@ -7,7 +7,7 @@ library test; void expectTypeError(void callback()) { try { - callback /*@callKind=closure*/ (); + callback(); throw 'Expected TypeError, did not occur'; } on TypeError {} } diff --git a/pkg/front_end/testcases/runtime_checks_new/mixin_forwarding_stub_getter.dart b/pkg/front_end/testcases/runtime_checks_new/mixin_forwarding_stub_getter.dart index dca4ecae7eb..a1739c50601 100644 --- a/pkg/front_end/testcases/runtime_checks_new/mixin_forwarding_stub_getter.dart +++ b/pkg/front_end/testcases/runtime_checks_new/mixin_forwarding_stub_getter.dart @@ -9,7 +9,7 @@ typedef void F(T t); void expectTypeError(void callback()) { try { - callback /*@callKind=closure*/ (); + callback(); throw 'Expected TypeError, did not occur'; } on TypeError {} } @@ -36,7 +36,7 @@ abstract class I { } abstract class M { - T get x => f /*@callKind=this*/ (); + T get x => f(); void set x(Object value) { throw 'Should not be reached'; } @@ -64,7 +64,7 @@ void test(I iObj, I iInt) { }); // iInt.x is expected to return type (int) -> void, and it does. var x = iInt. /*@checkReturn=(int) -> void*/ x; - x /*@callKind=closure*/ (1); + x(1); } void main() { diff --git a/pkg/front_end/testcases/runtime_checks_new/mixin_forwarding_stub_setter.dart b/pkg/front_end/testcases/runtime_checks_new/mixin_forwarding_stub_setter.dart index 3c909f00d3e..68558fd1056 100644 --- a/pkg/front_end/testcases/runtime_checks_new/mixin_forwarding_stub_setter.dart +++ b/pkg/front_end/testcases/runtime_checks_new/mixin_forwarding_stub_setter.dart @@ -7,7 +7,7 @@ library test; void expectTypeError(void callback()) { try { - callback /*@callKind=closure*/ (); + callback(); throw 'Expected TypeError, did not occur'; } on TypeError {} } diff --git a/pkg/front_end/testcases/runtime_checks_new/stub_checked_via_target.dart b/pkg/front_end/testcases/runtime_checks_new/stub_checked_via_target.dart index 98ad30fee41..0a8e34b9fe9 100644 --- a/pkg/front_end/testcases/runtime_checks_new/stub_checked_via_target.dart +++ b/pkg/front_end/testcases/runtime_checks_new/stub_checked_via_target.dart @@ -7,7 +7,7 @@ library test; void expectTypeError(void callback()) { try { - callback /*@callKind=closure*/ (); + callback(); throw 'Expected TypeError, did not occur'; } on TypeError {} } diff --git a/pkg/kernel/binary.md b/pkg/kernel/binary.md index 28063885f6d..0cfe66148d8 100644 --- a/pkg/kernel/binary.md +++ b/pkg/kernel/binary.md @@ -515,7 +515,6 @@ type SpecializedVariableSet extends Expression { type PropertyGet extends Expression { Byte tag = 22; FileOffset fileOffset; - Byte flags (dispatchCategoryLowBit, dispatchCategoryHighBit); Expression receiver; Name name; MemberReference interfaceTarget; // May be NullReference. @@ -524,7 +523,6 @@ type PropertyGet extends Expression { type PropertySet extends Expression { Byte tag = 23; FileOffset fileOffset; - Byte flags (dispatchCategoryLowBit, dispatchCategoryHighBit); Expression receiver; Name name; Expression value; @@ -549,7 +547,6 @@ type SuperPropertySet extends Expression { type DirectPropertyGet extends Expression { Byte tag = 15; // Note: tag is out of order FileOffset fileOffset; - Byte flags (dispatchCategoryLowBit, dispatchCategoryHighBit); Expression receiver; MemberReference target; } @@ -557,7 +554,6 @@ type DirectPropertyGet extends Expression { type DirectPropertySet extends Expression { Byte tag = 16; // Note: tag is out of order FileOffset fileOffset; - Byte flags (dispatchCategoryLowBit, dispatchCategoryHighBit); Expression receiver; MemberReference target; Expression value; @@ -593,7 +589,6 @@ type NamedExpression { type MethodInvocation extends Expression { Byte tag = 28; FileOffset fileOffset; - Byte flags (dispatchCategoryLowBit, dispatchCategoryHighBit); Expression receiver; Name name; Arguments arguments; @@ -611,7 +606,6 @@ type SuperMethodInvocation extends Expression { type DirectMethodInvocation extends Expression { Byte tag = 17; // Note: tag is out of order FileOffset fileOffset; - Byte flags (dispatchCategoryLowBit, dispatchCategoryHighBit); Expression receiver; MemberReference target; Arguments arguments; diff --git a/pkg/kernel/lib/ast.dart b/pkg/kernel/lib/ast.dart index dcb6c66284f..e50b62db920 100644 --- a/pkg/kernel/lib/ast.dart +++ b/pkg/kernel/lib/ast.dart @@ -2185,7 +2185,6 @@ class PropertyGet extends Expression { Expression receiver; @coq Name name; - int flags = 0; @nocoq Reference interfaceTargetReference; @@ -2196,19 +2195,6 @@ class PropertyGet extends Expression { PropertyGet.byReference( this.receiver, this.name, this.interfaceTargetReference) { receiver?.parent = this; - this.dispatchCategory = DispatchCategory.dynamicDispatch; - } - - // Must match serialized bit positions - static const int ShiftDispatchCategory = 0; - static const int FlagDispatchCategory = 3 << ShiftDispatchCategory; - - DispatchCategory get dispatchCategory => DispatchCategory - .values[(flags & FlagDispatchCategory) >> ShiftDispatchCategory]; - - void set dispatchCategory(DispatchCategory value) { - flags = (flags & ~FlagDispatchCategory) | - (value.index << ShiftDispatchCategory); } Member get interfaceTarget => interfaceTargetReference?.asMember; @@ -2261,7 +2247,6 @@ class PropertySet extends Expression { Expression receiver; Name name; Expression value; - int flags = 0; Reference interfaceTargetReference; @@ -2274,19 +2259,6 @@ class PropertySet extends Expression { this.receiver, this.name, this.value, this.interfaceTargetReference) { receiver?.parent = this; value?.parent = this; - this.dispatchCategory = DispatchCategory.dynamicDispatch; - } - - // Must match serialized bit positions. - static const int ShiftDispatchCategory = 0; - static const int FlagDispatchCategory = 3 << ShiftDispatchCategory; - - DispatchCategory get dispatchCategory => DispatchCategory - .values[(flags & FlagDispatchCategory) >> ShiftDispatchCategory]; - - void set dispatchCategory(DispatchCategory value) { - flags = (flags & ~FlagDispatchCategory) | - (value.index << ShiftDispatchCategory); } Member get interfaceTarget => interfaceTargetReference?.asMember; @@ -2322,26 +2294,12 @@ class PropertySet extends Expression { class DirectPropertyGet extends Expression { Expression receiver; Reference targetReference; - int flags = 0; DirectPropertyGet(Expression receiver, Member target) : this.byReference(receiver, getMemberReference(target)); DirectPropertyGet.byReference(this.receiver, this.targetReference) { receiver?.parent = this; - this.dispatchCategory = DispatchCategory.dynamicDispatch; - } - - // Must match serialized bit positions - static const int ShiftDispatchCategory = 0; - static const int FlagDispatchCategory = 3 << ShiftDispatchCategory; - - DispatchCategory get dispatchCategory => DispatchCategory - .values[(flags & FlagDispatchCategory) >> ShiftDispatchCategory]; - - void set dispatchCategory(DispatchCategory value) { - flags = (flags & ~FlagDispatchCategory) | - (value.index << ShiftDispatchCategory); } Member get target => targetReference?.asMember; @@ -2381,7 +2339,6 @@ class DirectPropertySet extends Expression { Expression receiver; Reference targetReference; Expression value; - int flags = 0; DirectPropertySet(Expression receiver, Member target, Expression value) : this.byReference(receiver, getMemberReference(target), value); @@ -2392,18 +2349,6 @@ class DirectPropertySet extends Expression { value?.parent = this; } - // Must match serialized bit positions - static const int ShiftDispatchCategory = 0; - static const int FlagDispatchCategory = 3 << ShiftDispatchCategory; - - DispatchCategory get dispatchCategory => DispatchCategory - .values[(flags & FlagDispatchCategory) >> ShiftDispatchCategory]; - - void set dispatchCategory(DispatchCategory value) { - flags = (flags & ~FlagDispatchCategory) | - (value.index << ShiftDispatchCategory); - } - Member get target => targetReference?.asMember; void set target(Member target) { @@ -2438,7 +2383,6 @@ class DirectMethodInvocation extends InvocationExpression { Expression receiver; Reference targetReference; Arguments arguments; - int flags = 0; DirectMethodInvocation( Expression receiver, Procedure target, Arguments arguments) @@ -2448,19 +2392,6 @@ class DirectMethodInvocation extends InvocationExpression { this.receiver, this.targetReference, this.arguments) { receiver?.parent = this; arguments?.parent = this; - this.dispatchCategory = DispatchCategory.dynamicDispatch; - } - - // Must match serialized bit positions - static const int ShiftDispatchCategory = 0; - static const int FlagDispatchCategory = 3 << ShiftDispatchCategory; - - DispatchCategory get dispatchCategory => DispatchCategory - .values[(flags & FlagDispatchCategory) >> ShiftDispatchCategory]; - - void set dispatchCategory(DispatchCategory value) { - flags = (flags & ~FlagDispatchCategory) | - (value.index << ShiftDispatchCategory); } Procedure get target => targetReference?.asProcedure; @@ -2516,8 +2447,6 @@ class SuperPropertyGet extends Expression { Reference interfaceTargetReference; - DispatchCategory get dispatchCategory => DispatchCategory.viaThis; - SuperPropertyGet(Name name, [Member interfaceTarget]) : this.byReference(name, getMemberReference(interfaceTarget)); @@ -2740,7 +2669,6 @@ class MethodInvocation extends InvocationExpression { Expression receiver; Name name; Arguments arguments; - int flags = 0; Reference interfaceTargetReference; @@ -2753,19 +2681,6 @@ class MethodInvocation extends InvocationExpression { this.receiver, this.name, this.arguments, this.interfaceTargetReference) { receiver?.parent = this; arguments?.parent = this; - this.dispatchCategory = DispatchCategory.dynamicDispatch; - } - - // Must match serialized bit positions - static const int ShiftDispatchCategory = 0; - static const int FlagDispatchCategory = 3 << ShiftDispatchCategory; - - DispatchCategory get dispatchCategory => DispatchCategory - .values[(flags & FlagDispatchCategory) >> ShiftDispatchCategory]; - - void set dispatchCategory(DispatchCategory value) { - flags = (flags & ~FlagDispatchCategory) | - (value.index << ShiftDispatchCategory); } Member get interfaceTarget => interfaceTargetReference?.asMember; @@ -2841,7 +2756,6 @@ class MethodInvocation extends InvocationExpression { class SuperMethodInvocation extends InvocationExpression { Name name; Arguments arguments; - DispatchCategory get dispatchCategory => DispatchCategory.viaThis; Reference interfaceTargetReference; @@ -4404,96 +4318,6 @@ class YieldStatement extends Statement { } } -/// Categorization of a call site indicating its effect on type guarantees. -enum DispatchCategory { - /// This call site binds to its callee through a specific interface. - /// - /// The front end guarantees that the target of the call exists, has the - /// correct arity, and accepts all of the supplied named parameters. Further, - /// it guarantees that the number of type parameters supplied matches the - /// number of type parameters expected by the target of the call. - /// - /// Due to parameter covariance, it is not necessarily guaranteed that the - /// actual values of parameters will match the declared types of those - /// parameters in the method actually being called. A runtime type check is - /// required for any parameter meeting one of the following conditions: - /// - /// - The parameter in the interface target is tagged with - /// `isGenericCovariantInterface`, and the corresponding parameter in the - /// method actually being called is tagged with `isGenericCovariantImpl`. - /// - /// - The parameter in the method actually being called is tagged with - /// `isCovariant`. - /// - /// Note: type parameters of generic methods require similar checks; the - /// flags `isGenericCovariantInterface` and `isGenericCovariantImpl` are found - /// in [TypeParameter], and the implementation must check that the actual - /// type is a subtype of the type parameter bound declared in the actual - /// method being called. For type parameter checks, there is no `isCovariant` - /// tag. - /// - /// Note: if the interface target or the method actually being called is a - /// field, then the tags `isGenericCovariantInterface`, - /// `isGenericCovariantImpl`, and `isCovariant` are found in [Field]. - interface, - - /// This call site binds to its callee via a call on `this`. - /// - /// Similar to [interface], however the target of the call is a method on - /// `this` or `super`, therefore all of the class's type parameters are known - /// to match exactly. - /// - /// Due to parameter covariance, it is not necessarily guaranteed that the - /// actual values of parameters will match the declared types of those - /// parameters in the method actually being called. A runtime type check is - /// required for any parameter meeting one of the following condition: - /// - /// - The parameter in the method actually being called is tagged with - /// `isCovariant`. - /// - /// Note: type parameters of generic methods do not require a check when the - /// call is via `this`. - /// - /// Note: if the interface target or the method actually being called is a - /// field, then the tag `isCovariant` is found in [Field]. - viaThis, - - /// This call site is an invocation of a function object (formed either by a - /// tear off or a function literal). - /// - /// Similar to [interface], however the interface target of the call is not - /// known. - /// - /// Due to parameter covariance, it is not necessarily guaranteed that the - /// actual values of parameters will match the declared types of those - /// parameters in the method actually being called. A runtime type check is - /// required for any parameter meeting one of the following conditions: - /// - /// - The parameter in the method actually being called is tagged with - /// `isGenericCovariantImpl`. - /// - /// - The parameter in the method actually being called is tagged with - /// `isCovariant`. - /// - /// Note: type parameters of generic methods require similar checks; the - /// flag `isGenericCovariantImpl` is found in [TypeParameter], and the - /// implementation must check that the actual type is a subtype of the type - /// parameter bound declared in the actual method being called. For type - /// parameter checks, there is no `isCovariant` tag. - /// - /// Note: if the interface target or the method actually being called is a - /// field, then the tags `isGenericCovariantImpl` and `isCovariant` are found - /// in [Field]. - closure, - - /// The call site is dynamic. - /// - /// The front end makes no guarantees that the target of the call will accept - /// the actual runtime types of the parameters, nor that the target of the - /// call even exists. Everything must be checked at runtime. - dynamicDispatch, -} - /// Declaration of a local variable. /// /// This may occur as a statement, but is also used in several non-statement diff --git a/pkg/kernel/lib/binary/ast_from_binary.dart b/pkg/kernel/lib/binary/ast_from_binary.dart index 97fd9ddb754..ae840c7b528 100644 --- a/pkg/kernel/lib/binary/ast_from_binary.dart +++ b/pkg/kernel/lib/binary/ast_from_binary.dart @@ -1212,18 +1212,14 @@ class BinaryBuilder { ..fileOffset = offset; case Tag.PropertyGet: int offset = readOffset(); - int flags = readByte(); return new PropertyGet.byReference( readExpression(), readName(), readMemberReference(allowNull: true)) - ..fileOffset = offset - ..flags = flags; + ..fileOffset = offset; case Tag.PropertySet: int offset = readOffset(); - int flags = readByte(); return new PropertySet.byReference(readExpression(), readName(), readExpression(), readMemberReference(allowNull: true)) - ..fileOffset = offset - ..flags = flags; + ..fileOffset = offset; case Tag.SuperPropertyGet: int offset = readOffset(); addTransformerFlag(TransformerFlag.superCalls); @@ -1238,18 +1234,14 @@ class BinaryBuilder { ..fileOffset = offset; case Tag.DirectPropertyGet: int offset = readOffset(); - int flags = readByte(); return new DirectPropertyGet.byReference( readExpression(), readMemberReference()) - ..fileOffset = offset - ..flags = flags; + ..fileOffset = offset; case Tag.DirectPropertySet: int offset = readOffset(); - int flags = readByte(); return new DirectPropertySet.byReference( readExpression(), readMemberReference(), readExpression()) - ..fileOffset = offset - ..flags = flags; + ..fileOffset = offset; case Tag.StaticGet: int offset = readOffset(); return new StaticGet.byReference(readMemberReference()) @@ -1261,11 +1253,9 @@ class BinaryBuilder { ..fileOffset = offset; case Tag.MethodInvocation: int offset = readOffset(); - int flags = readByte(); return new MethodInvocation.byReference(readExpression(), readName(), readArguments(), readMemberReference(allowNull: true)) - ..fileOffset = offset - ..flags = flags; + ..fileOffset = offset; case Tag.SuperMethodInvocation: int offset = readOffset(); addTransformerFlag(TransformerFlag.superCalls); @@ -1274,11 +1264,9 @@ class BinaryBuilder { ..fileOffset = offset; case Tag.DirectMethodInvocation: int offset = readOffset(); - int flags = readByte(); return new DirectMethodInvocation.byReference( readExpression(), readMemberReference(), readArguments()) - ..fileOffset = offset - ..flags = flags; + ..fileOffset = offset; case Tag.StaticInvocation: int offset = readOffset(); return new StaticInvocation.byReference( diff --git a/pkg/kernel/lib/binary/ast_to_binary.dart b/pkg/kernel/lib/binary/ast_to_binary.dart index ec689228351..de480d657ba 100644 --- a/pkg/kernel/lib/binary/ast_to_binary.dart +++ b/pkg/kernel/lib/binary/ast_to_binary.dart @@ -1002,7 +1002,6 @@ class BinaryPrinter implements Visitor, BinarySink { void visitPropertyGet(PropertyGet node) { writeByte(Tag.PropertyGet); writeOffset(node.fileOffset); - writeByte(node.flags); writeNode(node.receiver); writeName(node.name); writeReference(node.interfaceTargetReference); @@ -1012,7 +1011,6 @@ class BinaryPrinter implements Visitor, BinarySink { void visitPropertySet(PropertySet node) { writeByte(Tag.PropertySet); writeOffset(node.fileOffset); - writeByte(node.flags); writeNode(node.receiver); writeName(node.name); writeNode(node.value); @@ -1040,7 +1038,6 @@ class BinaryPrinter implements Visitor, BinarySink { void visitDirectPropertyGet(DirectPropertyGet node) { writeByte(Tag.DirectPropertyGet); writeOffset(node.fileOffset); - writeByte(node.flags); writeNode(node.receiver); writeReference(node.targetReference); } @@ -1049,7 +1046,6 @@ class BinaryPrinter implements Visitor, BinarySink { void visitDirectPropertySet(DirectPropertySet node) { writeByte(Tag.DirectPropertySet); writeOffset(node.fileOffset); - writeByte(node.flags); writeNode(node.receiver); writeReference(node.targetReference); writeNode(node.value); @@ -1074,7 +1070,6 @@ class BinaryPrinter implements Visitor, BinarySink { void visitMethodInvocation(MethodInvocation node) { writeByte(Tag.MethodInvocation); writeOffset(node.fileOffset); - writeByte(node.flags); writeNode(node.receiver); writeName(node.name); writeNode(node.arguments); @@ -1094,7 +1089,6 @@ class BinaryPrinter implements Visitor, BinarySink { void visitDirectMethodInvocation(DirectMethodInvocation node) { writeByte(Tag.DirectMethodInvocation); writeOffset(node.fileOffset); - writeByte(node.flags); writeNode(node.receiver); writeReference(node.targetReference); writeNode(node.arguments); diff --git a/pkg/kernel/lib/clone.dart b/pkg/kernel/lib/clone.dart index 9c1db32395f..b70521e4bf8 100644 --- a/pkg/kernel/lib/clone.dart +++ b/pkg/kernel/lib/clone.dart @@ -98,26 +98,22 @@ class CloneVisitor implements TreeVisitor { visitPropertyGet(PropertyGet node) { return new PropertyGet.byReference( - clone(node.receiver), node.name, node.interfaceTargetReference) - ..flags = node.flags; + clone(node.receiver), node.name, node.interfaceTargetReference); } visitPropertySet(PropertySet node) { return new PropertySet.byReference(clone(node.receiver), node.name, - clone(node.value), node.interfaceTargetReference) - ..flags = node.flags; + clone(node.value), node.interfaceTargetReference); } visitDirectPropertyGet(DirectPropertyGet node) { return new DirectPropertyGet.byReference( - clone(node.receiver), node.targetReference) - ..flags = node.flags; + clone(node.receiver), node.targetReference); } visitDirectPropertySet(DirectPropertySet node) { return new DirectPropertySet.byReference( - clone(node.receiver), node.targetReference, clone(node.value)) - ..flags = node.flags; + clone(node.receiver), node.targetReference, clone(node.value)); } visitSuperPropertyGet(SuperPropertyGet node) { @@ -140,14 +136,12 @@ class CloneVisitor implements TreeVisitor { visitMethodInvocation(MethodInvocation node) { return new MethodInvocation.byReference(clone(node.receiver), node.name, - clone(node.arguments), node.interfaceTargetReference) - ..flags = node.flags; + clone(node.arguments), node.interfaceTargetReference); } visitDirectMethodInvocation(DirectMethodInvocation node) { return new DirectMethodInvocation.byReference( - clone(node.receiver), node.targetReference, clone(node.arguments)) - ..flags = node.flags; + clone(node.receiver), node.targetReference, clone(node.arguments)); } visitSuperMethodInvocation(SuperMethodInvocation node) { diff --git a/pkg/vm/lib/transformations/no_dynamic_invocations_annotator.dart b/pkg/vm/lib/transformations/no_dynamic_invocations_annotator.dart index 00e93ff7d90..9806c89f250 100644 --- a/pkg/vm/lib/transformations/no_dynamic_invocations_annotator.dart +++ b/pkg/vm/lib/transformations/no_dynamic_invocations_annotator.dart @@ -168,7 +168,7 @@ class DynamicSelectorsCollector extends RecursiveVisitor { super.visitMethodInvocation(node); Selector selector; - if (node.dispatchCategory == DispatchCategory.dynamicDispatch) { + if (node.interfaceTarget == null) { dynamicSelectors.add(new Selector.doInvoke(node.name)); } else { if (node.receiver is! ThisExpression) { @@ -182,13 +182,9 @@ class DynamicSelectorsCollector extends RecursiveVisitor { super.visitDirectMethodInvocation(node); Selector selector; - if (node.dispatchCategory == DispatchCategory.dynamicDispatch) { - dynamicSelectors.add(selector = new Selector.doInvoke(node.target.name)); - } else { - if (node.receiver is! ThisExpression) { - nonThisSelectors - .add(selector ??= new Selector.doInvoke(node.target.name)); - } + if (node.receiver is! ThisExpression) { + nonThisSelectors + .add(selector ??= new Selector.doInvoke(node.target.name)); } } @@ -197,7 +193,7 @@ class DynamicSelectorsCollector extends RecursiveVisitor { super.visitPropertyGet(node); Selector selector; - if (node.dispatchCategory == DispatchCategory.dynamicDispatch) { + if (node.interfaceTarget == null) { dynamicSelectors.add(selector = new Selector.doGet(node.name)); } else { if (node.receiver is! ThisExpression) { @@ -215,17 +211,13 @@ class DynamicSelectorsCollector extends RecursiveVisitor { visitDirectPropertyGet(DirectPropertyGet node) { super.visitDirectPropertyGet(node); - if (node.dispatchCategory == DispatchCategory.dynamicDispatch) { - dynamicSelectors.add(new Selector.doGet(node.target.name)); - } else { - if (node.receiver is! ThisExpression) { - nonThisSelectors.add(new Selector.doGet(node.target.name)); - } + if (node.receiver is! ThisExpression) { + nonThisSelectors.add(new Selector.doGet(node.target.name)); + } - final target = node.target; - if (target is Procedure && target.kind == ProcedureKind.Method) { - tearOffSelectors.add(new Selector.doInvoke(target.name)); - } + final target = node.target; + if (target is Procedure && target.kind == ProcedureKind.Method) { + tearOffSelectors.add(new Selector.doInvoke(target.name)); } } @@ -234,7 +226,7 @@ class DynamicSelectorsCollector extends RecursiveVisitor { super.visitPropertySet(node); Selector selector; - if (node.dispatchCategory == DispatchCategory.dynamicDispatch) { + if (node.interfaceTarget == null) { dynamicSelectors.add(selector = new Selector.doSet(node.name)); } else { if (node.receiver is! ThisExpression) { @@ -248,12 +240,8 @@ class DynamicSelectorsCollector extends RecursiveVisitor { super.visitDirectPropertySet(node); Selector selector; - if (node.dispatchCategory == DispatchCategory.dynamicDispatch) { - dynamicSelectors.add(selector = new Selector.doSet(node.target.name)); - } else { - if (node.receiver is! ThisExpression) { - nonThisSelectors.add(selector ??= new Selector.doSet(node.target.name)); - } + if (node.receiver is! ThisExpression) { + nonThisSelectors.add(selector ??= new Selector.doSet(node.target.name)); } } } diff --git a/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc b/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc index 2776ee83e45..8a137099010 100644 --- a/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc +++ b/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc @@ -1361,7 +1361,6 @@ void StreamingScopeBuilder::VisitExpression() { } case kPropertyGet: builder_->ReadPosition(); // read position. - builder_->ReadFlags(); // read flags. VisitExpression(); // read receiver. builder_->SkipName(); // read name. // read interface_target_reference. @@ -1369,7 +1368,6 @@ void StreamingScopeBuilder::VisitExpression() { return; case kPropertySet: builder_->ReadPosition(); // read position. - builder_->ReadFlags(); // read flags VisitExpression(); // read receiver. builder_->SkipName(); // read name. VisitExpression(); // read value. @@ -1378,13 +1376,11 @@ void StreamingScopeBuilder::VisitExpression() { return; case kDirectPropertyGet: builder_->ReadPosition(); // read position. - builder_->ReadFlags(); // read flags. VisitExpression(); // read receiver. builder_->SkipCanonicalNameReference(); // read target_reference. return; case kDirectPropertySet: builder_->ReadPosition(); // read position. - builder_->ReadFlags(); // read flags. VisitExpression(); // read receiver. builder_->SkipCanonicalNameReference(); // read target_reference. VisitExpression(); // read value· @@ -1413,7 +1409,6 @@ void StreamingScopeBuilder::VisitExpression() { return; case kMethodInvocation: builder_->ReadPosition(); // read position. - builder_->ReadFlags(); // read flags. VisitExpression(); // read receiver. builder_->SkipName(); // read name. VisitArguments(); // read arguments. @@ -1422,7 +1417,6 @@ void StreamingScopeBuilder::VisitExpression() { return; case kDirectMethodInvocation: builder_->ReadPosition(); // read position. - builder_->ReadFlags(); // read flags. VisitExpression(); // read receiver. builder_->SkipCanonicalNameReference(); // read target_reference. VisitArguments(); // read arguments. @@ -3027,7 +3021,6 @@ void StreamingConstantEvaluator::EvaluateGetStringLength( void StreamingConstantEvaluator::EvaluatePropertyGet() { const TokenPosition position = builder_->ReadPosition(); // read position. - builder_->ReadFlags(); // read flags. intptr_t expression_offset = builder_->ReaderOffset(); builder_->SkipExpression(); // read receiver. StringIndex name = builder_->ReadNameAsStringIndex(); // read name. @@ -3044,7 +3037,6 @@ void StreamingConstantEvaluator::EvaluatePropertyGet() { void StreamingConstantEvaluator::EvaluateDirectPropertyGet() { TokenPosition position = builder_->ReadPosition(); // read position. - builder_->ReadFlags(); // read flags. intptr_t expression_offset = builder_->ReaderOffset(); builder_->SkipExpression(); // read receiver. NameIndex kernel_name = @@ -3125,7 +3117,6 @@ void StreamingConstantEvaluator::EvaluateStaticGet() { void StreamingConstantEvaluator::EvaluateMethodInvocation() { builder_->ReadPosition(); // read position. - builder_->ReadFlags(); // read flags. // This method call wasn't cached, so receiver et al. isn't cached either. const Instance& receiver = EvaluateExpression(builder_->ReaderOffset(), false); // read receiver. @@ -3152,7 +3143,6 @@ void StreamingConstantEvaluator::EvaluateMethodInvocation() { void StreamingConstantEvaluator::EvaluateDirectMethodInvocation() { builder_->ReadPosition(); // read position. - builder_->ReadFlags(); // read flags. const Instance& receiver = EvaluateExpression(builder_->ReaderOffset(), false); // read receiver. @@ -5665,14 +5655,12 @@ void StreamingFlowGraphBuilder::SkipExpression() { return; case kPropertyGet: ReadPosition(); // read position. - SkipFlags(); // read flags. SkipExpression(); // read receiver. SkipName(); // read name. SkipCanonicalNameReference(); // read interface_target_reference. return; case kPropertySet: ReadPosition(); // read position. - SkipFlags(); // read flags SkipExpression(); // read receiver. SkipName(); // read name. SkipExpression(); // read value. @@ -5691,13 +5679,11 @@ void StreamingFlowGraphBuilder::SkipExpression() { return; case kDirectPropertyGet: ReadPosition(); // read position. - SkipFlags(); // read flags. SkipExpression(); // read receiver. SkipCanonicalNameReference(); // read target_reference. return; case kDirectPropertySet: ReadPosition(); // read position. - SkipFlags(); // read flags. SkipExpression(); // read receiver. SkipCanonicalNameReference(); // read target_reference. SkipExpression(); // read value· @@ -5713,7 +5699,6 @@ void StreamingFlowGraphBuilder::SkipExpression() { return; case kMethodInvocation: ReadPosition(); // read position. - SkipFlags(); // read flags. SkipExpression(); // read receiver. SkipName(); // read name. SkipArguments(); // read arguments. @@ -5727,7 +5712,6 @@ void StreamingFlowGraphBuilder::SkipExpression() { return; case kDirectMethodInvocation: ReadPosition(); // read position. - SkipFlags(); // read flags. SkipExpression(); // read receiver. SkipCanonicalNameReference(); // read target_reference. SkipArguments(); // read arguments. @@ -6762,8 +6746,6 @@ Fragment StreamingFlowGraphBuilder::BuildPropertyGet(TokenPosition* p) { const InferredTypeMetadata result_type = inferred_type_metadata_helper_.GetInferredType(offset); - ReadFlags(); // read flags - Fragment instructions = BuildExpression(); // read receiver. LocalVariable* receiver = NULL; @@ -6823,8 +6805,6 @@ Fragment StreamingFlowGraphBuilder::BuildPropertySet(TokenPosition* p) { const TokenPosition position = ReadPosition(); // read position. if (p != NULL) *p = position; - ReadFlags(); // skip flags - instructions += BuildExpression(); // read receiver. LocalVariable* receiver = NULL; @@ -7098,8 +7078,6 @@ Fragment StreamingFlowGraphBuilder::BuildDirectPropertyGet(TokenPosition* p) { const InferredTypeMetadata result_type = inferred_type_metadata_helper_.GetInferredType(offset); - ReadFlags(); // read flags. - const Tag receiver_tag = PeekTag(); // peek tag for receiver. Fragment instructions = BuildExpression(); // read receiver. const NameIndex kernel_name = @@ -7149,8 +7127,6 @@ Fragment StreamingFlowGraphBuilder::BuildDirectPropertySet(TokenPosition* p) { const TokenPosition position = ReadPosition(); // read position. if (p != NULL) *p = position; - ReadFlags(); // skip flags. - Fragment instructions(NullConstant()); LocalVariable* value = MakeTemporary(); @@ -7282,8 +7258,6 @@ Fragment StreamingFlowGraphBuilder::BuildMethodInvocation(TokenPosition* p) { const InferredTypeMetadata result_type = inferred_type_metadata_helper_.GetInferredType(offset); - ReadFlags(); // skip flags. - const Tag receiver_tag = PeekTag(); // peek tag for receiver. if (IsNumberLiteral(receiver_tag) && (!optimizing() || constant_evaluator_.IsCached(offset))) { @@ -7458,8 +7432,6 @@ Fragment StreamingFlowGraphBuilder::BuildDirectMethodInvocation( const InferredTypeMetadata result_type = inferred_type_metadata_helper_.GetInferredType(offset); - ReadFlags(); // skip flags. - Tag receiver_tag = PeekTag(); // peek tag for receiver. Fragment instructions; diff --git a/runtime/vm/compiler/frontend/kernel_binary_flowgraph.h b/runtime/vm/compiler/frontend/kernel_binary_flowgraph.h index 6881cc6e5c2..722e9ab5639 100644 --- a/runtime/vm/compiler/frontend/kernel_binary_flowgraph.h +++ b/runtime/vm/compiler/frontend/kernel_binary_flowgraph.h @@ -1093,8 +1093,6 @@ class StreamingFlowGraphBuilder { void ReadUntilFunctionNode(ParsedFunction* set_forwarding_stub = NULL); intptr_t ReadListLength(); - enum DispatchCategory { Interface, ViaThis, Closure, DynamicDispatch }; - void ReportUnexpectedTag(const char* variant, Tag tag); private: