Only make function literals in top-level object literals pretenured and constant function properties.
This change is a refinement of http://code.google.com/p/v8/source/detail?r=7283. Making all function literals inside object literals constant function properties causes us to lose map sharing. This hurts code where many object literals are created. The idea is that top-level code is mostly executed once and functions inside top-level object literals remain fast with this change. BUG=v8:1795 Review URL: http://codereview.chromium.org/8746018 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10096 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
552f800d46
commit
3c82957f04
@ -3844,9 +3844,11 @@ Expression* Parser::ParseObjectLiteral(bool* ok) {
|
||||
ObjectLiteral::Property* property =
|
||||
new(zone()) ObjectLiteral::Property(key, value);
|
||||
|
||||
// Mark object literals that contain function literals and pretenure the
|
||||
// literal so it can be added as a constant function property.
|
||||
if (value->AsFunctionLiteral() != NULL) {
|
||||
// Mark top-level object literals that contain function literals and
|
||||
// pretenure the literal so it can be added as a constant function
|
||||
// property.
|
||||
if (top_scope_->DeclarationScope()->is_global_scope() &&
|
||||
value->AsFunctionLiteral() != NULL) {
|
||||
has_function = true;
|
||||
value->AsFunctionLiteral()->set_pretenure();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user