Reviewers: loislo, Yury Semikhatsky, alph,

Description:
Disable allocation folding when allocations tracking is on

BUG=

Please review this at https://codereview.chromium.org/32583002/

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

Affected files (+26, -2 lines):
  M src/hydrogen-instructions.h
  M src/hydrogen-instructions.cc
  M test/cctest/test-heap-profiler.cc


Index: src/hydrogen-instructions.cc
diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc
index 1613127e2febe7c80d0d99ceb9f4efac5bb821d8..29a69717cacb35f95ff62e8afacd4e825830087d 100644
--- a/src/hydrogen-instructions.cc
+++ b/src/hydrogen-instructions.cc
@@ -3307,7 +3307,10 @@ void HAllocate::HandleSideEffectDominator(GVNFlag side_effect,
                                           HValue* dominator) {
   ASSERT(side_effect == kChangesNewSpacePromotion);
   Zone* zone = block()->zone();
-  if (!FLAG_use_allocation_folding) return;
+  if (!FLAG_use_allocation_folding ||
+      isolate()->heap_profiler()->is_tracking_allocations()) {
+    return;
+  }

   // Try to fold allocations together with their dominating allocations.
   if (!dominator->IsAllocate()) {
Index: src/hydrogen-instructions.h
diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h
index de8e19a5fd73f72331c249c881d0222b0318b16d..c855859166e1c2c780d357c38a7a54b8899e6b3e 100644
--- a/src/hydrogen-instructions.h
+++ b/src/hydrogen-instructions.h
@@ -5354,7 +5354,8 @@ class HAllocate V8_FINAL : public HTemplateInstruction<2> {
     // other, i.e., have a pointer to each other. A GC in between these
// allocations may leave such objects behind in a not completely initialized
     // state.
-    if (!FLAG_use_gvn || !FLAG_use_allocation_folding) {
+    if (!FLAG_use_gvn || !FLAG_use_allocation_folding ||
+        Isolate::Current()->heap_profiler()->is_tracking_allocations()) {
       flags_ = static_cast<HAllocate::Flags>(flags_ | PREFILL_WITH_FILLER);
     }
     clear_next_map_word_ = pretenure_flag == NOT_TENURED &&
Index: test/cctest/test-heap-profiler.cc
diff --git a/test/cctest/test-heap-profiler.cc b/test/cctest/test-heap-profiler.cc index 809372d75aa80c1710c6c224d29fcbc76fc6cd09..e62b3a432a58ae9d9272a8dee1f15aaac85ac495 100644
--- a/test/cctest/test-heap-profiler.cc
+++ b/test/cctest/test-heap-profiler.cc
@@ -2072,3 +2072,23 @@ TEST(HeapObjectsTracker) {
     "    a.shift();\n"
     "findUntrackedObjects();\n");
 }
+
+
+// If we don't disable allocation folding when allocations tracking is on, we
+// may have untracked allocations.
+TEST(DisableAllocationFolding) {
+  LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
+  HeapObjectsTracker tracker;
+  CompileRun(
+    "function literal() {"
+    "    return [1];"
+    "}"
+    "function modify_literal(literal, v) {"
+    "    literal[0] = v;"
+    "    return literal;"
+    "}"
+    "obj = modify_literal(literal(), 1);"
+    "obj = modify_literal(literal(), 1.5);"
+    "obj = modify_literal(literal(), 1);");
+}


--
--
v8-dev mailing list
v8-dev@googlegroups.com
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 v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to