1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef V8_MIPS_FRAME_CONSTANTS_MIPS_H_
6 #define V8_MIPS_FRAME_CONSTANTS_MIPS_H_
7 
8 #include "src/base/macros.h"
9 #include "src/frame-constants.h"
10 
11 namespace v8 {
12 namespace internal {
13 
14 class EntryFrameConstants : public AllStatic {
15  public:
16   static constexpr int kCallerFPOffset =
17       -(StandardFrameConstants::kFixedFrameSizeFromFp + kPointerSize);
18 };
19 
20 class ExitFrameConstants : public TypedFrameConstants {
21  public:
22   static constexpr int kSPOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(0);
23   static constexpr int kCodeOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(1);
24   DEFINE_TYPED_FRAME_SIZES(2);
25 
26   // The caller fields are below the frame pointer on the stack.
27   static constexpr int kCallerFPOffset = +0 * kPointerSize;
28   // The calling JS function is between FP and PC.
29   static constexpr int kCallerPCOffset = +1 * kPointerSize;
30 
31   // MIPS-specific: a pointer to the old sp to avoid unnecessary calculations.
32   static constexpr int kCallerSPOffset = +2 * kPointerSize;
33 
34   // FP-relative displacement of the caller's SP.
35   static constexpr int kCallerSPDisplacement = +2 * kPointerSize;
36 
37   static constexpr int kConstantPoolOffset = 0;  // Not used.
38 };
39 
40 class WasmCompileLazyFrameConstants : public TypedFrameConstants {
41  public:
42   static constexpr int kNumberOfSavedGpParamRegs = 4;
43   static constexpr int kNumberOfSavedFpParamRegs = 7;
44 
45   // FP-relative.
46   static constexpr int kWasmInstanceOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(3);
47   static constexpr int kFixedFrameSizeFromFp =
48       TypedFrameConstants::kFixedFrameSizeFromFp +
49       kNumberOfSavedGpParamRegs * kPointerSize +
50       kNumberOfSavedFpParamRegs * kDoubleSize;
51 };
52 
53 class JavaScriptFrameConstants : public AllStatic {
54  public:
55   // FP-relative.
56   static constexpr int kLocal0Offset =
57       StandardFrameConstants::kExpressionsOffset;
58   static constexpr int kLastParameterOffset = +2 * kPointerSize;
59   static constexpr int kFunctionOffset =
60       StandardFrameConstants::kFunctionOffset;
61 
62   // Caller SP-relative.
63   static constexpr int kParam0Offset = -2 * kPointerSize;
64   static constexpr int kReceiverOffset = -1 * kPointerSize;
65 };
66 
67 }  // namespace internal
68 }  // namespace v8
69 
70 #endif  // V8_MIPS_FRAME_CONSTANTS_MIPS_H_
71