| // Copyright 2011 the V8 project authors. All rights reserved. | 
 | // Use of this source code is governed by a BSD-style license that can be | 
 | // found in the LICENSE file. | 
 |  | 
 | #ifndef V8_EXECUTION_MIPS_FRAME_CONSTANTS_MIPS_H_ | 
 | #define V8_EXECUTION_MIPS_FRAME_CONSTANTS_MIPS_H_ | 
 |  | 
 | #include "src/base/bits.h" | 
 | #include "src/base/macros.h" | 
 | #include "src/execution/frame-constants.h" | 
 |  | 
 | namespace v8 { | 
 | namespace internal { | 
 |  | 
 | class EntryFrameConstants : public AllStatic { | 
 |  public: | 
 |   // This is the offset to where JSEntry pushes the current value of | 
 |   // Isolate::c_entry_fp onto the stack. | 
 |   static constexpr int kCallerFPOffset = -3 * kSystemPointerSize; | 
 |  | 
 |   // Stack offsets for arguments passed to JSEntry. | 
 |   static constexpr int kArgcOffset = +0 * kSystemPointerSize; | 
 |   static constexpr int kArgvOffset = +1 * kSystemPointerSize; | 
 | }; | 
 |  | 
 | class WasmCompileLazyFrameConstants : public TypedFrameConstants { | 
 |  public: | 
 |   static constexpr int kNumberOfSavedGpParamRegs = 3; | 
 |   static constexpr int kNumberOfSavedFpParamRegs = 7; | 
 |   static constexpr int kNumberOfSavedAllParamRegs = 10; | 
 |  | 
 |   // FP-relative. | 
 |   // See Generate_WasmCompileLazy in builtins-mips.cc. | 
 |   static constexpr int kWasmInstanceOffset = | 
 |       TYPED_FRAME_PUSHED_VALUE_OFFSET(kNumberOfSavedAllParamRegs); | 
 |   static constexpr int kFixedFrameSizeFromFp = | 
 |       TypedFrameConstants::kFixedFrameSizeFromFp + | 
 |       kNumberOfSavedGpParamRegs * kPointerSize + | 
 |       kNumberOfSavedFpParamRegs * kDoubleSize; | 
 | }; | 
 |  | 
 | // Frame constructed by the {WasmDebugBreak} builtin. | 
 | // After pushing the frame type marker, the builtin pushes all Liftoff cache | 
 | // registers (see liftoff-assembler-defs.h). | 
 | class WasmDebugBreakFrameConstants : public TypedFrameConstants { | 
 |  public: | 
 |   // {v0, v1, a0, a1, a2, a3, t0, t1, t2, t3, t4, t5, t6, s7} | 
 |   static constexpr uint32_t kPushedGpRegs = 0b111111111111100 + (1 << 23); | 
 |   // {f0, f2, f4, f6, f8, f10, f12, f14, f16, f18, f20, f22, f24} | 
 |   static constexpr uint32_t kPushedFpRegs = 0b1010101010101010101010101; | 
 |  | 
 |   static constexpr int kNumPushedGpRegisters = | 
 |       base::bits::CountPopulation(kPushedGpRegs); | 
 |   static constexpr int kNumPushedFpRegisters = | 
 |       base::bits::CountPopulation(kPushedFpRegs); | 
 |  | 
 |   static constexpr int kLastPushedGpRegisterOffset = | 
 |       -kFixedFrameSizeFromFp - kNumPushedGpRegisters * kSystemPointerSize; | 
 |   static constexpr int kLastPushedFpRegisterOffset = | 
 |       kLastPushedGpRegisterOffset - kNumPushedFpRegisters * kDoubleSize; | 
 |  | 
 |   // Offsets are fp-relative. | 
 |   static int GetPushedGpRegisterOffset(int reg_code) { | 
 |     DCHECK_NE(0, kPushedGpRegs & (1 << reg_code)); | 
 |     uint32_t lower_regs = kPushedGpRegs & ((uint32_t{1} << reg_code) - 1); | 
 |     return kLastPushedGpRegisterOffset + | 
 |            base::bits::CountPopulation(lower_regs) * kSystemPointerSize; | 
 |   } | 
 |  | 
 |   static int GetPushedFpRegisterOffset(int reg_code) { | 
 |     DCHECK_NE(0, kPushedFpRegs & (1 << reg_code)); | 
 |     uint32_t lower_regs = kPushedFpRegs & ((uint32_t{1} << reg_code) - 1); | 
 |     return kLastPushedFpRegisterOffset + | 
 |            base::bits::CountPopulation(lower_regs) * kDoubleSize; | 
 |   } | 
 | }; | 
 |  | 
 | }  // namespace internal | 
 | }  // namespace v8 | 
 |  | 
 | #endif  // V8_EXECUTION_MIPS_FRAME_CONSTANTS_MIPS_H_ |