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

Side by Side Diff: sky/engine/platform/heap/ThreadState.cpp

Issue 683593002: Remove GarbageCollected support from the bindings (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « sky/engine/platform/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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 ASSERT_NOT_REACHED(); 75 ASSERT_NOT_REACHED();
76 return 0; 76 return 0;
77 #endif 77 #endif
78 #elif OS(MACOSX) 78 #elif OS(MACOSX)
79 return pthread_get_stackaddr_np(pthread_self()); 79 return pthread_get_stackaddr_np(pthread_self());
80 #else 80 #else
81 #error Unsupported getStackStart on this platform. 81 #error Unsupported getStackStart on this platform.
82 #endif 82 #endif
83 } 83 }
84 84
85 // The maximum number of WrapperPersistentRegions to keep around in the
86 // m_pooledWrapperPersistentRegions pool.
87 static const size_t MaxPooledWrapperPersistentRegionCount = 2;
88
89 WTF::ThreadSpecific<ThreadState*>* ThreadState::s_threadSpecific = 0; 85 WTF::ThreadSpecific<ThreadState*>* ThreadState::s_threadSpecific = 0;
90 uint8_t ThreadState::s_mainThreadStateStorage[sizeof(ThreadState)]; 86 uint8_t ThreadState::s_mainThreadStateStorage[sizeof(ThreadState)];
91 SafePointBarrier* ThreadState::s_safePointBarrier = 0; 87 SafePointBarrier* ThreadState::s_safePointBarrier = 0;
92 bool ThreadState::s_inGC = false; 88 bool ThreadState::s_inGC = false;
93 89
94 static Mutex& threadAttachMutex() 90 static Mutex& threadAttachMutex()
95 { 91 {
96 AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex); 92 AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex);
97 return mutex; 93 return mutex;
98 } 94 }
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 InitializeHeaps<index>::init(heaps, state); 186 InitializeHeaps<index>::init(heaps, state);
191 heaps[index] = new typename HeapIndexTrait<index>::HeapType(state, index ); 187 heaps[index] = new typename HeapIndexTrait<index>::HeapType(state, index );
192 } 188 }
193 }; 189 };
194 template<> struct InitializeHeaps<0> { 190 template<> struct InitializeHeaps<0> {
195 static void init(BaseHeap** heaps, ThreadState* state) { } 191 static void init(BaseHeap** heaps, ThreadState* state) { }
196 }; 192 };
197 193
198 ThreadState::ThreadState() 194 ThreadState::ThreadState()
199 : m_thread(currentThread()) 195 : m_thread(currentThread())
200 , m_liveWrapperPersistents(new WrapperPersistentRegion())
201 , m_pooledWrapperPersistents(0)
202 , m_pooledWrapperPersistentRegionCount(0)
203 , m_persistents(adoptPtr(new PersistentAnchor())) 196 , m_persistents(adoptPtr(new PersistentAnchor()))
204 , m_startOfStack(reinterpret_cast<intptr_t*>(getStackStart())) 197 , m_startOfStack(reinterpret_cast<intptr_t*>(getStackStart()))
205 , m_endOfStack(reinterpret_cast<intptr_t*>(getStackStart())) 198 , m_endOfStack(reinterpret_cast<intptr_t*>(getStackStart()))
206 , m_safePointScopeMarker(0) 199 , m_safePointScopeMarker(0)
207 , m_atSafePoint(false) 200 , m_atSafePoint(false)
208 , m_interruptors() 201 , m_interruptors()
209 , m_gcRequested(false) 202 , m_gcRequested(false)
210 , m_forcePreciseGCForTesting(false) 203 , m_forcePreciseGCForTesting(false)
211 , m_sweepRequested(0) 204 , m_sweepRequested(0)
212 , m_sweepInProgress(false) 205 , m_sweepInProgress(false)
(...skipping 15 matching lines...) Expand all
228 CallbackStack::init(&m_weakCallbackStack); 221 CallbackStack::init(&m_weakCallbackStack);
229 } 222 }
230 223
231 ThreadState::~ThreadState() 224 ThreadState::~ThreadState()
232 { 225 {
233 checkThread(); 226 checkThread();
234 CallbackStack::shutdown(&m_weakCallbackStack); 227 CallbackStack::shutdown(&m_weakCallbackStack);
235 for (int i = 0; i < NumberOfHeaps; i++) 228 for (int i = 0; i < NumberOfHeaps; i++)
236 delete m_heaps[i]; 229 delete m_heaps[i];
237 deleteAllValues(m_interruptors); 230 deleteAllValues(m_interruptors);
238 while (m_liveWrapperPersistents) {
239 WrapperPersistentRegion* region = WrapperPersistentRegion::removeHead(&m _liveWrapperPersistents);
240 delete region;
241 }
242 while (m_pooledWrapperPersistents) {
243 WrapperPersistentRegion* region = WrapperPersistentRegion::removeHead(&m _pooledWrapperPersistents);
244 delete region;
245 }
246 **s_threadSpecific = 0; 231 **s_threadSpecific = 0;
247 } 232 }
248 233
249 void ThreadState::attach() 234 void ThreadState::attach()
250 { 235 {
251 RELEASE_ASSERT(!Heap::s_shutdownCalled); 236 RELEASE_ASSERT(!Heap::s_shutdownCalled);
252 MutexLocker locker(threadAttachMutex()); 237 MutexLocker locker(threadAttachMutex());
253 ThreadState* state = new ThreadState(); 238 ThreadState* state = new ThreadState();
254 attachedThreads().add(state); 239 attachedThreads().add(state);
255 } 240 }
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 __msan_unpoison(&ptr, sizeof(ptr)); 388 __msan_unpoison(&ptr, sizeof(ptr));
404 #endif 389 #endif
405 Heap::checkAndMarkPointer(visitor, ptr); 390 Heap::checkAndMarkPointer(visitor, ptr);
406 visitAsanFakeStackForPointer(visitor, ptr); 391 visitAsanFakeStackForPointer(visitor, ptr);
407 } 392 }
408 } 393 }
409 394
410 void ThreadState::visitPersistents(Visitor* visitor) 395 void ThreadState::visitPersistents(Visitor* visitor)
411 { 396 {
412 m_persistents->trace(visitor); 397 m_persistents->trace(visitor);
413 WrapperPersistentRegion::trace(m_liveWrapperPersistents, visitor);
414 } 398 }
415 399
416 bool ThreadState::checkAndMarkPointer(Visitor* visitor, Address address) 400 bool ThreadState::checkAndMarkPointer(Visitor* visitor, Address address)
417 { 401 {
418 // If thread is terminating ignore conservative pointers. 402 // If thread is terminating ignore conservative pointers.
419 if (m_isTerminating) 403 if (m_isTerminating)
420 return false; 404 return false;
421 405
422 // This checks for normal pages and for large objects which span the extent 406 // This checks for normal pages and for large objects which span the extent
423 // of several normal pages. 407 // of several normal pages.
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 { 507 {
524 CallbackStack::Item* slot = m_weakCallbackStack->allocateEntry(&m_weakCallba ckStack); 508 CallbackStack::Item* slot = m_weakCallbackStack->allocateEntry(&m_weakCallba ckStack);
525 *slot = CallbackStack::Item(object, callback); 509 *slot = CallbackStack::Item(object, callback);
526 } 510 }
527 511
528 bool ThreadState::popAndInvokeWeakPointerCallback(Visitor* visitor) 512 bool ThreadState::popAndInvokeWeakPointerCallback(Visitor* visitor)
529 { 513 {
530 return m_weakCallbackStack->popAndInvokeCallback<WeaknessProcessing>(&m_weak CallbackStack, visitor); 514 return m_weakCallbackStack->popAndInvokeCallback<WeaknessProcessing>(&m_weak CallbackStack, visitor);
531 } 515 }
532 516
533 WrapperPersistentRegion* ThreadState::takeWrapperPersistentRegion()
534 {
535 WrapperPersistentRegion* region;
536 if (m_pooledWrapperPersistentRegionCount) {
537 region = WrapperPersistentRegion::removeHead(&m_pooledWrapperPersistents );
538 m_pooledWrapperPersistentRegionCount--;
539 } else {
540 region = new WrapperPersistentRegion();
541 }
542 ASSERT(region);
543 WrapperPersistentRegion::insertHead(&m_liveWrapperPersistents, region);
544 return region;
545 }
546
547 void ThreadState::freeWrapperPersistentRegion(WrapperPersistentRegion* region)
548 {
549 if (!region->removeIfNotLast(&m_liveWrapperPersistents))
550 return;
551
552 // Region was removed, ie. it was not the last region in the list.
553 if (m_pooledWrapperPersistentRegionCount < MaxPooledWrapperPersistentRegionC ount) {
554 WrapperPersistentRegion::insertHead(&m_pooledWrapperPersistents, region) ;
555 m_pooledWrapperPersistentRegionCount++;
556 } else {
557 delete region;
558 }
559 }
560
561 PersistentNode* ThreadState::globalRoots() 517 PersistentNode* ThreadState::globalRoots()
562 { 518 {
563 AtomicallyInitializedStatic(PersistentNode*, anchor = new PersistentAnchor); 519 AtomicallyInitializedStatic(PersistentNode*, anchor = new PersistentAnchor);
564 return anchor; 520 return anchor;
565 } 521 }
566 522
567 Mutex& ThreadState::globalRootsMutex() 523 Mutex& ThreadState::globalRootsMutex()
568 { 524 {
569 AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex); 525 AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex);
570 return mutex; 526 return mutex;
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 return gcInfo; 889 return gcInfo;
934 } 890 }
935 } 891 }
936 if (needLockForIteration) 892 if (needLockForIteration)
937 threadAttachMutex().unlock(); 893 threadAttachMutex().unlock();
938 return 0; 894 return 0;
939 } 895 }
940 #endif 896 #endif
941 897
942 } 898 }
OLDNEW
« no previous file with comments | « sky/engine/platform/heap/ThreadState.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698