• 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_S390_FRAME_CONSTANTS_S390_H_
6 #define V8_EXECUTION_S390_FRAME_CONSTANTS_S390_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   static constexpr int kCallerFPOffset = -3 * kSystemPointerSize;
18 
19   // Stack offsets for arguments passed to JSEntry.
20   static constexpr int kArgvOffset = 20 * kSystemPointerSize;
21 };
22 
23 class WasmCompileLazyFrameConstants : public TypedFrameConstants {
24  public:
25   static constexpr int kNumberOfSavedGpParamRegs = 4;
26 #ifdef V8_TARGET_ARCH_S390X
27   static constexpr int kNumberOfSavedFpParamRegs = 4;
28 #else
29   static constexpr int kNumberOfSavedFpParamRegs = 2;
30 #endif
31 
32   // FP-relative.
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 };
39 
40 // Frame constructed by the {WasmDebugBreak} builtin.
41 // After pushing the frame type marker, the builtin pushes all Liftoff cache
42 // registers (see liftoff-assembler-defs.h).
43 class WasmDebugBreakFrameConstants : public TypedFrameConstants {
44  public:
45   // {r2, r3, r4, r5, r6, r7, r8}
46   static constexpr uint32_t kPushedGpRegs = 0b111111100;
47   // {d0 .. d12}
48   static constexpr uint32_t kPushedFpRegs = 0b1111111111111;
49 
50   static constexpr int kNumPushedGpRegisters =
51       base::bits::CountPopulation(kPushedGpRegs);
52   static constexpr int kNumPushedFpRegisters =
53       base::bits::CountPopulation(kPushedFpRegs);
54 
55   static constexpr int kLastPushedGpRegisterOffset =
56       -TypedFrameConstants::kFixedFrameSizeFromFp -
57       kSystemPointerSize * kNumPushedGpRegisters;
58   static constexpr int kLastPushedFpRegisterOffset =
59       kLastPushedGpRegisterOffset - kDoubleSize * kNumPushedFpRegisters;
60 
61   // Offsets are fp-relative.
GetPushedGpRegisterOffset(int reg_code)62   static int GetPushedGpRegisterOffset(int reg_code) {
63     DCHECK_NE(0, kPushedGpRegs & (1 << reg_code));
64     uint32_t lower_regs = kPushedGpRegs & ((uint32_t{1} << reg_code) - 1);
65     return kLastPushedGpRegisterOffset +
66            base::bits::CountPopulation(lower_regs) * kSystemPointerSize;
67   }
68 
GetPushedFpRegisterOffset(int reg_code)69   static int GetPushedFpRegisterOffset(int reg_code) {
70     DCHECK_NE(0, kPushedFpRegs & (1 << reg_code));
71     uint32_t lower_regs = kPushedFpRegs & ((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_S390_FRAME_CONSTANTS_S390_H_
81