13ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch// Copyright 2012 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: 383ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochconst 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 433ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochconst int kNumRegs = 16; 44a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 45a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 46a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Caller-saved/arguments registers 473ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochconst 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 533ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochconst 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 633ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochconst 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) 691e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block kR9Available << 9 | // r9 v6 70a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 1 << 10 | // r10 v7 71a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 1 << 11; // r11 v8 (fp in JavaScript code) 72a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 733ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch// When calling into C++ (only for C++ calls that can't cause a GC). 743ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch// The call code will take care of lr, fp, etc. 753ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochconst RegList kCallerSaved = 763ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 1 << 0 | // r0 773ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 1 << 1 | // r1 783ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 1 << 2 | // r2 793ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 1 << 3 | // r3 803ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 1 << 9; // r9 813ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 823ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 833ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochconst int kNumCalleeSaved = 7 + kR9Available; 84a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 857d3e7fc4b65010eabe860313ee0c64f50843f6e3Ben Murdoch// Double registers d8 to d15 are callee-saved. 863ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochconst int kNumDoubleCalleeSaved = 8; 877d3e7fc4b65010eabe860313ee0c64f50843f6e3Ben Murdoch 88a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 89b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch// Number of registers for which space is reserved in safepoints. Must be a 90b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch// multiple of 8. 91b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch// TODO(regis): Only 8 registers may actually be sufficient. Revisit. 923ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochconst int kNumSafepointRegisters = 16; 93b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch 94b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch// Define the list of registers actually saved at safepoints. 95b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch// Note that the number of saved registers may be smaller than the reserved 96b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch// space, i.e. kNumSafepointSavedRegisters <= kNumSafepointRegisters. 973ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochconst RegList kSafepointSavedRegisters = kJSCallerSaved | kCalleeSaved; 983ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochconst int kNumSafepointSavedRegisters = kNumJSCallerSaved + kNumCalleeSaved; 99b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch 100a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// ---------------------------------------------------- 101a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 102a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 103a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass StackHandlerConstants : public AllStatic { 104a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public: 1053ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch static const int kNextOffset = 0 * kPointerSize; 1063ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch static const int kCodeOffset = 1 * kPointerSize; 1073ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch static const int kStateOffset = 2 * kPointerSize; 1083ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch static const int kContextOffset = 3 * kPointerSize; 1093ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch static const int kFPOffset = 4 * kPointerSize; 110a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 1113ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch static const int kSize = kFPOffset + kPointerSize; 112a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block}; 113a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 114a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 115a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass EntryFrameConstants : public AllStatic { 116a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public: 117a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kCallerFPOffset = -3 * kPointerSize; 118a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block}; 119a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 120a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 121a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass ExitFrameConstants : public AllStatic { 122a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public: 1231e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block static const int kCodeOffset = -2 * kPointerSize; 12480d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsen static const int kSPOffset = -1 * kPointerSize; 125a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 126a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // The caller fields are below the frame pointer on the stack. 1271e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block static const int kCallerFPOffset = 0 * kPointerSize; 1281e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block // The calling JS function is below FP. 1291e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block static const int kCallerPCOffset = 1 * kPointerSize; 130a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 131a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // FP-relative displacement of the caller's SP. It points just 132a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // below the saved PC. 1331e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block static const int kCallerSPDisplacement = 2 * kPointerSize; 134a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block}; 135a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 136a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 137a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass StandardFrameConstants : public AllStatic { 138a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public: 1393ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch // Fixed part of the frame consists of return address, caller fp, 1403ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch // context and function. 1413ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch static const int kFixedFrameSize = 4 * kPointerSize; 142a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kExpressionsOffset = -3 * kPointerSize; 143a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kMarkerOffset = -2 * kPointerSize; 144a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kContextOffset = -1 * kPointerSize; 145a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kCallerFPOffset = 0 * kPointerSize; 1461e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block static const int kCallerPCOffset = 1 * kPointerSize; 1471e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block static const int kCallerSPOffset = 2 * kPointerSize; 148a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block}; 149a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 150a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 151a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass JavaScriptFrameConstants : public AllStatic { 152a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public: 153a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // FP-relative. 154a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kLocal0Offset = StandardFrameConstants::kExpressionsOffset; 1558b112d2025046f85ef7f6be087c6129c872ebad2Ben Murdoch static const int kLastParameterOffset = +2 * kPointerSize; 156a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kFunctionOffset = StandardFrameConstants::kMarkerOffset; 157a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 158a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // Caller SP-relative. 159a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kParam0Offset = -2 * kPointerSize; 160a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kReceiverOffset = -1 * kPointerSize; 161a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block}; 162a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 163a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 164a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass ArgumentsAdaptorFrameConstants : public AllStatic { 165a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public: 166a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kLengthOffset = StandardFrameConstants::kExpressionsOffset; 1673ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch static const int kFrameSize = 1683ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch StandardFrameConstants::kFixedFrameSize + kPointerSize; 169a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block}; 170a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 171a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 172a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass InternalFrameConstants : public AllStatic { 173a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public: 174a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kCodeOffset = StandardFrameConstants::kExpressionsOffset; 175a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block}; 176a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 177a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 178a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockinline Object* JavaScriptFrame::function_slot_object() const { 179a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block const int offset = JavaScriptFrameConstants::kFunctionOffset; 180a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block return Memory::Object_at(fp() + offset); 181a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block} 182a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 183a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 184a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block} } // namespace v8::internal 185a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 186a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#endif // V8_ARM_FRAMES_ARM_H_ 187