Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Unified Diff: runtime/vm/flow_graph_compiler_arm64.cc

Issue 1921893002: Faster code for megamorphic calls fo get:hashCode for Smi and OneByteString (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: sync Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..3a3dad8424b7de9af20ba1c19586f21fc8074873 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.
+
+ __ 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) {

Powered by Google App Engine
This is Rietveld 408576698