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

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

Issue 177203002: Allocation tracker: add separate entry for allocations via V8 API (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Reverted v8globals.h changes Created 6 years, 10 months 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 | « src/heap-snapshot-generator.cc ('k') | 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 c04ed9de13bee42711db470fee3ea1fbcb5b0d3a..1c3df0311a514557ad883f748c7dc9e60364c4f1 100644
--- a/test/cctest/test-heap-profiler.cc
+++ b/test/cctest/test-heap-profiler.cc
@@ -2216,8 +2216,9 @@ static AllocationTraceNode* FindNode(
Vector<AllocationTraceNode*> children = node->children();
node = NULL;
for (int j = 0; j < children.length(); j++) {
- v8::SnapshotObjectId id = children[j]->function_id();
- AllocationTracker::FunctionInfo* info = tracker->GetFunctionInfo(id);
+ unsigned index = children[j]->function_info_index();
+ AllocationTracker::FunctionInfo* info =
+ tracker->function_info_list()[index];
if (info && strcmp(info->name, name) == 0) {
node = children[j];
break;
@@ -2364,6 +2365,34 @@ TEST(TrackBumpPointerAllocations) {
}
+TEST(TrackV8ApiAllocation) {
+ v8::HandleScope scope(v8::Isolate::GetCurrent());
+ LocalContext env;
+
+ v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
+ const char* names[] = { "(V8 API)" };
+ heap_profiler->StartTrackingHeapObjects(true);
+
+ v8::Handle<v8::Object> o1 = v8::Object::New(env->GetIsolate());
+ o1->Clone();
+
+ AllocationTracker* tracker =
+ reinterpret_cast<i::HeapProfiler*>(heap_profiler)->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(), 2);
+ CHECK_GE(node->allocation_size(), 4 * node->allocation_count());
+ heap_profiler->StopTrackingHeapObjects();
+}
+
+
TEST(ArrayBufferAndArrayBufferView) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
« no previous file with comments | « src/heap-snapshot-generator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698