blob: 3e3d63d62b917f4c2547dd353cbeec6b7128ef9e [file] [log] [blame]
Ben Murdochc7cc0282012-03-05 14:35:55 +00001// Copyright 2012 the V8 project authors. All rights reserved.
Steve Blocka7e24c12009-10-30 11:49:00 +00002// 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
31namespace v8 {
32namespace internal {
33
Ben Murdoch592a9fc2012-03-05 11:04:45 +000034const int kNumRegs = 16;
35const RegList kJSCallerSaved =
Steve Blocka7e24c12009-10-30 11:49:00 +000036 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
Ben Murdoch592a9fc2012-03-05 11:04:45 +000042const int kNumJSCallerSaved = 5;
Steve Blocka7e24c12009-10-30 11:49:00 +000043
44typedef Object* JSCallerSavedBuffer[kNumJSCallerSaved];
45
Ben Murdochb0fe1622011-05-05 13:52:32 +010046// Number of registers for which space is reserved in safepoints.
Ben Murdoch592a9fc2012-03-05 11:04:45 +000047const int kNumSafepointRegisters = 16;
Ben Murdochb0fe1622011-05-05 13:52:32 +010048
49// ----------------------------------------------------
50
Steve Blocka7e24c12009-10-30 11:49:00 +000051class StackHandlerConstants : public AllStatic {
52 public:
Ben Murdoch592a9fc2012-03-05 11:04:45 +000053 static const int kNextOffset = 0 * kPointerSize;
54 static const int kCodeOffset = 1 * kPointerSize;
55 static const int kStateOffset = 2 * kPointerSize;
56 static const int kContextOffset = 3 * kPointerSize;
57 static const int kFPOffset = 4 * kPointerSize;
Steve Blocka7e24c12009-10-30 11:49:00 +000058
Ben Murdoch592a9fc2012-03-05 11:04:45 +000059 static const int kSize = kFPOffset + kPointerSize;
Steve Blocka7e24c12009-10-30 11:49:00 +000060};
61
62
63class EntryFrameConstants : public AllStatic {
64 public:
Steve Block8defd9f2010-07-08 12:39:36 +010065#ifdef _WIN64
Steve Blocka7e24c12009-10-30 11:49:00 +000066 static const int kCallerFPOffset = -10 * kPointerSize;
Steve Block8defd9f2010-07-08 12:39:36 +010067#else
68 static const int kCallerFPOffset = -8 * kPointerSize;
69#endif
Steve Blocka7e24c12009-10-30 11:49:00 +000070 static const int kArgvOffset = 6 * kPointerSize;
71};
72
73
74class ExitFrameConstants : public AllStatic {
75 public:
Steve Blockd0582a62009-12-15 09:54:21 +000076 static const int kCodeOffset = -2 * kPointerSize;
Steve Blocka7e24c12009-10-30 11:49:00 +000077 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
88class StandardFrameConstants : public AllStatic {
89 public:
Ben Murdochc7cc0282012-03-05 14:35:55 +000090 // Fixed part of the frame consists of return address, caller fp,
91 // context and function.
92 static const int kFixedFrameSize = 4 * kPointerSize;
Steve Blocka7e24c12009-10-30 11:49:00 +000093 static const int kExpressionsOffset = -3 * kPointerSize;
94 static const int kMarkerOffset = -2 * kPointerSize;
95 static const int kContextOffset = -1 * kPointerSize;
96 static const int kCallerFPOffset = 0 * kPointerSize;
97 static const int kCallerPCOffset = +1 * kPointerSize;
98 static const int kCallerSPOffset = +2 * kPointerSize;
99};
100
101
102class JavaScriptFrameConstants : public AllStatic {
103 public:
104 // FP-relative.
105 static const int kLocal0Offset = StandardFrameConstants::kExpressionsOffset;
Ben Murdoch8b112d22011-06-08 16:22:53 +0100106 static const int kLastParameterOffset = +2 * kPointerSize;
Steve Blocka7e24c12009-10-30 11:49:00 +0000107 static const int kFunctionOffset = StandardFrameConstants::kMarkerOffset;
108
109 // Caller SP-relative.
110 static const int kParam0Offset = -2 * kPointerSize;
111 static const int kReceiverOffset = -1 * kPointerSize;
112};
113
114
115class ArgumentsAdaptorFrameConstants : public AllStatic {
116 public:
117 static const int kLengthOffset = StandardFrameConstants::kExpressionsOffset;
Ben Murdochc7cc0282012-03-05 14:35:55 +0000118 static const int kFrameSize =
119 StandardFrameConstants::kFixedFrameSize + kPointerSize;
Steve Blocka7e24c12009-10-30 11:49:00 +0000120};
121
122
123class InternalFrameConstants : public AllStatic {
124 public:
125 static const int kCodeOffset = StandardFrameConstants::kExpressionsOffset;
126};
127
128
129inline Object* JavaScriptFrame::function_slot_object() const {
130 const int offset = JavaScriptFrameConstants::kFunctionOffset;
131 return Memory::Object_at(fp() + offset);
132}
133
134} } // namespace v8::internal
135
136#endif // V8_X64_FRAMES_X64_H_