interface-descriptors-x64.cc 10.5 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_X64

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 rsi; }
15

16 17 18 19 20 21 22 23
void CallInterfaceDescriptor::DefaultInitializePlatformSpecific(
    CallInterfaceDescriptorData* data, int register_parameter_count) {
  const Register default_stub_registers[] = {rax, rbx, rcx, rdx, rdi};
  CHECK_LE(static_cast<size_t>(register_parameter_count),
           arraysize(default_stub_registers));
  data->InitializePlatformSpecific(register_parameter_count,
                                   default_stub_registers);
}
24

25 26
void RecordWriteDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
27 28 29 30 31 32 33 34 35 36 37 38 39
  const Register default_stub_registers[] = {arg_reg_1, arg_reg_2, arg_reg_3,
                                             arg_reg_4, 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(
    CallInterfaceDescriptorData* data) {
40 41 42 43 44 45 46 47 48 49 50
  const Register default_stub_registers[] = {arg_reg_1, arg_reg_2, arg_reg_3,
                                             arg_reg_4, 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);
}

51
const Register FastNewFunctionContextDescriptor::ScopeInfoRegister() {
52 53 54 55
  return rdi;
}
const Register FastNewFunctionContextDescriptor::SlotsRegister() { return rax; }

56 57
const Register LoadDescriptor::ReceiverRegister() { return rdx; }
const Register LoadDescriptor::NameRegister() { return rcx; }
58
const Register LoadDescriptor::SlotRegister() { return rax; }
59

60
const Register LoadWithVectorDescriptor::VectorRegister() { return rbx; }
61 62 63 64

const Register StoreDescriptor::ReceiverRegister() { return rdx; }
const Register StoreDescriptor::NameRegister() { return rcx; }
const Register StoreDescriptor::ValueRegister() { return rax; }
65
const Register StoreDescriptor::SlotRegister() { return rdi; }
66

67
const Register StoreWithVectorDescriptor::VectorRegister() { return rbx; }
68

69 70 71
const Register StoreTransitionDescriptor::SlotRegister() { return rdi; }
const Register StoreTransitionDescriptor::VectorRegister() { return rbx; }
const Register StoreTransitionDescriptor::MapRegister() { return r11; }
72

73 74
const Register ApiGetterDescriptor::HolderRegister() { return rcx; }
const Register ApiGetterDescriptor::CallbackRegister() { return rbx; }
75

76 77 78 79
const Register GrowArrayElementsDescriptor::ObjectRegister() { return rax; }
const Register GrowArrayElementsDescriptor::KeyRegister() { return rbx; }


80 81
void TypeofDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
82
  Register registers[] = {rbx};
83
  data->InitializePlatformSpecific(arraysize(registers), registers);
84 85 86
}


87
// static
88
const Register TypeConversionDescriptor::ArgumentRegister() { return rax; }
89

90 91 92 93 94 95 96 97
void CallTrampolineDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // rax : number of arguments
  // rdi : the target to call
  Register registers[] = {rdi, rax};
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

98 99 100 101 102
void CallVarargsDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // rax : number of arguments (on the stack, not including receiver)
  // rdi : the target to call
  // rcx : arguments list length (untagged)
103 104
  // rbx : arguments list (FixedArray)
  Register registers[] = {rdi, rax, rcx, rbx};
105 106 107
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

108 109
void CallForwardVarargsDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
110 111 112 113 114 115 116
  // rax : number of arguments
  // rcx : start index (to support rest parameters)
  // rdi : the target to call
  Register registers[] = {rdi, rax, rcx};
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

117 118 119 120 121 122 123 124
void CallFunctionTemplateDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // rdx: the function template info
  // rcx: number of arguments (on the stack, not including receiver)
  Register registers[] = {rdx, rcx};
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

125 126 127 128 129 130 131 132 133
void CallWithSpreadDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // rax : number of arguments (on the stack, not including receiver)
  // rdi : the target to call
  // rbx : the object to spread
  Register registers[] = {rdi, rax, rbx};
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

134 135 136 137 138 139 140 141 142 143 144 145 146 147
void CallWithArrayLikeDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // rdi : the target to call
  // rbx : the arguments list
  Register registers[] = {rdi, rbx};
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

void ConstructVarargsDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // rax : number of arguments (on the stack, not including receiver)
  // rdi : the target to call
  // rdx : the new target
  // rcx : arguments list length (untagged)
148 149
  // rbx : arguments list (FixedArray)
  Register registers[] = {rdi, rdx, rax, rcx, rbx};
