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 #include "src/v8.h" 6 7 #if V8_TARGET_ARCH_ARM 8 9 #include "src/interface-descriptors.h" 10 11 namespace v8 { 12 namespace internal { 13 14 const Register CallInterfaceDescriptor::ContextRegister() { return cp; } 15 16 17 const Register LoadDescriptor::ReceiverRegister() { return r1; } 18 const Register LoadDescriptor::NameRegister() { return r2; } 19 20 21 const Register VectorLoadICTrampolineDescriptor::SlotRegister() { return r0; } 22 23 24 const Register VectorLoadICDescriptor::VectorRegister() { return r3; } 25 26 27 const Register StoreDescriptor::ReceiverRegister() { return r1; } 28 const Register StoreDescriptor::NameRegister() { return r2; } 29 const Register StoreDescriptor::ValueRegister() { return r0; } 30 31 32 const Register ElementTransitionAndStoreDescriptor::MapRegister() { return r3; } 33 34 35 const Register InstanceofDescriptor::left() { return r0; } 36 const Register InstanceofDescriptor::right() { return r1; } 37 38 39 const Register ArgumentsAccessReadDescriptor::index() { return r1; } 40 const Register ArgumentsAccessReadDescriptor::parameter_count() { return r0; } 41 42 43 const Register ApiGetterDescriptor::function_address() { return r2; } 44 45 46 const Register MathPowTaggedDescriptor::exponent() { return r2; } 47 48 49 const Register MathPowIntegerDescriptor::exponent() { 50 return MathPowTaggedDescriptor::exponent(); 51 } 52 53 54 void FastNewClosureDescriptor::Initialize(CallInterfaceDescriptorData* data) { 55 Register registers[] = {cp, r2}; 56 data->Initialize(arraysize(registers), registers, NULL); 57 } 58 59 60 void FastNewContextDescriptor::Initialize(CallInterfaceDescriptorData* data) { 61 Register registers[] = {cp, r1}; 62 data->Initialize(arraysize(registers), registers, NULL); 63 } 64 65 66 void ToNumberDescriptor::Initialize(CallInterfaceDescriptorData* data) { 67 Register registers[] = {cp, r0}; 68 data->Initialize(arraysize(registers), registers, NULL); 69 } 70 71 72 void NumberToStringDescriptor::Initialize(CallInterfaceDescriptorData* data) { 73 Register registers[] = {cp, r0}; 74 data->Initialize(arraysize(registers), registers, NULL); 75 } 76 77 78 void FastCloneShallowArrayDescriptor::Initialize( 79 CallInterfaceDescriptorData* data) { 80 Register registers[] = {cp, r3, r2, r1}; 81 Representation representations[] = { 82 Representation::Tagged(), Representation::Tagged(), Representation::Smi(), 83 Representation::Tagged()}; 84 data->Initialize(arraysize(registers), registers, representations); 85 } 86 87 88 void FastCloneShallowObjectDescriptor::Initialize( 89 CallInterfaceDescriptorData* data) { 90 Register registers[] = {cp, r3, r2, r1, r0}; 91 data->Initialize(arraysize(registers), registers, NULL); 92 } 93 94 95 void CreateAllocationSiteDescriptor::Initialize( 96 CallInterfaceDescriptorData* data) { 97 Register registers[] = {cp, r2, r3}; 98 data->Initialize(arraysize(registers), registers, NULL); 99 } 100 101 102 void StoreArrayLiteralElementDescriptor::Initialize( 103 CallInterfaceDescriptorData* data) { 104 Register registers[] = {cp, r3, r0}; 105 data->Initialize(arraysize(registers), registers, NULL); 106 } 107 108 109 void CallFunctionDescriptor::Initialize(CallInterfaceDescriptorData* data) { 110 Register registers[] = {cp, r1}; 111 data->Initialize(arraysize(registers), registers, NULL); 112 } 113 114 115 void CallFunctionWithFeedbackDescriptor::Initialize( 116 CallInterfaceDescriptorData* data) { 117 Register registers[] = {cp, r1, r3}; 118 Representation representations[] = {Representation::Tagged(), 119 Representation::Tagged(), 120 Representation::Smi()}; 121 data->Initialize(arraysize(registers), registers, representations); 122 } 123 124 125 void CallConstructDescriptor::Initialize(CallInterfaceDescriptorData* data) { 126 // r0 : number of arguments 127 // r1 : the function to call 128 // r2 : feedback vector 129 // r3 : (only if r2 is not the megamorphic symbol) slot in feedback 130 // vector (Smi) 131 // TODO(turbofan): So far we don't gather type feedback and hence skip the 132 // slot parameter, but ArrayConstructStub needs the vector to be undefined. 133 Register registers[] = {cp, r0, r1, r2}; 134 data->Initialize(arraysize(registers), registers, NULL); 135 } 136 137 138 void RegExpConstructResultDescriptor::Initialize( 139 CallInterfaceDescriptorData* data) { 140 Register registers[] = {cp, r2, r1, r0}; 141 data->Initialize(arraysize(registers), registers, NULL); 142 } 143 144 145 void TransitionElementsKindDescriptor::Initialize( 146 CallInterfaceDescriptorData* data) { 147 Register registers[] = {cp, r0, r1}; 148 data->Initialize(arraysize(registers), registers, NULL); 149 } 150 151 152 void ArrayConstructorConstantArgCountDescriptor::Initialize( 153 CallInterfaceDescriptorData* data) { 154 // register state 155 // cp -- context 156 // r0 -- number of arguments 157 // r1 -- function 158 // r2 -- allocation site with elements kind 159 Register registers[] = {cp, r1, r2}; 160 data->Initialize(arraysize(registers), registers, NULL); 161 } 162 163 164 void ArrayConstructorDescriptor::Initialize(CallInterfaceDescriptorData* data) { 165 // stack param count needs (constructor pointer, and single argument) 166 Register registers[] = {cp, r1, r2, r0}; 167 Representation representations[] = { 168 Representation::Tagged(), Representation::Tagged(), 169 Representation::Tagged(), Representation::Integer32()}; 170 data->Initialize(arraysize(registers), registers, representations); 171 } 172 173 174 void InternalArrayConstructorConstantArgCountDescriptor::Initialize( 175 CallInterfaceDescriptorData* data) { 176 // register state 177 // cp -- context 178 // r0 -- number of arguments 179 // r1 -- constructor function 180 Register registers[] = {cp, r1}; 181 data->Initialize(arraysize(registers), registers, NULL); 182 } 183 184 185 void InternalArrayConstructorDescriptor::Initialize( 186 CallInterfaceDescriptorData* data) { 187 // stack param count needs (constructor pointer, and single argument) 188 Register registers[] = {cp, r1, r0}; 189 Representation representations[] = {Representation::Tagged(), 190 Representation::Tagged(), 191 Representation::Integer32()}; 192 data->Initialize(arraysize(registers), registers, representations); 193 } 194 195 196 void CompareNilDescriptor::Initialize(CallInterfaceDescriptorData* data) { 197 Register registers[] = {cp, r0}; 198 data->Initialize(arraysize(registers), registers, NULL); 199 } 200 201 202 void ToBooleanDescriptor::Initialize(CallInterfaceDescriptorData* data) { 203 Register registers[] = {cp, r0}; 204 data->Initialize(arraysize(registers), registers, NULL); 205 } 206 207 208 void BinaryOpDescriptor::Initialize(CallInterfaceDescriptorData* data) { 209 Register registers[] = {cp, r1, r0}; 210 data->Initialize(arraysize(registers), registers, NULL); 211 } 212 213 214 void BinaryOpWithAllocationSiteDescriptor::Initialize( 215 CallInterfaceDescriptorData* data) { 216 Register registers[] = {cp, r2, r1, r0}; 217 data->Initialize(arraysize(registers), registers, NULL); 218 } 219 220 221 void StringAddDescriptor::Initialize(CallInterfaceDescriptorData* data) { 222 Register registers[] = {cp, r1, r0}; 223 data->Initialize(arraysize(registers), registers, NULL); 224 } 225 226 227 void KeyedDescriptor::Initialize(CallInterfaceDescriptorData* data) { 228 static PlatformInterfaceDescriptor noInlineDescriptor = 229 PlatformInterfaceDescriptor(NEVER_INLINE_TARGET_ADDRESS); 230 231 Register registers[] = { 232 cp, // context 233 r2, // key 234 }; 235 Representation representations[] = { 236 Representation::Tagged(), // context 237 Representation::Tagged(), // key 238 }; 239 data->Initialize(arraysize(registers), registers, representations, 240 &noInlineDescriptor); 241 } 242 243 244 void NamedDescriptor::Initialize(CallInterfaceDescriptorData* data) { 245 static PlatformInterfaceDescriptor noInlineDescriptor = 246 PlatformInterfaceDescriptor(NEVER_INLINE_TARGET_ADDRESS); 247 248 Register registers[] = { 249 cp, // context 250 r2, // name 251 }; 252 Representation representations[] = { 253 Representation::Tagged(), // context 254 Representation::Tagged(), // name 255 }; 256 data->Initialize(arraysize(registers), registers, representations, 257 &noInlineDescriptor); 258 } 259 260 261 void CallHandlerDescriptor::Initialize(CallInterfaceDescriptorData* data) { 262 static PlatformInterfaceDescriptor default_descriptor = 263 PlatformInterfaceDescriptor(CAN_INLINE_TARGET_ADDRESS); 264 265 Register registers[] = { 266 cp, // context 267 r0, // receiver 268 }; 269 Representation representations[] = { 270 Representation::Tagged(), // context 271 Representation::Tagged(), // receiver 272 }; 273 data->Initialize(arraysize(registers), registers, representations, 274 &default_descriptor); 275 } 276 277 278 void ArgumentAdaptorDescriptor::Initialize(CallInterfaceDescriptorData* data) { 279 static PlatformInterfaceDescriptor default_descriptor = 280 PlatformInterfaceDescriptor(CAN_INLINE_TARGET_ADDRESS); 281 282 Register registers[] = { 283 cp, // context 284 r1, // JSFunction 285 r0, // actual number of arguments 286 r2, // expected number of arguments 287 }; 288 Representation representations[] = { 289 Representation::Tagged(), // context 290 Representation::Tagged(), // JSFunction 291 Representation::Integer32(), // actual number of arguments 292 Representation::Integer32(), // expected number of arguments 293 }; 294 data->Initialize(arraysize(registers), registers, representations, 295 &default_descriptor); 296 } 297 298 299 void ApiFunctionDescriptor::Initialize(CallInterfaceDescriptorData* data) { 300 static PlatformInterfaceDescriptor default_descriptor = 301 PlatformInterfaceDescriptor(CAN_INLINE_TARGET_ADDRESS); 302 303 Register registers[] = { 304 cp, // context 305 r0, // callee 306 r4, // call_data 307 r2, // holder 308 r1, // api_function_address 309 }; 310 Representation representations[] = { 311 Representation::Tagged(), // context 312 Representation::Tagged(), // callee 313 Representation::Tagged(), // call_data 314 Representation::Tagged(), // holder 315 Representation::External(), // api_function_address 316 }; 317 data->Initialize(arraysize(registers), registers, representations, 318 &default_descriptor); 319 } 320 } 321 } // namespace v8::internal 322 323 #endif // V8_TARGET_ARCH_ARM 324