Closed Bug 600764 Opened 14 years ago Closed 13 years ago

JM: Make looping to obj.length faster

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: dmandelin, Unassigned)

References

Details

This microbenchmark, extracted from A*, loops over an array up to its length:

    function lengthInLoop(a) {
	for (var i = 0; i < a.length; ++i) {
	}
    }

    function makeArray(n) {
	var a = [];
	for (var i = 0; i < 4000; ++i)
	    a.push(0);
	return a;
    }

    var a = makeArray(4000);

    var t0 = new Date;
    for (var i = 0; i < 10000; ++i)
	lengthInLoop(a);
    var t1 = new Date;
    print('lengthInLoop ' + (t1-t0));

The methodjit runs this 2x slower than the tracejit. It seems that it should be able to be about as fast.

If we fix this bug and bug 599214, then the methodjit should be about as fast as the tracer on A*, which will make tuning easier.
Blocks: JaegerSpeed
The following line in makeArray():
  for (var i = 0; i < 4000; ++i)

should read:
  for (var i = 0; i < n; ++i)
Interp: 2040
TM: 2053
JM: 409
JM+TI: 37
d8: 57

Looks like TI made this fast.
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.