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