| Index: runtime/vm/intermediate_language_x64.cc
|
| ===================================================================
|
| --- runtime/vm/intermediate_language_x64.cc (revision 35442)
|
| +++ runtime/vm/intermediate_language_x64.cc (working copy)
|
| @@ -529,6 +529,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;
|
| + __ testq(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;
|
| + __ cmpq(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(), PP);
|
| + __ jmp(&done, Assembler::kNearJump);
|
| + __ Bind(&is_true);
|
| + __ LoadObject(result_reg, Bool::True(), PP);
|
| + __ Bind(&done);
|
| +}
|
| +
|
| +
|
| LocationSummary* RelationalOpInstr::MakeLocationSummary(bool opt) const {
|
| const intptr_t kNumInputs = 2;
|
| const intptr_t kNumTemps = 0;
|
|
|