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

Unified Diff: runtime/vm/intermediate_language_mips.cc

Issue 381803005: Reland r38116: Improve receiver class check in polymorphic inlining. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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
Index: runtime/vm/intermediate_language_mips.cc
===================================================================
--- runtime/vm/intermediate_language_mips.cc (revision 38118)
+++ runtime/vm/intermediate_language_mips.cc (working copy)
@@ -4284,12 +4284,16 @@
LocationSummary* CheckClassInstr::MakeLocationSummary(Isolate* isolate,
bool opt) const {
const intptr_t kNumInputs = 1;
- const intptr_t kNumTemps = !IsNullCheck() ? 1 : 0;
+ const bool need_mask_temp = IsDenseSwitch() && !IsDenseMask(ComputeCidMask());
+ const intptr_t kNumTemps = !IsNullCheck() ? (need_mask_temp ? 2 : 1) : 0;
LocationSummary* summary = new(isolate) LocationSummary(
isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall);
summary->set_in(0, Location::RequiresRegister());
if (!IsNullCheck()) {
summary->set_temp(0, Location::RequiresRegister());
+ if (need_mask_temp) {
+ summary->set_temp(1, Location::RequiresRegister());
+ }
}
return summary;
}
@@ -4321,16 +4325,36 @@
__ beq(CMPRES1, ZR, deopt);
}
__ LoadClassId(temp, value);
- const intptr_t num_checks = unary_checks().NumberOfChecks();
- for (intptr_t i = cix; i < num_checks; i++) {
- ASSERT(unary_checks().GetReceiverClassIdAt(i) != kSmiCid);
- __ LoadImmediate(TMP, unary_checks().GetReceiverClassIdAt(i));
- __ subu(CMPRES1, temp, TMP);
- if (i == (num_checks - 1)) {
- __ bne(CMPRES1, ZR, deopt);
- } else {
- __ beq(CMPRES1, ZR, &is_ok);
+
+ if (IsDenseSwitch()) {
+ ASSERT(cids_[0] < cids_[cids_.length() - 1]);
+ __ LoadImmediate(TMP, cids_[0]);
+ __ subu(temp, temp, TMP);
+ __ LoadImmediate(TMP, cids_[cids_.length() - 1] - cids_[0]);
+ __ BranchUnsignedGreater(temp, TMP, deopt);
+
+ intptr_t mask = ComputeCidMask();
+ if (!IsDenseMask(mask)) {
+ // Only need mask if there are missing numbers in the range.
+ ASSERT(cids_.length() > 2);
+ Register mask_reg = locs()->temp(1).reg();
+ __ LoadImmediate(mask_reg, 1);
+ __ sllv(mask_reg, mask_reg, temp);
+ __ AndImmediate(mask_reg, mask_reg, mask);
+ __ beq(mask_reg, ZR, deopt);
}
+ } else {
+ const intptr_t num_checks = unary_checks().NumberOfChecks();
+ for (intptr_t i = cix; i < num_checks; i++) {
+ ASSERT(unary_checks().GetReceiverClassIdAt(i) != kSmiCid);
+ __ LoadImmediate(TMP, unary_checks().GetReceiverClassIdAt(i));
+ __ subu(CMPRES1, temp, TMP);
+ if (i == (num_checks - 1)) {
+ __ bne(CMPRES1, ZR, deopt);
+ } else {
+ __ beq(CMPRES1, ZR, &is_ok);
+ }
+ }
}
__ Bind(&is_ok);
}
@@ -4356,6 +4380,34 @@
}
+LocationSummary* CheckClassIdInstr::MakeLocationSummary(Isolate* isolate,
+ bool opt) const {
+ const intptr_t kNumInputs = 2;
+ const intptr_t kNumTemps = 0;
+ LocationSummary* summary = new(isolate) LocationSummary(
+ isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall);
+ summary->set_in(0, Location::RequiresRegister());
+ summary->set_in(1, Location::RegisterOrSmiConstant(right()));
+ return summary;
+}
+
+
+void CheckClassIdInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
+ Register left = locs()->in(0).reg();
+ Location right = locs()->in(1);
+ Label* deopt = compiler->AddDeoptStub(deopt_id(), ICData::kDeoptCheckClass);
+ if (right.IsRegister()) {
+ __ bne(left, right.reg(), deopt);
+ } else {
+ ASSERT(right.IsConstant());
+ const Object& right_const = Smi::Cast(right.constant());
+ __ BranchNotEqual(left,
+ reinterpret_cast<int32_t>(right_const.raw()),
+ deopt);
+ }
+}
+
+
LocationSummary* CheckArrayBoundInstr::MakeLocationSummary(Isolate* isolate,
bool opt) const {
const intptr_t kNumInputs = 2;

Powered by Google App Engine
This is Rietveld 408576698