1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #if V8_TARGET_ARCH_MIPS64
6
7 #include "src/interface-descriptors.h"
8
9 namespace v8 {
10 namespace internal {
11
ContextRegister()12 const Register CallInterfaceDescriptor::ContextRegister() { return cp; }
13
DefaultInitializePlatformSpecific(CallInterfaceDescriptorData * data,int register_parameter_count)14 void CallInterfaceDescriptor::DefaultInitializePlatformSpecific(
15 CallInterfaceDescriptorData* data, int register_parameter_count) {
16 const Register default_stub_registers[] = {a0, a1, a2, a3, a4};
17 CHECK_LE(static_cast<size_t>(register_parameter_count),
18 arraysize(default_stub_registers));
19 data->InitializePlatformSpecific(register_parameter_count,
20 default_stub_registers);
21 }
22
InitializePlatformSpecific(CallInterfaceDescriptorData * data)23 void RecordWriteDescriptor::InitializePlatformSpecific(
24 CallInterfaceDescriptorData* data) {
25 const Register default_stub_registers[] = {a0, a1, a2, a3, kReturnRegister0};
26
27 data->RestrictAllocatableRegisters(default_stub_registers,
28 arraysize(default_stub_registers));
29
30 CHECK_LE(static_cast<size_t>(kParameterCount),
31 arraysize(default_stub_registers));
32 data->InitializePlatformSpecific(kParameterCount, default_stub_registers);
33 }
34
ScopeInfoRegister()35 const Register FastNewFunctionContextDescriptor::ScopeInfoRegister() {
36 return a1;
37 }
SlotsRegister()38 const Register FastNewFunctionContextDescriptor::SlotsRegister() { return a0; }
39
ReceiverRegister()40 const Register LoadDescriptor::ReceiverRegister() { return a1; }
NameRegister()41 const Register LoadDescriptor::NameRegister() { return a2; }
SlotRegister()42 const Register LoadDescriptor::SlotRegister() { return a0; }
43
VectorRegister()44 const Register LoadWithVectorDescriptor::VectorRegister() { return a3; }
45
ReceiverRegister()46 const Register StoreDescriptor::ReceiverRegister() { return a1; }
NameRegister()47 const Register StoreDescriptor::NameRegister() { return a2; }
ValueRegister()48 const Register StoreDescriptor::ValueRegister() { return a0; }
SlotRegister()49 const Register StoreDescriptor::SlotRegister() { return a4; }
50
VectorRegister()51 const Register StoreWithVectorDescriptor::VectorRegister() { return a3; }
52
SlotRegister()53 const Register StoreTransitionDescriptor::SlotRegister() { return a4; }
VectorRegister()54 const Register StoreTransitionDescriptor::VectorRegister() { return a3; }
MapRegister()55 const Register StoreTransitionDescriptor::MapRegister() { return a5; }
56
HolderRegister()57 const Register ApiGetterDescriptor::HolderRegister() { return a0; }
CallbackRegister()58 const Register ApiGetterDescriptor::CallbackRegister() { return a3; }
59
ObjectRegister()60 const Register GrowArrayElementsDescriptor::ObjectRegister() { return a0; }
KeyRegister()61 const Register GrowArrayElementsDescriptor::KeyRegister() { return a3; }
62
63
64 // static
ArgumentRegister()65 const Register TypeConversionDescriptor::ArgumentRegister() { return a0; }
66
InitializePlatformSpecific(CallInterfaceDescriptorData * data)67 void TypeofDescriptor::InitializePlatformSpecific(
68 CallInterfaceDescriptorData* data) {
69 Register registers[] = {a3};
70 data->InitializePlatformSpecific(arraysize(registers), registers);
71 }
72
InitializePlatformSpecific(CallInterfaceDescriptorData * data)73 void CallFunctionDescriptor::InitializePlatformSpecific(
74 CallInterfaceDescriptorData* data) {
75 Register registers[] = {a1};
76 data->InitializePlatformSpecific(arraysize(registers), registers);
77 }
78
InitializePlatformSpecific(CallInterfaceDescriptorData * data)79 void CallTrampolineDescriptor::InitializePlatformSpecific(
80 CallInterfaceDescriptorData* data) {
81 // a1: target
82 // a0: number of arguments
83 Register registers[] = {a1, a0};
84 data->InitializePlatformSpecific(arraysize(registers), registers);
85 }
86
InitializePlatformSpecific(CallInterfaceDescriptorData * data)87 void CallVarargsDescriptor::InitializePlatformSpecific(
88 CallInterfaceDescriptorData* data) {
89 // a0 : number of arguments (on the stack, not including receiver)
90 // a1 : the target to call
91 // a2 : arguments list (FixedArray)
92 // a4 : arguments list length (untagged)
93 Register registers[] = {a1, a0, a2, a4};
94 data->InitializePlatformSpecific(arraysize(registers), registers);
95 }
96
InitializePlatformSpecific(CallInterfaceDescriptorData * data)97 void CallForwardVarargsDescriptor::InitializePlatformSpecific(
98 CallInterfaceDescriptorData* data) {
99 // a1: the target to call
100 // a0: number of arguments
101 // a2: start index (to support rest parameters)
102 Register registers[] = {a1, a0, a2};
103 data->InitializePlatformSpecific(arraysize(registers), registers);
104 }
105
InitializePlatformSpecific(CallInterfaceDescriptorData * data)106 void CallWithSpreadDescriptor::InitializePlatformSpecific(
107 CallInterfaceDescriptorData* data) {
108 // a0 : number of arguments (on the stack, not including receiver)
109 // a1 : the target to call
110 // a2 : the object to spread
111 Register registers[] = {a1, a0, a2};
112 data->InitializePlatformSpecific(arraysize(registers), registers);
113 }
114
InitializePlatformSpecific(CallInterfaceDescriptorData * data)115 void CallWithArrayLikeDescriptor::InitializePlatformSpecific(
116 CallInterfaceDescriptorData* data) {
117 // a1 : the target to call
118 // a2 : the arguments list
119 Register registers[] = {a1, a2};
120 data->InitializePlatformSpecific(arraysize(registers), registers);
121 }
122
InitializePlatformSpecific(CallInterfaceDescriptorData * data)123 void ConstructVarargsDescriptor::InitializePlatformSpecific(
124 CallInterfaceDescriptorData* data) {
125 // a0 : number of arguments (on the stack, not including receiver)
126 // a1 : the target to call
127 // a3 : the new target
128 // a2 : arguments list (FixedArray)
129 // a4 : arguments list length (untagged)
130 Register registers[] = {a1, a3, a0, a2, a4};
131 data->InitializePlatformSpecific(arraysize(registers), registers);
132 }
133
InitializePlatformSpecific(CallInterfaceDescriptorData * data)134 void ConstructForwardVarargsDescriptor::InitializePlatformSpecific(
135 CallInterfaceDescriptorData* data) {
136 // a1: the target to call
137 // a3: new target
138 // a0: number of arguments
139 // a2: start index (to support rest parameters)
140 Register registers[] = {a1, a3, a0, a2};
141 data->InitializePlatformSpecific(arraysize(registers), registers);
142 }
143
InitializePlatformSpecific(CallInterfaceDescriptorData * data)144 void ConstructWithSpreadDescriptor::InitializePlatformSpecific(
145 CallInterfaceDescriptorData* data) {
146 // a0 : number of arguments (on the stack, not including receiver)
147 // a1 : the target to call
148 // a3 : the new target
149 // a2 : the object to spread
150 Register registers[] = {a1, a3, a0, a2};
151 data->InitializePlatformSpecific(arraysize(registers), registers);
152 }
153
InitializePlatformSpecific(CallInterfaceDescriptorData * data)154 void ConstructWithArrayLikeDescriptor::InitializePlatformSpecific(
155 CallInterfaceDescriptorData* data) {
156 // a1 : the target to call
157 // a3 : the new target
158 // a2 : the arguments list
159 Register registers[] = {a1, a3, a2};
160 data->InitializePlatformSpecific(arraysize(registers), registers);
161 }
162
InitializePlatformSpecific(CallInterfaceDescriptorData * data)163 void ConstructStubDescriptor::InitializePlatformSpecific(
164 CallInterfaceDescriptorData* data) {
165 // a1: target
166 // a3: new target
167 // a0: number of arguments
168 // a2: allocation site or undefined
169 Register registers[] = {a1, a3, a0, a2};
170 data->InitializePlatformSpecific(arraysize(registers), registers);
171 }
172
InitializePlatformSpecific(CallInterfaceDescriptorData * data)173 void AbortDescriptor::InitializePlatformSpecific(
174 CallInterfaceDescriptorData* data) {
175 Register registers[] = {a0};
176 data->InitializePlatformSpecific(arraysize(registers), registers);
177 }
178
InitializePlatformSpecific(CallInterfaceDescriptorData * data)179 void AllocateHeapNumberDescriptor::InitializePlatformSpecific(
180 CallInterfaceDescriptorData* data) {
181 // register state
182 data->InitializePlatformSpecific(0, nullptr);
183 }
184
InitializePlatformSpecific(CallInterfaceDescriptorData * data)185 void CompareDescriptor::InitializePlatformSpecific(
186 CallInterfaceDescriptorData* data) {
187 Register registers[] = {a1, a0};
188 data->InitializePlatformSpecific(arraysize(registers), registers);
189 }
190
InitializePlatformSpecific(CallInterfaceDescriptorData * data)191 void BinaryOpDescriptor::InitializePlatformSpecific(
192 CallInterfaceDescriptorData* data) {
193 Register registers[] = {a1, a0};
194 data->InitializePlatformSpecific(arraysize(registers), registers);
195 }
196
InitializePlatformSpecific(CallInterfaceDescriptorData * data)197 void ArgumentAdaptorDescriptor::InitializePlatformSpecific(
198 CallInterfaceDescriptorData* data) {
199 Register registers[] = {
200 a1, // JSFunction
201 a3, // the new target
202 a0, // actual number of arguments
203 a2, // expected number of arguments
204 };
205 data->InitializePlatformSpecific(arraysize(registers), registers);
206 }
207
InitializePlatformSpecific(CallInterfaceDescriptorData * data)208 void ApiCallbackDescriptor::InitializePlatformSpecific(
209 CallInterfaceDescriptorData* data) {
210 Register registers[] = {
211 JavaScriptFrame::context_register(), // callee context
212 a4, // call_data
213 a2, // holder
214 a1, // api_function_address
215 };
216 data->InitializePlatformSpecific(arraysize(registers), registers);
217 }
218
InitializePlatformSpecific(CallInterfaceDescriptorData * data)219 void InterpreterDispatchDescriptor::InitializePlatformSpecific(
220 CallInterfaceDescriptorData* data) {
221 Register registers[] = {
222 kInterpreterAccumulatorRegister, kInterpreterBytecodeOffsetRegister,
223 kInterpreterBytecodeArrayRegister, kInterpreterDispatchTableRegister};
224 data->InitializePlatformSpecific(arraysize(registers), registers);
225 }
226
InitializePlatformSpecific(CallInterfaceDescriptorData * data)227 void InterpreterPushArgsThenCallDescriptor::InitializePlatformSpecific(
228 CallInterfaceDescriptorData* data) {
229 Register registers[] = {
230 a0, // argument count (not including receiver)
231 a2, // address of first argument
232 a1 // the target callable to be call
233 };
234 data->InitializePlatformSpecific(arraysize(registers), registers);
235 }
236
InitializePlatformSpecific(CallInterfaceDescriptorData * data)237 void InterpreterPushArgsThenConstructDescriptor::InitializePlatformSpecific(
238 CallInterfaceDescriptorData* data) {
239 Register registers[] = {
240 a0, // argument count (not including receiver)
241 a3, // new target
242 a1, // constructor to call
243 a2, // allocation site feedback if available, undefined otherwise.
244 a4 // address of the first argument
245 };
246 data->InitializePlatformSpecific(arraysize(registers), registers);
247 }
248
InitializePlatformSpecific(CallInterfaceDescriptorData * data)249 void ResumeGeneratorDescriptor::InitializePlatformSpecific(
250 CallInterfaceDescriptorData* data) {
251 Register registers[] = {
252 v0, // the value to pass to the generator
253 a1 // the JSGeneratorObject to resume
254 };
255 data->InitializePlatformSpecific(arraysize(registers), registers);
256 }
257
InitializePlatformSpecific(CallInterfaceDescriptorData * data)258 void FrameDropperTrampolineDescriptor::InitializePlatformSpecific(
259 CallInterfaceDescriptorData* data) {
260 Register registers[] = {
261 a1, // loaded new FP
262 };
263 data->InitializePlatformSpecific(arraysize(registers), registers);
264 }
265
266 } // namespace internal
267 } // namespace v8
268
269 #endif // V8_TARGET_ARCH_MIPS64
270