OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/interface-descriptors.h" | 5 #include "src/interface-descriptors.h" |
6 | 6 |
7 namespace v8 { | 7 namespace v8 { |
8 namespace internal { | 8 namespace internal { |
9 | 9 |
10 namespace { | 10 namespace { |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
487 Zone* zone = isolate->interface_descriptor_zone(); | 487 Zone* zone = isolate->interface_descriptor_zone(); |
488 FunctionType* function = | 488 FunctionType* function = |
489 Type::Function(AnyTagged(zone), Type::Undefined(), 4, zone)->AsFunction(); | 489 Type::Function(AnyTagged(zone), Type::Undefined(), 4, zone)->AsFunction(); |
490 function->InitParameter(0, Type::Receiver()); // JSFunction | 490 function->InitParameter(0, Type::Receiver()); // JSFunction |
491 function->InitParameter(1, AnyTagged(zone)); // the new target | 491 function->InitParameter(1, AnyTagged(zone)); // the new target |
492 function->InitParameter(2, UntaggedIntegral32(zone)); // actual #arguments | 492 function->InitParameter(2, UntaggedIntegral32(zone)); // actual #arguments |
493 function->InitParameter(3, UntaggedIntegral32(zone)); // expected #arguments | 493 function->InitParameter(3, UntaggedIntegral32(zone)); // expected #arguments |
494 return function; | 494 return function; |
495 } | 495 } |
496 | 496 |
497 FunctionType* ApiFunctionDescriptor::BuildCallInterfaceDescriptorFunctionType( | 497 CallInterfaceDescriptor ApiCallbackDescriptorBase::ForArgs(Isolate* isolate, |
498 Isolate* isolate, int paramater_count) { | 498 int argc) { |
499 Zone* zone = isolate->interface_descriptor_zone(); | 499 switch (argc) { |
500 FunctionType* function = | 500 case 0: |
501 Type::Function(AnyTagged(zone), Type::Undefined(), 5, zone)->AsFunction(); | 501 return ApiCallbackWith0ArgsDescriptor(isolate); |
502 function->InitParameter(0, AnyTagged(zone)); // callee | 502 case 1: |
503 function->InitParameter(1, AnyTagged(zone)); // call_data | 503 return ApiCallbackWith1ArgsDescriptor(isolate); |
504 function->InitParameter(2, AnyTagged(zone)); // holder | 504 case 2: |
505 function->InitParameter(3, ExternalPointer(zone)); // api_function_address | 505 return ApiCallbackWith2ArgsDescriptor(isolate); |
506 function->InitParameter(4, UntaggedIntegral32(zone)); // actual #arguments | 506 case 3: |
507 return function; | 507 return ApiCallbackWith3ArgsDescriptor(isolate); |
508 case 4: | |
509 return ApiCallbackWith4ArgsDescriptor(isolate); | |
510 case 5: | |
511 return ApiCallbackWith5ArgsDescriptor(isolate); | |
512 case 6: | |
513 return ApiCallbackWith6ArgsDescriptor(isolate); | |
514 case 7: | |
515 return ApiCallbackWith7ArgsDescriptor(isolate); | |
danno
2016/03/04 18:07:42
Shouldn't you have a default case that is also unr
vogelheim
2016/03/08 12:59:27
Done.
I'm honestly a bit confused at this feedbac
danno
2016/03/09 10:23:38
I looked at the C/C++ spec, and you're right. With
| |
516 } | |
517 UNREACHABLE(); | |
508 } | 518 } |
509 | 519 |
510 FunctionType* ApiAccessorDescriptor::BuildCallInterfaceDescriptorFunctionType( | 520 FunctionType* BuildFunctionTypeForCallback(Isolate* isolate, |
511 Isolate* isolate, int paramater_count) { | 521 int accessor_parameter_count) { |
512 Zone* zone = isolate->interface_descriptor_zone(); | 522 Zone* zone = isolate->interface_descriptor_zone(); |
513 FunctionType* function = | 523 FunctionType* function = Type::Function(AnyTagged(zone), Type::Undefined(), |
514 Type::Function(AnyTagged(zone), Type::Undefined(), 4, zone)->AsFunction(); | 524 4 + accessor_parameter_count, zone) |
525 ->AsFunction(); | |
515 function->InitParameter(0, AnyTagged(zone)); // callee | 526 function->InitParameter(0, AnyTagged(zone)); // callee |
516 function->InitParameter(1, AnyTagged(zone)); // call_data | 527 function->InitParameter(1, AnyTagged(zone)); // call_data |
517 function->InitParameter(2, AnyTagged(zone)); // holder | 528 function->InitParameter(2, AnyTagged(zone)); // holder |
518 function->InitParameter(3, ExternalPointer(zone)); // api_function_address | 529 function->InitParameter(3, ExternalPointer(zone)); // api_function_address |
530 for (int i = 0; i < accessor_parameter_count; i++) { | |
531 function->InitParameter(i, AnyTagged(zone)); | |
532 } | |
519 return function; | 533 return function; |
520 } | 534 } |
521 | 535 |
536 template <int argc> | |
537 FunctionType* | |
538 ApiCallbackWithArgsBase<argc>::BuildCallInterfaceDescriptorFunctionType( | |
539 Isolate* isolate, int parameter_count) { | |
540 return BuildFunctionTypeForCallback(isolate, argc); | |
541 } | |
542 | |
543 template class ApiCallbackWithArgsBase<0>; | |
544 template class ApiCallbackWithArgsBase<1>; | |
545 template class ApiCallbackWithArgsBase<2>; | |
546 template class ApiCallbackWithArgsBase<3>; | |
547 template class ApiCallbackWithArgsBase<4>; | |
548 template class ApiCallbackWithArgsBase<5>; | |
549 template class ApiCallbackWithArgsBase<6>; | |
550 template class ApiCallbackWithArgsBase<7>; | |
551 | |
522 FunctionType* | 552 FunctionType* |
523 InterpreterDispatchDescriptor::BuildCallInterfaceDescriptorFunctionType( | 553 InterpreterDispatchDescriptor::BuildCallInterfaceDescriptorFunctionType( |
524 Isolate* isolate, int parameter_count) { | 554 Isolate* isolate, int parameter_count) { |
525 Zone* zone = isolate->interface_descriptor_zone(); | 555 Zone* zone = isolate->interface_descriptor_zone(); |
526 FunctionType* function = | 556 FunctionType* function = |
527 Type::Function(AnyTagged(zone), Type::Undefined(), 5, zone)->AsFunction(); | 557 Type::Function(AnyTagged(zone), Type::Undefined(), 5, zone)->AsFunction(); |
528 function->InitParameter(kAccumulatorParameter, AnyTagged(zone)); | 558 function->InitParameter(kAccumulatorParameter, AnyTagged(zone)); |
529 function->InitParameter(kRegisterFileParameter, ExternalPointer(zone)); | 559 function->InitParameter(kRegisterFileParameter, ExternalPointer(zone)); |
530 function->InitParameter(kBytecodeOffsetParameter, UntaggedIntegral32(zone)); | 560 function->InitParameter(kBytecodeOffsetParameter, UntaggedIntegral32(zone)); |
531 function->InitParameter(kBytecodeArrayParameter, AnyTagged(zone)); | 561 function->InitParameter(kBytecodeArrayParameter, AnyTagged(zone)); |
532 function->InitParameter(kDispatchTableParameter, AnyTagged(zone)); | 562 function->InitParameter(kDispatchTableParameter, AnyTagged(zone)); |
533 return function; | 563 return function; |
534 } | 564 } |
535 | 565 |
536 } // namespace internal | 566 } // namespace internal |
537 } // namespace v8 | 567 } // namespace v8 |
OLD | NEW |