diff options
Diffstat (limited to 'Source/JavaScriptCore/runtime/StackAlignment.h')
-rw-r--r-- | Source/JavaScriptCore/runtime/StackAlignment.h | 26 |
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 |