Open Bug 966259 Opened 10 years ago Updated 2 years ago

Relational comparison of objects is slower than v8

Categories

(Core :: JavaScript Engine: JIT, defect, P5)

defect

Tracking

()

People

(Reporter: jandem, Unassigned)

References

(Blocks 1 open bug)

Details

Octane-box2d has a function that does this:

    x.proxyA = t < m ? t : m;
    x.proxyB = t >= m ? t : m;

t and m are both objects that don't have a valueOf/toString hook, so this effectively comes down to comparing "[object Object]" and the first comparison is always false, the second always true...

This is pretty stupid but if Ion could see we have objects with the default valueOf/toString properties it could probably fold this.

Box2d does this about 40,000 times, for the (similar) micro-benchmark below I get 54 ms for us, 30 ms for v8.

function f() {
    var o1 = {}, o2 = {};
    var res = false;
    var t = new Date;
    for (var i=0; i<40000; i++) {
	res = o1 < o2;
	res = o1 >= o2;
    }
    print(new Date - t);
    return res;
}
f();
(In reply to Jan de Mooij [:jandem] from comment #0)
> Box2d does this about 40,000 times, for the (similar) micro-benchmark below
> I get 54 ms for us, 30 ms for v8.

With the patch in bug 966264 I get 29 ms.
Priority: -- → P5
Assignee: jdemooij → nobody
Status: ASSIGNED → NEW
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.