summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/runtime/StackAlignment.h
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/JavaScriptCore/runtime/StackAlignment.h
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/JavaScriptCore/runtime/StackAlignment.h')
-rw-r--r--Source/JavaScriptCore/runtime/StackAlignment.h26
1 files changed, 21 insertions, 5 deletions
diff --git a/Source/JavaScriptCore/runtime/StackAlignment.h b/Source/JavaScriptCore/runtime/StackAlignment.h
index b803e4ded..00c90a1e7 100644
--- a/Source/JavaScriptCore/runtime/StackAlignment.h
+++ b/Source/JavaScriptCore/runtime/StackAlignment.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2013, 2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -23,10 +23,10 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef StackAlignment_h
-#define StackAlignment_h
+#pragma once
#include "JSCJSValue.h"
+#include <wtf/MathExtras.h>
namespace JSC {
@@ -38,7 +38,23 @@ inline unsigned stackAlignmentRegisters()
return stackAlignmentBytes() / sizeof(EncodedJSValue);
}
-} // namespace JSC
+// Align argument count taking into account the CallFrameHeaderSize may be
+// an "unaligned" count of registers.
+inline unsigned roundArgumentCountToAlignFrame(unsigned argumentCount)
+{
+ return WTF::roundUpToMultipleOf(stackAlignmentRegisters(), argumentCount + CallFrame::headerSizeInRegisters) - CallFrame::headerSizeInRegisters;
+}
-#endif // StackAlignment_h
+// Align local register count to make the last local end on a stack aligned address given the
+// CallFrame is at an address that is stack aligned minus CallerFrameAndPC::sizeInRegisters
+inline unsigned roundLocalRegisterCountForFramePointerOffset(unsigned localRegisterCount)
+{
+ return WTF::roundUpToMultipleOf(stackAlignmentRegisters(), localRegisterCount + CallerFrameAndPC::sizeInRegisters) - CallerFrameAndPC::sizeInRegisters;
+}
+inline unsigned logStackAlignmentRegisters()
+{
+ return WTF::fastLog2(stackAlignmentRegisters());
+}
+
+} // namespace JSC