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

Side by Side Diff: third_party/WebKit/Source/platform/heap/StackFrameDepth.cpp

Issue 2619493003: Replace ASSERTs in platform/heap/ with DCHECKs
Patch Set: temp Created 3 years, 11 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/heap/StackFrameDepth.h" 5 #include "platform/heap/StackFrameDepth.h"
6 6
7 #include "public/platform/Platform.h" 7 #include "public/platform/Platform.h"
8 8
9 #if OS(WIN) 9 #if OS(WIN)
10 #include <stddef.h> 10 #include <stddef.h>
(...skipping 29 matching lines...) Expand all
40 // except if ASan is enabled. 40 // except if ASan is enabled.
41 size_t stackSize = getUnderestimatedStackSize(); 41 size_t stackSize = getUnderestimatedStackSize();
42 if (!stackSize) { 42 if (!stackSize) {
43 m_stackFrameLimit = getFallbackStackLimit(); 43 m_stackFrameLimit = getFallbackStackLimit();
44 return; 44 return;
45 } 45 }
46 46
47 static const int kStackRoomSize = 1024; 47 static const int kStackRoomSize = 1024;
48 48
49 Address stackBase = reinterpret_cast<Address>(getStackStart()); 49 Address stackBase = reinterpret_cast<Address>(getStackStart());
50 RELEASE_ASSERT(stackSize > static_cast<const size_t>(kStackRoomSize)); 50 CHECK(stackSize > static_cast<const size_t>(kStackRoomSize));
51 size_t stackRoom = stackSize - kStackRoomSize; 51 size_t stackRoom = stackSize - kStackRoomSize;
52 RELEASE_ASSERT(stackBase > reinterpret_cast<Address>(stackRoom)); 52 CHECK(stackBase > reinterpret_cast<Address>(stackRoom));
53 m_stackFrameLimit = reinterpret_cast<uintptr_t>(stackBase - stackRoom); 53 m_stackFrameLimit = reinterpret_cast<uintptr_t>(stackBase - stackRoom);
54 54
55 // If current stack use is already exceeding estimated limit, mark as 55 // If current stack use is already exceeding estimated limit, mark as
56 // disabled. 56 // disabled.
57 if (!isSafeToRecurse()) 57 if (!isSafeToRecurse())
58 disableStackLimit(); 58 disableStackLimit();
59 } 59 }
60 60
61 size_t StackFrameDepth::getUnderestimatedStackSize() { 61 size_t StackFrameDepth::getUnderestimatedStackSize() {
62 // FIXME: ASAN bot uses a fake stack as a thread stack frame, 62 // FIXME: ASAN bot uses a fake stack as a thread stack frame,
(...skipping 15 matching lines...) Expand all
78 #if OS(FREEBSD) 78 #if OS(FREEBSD)
79 pthread_attr_init(&attr); 79 pthread_attr_init(&attr);
80 error = pthread_attr_get_np(pthread_self(), &attr); 80 error = pthread_attr_get_np(pthread_self(), &attr);
81 #else 81 #else
82 error = pthread_getattr_np(pthread_self(), &attr); 82 error = pthread_getattr_np(pthread_self(), &attr);
83 #endif 83 #endif
84 if (!error) { 84 if (!error) {
85 void* base; 85 void* base;
86 size_t size; 86 size_t size;
87 error = pthread_attr_getstack(&attr, &base, &size); 87 error = pthread_attr_getstack(&attr, &base, &size);
88 RELEASE_ASSERT(!error); 88 CHECK(!error);
89 pthread_attr_destroy(&attr); 89 pthread_attr_destroy(&attr);
90 return size; 90 return size;
91 } 91 }
92 #if OS(FREEBSD) 92 #if OS(FREEBSD)
93 pthread_attr_destroy(&attr); 93 pthread_attr_destroy(&attr);
94 #endif 94 #endif
95 95
96 // Return a 512k stack size, (conservatively) assuming the following: 96 // Return a 512k stack size, (conservatively) assuming the following:
97 // - that size is much lower than the pthreads default (x86 pthreads has a 2M 97 // - that size is much lower than the pthreads default (x86 pthreads has a 2M
98 // default.) 98 // default.)
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 #if OS(FREEBSD) 141 #if OS(FREEBSD)
142 pthread_attr_init(&attr); 142 pthread_attr_init(&attr);
143 error = pthread_attr_get_np(pthread_self(), &attr); 143 error = pthread_attr_get_np(pthread_self(), &attr);
144 #else 144 #else
145 error = pthread_getattr_np(pthread_self(), &attr); 145 error = pthread_getattr_np(pthread_self(), &attr);
146 #endif 146 #endif
147 if (!error) { 147 if (!error) {
148 void* base; 148 void* base;
149 size_t size; 149 size_t size;
150 error = pthread_attr_getstack(&attr, &base, &size); 150 error = pthread_attr_getstack(&attr, &base, &size);
151 RELEASE_ASSERT(!error); 151 CHECK(!error);
152 pthread_attr_destroy(&attr); 152 pthread_attr_destroy(&attr);
153 return reinterpret_cast<uint8_t*>(base) + size; 153 return reinterpret_cast<uint8_t*>(base) + size;
154 } 154 }
155 #if OS(FREEBSD) 155 #if OS(FREEBSD)
156 pthread_attr_destroy(&attr); 156 pthread_attr_destroy(&attr);
157 #endif 157 #endif
158 #if defined(__GLIBC__) 158 #if defined(__GLIBC__)
159 // pthread_getattr_np can fail for the main thread. In this case 159 // pthread_getattr_np can fail for the main thread. In this case
160 // just like NaCl we rely on the __libc_stack_end to give us 160 // just like NaCl we rely on the __libc_stack_end to give us
161 // the start of the stack. 161 // the start of the stack.
162 // See https://code.google.com/p/nativeclient/issues/detail?id=3431. 162 // See https://code.google.com/p/nativeclient/issues/detail?id=3431.
163 return __libc_stack_end; 163 return __libc_stack_end;
164 #else 164 #else
165 ASSERT_NOT_REACHED(); 165 NOTREACHED();
166 return nullptr; 166 return nullptr;
167 #endif 167 #endif
168 #elif OS(MACOSX) 168 #elif OS(MACOSX)
169 return pthread_get_stackaddr_np(pthread_self()); 169 return pthread_get_stackaddr_np(pthread_self());
170 #elif OS(WIN) && COMPILER(MSVC) 170 #elif OS(WIN) && COMPILER(MSVC)
171 // On Windows stack limits for the current thread are available in 171 // On Windows stack limits for the current thread are available in
172 // the thread information block (TIB). Its fields can be accessed through 172 // the thread information block (TIB). Its fields can be accessed through
173 // FS segment register on x86 and GS segment register on x86_64. 173 // FS segment register on x86 and GS segment register on x86_64.
174 #ifdef _WIN64 174 #ifdef _WIN64
175 return reinterpret_cast<void*>(__readgsqword(offsetof(NT_TIB64, StackBase))); 175 return reinterpret_cast<void*>(__readgsqword(offsetof(NT_TIB64, StackBase)));
176 #else 176 #else
177 return reinterpret_cast<void*>(__readfsdword(offsetof(NT_TIB, StackBase))); 177 return reinterpret_cast<void*>(__readfsdword(offsetof(NT_TIB, StackBase)));
178 #endif 178 #endif
179 #else 179 #else
180 #error Unsupported getStackStart on this platform. 180 #error Unsupported getStackStart on this platform.
181 #endif 181 #endif
182 } 182 }
183 183
184 } // namespace blink 184 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698