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

Unified Diff: runtime/vm/intermediate_language_ia32.cc

Issue 10824349: Implement class id checks as a separate instruction and add a local CSE optimization pass. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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/intermediate_language.cc ('k') | runtime/vm/intermediate_language_x64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/intermediate_language_ia32.cc
===================================================================
--- runtime/vm/intermediate_language_ia32.cc (revision 10885)
+++ runtime/vm/intermediate_language_ia32.cc (working copy)
@@ -2130,6 +2130,47 @@
EmitBranchOnCondition(compiler, branch_condition);
}
+
+LocationSummary* CheckClassComp::MakeLocationSummary() const {
+ const intptr_t kNumInputs = 1;
+ const intptr_t kNumTemps = 1;
+ LocationSummary* summary =
+ new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
+ summary->set_in(0, Location::RequiresRegister());
+ summary->set_temp(0, Location::RequiresRegister());
+ return summary;
+}
+
+
+void CheckClassComp::EmitNativeCode(FlowGraphCompiler* compiler) {
+ Register value = locs()->in(0).reg();
+ Register temp = locs()->temp(0).reg();
+ Label* deopt = compiler->AddDeoptStub(deopt_id(),
+ try_index(),
+ kDeoptCheckClass,
+ value);
+ ASSERT(ic_data()->GetReceiverClassIdAt(0) != kSmiCid);
+ __ testl(value, Immediate(kSmiTagMask));
+ __ j(ZERO, deopt);
+ __ LoadClassId(temp, value);
+ Label is_ok;
+ const intptr_t num_checks = ic_data()->NumberOfChecks();
+ const bool use_near_jump = num_checks < 5;
+ for (intptr_t i = 0; i < num_checks; i++) {
+ __ cmpl(temp, Immediate(ic_data()->GetReceiverClassIdAt(i)));
+ if (i == (num_checks - 1)) {
+ __ j(NOT_EQUAL, deopt);
+ } else {
+ if (use_near_jump) {
+ __ j(EQUAL, &is_ok, Assembler::kNearJump);
+ } else {
+ __ j(EQUAL, &is_ok);
+ }
+ }
+ }
+ __ Bind(&is_ok);
+}
+
} // namespace dart
#undef __
« no previous file with comments | « runtime/vm/intermediate_language.cc ('k') | runtime/vm/intermediate_language_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698