JM: Make looping to obj.length faster

RESOLVED WORKSFORME

Status

()

Core
JavaScript Engine
RESOLVED WORKSFORME
7 years ago
6 years ago

People

(Reporter: dmandelin, Unassigned)

Tracking

Trunk
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

7 years ago
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.
(Reporter)

Updated

7 years ago
Blocks: 578133

Comment 1

7 years ago
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
Last Resolved: 6 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.