OLD | NEW |
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 1587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1598 } | 1598 } |
1599 | 1599 |
1600 | 1600 |
1601 TEST(WeakGlobalHandle) { | 1601 TEST(WeakGlobalHandle) { |
1602 LocalContext env; | 1602 LocalContext env; |
1603 v8::HandleScope scope(env->GetIsolate()); | 1603 v8::HandleScope scope(env->GetIsolate()); |
1604 | 1604 |
1605 CHECK(!HasWeakGlobalHandle()); | 1605 CHECK(!HasWeakGlobalHandle()); |
1606 | 1606 |
1607 v8::Persistent<v8::Object> handle(env->GetIsolate(), v8::Object::New()); | 1607 v8::Persistent<v8::Object> handle(env->GetIsolate(), v8::Object::New()); |
1608 handle.MakeWeak<v8::Value, void>(env->GetIsolate(), | 1608 handle.MakeWeak<v8::Value, void>(NULL, PersistentHandleCallback); |
1609 NULL, | |
1610 PersistentHandleCallback); | |
1611 | 1609 |
1612 CHECK(HasWeakGlobalHandle()); | 1610 CHECK(HasWeakGlobalHandle()); |
1613 } | 1611 } |
1614 | 1612 |
1615 | 1613 |
1616 TEST(WeakNativeContextRefs) { | 1614 TEST(WeakNativeContextRefs) { |
1617 LocalContext env; | 1615 LocalContext env; |
1618 v8::HandleScope scope(env->GetIsolate()); | 1616 v8::HandleScope scope(env->GetIsolate()); |
1619 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); | 1617 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); |
1620 | 1618 |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1782 // Check all the objects have got their names. | 1780 // Check all the objects have got their names. |
1783 // ... well check just every 8th because otherwise it's too slow in debug. | 1781 // ... well check just every 8th because otherwise it's too slow in debug. |
1784 for (int i = 0; i < num_objects - 1; i += 8) { | 1782 for (int i = 0; i < num_objects - 1; i += 8) { |
1785 i::EmbeddedVector<char, 100> var_name; | 1783 i::EmbeddedVector<char, 100> var_name; |
1786 i::OS::SNPrintF(var_name, "f_%d", i); | 1784 i::OS::SNPrintF(var_name, "f_%d", i); |
1787 const v8::HeapGraphNode* f_object = GetProperty( | 1785 const v8::HeapGraphNode* f_object = GetProperty( |
1788 context_object, v8::HeapGraphEdge::kContextVariable, var_name.start()); | 1786 context_object, v8::HeapGraphEdge::kContextVariable, var_name.start()); |
1789 CHECK_NE(NULL, f_object); | 1787 CHECK_NE(NULL, f_object); |
1790 } | 1788 } |
1791 } | 1789 } |
OLD | NEW |