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

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

Issue 14908004: add weakcallback without persistent copying (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: missed some instances Created 7 years, 7 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 | « test/cctest/test-heap.cc ('k') | test/cctest/test-mark-compact.cc » ('j') | 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 1568 matching lines...) Expand 10 before | Expand all | Expand 10 after
1579 snapshot->GetRoot(), v8::HeapGraphNode::kObject, "(GC roots)"); 1579 snapshot->GetRoot(), v8::HeapGraphNode::kObject, "(GC roots)");
1580 CHECK_NE(NULL, gc_roots); 1580 CHECK_NE(NULL, gc_roots);
1581 const v8::HeapGraphNode* global_handles = GetNode( 1581 const v8::HeapGraphNode* global_handles = GetNode(
1582 gc_roots, v8::HeapGraphNode::kObject, "(Global handles)"); 1582 gc_roots, v8::HeapGraphNode::kObject, "(Global handles)");
1583 CHECK_NE(NULL, global_handles); 1583 CHECK_NE(NULL, global_handles);
1584 return HasWeakEdge(global_handles); 1584 return HasWeakEdge(global_handles);
1585 } 1585 }
1586 1586
1587 1587
1588 static void PersistentHandleCallback(v8::Isolate* isolate, 1588 static void PersistentHandleCallback(v8::Isolate* isolate,
1589 v8::Persistent<v8::Value> handle, 1589 v8::Persistent<v8::Value>* handle,
1590 void*) { 1590 void*) {
1591 handle.Dispose(isolate); 1591 handle->Dispose(isolate);
1592 } 1592 }
1593 1593
1594 1594
1595 TEST(WeakGlobalHandle) { 1595 TEST(WeakGlobalHandle) {
1596 LocalContext env; 1596 LocalContext env;
1597 v8::HandleScope scope(env->GetIsolate()); 1597 v8::HandleScope scope(env->GetIsolate());
1598 1598
1599 CHECK(!HasWeakGlobalHandle()); 1599 CHECK(!HasWeakGlobalHandle());
1600 1600
1601 v8::Persistent<v8::Object> handle = 1601 v8::Persistent<v8::Object> handle =
1602 v8::Persistent<v8::Object>::New(env->GetIsolate(), v8::Object::New()); 1602 v8::Persistent<v8::Object>::New(env->GetIsolate(), v8::Object::New());
1603 handle.MakeWeak(env->GetIsolate(), NULL, PersistentHandleCallback); 1603 handle.MakeWeak<v8::Value, void>(env->GetIsolate(),
1604 NULL,
1605 PersistentHandleCallback);
1604 1606
1605 CHECK(HasWeakGlobalHandle()); 1607 CHECK(HasWeakGlobalHandle());
1606 } 1608 }
1607 1609
1608 1610
1609 TEST(WeakNativeContextRefs) { 1611 TEST(WeakNativeContextRefs) {
1610 LocalContext env; 1612 LocalContext env;
1611 v8::HandleScope scope(env->GetIsolate()); 1613 v8::HandleScope scope(env->GetIsolate());
1612 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); 1614 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
1613 1615
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1775 // Check all the objects have got their names. 1777 // Check all the objects have got their names.
1776 // ... well check just every 8th because otherwise it's too slow in debug. 1778 // ... well check just every 8th because otherwise it's too slow in debug.
1777 for (int i = 0; i < num_objects - 1; i += 8) { 1779 for (int i = 0; i < num_objects - 1; i += 8) {
1778 i::EmbeddedVector<char, 100> var_name; 1780 i::EmbeddedVector<char, 100> var_name;
1779 i::OS::SNPrintF(var_name, "f_%d", i); 1781 i::OS::SNPrintF(var_name, "f_%d", i);
1780 const v8::HeapGraphNode* f_object = GetProperty( 1782 const v8::HeapGraphNode* f_object = GetProperty(
1781 context_object, v8::HeapGraphEdge::kContextVariable, var_name.start()); 1783 context_object, v8::HeapGraphEdge::kContextVariable, var_name.start());
1782 CHECK_NE(NULL, f_object); 1784 CHECK_NE(NULL, f_object);
1783 } 1785 }
1784 } 1786 }
OLDNEW
« no previous file with comments | « test/cctest/test-heap.cc ('k') | test/cctest/test-mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698