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

Unified 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: move preGC 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/heap/InlinedGlobalMarkingVisitor.h ('k') | Source/platform/heap/StackFrameDepth.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/heap/StackFrameDepth.h
diff --git a/Source/platform/heap/StackFrameDepth.h b/Source/platform/heap/StackFrameDepth.h
new file mode 100644
index 0000000000000000000000000000000000000000..ed43873ed34980243d0dd379160111fb885c86f1
--- /dev/null
+++ b/Source/platform/heap/StackFrameDepth.h
@@ -0,0 +1,52 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef StackFrameDepth_h
+#define StackFrameDepth_h
+
+#include "platform/PlatformExport.h"
+#include "wtf/Assertions.h"
+#include <stdint.h>
+
+namespace blink {
+
+// StackFrameDepth keeps track of current call stack frame depth.
+// Use isSafeToRecurse() to query if there is a room in current
+// call stack for more recursive call.
+class PLATFORM_EXPORT StackFrameDepth final {
+public:
+ inline bool isSafeToRecurse()
+ {
+ ASSERT(m_stackFrameLimit);
+
+ // Below comparison assumes callstack to glow downward,
+ // which is true for all ABI Blink currently supports.
+ return currentStackFrame() > m_stackFrameLimit;
+ }
+
+ static uintptr_t currentStackFrame(const char* dummy = nullptr)
+ {
+#if COMPILER(GCC)
+ return reinterpret_cast<uintptr_t>(__builtin_frame_address(0));
+#elif COMPILER(MSVC)
+ return reinterpret_cast<uintptr_t>(&dummy) - sizeof(void*);
+#else
+#error "Stack frame pointer estimation not supported on this platform."
+ return 0;
+#endif
+ }
+
+ void configureLimit();
+
+private:
+ // The maximum depth of eager, unrolled trace() calls that is
+ // considered safe and allowed.
+ static const int kSafeStackFrameSize = 32 * 1024;
+
+ uintptr_t m_stackFrameLimit;
+};
+
+} // namespace blink
+
+#endif // StackFrameDepth_h
« no previous file with comments | « Source/platform/heap/InlinedGlobalMarkingVisitor.h ('k') | Source/platform/heap/StackFrameDepth.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698