Chromium Code Reviews| Index: runtime/vm/intermediate_language.cc |
| diff --git a/runtime/vm/intermediate_language.cc b/runtime/vm/intermediate_language.cc |
| index ab7c878e846a2b9d1be3bdb19ac5608f1ed6a5f1..e343eaab4a1e761bf6ed22302260877d06475947 100644 |
| --- a/runtime/vm/intermediate_language.cc |
| +++ b/runtime/vm/intermediate_language.cc |
| @@ -3226,6 +3226,67 @@ void PolymorphicInstanceCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| #endif |
| +RawType* PolymorphicInstanceCallInstr::ComputeRuntimeType( |
| + const ICData& ic_data) { |
| + bool is_string = true; |
| + bool is_integer = true; |
| + bool is_double = true; |
| + |
| + const intptr_t num_checks = ic_data.NumberOfChecks(); |
| + for (intptr_t i = 0; i < num_checks; i++) { |
|
Florian Schneider
2016/10/06 18:03:19
I'd rather use the propagated type of the receiver
Vyacheslav Egorov (Google)
2016/10/24 20:23:03
This is also called from a place where type propag
|
| + const intptr_t cid = ic_data.GetReceiverClassIdAt(i); |
| + is_string = is_string && RawObject::IsStringClassId(cid); |
| + is_integer = is_integer && RawObject::IsIntegerClassId(cid); |
| + is_double = is_double && (cid == kDoubleCid); |
| + } |
| + |
| + if (is_string) { |
| + return Type::StringType(); |
| + } else if (is_integer) { |
| + return Type::IntType(); |
| + } else if (is_double) { |
| + return Type::Double(); |
| + } |
| + |
| + return Type::null(); |
| +} |
| + |
| + |
| +Definition* PolymorphicInstanceCallInstr::Canonicalize(FlowGraph* flow_graph) { |
| + if (!HasSingleRecognizedTarget() || with_checks()) { |
| + return this; |
| + } |
| + |
| + const Function& target = Function::Handle(ic_data().GetTargetAt(0)); |
| + if (target.recognized_kind() == MethodRecognizer::kObjectRuntimeType) { |
| + const AbstractType& type = |
| + AbstractType::Handle(ComputeRuntimeType(ic_data())); |
| + if (!type.IsNull()) { |
| + return flow_graph->GetConstant(type); |
| + } |
| + } |
| + |
| + return this; |
| +} |
| + |
| + |
| +Definition* StaticCallInstr::Canonicalize(FlowGraph* flow_graph) { |
| + if (!FLAG_precompiled_mode) { |
| + return this; |
| + } |
| + |
| + if (function().recognized_kind() == MethodRecognizer::kObjectRuntimeType) { |
| + if (input_use_list() == NULL) { |
| + // This function has only environment uses. In precompiled mode it is |
| + // fine to remove it - because we will never deoptimize. |
| + return flow_graph->constant_dead(); |
| + } |
| + } |
| + |
| + return this; |
| +} |
| + |
| + |
| LocationSummary* StaticCallInstr::MakeLocationSummary(Zone* zone, |
| bool optimizing) const { |
| return MakeCallSummary(zone); |