144f0eee88ff00398ff7f715fab053374d808c90dSteve Block// Copyright 2011 the V8 project authors. All rights reserved. 2b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch// Use of this source code is governed by a BSD-style license that can be 3b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch// found in the LICENSE file. 43100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu 53100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu 63100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu 73100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu#ifndef V8_MIPS_FRAMES_MIPS_H_ 83100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu#define V8_MIPS_FRAMES_MIPS_H_ 93100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu 103100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescunamespace v8 { 113100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescunamespace internal { 123100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu 133100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu// Register lists. 143100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu// Note that the bit values must match those used in actual instruction 153100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu// encoding. 163ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochconst int kNumRegs = 32; 173100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu 183ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochconst RegList kJSCallerSaved = 19589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 1 << 2 | // v0 20589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 1 << 3 | // v1 21589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 1 << 4 | // a0 22589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 1 << 5 | // a1 23589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 1 << 6 | // a2 24589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 1 << 7 | // a3 25589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 1 << 8 | // t0 26589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 1 << 9 | // t1 27589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 1 << 10 | // t2 28589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 1 << 11 | // t3 29589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 1 << 12 | // t4 30589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 1 << 13 | // t5 31589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 1 << 14 | // t6 32589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 1 << 15; // t7 33589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 343ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochconst int kNumJSCallerSaved = 14; 353100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu 363100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu 373100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu// Return the code of the n-th caller-saved register available to JavaScript 3844f0eee88ff00398ff7f715fab053374d808c90dSteve Block// e.g. JSCallerSavedReg(0) returns a0.code() == 4. 393100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescuint JSCallerSavedCode(int n); 403100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu 413100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu 423100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu// Callee-saved registers preserved when switching from C to JavaScript. 433ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochconst RegList kCalleeSaved = 44589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 1 << 16 | // s0 45589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 1 << 17 | // s1 46589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 1 << 18 | // s2 47589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 1 << 19 | // s3 48589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 1 << 20 | // s4 49589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 1 << 21 | // s5 50589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 1 << 22 | // s6 (roots in Javascript code) 51589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 1 << 23 | // s7 (cp in Javascript code) 52589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 1 << 30; // fp/s8 533100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu 543ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochconst int kNumCalleeSaved = 9; 553100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu 563ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochconst RegList kCalleeSavedFPU = 57589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 1 << 20 | // f20 58589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 1 << 22 | // f22 59589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 1 << 24 | // f24 60589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 1 << 26 | // f26 61589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 1 << 28 | // f28 62589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 1 << 30; // f30 633100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu 643ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochconst int kNumCalleeSavedFPU = 6; 653ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 663ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochconst RegList kCallerSavedFPU = 673ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 1 << 0 | // f0 683ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 1 << 2 | // f2 693ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 1 << 4 | // f4 703ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 1 << 6 | // f6 713ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 1 << 8 | // f8 723ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 1 << 10 | // f10 733ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 1 << 12 | // f12 743ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 1 << 14 | // f14 753ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 1 << 16 | // f16 763ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 1 << 18; // f18 773ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 783ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 7944f0eee88ff00398ff7f715fab053374d808c90dSteve Block// Number of registers for which space is reserved in safepoints. Must be a 8044f0eee88ff00398ff7f715fab053374d808c90dSteve Block// multiple of 8. 813ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochconst int kNumSafepointRegisters = 24; 8244f0eee88ff00398ff7f715fab053374d808c90dSteve Block 8344f0eee88ff00398ff7f715fab053374d808c90dSteve Block// Define the list of registers actually saved at safepoints. 8444f0eee88ff00398ff7f715fab053374d808c90dSteve Block// Note that the number of saved registers may be smaller than the reserved 8544f0eee88ff00398ff7f715fab053374d808c90dSteve Block// space, i.e. kNumSafepointSavedRegisters <= kNumSafepointRegisters. 863ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochconst RegList kSafepointSavedRegisters = kJSCallerSaved | kCalleeSaved; 873ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochconst int kNumSafepointSavedRegisters = 8844f0eee88ff00398ff7f715fab053374d808c90dSteve Block kNumJSCallerSaved + kNumCalleeSaved; 8944f0eee88ff00398ff7f715fab053374d808c90dSteve Block 903ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochconst int kUndefIndex = -1; 91257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch// Map with indexes on stack that corresponds to codes of saved registers. 923ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochconst int kSafepointRegisterStackIndexMap[kNumRegs] = { 93589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch kUndefIndex, // zero_reg 94589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch kUndefIndex, // at 95589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 0, // v0 96589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 1, // v1 97589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 2, // a0 98589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 3, // a1 99589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 4, // a2 100589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 5, // a3 101589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 6, // t0 102589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 7, // t1 103589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 8, // t2 104589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 9, // t3 105589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 10, // t4 106589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 11, // t5 107589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 12, // t6 108589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 13, // t7 109589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 14, // s0 110589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 15, // s1 111589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 16, // s2 112589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 17, // s3 113589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 18, // s4 114589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 19, // s5 115589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 20, // s6 116589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 21, // s7 117589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch kUndefIndex, // t8 118589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch kUndefIndex, // t9 119589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch kUndefIndex, // k0 120589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch kUndefIndex, // k1 121589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch kUndefIndex, // gp 122589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch kUndefIndex, // sp 123589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 22, // fp 124257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch kUndefIndex 125257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch}; 126257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch 1273100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu 1283100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu// ---------------------------------------------------- 1293100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu 1303100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescuclass EntryFrameConstants : public AllStatic { 1313100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu public: 132b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch static const int kCallerFPOffset = 133b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch -(StandardFrameConstants::kFixedFrameSizeFromFp + kPointerSize); 1343100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu}; 1353100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu 1361b268ca467c924004286c97bac133db489cf43d0Ben Murdochclass ExitFrameConstants : public TypedFrameConstants { 1373100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu public: 1381b268ca467c924004286c97bac133db489cf43d0Ben Murdoch static const int kSPOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(0); 1391b268ca467c924004286c97bac133db489cf43d0Ben Murdoch static const int kCodeOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(1); 1401b268ca467c924004286c97bac133db489cf43d0Ben Murdoch DEFINE_TYPED_FRAME_SIZES(2); 1413100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu 1423100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu // The caller fields are below the frame pointer on the stack. 1433100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu static const int kCallerFPOffset = +0 * kPointerSize; 1443100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu // The calling JS function is between FP and PC. 1453100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu static const int kCallerPCOffset = +1 * kPointerSize; 1463100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu 147257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch // MIPS-specific: a pointer to the old sp to avoid unnecessary calculations. 148257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch static const int kCallerSPOffset = +2 * kPointerSize; 149257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch 1503100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu // FP-relative displacement of the caller's SP. 151257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch static const int kCallerSPDisplacement = +2 * kPointerSize; 1523100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu 153b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch static const int kConstantPoolOffset = 0; // Not used. 1543100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu}; 1553100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu 1563100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu 1573100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescuclass JavaScriptFrameConstants : public AllStatic { 1583100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu public: 1593100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu // FP-relative. 1603100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu static const int kLocal0Offset = StandardFrameConstants::kExpressionsOffset; 1618b112d2025046f85ef7f6be087c6129c872ebad2Ben Murdoch static const int kLastParameterOffset = +2 * kPointerSize; 1621b268ca467c924004286c97bac133db489cf43d0Ben Murdoch static const int kFunctionOffset = StandardFrameConstants::kFunctionOffset; 1633100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu 1643100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu // Caller SP-relative. 1653100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu static const int kParam0Offset = -2 * kPointerSize; 1663100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu static const int kReceiverOffset = -1 * kPointerSize; 1673100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu}; 1683100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu 1693100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu 170014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} // namespace internal 171014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} // namespace v8 1723100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu 1733100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu#endif 174