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

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

Issue 1609943003: Make platform/heap to use USING_FAST_MALLOC. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed compile error Created 4 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 #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/Assertions.h" 10 #include "wtf/Assertions.h"
10 #include <cstddef> 11 #include <cstddef>
11 #include <stdint.h> 12 #include <stdint.h>
12 13
13 namespace blink { 14 namespace blink {
14 15
15 // StackFrameDepth keeps track of current call stack frame depth. 16 // StackFrameDepth keeps track of current call stack frame depth.
16 // Use isSafeToRecurse() to query if there is a room in current 17 // Use isSafeToRecurse() to query if there is a room in current
17 // call stack for more recursive call. 18 // call stack for more recursive call.
18 class PLATFORM_EXPORT StackFrameDepth final { 19 class PLATFORM_EXPORT StackFrameDepth final {
20 STATIC_ONLY(StackFrameDepth);
19 public: 21 public:
20 inline static bool isSafeToRecurse() 22 inline static bool isSafeToRecurse()
21 { 23 {
22 ASSERT(s_stackFrameLimit || !s_isEnabled); 24 ASSERT(s_stackFrameLimit || !s_isEnabled);
23 25
24 // Asssume that the stack grows towards lower addresses, which 26 // Asssume that the stack grows towards lower addresses, which
25 // all the ABIs currently supported do. 27 // all the ABIs currently supported do.
26 // 28 //
27 // A unit test checks that the assumption holds for a target 29 // A unit test checks that the assumption holds for a target
28 // (HeapTest.StackGrowthDirection.) 30 // (HeapTest.StackGrowthDirection.)
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 // considered safe and allowed. 73 // considered safe and allowed.
72 static const int kSafeStackFrameSize = 32 * 1024; 74 static const int kSafeStackFrameSize = 32 * 1024;
73 75
74 static uintptr_t s_stackFrameLimit; 76 static uintptr_t s_stackFrameLimit;
75 #if ENABLE(ASSERT) 77 #if ENABLE(ASSERT)
76 static bool s_isEnabled; 78 static bool s_isEnabled;
77 #endif 79 #endif
78 }; 80 };
79 81
80 class StackFrameDepthScope { 82 class StackFrameDepthScope {
83 STACK_ALLOCATED();
84 WTF_MAKE_NONCOPYABLE(StackFrameDepthScope);
81 public: 85 public:
82 StackFrameDepthScope() 86 StackFrameDepthScope()
83 { 87 {
84 StackFrameDepth::enableStackLimit(); 88 StackFrameDepth::enableStackLimit();
85 ASSERT(StackFrameDepth::isSafeToRecurse()); 89 ASSERT(StackFrameDepth::isSafeToRecurse());
86 } 90 }
87 91
88 ~StackFrameDepthScope() 92 ~StackFrameDepthScope()
89 { 93 {
90 StackFrameDepth::disableStackLimit(); 94 StackFrameDepth::disableStackLimit();
91 } 95 }
92 }; 96 };
93 97
94 } // namespace blink 98 } // namespace blink
95 99
96 #endif // StackFrameDepth_h 100 #endif // StackFrameDepth_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698