• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_EXECUTION_MIPS64_FRAME_CONSTANTS_MIPS64_H_
6 #define V8_EXECUTION_MIPS64_FRAME_CONSTANTS_MIPS64_H_
7 
8 #include "src/base/bits.h"
9 #include "src/base/macros.h"
10 #include "src/codegen/register.h"
11 #include "src/execution/frame-constants.h"
12 
13 namespace v8 {
14 namespace internal {
15 
16 class EntryFrameConstants : public AllStatic {
17  public:
18   // This is the offset to where JSEntry pushes the current value of
19   // Isolate::c_entry_fp onto the stack.
20   static constexpr int kCallerFPOffset = -3 * kSystemPointerSize;
21 };
22 
23 class WasmCompileLazyFrameConstants : public TypedFrameConstants {
24  public:
25   static constexpr int kNumberOfSavedGpParamRegs = 7;
26   static constexpr int kNumberOfSavedFpParamRegs = 7;
27   static constexpr int kNumberOfSavedAllParamRegs = 14;
28 
29   // FP-relative.
30   // See Generate_WasmCompileLazy in builtins-mips64.cc.
31   static constexpr int kWasmInstanceOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(6);
32 
33   static constexpr int kFixedFrameSizeFromFp =
34       TypedFrameConstants::kFixedFrameSizeFromFp +
35       kNumberOfSavedGpParamRegs * kPointerSize +
36       kNumberOfSavedFpParamRegs * kSimd128Size;
37 };
38 
39 // Frame constructed by the {WasmDebugBreak} builtin.
40 // After pushing the frame type marker, the builtin pushes all Liftoff cache
41 // registers (see liftoff-assembler-defs.h).
42 class WasmDebugBreakFrameConstants : public TypedFrameConstants {
43  public:
44   // {v0, v1, a0, a1, a2, a3, a4, a5, a6, a7, t0, t1, t2, s7}
45   static constexpr RegList kPushedGpRegs = {v0, v1, a0, a1, a2, a3, a4,
46                                             a5, a6, a7, t0, t1, t2, s7};
47   // {f0, f2, f4, f6, f8, f10, f12, f14, f16, f18, f20, f22, f24, f26}
48   static constexpr DoubleRegList kPushedFpRegs = {
49       f0, f2, f4, f6, f8, f10, f12, f14, f16, f18, f20, f22, f24, f26};
50 
51   static constexpr int kNumPushedGpRegisters = kPushedGpRegs.Count();
52   static constexpr int kNumPushedFpRegisters = kPushedFpRegs.Count();
53 
54   static constexpr int kLastPushedGpRegisterOffset =
55       -kFixedFrameSizeFromFp - kNumPushedGpRegisters * kSystemPointerSize;
56   static constexpr int kLastPushedFpRegisterOffset =
57       kLastPushedGpRegisterOffset - kNumPushedFpRegisters * kDoubleSize;
58 
59   // Offsets are fp-relative.
GetPushedGpRegisterOffset(int reg_code)60   static int GetPushedGpRegisterOffset(int reg_code) {
61     DCHECK_NE(0, kPushedGpRegs.bits() & (1 << reg_code));
62     uint32_t lower_regs =
63         kPushedGpRegs.bits() & ((uint32_t{1} << reg_code) - 1);
64     return kLastPushedGpRegisterOffset +
65            base::bits::CountPopulation(lower_regs) * kSystemPointerSize;
66   }
67 
GetPushedFpRegisterOffset(int reg_code)68   static int GetPushedFpRegisterOffset(int reg_code) {
69     DCHECK_NE(0, kPushedFpRegs.bits() & (1 << reg_code));
70     uint32_t lower_regs =
71         kPushedFpRegs.bits() & ((uint32_t{1} << reg_code) - 1);
72     return kLastPushedFpRegisterOffset +
73            base::bits::CountPopulation(lower_regs) * kDoubleSize;
74   }
75 };
76 
77 }  // namespace internal
78 }  // namespace v8
79 
80 #endif  // V8_EXECUTION_MIPS64_FRAME_CONSTANTS_MIPS64_H_
81