1 // Copyright 2014 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_PPC
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[] = {r3, r4, r5, r6, r7};
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[] = {r3, r4, r5, r6, r7};
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 r4;
37 }
SlotsRegister()38 const Register FastNewFunctionContextDescriptor::SlotsRegister() { return r3; }
39 
ReceiverRegister()40 const Register LoadDescriptor::ReceiverRegister() { return r4; }
NameRegister()41 const Register LoadDescriptor::NameRegister() { return r5; }
SlotRegister()42 const Register LoadDescriptor::SlotRegister() { return r3; }
43 
VectorRegister()44 const Register LoadWithVectorDescriptor::VectorRegister() { return r6; }
45 
ReceiverRegister()46 const Register StoreDescriptor::ReceiverRegister() { return r4; }
NameRegister()47 const Register StoreDescriptor::NameRegister() { return r5; }
ValueRegister()48 const Register StoreDescriptor::ValueRegister() { return r3; }
SlotRegister()49 const Register StoreDescriptor::SlotRegister() { return r7; }
50 
VectorRegister()51 const Register StoreWithVectorDescriptor::VectorRegister() { return r6; }
52 
SlotRegister()53 const Register StoreTransitionDescriptor::SlotRegister() { return r7; }
VectorRegister()54 const Register StoreTransitionDescriptor::VectorRegister() { return r6; }
MapRegister()55 const Register StoreTransitionDescriptor::MapRegister() { return r8; }
56 
HolderRegister()57 const Register ApiGetterDescriptor::HolderRegister() { return r3; }
CallbackRegister()58 const Register ApiGetterDescriptor::CallbackRegister() { return r6; }
59 
ObjectRegister()60 const Register GrowArrayElementsDescriptor::ObjectRegister() { return r3; }
KeyRegister()61 const Register GrowArrayElementsDescriptor::KeyRegister() { return r6; }
62 
63 
64 // static
ArgumentRegister()65 const Register TypeConversionDescriptor::ArgumentRegister() { return r3; }
66 
InitializePlatformSpecific(CallInterfaceDescriptorData * data)67 void TypeofDescriptor::InitializePlatformSpecific(
68     CallInterfaceDescriptorData* data) {
69   Register registers[] = {r6};
70   data->InitializePlatformSpecific(arraysize(registers), registers);
71 }
72 
InitializePlatformSpecific(CallInterfaceDescriptorData * data)73 void CallFunctionDescriptor::InitializePlatformSpecific(
74     CallInterfaceDescriptorData* data) {
75   Register registers[] = {r4};
76   data->InitializePlatformSpecific(arraysize(registers), registers);
77 }
78 
InitializePlatformSpecific(CallInterfaceDescriptorData * data)79 void CallTrampolineDescriptor::InitializePlatformSpecific(
80     CallInterfaceDescriptorData* data) {
81   // r3 : number of arguments
82   // r4 : the target to call
83   Register registers[] = {r4, r3};
84   data->InitializePlatformSpecific(arraysize(registers), registers);
85 }
86 
InitializePlatformSpecific(CallInterfaceDescriptorData * data)87 void CallVarargsDescriptor::InitializePlatformSpecific(
88     CallInterfaceDescriptorData* data) {
89   // r3 : number of arguments (on the stack, not including receiver)
90   // r4 : the target to call
91   // r5 : arguments list (FixedArray)
92   // r7 : arguments list length (untagged)
93   Register registers[] = {r4, r3, r5, r7};
94   data->InitializePlatformSpecific(arraysize(registers), registers);
95 }
96 
InitializePlatformSpecific(CallInterfaceDescriptorData * data)97 void CallForwardVarargsDescriptor::InitializePlatformSpecific(
98     CallInterfaceDescriptorData* data) {
99   // r3 : number of arguments
100   // r5 : start index (to support rest parameters)
101   // r4 : the target to call
102   Register registers[] = {r4, r3, r5};
103   data->InitializePlatformSpecific(arraysize(registers), registers);
104 }
105 
InitializePlatformSpecific(CallInterfaceDescriptorData * data)106 void CallWithSpreadDescriptor::InitializePlatformSpecific(
107     CallInterfaceDescriptorData* data) {
108   // r3 : number of arguments (on the stack, not including receiver)
109   // r4 : the target to call
110   // r5 : the object to spread
111   Register registers[] = {r4, r3, r5};
112   data->InitializePlatformSpecific(arraysize(registers), registers);
113 }
114 
InitializePlatformSpecific(CallInterfaceDescriptorData * data)115 void CallWithArrayLikeDescriptor::InitializePlatformSpecific(
116     CallInterfaceDescriptorData* data) {
117   // r4 : the target to call
118   // r5 : the arguments list
119   Register registers[] = {r4, r5};
120   data->InitializePlatformSpecific(arraysize(registers), registers);
121 }
122 
InitializePlatformSpecific(CallInterfaceDescriptorData * data)123 void ConstructVarargsDescriptor::InitializePlatformSpecific(
124     CallInterfaceDescriptorData* data) {
125   // r3 : number of arguments (on the stack, not including receiver)
126   // r4 : the target to call
127   // r6 : the new target
128   // r5 : arguments list (FixedArray)
129   // r7 : arguments list length (untagged)
130   Register registers[] = {r4, r6, r3, r5, r7};
131   data->InitializePlatformSpecific(arraysize(registers), registers);
132 }
133 
InitializePlatformSpecific(CallInterfaceDescriptorData * data)134 void ConstructForwardVarargsDescriptor::InitializePlatformSpecific(
135     CallInterfaceDescriptorData* data) {
136   // r3 : number of arguments
137   // r6 : the new target
138   // r5 : start index (to support rest parameters)
139   // r4 : the target to call
140   Register registers[] = {r4, r6, r3, r5};
141   data->InitializePlatformSpecific(arraysize(registers), registers);
142 }
143 
InitializePlatformSpecific(CallInterfaceDescriptorData * data)144 void ConstructWithSpreadDescriptor::InitializePlatformSpecific(
145     CallInterfaceDescriptorData* data) {
146   // r3 : number of arguments (on the stack, not including receiver)
147   // r4 : the target to call
148   // r6 : the new target
149   // r5 : the object to spread
150   Register registers[] = {r4, r6, r3, r5};
151   data->InitializePlatformSpecific(arraysize(registers), registers);
152 }
153 
InitializePlatformSpecific(CallInterfaceDescriptorData * data)154 void ConstructWithArrayLikeDescriptor::InitializePlatformSpecific(
155     CallInterfaceDescriptorData* data) {
156   // r4 : the target to call
157   // r6 : the new target
158   // r5 : the arguments list
159   Register registers[] = {r4, r6, r5};
160   data->InitializePlatformSpecific(arraysize(registers), registers);
161 }
162 
InitializePlatformSpecific(CallInterfaceDescriptorData * data)163 void ConstructStubDescriptor::InitializePlatformSpecific(
164     CallInterfaceDescriptorData* data) {
165   // r3 : number of arguments
166   // r4 : the target to call
167   // r6 : the new target
168   // r5 : allocation site or undefined
169   Register registers[] = {r4, r6, r3, r5};
170   data->InitializePlatformSpecific(arraysize(registers), registers);
171 }
172 
InitializePlatformSpecific(CallInterfaceDescriptorData * data)173 void AbortDescriptor::InitializePlatformSpecific(
174     CallInterfaceDescriptorData* data) {
175   Register registers[] = {r4};
176   data->InitializePlatformSpecific(arraysize(registers), registers);
177 }
178 
InitializePlatformSpecific(CallInterfaceDescriptorData * data)179 void AllocateHeapNumberDescriptor::InitializePlatformSpecific(
180     CallInterfaceDescriptorData* data) {
181   data->InitializePlatformSpecific(0, nullptr);
182 }
183 
InitializePlatformSpecific(CallInterfaceDescriptorData * data)184 void CompareDescriptor::InitializePlatformSpecific(
185     CallInterfaceDescriptorData* data) {
186   Register registers[] = {r4, r3};
187   data->InitializePlatformSpecific(arraysize(registers), registers);
188 }
189 
190 
InitializePlatformSpecific(CallInterfaceDescriptorData * data)191 void BinaryOpDescriptor::InitializePlatformSpecific(
192     CallInterfaceDescriptorData* data) {
193   Register registers[] = {r4, r3};
194   data->InitializePlatformSpecific(arraysize(registers), registers);
195 }
196 
InitializePlatformSpecific(CallInterfaceDescriptorData * data)197 void ArgumentAdaptorDescriptor::InitializePlatformSpecific(
198     CallInterfaceDescriptorData* data) {
199   Register registers[] = {
200       r4,  // JSFunction
201       r6,  // the new target
202       r3,  // actual number of arguments
203       r5,  // 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       r7,                                   // call_data
213       r5,                                   // holder
214       r4,                                   // 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       r3,  // argument count (not including receiver)
231       r5,  // address of first argument
232       r4   // 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       r3,  // argument count (not including receiver)
241       r6,  // new target
242       r4,  // constructor to call
243       r5,  // allocation site feedback if available, undefined otherwise
244       r7   // 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       r3,  // the value to pass to the generator
253       r4   // 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       r4,  // loaded new FP
262   };
263   data->InitializePlatformSpecific(arraysize(registers), registers);
264 }
265 
266 }  // namespace internal
267 }  // namespace v8
268 
269 #endif  // V8_TARGET_ARCH_PPC
270