Make sure that the inline_new flag guards all the optimizations for
authorager@chromium.org <ager@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 16 Feb 2010 15:14:34 +0000 (15:14 +0000)
committerager@chromium.org <ager@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 16 Feb 2010 15:14:34 +0000 (15:14 +0000)
constructors that only contain simple this assignments.

Make sure that constructors with declarations are not treated as
constructors with only simple this property assignments.

Review URL: http://codereview.chromium.org/601081

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3875 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/heap.cc
src/parser.cc
src/runtime.cc

index e90ae205b9606da4a7927192f98fe66bac494e73..08f6c08092e6161be19484ace77727fcf02b78a6 100644 (file)
@@ -2383,11 +2383,14 @@ Object* Heap::AllocateInitialMap(JSFunction* fun) {
   map->set_unused_property_fields(in_object_properties);
   map->set_prototype(prototype);
 
-  // If the function has only simple this property assignments add field
-  // descriptors for these to the initial map as the object cannot be
-  // constructed without having these properties.
+  // If the function has only simple this property assignments add
+  // field descriptors for these to the initial map as the object
+  // cannot be constructed without having these properties.  Guard by
+  // the inline_new flag so we only change the map if we generate a
+  // specialized construct stub.
   ASSERT(in_object_properties <= Map::kMaxPreAllocatedPropertyFields);
-  if (fun->shared()->has_only_simple_this_property_assignments() &&
+  if (FLAG_inline_new &&
+      fun->shared()->has_only_simple_this_property_assignments() &&
       fun->shared()->this_property_assignments_count() > 0) {
     int count = fun->shared()->this_property_assignments_count();
     if (count > in_object_properties) {
index b06d86f592450b164aa1e32c57a0c8466d4a2f8e..5058296db2dab862bcd8b757be3b2aa5765c0dd3 100644 (file)
@@ -1690,7 +1690,8 @@ void* Parser::ParseSourceElements(ZoneListWrapper<Statement>* processor,
   // Propagate the collected information on this property assignments.
   if (top_scope_->is_function_scope()) {
     bool only_simple_this_property_assignments =
-        this_property_assignment_finder.only_simple_this_property_assignments();
+        this_property_assignment_finder.only_simple_this_property_assignments()
+        && top_scope_->declarations()->length() == 0;
     if (only_simple_this_property_assignments) {
       temp_scope_->SetThisPropertyAssignmentInfo(
           only_simple_this_property_assignments,
index 26a763000aaffdb85101ee15c0e097eda3c2c3ba..de9ac3641d49fb25191081ed50ca5782327db64b 100644 (file)
@@ -4850,9 +4850,6 @@ static Object* Runtime_NewClosure(Arguments args) {
 
 
 static Code* ComputeConstructStub(Handle<SharedFunctionInfo> shared) {
-  // TODO(385): Change this to create a construct stub specialized for
-  // the given map to make allocation of simple objects - and maybe
-  // arrays - much faster.
   if (FLAG_inline_new
       && shared->has_only_simple_this_property_assignments()) {
     ConstructStubCompiler compiler;