• 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_MIPS_FRAME_CONSTANTS_MIPS_H_
6 #define V8_EXECUTION_MIPS_FRAME_CONSTANTS_MIPS_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   // Stack offsets for arguments passed to JSEntry.
22   static constexpr int kArgcOffset = +0 * kSystemPointerSize;
23   static constexpr int kArgvOffset = +1 * kSystemPointerSize;
24 };
25 
26 class WasmCompileLazyFrameConstants : public TypedFrameConstants {
27  public:
28   static constexpr int kNumberOfSavedGpParamRegs = 3;
29   static constexpr int kNumberOfSavedFpParamRegs = 7;
30   static constexpr int kNumberOfSavedAllParamRegs = 10;
31 
32   // FP-relative.
33   // See Generate_WasmCompileLazy in builtins-mips.cc.
34   static constexpr int kWasmInstanceOffset =
35       TYPED_FRAME_PUSHED_VALUE_OFFSET(kNumberOfSavedAllParamRegs);
36   static constexpr int kFixedFrameSizeFromFp =
37       TypedFrameConstants::kFixedFrameSizeFromFp +
38       kNumberOfSavedGpParamRegs * kPointerSize +
39       kNumberOfSavedFpParamRegs * kDoubleSize;
40 };
41 
42 // Frame constructed by the {WasmDebugBreak} builtin.
43 // After pushing the frame type marker, the builtin pushes all Liftoff cache
44 // registers (see liftoff-assembler-defs.h).
45 class WasmDebugBreakFrameConstants : public TypedFrameConstants {
46  public:
47   // {v0, v1, a0, a1, a2, a3, t0, t1, t2, t3, t4, t5, t6, s7}
48   static constexpr uint32_t kPushedGpRegs = 0b111111111111100 + (1 << 23);
49   // {f0, f2, f4, f6, f8, f10, f12, f14, f16, f18, f20, f22, f24}
50   static constexpr uint32_t kPushedFpRegs = 0b1010101010101010101010101;
51 
52   static constexpr int kNumPushedGpRegisters =
53       base::bits::CountPopulation(kPushedGpRegs);
54   static constexpr int kNumPushedFpRegisters =
55       base::bits::CountPopulation(kPushedFpRegs);
56 
57   static constexpr int kLastPushedGpRegisterOffset =
58       -kFixedFrameSizeFromFp - kNumPushedGpRegisters * kSystemPointerSize;
59   static constexpr int kLastPushedFpRegisterOffset =
60       kLastPushedGpRegisterOffset - kNumPushedFpRegisters * kDoubleSize;
61 
62   // Offsets are fp-relative.
GetPushedGpRegisterOffset(int reg_code)63   static int GetPushedGpRegisterOffset(int reg_code) {
64     DCHECK_NE(0, kPushedGpRegs & (1 << reg_code));
65     uint32_t lower_regs = kPushedGpRegs & ((uint32_t{1} << reg_code) - 1);
66     return kLastPushedGpRegisterOffset +
67            base::bits::CountPopulation(lower_regs) * kSystemPointerSize;
68   }
69 
GetPushedFpRegisterOffset(int reg_code)70   static int GetPushedFpRegisterOffset(int reg_code) {
71     DCHECK_NE(0, kPushedFpRegs & (1 << reg_code));
72     uint32_t lower_regs = kPushedFpRegs & ((uint32_t{1} << reg_code) - 1);
73     return kLastPushedFpRegisterOffset +
74            base::bits::CountPopulation(lower_regs) * kDoubleSize;
75   }
76 };
77 
78 }  // namespace internal
79 }  // namespace v8
80 
81 #endif  // V8_EXECUTION_MIPS_FRAME_CONSTANTS_MIPS_H_
82