1 // Copyright 2012 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_IA32_FRAME_CONSTANTS_IA32_H_ 6 #define V8_EXECUTION_IA32_FRAME_CONSTANTS_IA32_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 // This is the offset to where JSEntry pushes the current value of 19 // Isolate::c_entry_fp onto the stack. 20 static constexpr int kCallerFPOffset = -6 * kSystemPointerSize; 21 22 // EntryFrame is used by JSEntry, JSConstructEntry and JSRunMicrotasksEntry. 23 // All of them take |root_register_value| as the first parameter. 24 static constexpr int kRootRegisterValueOffset = +2 * kSystemPointerSize; 25 26 // Rest of parameters passed to JSEntry and JSConstructEntry. 27 static constexpr int kNewTargetArgOffset = +3 * kSystemPointerSize; 28 static constexpr int kFunctionArgOffset = +4 * kSystemPointerSize; 29 static constexpr int kReceiverArgOffset = +5 * kSystemPointerSize; 30 static constexpr int kArgcOffset = +6 * kSystemPointerSize; 31 static constexpr int kArgvOffset = +7 * kSystemPointerSize; 32 33 // Rest of parameters passed to JSRunMicrotasksEntry. 34 static constexpr int kMicrotaskQueueArgOffset = +3 * kSystemPointerSize; 35 }; 36 37 class WasmCompileLazyFrameConstants : public TypedFrameConstants { 38 public: 39 static constexpr int kNumberOfSavedGpParamRegs = 4; 40 static constexpr int kNumberOfSavedFpParamRegs = 6; 41 42 // FP-relative. 43 static constexpr int kWasmInstanceOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(0); 44 static constexpr int kFixedFrameSizeFromFp = 45 TypedFrameConstants::kFixedFrameSizeFromFp + 46 kNumberOfSavedGpParamRegs * kSystemPointerSize + 47 kNumberOfSavedFpParamRegs * kSimd128Size; 48 }; 49 50 // Frame constructed by the {WasmDebugBreak} builtin. 51 // After pushing the frame type marker, the builtin pushes all Liftoff cache 52 // registers (see liftoff-assembler-defs.h). 53 class WasmDebugBreakFrameConstants : public TypedFrameConstants { 54 public: 55 // Omit ebx, which is the root register. 56 static constexpr RegList kPushedGpRegs = {eax, ecx, edx, esi, edi}; 57 58 // Omit xmm7, which is the kScratchDoubleReg. 59 static constexpr DoubleRegList kPushedFpRegs = {xmm0, xmm1, xmm2, xmm3, 60 xmm4, xmm5, xmm6}; 61 62 static constexpr int kNumPushedGpRegisters = kPushedGpRegs.Count(); 63 static constexpr int kNumPushedFpRegisters = kPushedFpRegs.Count(); 64 65 static constexpr int kLastPushedGpRegisterOffset = 66 -kFixedFrameSizeFromFp - kNumPushedGpRegisters * kSystemPointerSize; 67 static constexpr int kLastPushedFpRegisterOffset = 68 kLastPushedGpRegisterOffset - kNumPushedFpRegisters * kSimd128Size; 69 70 // Offsets are fp-relative. GetPushedGpRegisterOffset(int reg_code)71 static int GetPushedGpRegisterOffset(int reg_code) { 72 DCHECK_NE(0, kPushedGpRegs.bits() & (1 << reg_code)); 73 uint32_t lower_regs = 74 kPushedGpRegs.bits() & ((uint32_t{1} << reg_code) - 1); 75 return kLastPushedGpRegisterOffset + 76 base::bits::CountPopulation(lower_regs) * kSystemPointerSize; 77 } 78 GetPushedFpRegisterOffset(int reg_code)79 static int GetPushedFpRegisterOffset(int reg_code) { 80 DCHECK_NE(0, kPushedFpRegs.bits() & (1 << reg_code)); 81 uint32_t lower_regs = 82 kPushedFpRegs.bits() & ((uint32_t{1} << reg_code) - 1); 83 return kLastPushedFpRegisterOffset + 84 base::bits::CountPopulation(lower_regs) * kSimd128Size; 85 } 86 }; 87 88 } // namespace internal 89 } // namespace v8 90 91 #endif // V8_EXECUTION_IA32_FRAME_CONSTANTS_IA32_H_ 92