blob: 6223748d6409a687bcf87434ef0feb6386470881 [file] [log] [blame]
yangguo@chromium.org659ceec2012-01-26 07:37:54 +00001// Copyright 2012 the V8 project authors. All rights reserved.
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +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
ager@chromium.org5ec48922009-05-05 07:25:34 +000028#ifndef V8_IA32_FRAMES_IA32_H_
29#define V8_IA32_FRAMES_IA32_H_
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000030
kasperl@chromium.org71affb52009-05-26 05:44:31 +000031namespace v8 {
32namespace internal {
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000033
34
35// Register lists
36// Note that the bit values must match those used in actual instruction encoding
mstarzinger@chromium.org1b3afd12011-11-29 14:28:56 +000037const int kNumRegs = 8;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000038
39
40// Caller-saved registers
mstarzinger@chromium.org1b3afd12011-11-29 14:28:56 +000041const RegList kJSCallerSaved =
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000042 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
mstarzinger@chromium.org1b3afd12011-11-29 14:28:56 +000048const int kNumJSCallerSaved = 5;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000049
50typedef Object* JSCallerSavedBuffer[kNumJSCallerSaved];
51
kasperl@chromium.orga5551262010-12-07 12:49:48 +000052
53// Number of registers for which space is reserved in safepoints.
mstarzinger@chromium.org1b3afd12011-11-29 14:28:56 +000054const int kNumSafepointRegisters = 8;
kasperl@chromium.orga5551262010-12-07 12:49:48 +000055
mmassi@chromium.org7028c052012-06-13 11:51:58 +000056const int kNoAlignmentPadding = 0;
57const int kAlignmentPaddingPushed = 2;
58const int kAlignmentZapValue = 0x12345678; // Not heap object tagged.
59
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000060// ----------------------------------------------------
61
62
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000063class EntryFrameConstants : public AllStatic {
64 public:
65 static const int kCallerFPOffset = -6 * kPointerSize;
66
67 static const int kFunctionArgOffset = +3 * kPointerSize;
68 static const int kReceiverArgOffset = +4 * kPointerSize;
69 static const int kArgcOffset = +5 * kPointerSize;
70 static const int kArgvOffset = +6 * kPointerSize;
71};
72
73
74class ExitFrameConstants : public AllStatic {
75 public:
vegorov@chromium.org7304bca2011-05-16 12:14:13 +000076 static const int kCodeOffset = -2 * kPointerSize;
77 static const int kSPOffset = -1 * kPointerSize;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000078
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000079 static const int kCallerFPOffset = 0 * kPointerSize;
80 static const int kCallerPCOffset = +1 * kPointerSize;
ager@chromium.orgeadaf222009-06-16 09:43:10 +000081
82 // FP-relative displacement of the caller's SP. It points just
83 // below the saved PC.
84 static const int kCallerSPDisplacement = +2 * kPointerSize;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000085};
86
87
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000088class JavaScriptFrameConstants : public AllStatic {
89 public:
90 // FP-relative.
91 static const int kLocal0Offset = StandardFrameConstants::kExpressionsOffset;
kmillikin@chromium.orgc36ce6e2011-04-04 08:25:31 +000092 static const int kLastParameterOffset = +2 * kPointerSize;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000093 static const int kFunctionOffset = StandardFrameConstants::kMarkerOffset;
94
ager@chromium.orgeadaf222009-06-16 09:43:10 +000095 // Caller SP-relative.
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000096 static const int kParam0Offset = -2 * kPointerSize;
97 static const int kReceiverOffset = -1 * kPointerSize;
mmassi@chromium.org7028c052012-06-13 11:51:58 +000098
99 static const int kDynamicAlignmentStateOffset = kLocal0Offset;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000100};
101
102
103class ArgumentsAdaptorFrameConstants : public AllStatic {
104 public:
ulan@chromium.org750145a2013-03-07 15:14:13 +0000105 // FP-relative.
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000106 static const int kLengthOffset = StandardFrameConstants::kExpressionsOffset;
ulan@chromium.org750145a2013-03-07 15:14:13 +0000107
yangguo@chromium.org659ceec2012-01-26 07:37:54 +0000108 static const int kFrameSize =
109 StandardFrameConstants::kFixedFrameSize + kPointerSize;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000110};
111
112
ulan@chromium.org750145a2013-03-07 15:14:13 +0000113class ConstructFrameConstants : public AllStatic {
114 public:
115 // FP-relative.
116 static const int kImplicitReceiverOffset = -5 * kPointerSize;
117 static const int kConstructorOffset = kMinInt;
118 static const int kLengthOffset = -4 * kPointerSize;
119 static const int kCodeOffset = StandardFrameConstants::kExpressionsOffset;
120
121 static const int kFrameSize =
122 StandardFrameConstants::kFixedFrameSize + 3 * kPointerSize;
123};
124
125
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000126class InternalFrameConstants : public AllStatic {
127 public:
ulan@chromium.org750145a2013-03-07 15:14:13 +0000128 // FP-relative.
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000129 static const int kCodeOffset = StandardFrameConstants::kExpressionsOffset;
130};
131
132
ager@chromium.orgbb29dc92009-03-24 13:25:23 +0000133inline Object* JavaScriptFrame::function_slot_object() const {
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000134 const int offset = JavaScriptFrameConstants::kFunctionOffset;
ager@chromium.orgbb29dc92009-03-24 13:25:23 +0000135 return Memory::Object_at(fp() + offset);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000136}
137
138
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000139} } // namespace v8::internal
140
ager@chromium.org5ec48922009-05-05 07:25:34 +0000141#endif // V8_IA32_FRAMES_IA32_H_