OLD | NEW |
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 "config.h" | 5 #include "config.h" |
6 #include "platform/heap/StackFrameDepth.h" | 6 #include "platform/heap/StackFrameDepth.h" |
7 | 7 |
8 #include "public/platform/Platform.h" | 8 #include "public/platform/Platform.h" |
9 | 9 |
10 #if OS(WIN) | 10 #if OS(WIN) |
(...skipping 24 matching lines...) Expand all Loading... |
35 void StackFrameDepth::enableStackLimit() | 35 void StackFrameDepth::enableStackLimit() |
36 { | 36 { |
37 #if ENABLE(ASSERT) | 37 #if ENABLE(ASSERT) |
38 s_isEnabled = true; | 38 s_isEnabled = true; |
39 #endif | 39 #endif |
40 | 40 |
41 static const int kStackRoomSize = 1024; | 41 static const int kStackRoomSize = 1024; |
42 | 42 |
43 size_t stackSize = getUnderestimatedStackSize(); | 43 size_t stackSize = getUnderestimatedStackSize(); |
44 if (stackSize) { | 44 if (stackSize) { |
45 size_t stackBase = reinterpret_cast<size_t>(getStackStart()); | 45 Address stackBase = reinterpret_cast<Address>(getStackStart()); |
46 s_stackFrameLimit = stackBase - stackSize + kStackRoomSize; | 46 RELEASE_ASSERT(stackSize > static_cast<const size_t>(kStackRoomSize)); |
| 47 size_t stackRoom = stackSize - kStackRoomSize; |
| 48 RELEASE_ASSERT(stackBase > reinterpret_cast<Address>(stackRoom)); |
| 49 s_stackFrameLimit = reinterpret_cast<uintptr_t>(stackBase - stackRoom); |
47 return; | 50 return; |
48 } | 51 } |
49 | 52 |
50 // Fallback version | 53 // Fallback version |
51 // Allocate a 32KB object on stack and query stack frame base after it. | 54 // Allocate a 32KB object on stack and query stack frame base after it. |
52 char dummy[kSafeStackFrameSize]; | 55 char dummy[kSafeStackFrameSize]; |
53 s_stackFrameLimit = currentStackFrameBaseOnCallee(dummy); | 56 s_stackFrameLimit = currentStackFrameBaseOnCallee(dummy); |
54 | 57 |
55 // Assert that the stack frame can be used. | 58 // Assert that the stack frame can be used. |
56 dummy[sizeof(dummy) - 1] = 0; | 59 dummy[sizeof(dummy) - 1] = 0; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 return reinterpret_cast<void*>(__readgsqword(offsetof(NT_TIB64, StackBase)))
; | 150 return reinterpret_cast<void*>(__readgsqword(offsetof(NT_TIB64, StackBase)))
; |
148 #else | 151 #else |
149 return reinterpret_cast<void*>(__readfsdword(offsetof(NT_TIB, StackBase))); | 152 return reinterpret_cast<void*>(__readfsdword(offsetof(NT_TIB, StackBase))); |
150 #endif | 153 #endif |
151 #else | 154 #else |
152 #error Unsupported getStackStart on this platform. | 155 #error Unsupported getStackStart on this platform. |
153 #endif | 156 #endif |
154 } | 157 } |
155 | 158 |
156 } // namespace blink | 159 } // namespace blink |
OLD | NEW |