Reviewers: Vyacheslav Egorov,

Description:
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

Please review this at http://codereview.chromium.org/8746018/

SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/

Affected files:
  M     src/parser.cc


Index: src/parser.cc
===================================================================
--- src/parser.cc       (revision 10094)
+++ src/parser.cc       (working copy)
@@ -3844,9 +3844,11 @@
     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();
     }


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

Reply via email to