OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
605 private: | 605 private: |
606 Object* GetCode(PropertyType type, String* name); | 606 Object* GetCode(PropertyType type, String* name); |
607 }; | 607 }; |
608 | 608 |
609 | 609 |
610 // List of functions with custom constant call IC stubs. | 610 // List of functions with custom constant call IC stubs. |
611 // | 611 // |
612 // Installation of custom call generators for the selected builtins is | 612 // Installation of custom call generators for the selected builtins is |
613 // handled by the bootstrapper. | 613 // handled by the bootstrapper. |
614 // | 614 // |
615 // Each entry has a name of a global function (lowercased), a name of | 615 // Each entry has a name of a global function (lowercased), a flag |
616 // a builtin function on its instance prototype (the one the generator | 616 // controlling whether the generator is set on the function itself or |
617 // is set for), and a name of a generator itself (used to build ids | 617 // on its instance prototype, a name of a builtin function on the |
618 // and generator function names). | 618 // function or its instance prototype (the one the generator is set |
619 #define CUSTOM_CALL_IC_GENERATORS(V) \ | 619 // for), and a name of a generator itself (used to build ids and |
620 V(array, push, ArrayPush) \ | 620 // generator function names). |
621 V(array, pop, ArrayPop) \ | 621 #define CUSTOM_CALL_IC_GENERATORS(V) \ |
622 V(string, charCodeAt, StringCharCodeAt) \ | 622 V(array, INSTANCE_PROTOTYPE, push, ArrayPush) \ |
623 V(string, charAt, StringCharAt) | 623 V(array, INSTANCE_PROTOTYPE, pop, ArrayPop) \ |
| 624 V(string, INSTANCE_PROTOTYPE, charCodeAt, StringCharCodeAt) \ |
| 625 V(string, INSTANCE_PROTOTYPE, charAt, StringCharAt) \ |
| 626 V(string, FUNCTION, fromCharCode, StringFromCharCode) |
624 | 627 |
625 | 628 |
626 class CallStubCompiler: public StubCompiler { | 629 class CallStubCompiler: public StubCompiler { |
627 public: | 630 public: |
| 631 enum CustomGeneratorOwner { |
| 632 FUNCTION, |
| 633 INSTANCE_PROTOTYPE |
| 634 }; |
| 635 |
628 enum { | 636 enum { |
629 #define DECLARE_CALL_GENERATOR_ID(ignored1, ignored2, name) \ | 637 #define DECLARE_CALL_GENERATOR_ID(ignored1, ignore2, ignored3, name) \ |
630 k##name##CallGenerator, | 638 k##name##CallGenerator, |
631 CUSTOM_CALL_IC_GENERATORS(DECLARE_CALL_GENERATOR_ID) | 639 CUSTOM_CALL_IC_GENERATORS(DECLARE_CALL_GENERATOR_ID) |
632 #undef DECLARE_CALL_GENERATOR_ID | 640 #undef DECLARE_CALL_GENERATOR_ID |
633 kNumCallGenerators | 641 kNumCallGenerators |
634 }; | 642 }; |
635 | 643 |
636 CallStubCompiler(int argc, | 644 CallStubCompiler(int argc, |
637 InLoopFlag in_loop, | 645 InLoopFlag in_loop, |
638 Code::Kind kind, | 646 Code::Kind kind, |
639 InlineCacheHolderFlag cache_holder); | 647 InlineCacheHolderFlag cache_holder); |
640 | 648 |
641 Object* CompileCallField(JSObject* object, | 649 Object* CompileCallField(JSObject* object, |
642 JSObject* holder, | 650 JSObject* holder, |
643 int index, | 651 int index, |
644 String* name); | 652 String* name); |
645 Object* CompileCallConstant(Object* object, | 653 Object* CompileCallConstant(Object* object, |
646 JSObject* holder, | 654 JSObject* holder, |
647 JSFunction* function, | 655 JSFunction* function, |
648 String* name, | 656 String* name, |
649 CheckType check); | 657 CheckType check); |
650 Object* CompileCallInterceptor(JSObject* object, | 658 Object* CompileCallInterceptor(JSObject* object, |
651 JSObject* holder, | 659 JSObject* holder, |
652 String* name); | 660 String* name); |
653 Object* CompileCallGlobal(JSObject* object, | 661 Object* CompileCallGlobal(JSObject* object, |
654 GlobalObject* holder, | 662 GlobalObject* holder, |
655 JSGlobalPropertyCell* cell, | 663 JSGlobalPropertyCell* cell, |
656 JSFunction* function, | 664 JSFunction* function, |
657 String* name); | 665 String* name); |
658 | 666 |
659 // Compiles a custom call constant IC using the generator with given id. | 667 // Compiles a custom call constant/global IC using the generator |
| 668 // with given id. For constant calls cell is NULL. |
660 Object* CompileCustomCall(int generator_id, | 669 Object* CompileCustomCall(int generator_id, |
661 Object* object, | 670 Object* object, |
662 JSObject* holder, | 671 JSObject* holder, |
| 672 JSGlobalPropertyCell* cell, |
663 JSFunction* function, | 673 JSFunction* function, |
664 String* name, | 674 String* name); |
665 CheckType check); | |
666 | 675 |
667 #define DECLARE_CALL_GENERATOR(ignored1, ignored2, name) \ | 676 #define DECLARE_CALL_GENERATOR(ignored1, ignored2, ignored3, name) \ |
668 Object* Compile##name##Call(Object* object, \ | 677 Object* Compile##name##Call(Object* object, \ |
669 JSObject* holder, \ | 678 JSObject* holder, \ |
670 JSFunction* function, \ | 679 JSGlobalPropertyCell* cell, \ |
671 String* fname, \ | 680 JSFunction* function, \ |
672 CheckType check); | 681 String* fname); |
673 CUSTOM_CALL_IC_GENERATORS(DECLARE_CALL_GENERATOR) | 682 CUSTOM_CALL_IC_GENERATORS(DECLARE_CALL_GENERATOR) |
674 #undef DECLARE_CALL_GENERATOR | 683 #undef DECLARE_CALL_GENERATOR |
675 | 684 |
676 private: | 685 private: |
677 const ParameterCount arguments_; | 686 const ParameterCount arguments_; |
678 const InLoopFlag in_loop_; | 687 const InLoopFlag in_loop_; |
679 const Code::Kind kind_; | 688 const Code::Kind kind_; |
680 const InlineCacheHolderFlag cache_holder_; | 689 const InlineCacheHolderFlag cache_holder_; |
681 | 690 |
682 const ParameterCount& arguments() { return arguments_; } | 691 const ParameterCount& arguments() { return arguments_; } |
683 | 692 |
684 Object* GetCode(PropertyType type, String* name); | 693 Object* GetCode(PropertyType type, String* name); |
685 | 694 |
686 // Convenience function. Calls GetCode above passing | 695 // Convenience function. Calls GetCode above passing |
687 // CONSTANT_FUNCTION type and the name of the given function. | 696 // CONSTANT_FUNCTION type and the name of the given function. |
688 Object* GetCode(JSFunction* function); | 697 Object* GetCode(JSFunction* function); |
689 | 698 |
690 void GenerateNameCheck(String* name, Label* miss); | 699 void GenerateNameCheck(String* name, Label* miss); |
691 | 700 |
| 701 void GenerateGlobalReceiverCheck(JSObject* object, |
| 702 JSObject* holder, |
| 703 String* name, |
| 704 Label* miss); |
| 705 |
| 706 // Generates code to load the function from the cell checking that |
| 707 // it still contains the same function. |
| 708 void GenerateLoadFunctionFromCell(JSGlobalPropertyCell* cell, |
| 709 JSFunction* function, |
| 710 Label* miss); |
| 711 |
692 // Generates a jump to CallIC miss stub. Returns Failure if the jump cannot | 712 // Generates a jump to CallIC miss stub. Returns Failure if the jump cannot |
693 // be generated. | 713 // be generated. |
694 Object* GenerateMissBranch(); | 714 Object* GenerateMissBranch(); |
695 }; | 715 }; |
696 | 716 |
697 | 717 |
698 class ConstructStubCompiler: public StubCompiler { | 718 class ConstructStubCompiler: public StubCompiler { |
699 public: | 719 public: |
700 explicit ConstructStubCompiler() {} | 720 explicit ConstructStubCompiler() {} |
701 | 721 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
750 | 770 |
751 JSFunction* constant_function_; | 771 JSFunction* constant_function_; |
752 bool is_simple_api_call_; | 772 bool is_simple_api_call_; |
753 FunctionTemplateInfo* expected_receiver_type_; | 773 FunctionTemplateInfo* expected_receiver_type_; |
754 CallHandlerInfo* api_call_info_; | 774 CallHandlerInfo* api_call_info_; |
755 }; | 775 }; |
756 | 776 |
757 } } // namespace v8::internal | 777 } } // namespace v8::internal |
758 | 778 |
759 #endif // V8_STUB_CACHE_H_ | 779 #endif // V8_STUB_CACHE_H_ |
OLD | NEW |