Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 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 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 5 | #include "src/interface-descriptors.h" |
| 6 | |
| 7 | namespace v8 { |
| 8 | namespace internal { |
| 9 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 10 | namespace { |
| 11 | // Constructors for common combined semantic and representation types. |
| 12 | Type* SmiType(Zone* zone) { |
| 13 | return Type::Intersect(Type::SignedSmall(), Type::TaggedSigned(), zone); |
| 14 | } |
| 15 | |
| 16 | |
| 17 | Type* UntaggedIntegral32(Zone* zone) { |
| 18 | return Type::Intersect(Type::Signed32(), Type::UntaggedIntegral32(), zone); |
| 19 | } |
| 20 | |
| 21 | |
| 22 | Type* AnyTagged(Zone* zone) { |
| 23 | return Type::Intersect( |
| 24 | Type::Any(), |
| 25 | Type::Union(Type::TaggedPointer(), Type::TaggedSigned(), zone), zone); |
| 26 | } |
| 27 | |
| 28 | |
| 29 | Type* ExternalPointer(Zone* zone) { |
| 30 | return Type::Intersect(Type::Internal(), Type::UntaggedPointer(), zone); |
| 31 | } |
| 32 | } // namespace |
| 33 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 34 | FunctionType* CallInterfaceDescriptor::BuildDefaultFunctionType( |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 35 | Isolate* isolate, int parameter_count) { |
| 36 | Zone* zone = isolate->interface_descriptor_zone(); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 37 | FunctionType* function = |
| 38 | Type::Function(AnyTagged(zone), Type::Undefined(), parameter_count, zone) |
| 39 | ->AsFunction(); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 40 | while (parameter_count-- != 0) { |
| 41 | function->InitParameter(parameter_count, AnyTagged(zone)); |
| 42 | } |
| 43 | return function; |
| 44 | } |
| 45 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 46 | void CallInterfaceDescriptorData::InitializePlatformSpecific( |
Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame^] | 47 | int register_parameter_count, const Register* registers, |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 48 | PlatformInterfaceDescriptor* platform_descriptor) { |
| 49 | platform_specific_descriptor_ = platform_descriptor; |
| 50 | register_param_count_ = register_parameter_count; |
| 51 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 52 | // InterfaceDescriptor owns a copy of the registers array. |
| 53 | register_params_.Reset(NewArray<Register>(register_parameter_count)); |
| 54 | for (int i = 0; i < register_parameter_count; i++) { |
| 55 | register_params_[i] = registers[i]; |
| 56 | } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 57 | } |
| 58 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 59 | const char* CallInterfaceDescriptor::DebugName(Isolate* isolate) const { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 60 | CallInterfaceDescriptorData* start = isolate->call_descriptor_data(0); |
| 61 | size_t index = data_ - start; |
| 62 | DCHECK(index < CallDescriptors::NUMBER_OF_DESCRIPTORS); |
| 63 | CallDescriptors::Key key = static_cast<CallDescriptors::Key>(index); |
| 64 | switch (key) { |
| 65 | #define DEF_CASE(NAME) \ |
| 66 | case CallDescriptors::NAME: \ |
| 67 | return #NAME " Descriptor"; |
| 68 | INTERFACE_DESCRIPTOR_LIST(DEF_CASE) |
| 69 | #undef DEF_CASE |
| 70 | case CallDescriptors::NUMBER_OF_DESCRIPTORS: |
| 71 | break; |
| 72 | } |
| 73 | return ""; |
| 74 | } |
| 75 | |
| 76 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 77 | void VoidDescriptor::InitializePlatformSpecific( |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 78 | CallInterfaceDescriptorData* data) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 79 | data->InitializePlatformSpecific(0, nullptr); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 80 | } |
| 81 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 82 | FunctionType* LoadDescriptor::BuildCallInterfaceDescriptorFunctionType( |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 83 | Isolate* isolate, int paramater_count) { |
| 84 | Zone* zone = isolate->interface_descriptor_zone(); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 85 | FunctionType* function = |
| 86 | Type::Function(AnyTagged(zone), Type::Undefined(), 3, zone)->AsFunction(); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 87 | function->InitParameter(0, AnyTagged(zone)); |
| 88 | function->InitParameter(1, AnyTagged(zone)); |
| 89 | function->InitParameter(2, SmiType(zone)); |
| 90 | return function; |
| 91 | } |
| 92 | |
| 93 | |
| 94 | void LoadDescriptor::InitializePlatformSpecific( |
| 95 | CallInterfaceDescriptorData* data) { |
| 96 | Register registers[] = {ReceiverRegister(), NameRegister(), SlotRegister()}; |
| 97 | data->InitializePlatformSpecific(arraysize(registers), registers); |
| 98 | } |
| 99 | |
Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame^] | 100 | FunctionType* LoadGlobalDescriptor::BuildCallInterfaceDescriptorFunctionType( |
| 101 | Isolate* isolate, int paramater_count) { |
| 102 | Zone* zone = isolate->interface_descriptor_zone(); |
| 103 | FunctionType* function = |
| 104 | Type::Function(AnyTagged(zone), Type::Undefined(), 1, zone)->AsFunction(); |
| 105 | function->InitParameter(0, SmiType(zone)); |
| 106 | return function; |
| 107 | } |
| 108 | |
| 109 | void LoadGlobalDescriptor::InitializePlatformSpecific( |
| 110 | CallInterfaceDescriptorData* data) { |
| 111 | Register registers[] = {LoadWithVectorDescriptor::SlotRegister()}; |
| 112 | data->InitializePlatformSpecific(arraysize(registers), registers); |
| 113 | } |
| 114 | |
| 115 | FunctionType* |
| 116 | LoadGlobalWithVectorDescriptor::BuildCallInterfaceDescriptorFunctionType( |
| 117 | Isolate* isolate, int paramater_count) { |
| 118 | Zone* zone = isolate->interface_descriptor_zone(); |
| 119 | FunctionType* function = |
| 120 | Type::Function(AnyTagged(zone), Type::Undefined(), 2, zone)->AsFunction(); |
| 121 | function->InitParameter(0, SmiType(zone)); |
| 122 | function->InitParameter(1, AnyTagged(zone)); |
| 123 | return function; |
| 124 | } |
| 125 | |
| 126 | void LoadGlobalWithVectorDescriptor::InitializePlatformSpecific( |
| 127 | CallInterfaceDescriptorData* data) { |
| 128 | Register registers[] = {LoadWithVectorDescriptor::SlotRegister(), |
| 129 | LoadWithVectorDescriptor::VectorRegister()}; |
| 130 | data->InitializePlatformSpecific(arraysize(registers), registers); |
| 131 | } |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 132 | |
| 133 | void StoreDescriptor::InitializePlatformSpecific( |
| 134 | CallInterfaceDescriptorData* data) { |
| 135 | Register registers[] = {ReceiverRegister(), NameRegister(), ValueRegister()}; |
| 136 | data->InitializePlatformSpecific(arraysize(registers), registers); |
| 137 | } |
| 138 | |
| 139 | |
| 140 | void StoreTransitionDescriptor::InitializePlatformSpecific( |
| 141 | CallInterfaceDescriptorData* data) { |
| 142 | Register registers[] = {ReceiverRegister(), NameRegister(), ValueRegister(), |
| 143 | MapRegister()}; |
| 144 | |
| 145 | data->InitializePlatformSpecific(arraysize(registers), registers); |
| 146 | } |
| 147 | |
| 148 | |
| 149 | void VectorStoreTransitionDescriptor::InitializePlatformSpecific( |
| 150 | CallInterfaceDescriptorData* data) { |
| 151 | if (SlotRegister().is(no_reg)) { |
| 152 | Register registers[] = {ReceiverRegister(), NameRegister(), ValueRegister(), |
| 153 | MapRegister(), VectorRegister()}; |
| 154 | data->InitializePlatformSpecific(arraysize(registers), registers); |
| 155 | } else { |
| 156 | Register registers[] = {ReceiverRegister(), NameRegister(), |
| 157 | ValueRegister(), MapRegister(), |
| 158 | SlotRegister(), VectorRegister()}; |
| 159 | data->InitializePlatformSpecific(arraysize(registers), registers); |
| 160 | } |
| 161 | } |
| 162 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 163 | FunctionType* |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 164 | StoreTransitionDescriptor::BuildCallInterfaceDescriptorFunctionType( |
| 165 | Isolate* isolate, int paramater_count) { |
| 166 | Zone* zone = isolate->interface_descriptor_zone(); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 167 | FunctionType* function = |
| 168 | Type::Function(AnyTagged(zone), Type::Undefined(), 4, zone)->AsFunction(); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 169 | function->InitParameter(0, AnyTagged(zone)); // Receiver |
| 170 | function->InitParameter(1, AnyTagged(zone)); // Name |
| 171 | function->InitParameter(2, AnyTagged(zone)); // Value |
| 172 | function->InitParameter(3, AnyTagged(zone)); // Map |
| 173 | return function; |
| 174 | } |
| 175 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 176 | FunctionType* |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 177 | StoreGlobalViaContextDescriptor::BuildCallInterfaceDescriptorFunctionType( |
| 178 | Isolate* isolate, int paramater_count) { |
| 179 | Zone* zone = isolate->interface_descriptor_zone(); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 180 | FunctionType* function = |
| 181 | Type::Function(AnyTagged(zone), Type::Undefined(), 2, zone)->AsFunction(); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 182 | function->InitParameter(0, UntaggedIntegral32(zone)); |
| 183 | function->InitParameter(1, AnyTagged(zone)); |
| 184 | return function; |
| 185 | } |
| 186 | |
| 187 | |
| 188 | void StoreGlobalViaContextDescriptor::InitializePlatformSpecific( |
| 189 | CallInterfaceDescriptorData* data) { |
| 190 | Register registers[] = {SlotRegister(), ValueRegister()}; |
| 191 | data->InitializePlatformSpecific(arraysize(registers), registers); |
| 192 | } |
| 193 | |
| 194 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 195 | void StringCompareDescriptor::InitializePlatformSpecific( |
| 196 | CallInterfaceDescriptorData* data) { |
| 197 | Register registers[] = {LeftRegister(), RightRegister()}; |
| 198 | data->InitializePlatformSpecific(arraysize(registers), registers); |
| 199 | } |
| 200 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 201 | void TypeConversionDescriptor::InitializePlatformSpecific( |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 202 | CallInterfaceDescriptorData* data) { |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 203 | Register registers[] = {ArgumentRegister()}; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 204 | data->InitializePlatformSpecific(arraysize(registers), registers); |
| 205 | } |
| 206 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 207 | void MathPowTaggedDescriptor::InitializePlatformSpecific( |
| 208 | CallInterfaceDescriptorData* data) { |
| 209 | Register registers[] = {exponent()}; |
| 210 | data->InitializePlatformSpecific(arraysize(registers), registers); |
| 211 | } |
| 212 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 213 | void MathPowIntegerDescriptor::InitializePlatformSpecific( |
| 214 | CallInterfaceDescriptorData* data) { |
| 215 | Register registers[] = {exponent()}; |
| 216 | data->InitializePlatformSpecific(arraysize(registers), registers); |
| 217 | } |
| 218 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 219 | FunctionType* |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 220 | LoadWithVectorDescriptor::BuildCallInterfaceDescriptorFunctionType( |
| 221 | Isolate* isolate, int paramater_count) { |
| 222 | Zone* zone = isolate->interface_descriptor_zone(); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 223 | FunctionType* function = |
| 224 | Type::Function(AnyTagged(zone), Type::Undefined(), 4, zone)->AsFunction(); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 225 | function->InitParameter(0, AnyTagged(zone)); |
| 226 | function->InitParameter(1, AnyTagged(zone)); |
| 227 | function->InitParameter(2, SmiType(zone)); |
| 228 | function->InitParameter(3, AnyTagged(zone)); |
| 229 | return function; |
| 230 | } |
| 231 | |
| 232 | |
| 233 | void LoadWithVectorDescriptor::InitializePlatformSpecific( |
| 234 | CallInterfaceDescriptorData* data) { |
| 235 | Register registers[] = {ReceiverRegister(), NameRegister(), SlotRegister(), |
| 236 | VectorRegister()}; |
| 237 | data->InitializePlatformSpecific(arraysize(registers), registers); |
| 238 | } |
| 239 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 240 | FunctionType* |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 241 | VectorStoreTransitionDescriptor::BuildCallInterfaceDescriptorFunctionType( |
| 242 | Isolate* isolate, int paramater_count) { |
| 243 | Zone* zone = isolate->interface_descriptor_zone(); |
| 244 | bool has_slot = !VectorStoreTransitionDescriptor::SlotRegister().is(no_reg); |
| 245 | int arg_count = has_slot ? 6 : 5; |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 246 | FunctionType* function = |
| 247 | Type::Function(AnyTagged(zone), Type::Undefined(), arg_count, zone) |
| 248 | ->AsFunction(); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 249 | int index = 0; |
| 250 | function->InitParameter(index++, AnyTagged(zone)); // receiver |
| 251 | function->InitParameter(index++, AnyTagged(zone)); // name |
| 252 | function->InitParameter(index++, AnyTagged(zone)); // value |
| 253 | function->InitParameter(index++, AnyTagged(zone)); // map |
| 254 | if (has_slot) { |
| 255 | function->InitParameter(index++, SmiType(zone)); // slot |
| 256 | } |
| 257 | function->InitParameter(index++, AnyTagged(zone)); // vector |
| 258 | return function; |
| 259 | } |
| 260 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 261 | FunctionType* VectorStoreICDescriptor::BuildCallInterfaceDescriptorFunctionType( |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 262 | Isolate* isolate, int paramater_count) { |
| 263 | Zone* zone = isolate->interface_descriptor_zone(); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 264 | FunctionType* function = |
| 265 | Type::Function(AnyTagged(zone), Type::Undefined(), 5, zone)->AsFunction(); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 266 | function->InitParameter(0, AnyTagged(zone)); |
| 267 | function->InitParameter(1, AnyTagged(zone)); |
| 268 | function->InitParameter(2, AnyTagged(zone)); |
| 269 | function->InitParameter(3, SmiType(zone)); |
| 270 | function->InitParameter(4, AnyTagged(zone)); |
| 271 | return function; |
| 272 | } |
| 273 | |
| 274 | |
| 275 | void VectorStoreICDescriptor::InitializePlatformSpecific( |
| 276 | CallInterfaceDescriptorData* data) { |
| 277 | Register registers[] = {ReceiverRegister(), NameRegister(), ValueRegister(), |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 278 | SlotRegister(), VectorRegister()}; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 279 | data->InitializePlatformSpecific(arraysize(registers), registers); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 280 | } |
| 281 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 282 | FunctionType* |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 283 | VectorStoreICTrampolineDescriptor::BuildCallInterfaceDescriptorFunctionType( |
| 284 | Isolate* isolate, int paramater_count) { |
| 285 | Zone* zone = isolate->interface_descriptor_zone(); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 286 | FunctionType* function = |
| 287 | Type::Function(AnyTagged(zone), Type::Undefined(), 4, zone)->AsFunction(); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 288 | function->InitParameter(0, AnyTagged(zone)); |
| 289 | function->InitParameter(1, AnyTagged(zone)); |
| 290 | function->InitParameter(2, AnyTagged(zone)); |
| 291 | function->InitParameter(3, SmiType(zone)); |
| 292 | return function; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 293 | } |
| 294 | |
| 295 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 296 | void VectorStoreICTrampolineDescriptor::InitializePlatformSpecific( |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 297 | CallInterfaceDescriptorData* data) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 298 | Register registers[] = {ReceiverRegister(), NameRegister(), ValueRegister(), |
| 299 | SlotRegister()}; |
| 300 | data->InitializePlatformSpecific(arraysize(registers), registers); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 301 | } |
| 302 | |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 303 | const Register ApiGetterDescriptor::ReceiverRegister() { |
| 304 | return LoadDescriptor::ReceiverRegister(); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 305 | } |
| 306 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 307 | void ApiGetterDescriptor::InitializePlatformSpecific( |
| 308 | CallInterfaceDescriptorData* data) { |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 309 | Register registers[] = {ReceiverRegister(), HolderRegister(), |
| 310 | CallbackRegister()}; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 311 | data->InitializePlatformSpecific(arraysize(registers), registers); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 312 | } |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 313 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 314 | void ContextOnlyDescriptor::InitializePlatformSpecific( |
| 315 | CallInterfaceDescriptorData* data) { |
| 316 | data->InitializePlatformSpecific(0, nullptr); |
| 317 | } |
| 318 | |
Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame^] | 319 | CallInterfaceDescriptor OnStackArgsDescriptorBase::ForArgs( |
| 320 | Isolate* isolate, int parameter_count) { |
| 321 | switch (parameter_count) { |
| 322 | case 1: |
| 323 | return OnStackWith1ArgsDescriptor(isolate); |
| 324 | case 2: |
| 325 | return OnStackWith2ArgsDescriptor(isolate); |
| 326 | case 3: |
| 327 | return OnStackWith3ArgsDescriptor(isolate); |
| 328 | case 4: |
| 329 | return OnStackWith4ArgsDescriptor(isolate); |
| 330 | case 5: |
| 331 | return OnStackWith5ArgsDescriptor(isolate); |
| 332 | case 6: |
| 333 | return OnStackWith6ArgsDescriptor(isolate); |
| 334 | case 7: |
| 335 | return OnStackWith7ArgsDescriptor(isolate); |
| 336 | default: |
| 337 | UNREACHABLE(); |
| 338 | return VoidDescriptor(isolate); |
| 339 | } |
| 340 | } |
| 341 | |
| 342 | FunctionType* |
| 343 | OnStackArgsDescriptorBase::BuildCallInterfaceDescriptorFunctionTypeWithArg( |
| 344 | Isolate* isolate, int register_parameter_count, int parameter_count) { |
| 345 | DCHECK_EQ(0, register_parameter_count); |
| 346 | DCHECK_GT(parameter_count, 0); |
| 347 | Zone* zone = isolate->interface_descriptor_zone(); |
| 348 | FunctionType* function = |
| 349 | Type::Function(AnyTagged(zone), AnyTagged(zone), parameter_count, zone) |
| 350 | ->AsFunction(); |
| 351 | for (int i = 0; i < parameter_count; i++) { |
| 352 | function->InitParameter(i, AnyTagged(zone)); |
| 353 | } |
| 354 | return function; |
| 355 | } |
| 356 | |
| 357 | void OnStackArgsDescriptorBase::InitializePlatformSpecific( |
| 358 | CallInterfaceDescriptorData* data) { |
| 359 | data->InitializePlatformSpecific(0, nullptr); |
| 360 | } |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 361 | |
| 362 | void GrowArrayElementsDescriptor::InitializePlatformSpecific( |
| 363 | CallInterfaceDescriptorData* data) { |
| 364 | Register registers[] = {ObjectRegister(), KeyRegister()}; |
| 365 | data->InitializePlatformSpecific(arraysize(registers), registers); |
| 366 | } |
| 367 | |
Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame^] | 368 | FunctionType* |
| 369 | VarArgFunctionDescriptor::BuildCallInterfaceDescriptorFunctionType( |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 370 | Isolate* isolate, int paramater_count) { |
| 371 | Zone* zone = isolate->interface_descriptor_zone(); |
| 372 | FunctionType* function = |
| 373 | Type::Function(AnyTagged(zone), AnyTagged(zone), 1, zone)->AsFunction(); |
| 374 | function->InitParameter(0, UntaggedIntegral32(zone)); // actual #arguments |
| 375 | return function; |
| 376 | } |
| 377 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 378 | FunctionType* |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 379 | FastCloneRegExpDescriptor::BuildCallInterfaceDescriptorFunctionType( |
| 380 | Isolate* isolate, int paramater_count) { |
| 381 | Zone* zone = isolate->interface_descriptor_zone(); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 382 | FunctionType* function = |
| 383 | Type::Function(AnyTagged(zone), Type::Undefined(), 4, zone)->AsFunction(); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 384 | function->InitParameter(0, AnyTagged(zone)); // closure |
| 385 | function->InitParameter(1, SmiType(zone)); // literal_index |
| 386 | function->InitParameter(2, AnyTagged(zone)); // pattern |
| 387 | function->InitParameter(3, AnyTagged(zone)); // flags |
| 388 | return function; |
| 389 | } |
| 390 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 391 | FunctionType* |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 392 | FastCloneShallowArrayDescriptor::BuildCallInterfaceDescriptorFunctionType( |
| 393 | Isolate* isolate, int paramater_count) { |
| 394 | Zone* zone = isolate->interface_descriptor_zone(); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 395 | FunctionType* function = |
| 396 | Type::Function(AnyTagged(zone), Type::Undefined(), 3, zone)->AsFunction(); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 397 | function->InitParameter(0, AnyTagged(zone)); |
| 398 | function->InitParameter(1, SmiType(zone)); |
| 399 | function->InitParameter(2, AnyTagged(zone)); |
| 400 | return function; |
| 401 | } |
| 402 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 403 | FunctionType* |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 404 | CreateAllocationSiteDescriptor::BuildCallInterfaceDescriptorFunctionType( |
| 405 | Isolate* isolate, int paramater_count) { |
| 406 | Zone* zone = isolate->interface_descriptor_zone(); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 407 | FunctionType* function = |
| 408 | Type::Function(AnyTagged(zone), Type::Undefined(), 2, zone)->AsFunction(); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 409 | function->InitParameter(0, AnyTagged(zone)); |
| 410 | function->InitParameter(1, SmiType(zone)); |
| 411 | return function; |
| 412 | } |
| 413 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 414 | FunctionType* |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 415 | CreateWeakCellDescriptor::BuildCallInterfaceDescriptorFunctionType( |
| 416 | Isolate* isolate, int paramater_count) { |
| 417 | Zone* zone = isolate->interface_descriptor_zone(); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 418 | FunctionType* function = |
| 419 | Type::Function(AnyTagged(zone), Type::Undefined(), 3, zone)->AsFunction(); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 420 | function->InitParameter(0, AnyTagged(zone)); |
| 421 | function->InitParameter(1, SmiType(zone)); |
| 422 | function->InitParameter(2, AnyTagged(zone)); |
| 423 | return function; |
| 424 | } |
| 425 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 426 | FunctionType* |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 427 | CallTrampolineDescriptor::BuildCallInterfaceDescriptorFunctionType( |
| 428 | Isolate* isolate, int paramater_count) { |
| 429 | Zone* zone = isolate->interface_descriptor_zone(); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 430 | FunctionType* function = |
| 431 | Type::Function(AnyTagged(zone), Type::Undefined(), 2, zone)->AsFunction(); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 432 | function->InitParameter(0, AnyTagged(zone)); // target |
| 433 | function->InitParameter(1, UntaggedIntegral32(zone)); // actual #arguments |
| 434 | return function; |
| 435 | } |
| 436 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 437 | FunctionType* ConstructStubDescriptor::BuildCallInterfaceDescriptorFunctionType( |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 438 | Isolate* isolate, int paramater_count) { |
| 439 | Zone* zone = isolate->interface_descriptor_zone(); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 440 | FunctionType* function = |
| 441 | Type::Function(AnyTagged(zone), Type::Undefined(), 4, zone)->AsFunction(); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 442 | function->InitParameter(0, AnyTagged(zone)); // target |
| 443 | function->InitParameter(1, AnyTagged(zone)); // new.target |
| 444 | function->InitParameter(2, UntaggedIntegral32(zone)); // actual #arguments |
| 445 | function->InitParameter(3, AnyTagged(zone)); // opt. allocation site |
| 446 | return function; |
| 447 | } |
| 448 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 449 | FunctionType* |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 450 | ConstructTrampolineDescriptor::BuildCallInterfaceDescriptorFunctionType( |
| 451 | Isolate* isolate, int paramater_count) { |
| 452 | Zone* zone = isolate->interface_descriptor_zone(); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 453 | FunctionType* function = |
| 454 | Type::Function(AnyTagged(zone), Type::Undefined(), 3, zone)->AsFunction(); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 455 | function->InitParameter(0, AnyTagged(zone)); // target |
| 456 | function->InitParameter(1, AnyTagged(zone)); // new.target |
| 457 | function->InitParameter(2, UntaggedIntegral32(zone)); // actual #arguments |
| 458 | return function; |
| 459 | } |
| 460 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 461 | FunctionType* |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 462 | CallFunctionWithFeedbackDescriptor::BuildCallInterfaceDescriptorFunctionType( |
| 463 | Isolate* isolate, int paramater_count) { |
| 464 | Zone* zone = isolate->interface_descriptor_zone(); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 465 | FunctionType* function = |
| 466 | Type::Function(AnyTagged(zone), Type::Undefined(), 2, zone)->AsFunction(); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 467 | function->InitParameter(0, Type::Receiver()); // JSFunction |
| 468 | function->InitParameter(1, SmiType(zone)); |
| 469 | return function; |
| 470 | } |
| 471 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 472 | FunctionType* CallFunctionWithFeedbackAndVectorDescriptor:: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 473 | BuildCallInterfaceDescriptorFunctionType(Isolate* isolate, |
| 474 | int paramater_count) { |
| 475 | Zone* zone = isolate->interface_descriptor_zone(); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 476 | FunctionType* function = |
| 477 | Type::Function(AnyTagged(zone), Type::Undefined(), 3, zone)->AsFunction(); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 478 | function->InitParameter(0, Type::Receiver()); // JSFunction |
| 479 | function->InitParameter(1, SmiType(zone)); |
| 480 | function->InitParameter(2, AnyTagged(zone)); |
| 481 | return function; |
| 482 | } |
| 483 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 484 | FunctionType* |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 485 | ArrayNoArgumentConstructorDescriptor::BuildCallInterfaceDescriptorFunctionType( |
| 486 | Isolate* isolate, int paramater_count) { |
| 487 | Zone* zone = isolate->interface_descriptor_zone(); |
| 488 | FunctionType* function = |
| 489 | Type::Function(AnyTagged(zone), Type::Undefined(), 4, zone)->AsFunction(); |
| 490 | function->InitParameter(0, Type::Receiver()); // JSFunction |
| 491 | function->InitParameter(1, AnyTagged(zone)); |
| 492 | function->InitParameter(2, UntaggedIntegral32(zone)); |
| 493 | function->InitParameter(3, AnyTagged(zone)); |
| 494 | return function; |
| 495 | } |
| 496 | |
Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame^] | 497 | FunctionType* ArraySingleArgumentConstructorDescriptor:: |
| 498 | BuildCallInterfaceDescriptorFunctionType(Isolate* isolate, |
| 499 | int paramater_count) { |
| 500 | Zone* zone = isolate->interface_descriptor_zone(); |
| 501 | FunctionType* function = |
| 502 | Type::Function(AnyTagged(zone), Type::Undefined(), 5, zone)->AsFunction(); |
| 503 | function->InitParameter(0, Type::Receiver()); // JSFunction |
| 504 | function->InitParameter(1, AnyTagged(zone)); |
| 505 | function->InitParameter(2, UntaggedIntegral32(zone)); |
| 506 | function->InitParameter(3, AnyTagged(zone)); |
| 507 | function->InitParameter(4, AnyTagged(zone)); |
| 508 | return function; |
| 509 | } |
| 510 | |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 511 | FunctionType* |
Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame^] | 512 | ArrayNArgumentsConstructorDescriptor::BuildCallInterfaceDescriptorFunctionType( |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 513 | Isolate* isolate, int paramater_count) { |
| 514 | Zone* zone = isolate->interface_descriptor_zone(); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 515 | FunctionType* function = |
| 516 | Type::Function(AnyTagged(zone), Type::Undefined(), 3, zone)->AsFunction(); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 517 | function->InitParameter(0, Type::Receiver()); // JSFunction |
Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame^] | 518 | function->InitParameter(1, AnyTagged(zone)); // Allocation site or undefined |
| 519 | function->InitParameter(2, UntaggedIntegral32(zone)); // Arg count |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 520 | return function; |
| 521 | } |
| 522 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 523 | FunctionType* |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 524 | ArgumentAdaptorDescriptor::BuildCallInterfaceDescriptorFunctionType( |
| 525 | Isolate* isolate, int paramater_count) { |
| 526 | Zone* zone = isolate->interface_descriptor_zone(); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 527 | FunctionType* function = |
| 528 | Type::Function(AnyTagged(zone), Type::Undefined(), 4, zone)->AsFunction(); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 529 | function->InitParameter(0, Type::Receiver()); // JSFunction |
| 530 | function->InitParameter(1, AnyTagged(zone)); // the new target |
| 531 | function->InitParameter(2, UntaggedIntegral32(zone)); // actual #arguments |
| 532 | function->InitParameter(3, UntaggedIntegral32(zone)); // expected #arguments |
| 533 | return function; |
| 534 | } |
| 535 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 536 | CallInterfaceDescriptor ApiCallbackDescriptorBase::ForArgs(Isolate* isolate, |
| 537 | int argc) { |
| 538 | switch (argc) { |
| 539 | case 0: |
| 540 | return ApiCallbackWith0ArgsDescriptor(isolate); |
| 541 | case 1: |
| 542 | return ApiCallbackWith1ArgsDescriptor(isolate); |
| 543 | case 2: |
| 544 | return ApiCallbackWith2ArgsDescriptor(isolate); |
| 545 | case 3: |
| 546 | return ApiCallbackWith3ArgsDescriptor(isolate); |
| 547 | case 4: |
| 548 | return ApiCallbackWith4ArgsDescriptor(isolate); |
| 549 | case 5: |
| 550 | return ApiCallbackWith5ArgsDescriptor(isolate); |
| 551 | case 6: |
| 552 | return ApiCallbackWith6ArgsDescriptor(isolate); |
| 553 | case 7: |
| 554 | return ApiCallbackWith7ArgsDescriptor(isolate); |
| 555 | default: |
| 556 | UNREACHABLE(); |
| 557 | return VoidDescriptor(isolate); |
| 558 | } |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 559 | } |
| 560 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 561 | FunctionType* |
| 562 | ApiCallbackDescriptorBase::BuildCallInterfaceDescriptorFunctionTypeWithArg( |
| 563 | Isolate* isolate, int parameter_count, int argc) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 564 | Zone* zone = isolate->interface_descriptor_zone(); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 565 | FunctionType* function = |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 566 | Type::Function(AnyTagged(zone), Type::Undefined(), 4 + argc, zone) |
| 567 | ->AsFunction(); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 568 | function->InitParameter(0, AnyTagged(zone)); // callee |
| 569 | function->InitParameter(1, AnyTagged(zone)); // call_data |
| 570 | function->InitParameter(2, AnyTagged(zone)); // holder |
| 571 | function->InitParameter(3, ExternalPointer(zone)); // api_function_address |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 572 | for (int i = 0; i < argc; i++) { |
| 573 | function->InitParameter(i, AnyTagged(zone)); |
| 574 | } |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 575 | return function; |
| 576 | } |
| 577 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 578 | FunctionType* |
| 579 | InterpreterDispatchDescriptor::BuildCallInterfaceDescriptorFunctionType( |
| 580 | Isolate* isolate, int parameter_count) { |
| 581 | Zone* zone = isolate->interface_descriptor_zone(); |
| 582 | FunctionType* function = |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 583 | Type::Function(AnyTagged(zone), Type::Undefined(), 4, zone)->AsFunction(); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 584 | function->InitParameter(kAccumulatorParameter, AnyTagged(zone)); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 585 | function->InitParameter(kBytecodeOffsetParameter, UntaggedIntegral32(zone)); |
| 586 | function->InitParameter(kBytecodeArrayParameter, AnyTagged(zone)); |
| 587 | function->InitParameter(kDispatchTableParameter, AnyTagged(zone)); |
| 588 | return function; |
| 589 | } |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 590 | |
| 591 | } // namespace internal |
| 592 | } // namespace v8 |