Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1 | // Copyright 2009 the V8 project authors. All rights reserved. |
| 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_X64_FRAMES_X64_H_ |
| 29 | #define V8_X64_FRAMES_X64_H_ |
| 30 | |
| 31 | namespace v8 { |
| 32 | namespace internal { |
| 33 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 34 | static const int kNumRegs = 8; |
| 35 | static const RegList kJSCallerSaved = |
| 36 | 1 << 0 | // rax |
| 37 | 1 << 1 | // rcx |
| 38 | 1 << 2 | // rdx |
| 39 | 1 << 3 | // rbx - used as a caller-saved register in JavaScript code |
| 40 | 1 << 7; // rdi - callee function |
| 41 | |
| 42 | static const int kNumJSCallerSaved = 5; |
| 43 | |
| 44 | typedef Object* JSCallerSavedBuffer[kNumJSCallerSaved]; |
| 45 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 46 | // Number of registers for which space is reserved in safepoints. |
| 47 | // TODO(x64): This should not be 0. |
| 48 | static const int kNumSafepointRegisters = 0; |
| 49 | |
| 50 | // ---------------------------------------------------- |
| 51 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 52 | class StackHandlerConstants : public AllStatic { |
| 53 | public: |
| 54 | static const int kNextOffset = 0 * kPointerSize; |
| 55 | static const int kFPOffset = 1 * kPointerSize; |
| 56 | static const int kStateOffset = 2 * kPointerSize; |
| 57 | static const int kPCOffset = 3 * kPointerSize; |
| 58 | |
| 59 | static const int kSize = 4 * kPointerSize; |
| 60 | }; |
| 61 | |
| 62 | |
| 63 | class EntryFrameConstants : public AllStatic { |
| 64 | public: |
Steve Block | 8defd9f | 2010-07-08 12:39:36 +0100 | [diff] [blame] | 65 | #ifdef _WIN64 |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 66 | static const int kCallerFPOffset = -10 * kPointerSize; |
Steve Block | 8defd9f | 2010-07-08 12:39:36 +0100 | [diff] [blame] | 67 | #else |
| 68 | static const int kCallerFPOffset = -8 * kPointerSize; |
| 69 | #endif |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 70 | static const int kArgvOffset = 6 * kPointerSize; |
| 71 | }; |
| 72 | |
| 73 | |
| 74 | class ExitFrameConstants : public AllStatic { |
| 75 | public: |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 76 | static const int kCodeOffset = -2 * kPointerSize; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 77 | static const int kSPOffset = -1 * kPointerSize; |
| 78 | |
| 79 | static const int kCallerFPOffset = +0 * kPointerSize; |
| 80 | static const int kCallerPCOffset = +1 * kPointerSize; |
| 81 | |
| 82 | // FP-relative displacement of the caller's SP. It points just |
| 83 | // below the saved PC. |
| 84 | static const int kCallerSPDisplacement = +2 * kPointerSize; |
| 85 | }; |
| 86 | |
| 87 | |
| 88 | class StandardFrameConstants : public AllStatic { |
| 89 | public: |
| 90 | static const int kExpressionsOffset = -3 * kPointerSize; |
| 91 | static const int kMarkerOffset = -2 * kPointerSize; |
| 92 | static const int kContextOffset = -1 * kPointerSize; |
| 93 | static const int kCallerFPOffset = 0 * kPointerSize; |
| 94 | static const int kCallerPCOffset = +1 * kPointerSize; |
| 95 | static const int kCallerSPOffset = +2 * kPointerSize; |
| 96 | }; |
| 97 | |
| 98 | |
| 99 | class JavaScriptFrameConstants : public AllStatic { |
| 100 | public: |
| 101 | // FP-relative. |
| 102 | static const int kLocal0Offset = StandardFrameConstants::kExpressionsOffset; |
| 103 | static const int kSavedRegistersOffset = +2 * kPointerSize; |
| 104 | static const int kFunctionOffset = StandardFrameConstants::kMarkerOffset; |
| 105 | |
| 106 | // Caller SP-relative. |
| 107 | static const int kParam0Offset = -2 * kPointerSize; |
| 108 | static const int kReceiverOffset = -1 * kPointerSize; |
| 109 | }; |
| 110 | |
| 111 | |
| 112 | class ArgumentsAdaptorFrameConstants : public AllStatic { |
| 113 | public: |
| 114 | static const int kLengthOffset = StandardFrameConstants::kExpressionsOffset; |
| 115 | }; |
| 116 | |
| 117 | |
| 118 | class InternalFrameConstants : public AllStatic { |
| 119 | public: |
| 120 | static const int kCodeOffset = StandardFrameConstants::kExpressionsOffset; |
| 121 | }; |
| 122 | |
| 123 | |
| 124 | inline Object* JavaScriptFrame::function_slot_object() const { |
| 125 | const int offset = JavaScriptFrameConstants::kFunctionOffset; |
| 126 | return Memory::Object_at(fp() + offset); |
| 127 | } |
| 128 | |
| 129 | } } // namespace v8::internal |
| 130 | |
| 131 | #endif // V8_X64_FRAMES_X64_H_ |