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

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

Issue 12033011: Add Isolate parameter to Persistent class. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Added new kind of callback Created 7 years, 11 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
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 <ctype.h> 5 #include <ctype.h>
6 6
7 #include "v8.h" 7 #include "v8.h"
8 8
9 #include "cctest.h" 9 #include "cctest.h"
10 #include "hashmap.h" 10 #include "hashmap.h"
(...skipping 1460 matching lines...) Expand 10 before | Expand all | Expand 10 after
1471 const v8::HeapGraphNode* gc_roots = GetNode( 1471 const v8::HeapGraphNode* gc_roots = GetNode(
1472 snapshot->GetRoot(), v8::HeapGraphNode::kObject, "(GC roots)"); 1472 snapshot->GetRoot(), v8::HeapGraphNode::kObject, "(GC roots)");
1473 CHECK_NE(NULL, gc_roots); 1473 CHECK_NE(NULL, gc_roots);
1474 const v8::HeapGraphNode* global_handles = GetNode( 1474 const v8::HeapGraphNode* global_handles = GetNode(
1475 gc_roots, v8::HeapGraphNode::kObject, "(Global handles)"); 1475 gc_roots, v8::HeapGraphNode::kObject, "(Global handles)");
1476 CHECK_NE(NULL, global_handles); 1476 CHECK_NE(NULL, global_handles);
1477 return HasWeakEdge(global_handles); 1477 return HasWeakEdge(global_handles);
1478 } 1478 }
1479 1479
1480 1480
1481 static void PersistentHandleCallback(v8::Persistent<v8::Value> handle, void*) { 1481 static void PersistentHandleCallback(v8::Isolate* isolate,
1482 handle.Dispose(); 1482 v8::Persistent<v8::Value> handle,
1483 void*) {
1484 handle.Dispose(isolate);
1483 } 1485 }
1484 1486
1485 1487
1486 TEST(WeakGlobalHandle) { 1488 TEST(WeakGlobalHandle) {
1487 v8::HandleScope scope; 1489 v8::HandleScope scope;
1488 LocalContext env; 1490 LocalContext env;
1489 1491
1490 CHECK(!HasWeakGlobalHandle()); 1492 CHECK(!HasWeakGlobalHandle());
1491 1493
1492 v8::Persistent<v8::Object> handle = 1494 v8::Persistent<v8::Object> handle =
1493 v8::Persistent<v8::Object>::New(v8::Object::New()); 1495 v8::Persistent<v8::Object>::New(v8::Object::New());
1494 handle.MakeWeak(NULL, PersistentHandleCallback); 1496 handle.MakeWeak(env->GetIsolate(), NULL, PersistentHandleCallback);
1495 1497
1496 CHECK(HasWeakGlobalHandle()); 1498 CHECK(HasWeakGlobalHandle());
1497 } 1499 }
1498 1500
1499 1501
1500 TEST(WeakNativeContextRefs) { 1502 TEST(WeakNativeContextRefs) {
1501 v8::HandleScope scope; 1503 v8::HandleScope scope;
1502 LocalContext env; 1504 LocalContext env;
1503 1505
1504 const v8::HeapSnapshot* snapshot = 1506 const v8::HeapSnapshot* snapshot =
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1577 v8::Persistent<v8::String> p_BBB = 1579 v8::Persistent<v8::String> p_BBB =
1578 v8::Persistent<v8::String>::New(v8_str("BBB")); 1580 v8::Persistent<v8::String>::New(v8_str("BBB"));
1579 CHECK_EQ(global_handle_count + 2, 1581 CHECK_EQ(global_handle_count + 2,
1580 v8::HeapProfiler::GetPersistentHandleCount()); 1582 v8::HeapProfiler::GetPersistentHandleCount());
1581 v8::Persistent<v8::String> p_CCC = 1583 v8::Persistent<v8::String> p_CCC =
1582 v8::Persistent<v8::String>::New(v8_str("CCC")); 1584 v8::Persistent<v8::String>::New(v8_str("CCC"));
1583 CHECK_EQ(global_handle_count + 3, 1585 CHECK_EQ(global_handle_count + 3,
1584 v8::HeapProfiler::GetPersistentHandleCount()); 1586 v8::HeapProfiler::GetPersistentHandleCount());
1585 1587
1586 // Dipose the persistent handles in a different order. 1588 // Dipose the persistent handles in a different order.
1587 p_AAA.Dispose(); 1589 p_AAA.Dispose(env->GetIsolate());
1588 CHECK_EQ(global_handle_count + 2, 1590 CHECK_EQ(global_handle_count + 2,
1589 v8::HeapProfiler::GetPersistentHandleCount()); 1591 v8::HeapProfiler::GetPersistentHandleCount());
1590 p_CCC.Dispose(); 1592 p_CCC.Dispose(env->GetIsolate());
1591 CHECK_EQ(global_handle_count + 1, 1593 CHECK_EQ(global_handle_count + 1,
1592 v8::HeapProfiler::GetPersistentHandleCount()); 1594 v8::HeapProfiler::GetPersistentHandleCount());
1593 p_BBB.Dispose(); 1595 p_BBB.Dispose(env->GetIsolate());
1594 CHECK_EQ(global_handle_count, v8::HeapProfiler::GetPersistentHandleCount()); 1596 CHECK_EQ(global_handle_count, v8::HeapProfiler::GetPersistentHandleCount());
1595 } 1597 }
1596 1598
1597 1599
1598 TEST(AllStrongGcRootsHaveNames) { 1600 TEST(AllStrongGcRootsHaveNames) {
1599 v8::HandleScope scope; 1601 v8::HandleScope scope;
1600 LocalContext env; 1602 LocalContext env;
1601 1603
1602 CompileRun("foo = {};"); 1604 CompileRun("foo = {};");
1603 const v8::HeapSnapshot* snapshot = 1605 const v8::HeapSnapshot* snapshot =
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1650 const v8::HeapGraphNode* map = 1652 const v8::HeapGraphNode* map =
1651 GetProperty(global_object, v8::HeapGraphEdge::kInternal, "map"); 1653 GetProperty(global_object, v8::HeapGraphEdge::kInternal, "map");
1652 CHECK_NE(NULL, map); 1654 CHECK_NE(NULL, map);
1653 const v8::HeapGraphNode* own_descriptors = GetProperty( 1655 const v8::HeapGraphNode* own_descriptors = GetProperty(
1654 map, v8::HeapGraphEdge::kInternal, "descriptors"); 1656 map, v8::HeapGraphEdge::kInternal, "descriptors");
1655 CHECK_NE(NULL, own_descriptors); 1657 CHECK_NE(NULL, own_descriptors);
1656 const v8::HeapGraphNode* own_transitions = GetProperty( 1658 const v8::HeapGraphNode* own_transitions = GetProperty(
1657 map, v8::HeapGraphEdge::kInternal, "transitions"); 1659 map, v8::HeapGraphEdge::kInternal, "transitions");
1658 CHECK_EQ(NULL, own_transitions); 1660 CHECK_EQ(NULL, own_transitions);
1659 } 1661 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698