Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure the isolate hidden class is constant #6892

Closed
floitschG opened this issue Nov 23, 2012 · 7 comments
Closed

Make sure the isolate hidden class is constant #6892

floitschG opened this issue Nov 23, 2012 · 7 comments

Comments

@floitschG
Copy link
Contributor

V8 optimizes function instantiations by moving constant functions into the hidden class.
for example function A() { this.foo = function() { return 499; }; }
Afaik this will move the function into the hidden class of the newly allocated object.
However if 'foo' changes this means that we have a map-transition. Normally this doesn't happen for dart2js generated code, but we should probably make sure that non-final statics don't have this problem:
===
bar() => 499;
var foo = bar;
// later in code:
... foo = (() => 42);
===

@peter-ahe-google
Copy link
Contributor

Added this to the Later milestone.

@kasperl
Copy link

kasperl commented May 23, 2013

Added TriageForM5 label.

@kasperl
Copy link

kasperl commented May 28, 2013

Removed TriageForM5 label.

@kasperl
Copy link

kasperl commented Jul 10, 2014

Removed this from the Later milestone.
Added Oldschool-Milestone-Later label.

@kasperl
Copy link

kasperl commented Aug 4, 2014

Removed Oldschool-Milestone-Later label.

@karlklose
Copy link
Contributor

@floitschG Could you update the status of this bug?

@floitschG
Copy link
Contributor Author

Current version of dart2js seems to do the right thing. Deferred loading of libraries destroys the hidden map of global objects, but that's a different issue.

final x = (() { return 499; }) ();
final y = (() { return 42; }) ();

foo() {
  var sum = 0;
  for (int i = 0; i < 100000; i++) {
    sum += x;
    sum = sum & 0xFFFFFF;
  }
  return sum;
}

main() {
  for (int j = 0; j < 1000; j++) { foo(); }

  var sw = new Stopwatch()..start();
  for (int j = 0; j < 1000; j++) { foo(); }
  print(sw.elapsedMilliseconds);
  print(y);
  for (int j = 0; j < 1000; j++) { foo(); }
  sw.reset();
  for (int j = 0; j < 1000; j++) { foo(); }
  print(sw.elapsedMilliseconds);
}

@kevmoo kevmoo removed the triaged label Mar 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants