Closed Bug 685707 Opened 13 years ago Closed 13 years ago

IonMonkey: Implement JSOP_DIV

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: dvander, Assigned: dvander)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 1 obsolete file)

Need this to run a Mandelbrot benchmark.
Attached patch fix (obsolete) — Splinter Review
Attachment #559311 - Flags: review?(sstangl)
Attached patch v2Splinter Review
The original patch broke constant folding.
Attachment #559311 - Attachment is obsolete: true
Attachment #559311 - Flags: review?(sstangl)
Attachment #559353 - Flags: review?(sstangl)
Comment on attachment 559353 [details] [diff] [review] v2 Review of attachment 559353 [details] [diff] [review]: ----------------------------------------------------------------- ::: js/src/ion/MIR.cpp @@ +565,5 @@ > + if (specialization_ == MIRType_None) > + return this; > + > + MDefinition *lhs = getOperand(0); > + MDefinition *rhs = getOperand(1); From Bug 685695, MDefinition *lhs = lhs(); MDefinition *rhs = rhs(); @@ +571,5 @@ > + return folded; > + > + // 0 / x -> 0 > + // x / 1 -> x > + if (IsConstant(lhs, 0) || IsConstant(rhs, 1)) Also "-0 / x -> -0" and "NaN / x -> NaN", but perhaps these doesn't pass the threshold for usefulness. It might be more reasonable to handle the NaN case (for all arith) in EvaluateConstantOperands() -- if one of the operands is constant and NaN, the other does not need to be constant for the result to be known. ::: js/src/ion/shared/CodeGenerator-x86-shared.cpp @@ +453,5 @@ > +{ > + Register remainder = ToRegister(ins->remainder()); > + Register lhs = ToRegister(ins->lhs()); > + Register rhs = ToRegister(ins->rhs()); > + If we alias %eax to %rax and %edx to %rdx for x64, as in JSC's Assembler, then we can assert that the Registers are as required. @@ +472,5 @@ > + // Prevent negative 0. > + Label nonzero; > + masm.testl(lhs, lhs); > + masm.j(Assembler::NonZero, &nonzero); > + masm.cmpl(rhs, Imm32(0)); I don't know whether a test on the sign bit should be preferred over cmp in this case, but I suspect cmp is fine. @@ +483,5 @@ > + masm.idiv(rhs); > + > + // If the remainder is > 0, bailout since this must be a double. > + masm.testl(remainder, remainder); > + if (!bailoutIf(Assembler::NonZero, ins->snapshot())) Having two integer operands and a double result seems like a very common case, but this is fine for now. ::: js/src/ion/shared/LIR-x86-shared.h @@ +44,5 @@ > + > +namespace js { > +namespace ion { > + > +class LDivI : public LBinaryMath<1> LBinaryMath<Temps(1)>, ideally. ::: js/src/ion/x64/Lowering-x64.cpp @@ +215,5 @@ > > +bool > +LIRGeneratorX64::lowerDivI(MDiv *div) > +{ > + LDivI *lir = new LDivI(useFixed(div->lhs(), rax), useRegister(div->lhs()), tempFixed(rdx)); Technically %eax and %edx in the JSC assembler are aliases for %rax and %rdx, respectively, so we could eliminate the duplication via some Lowering-x86-shared.{cpp,h}. The duplication is fine here, though. ::: js/src/jit-test/tests/sunspider/check-math-spectral-norm.js @@ +4,5 @@ > // contributed by Ian Osgood > > function A(i,j) { > + //var t = (i+j)*(i+j+1); > + //var k = 2+i+1; Probably not intended for checkin.
Attachment #559353 - Flags: review?(sstangl) → review+
http://hg.mozilla.org/projects/ionmonkey/rev/e6f9d57d8836 I added the register aliases, but am going to hold off on Lowering-x86-shared until we get more duplication. > LBinaryMath<Temps(1)>, ideally. Where Temps is what?
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: