frames-ia32.h revision 3ef787dbeca8a5fb1086949cda830dccee07bfbd
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_IA32_FRAMES_IA32_H_ 29a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#define V8_IA32_FRAMES_IA32_H_ 30a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 31a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blocknamespace v8 { 32a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blocknamespace internal { 33a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 34a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 35a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Register lists 36a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Note that the bit values must match those used in actual instruction encoding 373ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochconst int kNumRegs = 8; 38a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 39a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 40a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Caller-saved registers 413ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochconst RegList kJSCallerSaved = 42a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 1 << 0 | // eax 43a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 1 << 1 | // ecx 44a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 1 << 2 | // edx 45a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 1 << 3 | // ebx - used as a caller-saved register in JavaScript code 46a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 1 << 7; // edi - callee function 47a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 483ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochconst int kNumJSCallerSaved = 5; 49a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 50a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blocktypedef Object* JSCallerSavedBuffer[kNumJSCallerSaved]; 51a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 52b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch 53b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch// Number of registers for which space is reserved in safepoints. 543ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochconst int kNumSafepointRegisters = 8; 55b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch 56a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// ---------------------------------------------------- 57a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 58a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 59a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass StackHandlerConstants : public AllStatic { 60a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public: 613ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch static const int kNextOffset = 0 * kPointerSize; 623ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch static const int kCodeOffset = 1 * kPointerSize; 633ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch static const int kStateOffset = 2 * kPointerSize; 643ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch static const int kContextOffset = 3 * kPointerSize; 653ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch static const int kFPOffset = 4 * kPointerSize; 66a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 673ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch static const int kSize = kFPOffset + kPointerSize; 68a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block}; 69a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 70a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 71a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass EntryFrameConstants : public AllStatic { 72a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public: 73a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kCallerFPOffset = -6 * kPointerSize; 74a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 75a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kFunctionArgOffset = +3 * kPointerSize; 76a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kReceiverArgOffset = +4 * kPointerSize; 77a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kArgcOffset = +5 * kPointerSize; 78a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kArgvOffset = +6 * kPointerSize; 79a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block}; 80a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 81a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 82a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass ExitFrameConstants : public AllStatic { 83a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public: 84257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch static const int kCodeOffset = -2 * kPointerSize; 85257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch static const int kSPOffset = -1 * kPointerSize; 86a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 87a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kCallerFPOffset = 0 * kPointerSize; 88a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kCallerPCOffset = +1 * kPointerSize; 89a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 90a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // FP-relative displacement of the caller's SP. It points just 91a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // below the saved PC. 92a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kCallerSPDisplacement = +2 * kPointerSize; 93a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block}; 94a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 95a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 96a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass StandardFrameConstants : public AllStatic { 97a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public: 983ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch // Fixed part of the frame consists of return address, caller fp, 993ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch // context and function. 100257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch // StandardFrame::IterateExpressions assumes that kContextOffset is the last 101257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch // object pointer. 1023ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch static const int kFixedFrameSize = 4 * kPointerSize; 103a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kExpressionsOffset = -3 * kPointerSize; 104a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kMarkerOffset = -2 * kPointerSize; 105a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kContextOffset = -1 * kPointerSize; 106a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kCallerFPOffset = 0 * kPointerSize; 107a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kCallerPCOffset = +1 * kPointerSize; 108a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kCallerSPOffset = +2 * kPointerSize; 109a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block}; 110a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 111a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 112a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass JavaScriptFrameConstants : public AllStatic { 113a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public: 114a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // FP-relative. 115a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kLocal0Offset = StandardFrameConstants::kExpressionsOffset; 1168b112d2025046f85ef7f6be087c6129c872ebad2Ben Murdoch static const int kLastParameterOffset = +2 * kPointerSize; 117a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kFunctionOffset = StandardFrameConstants::kMarkerOffset; 118a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 119a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // Caller SP-relative. 120a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kParam0Offset = -2 * kPointerSize; 121a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kReceiverOffset = -1 * kPointerSize; 122a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block}; 123a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 124a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 125a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass ArgumentsAdaptorFrameConstants : public AllStatic { 126a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public: 127a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kLengthOffset = StandardFrameConstants::kExpressionsOffset; 1283ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch static const int kFrameSize = 1293ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch StandardFrameConstants::kFixedFrameSize + kPointerSize; 130a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block}; 131a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 132a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 133a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass InternalFrameConstants : public AllStatic { 134a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public: 135a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kCodeOffset = StandardFrameConstants::kExpressionsOffset; 136a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block}; 137a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 138a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 139a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockinline Object* JavaScriptFrame::function_slot_object() const { 140a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block const int offset = JavaScriptFrameConstants::kFunctionOffset; 141a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block return Memory::Object_at(fp() + offset); 142a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block} 143a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 144a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 145a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block} } // namespace v8::internal 146a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 147a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#endif // V8_IA32_FRAMES_IA32_H_ 148