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

7
#include "src/codegen/interface-descriptors.h"
8

9
#include "src/execution/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
void WasmI32AtomicWait32Descriptor::InitializePlatformSpecific(
35
    CallInterfaceDescriptorData* data) {
36
  const Register default_stub_registers[] = {a0, a1, a2, a3};
37 38 39 40 41
  CHECK_EQ(static_cast<size_t>(kParameterCount),
           arraysize(default_stub_registers));
  data->InitializePlatformSpecific(kParameterCount, default_stub_registers);
}

42 43 44 45 46 47 48 49 50
void WasmI64AtomicWait32Descriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  const Register default_stub_registers[] = {a0, a1, a2, a3, a4};
  CHECK_EQ(static_cast<size_t>(kParameterCount - kStackArgumentsCount),
           arraysize(default_stub_registers));
  data->InitializePlatformSpecific(kParameterCount - kStackArgumentsCount,
                                   default_stub_registers);
}

51
void RecordWriteDescriptor::InitializePlatformSpecific(
52 53 54 55 56 57 58 59 60 61 62 63
    CallInterfaceDescriptorData* data) {
  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);
}

void EphemeronKeyBarrierDescriptor::InitializePlatformSpecific(
64
    CallInterfaceDescriptorData* data) {
65 66 67 68 69 70 71 72
  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);
73 74
}

75 76
const Register LoadDescriptor::ReceiverRegister() { return a1; }
const Register LoadDescriptor::NameRegister() { return a2; }
77
const Register LoadDescriptor::SlotRegister() { return a0; }
78

79
const Register LoadWithVectorDescriptor::VectorRegister() { return a3; }
80 81 82 83

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

86
const Register StoreWithVectorDescriptor::VectorRegister() { return a3; }
87

88 89 90
const Register StoreTransitionDescriptor::SlotRegister() { return a4; }
const Register StoreTransitionDescriptor::VectorRegister() { return a3; }
const Register StoreTransitionDescriptor::MapRegister() { return a5; }
91

92 93
const Register ApiGetterDescriptor::HolderRegister() { return a0; }
const Register ApiGetterDescriptor::CallbackRegister() { return a3; }
94

95 96 97
const Register GrowArrayElementsDescriptor::ObjectRegister() { return a0; }
const Register GrowArrayElementsDescriptor::KeyRegister() { return a3; }

98
// static
99
const Register TypeConversionDescriptor::ArgumentRegister() { return a0; }
100

101 102
void TypeofDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
103
  Register registers[] = {a3};
104
  data->InitializePlatformSpecific(arraysize(registers), registers);
105 106
}

107 108 109 110 111 112 113 114
void CallTrampolineDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // a1: target
  // a0: number of arguments
  Register registers[] = {a1, a0};
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

115 116 117 118 119
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)
120 121
  // a2 : arguments list (FixedArray)
  Register registers[] = {a1, a0, a4, a2};
122 123 124
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

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

Yu Yin's avatar
Yu Yin committed
134 135 136 137 138 139 140 141
void CallFunctionTemplateDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // a1 : function template info
  // a0 : number of arguments (on the stack, not including receiver)
  Register registers[] = {a1, a0};
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

142 143 144 145 146 147 148 149 150
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);
}

151 152 153 154 155 156 157 158 159 160 161 162 163 164
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)
165 166
  // a2 : arguments list (FixedArray)
  Register registers[] = {a1, a3, a0, a4, a2};
167 168 169
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

170 171 172 173 174
void ConstructForwardVarargsDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // a1: the target to call
  // a3: new target
  // a0: number of arguments
175
  // a2: start index (to support rest parameters)
176
  Register registers[] = {a1, a3, a0, a2};
177
  data->InitializePlatformSpecific(arraysize(registers), registers);
178 179
}

180 181 182 183 184 185 186 187 188 189
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);
}

190 191 192 193 194 195 196
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);
197
}
198

199 200 201 202 203 204 205 206 207 208
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);
}

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

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

221 222
void BinaryOpDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
223
  Register registers[] = {a1, a0};
