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

Side by Side Diff: test/cctest/test-heap-profiler.cc

Issue 10094011: Add method for resolving SnapshotObjectId by given object (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« src/heap-profiler.cc ('K') | « src/profile-generator.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // 2 //
3 // Tests for heap profiler 3 // Tests for heap profiler
4 4
5 #include "v8.h" 5 #include "v8.h"
6 6
7 #include "cctest.h" 7 #include "cctest.h"
8 #include "heap-profiler.h" 8 #include "heap-profiler.h"
9 #include "snapshot.h" 9 #include "snapshot.h"
10 #include "utils-inl.h" 10 #include "utils-inl.h"
(...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after
902 902
903 const v8::HeapSnapshot* snapshot = 903 const v8::HeapSnapshot* snapshot =
904 v8::HeapProfiler::TakeSnapshot(v8_str("id")); 904 v8::HeapProfiler::TakeSnapshot(v8_str("id"));
905 const v8::HeapGraphNode* root = snapshot->GetRoot(); 905 const v8::HeapGraphNode* root = snapshot->GetRoot();
906 CheckChildrenIds(snapshot, root, 0, 3); 906 CheckChildrenIds(snapshot, root, 0, 3);
907 // Check a big id, which should not exist yet. 907 // Check a big id, which should not exist yet.
908 CHECK_EQ(NULL, snapshot->GetNodeById(0x1000000UL)); 908 CHECK_EQ(NULL, snapshot->GetNodeById(0x1000000UL));
909 } 909 }
910 910
911 911
912 TEST(HeapSnapshotGetSnapshotObjectId) {
913 v8::HandleScope scope;
914 LocalContext env;
915 CompileRun("globalObject = {};\n");
916 const v8::HeapSnapshot* snapshot =
917 v8::HeapProfiler::TakeSnapshot(v8_str("get_snapshot_object_id"));
918 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
919 const v8::HeapGraphNode* global_object =
920 GetProperty(global, v8::HeapGraphEdge::kProperty, "globalObject");
921 CHECK(global_object);
922
923 v8::Local<v8::Value> globalObjectHandle =
924 env->Global()->Get(v8::String::New("globalObject"));
925 CHECK(!globalObjectHandle.IsEmpty());
926 CHECK(globalObjectHandle->IsObject());
927
928 v8::SnapshotObjectId id =
929 v8::HeapProfiler::GetSnapshotObjectId(globalObjectHandle);
930 CHECK_NE(static_cast<int>(v8::HeapProfiler::kUnknownObjectId),
931 id);
932 CHECK_EQ(static_cast<int>(id), global_object->GetId());
933 }
934
935
936 TEST(HeapSnapshotUnknownSnapshotObjectId) {
937 v8::HandleScope scope;
938 LocalContext env;
939 CompileRun("globalObject = {};\n");
940 const v8::HeapSnapshot* snapshot =
941 v8::HeapProfiler::TakeSnapshot(v8_str("unknown_object_id"));
942 const v8::HeapGraphNode* node =
943 snapshot->GetNodeById(v8::HeapProfiler::kUnknownObjectId);
944 CHECK_EQ(NULL, node);
945 }
946
947
912 namespace { 948 namespace {
913 949
914 class TestActivityControl : public v8::ActivityControl { 950 class TestActivityControl : public v8::ActivityControl {
915 public: 951 public:
916 explicit TestActivityControl(int abort_count) 952 explicit TestActivityControl(int abort_count)
917 : done_(0), total_(0), abort_count_(abort_count) {} 953 : done_(0), total_(0), abort_count_(abort_count) {}
918 ControlOption ReportProgressValue(int done, int total) { 954 ControlOption ReportProgressValue(int done, int total) {
919 done_ = done; 955 done_ = done;
920 total_ = total; 956 total_ = total;
921 return --abort_count_ != 0 ? kContinue : kAbort; 957 return --abort_count_ != 0 ? kContinue : kAbort;
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
1552 // Dipose the persistent handles in a different order. 1588 // Dipose the persistent handles in a different order.
1553 p_AAA.Dispose(); 1589 p_AAA.Dispose();
1554 CHECK_EQ(global_handle_count + 2, 1590 CHECK_EQ(global_handle_count + 2,
1555 v8::HeapProfiler::GetPersistentHandleCount()); 1591 v8::HeapProfiler::GetPersistentHandleCount());
1556 p_CCC.Dispose(); 1592 p_CCC.Dispose();
1557 CHECK_EQ(global_handle_count + 1, 1593 CHECK_EQ(global_handle_count + 1,
1558 v8::HeapProfiler::GetPersistentHandleCount()); 1594 v8::HeapProfiler::GetPersistentHandleCount());
1559 p_BBB.Dispose(); 1595 p_BBB.Dispose();
1560 CHECK_EQ(global_handle_count, v8::HeapProfiler::GetPersistentHandleCount()); 1596 CHECK_EQ(global_handle_count, v8::HeapProfiler::GetPersistentHandleCount());
1561 } 1597 }
OLDNEW
« src/heap-profiler.cc ('K') | « src/profile-generator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698