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

Unified Diff: runtime/vm/flow_graph_compiler_arm.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
« no previous file with comments | « no previous file | runtime/vm/flow_graph_compiler_arm64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « no previous file | runtime/vm/flow_graph_compiler_arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698