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 2013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2024 snapshot->GetRoot(), v8::HeapGraphNode::kSynthetic, "(GC roots)"); | 2024 snapshot->GetRoot(), v8::HeapGraphNode::kSynthetic, "(GC roots)"); |
2025 CHECK(gc_roots); | 2025 CHECK(gc_roots); |
2026 const v8::HeapGraphNode* global_handles = GetNode( | 2026 const v8::HeapGraphNode* global_handles = GetNode( |
2027 gc_roots, v8::HeapGraphNode::kSynthetic, "(Global handles)"); | 2027 gc_roots, v8::HeapGraphNode::kSynthetic, "(Global handles)"); |
2028 CHECK(global_handles); | 2028 CHECK(global_handles); |
2029 return HasWeakEdge(global_handles); | 2029 return HasWeakEdge(global_handles); |
2030 } | 2030 } |
2031 | 2031 |
2032 | 2032 |
2033 static void PersistentHandleCallback( | 2033 static void PersistentHandleCallback( |
2034 const v8::WeakCallbackData<v8::Object, v8::Persistent<v8::Object> >& data) { | 2034 const v8::WeakCallbackInfo<v8::Persistent<v8::Object> >& data) { |
2035 data.GetParameter()->Reset(); | 2035 data.GetParameter()->Reset(); |
2036 delete data.GetParameter(); | |
2037 } | 2036 } |
2038 | 2037 |
2039 | 2038 |
2040 TEST(WeakGlobalHandle) { | 2039 TEST(WeakGlobalHandle) { |
2041 LocalContext env; | 2040 LocalContext env; |
2042 v8::HandleScope scope(env->GetIsolate()); | 2041 v8::HandleScope scope(env->GetIsolate()); |
2043 | 2042 |
2044 CHECK(!HasWeakGlobalHandle()); | 2043 CHECK(!HasWeakGlobalHandle()); |
2045 | 2044 |
2046 v8::Persistent<v8::Object> handle(env->GetIsolate(), | 2045 v8::Persistent<v8::Object> handle(env->GetIsolate(), |
2047 v8::Object::New(env->GetIsolate())); | 2046 v8::Object::New(env->GetIsolate())); |
2048 handle.SetWeak(&handle, PersistentHandleCallback); | 2047 handle.SetWeak(&handle, PersistentHandleCallback, |
| 2048 v8::WeakCallbackType::kParameter); |
2049 | 2049 |
2050 CHECK(HasWeakGlobalHandle()); | 2050 CHECK(HasWeakGlobalHandle()); |
2051 } | 2051 } |
2052 | 2052 |
2053 | 2053 |
2054 TEST(SfiAndJsFunctionWeakRefs) { | 2054 TEST(SfiAndJsFunctionWeakRefs) { |
2055 LocalContext env; | 2055 LocalContext env; |
2056 v8::HandleScope scope(env->GetIsolate()); | 2056 v8::HandleScope scope(env->GetIsolate()); |
2057 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); | 2057 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); |
2058 | 2058 |
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2759 map.AddRange(ToAddress(0x180), 0x80, 6U); | 2759 map.AddRange(ToAddress(0x180), 0x80, 6U); |
2760 map.AddRange(ToAddress(0x180), 0x80, 7U); | 2760 map.AddRange(ToAddress(0x180), 0x80, 7U); |
2761 CHECK_EQ(7u, map.GetTraceNodeId(ToAddress(0x180))); | 2761 CHECK_EQ(7u, map.GetTraceNodeId(ToAddress(0x180))); |
2762 CHECK_EQ(5u, map.GetTraceNodeId(ToAddress(0x200))); | 2762 CHECK_EQ(5u, map.GetTraceNodeId(ToAddress(0x200))); |
2763 CHECK_EQ(3u, map.size()); | 2763 CHECK_EQ(3u, map.size()); |
2764 | 2764 |
2765 map.Clear(); | 2765 map.Clear(); |
2766 CHECK_EQ(0u, map.size()); | 2766 CHECK_EQ(0u, map.size()); |
2767 CHECK_EQ(0u, map.GetTraceNodeId(ToAddress(0x400))); | 2767 CHECK_EQ(0u, map.GetTraceNodeId(ToAddress(0x400))); |
2768 } | 2768 } |
OLD | NEW |