Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 1 | // Copyright 2012 the V8 project authors. All rights reserved. |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 2 | // Redistribution and use in source and binary forms, with or without |
| 3 | // modification, are permitted provided that the following conditions are |
| 4 | // met: |
| 5 | // |
| 6 | // * Redistributions of source code must retain the above copyright |
| 7 | // notice, this list of conditions and the following disclaimer. |
| 8 | // * Redistributions in binary form must reproduce the above |
| 9 | // copyright notice, this list of conditions and the following |
| 10 | // disclaimer in the documentation and/or other materials provided |
| 11 | // with the distribution. |
| 12 | // * Neither the name of Google Inc. nor the names of its |
| 13 | // contributors may be used to endorse or promote products derived |
| 14 | // from this software without specific prior written permission. |
| 15 | // |
| 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | |
| 28 | #ifndef V8_IA32_FRAMES_IA32_H_ |
| 29 | #define V8_IA32_FRAMES_IA32_H_ |
| 30 | |
| 31 | namespace v8 { |
| 32 | namespace internal { |
| 33 | |
| 34 | |
| 35 | // Register lists |
| 36 | // Note that the bit values must match those used in actual instruction encoding |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 37 | const int kNumRegs = 8; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 38 | |
| 39 | |
| 40 | // Caller-saved registers |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 41 | const RegList kJSCallerSaved = |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 42 | 1 << 0 | // eax |
| 43 | 1 << 1 | // ecx |
| 44 | 1 << 2 | // edx |
| 45 | 1 << 3 | // ebx - used as a caller-saved register in JavaScript code |
| 46 | 1 << 7; // edi - callee function |
| 47 | |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 48 | const int kNumJSCallerSaved = 5; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 49 | |
| 50 | typedef Object* JSCallerSavedBuffer[kNumJSCallerSaved]; |
| 51 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 52 | |
| 53 | // Number of registers for which space is reserved in safepoints. |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 54 | const int kNumSafepointRegisters = 8; |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 55 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 56 | // ---------------------------------------------------- |
| 57 | |
| 58 | |
| 59 | class StackHandlerConstants : public AllStatic { |
| 60 | public: |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 61 | static const int kNextOffset = 0 * kPointerSize; |
| 62 | static const int kCodeOffset = 1 * kPointerSize; |
| 63 | static const int kStateOffset = 2 * kPointerSize; |
| 64 | static const int kContextOffset = 3 * kPointerSize; |
| 65 | static const int kFPOffset = 4 * kPointerSize; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 66 | |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 67 | static const int kSize = kFPOffset + kPointerSize; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 68 | }; |
| 69 | |
| 70 | |
| 71 | class EntryFrameConstants : public AllStatic { |
| 72 | public: |
| 73 | static const int kCallerFPOffset = -6 * kPointerSize; |
| 74 | |
| 75 | static const int kFunctionArgOffset = +3 * kPointerSize; |
| 76 | static const int kReceiverArgOffset = +4 * kPointerSize; |
| 77 | static const int kArgcOffset = +5 * kPointerSize; |
| 78 | static const int kArgvOffset = +6 * kPointerSize; |
| 79 | }; |
| 80 | |
| 81 | |
| 82 | class ExitFrameConstants : public AllStatic { |
| 83 | public: |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 84 | static const int kCodeOffset = -2 * kPointerSize; |
| 85 | static const int kSPOffset = -1 * kPointerSize; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 86 | |
| 87 | static const int kCallerFPOffset = 0 * kPointerSize; |
| 88 | static const int kCallerPCOffset = +1 * kPointerSize; |
| 89 | |
| 90 | // FP-relative displacement of the caller's SP. It points just |
| 91 | // below the saved PC. |
| 92 | static const int kCallerSPDisplacement = +2 * kPointerSize; |
| 93 | }; |
| 94 | |
| 95 | |
| 96 | class StandardFrameConstants : public AllStatic { |
| 97 | public: |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 98 | // Fixed part of the frame consists of return address, caller fp, |
| 99 | // context and function. |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 100 | // StandardFrame::IterateExpressions assumes that kContextOffset is the last |
| 101 | // object pointer. |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 102 | static const int kFixedFrameSize = 4 * kPointerSize; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 103 | static const int kExpressionsOffset = -3 * kPointerSize; |
| 104 | static const int kMarkerOffset = -2 * kPointerSize; |
| 105 | static const int kContextOffset = -1 * kPointerSize; |
| 106 | static const int kCallerFPOffset = 0 * kPointerSize; |
| 107 | static const int kCallerPCOffset = +1 * kPointerSize; |
| 108 | static const int kCallerSPOffset = +2 * kPointerSize; |
| 109 | }; |
| 110 | |
| 111 | |
| 112 | class JavaScriptFrameConstants : public AllStatic { |
| 113 | public: |
| 114 | // FP-relative. |
| 115 | static const int kLocal0Offset = StandardFrameConstants::kExpressionsOffset; |
Ben Murdoch | 8b112d2 | 2011-06-08 16:22:53 +0100 | [diff] [blame] | 116 | static const int kLastParameterOffset = +2 * kPointerSize; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 117 | static const int kFunctionOffset = StandardFrameConstants::kMarkerOffset; |
| 118 | |
| 119 | // Caller SP-relative. |
| 120 | static const int kParam0Offset = -2 * kPointerSize; |
| 121 | static const int kReceiverOffset = -1 * kPointerSize; |
| 122 | }; |
| 123 | |
| 124 | |
| 125 | class ArgumentsAdaptorFrameConstants : public AllStatic { |
| 126 | public: |
| 127 | static const int kLengthOffset = StandardFrameConstants::kExpressionsOffset; |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 128 | static const int kFrameSize = |
| 129 | StandardFrameConstants::kFixedFrameSize + kPointerSize; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 130 | }; |
| 131 | |
| 132 | |
| 133 | class InternalFrameConstants : public AllStatic { |
| 134 | public: |
| 135 | static const int kCodeOffset = StandardFrameConstants::kExpressionsOffset; |
| 136 | }; |
| 137 | |
| 138 | |
| 139 | inline Object* JavaScriptFrame::function_slot_object() const { |
| 140 | const int offset = JavaScriptFrameConstants::kFunctionOffset; |
| 141 | return Memory::Object_at(fp() + offset); |
| 142 | } |
| 143 | |
| 144 | |
| 145 | } } // namespace v8::internal |
| 146 | |
| 147 | #endif // V8_IA32_FRAMES_IA32_H_ |