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

Unified Diff: runtime/vm/stub_code_arm64.cc

Issue 2132803002: Megamorphic code cleanup. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 5 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 | « runtime/vm/stub_code_arm.cc ('k') | runtime/vm/stub_code_ia32.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/stub_code_arm64.cc
diff --git a/runtime/vm/stub_code_arm64.cc b/runtime/vm/stub_code_arm64.cc
index 072d5c6b7fc2a76dd6e87403ad71cb47269442a4..997c24684c07bf6de3075d92cb91a254948c27cc 100644
--- a/runtime/vm/stub_code_arm64.cc
+++ b/runtime/vm/stub_code_arm64.cc
@@ -2098,52 +2098,6 @@ void StubCode::GenerateOptimizedIdenticalWithNumberCheckStub(
}
-void StubCode::EmitMegamorphicLookup(Assembler* assembler) {
- __ LoadTaggedClassIdMayBeSmi(R0, R0);
- // R0: class ID of the receiver (smi).
- __ ldr(R2, FieldAddress(R5, MegamorphicCache::buckets_offset()));
- __ ldr(R1, FieldAddress(R5, MegamorphicCache::mask_offset()));
- // R2: cache buckets array.
- // R1: mask.
-
- // Compute the table index.
- ASSERT(MegamorphicCache::kSpreadFactor == 7);
- // Use lsl and sub to multiply with 7 == 8 - 1.
- __ LslImmediate(R3, R0, 3);
- __ sub(R3, R3, Operand(R0));
- // R3: probe.
-
- Label loop, update, load_target_function;
- __ b(&loop);
-
- __ Bind(&update);
- __ add(R3, R3, Operand(Smi::RawValue(1)));
- __ Bind(&loop);
- __ and_(R3, R3, Operand(R1));
- const intptr_t base = Array::data_offset();
- // R3 is smi tagged, but table entries are 16 bytes, so LSL 3.
- __ add(TMP, R2, Operand(R3, LSL, 3));
- __ ldr(R6, FieldAddress(TMP, base));
-
- ASSERT(kIllegalCid == 0);
- __ tst(R6, Operand(R6));
- __ b(&load_target_function, EQ);
- __ CompareRegisters(R6, R0);
- __ b(&update, NE);
-
- __ Bind(&load_target_function);
- // Call the target found in the cache. For a class id match, this is a
- // proper target for the given name and arguments descriptor. If the
- // illegal class id was found, the target is a cache miss handler that can
- // be invoked as a normal Dart function.
- __ add(TMP, R2, Operand(R3, LSL, 3));
- __ ldr(R0, FieldAddress(TMP, base + kWordSize));
- __ ldr(R4, FieldAddress(R5, MegamorphicCache::arguments_descriptor_offset()));
- __ ldr(R1, FieldAddress(R0, Function::entry_point_offset()));
- __ ldr(CODE_REG, FieldAddress(R0, Function::code_offset()));
-}
-
-
// Called from megamorphic calls.
// R0: receiver
// R5: MegamorphicCache (preserved)
@@ -2152,13 +2106,25 @@ void StubCode::EmitMegamorphicLookup(Assembler* assembler) {
// CODE_REG: target Code
// R4: arguments descriptor
void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) {
- __ LoadTaggedClassIdMayBeSmi(R0, R0);
- // R0: class ID of the receiver (smi).
+ // Jump if receiver is a smi.
+ Label smi_case;
+ __ TestImmediate(R0, kSmiTagMask);
+ __ b(&smi_case, EQ);
+
+ // Loads the cid of the object.
+ __ LoadClassId(R0, R0);
+
+ Label cid_loaded;
+ __ Bind(&cid_loaded);
__ ldr(R2, FieldAddress(R5, MegamorphicCache::buckets_offset()));
__ ldr(R1, FieldAddress(R5, MegamorphicCache::mask_offset()));
// R2: cache buckets array.
// R1: mask.
+ // Make the cid into a smi.
+ __ SmiTag(R0);
+ // R0: class ID of the receiver (smi).
+
// Compute the table index.
ASSERT(MegamorphicCache::kSpreadFactor == 7);
// Use lsl and sub to multiply with 7 == 8 - 1.
@@ -2198,6 +2164,11 @@ void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) {
// Try next extry in the table.
__ AddImmediate(R3, R3, Smi::RawValue(1));
__ b(&loop);
+
+ // Load cid for the Smi case.
+ __ Bind(&smi_case);
+ __ LoadImmediate(R0, kSmiCid);
+ __ b(&cid_loaded);
}
« no previous file with comments | « runtime/vm/stub_code_arm.cc ('k') | runtime/vm/stub_code_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698