Index: runtime/vm/flow_graph_compiler_arm.cc |
diff --git a/runtime/vm/flow_graph_compiler_arm.cc b/runtime/vm/flow_graph_compiler_arm.cc |
index 787b5139a7dfc4e8770a729a4800949564330b3b..9c5804490349158e7f78429f3944acde2ce93b75 100644 |
--- a/runtime/vm/flow_graph_compiler_arm.cc |
+++ b/runtime/vm/flow_graph_compiler_arm.cc |
@@ -1319,7 +1319,30 @@ void FlowGraphCompiler::EmitMegamorphicInstanceCall( |
MegamorphicCacheTable::Lookup(isolate(), name, arguments_descriptor)); |
__ Comment("MegamorphicCall"); |
+ // Load receiver into R0. |
__ LoadFromOffset(kWord, R0, SP, (argument_count - 1) * kWordSize); |
+ Label done; |
+ if (name.raw() == Symbols::hashCode().raw()) { |
+ Label megamorphic_call; |
+ __ Comment("Inlined get:hashCode for Smi and OneByteString"); |
+ __ tst(R0, Operand(kSmiTagMask)); |
+ __ b(&done, EQ); // Is Smi (result is receiver). |
+ |
+ // Use R9 (cache for megamorphic call) as scratch. |
+ __ CompareClassId(R0, kOneByteStringCid, R9); |
+ __ b(&megamorphic_call, NE); |
+ |
+ __ mov(R9, Operand(R0)); // Preserve receiver in R9. |
+ __ ldr(R0, FieldAddress(R0, String::hash_offset())); |
+ ASSERT(Smi::New(0) == 0); |
+ __ cmp(R0, Operand(0)); |
+ |
+ __ b(&done, NE); // Return if already computed. |
+ __ mov(R0, Operand(R9)); // Restore receiver in R0. |
+ |
+ __ Bind(&megamorphic_call); |
+ __ Comment("Slow case: megamorphic call"); |
+ } |
__ LoadObject(R9, cache); |
if (FLAG_use_megamorphic_stub) { |
__ BranchLink(*StubCode::MegamorphicLookup_entry()); |
@@ -1328,6 +1351,7 @@ void FlowGraphCompiler::EmitMegamorphicInstanceCall( |
} |
__ blx(R1); |
+ __ Bind(&done); |
RecordSafepoint(locs, slow_path_argument_count); |
const intptr_t deopt_id_after = Thread::ToDeoptAfter(deopt_id); |
if (FLAG_precompiled_mode) { |