OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
11 // with the distribution. | 11 // with the distribution. |
12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
15 // | 15 // |
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #ifndef V8_X64_FRAMES_X64_H_ | 28 #include "a64/constants-a64.h" |
29 #define V8_X64_FRAMES_X64_H_ | 29 #include "a64/assembler-a64.h" |
| 30 |
| 31 #ifndef V8_A64_FRAMES_A64_H_ |
| 32 #define V8_A64_FRAMES_A64_H_ |
30 | 33 |
31 namespace v8 { | 34 namespace v8 { |
32 namespace internal { | 35 namespace internal { |
33 | 36 |
34 const int kNumRegs = 16; | 37 const int kNumRegs = kNumberOfRegisters; |
35 const RegList kJSCallerSaved = | 38 // Registers x0-x17 are caller-saved. |
36 1 << 0 | // rax | 39 const int kNumJSCallerSaved = 18; |
37 1 << 1 | // rcx | 40 const RegList kJSCallerSaved = 0x3ffff; |
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 const int kNumJSCallerSaved = 5; | |
43 | |
44 typedef Object* JSCallerSavedBuffer[kNumJSCallerSaved]; | 41 typedef Object* JSCallerSavedBuffer[kNumJSCallerSaved]; |
45 | 42 |
46 // Number of registers for which space is reserved in safepoints. | 43 // Number of registers for which space is reserved in safepoints. Must be a |
47 const int kNumSafepointRegisters = 16; | 44 // multiple of eight. |
| 45 // TODO(all): Refine this number. |
| 46 const int kNumSafepointRegisters = 32; |
48 | 47 |
49 // ---------------------------------------------------- | 48 // Define the list of registers actually saved at safepoints. |
| 49 // Note that the number of saved registers may be smaller than the reserved |
| 50 // space, i.e. kNumSafepointSavedRegisters <= kNumSafepointRegisters. |
| 51 #define kSafepointSavedRegisters CPURegList::GetSafepointSavedRegisters().list() |
| 52 #define kNumSafepointSavedRegisters \ |
| 53 CPURegList::GetSafepointSavedRegisters().Count(); |
50 | 54 |
51 class EntryFrameConstants : public AllStatic { | 55 class EntryFrameConstants : public AllStatic { |
52 public: | 56 public: |
53 #ifdef _WIN64 | |
54 static const int kCalleeSaveXMMRegisters = 10; | |
55 static const int kXMMRegisterSize = 16; | |
56 static const int kXMMRegistersBlockSize = | |
57 kXMMRegisterSize * kCalleeSaveXMMRegisters; | |
58 static const int kCallerFPOffset = | 57 static const int kCallerFPOffset = |
59 -10 * kPointerSize - kXMMRegistersBlockSize; | 58 -(StandardFrameConstants::kFixedFrameSizeFromFp + kPointerSize); |
60 #else | |
61 static const int kCallerFPOffset = -8 * kPointerSize; | |
62 #endif | |
63 static const int kArgvOffset = 6 * kPointerSize; | |
64 }; | 59 }; |
65 | 60 |
66 | 61 |
67 class ExitFrameConstants : public AllStatic { | 62 class ExitFrameConstants : public AllStatic { |
68 public: | 63 public: |
69 static const int kFrameSize = 2 * kPointerSize; | 64 static const int kFrameSize = 2 * kPointerSize; |
70 | 65 |
71 static const int kCodeOffset = -2 * kPointerSize; | 66 static const int kCallerSPDisplacement = 2 * kPointerSize; |
72 static const int kSPOffset = -1 * kPointerSize; | 67 static const int kCallerPCOffset = 1 * kPointerSize; |
73 | 68 static const int kCallerFPOffset = 0 * kPointerSize; // <- fp |
74 static const int kCallerFPOffset = +0 * kPointerSize; | 69 static const int kSPOffset = -1 * kPointerSize; |
75 static const int kCallerPCOffset = kFPOnStackSize; | 70 static const int kCodeOffset = -2 * kPointerSize; |
76 | 71 static const int kLastExitFrameField = kCodeOffset; |
77 // FP-relative displacement of the caller's SP. It points just | |
78 // below the saved PC. | |
79 static const int kCallerSPDisplacement = kCallerPCOffset + kPCOnStackSize; | |
80 }; | 72 }; |
81 | 73 |
82 | 74 |
83 class JavaScriptFrameConstants : public AllStatic { | 75 class JavaScriptFrameConstants : public AllStatic { |
84 public: | 76 public: |
85 // FP-relative. | 77 // FP-relative. |
86 static const int kLocal0Offset = StandardFrameConstants::kExpressionsOffset; | 78 static const int kLocal0Offset = StandardFrameConstants::kExpressionsOffset; |
87 static const int kLastParameterOffset = kFPOnStackSize + kPCOnStackSize; | 79 |
| 80 // There are two words on the stack (saved fp and saved lr) between fp and |
| 81 // the arguments. |
| 82 static const int kLastParameterOffset = 2 * kPointerSize; |
| 83 |
88 static const int kFunctionOffset = StandardFrameConstants::kMarkerOffset; | 84 static const int kFunctionOffset = StandardFrameConstants::kMarkerOffset; |
89 | |
90 // Caller SP-relative. | |
91 static const int kParam0Offset = -2 * kPointerSize; | |
92 static const int kReceiverOffset = -1 * kPointerSize; | |
93 }; | 85 }; |
94 | 86 |
95 | 87 |
96 class ArgumentsAdaptorFrameConstants : public AllStatic { | 88 class ArgumentsAdaptorFrameConstants : public AllStatic { |
97 public: | 89 public: |
98 // FP-relative. | 90 // FP-relative. |
99 static const int kLengthOffset = StandardFrameConstants::kExpressionsOffset; | 91 static const int kLengthOffset = StandardFrameConstants::kExpressionsOffset; |
100 | 92 |
101 static const int kFrameSize = | 93 static const int kFrameSize = |
102 StandardFrameConstants::kFixedFrameSize + kPointerSize; | 94 StandardFrameConstants::kFixedFrameSize + kPointerSize; |
103 }; | 95 }; |
104 | 96 |
105 | 97 |
106 class ConstructFrameConstants : public AllStatic { | 98 class ConstructFrameConstants : public AllStatic { |
107 public: | 99 public: |
108 // FP-relative. | 100 // FP-relative. |
109 static const int kImplicitReceiverOffset = -5 * kPointerSize; | 101 static const int kCodeOffset = StandardFrameConstants::kExpressionsOffset; |
110 static const int kConstructorOffset = kMinInt; | |
111 static const int kLengthOffset = -4 * kPointerSize; | 102 static const int kLengthOffset = -4 * kPointerSize; |
112 static const int kCodeOffset = StandardFrameConstants::kExpressionsOffset; | 103 static const int kConstructorOffset = -5 * kPointerSize; |
| 104 static const int kImplicitReceiverOffset = -6 * kPointerSize; |
113 | 105 |
114 static const int kFrameSize = | 106 static const int kFrameSize = |
115 StandardFrameConstants::kFixedFrameSize + 3 * kPointerSize; | 107 StandardFrameConstants::kFixedFrameSize + 4 * kPointerSize; |
116 }; | 108 }; |
117 | 109 |
118 | 110 |
119 class InternalFrameConstants : public AllStatic { | 111 class InternalFrameConstants : public AllStatic { |
120 public: | 112 public: |
121 // FP-relative. | 113 // FP-relative. |
122 static const int kCodeOffset = StandardFrameConstants::kExpressionsOffset; | 114 static const int kCodeOffset = StandardFrameConstants::kExpressionsOffset; |
123 }; | 115 }; |
124 | 116 |
125 | 117 |
126 inline Object* JavaScriptFrame::function_slot_object() const { | 118 inline Object* JavaScriptFrame::function_slot_object() const { |
127 const int offset = JavaScriptFrameConstants::kFunctionOffset; | 119 const int offset = JavaScriptFrameConstants::kFunctionOffset; |
128 return Memory::Object_at(fp() + offset); | 120 return Memory::Object_at(fp() + offset); |
129 } | 121 } |
130 | 122 |
131 | 123 |
132 inline void StackHandler::SetFp(Address slot, Address fp) { | 124 inline void StackHandler::SetFp(Address slot, Address fp) { |
133 Memory::Address_at(slot) = fp; | 125 Memory::Address_at(slot) = fp; |
134 } | 126 } |
135 | 127 |
136 | 128 |
137 } } // namespace v8::internal | 129 } } // namespace v8::internal |
138 | 130 |
139 #endif // V8_X64_FRAMES_X64_H_ | 131 #endif // V8_A64_FRAMES_A64_H_ |
OLD | NEW |