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

Unified Diff: runtime/vm/stub_code_arm.cc

Issue 1429303005: Add fast Smi op version of switchable instance calls. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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.h ('k') | runtime/vm/stub_code_arm64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/stub_code_arm.cc
diff --git a/runtime/vm/stub_code_arm.cc b/runtime/vm/stub_code_arm.cc
index 94cf00b33d08a8d5f0183fe5343adce3998d91ae..0ad0ecdc685955f812f46722e1047581dfe4d478 100644
--- a/runtime/vm/stub_code_arm.cc
+++ b/runtime/vm/stub_code_arm.cc
@@ -2044,8 +2044,15 @@ void StubCode::GenerateOptimizedIdenticalWithNumberCheckStub(
}
+// Called from megamorphic calls.
+// R1: receiver
+// R9: MegamorphicCache (preserved)
+// Result:
+// R1: target entry point
+// CODE_REG: target Code
+// R4: arguments descriptor
void StubCode::EmitMegamorphicLookup(Assembler* assembler) {
- __ LoadTaggedClassIdMayBeSmi(R0, R0);
+ __ LoadTaggedClassIdMayBeSmi(R0, R1);
// R0: receiver cid as Smi.
__ ldr(R4, FieldAddress(R9, MegamorphicCache::arguments_descriptor_offset()));
__ ldr(R2, FieldAddress(R9, MegamorphicCache::buckets_offset()));
@@ -2085,13 +2092,6 @@ void StubCode::EmitMegamorphicLookup(Assembler* assembler) {
}
-// Called from megamorphic calls.
-// R0: receiver
-// R9: MegamorphicCache (preserved)
-// Result:
-// R1: target entry point
-// CODE_REG: target Code
-// R4: arguments descriptor
void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) {
EmitMegamorphicLookup(assembler);
__ Ret();
@@ -2099,34 +2099,75 @@ void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) {
// Called from switchable IC calls.
-// R0: receiver
+// R1: receiver
// R9: ICData (preserved)
// Result:
// R1: target entry point
// CODE_REG: target Code object
// R4: arguments descriptor
-void StubCode::GenerateICLookupStub(Assembler* assembler) {
+static void EmitICLookup(Assembler* assembler,
+ intptr_t args_checked,
+ Token::Kind kind) {
+ if (kind != Token::kILLEGAL) {
+ __ Comment("Fast Smi op");
+ Label not_smi_or_overflow;
+
+ // R1: receiver
+ __ ldr(R2, Address(SP, 0 * kWordSize));
+ // R2: argument
+ __ orr(TMP, R1, Operand(R2));
+ __ tst(TMP, Operand(kSmiTagMask));
+ __ b(&not_smi_or_overflow, NE);
+
+ switch (kind) {
+ case Token::kADD: {
+ __ adds(R0, R1, Operand(R2)); // Adds.
+ __ b(&not_smi_or_overflow, VS); // Branch if overflow.
+ break;
+ }
+ case Token::kSUB: {
+ __ subs(R0, R1, Operand(R2)); // Subtract.
+ __ b(&not_smi_or_overflow, VS); // Branch if overflow.
+ break;
+ }
+ case Token::kEQ: {
+ __ cmp(R1, Operand(R2));
+ __ LoadObject(R0, Bool::True(), EQ);
+ __ LoadObject(R0, Bool::False(), NE);
+ break;
+ }
+ default: UNIMPLEMENTED();
+ }
+ // Return past the call to lookup result.
+ __ add(LR, LR, Operand(Instr::kInstrSize));
+ __ Ret();
+
+ __ Bind(&not_smi_or_overflow);
+ }
+
Label loop, found, miss;
__ ldr(R4, FieldAddress(R9, ICData::arguments_descriptor_offset()));
__ ldr(R8, FieldAddress(R9, ICData::ic_data_offset()));
__ AddImmediate(R8, R8, Array::data_offset() - kHeapObjectTag);
// R8: first IC entry
- __ LoadTaggedClassIdMayBeSmi(R1, R0);
- // R1: receiver cid as Smi
+ __ LoadTaggedClassIdMayBeSmi(R0, R1);
+ // R0: receiver cid as Smi
__ Bind(&loop);
__ ldr(R2, Address(R8, 0));
- __ cmp(R1, Operand(R2));
+ __ cmp(R0, Operand(R2));
__ b(&found, EQ);
__ CompareImmediate(R2, Smi::RawValue(kIllegalCid));
__ b(&miss, EQ);
- const intptr_t entry_length = ICData::TestEntryLengthFor(1) * kWordSize;
+ const intptr_t entry_length =
+ ICData::TestEntryLengthFor(args_checked) * kWordSize;
__ AddImmediate(R8, entry_length); // Next entry.
__ b(&loop);
__ Bind(&found);
- const intptr_t target_offset = ICData::TargetIndexFor(1) * kWordSize;
+ const intptr_t target_offset =
+ ICData::TargetIndexFor(args_checked) * kWordSize;
__ LoadFromOffset(kWord, R0, R8, target_offset);
__ ldr(R1, FieldAddress(R0, Function::entry_point_offset()));
__ ldr(CODE_REG, FieldAddress(R0, Function::code_offset()));
@@ -2139,6 +2180,26 @@ void StubCode::GenerateICLookupStub(Assembler* assembler) {
__ Ret();
}
+
+void StubCode::GenerateICLookupStub(Assembler* assembler) {
+ EmitICLookup(assembler, 1, Token::kILLEGAL);
+}
+
+
+void StubCode::GenerateICSmiAddLookupStub(Assembler* assembler) {
+ EmitICLookup(assembler, 2, Token::kADD);
+}
+
+
+void StubCode::GenerateICSmiSubLookupStub(Assembler* assembler) {
+ EmitICLookup(assembler, 2, Token::kSUB);
+}
+
+
+void StubCode::GenerateICSmiEqualLookupStub(Assembler* assembler) {
+ EmitICLookup(assembler, 2, Token::kEQ);
+}
+
} // namespace dart
#endif // defined TARGET_ARCH_ARM
« no previous file with comments | « runtime/vm/stub_code.h ('k') | runtime/vm/stub_code_arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698