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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/heap-snapshot-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 // 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 2370 matching lines...) Expand 10 before | Expand all | Expand 10 after
2381 const v8::HeapGraphNode* first_view = 2381 const v8::HeapGraphNode* first_view =
2382 GetProperty(arr1_buffer, v8::HeapGraphEdge::kWeak, "weak_first_view"); 2382 GetProperty(arr1_buffer, v8::HeapGraphEdge::kWeak, "weak_first_view");
2383 CHECK_NE(NULL, first_view); 2383 CHECK_NE(NULL, first_view);
2384 const v8::HeapGraphNode* backing_store = 2384 const v8::HeapGraphNode* backing_store =
2385 GetProperty(arr1_buffer, v8::HeapGraphEdge::kInternal, "backing_store"); 2385 GetProperty(arr1_buffer, v8::HeapGraphEdge::kInternal, "backing_store");
2386 CHECK_NE(NULL, backing_store); 2386 CHECK_NE(NULL, backing_store);
2387 CHECK_EQ(400, backing_store->GetSelfSize()); 2387 CHECK_EQ(400, backing_store->GetSelfSize());
2388 } 2388 }
2389 2389
2390 2390
2391 static int GetRetainersCount(const v8::HeapSnapshot* snapshot,
2392 const v8::HeapGraphNode* node) {
2393 int count = 0;
2394 for (int i = 0, l = snapshot->GetNodesCount(); i < l; ++i) {
2395 const v8::HeapGraphNode* parent = snapshot->GetNode(i);
2396 for (int j = 0, l2 = parent->GetChildrenCount(); j < l2; ++j) {
2397 if (parent->GetChild(j)->GetToNode() == node) {
2398 ++count;
2399 }
2400 }
2401 }
2402 return count;
2403 }
2404
2405
2406 TEST(ArrayBufferSharedBackingStore) {
Dmitry Lomov (no reviews) 2014/02/17 15:26:36 I'd prefer a test that allocates ArrayBuffers with
2407 LocalContext env;
2408 v8::HandleScope scope(env->GetIsolate());
2409 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
2410 CompileRun("sin1 = Math.sin(1);");
2411 LocalContext env2;
2412 CompileRun("sin2 = Math.sin(2);");
2413 const v8::HeapSnapshot* snapshot =
2414 heap_profiler->TakeHeapSnapshot(v8_str("snapshot"));
2415 CHECK(ValidateSnapshot(snapshot));
2416 // The 0th-child is (GC Roots), 1st is the user root.
2417 const v8::HeapGraphNode* global =
2418 snapshot->GetRoot()->GetChild(1)->GetToNode();
2419 const v8::HeapGraphNode* builtins =
2420 GetProperty(global, v8::HeapGraphEdge::kInternal, "builtins");
2421 CHECK_NE(NULL, builtins);
2422 const v8::HeapGraphNode* sin_table =
2423 GetProperty(builtins, v8::HeapGraphEdge::kProperty, "kSinTable");
2424 CHECK_NE(NULL, sin_table);
2425 const v8::HeapGraphNode* buffer =
2426 GetProperty(sin_table, v8::HeapGraphEdge::kInternal, "buffer");
2427 CHECK_NE(NULL, buffer);
2428 const v8::HeapGraphNode* backing_store =
2429 GetProperty(buffer, v8::HeapGraphEdge::kInternal, "backing_store");
2430 CHECK_NE(NULL, backing_store);
2431 int retainers = GetRetainersCount(snapshot, backing_store);
2432 CHECK_EQ(2, retainers);
2433 }
2434
2435
2391 TEST(BoxObject) { 2436 TEST(BoxObject) {
2392 v8::Isolate* isolate = CcTest::isolate(); 2437 v8::Isolate* isolate = CcTest::isolate();
2393 v8::HandleScope scope(isolate); 2438 v8::HandleScope scope(isolate);
2394 LocalContext env; 2439 LocalContext env;
2395 v8::Handle<v8::Object> global_proxy = env->Global(); 2440 v8::Handle<v8::Object> global_proxy = env->Global();
2396 v8::Handle<v8::Object> global = global_proxy->GetPrototype().As<v8::Object>(); 2441 v8::Handle<v8::Object> global = global_proxy->GetPrototype().As<v8::Object>();
2397 2442
2398 i::Factory* factory = CcTest::i_isolate()->factory(); 2443 i::Factory* factory = CcTest::i_isolate()->factory();
2399 i::Handle<i::String> string = 2444 i::Handle<i::String> string =
2400 factory->NewStringFromAscii(i::CStrVector("string")); 2445 factory->NewStringFromAscii(i::CStrVector("string"));
2401 i::Handle<i::Object> box = factory->NewBox(string); 2446 i::Handle<i::Object> box = factory->NewBox(string);
2402 global->Set(0, v8::ToApiHandle<v8::Object>(box)); 2447 global->Set(0, v8::ToApiHandle<v8::Object>(box));
2403 2448
2404 v8::HeapProfiler* heap_profiler = isolate->GetHeapProfiler(); 2449 v8::HeapProfiler* heap_profiler = isolate->GetHeapProfiler();
2405 const v8::HeapSnapshot* snapshot = 2450 const v8::HeapSnapshot* snapshot =
2406 heap_profiler->TakeHeapSnapshot(v8_str("snapshot")); 2451 heap_profiler->TakeHeapSnapshot(v8_str("snapshot"));
2407 CHECK(ValidateSnapshot(snapshot)); 2452 CHECK(ValidateSnapshot(snapshot));
2408 const v8::HeapGraphNode* global_node = GetGlobalObject(snapshot); 2453 const v8::HeapGraphNode* global_node = GetGlobalObject(snapshot);
2409 const v8::HeapGraphNode* box_node = 2454 const v8::HeapGraphNode* box_node =
2410 GetProperty(global_node, v8::HeapGraphEdge::kElement, "0"); 2455 GetProperty(global_node, v8::HeapGraphEdge::kElement, "0");
2411 CHECK_NE(NULL, box_node); 2456 CHECK_NE(NULL, box_node);
2412 v8::String::Utf8Value box_node_name(box_node->GetName()); 2457 v8::String::Utf8Value box_node_name(box_node->GetName());
2413 CHECK_EQ("system / Box", *box_node_name); 2458 CHECK_EQ("system / Box", *box_node_name);
2414 const v8::HeapGraphNode* box_value = 2459 const v8::HeapGraphNode* box_value =
2415 GetProperty(box_node, v8::HeapGraphEdge::kInternal, "value"); 2460 GetProperty(box_node, v8::HeapGraphEdge::kInternal, "value");
2416 CHECK_NE(NULL, box_value); 2461 CHECK_NE(NULL, box_value);
2417 } 2462 }
OLDNEW
« 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