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

Unified Diff: runtime/vm/intermediate_language_ia32.cc

Issue 181183004: VM: Improve receiver class check in polymorphic inlining. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: improved polymorphic ClassCheck ia32 Created 6 years, 10 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_ia32.cc
===================================================================
--- runtime/vm/intermediate_language_ia32.cc (revision 33059)
+++ runtime/vm/intermediate_language_ia32.cc (working copy)
@@ -4581,6 +4581,9 @@
new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
summary->set_in(0, Location::RequiresRegister());
if (!IsNullCheck()) {
+ if (IsDenseSwitch()) {
+ summary->AddTemp(Location::RegisterLocation(ECX));
+ }
summary->AddTemp(Location::RequiresRegister());
}
return summary;
@@ -4615,18 +4618,36 @@
__ j(ZERO, deopt);
}
__ LoadClassId(temp, value);
- const intptr_t num_checks = unary_checks().NumberOfChecks();
- const bool use_near_jump = num_checks < 5;
- for (intptr_t i = cix; i < num_checks; i++) {
- ASSERT(unary_checks().GetReceiverClassIdAt(i) != kSmiCid);
- __ cmpl(temp, Immediate(unary_checks().GetReceiverClassIdAt(i)));
- if (i == (num_checks - 1)) {
- __ j(NOT_EQUAL, deopt);
- } else {
- if (use_near_jump) {
- __ j(EQUAL, &is_ok, Assembler::kNearJump);
+
+ if (IsDenseSwitch()) {
+ ASSERT(cids_[0] < cids_[cids_.length() - 1]);
+ ASSERT(temp == ECX);
+ Register mask_reg = locs()->temp(1).reg();
+ __ subl(temp, Immediate(cids_[0]));
+ __ cmpl(temp, Immediate(cids_[cids_.length() - 1] - cids_[0]));
+ __ j(ABOVE, deopt);
+ __ movl(mask_reg, Immediate(1));
+ __ shll(mask_reg, temp);
+ intptr_t mask = 0;
+ for (intptr_t i = 0; i < cids_.length(); ++i) {
+ mask |= 1 << (cids_[i] - cids_[0]);
+ }
+ __ andl(mask_reg, Immediate(mask));
+ __ j(ZERO, deopt);
+ } else {
+ const intptr_t num_checks = cids_.length();
+ const bool use_near_jump = num_checks < 5;
+ for (intptr_t i = cix; i < num_checks; i++) {
+ ASSERT(cids_[i] != kSmiCid);
+ __ cmpl(temp, Immediate(cids_[i]));
+ if (i == (num_checks - 1)) {
+ __ j(NOT_EQUAL, deopt);
} else {
- __ j(EQUAL, &is_ok);
+ if (use_near_jump) {
+ __ j(EQUAL, &is_ok, Assembler::kNearJump);
+ } else {
+ __ j(EQUAL, &is_ok);
+ }
}
}
}
@@ -4653,6 +4674,32 @@
}
+LocationSummary* CheckClassIdInstr::MakeLocationSummary(bool opt) const {
+ const intptr_t kNumInputs = 2;
+ const intptr_t kNumTemps = 0;
+ LocationSummary* summary =
+ new LocationSummary(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(), kDeoptCheckClass);
+ if (right.IsRegister()) {
+ __ cmpl(left, right.reg());
+ } else {
+ ASSERT(right.IsConstant());
+ const Object& right_const = Smi::Cast(right.constant());
+ __ cmpl(left, Immediate(reinterpret_cast<int32_t>(right_const.raw())));
+ }
+ __ j(NOT_ZERO, deopt);
+}
+
+
// Length: register or constant.
// Index: register, constant or stack slot.
LocationSummary* CheckArrayBoundInstr::MakeLocationSummary(bool opt) const {

Powered by Google App Engine
This is Rietveld 408576698