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

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

Issue 643883002: Oilpan: Avoid looking up TLS in ThreadState::current() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 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
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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 #ifdef _WIN64 103 #ifdef _WIN64
104 return reinterpret_cast<void*>(__readgsqword(offsetof(NT_TIB64, StackBase))) ; 104 return reinterpret_cast<void*>(__readgsqword(offsetof(NT_TIB64, StackBase))) ;
105 #else 105 #else
106 return reinterpret_cast<void*>(__readfsdword(offsetof(NT_TIB, StackBase))); 106 return reinterpret_cast<void*>(__readfsdword(offsetof(NT_TIB, StackBase)));
107 #endif 107 #endif
108 #else 108 #else
109 #error Unsupported getStackStart on this platform. 109 #error Unsupported getStackStart on this platform.
110 #endif 110 #endif
111 } 111 }
112 112
113 static size_t getUnderestimatedStackSize()
114 {
115 #if defined(__GLIBC__) || OS(ANDROID) || OS(FREEBSD)
116 // We cannot get the stack size in these platforms because
117 // pthread_getattr_np() can fail for the main thread.
118 // This is OK because ThreadState::current() doesn't use the stack size
119 // in these platforms.
120 return 0;
121 #elif OS(MACOSX)
122 return pthread_get_stacksize_np(pthread_self());
123 #elif OS(WIN) && COMPILER(MSVC)
124 // On Windows stack limits for the current thread are available in
125 // the thread information block (TIB). Its fields can be accessed through
126 // FS segment register on x86 and GS segment register on x86_64.
127 #ifdef _WIN64
128 return __readgsqword(offsetof(NT_TIB64, StackBase)) - __readgsqword(offsetof (NT_TIB64, StackLimit));
129 #else
130 return __readfsdword(offsetof(NT_TIB, StackBase)) - __readfsdword(offsetof(N T_TIB, StackLimit));
131 #endif
132 #else
133 return 0;
134 #endif
135 }
136
113 // The maximum number of WrapperPersistentRegions to keep around in the 137 // The maximum number of WrapperPersistentRegions to keep around in the
114 // m_pooledWrapperPersistentRegions pool. 138 // m_pooledWrapperPersistentRegions pool.
115 static const size_t MaxPooledWrapperPersistentRegionCount = 2; 139 static const size_t MaxPooledWrapperPersistentRegionCount = 2;
116 140
117 WTF::ThreadSpecific<ThreadState*>* ThreadState::s_threadSpecific = 0; 141 WTF::ThreadSpecific<ThreadState*>* ThreadState::s_threadSpecific = 0;
142 uintptr_t ThreadState::s_mainThreadStackStart = 0;
143 uintptr_t ThreadState::s_mainThreadUnderestimatedStackSize = 0;
118 uint8_t ThreadState::s_mainThreadStateStorage[sizeof(ThreadState)]; 144 uint8_t ThreadState::s_mainThreadStateStorage[sizeof(ThreadState)];
119 SafePointBarrier* ThreadState::s_safePointBarrier = 0; 145 SafePointBarrier* ThreadState::s_safePointBarrier = 0;
120 bool ThreadState::s_inGC = false; 146 bool ThreadState::s_inGC = false;
121 147
122 static Mutex& threadAttachMutex() 148 static Mutex& threadAttachMutex()
123 { 149 {
124 AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex); 150 AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex);
125 return mutex; 151 return mutex;
126 } 152 }
127 153
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 , m_shouldFlushHeapDoesNotContainCache(false) 344 , m_shouldFlushHeapDoesNotContainCache(false)
319 , m_lowCollectionRate(false) 345 , m_lowCollectionRate(false)
320 , m_numberOfSweeperTasks(0) 346 , m_numberOfSweeperTasks(0)
321 #if defined(ADDRESS_SANITIZER) 347 #if defined(ADDRESS_SANITIZER)
322 , m_asanFakeStack(__asan_get_current_fake_stack()) 348 , m_asanFakeStack(__asan_get_current_fake_stack())
323 #endif 349 #endif
324 { 350 {
325 ASSERT(!**s_threadSpecific); 351 ASSERT(!**s_threadSpecific);
326 **s_threadSpecific = this; 352 **s_threadSpecific = this;
327 353
354 if (isMainThread()) {
355 s_mainThreadStackStart = reinterpret_cast<intptr_t>(m_startOfStack);
356 s_mainThreadUnderestimatedStackSize = getUnderestimatedStackSize();
357 }
358
328 InitializeHeaps<NumberOfHeaps>::init(m_heaps, this); 359 InitializeHeaps<NumberOfHeaps>::init(m_heaps, this);
329 360
330 m_weakCallbackStack = new CallbackStack(); 361 m_weakCallbackStack = new CallbackStack();
331 362
332 if (blink::Platform::current()) 363 if (blink::Platform::current())
333 m_sweeperThread = adoptPtr(blink::Platform::current()->createThread("Bli nk GC Sweeper")); 364 m_sweeperThread = adoptPtr(blink::Platform::current()->createThread("Bli nk GC Sweeper"));
334 } 365 }
335 366
336 ThreadState::~ThreadState() 367 ThreadState::~ThreadState()
337 { 368 {
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after
1282 return gcInfo; 1313 return gcInfo;
1283 } 1314 }
1284 } 1315 }
1285 if (needLockForIteration) 1316 if (needLockForIteration)
1286 threadAttachMutex().unlock(); 1317 threadAttachMutex().unlock();
1287 return 0; 1318 return 0;
1288 } 1319 }
1289 #endif 1320 #endif
1290 1321
1291 } 1322 }
OLDNEW
« Source/platform/heap/ThreadState.h ('K') | « Source/platform/heap/ThreadState.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698