Chromium Code Reviews

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

Issue 1663823002: If marking system stack is unknown, be more forgiving about stack depths. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/heap/StackFrameDepth.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef StackFrameDepth_h 5 #ifndef StackFrameDepth_h
6 #define StackFrameDepth_h 6 #define StackFrameDepth_h
7 7
8 #include "platform/PlatformExport.h" 8 #include "platform/PlatformExport.h"
9 #include "wtf/Allocator.h" 9 #include "wtf/Allocator.h"
10 #include "wtf/Assertions.h" 10 #include "wtf/Assertions.h"
(...skipping 24 matching lines...)
35 static void disableStackLimit() 35 static void disableStackLimit()
36 { 36 {
37 s_stackFrameLimit = 0; 37 s_stackFrameLimit = 0;
38 #if ENABLE(ASSERT) 38 #if ENABLE(ASSERT)
39 s_isEnabled = false; 39 s_isEnabled = false;
40 #endif 40 #endif
41 } 41 }
42 42
43 #if ENABLE(ASSERT) 43 #if ENABLE(ASSERT)
44 inline static bool isEnabled() { return s_isEnabled; } 44 inline static bool isEnabled() { return s_isEnabled; }
45 inline static bool isAcceptableStackUse()
46 {
47 // ASan adds extra stack usage leading to too noisy asserts.
48 #if defined(ADDRESS_SANITIZER)
49 return true;
50 #else
51 // If a conservative fallback stack size is in effect, use
52 // a larger stack limit so as to avoid false positives.
53 return !s_isEnabled || isSafeToRecurse() || (s_isUsingFallbackStackSize && (s_stackFrameLimit - currentStackFrame()) < 3 * kSafeStackFrameSize);
haraken 2016/02/04 01:31:36 Nit: Slightly clearer: if (s_isUsingFallbackStack
sof 2016/02/04 09:54:32 Done.
54 #endif
55 }
45 #endif 56 #endif
46 57
47 static size_t getUnderestimatedStackSize(); 58 static size_t getUnderestimatedStackSize();
48 static void* getStackStart(); 59 static void* getStackStart();
49 60
50 #if COMPILER(MSVC) 61 #if COMPILER(MSVC)
51 // Ignore C4172: returning address of local variable or temporary: dummy. This 62 // Ignore C4172: returning address of local variable or temporary: dummy. This
52 // warning suppression has to go outside of the function to take effect. 63 // warning suppression has to go outside of the function to take effect.
53 #pragma warning(push) 64 #pragma warning(push)
54 #pragma warning(disable: 4172) 65 #pragma warning(disable: 4172)
(...skipping 14 matching lines...)
69 #endif 80 #endif
70 81
71 private: 82 private:
72 // The maximum depth of eager, unrolled trace() calls that is 83 // The maximum depth of eager, unrolled trace() calls that is
73 // considered safe and allowed. 84 // considered safe and allowed.
74 static const int kSafeStackFrameSize = 32 * 1024; 85 static const int kSafeStackFrameSize = 32 * 1024;
75 86
76 static uintptr_t s_stackFrameLimit; 87 static uintptr_t s_stackFrameLimit;
77 #if ENABLE(ASSERT) 88 #if ENABLE(ASSERT)
78 static bool s_isEnabled; 89 static bool s_isEnabled;
90 static bool s_isUsingFallbackStackSize;
79 #endif 91 #endif
80 }; 92 };
81 93
82 class StackFrameDepthScope { 94 class StackFrameDepthScope {
83 STACK_ALLOCATED(); 95 STACK_ALLOCATED();
84 WTF_MAKE_NONCOPYABLE(StackFrameDepthScope); 96 WTF_MAKE_NONCOPYABLE(StackFrameDepthScope);
85 public: 97 public:
86 StackFrameDepthScope() 98 StackFrameDepthScope()
87 { 99 {
88 StackFrameDepth::enableStackLimit(); 100 StackFrameDepth::enableStackLimit();
89 ASSERT(StackFrameDepth::isSafeToRecurse()); 101 ASSERT(StackFrameDepth::isSafeToRecurse());
90 } 102 }
91 103
92 ~StackFrameDepthScope() 104 ~StackFrameDepthScope()
93 { 105 {
94 StackFrameDepth::disableStackLimit(); 106 StackFrameDepth::disableStackLimit();
95 } 107 }
96 }; 108 };
97 109
98 } // namespace blink 110 } // namespace blink
99 111
100 #endif // StackFrameDepth_h 112 #endif // StackFrameDepth_h
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/heap/StackFrameDepth.cpp » ('j') | no next file with comments »

Powered by Google App Engine