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