OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1034 CHECK_EQ(2, stats_update.updates_written()); | 1034 CHECK_EQ(2, stats_update.updates_written()); |
1035 CHECK_LT(entries_size, stats_update.entries_size()); | 1035 CHECK_LT(entries_size, stats_update.entries_size()); |
1036 CHECK_EQ(2, stats_update.entries_count()); | 1036 CHECK_EQ(2, stats_update.entries_count()); |
1037 CHECK_EQ(8, stats_update.first_interval_index()); | 1037 CHECK_EQ(8, stats_update.first_interval_index()); |
1038 } | 1038 } |
1039 | 1039 |
1040 heap_profiler->StopTrackingHeapObjects(); | 1040 heap_profiler->StopTrackingHeapObjects(); |
1041 } | 1041 } |
1042 | 1042 |
1043 | 1043 |
1044 TEST(HeapObjectIds) { | |
1045 LocalContext env; | |
1046 v8::Isolate* isolate = env->GetIsolate(); | |
1047 v8::HandleScope scope(isolate); | |
1048 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); | |
1049 | |
1050 const int kLength = 10; | |
1051 v8::Handle<v8::Object> objects[kLength]; | |
1052 v8::SnapshotObjectId ids[kLength]; | |
1053 | |
1054 heap_profiler->StartTrackingHeapObjects(false); | |
1055 | |
1056 for (int i = 0; i < kLength; i++) { | |
1057 objects[i] = v8::Object::New(isolate); | |
1058 } | |
1059 GetHeapStatsUpdate(heap_profiler); | |
1060 | |
1061 for (int i = 0; i < kLength; i++) { | |
1062 v8::SnapshotObjectId id = heap_profiler->GetObjectId(objects[i]); | |
1063 CHECK_NE(v8::HeapProfiler::kUnknownObjectId, static_cast<int>(id)); | |
1064 ids[i] = id; | |
1065 } | |
1066 | |
1067 heap_profiler->StopTrackingHeapObjects(); | |
alph
2013/12/04 08:39:38
Maybe force a GC here to make the objects move.
| |
1068 | |
1069 for (int i = 0; i < kLength; i++) { | |
1070 v8::SnapshotObjectId id = heap_profiler->GetObjectId(objects[i]); | |
1071 CHECK_EQ(static_cast<int>(ids[i]), static_cast<int>(id)); | |
1072 v8::Handle<v8::Value> obj = heap_profiler->FindHeapObjectById(ids[i]); | |
1073 CHECK_EQ(objects[i], obj); | |
1074 } | |
1075 | |
1076 heap_profiler->ClearHeapObjectIds(); | |
1077 for (int i = 0; i < kLength; i++) { | |
1078 v8::SnapshotObjectId id = heap_profiler->GetObjectId(objects[i]); | |
1079 CHECK_EQ(v8::HeapProfiler::kUnknownObjectId, static_cast<int>(id)); | |
1080 v8::Handle<v8::Value> obj = heap_profiler->FindHeapObjectById(ids[i]); | |
1081 CHECK(obj.IsEmpty()); | |
1082 } | |
1083 } | |
1084 | |
1085 | |
1044 static void CheckChildrenIds(const v8::HeapSnapshot* snapshot, | 1086 static void CheckChildrenIds(const v8::HeapSnapshot* snapshot, |
1045 const v8::HeapGraphNode* node, | 1087 const v8::HeapGraphNode* node, |
1046 int level, int max_level) { | 1088 int level, int max_level) { |
1047 if (level > max_level) return; | 1089 if (level > max_level) return; |
1048 CHECK_EQ(node, snapshot->GetNodeById(node->GetId())); | 1090 CHECK_EQ(node, snapshot->GetNodeById(node->GetId())); |
1049 for (int i = 0, count = node->GetChildrenCount(); i < count; ++i) { | 1091 for (int i = 0, count = node->GetChildrenCount(); i < count; ++i) { |
1050 const v8::HeapGraphEdge* prop = node->GetChild(i); | 1092 const v8::HeapGraphEdge* prop = node->GetChild(i); |
1051 const v8::HeapGraphNode* child = | 1093 const v8::HeapGraphNode* child = |
1052 snapshot->GetNodeById(prop->GetToNode()->GetId()); | 1094 snapshot->GetNodeById(prop->GetToNode()->GetId()); |
1053 CHECK_EQ_SNAPSHOT_OBJECT_ID(prop->GetToNode()->GetId(), child->GetId()); | 1095 CHECK_EQ_SNAPSHOT_OBJECT_ID(prop->GetToNode()->GetId(), child->GetId()); |
(...skipping 1255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2309 | 2351 |
2310 AllocationTraceNode* node = | 2352 AllocationTraceNode* node = |
2311 FindNode(tracker, Vector<const char*>(names, ARRAY_SIZE(names))); | 2353 FindNode(tracker, Vector<const char*>(names, ARRAY_SIZE(names))); |
2312 CHECK_NE(NULL, node); | 2354 CHECK_NE(NULL, node); |
2313 CHECK_LT(node->allocation_count(), 100); | 2355 CHECK_LT(node->allocation_count(), 100); |
2314 | 2356 |
2315 CcTest::heap()->DisableInlineAllocation(); | 2357 CcTest::heap()->DisableInlineAllocation(); |
2316 heap_profiler->StopTrackingHeapObjects(); | 2358 heap_profiler->StopTrackingHeapObjects(); |
2317 } | 2359 } |
2318 } | 2360 } |
OLD | NEW |