interface-descriptors-mips64.cc 10.6 KB
Newer Older
1 2 3 4 5 6 7
// Copyright 2012 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.

#if V8_TARGET_ARCH_MIPS64

#include "src/interface-descriptors.h"
8 9

#include "src/frames.h"
10 11 12 13

namespace v8 {
namespace internal {

14
const Register CallInterfaceDescriptor::ContextRegister() { return cp; }
15

16 17 18 19 20 21 22 23
void CallInterfaceDescriptor::DefaultInitializePlatformSpecific(
    CallInterfaceDescriptorData* data, int register_parameter_count) {
  const Register default_stub_registers[] = {a0, a1, a2, a3, a4};
  CHECK_LE(static_cast<size_t>(register_parameter_count),
           arraysize(default_stub_registers));
  data->InitializePlatformSpecific(register_parameter_count,
                                   default_stub_registers);
}
24

25 26 27 28 29
// On MIPS it is not allowed to use odd numbered floating point registers
// (e.g. f1, f3, etc.) for parameters. This can happen if we use
// DefaultInitializePlatformSpecific to assign float registers for parameters.
// E.g if fourth parameter goes to float register, f7 would be assigned for
// parameter (a3 casted to int is 7).
30 31 32 33
bool CallInterfaceDescriptor::IsValidFloatParameterRegister(Register reg) {
  return reg.code() % 2 == 0;
}

34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
void WasmI32AtomicWaitDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  /* Register t0 correspond to f12 FPU register. */
  const Register default_stub_registers[] = {a0, a1, t0};
  CHECK_EQ(static_cast<size_t>(kParameterCount),
           arraysize(default_stub_registers));
  data->InitializePlatformSpecific(kParameterCount, default_stub_registers);
}

void WasmI64AtomicWaitDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  /* Register t0 correspond to f12 FPU register. */
  const Register default_stub_registers[] = {a0, a1, a2, t0};
  CHECK_EQ(static_cast<size_t>(kParameterCount),
           arraysize(default_stub_registers));
  data->InitializePlatformSpecific(kParameterCount, default_stub_registers);
}

52 53
void RecordWriteDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
54 55 56 57 58 59 60 61
  const Register default_stub_registers[] = {a0, a1, a2, a3, kReturnRegister0};

  data->RestrictAllocatableRegisters(default_stub_registers,
                                     arraysize(default_stub_registers));

  CHECK_LE(static_cast<size_t>(kParameterCount),
           arraysize(default_stub_registers));
  data->InitializePlatformSpecific(kParameterCount, default_stub_registers);
62 63
}

64
const Register FastNewFunctionContextDescriptor::ScopeInfoRegister() {
65 66 67 68
  return a1;
}
const Register FastNewFunctionContextDescriptor::SlotsRegister() { return a0; }

69 70
const Register LoadDescriptor::ReceiverRegister() { return a1; }
const Register LoadDescriptor::NameRegister() { return a2; }
71
const Register LoadDescriptor::SlotRegister() { return a0; }
72

73
const Register LoadWithVectorDescriptor::VectorRegister() { return a3; }
74 75 76 77

const Register StoreDescriptor::ReceiverRegister() { return a1; }
const Register StoreDescriptor::NameRegister() { return a2; }
const Register StoreDescriptor::ValueRegister() { return a0; }
78
const Register StoreDescriptor::SlotRegister() { return a4; }
79

80
const Register StoreWithVectorDescriptor::VectorRegister() { return a3; }
81

82 83 84
const Register StoreTransitionDescriptor::SlotRegister() { return a4; }
const Register StoreTransitionDescriptor::VectorRegister() { return a3; }
const Register StoreTransitionDescriptor::MapRegister() { return a5; }
85

86 87
const Register ApiGetterDescriptor::HolderRegister() { return a0; }
const Register ApiGetterDescriptor::CallbackRegister() { return a3; }
88

89 90 91 92
const Register GrowArrayElementsDescriptor::ObjectRegister() { return a0; }
const Register GrowArrayElementsDescriptor::KeyRegister() { return a3; }


93
// static
94
const Register TypeConversionDescriptor::ArgumentRegister() { return a0; }
95

96 97
void TypeofDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
98
  Register registers[] = {a3};
99
  data->InitializePlatformSpecific(arraysize(registers), registers);
100 101
}

102 103 104 105 106 107 108 109
void CallTrampolineDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // a1: target
  // a0: number of arguments
  Register registers[] = {a1, a0};
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

110 111 112 113 114
void CallVarargsDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // a0 : number of arguments (on the stack, not including receiver)
  // a1 : the target to call
  // a4 : arguments list length (untagged)
115 116
  // a2 : arguments list (FixedArray)
  Register registers[] = {a1, a0, a4, a2};
117 118 119
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

120 121 122
void CallForwardVarargsDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // a1: the target to call
123 124 125 126 127 128
  // a0: number of arguments
  // a2: start index (to support rest parameters)
  Register registers[] = {a1, a0, a2};
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

129 130 131 132 133 134 135 136 137
void CallWithSpreadDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // a0 : number of arguments (on the stack, not including receiver)
  // a1 : the target to call
  // a2 : the object to spread
  Register registers[] = {a1, a0, a2};
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

