frame-constants-mips64.h 2.82 KB
Newer Older
1 2 3 4
// 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.

5 6
#ifndef V8_EXECUTION_MIPS64_FRAME_CONSTANTS_MIPS64_H_
#define V8_EXECUTION_MIPS64_FRAME_CONSTANTS_MIPS64_H_
7

8
#include "src/base/bits.h"
9
#include "src/base/macros.h"
10
#include "src/execution/frame-constants.h"
11

12 13 14 15 16
namespace v8 {
namespace internal {

class EntryFrameConstants : public AllStatic {
 public:
17 18
  // This is the offset to where JSEntry pushes the current value of
  // Isolate::c_entry_fp onto the stack.
19
  static constexpr int kCallerFPOffset =
20 21 22
      -(StandardFrameConstants::kFixedFrameSizeFromFp + kPointerSize);
};

23 24
class WasmCompileLazyFrameConstants : public TypedFrameConstants {
 public:
25
  static constexpr int kNumberOfSavedGpParamRegs = 7;
26 27 28 29 30 31 32 33 34 35
  static constexpr int kNumberOfSavedFpParamRegs = 7;

  // FP-relative.
  static constexpr int kWasmInstanceOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(7);
  static constexpr int kFixedFrameSizeFromFp =
      TypedFrameConstants::kFixedFrameSizeFromFp +
      kNumberOfSavedGpParamRegs * kPointerSize +
      kNumberOfSavedFpParamRegs * kDoubleSize;
};

36 37 38 39 40 41 42 43 44 45 46 47 48 49
// 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, a4, a5, a6, a7, t0, t1, t2, s7}
  static constexpr uint32_t kPushedGpRegs = 0b111111111111100 + (1 << 23);
  // {f0, f2, f4, f6, f8, f10, f12, f14, f16, f18, f20, f22, f24, f26}
  static constexpr uint32_t kPushedFpRegs = 0b101010101010101010101010101;

  static constexpr int kNumPushedGpRegisters =
      base::bits::CountPopulation(kPushedGpRegs);
  static constexpr int kNumPushedFpRegisters =
      base::bits::CountPopulation(kPushedFpRegs);
50 51 52 53

  static constexpr int kLastPushedGpRegisterOffset =
      -kFixedFrameSizeFromFp - kNumPushedGpRegisters * kSystemPointerSize;
  static constexpr int kLastPushedFpRegisterOffset =
54
      kLastPushedGpRegisterOffset - kNumPushedFpRegisters * kDoubleSize;
55 56 57 58 59 60 61 62 63 64 65 66 67

  // 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 +
68
           base::bits::CountPopulation(lower_regs) * kDoubleSize;
69
  }
70 71
};

72 73
}  // namespace internal
}  // namespace v8
74

75
#endif  // V8_EXECUTION_MIPS64_FRAME_CONSTANTS_MIPS64_H_