• 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/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   // Need to take constant pool into account.
19   static constexpr int kCallerFPOffset = FLAG_enable_embedded_constant_pool
20                                              ? -4 * kSystemPointerSize
21                                              : -3 * kSystemPointerSize;
22 };
23 
24 class WasmCompileLazyFrameConstants : public TypedFrameConstants {
25  public:
26   static constexpr int kNumberOfSavedGpParamRegs = 7;
27   static constexpr int kNumberOfSavedFpParamRegs = 8;
28 
29   // FP-relative.
30   // The instance is pushed as part of the saved registers. Being in {r10}, it
31   // is the first register pushed (highest register code in
32   // {wasm::kGpParamRegisters}).
33   static constexpr int kWasmInstanceOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(0);
34   static constexpr int kFixedFrameSizeFromFp =
35       TypedFrameConstants::kFixedFrameSizeFromFp +
36       kNumberOfSavedGpParamRegs * kSystemPointerSize +
37       kNumberOfSavedFpParamRegs * kDoubleSize +
38       kNumberOfSavedFpParamRegs * kSimd128Size;
39 };
40 
41 // Frame constructed by the {WasmDebugBreak} builtin.
42 // After pushing the frame type marker, the builtin pushes all Liftoff cache
43 // registers (see liftoff-assembler-defs.h).
44 class WasmDebugBreakFrameConstants : public TypedFrameConstants {
45  public:
46   static constexpr RegList kPushedGpRegs = {r3, r4, r5,  r6,  r7,
47                                             r8, r9, r10, r11, cp};
48 
49   static constexpr DoubleRegList kPushedFpRegs = {d0, d1, d2, d3,  d4,  d5, d6,
50                                                   d7, d8, d9, d10, d11, d12};
51 
52   static constexpr Simd128RegList kPushedSimd128Regs = {
53       v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12};
54 
55   static constexpr int kNumPushedGpRegisters = kPushedGpRegs.Count();
56   static constexpr int kNumPushedFpRegisters = kPushedFpRegs.Count();
57 
58   static constexpr int kLastPushedGpRegisterOffset =
59       -TypedFrameConstants::kFixedFrameSizeFromFp -
60       kSystemPointerSize * kNumPushedGpRegisters;
61   static constexpr int kLastPushedFpRegisterOffset =
62       kLastPushedGpRegisterOffset - kDoubleSize * kNumPushedFpRegisters;
63 
64   // Offsets are fp-relative.
GetPushedGpRegisterOffset(int reg_code)65   static int GetPushedGpRegisterOffset(int reg_code) {
66     DCHECK_NE(0, kPushedGpRegs.bits() & (1 << reg_code));
67     uint32_t lower_regs =
68         kPushedGpRegs.bits() & ((uint32_t{1} << reg_code) - 1);
69     return kLastPushedGpRegisterOffset +
70            base::bits::CountPopulation(lower_regs) * kSystemPointerSize;
71   }
72 
GetPushedFpRegisterOffset(int reg_code)73   static int GetPushedFpRegisterOffset(int reg_code) {
74     DCHECK_NE(0, kPushedFpRegs.bits() & (1 << reg_code));
75     uint32_t lower_regs =
76         kPushedFpRegs.bits() & ((uint32_t{1} << reg_code) - 1);
77     return kLastPushedFpRegisterOffset +
78            base::bits::CountPopulation(lower_regs) * kSimd128Size;
79   }
80 };
81 
82 }  // namespace internal
83 }  // namespace v8
84 
85 #endif  // V8_EXECUTION_PPC_FRAME_CONSTANTS_PPC_H_
86