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

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

Issue 818253005: Oilpan: Query stack frame register instead of manual bookkeeping (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: ENABLE(STACKFRAME_POINTER_ESTIMATION) Created 5 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef StackFrameDepth_h
6 #define StackFrameDepth_h
7
8 #include "platform/PlatformExport.h"
9 #include "wtf/Assertions.h"
10 #include <stdint.h>
11
12 namespace blink {
13
14 // StackFrameDepth keeps track of current call stack frame depth.
15 // Use isSafeToRecurse() to query if there is a room in current
16 // call stack for more recursive call.
17 class PLATFORM_EXPORT StackFrameDepth final {
18 public:
19 inline bool isSafeToRecurse()
20 {
21 ASSERT(m_safeStackFrame);
22
23 // Below comparison assumes callstack to glow downward,
24 // which is true for all ABI Blink currently supports.
25 return estimateCurrentStackFrame() > m_safeStackFrame;
26 }
27
28 static uintptr_t estimateCurrentStackFrame(const char* dummy = nullptr)
haraken 2015/01/08 01:14:23 estimateCurrentStackFrame => currentStackFrame
kouhei (in TOK) 2015/01/08 03:29:54 Done.
29 {
30 #if COMPILER(GCC)
31 return reinterpret_cast<uintptr_t>(__builtin_frame_address(0));
32 #elif COMPILER(MSVC)
33 return reinterpret_cast<uintptr_t>(&dummy) - sizeof(void*);
34 #else
35 #error "Stack frame pointer estimation not supported on this platform."
36 return 0;
37 #endif
38 }
39
40 void configureLimit();
41
42 private:
43 // The maximum depth of eager, unrolled trace() calls that is
44 // considered safe and allowed.
45 static const int kMaxDepth = 400;
haraken 2015/01/08 01:14:23 Keep the number to 100 in this CL. You can increas
kouhei (in TOK) 2015/01/08 03:29:54 Changed this to kSafeStackFrameSize for clarity.
46
47 uintptr_t m_safeStackFrame;
haraken 2015/01/08 01:14:23 m_safeStackFrame => m_stackFrameLimit (for consist
kouhei (in TOK) 2015/01/08 03:29:54 Done.
48 };
49
50 } // namespace blink
51
52 #endif
haraken 2015/01/08 01:14:23 Add // StackFrameDepth_h
kouhei (in TOK) 2015/01/08 03:29:54 Done.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698