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

Side by Side Diff: Source/heap/ThreadState.cpp

Issue 183683017: Use OwnPtrs for heap contains cache and persistent anchor. We were leaking the HeapContainsCache. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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 | « Source/heap/ThreadState.h ('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 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 222
223 volatile int m_canResume; 223 volatile int m_canResume;
224 volatile int m_unparkedThreadCount; 224 volatile int m_unparkedThreadCount;
225 Mutex m_mutex; 225 Mutex m_mutex;
226 ThreadCondition m_parked; 226 ThreadCondition m_parked;
227 ThreadCondition m_resume; 227 ThreadCondition m_resume;
228 }; 228 };
229 229
230 ThreadState::ThreadState() 230 ThreadState::ThreadState()
231 : m_thread(currentThread()) 231 : m_thread(currentThread())
232 , m_persistents(adoptPtr(new PersistentAnchor()))
232 , m_startOfStack(reinterpret_cast<intptr_t*>(getStackStart())) 233 , m_startOfStack(reinterpret_cast<intptr_t*>(getStackStart()))
233 , m_endOfStack(reinterpret_cast<intptr_t*>(getStackStart())) 234 , m_endOfStack(reinterpret_cast<intptr_t*>(getStackStart()))
234 , m_safePointScopeMarker(0) 235 , m_safePointScopeMarker(0)
235 , m_atSafePoint(false) 236 , m_atSafePoint(false)
236 , m_interruptors() 237 , m_interruptors()
237 , m_gcRequested(false) 238 , m_gcRequested(false)
238 , m_sweepRequested(0) 239 , m_sweepRequested(0)
239 , m_sweepInProgress(false) 240 , m_sweepInProgress(false)
240 , m_noAllocationCount(0) 241 , m_noAllocationCount(0)
241 , m_inGC(false) 242 , m_inGC(false)
242 , m_heapContainsCache(new HeapContainsCache()) 243 , m_heapContainsCache(adoptPtr(new HeapContainsCache()))
243 , m_isCleaningUp(false) 244 , m_isCleaningUp(false)
244 { 245 {
245 ASSERT(!**s_threadSpecific); 246 ASSERT(!**s_threadSpecific);
246 **s_threadSpecific = this; 247 **s_threadSpecific = this;
247 248
248 m_persistents = new PersistentAnchor();
249 m_stats.clear(); 249 m_stats.clear();
250 m_statsAfterLastGC.clear(); 250 m_statsAfterLastGC.clear();
251 // First allocate the general heap, second iterate through to 251 // First allocate the general heap, second iterate through to
252 // allocate the type specific heaps 252 // allocate the type specific heaps
253 m_heaps[GeneralHeap] = new ThreadHeap<FinalizedHeapObjectHeader>(this); 253 m_heaps[GeneralHeap] = new ThreadHeap<FinalizedHeapObjectHeader>(this);
254 for (int i = GeneralHeap + 1; i < NumberOfHeaps; i++) 254 for (int i = GeneralHeap + 1; i < NumberOfHeaps; i++)
255 m_heaps[i] = new ThreadHeap<HeapObjectHeader>(this); 255 m_heaps[i] = new ThreadHeap<HeapObjectHeader>(this);
256 } 256 }
257 257
258 ThreadState::~ThreadState() 258 ThreadState::~ThreadState()
259 { 259 {
260 checkThread(); 260 checkThread();
261 for (int i = GeneralHeap; i < NumberOfHeaps; i++) 261 for (int i = GeneralHeap; i < NumberOfHeaps; i++)
262 delete m_heaps[i]; 262 delete m_heaps[i];
263 delete m_persistents;
264 m_persistents = 0;
265 deleteAllValues(m_interruptors); 263 deleteAllValues(m_interruptors);
266 **s_threadSpecific = 0; 264 **s_threadSpecific = 0;
267 } 265 }
268 266
269 void ThreadState::init() 267 void ThreadState::init()
270 { 268 {
271 s_threadSpecific = new WTF::ThreadSpecific<ThreadState*>(); 269 s_threadSpecific = new WTF::ThreadSpecific<ThreadState*>();
272 s_safePointBarrier = new SafePointBarrier; 270 s_safePointBarrier = new SafePointBarrier;
273 new(s_mainThreadStateStorage) ThreadState(); 271 new(s_mainThreadStateStorage) ThreadState();
274 attachedThreads().add(mainThreadState()); 272 attachedThreads().add(mainThreadState());
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 state->safePoint(HeapPointersOnStack); 700 state->safePoint(HeapPointersOnStack);
703 } 701 }
704 702
705 ThreadState::AttachedThreadStateSet& ThreadState::attachedThreads() 703 ThreadState::AttachedThreadStateSet& ThreadState::attachedThreads()
706 { 704 {
707 DEFINE_STATIC_LOCAL(AttachedThreadStateSet, threads, ()); 705 DEFINE_STATIC_LOCAL(AttachedThreadStateSet, threads, ());
708 return threads; 706 return threads;
709 } 707 }
710 708
711 } 709 }
OLDNEW
« no previous file with comments | « Source/heap/ThreadState.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698