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

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

Issue 12321042: Heap snapshot doesn't detect the fact that an old object was overriden by new one. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: comments addressed Created 7 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 | « no previous file | 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 a8a45b7b69e6c5ab458123dc0fa71946c8c772ba..6223d8b2c95dfacf27ec1276d3df9a56e1e6d7b4 100644
--- a/test/cctest/test-heap-profiler.cc
+++ b/test/cctest/test-heap-profiler.cc
@@ -360,6 +360,45 @@ TEST(HeapSnapshotInternalReferences) {
#define CHECK_NE_SNAPSHOT_OBJECT_ID(a, b) \
CHECK((a) != (b)) // NOLINT
+TEST(HeapSnapshotAddressReuse) {
+ v8::HandleScope scope;
+ LocalContext env;
+
+ CompileRun(
+ "function A() {}\n"
+ "var a = [];\n"
+ "for (var i = 0; i < 10000; ++i)\n"
+ " a[i] = new A();\n");
+ const v8::HeapSnapshot* snapshot1 =
+ v8::HeapProfiler::TakeSnapshot(v8_str("snapshot1"));
+ v8::SnapshotObjectId maxId1 = snapshot1->GetMaxSnapshotJSObjectId();
+
+ CompileRun(
+ "for (var i = 0; i < 10000; ++i)\n"
+ " a[i] = new A();\n");
+ HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
+
+ const v8::HeapSnapshot* snapshot2 =
+ v8::HeapProfiler::TakeSnapshot(v8_str("snapshot2"));
+ const v8::HeapGraphNode* global2 = GetGlobalObject(snapshot2);
+
+ const v8::HeapGraphNode* array_node =
+ GetProperty(global2, v8::HeapGraphEdge::kProperty, "a");
+ CHECK_NE(NULL, array_node);
+ int wrong_count = 0;
+ for (int i = 0, count = array_node->GetChildrenCount(); i < count; ++i) {
+ const v8::HeapGraphEdge* prop = array_node->GetChild(i);
+ if (prop->GetType() != v8::HeapGraphEdge::kElement)
+ continue;
+ v8::SnapshotObjectId id = prop->GetToNode()->GetId();
+ if (id < maxId1)
+ ++wrong_count;
+ }
+ // FIXME: Object ids should be unique but it is not so at the moment.
+ CHECK_NE(0, wrong_count);
+}
+
+
TEST(HeapEntryIdsAndArrayShift) {
v8::HandleScope scope;
LocalContext env;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698