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

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

Issue 166993002: Make a single HeapEntry per single JSArrayBuffer data in heap snapshot. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Added a test. 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 436f2559bb7fad15f5e6708d51021534567b25c8..5c102e0c52bc290fba38004da13a7c18e036e9eb 100644
--- a/test/cctest/test-heap-profiler.cc
+++ b/test/cctest/test-heap-profiler.cc
@@ -2388,6 +2388,51 @@ TEST(ArrayBufferAndArrayBufferView) {
}
+static int GetRetainersCount(const v8::HeapSnapshot* snapshot,
+ const v8::HeapGraphNode* node) {
+ int count = 0;
+ for (int i = 0, l = snapshot->GetNodesCount(); i < l; ++i) {
+ const v8::HeapGraphNode* parent = snapshot->GetNode(i);
+ for (int j = 0, l2 = parent->GetChildrenCount(); j < l2; ++j) {
+ if (parent->GetChild(j)->GetToNode() == node) {
+ ++count;
+ }
+ }
+ }
+ return count;
+}
+
+
+TEST(ArrayBufferSharedBackingStore) {
Dmitry Lomov (no reviews) 2014/02/17 15:26:36 I'd prefer a test that allocates ArrayBuffers with
+ LocalContext env;
+ v8::HandleScope scope(env->GetIsolate());
+ v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
+ CompileRun("sin1 = Math.sin(1);");
+ LocalContext env2;
+ CompileRun("sin2 = Math.sin(2);");
+ const v8::HeapSnapshot* snapshot =
+ heap_profiler->TakeHeapSnapshot(v8_str("snapshot"));
+ CHECK(ValidateSnapshot(snapshot));
+ // The 0th-child is (GC Roots), 1st is the user root.
+ const v8::HeapGraphNode* global =
+ snapshot->GetRoot()->GetChild(1)->GetToNode();
+ const v8::HeapGraphNode* builtins =
+ GetProperty(global, v8::HeapGraphEdge::kInternal, "builtins");
+ CHECK_NE(NULL, builtins);
+ const v8::HeapGraphNode* sin_table =
+ GetProperty(builtins, v8::HeapGraphEdge::kProperty, "kSinTable");
+ CHECK_NE(NULL, sin_table);
+ const v8::HeapGraphNode* buffer =
+ GetProperty(sin_table, v8::HeapGraphEdge::kInternal, "buffer");
+ CHECK_NE(NULL, buffer);
+ const v8::HeapGraphNode* backing_store =
+ GetProperty(buffer, v8::HeapGraphEdge::kInternal, "backing_store");
+ CHECK_NE(NULL, backing_store);
+ int retainers = GetRetainersCount(snapshot, backing_store);
+ CHECK_EQ(2, retainers);
+}
+
+
TEST(BoxObject) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
« 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