| Index: runtime/vm/intermediate_language_arm.cc
|
| ===================================================================
|
| --- runtime/vm/intermediate_language_arm.cc (revision 30236)
|
| +++ runtime/vm/intermediate_language_arm.cc (working copy)
|
| @@ -2266,6 +2266,16 @@
|
| summary->set_out(Location::RequiresRegister());
|
| return summary;
|
| }
|
| + if (op_kind() == Token::kTRUNCDIVMOD) {
|
| + summary->set_in(0, Location::RequiresRegister());
|
| + summary->set_in(1, Location::RequiresRegister());
|
| + summary->AddTemp(Location::RequiresRegister());
|
| + summary->AddTemp(Location::RequiresFpuRegister());
|
| + summary->AddTemp(Location::RequiresRegister()); // result_div.
|
| + summary->AddTemp(Location::RequiresRegister()); // result_mod.
|
| + summary->set_out(Location::RequiresRegister());
|
| + return summary;
|
| + }
|
| if (op_kind() == Token::kMOD) {
|
| summary->set_in(0, Location::RequiresRegister());
|
| summary->set_in(1, Location::RequiresRegister());
|
| @@ -2534,6 +2544,57 @@
|
| __ Bind(&done);
|
| break;
|
| }
|
| + case Token::kTRUNCDIVMOD: {
|
| + // Handle divide by zero in runtime.
|
| + __ cmp(right, ShifterOperand(0));
|
| + __ b(deopt, EQ);
|
| + Register temp = locs()->temp(0).reg();
|
| + DRegister dtemp = EvenDRegisterOf(locs()->temp(1).fpu_reg());
|
| + Register result_div = locs()->temp(2).reg();
|
| + Register result_mod = locs()->temp(3).reg();
|
| + __ Asr(temp, left, kSmiTagSize); // SmiUntag left into temp.
|
| + __ Asr(IP, right, kSmiTagSize); // SmiUntag right into IP.
|
| +
|
| + __ IntegerDivide(result_div, temp, IP, dtemp, DTMP);
|
| +
|
| + // Check the corner case of dividing the 'MIN_SMI' with -1, in which
|
| + // case we cannot tag the result.
|
| + __ CompareImmediate(result_div, 0x40000000);
|
| + __ b(deopt, EQ);
|
| + __ Asr(IP, right, kSmiTagSize); // SmiUntag right into IP.
|
| + // result_mod <- left - right * result_div.
|
| + __ mls(result_mod, IP, result_div, temp);
|
| + __ SmiTag(result_div);
|
| + __ SmiTag(result_mod);
|
| + // Correct MOD result:
|
| + // res = left % right;
|
| + // if (res < 0) {
|
| + // if (right < 0) {
|
| + // res = res - right;
|
| + // } else {
|
| + // res = res + right;
|
| + // }
|
| + // }
|
| + Label done;
|
| + __ cmp(result_mod, ShifterOperand(0));
|
| + __ b(&done, GE);
|
| + // Result is negative, adjust it.
|
| + __ cmp(right, ShifterOperand(0));
|
| + __ sub(result_mod, result_mod, ShifterOperand(right), LT);
|
| + __ add(result_mod, result_mod, ShifterOperand(right), GE);
|
| + __ Bind(&done);
|
| +
|
| + __ LoadObject(result, Array::ZoneHandle(Array::New(2, Heap::kOld)));
|
| + // Note that index is expected smi-tagged, (i.e, times 2) for all arrays.
|
| + // [0]: divide resut, [1]: mod result.
|
| + __ mov(temp, ShifterOperand(0 +
|
| + FlowGraphCompiler::DataOffsetFor(kArrayCid) - kHeapObjectTag));
|
| + Address store_address(result, temp, LSL, 0);
|
| + __ StoreIntoObjectNoBarrier(result, store_address, result_div);
|
| + __ add(temp, temp, ShifterOperand(kWordSize));
|
| + __ StoreIntoObjectNoBarrier(result, store_address, result_mod);
|
| + break;
|
| + }
|
| case Token::kSHR: {
|
| if (CanDeoptimize()) {
|
| __ CompareImmediate(right, 0);
|
|
|