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

Unified Diff: runtime/vm/intermediate_language_ia32.cc

Issue 258563004: Copy of Issue 231383002 after hard disk crash: First step in improving instance of test for a fixed… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 8 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 35442)
+++ runtime/vm/intermediate_language_ia32.cc (working copy)
@@ -582,6 +582,78 @@
}
+
+LocationSummary* TestCidsInstr::MakeLocationSummary(bool opt) const {
+ const intptr_t kNumInputs = 1;
+ const intptr_t kNumTemps = 1;
+ LocationSummary* locs =
+ new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
+ locs->set_in(0, Location::RequiresRegister());
+ locs->set_temp(0, Location::RequiresRegister());
+ locs->set_out(0, Location::RequiresRegister());
+ return locs;
+}
+
+
+Condition TestCidsInstr::EmitComparisonCode(FlowGraphCompiler* compiler,
+ BranchLabels labels) {
+ ASSERT((kind() == Token::kIS) || (kind() == Token::kISNOT));
+ Register val_reg = locs()->in(0).reg();
+ Register cid_reg = locs()->temp(0).reg();
+
+ Label* deopt = CanDeoptimize() ?
+ compiler->AddDeoptStub(deopt_id(), kDeoptTestCids) : NULL;
+
+ const intptr_t true_result = (kind() == Token::kIS) ? 1 : 0;
+ const ZoneGrowableArray<intptr_t>& data = cid_results();
+ ASSERT(data[0] == kSmiCid);
+ bool result = data[1] == true_result;
+ __ testl(val_reg, Immediate(kSmiTagMask));
+ __ j(ZERO, result ? labels.true_label : labels.false_label);
+ __ LoadClassId(cid_reg, val_reg);
+ for (intptr_t i = 2; i < data.length(); i += 2) {
+ const intptr_t test_cid = data[i];
+ ASSERT(test_cid != kSmiCid);
+ result = data[i + 1] == true_result;
+ __ cmpl(cid_reg, Immediate(test_cid));
+ __ j(EQUAL, result ? labels.true_label : labels.false_label);
+ }
+ // No match found, deoptimize or false.
+ if (deopt == NULL) {
+ Label* target = result ? labels.false_label : labels.true_label;
+ if (target != labels.fall_through) {
+ __ jmp(target);
+ }
+ } else {
+ __ jmp(deopt);
+ }
+ // Dummy result as the last instruction is a jump, any conditional
+ // branch using the result will therefore be skipped.
+ return ZERO;
+}
+
+
+void TestCidsInstr::EmitBranchCode(FlowGraphCompiler* compiler,
+ BranchInstr* branch) {
+ BranchLabels labels = compiler->CreateBranchLabels(branch);
+ EmitComparisonCode(compiler, labels);
+}
+
+
+void TestCidsInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
+ Register result_reg = locs()->out(0).reg();
+ Label is_true, is_false, done;
+ BranchLabels labels = { &is_true, &is_false, &is_false };
+ EmitComparisonCode(compiler, labels);
+ __ Bind(&is_false);
+ __ LoadObject(result_reg, Bool::False());
+ __ jmp(&done, Assembler::kNearJump);
+ __ Bind(&is_true);
+ __ LoadObject(result_reg, Bool::True());
+ __ Bind(&done);
+}
+
+
LocationSummary* RelationalOpInstr::MakeLocationSummary(bool opt) const {
const intptr_t kNumInputs = 2;
const intptr_t kNumTemps = 0;

Powered by Google App Engine
This is Rietveld 408576698