Revision: 10096
Author:   [email protected]
Date:     Wed Nov 30 08:00:47 2011
Log: 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
http://code.google.com/p/v8/source/detail?r=10096

Modified:
 /branches/bleeding_edge/src/parser.cc

=======================================
--- /branches/bleeding_edge/src/parser.cc       Tue Nov 29 00:43:14 2011
+++ /branches/bleeding_edge/src/parser.cc       Wed Nov 30 08:00:47 2011
@@ -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