1958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier// Copyright 2014 the V8 project authors. All rights reserved. 2958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier// Use of this source code is governed by a BSD-style license that can be 3958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier// found in the LICENSE file. 4958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 5958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier#ifndef V8_PPC_FRAMES_PPC_H_ 6958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier#define V8_PPC_FRAMES_PPC_H_ 7958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 8958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Berniernamespace v8 { 9958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Berniernamespace internal { 10958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 11958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 12958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier// Register list in load/store instructions 13958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier// Note that the bit values must match those used in actual instruction encoding 14958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernierconst int kNumRegs = 32; 15958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 16958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 17958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier// Caller-saved/arguments registers 18958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernierconst RegList kJSCallerSaved = 1 << 3 | // r3 a1 19958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 1 << 4 | // r4 a2 20958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 1 << 5 | // r5 a3 21958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 1 << 6 | // r6 a4 22958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 1 << 7 | // r7 a5 23958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 1 << 8 | // r8 a6 24958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 1 << 9 | // r9 a7 25958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 1 << 10 | // r10 a8 26958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 1 << 11; 27958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 28958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernierconst int kNumJSCallerSaved = 9; 29958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 30958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier// Return the code of the n-th caller-saved register available to JavaScript 31958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier// e.g. JSCallerSavedReg(0) returns r0.code() == 0 32958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernierint JSCallerSavedCode(int n); 33958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 34958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 35958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier// Callee-saved registers preserved when switching from C to JavaScript 36958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernierconst RegList kCalleeSaved = 1 << 14 | // r14 37958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 1 << 15 | // r15 38958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 1 << 16 | // r16 39958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 1 << 17 | // r17 40958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 1 << 18 | // r18 41958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 1 << 19 | // r19 42958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 1 << 20 | // r20 43958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 1 << 21 | // r21 44958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 1 << 22 | // r22 45958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 1 << 23 | // r23 46958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 1 << 24 | // r24 47958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 1 << 25 | // r25 48958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 1 << 26 | // r26 49958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 1 << 27 | // r27 50958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 1 << 28 | // r28 51958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 1 << 29 | // r29 52958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 1 << 30 | // r20 53958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 1 << 31; // r31 54958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 55958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 56958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernierconst int kNumCalleeSaved = 18; 57958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 58014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdochconst RegList kCallerSavedDoubles = 1 << 0 | // d0 59014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 1 << 1 | // d1 60014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 1 << 2 | // d2 61014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 1 << 3 | // d3 62014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 1 << 4 | // d4 63014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 1 << 5 | // d5 64014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 1 << 6 | // d6 65014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 1 << 7 | // d7 66014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 1 << 8 | // d8 67014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 1 << 9 | // d9 68014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 1 << 10 | // d10 69014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 1 << 11 | // d11 70014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 1 << 12 | // d12 71014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 1 << 13; // d13 72014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 73014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdochconst int kNumCallerSavedDoubles = 14; 74014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 75014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdochconst RegList kCalleeSavedDoubles = 1 << 14 | // d14 76014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 1 << 15 | // d15 77014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 1 << 16 | // d16 78014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 1 << 17 | // d17 79014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 1 << 18 | // d18 80014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 1 << 19 | // d19 81014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 1 << 20 | // d20 82014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 1 << 21 | // d21 83014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 1 << 22 | // d22 84014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 1 << 23 | // d23 85014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 1 << 24 | // d24 86014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 1 << 25 | // d25 87014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 1 << 26 | // d26 88014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 1 << 27 | // d27 89014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 1 << 28 | // d28 90014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 1 << 29 | // d29 91014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 1 << 30 | // d30 92014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 1 << 31; // d31 93014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 94014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdochconst int kNumCalleeSavedDoubles = 18; 95014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 96014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 97958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier// Number of registers for which space is reserved in safepoints. Must be a 98958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier// multiple of 8. 99958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernierconst int kNumSafepointRegisters = 32; 100958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 101958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier// The following constants describe the stack frame linkage area as 102958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier// defined by the ABI. Note that kNumRequiredStackFrameSlots must 103958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier// satisfy alignment requirements (rounding up if required). 104958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier#if V8_TARGET_ARCH_PPC64 && V8_TARGET_LITTLE_ENDIAN 105958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier// [0] back chain 106958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier// [1] condition register save area 107958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier// [2] link register save area 108958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier// [3] TOC save area 109958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier// [4] Parameter1 save area 110958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier// ... 111958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier// [11] Parameter8 save area 112958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier// [12] Parameter9 slot (if necessary) 113958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier// ... 114958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernierconst int kNumRequiredStackFrameSlots = 12; 115958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernierconst int kStackFrameLRSlot = 2; 116958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernierconst int kStackFrameExtraParamSlot = 12; 117958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier#elif V8_OS_AIX || V8_TARGET_ARCH_PPC64 118958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier// [0] back chain 119958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier// [1] condition register save area 120958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier// [2] link register save area 121958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier// [3] reserved for compiler 122958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier// [4] reserved by binder 123958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier// [5] TOC save area 124958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier// [6] Parameter1 save area 125958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier// ... 126958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier// [13] Parameter8 save area 127958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier// [14] Parameter9 slot (if necessary) 128958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier// ... 129958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier#if V8_TARGET_ARCH_PPC64 130958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernierconst int kNumRequiredStackFrameSlots = 14; 131958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier#else 132958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernierconst int kNumRequiredStackFrameSlots = 16; 133958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier#endif 134958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernierconst int kStackFrameLRSlot = 2; 135958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernierconst int kStackFrameExtraParamSlot = 14; 136958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier#else 137958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier// [0] back chain 138958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier// [1] link register save area 139958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier// [2] Parameter9 slot (if necessary) 140958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier// ... 141958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernierconst int kNumRequiredStackFrameSlots = 4; 142958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernierconst int kStackFrameLRSlot = 1; 143958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernierconst int kStackFrameExtraParamSlot = 2; 144958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier#endif 145958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 146958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier// ---------------------------------------------------- 147958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 148958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 149958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernierclass EntryFrameConstants : public AllStatic { 150958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier public: 151958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier static const int kCallerFPOffset = 152958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier -(StandardFrameConstants::kFixedFrameSizeFromFp + kPointerSize); 153958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier}; 154958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 1551b268ca467c924004286c97bac133db489cf43d0Ben Murdochclass ExitFrameConstants : public TypedFrameConstants { 156958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier public: 1571b268ca467c924004286c97bac133db489cf43d0Ben Murdoch static const int kSPOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(0); 1581b268ca467c924004286c97bac133db489cf43d0Ben Murdoch static const int kCodeOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(1); 1591b268ca467c924004286c97bac133db489cf43d0Ben Murdoch DEFINE_TYPED_FRAME_SIZES(2); 160958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 161958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier // The caller fields are below the frame pointer on the stack. 162958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier static const int kCallerFPOffset = 0 * kPointerSize; 163958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier // The calling JS function is below FP. 164958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier static const int kCallerPCOffset = 1 * kPointerSize; 165958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 166958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier // FP-relative displacement of the caller's SP. It points just 167958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier // below the saved PC. 168958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier static const int kCallerSPDisplacement = 2 * kPointerSize; 169958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier}; 170958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 171958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 172958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernierclass JavaScriptFrameConstants : public AllStatic { 173958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier public: 174958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier // FP-relative. 175958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier static const int kLocal0Offset = StandardFrameConstants::kExpressionsOffset; 176958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier static const int kLastParameterOffset = +2 * kPointerSize; 1771b268ca467c924004286c97bac133db489cf43d0Ben Murdoch static const int kFunctionOffset = StandardFrameConstants::kFunctionOffset; 178958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 179958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier // Caller SP-relative. 180958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier static const int kParam0Offset = -2 * kPointerSize; 181958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier static const int kReceiverOffset = -1 * kPointerSize; 182958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier}; 183958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 184958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 185014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} // namespace internal 186014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} // namespace v8 187958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier 188958fae7ec3f466955f8e5b50fa5b8d38b9e91675Emily Bernier#endif // V8_PPC_FRAMES_PPC_H_ 189