1e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch// Copyright 2010 the V8 project authors. All rights reserved.
2a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Redistribution and use in source and binary forms, with or without
3a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// modification, are permitted provided that the following conditions are
4a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// met:
5a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//
6a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//     * Redistributions of source code must retain the above copyright
7a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//       notice, this list of conditions and the following disclaimer.
8a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//     * Redistributions in binary form must reproduce the above
9a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//       copyright notice, this list of conditions and the following
10a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//       disclaimer in the documentation and/or other materials provided
11a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//       with the distribution.
12a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//     * Neither the name of Google Inc. nor the names of its
13a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//       contributors may be used to endorse or promote products derived
14a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//       from this software without specific prior written permission.
15a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//
16a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
28a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#ifndef V8_X64_FRAMES_X64_H_
29a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#define V8_X64_FRAMES_X64_H_
30a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
31a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blocknamespace v8 {
32a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blocknamespace internal {
33a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
341e0659c275bb392c045087af4f6b0d7565cb3d77Steve Blockstatic const int kNumRegs = 16;
35a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockstatic const RegList kJSCallerSaved =
36a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    1 << 0 |  // rax
37a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    1 << 1 |  // rcx
38a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    1 << 2 |  // rdx
39a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    1 << 3 |  // rbx - used as a caller-saved register in JavaScript code
40a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    1 << 7;   // rdi - callee function
41a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
42a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockstatic const int kNumJSCallerSaved = 5;
43a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
44a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blocktypedef Object* JSCallerSavedBuffer[kNumJSCallerSaved];
45a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
46b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch// Number of registers for which space is reserved in safepoints.
471e0659c275bb392c045087af4f6b0d7565cb3d77Steve Blockstatic const int kNumSafepointRegisters = 16;
48b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch
49b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch// ----------------------------------------------------
50b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch
51a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass StackHandlerConstants : public AllStatic {
52a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public:
53a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static const int kNextOffset  = 0 * kPointerSize;
54a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static const int kFPOffset    = 1 * kPointerSize;
55a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static const int kStateOffset = 2 * kPointerSize;
56a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static const int kPCOffset    = 3 * kPointerSize;
57a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
58a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static const int kSize = 4 * kPointerSize;
59a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block};
60a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
61a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
62a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass EntryFrameConstants : public AllStatic {
63a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public:
648defd9ff6930b4e24729971a61cf7469daf119beSteve Block#ifdef _WIN64
65a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static const int kCallerFPOffset      = -10 * kPointerSize;
668defd9ff6930b4e24729971a61cf7469daf119beSteve Block#else
678defd9ff6930b4e24729971a61cf7469daf119beSteve Block  static const int kCallerFPOffset      = -8 * kPointerSize;
688defd9ff6930b4e24729971a61cf7469daf119beSteve Block#endif
69a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static const int kArgvOffset          = 6 * kPointerSize;
70a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block};
71a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
72a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
73a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass ExitFrameConstants : public AllStatic {
74a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public:
75d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  static const int kCodeOffset      = -2 * kPointerSize;
76a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static const int kSPOffset        = -1 * kPointerSize;
77a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
78a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static const int kCallerFPOffset  = +0 * kPointerSize;
79a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static const int kCallerPCOffset  = +1 * kPointerSize;
80a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
81a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // FP-relative displacement of the caller's SP.  It points just
82a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // below the saved PC.
83a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static const int kCallerSPDisplacement = +2 * kPointerSize;
84a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block};
85a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
86a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
87a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass StandardFrameConstants : public AllStatic {
88a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public:
89a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static const int kExpressionsOffset = -3 * kPointerSize;
90a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static const int kMarkerOffset      = -2 * kPointerSize;
91a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static const int kContextOffset     = -1 * kPointerSize;
92a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static const int kCallerFPOffset    =  0 * kPointerSize;
93a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static const int kCallerPCOffset    = +1 * kPointerSize;
94a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static const int kCallerSPOffset    = +2 * kPointerSize;
95a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block};
96a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
97a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
98a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass JavaScriptFrameConstants : public AllStatic {
99a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public:
100a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // FP-relative.
101a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static const int kLocal0Offset = StandardFrameConstants::kExpressionsOffset;
1028b112d2025046f85ef7f6be087c6129c872ebad2Ben Murdoch  static const int kLastParameterOffset = +2 * kPointerSize;
103a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static const int kFunctionOffset = StandardFrameConstants::kMarkerOffset;
104a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
105a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Caller SP-relative.
106a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static const int kParam0Offset   = -2 * kPointerSize;
107a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static const int kReceiverOffset = -1 * kPointerSize;
108a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block};
109a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
110a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
111a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass ArgumentsAdaptorFrameConstants : public AllStatic {
112a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public:
113a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static const int kLengthOffset = StandardFrameConstants::kExpressionsOffset;
114a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block};
115a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
116a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
117a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass InternalFrameConstants : public AllStatic {
118a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public:
119a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static const int kCodeOffset = StandardFrameConstants::kExpressionsOffset;
120a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block};
121a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
122a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
123a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockinline Object* JavaScriptFrame::function_slot_object() const {
124a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  const int offset = JavaScriptFrameConstants::kFunctionOffset;
125a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  return Memory::Object_at(fp() + offset);
126a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block}
127a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
128a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block} }  // namespace v8::internal
129a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
130a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#endif  // V8_X64_FRAMES_X64_H_
131