| Index: runtime/vm/intermediate_language_mips.cc
|
| diff --git a/runtime/vm/intermediate_language_mips.cc b/runtime/vm/intermediate_language_mips.cc
|
| index 6446dddda33d0845a21ff4d0e94bdb53e2ca3d3e..6373d68659f65f573f64ba19247c9eab26daab65 100644
|
| --- a/runtime/vm/intermediate_language_mips.cc
|
| +++ b/runtime/vm/intermediate_language_mips.cc
|
| @@ -5063,7 +5063,7 @@ void BranchInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
|
| LocationSummary* CheckClassInstr::MakeLocationSummary(Zone* zone,
|
| bool opt) const {
|
| const intptr_t kNumInputs = 1;
|
| - const bool need_mask_temp = IsDenseSwitch() && !IsDenseMask(ComputeCidMask());
|
| + const bool need_mask_temp = IsDenseSwitch();
|
| const intptr_t kNumTemps = !IsNullCheck() ? (need_mask_temp ? 2 : 1) : 0;
|
| LocationSummary* summary = new (zone)
|
| LocationSummary(zone, kNumInputs, kNumTemps, LocationSummary::kNoCall);
|
| @@ -5078,89 +5078,70 @@ LocationSummary* CheckClassInstr::MakeLocationSummary(Zone* zone,
|
| }
|
|
|
|
|
| -void CheckClassInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
|
| - Label* deopt = compiler->AddDeoptStub(deopt_id(), ICData::kDeoptCheckClass,
|
| - licm_hoisted_ ? ICData::kHoisted : 0);
|
| - if (IsNullCheck()) {
|
| - if (DeoptIfNull()) {
|
| - __ BranchEqual(locs()->in(0).reg(), Object::null_object(), deopt);
|
| - } else {
|
| - ASSERT(DeoptIfNotNull());
|
| - __ BranchNotEqual(locs()->in(0).reg(), Object::null_object(), deopt);
|
| - }
|
| - return;
|
| - }
|
| -
|
| - ASSERT((unary_checks().GetReceiverClassIdAt(0) != kSmiCid) ||
|
| - (unary_checks().NumberOfChecks() > 1));
|
| - Register value = locs()->in(0).reg();
|
| - Register temp = locs()->temp(0).reg();
|
| - Label is_ok;
|
| - if (unary_checks().GetReceiverClassIdAt(0) == kSmiCid) {
|
| - __ andi(CMPRES1, value, Immediate(kSmiTagMask));
|
| - __ beq(CMPRES1, ZR, &is_ok);
|
| +void CheckClassInstr::EmitNullCheck(FlowGraphCompiler* compiler, Label* deopt) {
|
| + if (IsDeoptIfNull()) {
|
| + __ BranchEqual(locs()->in(0).reg(), Object::null_object(), deopt);
|
| } else {
|
| - __ andi(CMPRES1, value, Immediate(kSmiTagMask));
|
| - __ beq(CMPRES1, ZR, deopt);
|
| - }
|
| - Register biased_cid = temp;
|
| - __ LoadClassId(biased_cid, value);
|
| -
|
| - GrowableArray<CidRangeTarget> sorted_ic_data;
|
| - FlowGraphCompiler::SortICDataByCount(unary_checks(), &sorted_ic_data,
|
| - /* drop_smi = */ true);
|
| -
|
| - if (IsDenseSwitch()) {
|
| - ASSERT(cids_[0] < cids_[cids_.length() - 1]);
|
| - __ LoadImmediate(TMP, cids_[0]);
|
| - __ subu(biased_cid, biased_cid, TMP);
|
| - __ LoadImmediate(TMP, cids_[cids_.length() - 1] - cids_[0]);
|
| - __ BranchUnsignedGreater(biased_cid, 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, biased_cid);
|
| - __ AndImmediate(mask_reg, mask_reg, mask);
|
| - __ beq(mask_reg, ZR, deopt);
|
| + ASSERT(IsDeoptIfNotNull());
|
| + __ BranchNotEqual(locs()->in(0).reg(), Object::null_object(), deopt);
|
| + }
|
| + return;
|
| +}
|
| +
|
| +
|
| +void CheckClassInstr::EmitDenseSwitch(FlowGraphCompiler* compiler,
|
| + intptr_t min,
|
| + intptr_t max,
|
| + intptr_t mask,
|
| + Label* deopt) {
|
| + Register biased_cid = locs()->temp(0).reg();
|
| + __ LoadImmediate(TMP, min);
|
| + __ subu(biased_cid, biased_cid, TMP);
|
| + __ LoadImmediate(TMP, max - min);
|
| + __ BranchUnsignedGreater(biased_cid, TMP, deopt);
|
| +
|
| + Register mask_reg = locs()->temp(1).reg();
|
| + __ LoadImmediate(mask_reg, 1);
|
| + __ sllv(mask_reg, mask_reg, biased_cid);
|
| + __ AndImmediate(mask_reg, mask_reg, mask);
|
| + __ beq(mask_reg, ZR, deopt);
|
| +}
|
| +
|
| +
|
| +int CheckClassInstr::EmitCheckCid(FlowGraphCompiler* compiler,
|
| + int bias,
|
| + intptr_t cid_start,
|
| + intptr_t cid_end,
|
| + bool is_last,
|
| + Label* is_ok,
|
| + Label* deopt,
|
| + bool use_near_jump) {
|
| + Register biased_cid = locs()->temp(0).reg();
|
| + if (cid_start == cid_end) {
|
| + __ LoadImmediate(TMP, cid_start - bias);
|
| + if (is_last) {
|
| + __ bne(biased_cid, TMP, deopt);
|
| + } else {
|
| + __ beq(biased_cid, TMP, is_ok);
|
| }
|
| } else {
|
| - const intptr_t num_checks = sorted_ic_data.length();
|
| - int bias = 0;
|
| - for (intptr_t i = 0; i < num_checks; i++) {
|
| - const intptr_t cid_start = sorted_ic_data[i].cid_start;
|
| - const intptr_t cid_end = sorted_ic_data[i].cid_end;
|
| - ASSERT(cid_start > kSmiCid || cid_end < kSmiCid);
|
| - if (cid_start == cid_end) {
|
| - __ LoadImmediate(TMP, cid_start - bias);
|
| - if (i == (num_checks - 1)) {
|
| - __ bne(biased_cid, TMP, deopt);
|
| - } else {
|
| - __ beq(biased_cid, TMP, &is_ok);
|
| - }
|
| - } else {
|
| - // For class ID ranges use a subtract followed by an unsigned
|
| - // comparison to check both ends of the ranges with one comparison.
|
| - __ AddImmediate(biased_cid, biased_cid, bias - cid_start);
|
| - bias = cid_start;
|
| - // TODO(erikcorry): We should use sltiu instead of the temporary TMP if
|
| - // the range is small enough.
|
| - __ LoadImmediate(TMP, cid_end - cid_start);
|
| - // Reverse comparison so we get 1 if biased_cid > tmp ie cid is out of
|
| - // range.
|
| - __ sltu(TMP, TMP, biased_cid);
|
| - if (i == (num_checks - 1)) {
|
| - __ bne(TMP, ZR, deopt);
|
| - } else {
|
| - __ beq(TMP, ZR, &is_ok);
|
| - }
|
| - }
|
| + // For class ID ranges use a subtract followed by an unsigned
|
| + // comparison to check both ends of the ranges with one comparison.
|
| + __ AddImmediate(biased_cid, biased_cid, bias - cid_start);
|
| + bias = cid_start;
|
| + // TODO(erikcorry): We should use sltiu instead of the temporary TMP if
|
| + // the range is small enough.
|
| + __ LoadImmediate(TMP, cid_end - cid_start);
|
| + // Reverse comparison so we get 1 if biased_cid > tmp ie cid is out of
|
| + // range.
|
| + __ sltu(TMP, TMP, biased_cid);
|
| + if (is_last) {
|
| + __ bne(TMP, ZR, deopt);
|
| + } else {
|
| + __ beq(TMP, ZR, is_ok);
|
| }
|
| }
|
| - __ Bind(&is_ok);
|
| + return bias;
|
| }
|
|
|
|
|
|
|