Status: Accepted
Owner: ----
CC: [email protected]
Labels: Type-Bug Priority-Low OS-All

New issue 2432 by [email protected]: Enable faster method calls for functions stored in not as CONSTANT_FUNCTION
http://code.google.com/p/v8/issues/detail?id=2432

Currently hydrogen falls back to generic HCallNamed (compiles into IC) if method is not constant function which results in poor performance.

Consider the following micro benchmark:

var x = { };

x.foo = null; // (*)
x.foo = function () { return this; };

function call_foo(x) {
  for (var i = 0; i < 1000; i++) x = x.foo();
  return x;
}

function measure() {
  var start = Date.now(), end, n = 0;
  while (((end = Date.now()) - start) < 2000) {
    call_foo(x);
    n++;
  }
  return n;
}

measure();
print(measure());

∮ out/ia32.release/d8 test.js 1957399

If I comment line marked (*) it will run 5 times faster because foo turns into a CONSTANT_FUNCTION and can be called directly and inlined. ∮ out/ia32.release/d8 test.js 379549

If I scare away inlining (with large comment) it still runs 1.5 faster due to direct call.

It seems feasible to split HCallNamed into load and call and specialize call part based on the call target type feedback (which can be collected in a way similar to CallFunction stub).

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to