• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 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_PPC_FRAME_CONSTANTS_PPC_H_
6 #define V8_EXECUTION_PPC_FRAME_CONSTANTS_PPC_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   // Need to take constant pool into account.
18   static constexpr int kCallerFPOffset = FLAG_enable_embedded_constant_pool
19                                              ? -4 * kSystemPointerSize
20                                              : -3 * kSystemPointerSize;
21 };
22 
23 class WasmCompileLazyFrameConstants : public TypedFrameConstants {
24  public:
25   static constexpr int kNumberOfSavedGpParamRegs = 7;
26   static constexpr int kNumberOfSavedFpParamRegs = 8;
27 
28   // FP-relative.
29   static constexpr int kWasmInstanceOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(0);
30   static constexpr int kFixedFrameSizeFromFp =
31       TypedFrameConstants::kFixedFrameSizeFromFp +
32       kNumberOfSavedGpParamRegs * kSystemPointerSize +
33       kNumberOfSavedFpParamRegs * kDoubleSize;
34 };
35 
36 // Frame constructed by the {WasmDebugBreak} builtin.
37 // After pushing the frame type marker, the builtin pushes all Liftoff cache
38 // registers (see liftoff-assembler-defs.h).
39 class WasmDebugBreakFrameConstants : public TypedFrameConstants {
40  public:
41   // {r3, r4, r5, r6, r7, r8, r9, r10, r11}
42   static constexpr uint32_t kPushedGpRegs = 0b111111111000;
43   // {d0 .. d12}
44   static constexpr uint32_t kPushedFpRegs = 0b1111111111111;
45 
46   static constexpr int kNumPushedGpRegisters =
47       base::bits::CountPopulation(kPushedGpRegs);
48   static constexpr int kNumPushedFpRegisters =
49       base::bits::CountPopulation(kPushedFpRegs);
50 
51   static constexpr int kLastPushedGpRegisterOffset =
52       -TypedFrameConstants::kFixedFrameSizeFromFp -
53       kSystemPointerSize * kNumPushedGpRegisters;
54   static constexpr int kLastPushedFpRegisterOffset =
55       kLastPushedGpRegisterOffset - kDoubleSize * kNumPushedFpRegisters;
56 
57   // Offsets are fp-relative.
GetPushedGpRegisterOffset(int reg_code)58   static int GetPushedGpRegisterOffset(int reg_code) {
59     DCHECK_NE(0, kPushedGpRegs & (1 << reg_code));
60     uint32_t lower_regs = kPushedGpRegs & ((uint32_t{1} << reg_code) - 1);
61     return kLastPushedGpRegisterOffset +
62            base::bits::CountPopulation(lower_regs) * kSystemPointerSize;
63   }
64 
GetPushedFpRegisterOffset(int reg_code)65   static int GetPushedFpRegisterOffset(int reg_code) {
66     DCHECK_NE(0, kPushedFpRegs & (1 << reg_code));
67     uint32_t lower_regs = kPushedFpRegs & ((uint32_t{1} << reg_code) - 1);
68     return kLastPushedFpRegisterOffset +
69            base::bits::CountPopulation(lower_regs) * kDoubleSize;
70   }
71 };
72 
73 }  // namespace internal
74 }  // namespace v8
75 
76 #endif  // V8_EXECUTION_PPC_FRAME_CONSTANTS_PPC_H_
77