ager@chromium.org | 5ec4892 | 2009-05-05 07:25:34 +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 | |
ager@chromium.org | 9085a01 | 2009-05-11 19:22:57 +0000 | [diff] [blame] | 28 | #ifndef V8_X64_FRAMES_X64_H_ |
| 29 | #define V8_X64_FRAMES_X64_H_ |
| 30 | |
kasperl@chromium.org | 71affb5 | 2009-05-26 05:44:31 +0000 | [diff] [blame] | 31 | namespace v8 { |
| 32 | namespace internal { |
ager@chromium.org | 9085a01 | 2009-05-11 19:22:57 +0000 | [diff] [blame] | 33 | |
ager@chromium.org | 9085a01 | 2009-05-11 19:22:57 +0000 | [diff] [blame] | 34 | static const int kNumRegs = 8; |
ager@chromium.org | eadaf22 | 2009-06-16 09:43:10 +0000 | [diff] [blame] | 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 | |
ager@chromium.org | 9085a01 | 2009-05-11 19:22:57 +0000 | [diff] [blame] | 42 | static const int kNumJSCallerSaved = 5; |
ager@chromium.org | eadaf22 | 2009-06-16 09:43:10 +0000 | [diff] [blame] | 43 | |
ager@chromium.org | 9085a01 | 2009-05-11 19:22:57 +0000 | [diff] [blame] | 44 | typedef Object* JSCallerSavedBuffer[kNumJSCallerSaved]; |
| 45 | |
| 46 | class StackHandlerConstants : public AllStatic { |
| 47 | public: |
ager@chromium.org | e2902be | 2009-06-08 12:21:35 +0000 | [diff] [blame] | 48 | static const int kNextOffset = 0 * kPointerSize; |
ager@chromium.org | eadaf22 | 2009-06-16 09:43:10 +0000 | [diff] [blame] | 49 | static const int kFPOffset = 1 * kPointerSize; |
| 50 | static const int kStateOffset = 2 * kPointerSize; |
| 51 | static const int kPCOffset = 3 * kPointerSize; |
ager@chromium.org | 9085a01 | 2009-05-11 19:22:57 +0000 | [diff] [blame] | 52 | |
ager@chromium.org | eadaf22 | 2009-06-16 09:43:10 +0000 | [diff] [blame] | 53 | static const int kSize = 4 * kPointerSize; |
ager@chromium.org | 9085a01 | 2009-05-11 19:22:57 +0000 | [diff] [blame] | 54 | }; |
| 55 | |
| 56 | |
| 57 | class EntryFrameConstants : public AllStatic { |
| 58 | public: |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 59 | static const int kCallerFPOffset = -10 * kPointerSize; |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 60 | static const int kArgvOffset = 6 * kPointerSize; |
ager@chromium.org | 9085a01 | 2009-05-11 19:22:57 +0000 | [diff] [blame] | 61 | }; |
| 62 | |
| 63 | |
| 64 | class ExitFrameConstants : public AllStatic { |
| 65 | public: |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 66 | static const int kCodeOffset = -2 * kPointerSize; |
ager@chromium.org | 9085a01 | 2009-05-11 19:22:57 +0000 | [diff] [blame] | 67 | static const int kSPOffset = -1 * kPointerSize; |
| 68 | |
ager@chromium.org | eadaf22 | 2009-06-16 09:43:10 +0000 | [diff] [blame] | 69 | static const int kCallerFPOffset = +0 * kPointerSize; |
| 70 | static const int kCallerPCOffset = +1 * kPointerSize; |
ager@chromium.org | 9085a01 | 2009-05-11 19:22:57 +0000 | [diff] [blame] | 71 | |
ager@chromium.org | eadaf22 | 2009-06-16 09:43:10 +0000 | [diff] [blame] | 72 | // FP-relative displacement of the caller's SP. It points just |
| 73 | // below the saved PC. |
| 74 | static const int kCallerSPDisplacement = +2 * kPointerSize; |
ager@chromium.org | 9085a01 | 2009-05-11 19:22:57 +0000 | [diff] [blame] | 75 | }; |
| 76 | |
| 77 | |
| 78 | class StandardFrameConstants : public AllStatic { |
| 79 | public: |
ager@chromium.org | eadaf22 | 2009-06-16 09:43:10 +0000 | [diff] [blame] | 80 | static const int kExpressionsOffset = -3 * kPointerSize; |
| 81 | static const int kMarkerOffset = -2 * kPointerSize; |
ager@chromium.org | 9085a01 | 2009-05-11 19:22:57 +0000 | [diff] [blame] | 82 | static const int kContextOffset = -1 * kPointerSize; |
ager@chromium.org | eadaf22 | 2009-06-16 09:43:10 +0000 | [diff] [blame] | 83 | static const int kCallerFPOffset = 0 * kPointerSize; |
| 84 | static const int kCallerPCOffset = +1 * kPointerSize; |
| 85 | static const int kCallerSPOffset = +2 * kPointerSize; |
ager@chromium.org | 9085a01 | 2009-05-11 19:22:57 +0000 | [diff] [blame] | 86 | }; |
| 87 | |
| 88 | |
| 89 | class JavaScriptFrameConstants : public AllStatic { |
| 90 | public: |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 91 | // FP-relative. |
ager@chromium.org | 9085a01 | 2009-05-11 19:22:57 +0000 | [diff] [blame] | 92 | static const int kLocal0Offset = StandardFrameConstants::kExpressionsOffset; |
ager@chromium.org | eadaf22 | 2009-06-16 09:43:10 +0000 | [diff] [blame] | 93 | static const int kSavedRegistersOffset = +2 * kPointerSize; |
ager@chromium.org | 9085a01 | 2009-05-11 19:22:57 +0000 | [diff] [blame] | 94 | static const int kFunctionOffset = StandardFrameConstants::kMarkerOffset; |
| 95 | |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 96 | // Caller SP-relative. |
ager@chromium.org | eadaf22 | 2009-06-16 09:43:10 +0000 | [diff] [blame] | 97 | static const int kParam0Offset = -2 * kPointerSize; |
ager@chromium.org | 9085a01 | 2009-05-11 19:22:57 +0000 | [diff] [blame] | 98 | static const int kReceiverOffset = -1 * kPointerSize; |
| 99 | }; |
| 100 | |
| 101 | |
| 102 | class ArgumentsAdaptorFrameConstants : public AllStatic { |
| 103 | public: |
| 104 | static const int kLengthOffset = StandardFrameConstants::kExpressionsOffset; |
| 105 | }; |
| 106 | |
| 107 | |
| 108 | class InternalFrameConstants : public AllStatic { |
| 109 | public: |
| 110 | static const int kCodeOffset = StandardFrameConstants::kExpressionsOffset; |
| 111 | }; |
| 112 | |
| 113 | |
| 114 | inline Object* JavaScriptFrame::function_slot_object() const { |
| 115 | const int offset = JavaScriptFrameConstants::kFunctionOffset; |
| 116 | return Memory::Object_at(fp() + offset); |
| 117 | } |
| 118 | |
| 119 | } } // namespace v8::internal |
| 120 | |
| 121 | #endif // V8_X64_FRAMES_X64_H_ |