Status: Accepted
Owner: [email protected]
CC: [email protected]
Labels: Type-Bug Priority-Medium

New issue 2974 by [email protected]: Repeated redefinition of functions in an object leads to different maps
http://code.google.com/p/v8/issues/detail?id=2974

Consider following test case:

function f(o) {  o.z = 1; }
var loops = 5;

for (var j = 0; j < 5; j++) {
  print("\n===================================\n");
  o = { };
  o.a = function() { };
  o.b = function() { };
  o.c = function() { };
  o.d = function() { };
  o.e = function() { };
  o.z = 0;
  %DebugPrint(o);
  for (var i = 0; i < 10000; i++) f(o);
}


This emulates the behavior of running audio-oscillator several times. The function f is optimized in every loop, and deopted in the following loop because object o has a different map. The reason is that, when we start out with map A0, the first run of the loop looks like this regarding map transitions:

A0: {} -> A1 { a: constant } -> A2 { a: constant, b: constant } -> A3 { a: constant, b: constant, c: constant } -> ...

In the second loop, we assign o.a again, which causes a to become a field instead of constant.

A0: {} -> B1 { a: field } -> B2 { a: field, b: constant } -> B3 { a: field, b: constant, c: constant } -> ...

In the third loop:

A0: {} -> B1 { a: field } -> C2 { a: field, b: field } -> B3 { a: field, b: field, c: constant } -> ...

So we figure out that we should use fields instead of constants one by one, causing map changes all the time.


Calling JSObject::AddFastProperty instead of JSObject::AddConstantProperty in JSObject::AddProperty (as a hack) fixes this problem.

--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to