Revision: 14935
Author:   [email protected]
Date:     Tue Jun  4 06:20:13 2013
Log:      Added pretenuring support for call new.

BUG=
[email protected]

Review URL: https://codereview.chromium.org/16226012
http://code.google.com/p/v8/source/detail?r=14935

Modified:
 /branches/bleeding_edge/src/flag-definitions.h
 /branches/bleeding_edge/src/hydrogen.cc
 /branches/bleeding_edge/test/cctest/test-heap.cc

=======================================
--- /branches/bleeding_edge/src/flag-definitions.h      Mon Jun  3 07:46:23 2013
+++ /branches/bleeding_edge/src/flag-definitions.h      Tue Jun  4 06:20:13 2013
@@ -193,6 +193,9 @@
             true,
             "Optimize object size, Array shift, DOM strings and string +")
 DEFINE_bool(pretenuring, true, "allocate objects in old space")
+// TODO(hpayer): We will remove this flag as soon as we have pretenuring
+// support for specific allocation sites.
+DEFINE_bool(pretenuring_call_new, false, "pretenure call new")
 DEFINE_bool(track_fields, true, "track fields with only smi values")
 DEFINE_bool(track_double_fields, true, "track fields with double values")
DEFINE_bool(track_heap_object_fields, true, "track fields with heap values")
=======================================
--- /branches/bleeding_edge/src/hydrogen.cc     Tue Jun  4 05:48:51 2013
+++ /branches/bleeding_edge/src/hydrogen.cc     Tue Jun  4 06:20:13 2013
@@ -8780,11 +8780,19 @@
     HValue* size_in_bytes =
         AddInstruction(new(zone()) HConstant(instance_size,
             Representation::Integer32()));
+
+    HAllocate::Flags flags = HAllocate::DefaultFlags();
+    if (FLAG_pretenuring_call_new &&
+        isolate()->heap()->ShouldGloballyPretenure()) {
+      flags = static_cast<HAllocate::Flags>(
+          flags | HAllocate::CAN_ALLOCATE_IN_OLD_POINTER_SPACE);
+    }
+
     HInstruction* receiver =
         AddInstruction(new(zone()) HAllocate(context,
                                              size_in_bytes,
                                              HType::JSObject(),
-                                             HAllocate::DefaultFlags()));
+                                             flags));
     HAllocate::cast(receiver)->set_known_initial_map(initial_map);

     // Load the initial map from the constructor.
=======================================
--- /branches/bleeding_edge/test/cctest/test-heap.cc Tue Jun 4 03:30:05 2013 +++ /branches/bleeding_edge/test/cctest/test-heap.cc Tue Jun 4 06:20:13 2013
@@ -2183,6 +2183,30 @@
 }


+TEST(OptimizedPretenuringCallNew) {
+  i::FLAG_allow_natives_syntax = true;
+  i::FLAG_pretenuring_call_new = true;
+  CcTest::InitializeVM();
+  if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return;
+  if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
+  v8::HandleScope scope(CcTest::isolate());
+  HEAP->SetNewSpaceHighPromotionModeActive(true);
+
+  AlwaysAllocateScope always_allocate;
+  v8::Local<v8::Value> res = CompileRun(
+      "function g() { this.a = 0; }"
+      "function f() {"
+      "  return new g();"
+      "};"
+      "f(); f(); f();"
+      "%OptimizeFunctionOnNextCall(f);"
+      "f();");
+
+  Handle<JSObject> o =
+      v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
+  CHECK(HEAP->InOldPointerSpace(*o));
+}
+
 static int CountMapTransitions(Map* map) {
   return map->transitions()->number_of_transitions();
 }

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to