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

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

Issue 93843004: Add methods for finding object by its snapshot id and id for an object (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: One more time Created 7 years 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-profiler.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 eff5744d83543664cc10f09a49b98f862fc08bea..e151fdc5ff7654c927359dde38a0272f6e260300 100644
--- a/test/cctest/test-heap-profiler.cc
+++ b/test/cctest/test-heap-profiler.cc
@@ -1041,6 +1041,49 @@ TEST(HeapSnapshotObjectsStats) {
}
+TEST(HeapObjectIds) {
+ LocalContext env;
+ v8::Isolate* isolate = env->GetIsolate();
+ v8::HandleScope scope(isolate);
+ v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
+
+ const int kLength = 10;
+ v8::Handle<v8::Object> objects[kLength];
+ v8::SnapshotObjectId ids[kLength];
+
+ heap_profiler->StartTrackingHeapObjects(false);
+
+ for (int i = 0; i < kLength; i++) {
+ objects[i] = v8::Object::New(isolate);
+ }
+ GetHeapStatsUpdate(heap_profiler);
+
+ for (int i = 0; i < kLength; i++) {
+ v8::SnapshotObjectId id = heap_profiler->GetObjectId(objects[i]);
+ CHECK_NE(v8::HeapProfiler::kUnknownObjectId, static_cast<int>(id));
+ ids[i] = id;
+ }
+
+ heap_profiler->StopTrackingHeapObjects();
+ CcTest::heap()->CollectAllAvailableGarbage();
+
+ for (int i = 0; i < kLength; i++) {
+ v8::SnapshotObjectId id = heap_profiler->GetObjectId(objects[i]);
+ CHECK_EQ(static_cast<int>(ids[i]), static_cast<int>(id));
+ v8::Handle<v8::Value> obj = heap_profiler->FindObjectById(ids[i]);
+ CHECK_EQ(objects[i], obj);
+ }
+
+ heap_profiler->ClearObjectIds();
+ for (int i = 0; i < kLength; i++) {
+ v8::SnapshotObjectId id = heap_profiler->GetObjectId(objects[i]);
+ CHECK_EQ(v8::HeapProfiler::kUnknownObjectId, static_cast<int>(id));
+ v8::Handle<v8::Value> obj = heap_profiler->FindObjectById(ids[i]);
+ CHECK(obj.IsEmpty());
+ }
+}
+
+
static void CheckChildrenIds(const v8::HeapSnapshot* snapshot,
const v8::HeapGraphNode* node,
int level, int max_level) {
« no previous file with comments | « src/heap-profiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698