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