| 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 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 Map* transition, | 646 Map* transition, |
| 647 String* name); | 647 String* name); |
| 648 | 648 |
| 649 MUST_USE_RESULT MaybeObject* CompileStoreSpecialized(JSObject* receiver); | 649 MUST_USE_RESULT MaybeObject* CompileStoreSpecialized(JSObject* receiver); |
| 650 | 650 |
| 651 private: | 651 private: |
| 652 MaybeObject* GetCode(PropertyType type, String* name); | 652 MaybeObject* GetCode(PropertyType type, String* name); |
| 653 }; | 653 }; |
| 654 | 654 |
| 655 | 655 |
| 656 // List of functions with custom constant call IC stubs. | 656 // Subset of FUNCTIONS_WITH_ID_LIST with custom constant/global call |
| 657 // | 657 // IC stubs. |
| 658 // Installation of custom call generators for the selected builtins is | 658 #define CUSTOM_CALL_IC_GENERATORS(V) \ |
| 659 // handled by the bootstrapper. | 659 V(ArrayPush) \ |
| 660 // | 660 V(ArrayPop) \ |
| 661 // Each entry has a name of a global object property holding an object | 661 V(StringCharCodeAt) \ |
| 662 // optionally followed by ".prototype" (this controls whether the | 662 V(StringCharAt) \ |
| 663 // generator is set on the object itself or, in case it's a function, | 663 V(StringFromCharCode) \ |
| 664 // on the its instance prototype), a name of a builtin function on the | 664 V(MathFloor) \ |
| 665 // object (the one the generator is set for), and a name of the | 665 V(MathAbs) |
| 666 // generator (used to build ids and generator function names). | |
| 667 #define CUSTOM_CALL_IC_GENERATORS(V) \ | |
| 668 V(Array.prototype, push, ArrayPush) \ | |
| 669 V(Array.prototype, pop, ArrayPop) \ | |
| 670 V(String.prototype, charCodeAt, StringCharCodeAt) \ | |
| 671 V(String.prototype, charAt, StringCharAt) \ | |
| 672 V(String, fromCharCode, StringFromCharCode) \ | |
| 673 V(Math, floor, MathFloor) \ | |
| 674 V(Math, abs, MathAbs) | |
| 675 | 666 |
| 676 | 667 |
| 677 class CallStubCompiler: public StubCompiler { | 668 class CallStubCompiler: public StubCompiler { |
| 678 public: | 669 public: |
| 679 enum { | |
| 680 #define DECLARE_CALL_GENERATOR_ID(ignored1, ignore2, name) \ | |
| 681 k##name##CallGenerator, | |
| 682 CUSTOM_CALL_IC_GENERATORS(DECLARE_CALL_GENERATOR_ID) | |
| 683 #undef DECLARE_CALL_GENERATOR_ID | |
| 684 kNumCallGenerators | |
| 685 }; | |
| 686 | |
| 687 CallStubCompiler(int argc, | 670 CallStubCompiler(int argc, |
| 688 InLoopFlag in_loop, | 671 InLoopFlag in_loop, |
| 689 Code::Kind kind, | 672 Code::Kind kind, |
| 690 InlineCacheHolderFlag cache_holder); | 673 InlineCacheHolderFlag cache_holder); |
| 691 | 674 |
| 692 MUST_USE_RESULT MaybeObject* CompileCallField(JSObject* object, | 675 MUST_USE_RESULT MaybeObject* CompileCallField(JSObject* object, |
| 693 JSObject* holder, | 676 JSObject* holder, |
| 694 int index, | 677 int index, |
| 695 String* name); | 678 String* name); |
| 696 MUST_USE_RESULT MaybeObject* CompileCallConstant(Object* object, | 679 MUST_USE_RESULT MaybeObject* CompileCallConstant(Object* object, |
| 697 JSObject* holder, | 680 JSObject* holder, |
| 698 JSFunction* function, | 681 JSFunction* function, |
| 699 String* name, | 682 String* name, |
| 700 CheckType check); | 683 CheckType check); |
| 701 MUST_USE_RESULT MaybeObject* CompileCallInterceptor(JSObject* object, | 684 MUST_USE_RESULT MaybeObject* CompileCallInterceptor(JSObject* object, |
| 702 JSObject* holder, | 685 JSObject* holder, |
| 703 String* name); | 686 String* name); |
| 704 MUST_USE_RESULT MaybeObject* CompileCallGlobal(JSObject* object, | 687 MUST_USE_RESULT MaybeObject* CompileCallGlobal(JSObject* object, |
| 705 GlobalObject* holder, | 688 GlobalObject* holder, |
| 706 JSGlobalPropertyCell* cell, | 689 JSGlobalPropertyCell* cell, |
| 707 JSFunction* function, | 690 JSFunction* function, |
| 708 String* name); | 691 String* name); |
| 709 | 692 |
| 710 // Compiles a custom call constant/global IC using the generator | 693 static bool HasCustomCallGenerator(BuiltinFunctionId id); |
| 711 // with given id. For constant calls cell is NULL. | 694 |
| 712 MUST_USE_RESULT MaybeObject* CompileCustomCall(int generator_id, | 695 private: |
| 696 // Compiles a custom call constant/global IC. For constant calls |
| 697 // cell is NULL. Returns undefined if there is no custom call code |
| 698 // for the given function or it can't be generated. |
| 699 MUST_USE_RESULT MaybeObject* CompileCustomCall(BuiltinFunctionId id, |
| 713 Object* object, | 700 Object* object, |
| 714 JSObject* holder, | 701 JSObject* holder, |
| 715 JSGlobalPropertyCell* cell, | 702 JSGlobalPropertyCell* cell, |
| 716 JSFunction* function, | 703 JSFunction* function, |
| 717 String* name); | 704 String* name); |
| 718 | 705 |
| 719 #define DECLARE_CALL_GENERATOR(ignored1, ignored2, name) \ | 706 #define DECLARE_CALL_GENERATOR(name) \ |
| 720 MUST_USE_RESULT MaybeObject* Compile##name##Call(Object* object, \ | 707 MUST_USE_RESULT MaybeObject* Compile##name##Call(Object* object, \ |
| 721 JSObject* holder, \ | 708 JSObject* holder, \ |
| 722 JSGlobalPropertyCell* cell, \ | 709 JSGlobalPropertyCell* cell, \ |
| 723 JSFunction* function, \ | 710 JSFunction* function, \ |
| 724 String* fname); | 711 String* fname); |
| 725 CUSTOM_CALL_IC_GENERATORS(DECLARE_CALL_GENERATOR) | 712 CUSTOM_CALL_IC_GENERATORS(DECLARE_CALL_GENERATOR) |
| 726 #undef DECLARE_CALL_GENERATOR | 713 #undef DECLARE_CALL_GENERATOR |
| 727 | 714 |
| 728 private: | |
| 729 const ParameterCount arguments_; | 715 const ParameterCount arguments_; |
| 730 const InLoopFlag in_loop_; | 716 const InLoopFlag in_loop_; |
| 731 const Code::Kind kind_; | 717 const Code::Kind kind_; |
| 732 const InlineCacheHolderFlag cache_holder_; | 718 const InlineCacheHolderFlag cache_holder_; |
| 733 | 719 |
| 734 const ParameterCount& arguments() { return arguments_; } | 720 const ParameterCount& arguments() { return arguments_; } |
| 735 | 721 |
| 736 MUST_USE_RESULT MaybeObject* GetCode(PropertyType type, String* name); | 722 MUST_USE_RESULT MaybeObject* GetCode(PropertyType type, String* name); |
| 737 | 723 |
| 738 // Convenience function. Calls GetCode above passing | 724 // Convenience function. Calls GetCode above passing |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 | 799 |
| 814 JSFunction* constant_function_; | 800 JSFunction* constant_function_; |
| 815 bool is_simple_api_call_; | 801 bool is_simple_api_call_; |
| 816 FunctionTemplateInfo* expected_receiver_type_; | 802 FunctionTemplateInfo* expected_receiver_type_; |
| 817 CallHandlerInfo* api_call_info_; | 803 CallHandlerInfo* api_call_info_; |
| 818 }; | 804 }; |
| 819 | 805 |
| 820 } } // namespace v8::internal | 806 } } // namespace v8::internal |
| 821 | 807 |
| 822 #endif // V8_STUB_CACHE_H_ | 808 #endif // V8_STUB_CACHE_H_ |
| OLD | NEW |