Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(785)

Unified Diff: test/cctest/test-heap-profiler.cc

Issue 73893005: Add allocation tracker test for bumb pointer allocations (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-heap-profiler.cc
diff --git a/test/cctest/test-heap-profiler.cc b/test/cctest/test-heap-profiler.cc
index e5d2c6b48d4bd98fcf1d88bf376201541296a35b..23fe1c27e036e571abb23bdf7b4a90f0f3a4cfc1 100644
--- a/test/cctest/test-heap-profiler.cc
+++ b/test/cctest/test-heap-profiler.cc
@@ -2230,3 +2230,84 @@ TEST(TrackHeapAllocations) {
CHECK_GE(node->allocation_size(), 4 * node->allocation_count());
heap_profiler->StopRecordingHeapAllocations();
}
+
+
+static const char* inline_heap_allocation_source =
+"function f_0(x) {\n"
+" return f_1(x+1);\n"
+"}\n"
+"%NeverOptimizeFunction(f_0);\n"
+"function f_1(x) {\n"
+" return new f_2(x+1);\n"
+"}\n"
+"function f_2(x) {\n"
+" this.foo = x;\n"
+"}\n"
+"var instances = [];\n"
+"function start() {\n"
+" instances.push(f_0(0));\n"
+"}\n"
+"\n"
+"for (var i = 0; i < 100; i++) start();\n";
+
+
+TEST(TrackBumpPointerAllocations) {
+ i::FLAG_allow_natives_syntax = true;
+ v8::HandleScope scope(v8::Isolate::GetCurrent());
+ LocalContext env;
+
+ v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
+ const char* names[] = { "(anonymous function)", "start", "f_0", "f_1" };
+ // First check that normally all allocations are recorded.
+ {
+ heap_profiler->StartRecordingHeapAllocations();
+
+ CompileRun(inline_heap_allocation_source);
+
+ const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(
+ v8::String::New("Test2"));
+ i::HeapSnapshotsCollection* collection = ToInternal(snapshot)->collection();
+ AllocationTracker* tracker = collection->allocation_tracker();
+ CHECK_NE(NULL, tracker);
+ // Resolve all function locations.
+ tracker->PrepareForSerialization();
+ // Print for better diagnostics in case of failure.
+ tracker->trace_tree()->Print(tracker);
+
+ AllocationTraceNode* node =
+ FindNode(tracker, Vector<const char*>(names, ARRAY_SIZE(names)));
+ CHECK_NE(NULL, node);
+ CHECK_GE(node->allocation_count(), 100);
+ CHECK_GE(node->allocation_size(), 4 * node->allocation_count());
+ heap_profiler->StopRecordingHeapAllocations();
+ }
+
+ {
+ heap_profiler->StartRecordingHeapAllocations();
+
+ // Now check that not all allocations are tracked if we manually reenable
+ // inline allocations.
+ CHECK(CcTest::heap()->inline_allocation_disabled());
+ CcTest::heap()->EnableInlineAllocation();
+
+ CompileRun(inline_heap_allocation_source);
+
+ const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(
+ v8::String::New("Test1"));
+ i::HeapSnapshotsCollection* collection = ToInternal(snapshot)->collection();
+ AllocationTracker* tracker = collection->allocation_tracker();
+ CHECK_NE(NULL, tracker);
+ // Resolve all function locations.
+ tracker->PrepareForSerialization();
+ // Print for better diagnostics in case of failure.
+ tracker->trace_tree()->Print(tracker);
+
+ AllocationTraceNode* node =
+ FindNode(tracker, Vector<const char*>(names, ARRAY_SIZE(names)));
+ CHECK_NE(NULL, node);
+ CHECK_LT(node->allocation_count(), 100);
+
+ CcTest::heap()->DisableInlineAllocation();
+ heap_profiler->StopRecordingHeapAllocations();
+ }
+}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698