Index: runtime/vm/flow_graph_compiler_ia32.cc |
diff --git a/runtime/vm/flow_graph_compiler_ia32.cc b/runtime/vm/flow_graph_compiler_ia32.cc |
index 8152b3d85d4e99768ea96813cd8b3f215d4c796d..9a59030be138526335488b6f3cabb32f93345138 100644 |
--- a/runtime/vm/flow_graph_compiler_ia32.cc |
+++ b/runtime/vm/flow_graph_compiler_ia32.cc |
@@ -277,7 +277,7 @@ FlowGraphCompiler::GenerateInstantiatedTypeWithArgumentsTest( |
__ Comment("InstantiatedTypeWithArgumentsTest"); |
ASSERT(type.IsInstantiated()); |
const Class& type_class = Class::ZoneHandle(zone(), type.type_class()); |
- ASSERT((type_class.NumTypeArguments() > 0) || type_class.IsSignatureClass()); |
+ ASSERT(type.IsFunctionType() || (type_class.NumTypeArguments() > 0)); |
const Register kInstanceReg = EAX; |
Error& bound_error = Error::Handle(zone()); |
const Type& int_type = Type::Handle(zone(), Type::IntType()); |
@@ -290,15 +290,15 @@ FlowGraphCompiler::GenerateInstantiatedTypeWithArgumentsTest( |
} else { |
__ j(ZERO, is_not_instance_lbl); |
} |
- const intptr_t num_type_args = type_class.NumTypeArguments(); |
- const intptr_t num_type_params = type_class.NumTypeParameters(); |
- const intptr_t from_index = num_type_args - num_type_params; |
- const TypeArguments& type_arguments = |
- TypeArguments::ZoneHandle(zone(), type.arguments()); |
- const bool is_raw_type = type_arguments.IsNull() || |
- type_arguments.IsRaw(from_index, num_type_params); |
- // Signature class is an instantiated parameterized type. |
- if (!type_class.IsSignatureClass()) { |
+ // A function type test requires checking the function signature. |
+ if (!type.IsFunctionType()) { |
+ const intptr_t num_type_args = type_class.NumTypeArguments(); |
+ const intptr_t num_type_params = type_class.NumTypeParameters(); |
+ const intptr_t from_index = num_type_args - num_type_params; |
+ const TypeArguments& type_arguments = |
+ TypeArguments::ZoneHandle(zone(), type.arguments()); |
+ const bool is_raw_type = type_arguments.IsNull() || |
+ type_arguments.IsRaw(from_index, num_type_params); |
if (is_raw_type) { |
const Register kClassIdReg = ECX; |
// dynamic type argument, check only classes. |
@@ -365,6 +365,10 @@ bool FlowGraphCompiler::GenerateInstantiatedTypeNoArgumentsTest( |
Label* is_not_instance_lbl) { |
__ Comment("InstantiatedTypeNoArgumentsTest"); |
ASSERT(type.IsInstantiated()); |
+ if (type.IsFunctionType()) { |
+ // Fallthrough. |
+ return true; |
+ } |
const Class& type_class = Class::Handle(zone(), type.type_class()); |
ASSERT(type_class.NumTypeArguments() == 0); |
@@ -395,14 +399,10 @@ bool FlowGraphCompiler::GenerateInstantiatedTypeNoArgumentsTest( |
__ jmp(is_not_instance_lbl); |
return false; |
} |
- if (type.IsFunctionType()) { |
+ if (type.IsDartFunctionType()) { |
// Check if instance is a closure. |
- const Immediate& raw_null = |
- Immediate(reinterpret_cast<intptr_t>(Object::null())); |
- __ LoadClassById(EDI, kClassIdReg); |
- __ movl(EDI, FieldAddress(EDI, Class::signature_function_offset())); |
- __ cmpl(EDI, raw_null); |
- __ j(NOT_EQUAL, is_instance_lbl); |
+ __ cmpl(kClassIdReg, Immediate(kClosureCid)); |
+ __ j(EQUAL, is_instance_lbl); |
} |
// Custom checking for numbers (Smi, Mint, Bigint and Double). |
// Note that instance is not Smi (checked above). |
@@ -555,10 +555,10 @@ RawSubtypeTestCache* FlowGraphCompiler::GenerateInlineInstanceof( |
} |
if (type.IsInstantiated()) { |
const Class& type_class = Class::ZoneHandle(zone(), type.type_class()); |
- // A class equality check is only applicable with a dst type of a |
- // non-parameterized class, non-signature class, or with a raw dst type of |
+ // A class equality check is only applicable with a dst type (not a |
+ // function type) of a non-parameterized class or with a raw dst type of |
// a parameterized class. |
- if (type_class.IsSignatureClass() || (type_class.NumTypeArguments() > 0)) { |
+ if (type.IsFunctionType() || (type_class.NumTypeArguments() > 0)) { |
return GenerateInstantiatedTypeWithArgumentsTest(token_pos, |
type, |
is_instance_lbl, |