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

#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 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
const Register FastNewFunctionContextDescriptor::ScopeInfoRegister() {
40 41 42 43
  return edi;
}
const Register FastNewFunctionContextDescriptor::SlotsRegister() { return eax; }

44 45
const Register LoadDescriptor::ReceiverRegister() { return edx; }
const Register LoadDescriptor::NameRegister() { return ecx; }
46
const Register LoadDescriptor::SlotRegister() { return eax; }
47

48
const Register LoadWithVectorDescriptor::VectorRegister() { return no_reg; }
49 50 51

const Register StoreDescriptor::ReceiverRegister() { return edx; }
const Register StoreDescriptor::NameRegister() { return ecx; }
52 53
const Register StoreDescriptor::ValueRegister() { return no_reg; }
const Register StoreDescriptor::SlotRegister() { return no_reg; }
54

55
const Register StoreWithVectorDescriptor::VectorRegister() { return no_reg; }
56

57
const Register StoreTransitionDescriptor::SlotRegister() { return no_reg; }
58
const Register StoreTransitionDescriptor::VectorRegister() { return no_reg; }
59
const Register StoreTransitionDescriptor::MapRegister() { return edi; }
60

61 62
const Register ApiGetterDescriptor::HolderRegister() { return ecx; }
const Register ApiGetterDescriptor::CallbackRegister() { return eax; }
63

64
const Register GrowArrayElementsDescriptor::ObjectRegister() { return eax; }
65
const Register GrowArrayElementsDescriptor::KeyRegister() { return ecx; }
66

67
// static
68
const Register TypeConversionDescriptor::ArgumentRegister() { return eax; }
69

70 71
void TypeofDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
72
  Register registers[] = {ecx};
73
  data->InitializePlatformSpecific(arraysize(registers), registers);
74 75
}

76 77 78 79 80 81 82 83
void CallTrampolineDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // eax : number of arguments
  // edi : the target to call
  Register registers[] = {edi, eax};
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

84 85 86 87 88
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)
89 90
  // On the stack : arguments list (FixedArray)
  Register registers[] = {edi, eax, ecx};
91 92 93
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

94 95
void CallForwardVarargsDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
96 97 98 99 100 101 102
  // 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);
}

103 104 105 106 107 108 109 110
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);
}

111 112 113 114
void CallWithSpreadDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // eax : number of arguments (on the stack, not including receiver)
  // edi : the target to call
115 116
  // ecx : the object to spread
  Register registers[] = {edi, eax, ecx};
117 118 119
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

120 121 122
void CallWithArrayLikeDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // edi : the target to call
123 124
  // edx : the arguments list
  Register registers[] = {edi, edx};
125 126 127 128 129 130 131 132 133
  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)
134 135
  // On the stack : arguments list (FixedArray)
  Register registers[] = {edi, edx, eax, ecx};
136 137 138
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

139 140 141 142
void ConstructForwardVarargsDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // eax : number of arguments
  // edx : the new target
143 144
  // ecx : start index (to support rest parameters)
  // edi : the target to call
145
  Register registers[] = {edi, edx, eax, ecx};
146 147
  data->InitializePlatformSpecific(arraysize(registers), registers);
}
148

149 150 151 152 153
void ConstructWithSpreadDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // eax : number of arguments (on the stack, not including receiver)
  // edi : the target to call
  // edx : the new target
154 155
  // ecx : the object to spread
  Register registers[] = {edi, edx, eax, ecx};
156 157 158
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

159 160 161 162
void ConstructWithArrayLikeDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // edi : the target to call
  // edx : the new target
163 164
  // ecx : the arguments list
  Register registers[] = {edi, edx, ecx};
165 166 167
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

168 169 170 171 172
void ConstructStubDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  // eax : number of arguments
  // edx : the new target
  // edi : the target to call
173 174 175
  // ecx : allocation site or undefined
  // TODO(jgruber): Remove the unused allocation site parameter.
  Register registers[] = {edi, edx, eax, ecx};
176 177 178
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

179
void AbortDescriptor::InitializePlatformSpecific(
180 181 182 183
    CallInterfaceDescriptorData* data) {
  Register registers[] = {edx};
  data->InitializePlatformSpecific(arraysize(registers), registers);
}
184

185
void AllocateHeapNumberDescriptor::InitializePlatformSpecific(
186 187
    CallInterfaceDescriptorData* data) {
  // register state
188
  data->InitializePlatformSpecific(0, nullptr);
189 190
}

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

197 198
void BinaryOpDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
199
  Register registers[] = {edx, eax};
200
  data->InitializePlatformSpecific(arraysize(registers), registers);
201 202
}

203
void ArgumentsAdaptorDescriptor::InitializePlatformSpecific(
204
    CallInterfaceDescriptorData* data) {
205 206
  Register registers[] = {
      edi,  // JSFunction
207
      edx,  // the new target
208
      eax,  // actual number of arguments
209
      ecx,  // expected number of arguments
210
  };
211
  data->InitializePlatformSpecific(arraysize(registers), registers);
212 213
}

214
void ApiCallbackDescriptor::InitializePlatformSpecific(
215
    CallInterfaceDescriptorData* data) {
216
  Register registers[] = {
217 218 219 220
      edx,  // kApiFunctionAddress
      ecx,  // kArgc
      eax,  // kCallData
      edi,  // kHolder
221
  };
222
  data->InitializePlatformSpecific(arraysize(registers), registers);
223
}
224

225 226 227
void InterpreterDispatchDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  Register registers[] = {
228
      kInterpreterAccumulatorRegister, kInterpreterBytecodeOffsetRegister,
229
      kInterpreterBytecodeArrayRegister, kInterpreterDispatchTableRegister};
230 231
  data->InitializePlatformSpecific(arraysize(registers), registers);
}
232

233
void InterpreterPushArgsThenCallDescriptor::InitializePlatformSpecific(
234 235
    CallInterfaceDescriptorData* data) {
  Register registers[] = {
236
      eax,  // argument count (not including receiver)
237
      ecx,  // address of first argument
238 239 240 241 242
      edi   // the target callable to be call
  };
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

243
void InterpreterPushArgsThenConstructDescriptor::InitializePlatformSpecific(
244 245 246
    CallInterfaceDescriptorData* data) {
  Register registers[] = {
      eax,  // argument count (not including receiver)
247
      ecx,  // address of first argument
248 249
  };
  data->InitializePlatformSpecific(arraysize(registers), registers);
250 251
}

252 253 254 255
void ResumeGeneratorDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  Register registers[] = {
      eax,  // the value to pass to the generator
256
      edx   // the JSGeneratorObject to resume
257 258 259 260
  };
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

261 262 263
void FrameDropperTrampolineDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  Register registers[] = {
264
      eax,  // loaded new FP
265 266 267 268
  };
  data->InitializePlatformSpecific(arraysize(registers), registers);
}

269 270 271 272 273
void RunMicrotasksEntryDescriptor::InitializePlatformSpecific(
    CallInterfaceDescriptorData* data) {
  data->InitializePlatformSpecific(0, nullptr);
}

274 275
}  // namespace internal
}  // namespace v8
276 277

#endif  // V8_TARGET_ARCH_IA32