150 151 152
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

153 154 155 156
void ConstructForwardVarargsDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // rax : number of arguments
  // rdx : the new target
157 158
  // rcx : start index (to support rest parameters)
  // rdi : the target to call
159
  Register registers[] = {rdi, rdx, rax, rcx};
160 161
  data->InitializePlatformSpecific(arraysize(registers), registers);
}
162

163 164 165 166 167 168 169 170 171 172
void ConstructWithSpreadDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // rax : number of arguments (on the stack, not including receiver)
  // rdi : the target to call
  // rdx : the new target
  // rbx : the object to spread
  Register registers[] = {rdi, rdx, rax, rbx};
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

173 174 175 176 177 178 179 180 181
void ConstructWithArrayLikeDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // rdi : the target to call
  // rdx : the new target
  // rbx : the arguments list
  Register registers[] = {rdi, rdx, rbx};
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

182 183 184 185 186 187 188 189
void ConstructStubDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // rax : number of arguments
  // rdx : the new target
  // rdi : the target to call
  // rbx : allocation site or undefined
  Register registers[] = {rdi, rdx, rax, rbx};
  data->InitializePlatformSpecific(arraysize(registers), registers);
190 191
}

192
void AbortDescriptor::InitializePlatformSpecific(
193 194 195 196
    CallInterfaceDescriptorData* data) {
  Register registers[] = {rdx};
  data->InitializePlatformSpecific(arraysize(registers), registers);
}
197

198
void AllocateHeapNumberDescriptor::InitializePlatformSpecific(
199
    CallInterfaceDescriptorData* data) {
200
  data->InitializePlatformSpecific(0, nullptr);
201 202
}

203 204
void CompareDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
205
  Register registers[] = {rdx, rax};
206
  data->InitializePlatformSpecific(arraysize(registers), registers);
207 208
}

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

215
void ArgumentsAdaptorDescriptor::InitializePlatformSpecific(
216
    CallInterfaceDescriptorData* data) {
217 218
  Register registers[] = {
      rdi,  // JSFunction
219
      rdx,  // the new target
220 221 222
      rax,  // actual number of arguments
      rbx,  // expected number of arguments
  };
223
  data->InitializePlatformSpecific(arraysize(registers), registers);
224 225
}

226
void ApiCallbackDescriptor::InitializePlatformSpecific(
227
    CallInterfaceDescriptorData* data) {
228
  Register registers[] = {
229 230 231 232
      rdx,  // api function address
      rcx,  // argument count (not including receiver)
      rbx,  // call data
      rdi,  // holder
233
  };
234
  data->InitializePlatformSpecific(arraysize(registers), registers);
235
}
236

237 238 239
void InterpreterDispatchDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  Register registers[] = {
240
      kInterpreterAccumulatorRegister, kInterpreterBytecodeOffsetRegister,
241
      kInterpreterBytecodeArrayRegister, kInterpreterDispatchTableRegister};
242 243
  data->InitializePlatformSpecific(arraysize(registers), registers);
}
244

245
void InterpreterPushArgsThenCallDescriptor::InitializePlatformSpecific(
246 247
    CallInterfaceDescriptorData* data) {
  Register registers[] = {
248
      rax,  // argument count (not including receiver)
249 250 251 252 253 254
      rbx,  // address of first argument
      rdi   // the target callable to be call
  };
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

255
void InterpreterPushArgsThenConstructDescriptor::InitializePlatformSpecific(
256 257 258
    CallInterfaceDescriptorData* data) {
  Register registers[] = {
      rax,  // argument count (not including receiver)
259 260
      rcx,  // address of first argument
      rdi,  // constructor to call
261
      rdx,  // new target
262
      rbx,  // allocation site feedback if available, undefined otherwise
263 264
  };
  data->InitializePlatformSpecific(arraysize(registers), registers);
265 266
}

267 268 269 270
void ResumeGeneratorDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  Register registers[] = {
      rax,  // the value to pass to the generator
271
      rdx   // the JSGeneratorObject / JSAsyncGeneratorObject to resume
272 273 274 275
  };
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

276 277 278 279 280 281 282 283
void FrameDropperTrampolineDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  Register registers[] = {
      rbx,  // loaded new FP
  };
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

284 285 286 287 288 289
void RunMicrotasksEntryDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  Register registers[] = {arg_reg_1, arg_reg_2};
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

290 291
}  // namespace internal
}  // namespace v8
292 293

#endif  // V8_TARGET_ARCH_X64