224
  data->InitializePlatformSpecific(arraysize(registers), registers);
225 226
}

227
void ArgumentsAdaptorDescriptor::InitializePlatformSpecific(
228
    CallInterfaceDescriptorData* data) {
229 230
  Register registers[] = {
      a1,  // JSFunction
231
      a3,  // the new target
232 233 234
      a0,  // actual number of arguments
      a2,  // expected number of arguments
  };
235
  data->InitializePlatformSpecific(arraysize(registers), registers);
236 237
}

238
void ApiCallbackDescriptor::InitializePlatformSpecific(
239
    CallInterfaceDescriptorData* data) {
240
  Register registers[] = {
241 242 243 244
      a1,  // kApiFunctionAddress
      a2,  // kArgc
      a3,  // kCallData
      a0,  // kHolder
245
  };
246
  data->InitializePlatformSpecific(arraysize(registers), registers);
247
}
248

249 250 251
void InterpreterDispatchDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  Register registers[] = {
252
      kInterpreterAccumulatorRegister, kInterpreterBytecodeOffsetRegister,
253
      kInterpreterBytecodeArrayRegister, kInterpreterDispatchTableRegister};
254 255
  data->InitializePlatformSpecific(arraysize(registers), registers);
}
256

257
void InterpreterPushArgsThenCallDescriptor::InitializePlatformSpecific(
258 259
    CallInterfaceDescriptorData* data) {
  Register registers[] = {
260
      a0,  // argument count (not including receiver)
261 262 263 264 265 266
      a2,  // address of first argument
      a1   // the target callable to be call
  };
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

267
void InterpreterPushArgsThenConstructDescriptor::InitializePlatformSpecific(
268 269 270
    CallInterfaceDescriptorData* data) {
  Register registers[] = {
      a0,  // argument count (not including receiver)
271
      a4,  // address of the first argument
272
      a1,  // constructor to call
273 274
      a3,  // new target
      a2,  // allocation site feedback if available, undefined otherwise
275 276
  };
  data->InitializePlatformSpecific(arraysize(registers), registers);
277 278
}

279 280 281 282
void ResumeGeneratorDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  Register registers[] = {
      v0,  // the value to pass to the generator
283
      a1   // the JSGeneratorObject to resume
284 285 286 287
  };
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

288 289 290 291 292 293 294 295
void FrameDropperTrampolineDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  Register registers[] = {
      a1,  // loaded new FP
  };
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

296 297 298 299 300 301
void RunMicrotasksEntryDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  Register registers[] = {a0, a1};
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

302 303 304 305 306 307 308 309 310 311 312 313
void BinaryOp_WithFeedbackDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // TODO(v8:8888): Implement on this platform.
  DefaultInitializePlatformSpecific(data, 4);
}

void CallTrampoline_WithFeedbackDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // TODO(v8:8888): Implement on this platform.
  DefaultInitializePlatformSpecific(data, 4);
}

314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337
void CallWithArrayLike_WithFeedbackDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // TODO(v8:8888): Implement on this platform.
  DefaultInitializePlatformSpecific(data, 4);
}

void CallWithSpread_WithFeedbackDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // TODO(v8:8888): Implement on this platform.
  DefaultInitializePlatformSpecific(data, 4);
}

void ConstructWithArrayLike_WithFeedbackDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // TODO(v8:8888): Implement on this platform.
  DefaultInitializePlatformSpecific(data, 4);
}

void ConstructWithSpread_WithFeedbackDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // TODO(v8:8888): Implement on this platform.
  DefaultInitializePlatformSpecific(data, 4);
}

338 339 340 341 342 343 344 345 346 347 348 349
void Compare_WithFeedbackDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // TODO(v8:8888): Implement on this platform.
  DefaultInitializePlatformSpecific(data, 4);
}

void UnaryOp_WithFeedbackDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // TODO(v8:8888): Implement on this platform.
  DefaultInitializePlatformSpecific(data, 3);
}

350 351
}  // namespace internal
}  // namespace v8
352 353

#endif  // V8_TARGET_ARCH_MIPS64