frames-arm.h revision a7e24c173cf37484693b9abb38e494fa7bd7baeb
1a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Copyright 2006-2008 the V8 project authors. All rights reserved. 2a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Redistribution and use in source and binary forms, with or without 3a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// modification, are permitted provided that the following conditions are 4a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// met: 5a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// 6a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// * Redistributions of source code must retain the above copyright 7a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// notice, this list of conditions and the following disclaimer. 8a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// * Redistributions in binary form must reproduce the above 9a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// copyright notice, this list of conditions and the following 10a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// disclaimer in the documentation and/or other materials provided 11a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// with the distribution. 12a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// * Neither the name of Google Inc. nor the names of its 13a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// contributors may be used to endorse or promote products derived 14a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// from this software without specific prior written permission. 15a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// 16a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 28a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#ifndef V8_ARM_FRAMES_ARM_H_ 29a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#define V8_ARM_FRAMES_ARM_H_ 30a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 31a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blocknamespace v8 { 32a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blocknamespace internal { 33a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 34a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 35a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// The ARM ABI does not specify the usage of register r9, which may be reserved 36a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// as the static base or thread register on some platforms, in which case we 37a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// leave it alone. Adjust the value of kR9Available accordingly: 38a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockstatic const int kR9Available = 1; // 1 if available to us, 0 if reserved 39a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 40a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 41a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Register list in load/store instructions 42a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Note that the bit values must match those used in actual instruction encoding 43a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockstatic const int kNumRegs = 16; 44a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 45a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 46a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Caller-saved/arguments registers 47a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockstatic const RegList kJSCallerSaved = 48a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 1 << 0 | // r0 a1 49a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 1 << 1 | // r1 a2 50a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 1 << 2 | // r2 a3 51a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 1 << 3; // r3 a4 52a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 53a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockstatic const int kNumJSCallerSaved = 4; 54a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 55a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blocktypedef Object* JSCallerSavedBuffer[kNumJSCallerSaved]; 56a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 57a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Return the code of the n-th caller-saved register available to JavaScript 58a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// e.g. JSCallerSavedReg(0) returns r0.code() == 0 59a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockint JSCallerSavedCode(int n); 60a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 61a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 62a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Callee-saved registers preserved when switching from C to JavaScript 63a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockstatic const RegList kCalleeSaved = 64a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 1 << 4 | // r4 v1 65a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 1 << 5 | // r5 v2 66a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 1 << 6 | // r6 v3 67a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 1 << 7 | // r7 v4 68a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 1 << 8 | // r8 v5 (cp in JavaScript code) 69a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block kR9Available 70a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block << 9 | // r9 v6 71a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 1 << 10 | // r10 v7 72a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 1 << 11; // r11 v8 (fp in JavaScript code) 73a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 74a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockstatic const int kNumCalleeSaved = 7 + kR9Available; 75a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 76a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 77a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// ---------------------------------------------------- 78a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 79a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 80a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass StackHandlerConstants : public AllStatic { 81a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public: 82a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kNextOffset = 0 * kPointerSize; 83a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kStateOffset = 1 * kPointerSize; 84a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kFPOffset = 2 * kPointerSize; 85a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kPCOffset = 3 * kPointerSize; 86a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 87a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kSize = kPCOffset + kPointerSize; 88a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block}; 89a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 90a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 91a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass EntryFrameConstants : public AllStatic { 92a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public: 93a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kCallerFPOffset = -3 * kPointerSize; 94a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block}; 95a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 96a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 97a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass ExitFrameConstants : public AllStatic { 98a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public: 99a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // Exit frames have a debug marker on the stack. 100a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kSPDisplacement = -1 * kPointerSize; 101a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 102a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // The debug marker is just above the frame pointer. 103a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kDebugMarkOffset = -1 * kPointerSize; 104a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 105a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kSavedRegistersOffset = 0 * kPointerSize; 106a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 107a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // The caller fields are below the frame pointer on the stack. 108a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kCallerFPOffset = +0 * kPointerSize; 109a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // The calling JS function is between FP and PC. 110a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kCallerPCOffset = +2 * kPointerSize; 111a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 112a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // FP-relative displacement of the caller's SP. It points just 113a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // below the saved PC. 114a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kCallerSPDisplacement = +3 * kPointerSize; 115a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block}; 116a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 117a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 118a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass StandardFrameConstants : public AllStatic { 119a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public: 120a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kExpressionsOffset = -3 * kPointerSize; 121a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kMarkerOffset = -2 * kPointerSize; 122a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kContextOffset = -1 * kPointerSize; 123a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kCallerFPOffset = 0 * kPointerSize; 124a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kCallerPCOffset = +1 * kPointerSize; 125a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kCallerSPOffset = +2 * kPointerSize; 126a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block}; 127a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 128a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 129a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass JavaScriptFrameConstants : public AllStatic { 130a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public: 131a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // FP-relative. 132a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kLocal0Offset = StandardFrameConstants::kExpressionsOffset; 133a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kSavedRegistersOffset = +2 * kPointerSize; 134a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kFunctionOffset = StandardFrameConstants::kMarkerOffset; 135a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 136a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // Caller SP-relative. 137a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kParam0Offset = -2 * kPointerSize; 138a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kReceiverOffset = -1 * kPointerSize; 139a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block}; 140a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 141a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 142a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass ArgumentsAdaptorFrameConstants : public AllStatic { 143a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public: 144a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kLengthOffset = StandardFrameConstants::kExpressionsOffset; 145a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block}; 146a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 147a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 148a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass InternalFrameConstants : public AllStatic { 149a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public: 150a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kCodeOffset = StandardFrameConstants::kExpressionsOffset; 151a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block}; 152a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 153a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 154a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockinline Object* JavaScriptFrame::function_slot_object() const { 155a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block const int offset = JavaScriptFrameConstants::kFunctionOffset; 156a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block return Memory::Object_at(fp() + offset); 157a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block} 158a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 159a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 160a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block} } // namespace v8::internal 161a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 162a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#endif // V8_ARM_FRAMES_ARM_H_ 163