Index: runtime/vm/flow_graph_compiler_arm64.cc |
diff --git a/runtime/vm/flow_graph_compiler_arm64.cc b/runtime/vm/flow_graph_compiler_arm64.cc |
index 290fa6ad28e3d880378526af3bd79daf941e1c8e..d62a23a3059960a3c784cc5511c0a7be77c02b73 100644 |
--- a/runtime/vm/flow_graph_compiler_arm64.cc |
+++ b/runtime/vm/flow_graph_compiler_arm64.cc |
@@ -1300,7 +1300,29 @@ void FlowGraphCompiler::EmitMegamorphicInstanceCall( |
MegamorphicCacheTable::Lookup(isolate(), name, arguments_descriptor)); |
__ Comment("MegamorphicCall"); |
+ // Load receiver into R0. |
__ LoadFromOffset(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"); |
+ __ tsti(R0, Immediate(kSmiTagMask)); |
+ __ b(&done, EQ); // Is Smi (result is receiver). |
+ |
+ __ CompareClassId(R0, kOneByteStringCid); |
+ __ b(&megamorphic_call, NE); |
+ |
+ // Use R5 (cache for megamorphic call) as scratch. |
+ __ mov(R5, R0); // Preserve receiver in R5, result in R0. |
+ __ ldr(R0, FieldAddress(R0, String::hash_offset())); |
+ __ CompareRegisters(R0, ZR); |
+ __ b(&done, NE); |
+ __ mov(R0, R5); // Restore receiver in R0, |
+ |
+ __ Bind(&megamorphic_call); |
+ __ Comment("Slow case: megamorphic call"); |
+ } |
+ |
__ LoadObject(R5, cache); |
if (FLAG_use_megamorphic_stub) { |
__ BranchLink(*StubCode::MegamorphicLookup_entry()); |
@@ -1309,6 +1331,7 @@ void FlowGraphCompiler::EmitMegamorphicInstanceCall( |
} |
__ blr(R1); |
+ __ Bind(&done); |
RecordSafepoint(locs, slow_path_argument_count); |
const intptr_t deopt_id_after = Thread::ToDeoptAfter(deopt_id); |
if (FLAG_precompiled_mode) { |