Index: src/mips/macro-assembler-mips.cc |
diff --git a/src/mips/macro-assembler-mips.cc b/src/mips/macro-assembler-mips.cc |
index 5510f7263f60677600cc6751e9d6b63bec003c81..859b5c209f0c7df11b915e697ffd70657b1ebc25 100644 |
--- a/src/mips/macro-assembler-mips.cc |
+++ b/src/mips/macro-assembler-mips.cc |
@@ -5598,6 +5598,62 @@ void MacroAssembler::SubBranchOvf(Register dst, Register left, Register right, |
BranchOvfHelper(this, overflow_dst, overflow_label, no_overflow_label); |
} |
+static inline void BranchOvfHelperMult(MacroAssembler* masm, |
+ Register overflow_dst, |
+ Label* overflow_label, |
+ Label* no_overflow_label) { |
+ DCHECK(overflow_label || no_overflow_label); |
+ if (!overflow_label) { |
+ DCHECK(no_overflow_label); |
+ masm->Branch(no_overflow_label, eq, overflow_dst, Operand(zero_reg)); |
+ } else { |
+ masm->Branch(overflow_label, ne, overflow_dst, Operand(zero_reg)); |
+ if (no_overflow_label) masm->Branch(no_overflow_label); |
+ } |
+} |
+ |
+void MacroAssembler::MulBranchOvf(Register dst, Register left, |
+ const Operand& right, Label* overflow_label, |
+ Label* no_overflow_label, Register scratch) { |
+ DCHECK(overflow_label || no_overflow_label); |
+ if (right.is_reg()) { |
+ MulBranchOvf(dst, left, right.rm(), overflow_label, no_overflow_label, |
+ scratch); |
+ } else { |
+ Register overflow_dst = t9; |
+ DCHECK(!dst.is(scratch)); |
+ DCHECK(!dst.is(overflow_dst)); |
+ DCHECK(!scratch.is(overflow_dst)); |
+ DCHECK(!left.is(overflow_dst)); |
+ DCHECK(!left.is(scratch)); |
+ |
+ Mul(overflow_dst, dst, left, right.immediate()); |
+ sra(scratch, dst, 31); |
+ xor_(overflow_dst, overflow_dst, scratch); |
+ |
+ BranchOvfHelperMult(this, overflow_dst, overflow_label, no_overflow_label); |
+ } |
+} |
+ |
+void MacroAssembler::MulBranchOvf(Register dst, Register left, Register right, |
+ Label* overflow_label, |
+ Label* no_overflow_label, Register scratch) { |
+ DCHECK(overflow_label || no_overflow_label); |
+ Register overflow_dst = t9; |
+ DCHECK(!dst.is(scratch)); |
+ DCHECK(!dst.is(overflow_dst)); |
+ DCHECK(!scratch.is(overflow_dst)); |
+ DCHECK(!overflow_dst.is(left)); |
+ DCHECK(!overflow_dst.is(right)); |
+ DCHECK(!scratch.is(left)); |
+ DCHECK(!scratch.is(right)); |
+ |
+ Mul(overflow_dst, dst, left, right); |
+ sra(scratch, dst, 31); |
+ xor_(overflow_dst, overflow_dst, scratch); |
+ |
+ BranchOvfHelperMult(this, overflow_dst, overflow_label, no_overflow_label); |
+} |
void MacroAssembler::CallRuntime(const Runtime::Function* f, int num_arguments, |
SaveFPRegsMode save_doubles, |