Closed Bug 780052 Opened 12 years ago Closed 12 years ago

IonMonkey: Handle some multi-type comparisons without CompareV.

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: sstangl, Unassigned)

References

Details

(Whiteboard: [ion:t])

Attachments

(1 file)

In 3d-raytrace, Triangle.prototype.intersect() and Scene.prototype.intersect() both take arguments that are double|undefined and used only in comparisons. The latter function calls the former in a tight loop, and then includes more such comparisons on top. We should at least be able to handle (Double, Value) comparisons with the TypeSet case of a single (matching?) type and Undefined. `perf` shows about 10% of execution in the expanded benchmark from Bug 777583 is spent in ion::GreaterThan and ion::LessThan.
Attached patch patchSplinter Review
Handles the (Double, Double|Undefined) case by coercing the Undefined to NaN. This is more work than propagating false based on a typecheck, but easier to implement. On x86_64, the raytrace benchmark from Bug 777583 goes from 800 -> 600ms. The actual raytrace benchmark goes from about 28 -> 27ms; the difference is small but noticeable.
Attachment #649483 - Flags: review?(dvander)
Comment on attachment 649483 [details] [diff] [review] patch Flipping review to Jan since I think he's more familiar with the comparison path now.
Attachment #649483 - Flags: review?(dvander) → review?(jdemooij)
Comment on attachment 649483 [details] [diff] [review] patch Review of attachment 649483 [details] [diff] [review]: ----------------------------------------------------------------- ::: js/src/ion/MIR.cpp @@ +981,5 @@ > } > + > + // Handle double comparisons against something that safely coerces to double. > + if (jsop() != JSOP_STRICTEQ && jsop() != JSOP_STRICTNE && lhs == MIRType_Double) { > + types::TypeFlags flags = b.rhsTypes->baseFlags(); Nit: JS_ASSERT(jsop() == JSOP_EQ || jsop() == JSOP_NE); @@ +984,5 @@ > + if (jsop() != JSOP_STRICTEQ && jsop() != JSOP_STRICTNE && lhs == MIRType_Double) { > + types::TypeFlags flags = b.rhsTypes->baseFlags(); > + > + // Strings are unhandled -- visitToDouble() doesn't support them yet. > + types::TypeFlags converts = types::TYPE_FLAG_NULL | types::TYPE_FLAG_UNDEFINED | ToDouble(null) is 0, but "0 == null" should be false. @@ +988,5 @@ > + types::TypeFlags converts = types::TYPE_FLAG_NULL | types::TYPE_FLAG_UNDEFINED | > + types::TYPE_FLAG_INT32 | types::TYPE_FLAG_BOOLEAN | > + types::TYPE_FLAG_DOUBLE; > + > + // If rhs can be safely coerced to a Double. Can we factor this check out to a helper function and also handle the rhs == MIRType_Double case? The RHS is often constant (x == 1.2) so it could help to support mixed lhs types there too.
Attachment #649483 - Flags: review?(jdemooij) → review+
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Blocks: 796114
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: