interface-descriptors-ia32.cc 10.4 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_IA32

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

16 17
void CallInterfaceDescriptor::DefaultInitializePlatformSpecific(
    CallInterfaceDescriptorData* data, int register_parameter_count) {
18 19
  constexpr Register default_stub_registers[] = {eax, ecx, edx, edi};
  STATIC_ASSERT(arraysize(default_stub_registers) == kMaxBuiltinRegisterParams);
20 21 22 23 24
  CHECK_LE(static_cast<size_t>(register_parameter_count),
           arraysize(default_stub_registers));
  data->InitializePlatformSpecific(register_parameter_count,
                                   default_stub_registers);
}
25

26 27
void RecordWriteDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
28
  static const Register default_stub_registers[] = {ecx, edx, esi, edi,
29 30 31 32 33 34 35 36
                                                    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);
37 38
}

39 40 41 42 43 44 45 46 47 48 49 50 51
void EphemeronKeyBarrierDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  static const Register default_stub_registers[] = {ecx, edx, esi, edi,
                                                    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);
}

52
const Register FastNewFunctionContextDescriptor::ScopeInfoRegister() {
53 54 55 56
  return edi;
}
const Register FastNewFunctionContextDescriptor::SlotsRegister() { return eax; }

57 58
const Register LoadDescriptor::ReceiverRegister() { return edx; }
const Register LoadDescriptor::NameRegister() { return ecx; }
59
const Register LoadDescriptor::SlotRegister() { return eax; }
60

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

const Register StoreDescriptor::ReceiverRegister() { return edx; }
const Register StoreDescriptor::NameRegister() { return ecx; }
65 66
const Register StoreDescriptor::ValueRegister() { return no_reg; }
const Register StoreDescriptor::SlotRegister() { return no_reg; }
67

68
const Register StoreWithVectorDescriptor::VectorRegister() { return no_reg; }
69

70
const Register StoreTransitionDescriptor::SlotRegister() { return no_reg; }
71
const Register StoreTransitionDescriptor::VectorRegister() { return no_reg; }
72
const Register StoreTransitionDescriptor::MapRegister() { return edi; }
73

74 75
const Register ApiGetterDescriptor::HolderRegister() { return ecx; }
const Register ApiGetterDescriptor::CallbackRegister() { return eax; }
76

77
const Register GrowArrayElementsDescriptor::ObjectRegister() { return eax; }
78
const Register GrowArrayElementsDescriptor::KeyRegister() { return ecx; }
79

80
// static
81
const Register TypeConversionDescriptor::ArgumentRegister() { return eax; }
82

83 84
void TypeofDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
85
  Register registers[] = {ecx};
86
  data->InitializePlatformSpecific(arraysize(registers), registers);
87 88
}

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

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

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

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

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

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

void ConstructVarargsDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // eax : number of arguments (on the stack, not including receiver)
  // edi : the target to call
  // edx : the new target
  // ecx : arguments list length (untagged)
147 148
  // On the stack : arguments list (FixedArray)
  Register registers[] = {edi, edx, eax, ecx};
149 150 151
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

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

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

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

181 182 183 184 185
void ConstructStubDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // eax : number of arguments
  // edx : the new target
  // edi : the target to call
186 187 188
  // ecx : allocation site or undefined
  // TODO(jgruber): Remove the unused allocation site parameter.
  Register registers[] = {edi, edx, eax, ecx};
189 190 191
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

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

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

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

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

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

227
void ApiCallbackDescriptor::InitializePlatformSpecific(
228
    CallInterfaceDescriptorData* data) {
229
  Register registers[] = {
230 231 232 233
      edx,  // kApiFunctionAddress
      ecx,  // kArgc
      eax,  // kCallData
      edi,  // kHolder
234
  };
235
  data->InitializePlatformSpecific(arraysize(registers), registers);
236
}
237

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

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

256
void InterpreterPushArgsThenConstructDescriptor::InitializePlatformSpecific(
257 258 259
    CallInterfaceDescriptorData* data) {
  Register registers[] = {
      eax,  // argument count (not including receiver)
260
      ecx,  // address of first argument
261 262
  };
  data->InitializePlatformSpecific(arraysize(registers), registers);
263 264
}

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

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

282 283 284 285 286
void RunMicrotasksEntryDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  data->InitializePlatformSpecific(0, nullptr);
}

287 288
}  // namespace internal
}  // namespace v8
289 290

#endif  // V8_TARGET_ARCH_IA32