Index: Source/platform/heap/StackFrameDepth.cpp |
diff --git a/Source/platform/heap/StackFrameDepth.cpp b/Source/platform/heap/StackFrameDepth.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..3389f7b6514b2ad9811e5e7ecde15445571c8277 |
--- /dev/null |
+++ b/Source/platform/heap/StackFrameDepth.cpp |
@@ -0,0 +1,28 @@ |
+// 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. |
+ |
+#include "config.h" |
+#include "platform/heap/StackFrameDepth.h" |
+ |
+namespace blink { |
+ |
+static const char* s_avoidOptimization = nullptr; |
+NEVER_INLINE static uintptr_t estimateStackFrameBaseOnCallee(const char* dummy) |
+{ |
+ s_avoidOptimization = dummy; |
+ return StackFrameDepth::estimateCurrentStackFrame(); |
+} |
+ |
+void StackFrameDepth::configureLimit() |
haraken
2015/01/08 01:14:22
Can we add NEVER_INLINE to configureLimit and remo
kouhei (in TOK)
2015/01/08 03:29:54
No. We want %rbp after dummy[] is pushed.
|
+{ |
+ // Allocate a large object in stack and query stack frame pointer after it. |
+ const size_t kTypicalPointersPerFrame = 4; // Return address + 3 local variable/argument |
+ char dummy[kMaxDepth * kTypicalPointersPerFrame * sizeof(void*)]; |
+ m_safeStackFrame = estimateStackFrameBaseOnCallee(dummy); |
+ |
+ // Assert that the stack frame can be used. |
+ dummy[sizeof(dummy)-1] = 0; |
haraken
2015/01/08 01:14:22
Add spaces around '-'.
haraken
2015/01/08 01:14:22
I guess if we move this code up to line 22, s_avoi
kouhei (in TOK)
2015/01/08 03:29:54
Done.
|
+} |
+ |
+} // namespace blink |