138 139 140 141 142 143 144 145 146 147 148 149 150 151
void CallWithArrayLikeDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // a1 : the target to call
  // a2 : the arguments list
  Register registers[] = {a1, a2};
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

void ConstructVarargsDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // a0 : number of arguments (on the stack, not including receiver)
  // a1 : the target to call
  // a3 : the new target
  // a4 : arguments list length (untagged)
152 153
  // a2 : arguments list (FixedArray)
  Register registers[] = {a1, a3, a0, a4, a2};
154 155 156
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

157 158 159 160 161
void ConstructForwardVarargsDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // a1: the target to call
  // a3: new target
  // a0: number of arguments
162
  // a2: start index (to support rest parameters)
163
  Register registers[] = {a1, a3, a0, a2};
164
  data->InitializePlatformSpecific(arraysize(registers), registers);
165 166
}

167 168 169 170 171 172 173 174 175 176
void ConstructWithSpreadDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // a0 : number of arguments (on the stack, not including receiver)
  // a1 : the target to call
  // a3 : the new target
  // a2 : the object to spread
  Register registers[] = {a1, a3, a0, a2};
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

177 178 179 180 181 182 183
void ConstructWithArrayLikeDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // a1 : the target to call
  // a3 : the new target
  // a2 : the arguments list
  Register registers[] = {a1, a3, a2};
  data->InitializePlatformSpecific(arraysize(registers), registers);
184
}
185

186 187 188 189 190 191 192 193 194 195
void ConstructStubDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // a1: target
  // a3: new target
  // a0: number of arguments
  // a2: allocation site or undefined
  Register registers[] = {a1, a3, a0, a2};
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

196
void AbortDescriptor::InitializePlatformSpecific(
197 198 199 200
    CallInterfaceDescriptorData* data) {
  Register registers[] = {a0};
  data->InitializePlatformSpecific(arraysize(registers), registers);
}
201

202
void AllocateHeapNumberDescriptor::InitializePlatformSpecific(
203 204
    CallInterfaceDescriptorData* data) {
  // register state
205
  data->InitializePlatformSpecific(0, nullptr);
206 207
}

208 209
void CompareDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
210
  Register registers[] = {a1, a0};
211
  data->InitializePlatformSpecific(arraysize(registers), registers);
212 213
}

214 215
void BinaryOpDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
216
  Register registers[] = {a1, a0};
217
  data->InitializePlatformSpecific(arraysize(registers), registers);
218 219
}

220
void ArgumentsAdaptorDescriptor::InitializePlatformSpecific(
221
    CallInterfaceDescriptorData* data) {
222 223
  Register registers[] = {
      a1,  // JSFunction
224
      a3,  // the new target
225 226 227
      a0,  // actual number of arguments
      a2,  // expected number of arguments
  };
228
  data->InitializePlatformSpecific(arraysize(registers), registers);
229 230
}

231
void ApiCallbackDescriptor::InitializePlatformSpecific(
232
    CallInterfaceDescriptorData* data) {
233
  Register registers[] = {
234 235 236
      JavaScriptFrame::context_register(),  // kTargetContext
      a1,                                   // kApiFunctionAddress
      a2,                                   // kArgc
237
  };
238
  data->InitializePlatformSpecific(arraysize(registers), registers);
239
}
240

241 242 243
void InterpreterDispatchDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  Register registers[] = {
244
      kInterpreterAccumulatorRegister, kInterpreterBytecodeOffsetRegister,
245
      kInterpreterBytecodeArrayRegister, kInterpreterDispatchTableRegister};
246 247
  data->InitializePlatformSpecific(arraysize(registers), registers);
}
248

249
void InterpreterPushArgsThenCallDescriptor::InitializePlatformSpecific(
250 251
    CallInterfaceDescriptorData* data) {
  Register registers[] = {
252
      a0,  // argument count (not including receiver)
253 254 255 256 257 258
      a2,  // address of first argument
      a1   // the target callable to be call
  };
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

259
void InterpreterPushArgsThenConstructDescriptor::InitializePlatformSpecific(
260 261 262
    CallInterfaceDescriptorData* data) {
  Register registers[] = {
      a0,  // argument count (not including receiver)
263
      a4,  // address of the first argument
264
      a1,  // constructor to call
265 266
      a3,  // new target
      a2,  // allocation site feedback if available, undefined otherwise
267 268
  };
  data->InitializePlatformSpecific(arraysize(registers), registers);
269 270
}

271 272 273 274
void ResumeGeneratorDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  Register registers[] = {
      v0,  // the value to pass to the generator
275
      a1   // the JSGeneratorObject to resume
276 277 278 279
  };
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

280 281 282 283 284 285 286 287
void FrameDropperTrampolineDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  Register registers[] = {
      a1,  // loaded new FP
  };
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

288 289 290 291 292 293
void RunMicrotasksEntryDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  Register registers[] = {a0, a1};
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

294 295
}  // namespace internal
}  // namespace v8
296 297

#endif  // V8_TARGET_ARCH_MIPS64