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..4bfc0397030fb319a425c4341aa3c4067cf80415 100644 |
--- a/test/cctest/test-heap-profiler.cc |
+++ b/test/cctest/test-heap-profiler.cc |
@@ -2230,3 +2230,55 @@ TEST(TrackHeapAllocations) { |
CHECK_GE(node->allocation_size(), 4 * node->allocation_count()); |
heap_profiler->StopRecordingHeapAllocations(); |
} |
+ |
+ |
+static const char* inline_heap_allocation_source = |
loislo
2013/11/15 13:44:15
I see no reason to think that it was an inline all
yurys
2013/11/15 14:32:26
Done. Added additional step which checks that the
|
+"function f_0(x) {\n" |
+" try {\n" |
+" return f_1(x+1);\n" |
+" } catch (e) {}\n" |
+"}\n" |
+"function f_1(x) {\n" |
+" try {\n" |
Michael Starzinger
2013/11/15 13:38:39
I guess the try-catch is used to prevent optimizat
yurys
2013/11/15 13:48:06
You are right, try-catch is here just to prevent o
|
+" return new f_2(x+1);\n" |
+" } catch (e) {}\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) { |
+ v8::HandleScope scope(v8::Isolate::GetCurrent()); |
+ LocalContext env; |
+ |
+ v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); |
+ heap_profiler->StartRecordingHeapAllocations(); |
+ |
+ CompileRun(inline_heap_allocation_source); |
+ |
+ const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot( |
+ v8::String::New("Test")); |
+ 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); |
+ |
+ const char* names[] = |
+ { "(anonymous function)", "start", "f_0", "f_1" }; |
+ 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(); |
+} |