| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 |
| 11 // with the distribution. | 11 // with the distribution. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #ifndef V8_STUB_CACHE_H_ | 28 #ifndef V8_STUB_CACHE_H_ |
| 29 #define V8_STUB_CACHE_H_ | 29 #define V8_STUB_CACHE_H_ |
| 30 | 30 |
| 31 #include "allocation.h" | 31 #include "allocation.h" |
| 32 #include "arguments.h" | 32 #include "arguments.h" |
| 33 #include "macro-assembler.h" | 33 #include "macro-assembler.h" |
| 34 #include "objects.h" |
| 34 #include "zone-inl.h" | 35 #include "zone-inl.h" |
| 35 | 36 |
| 36 namespace v8 { | 37 namespace v8 { |
| 37 namespace internal { | 38 namespace internal { |
| 38 | 39 |
| 39 | 40 |
| 40 // The stub cache is used for megamorphic calls and property accesses. | 41 // The stub cache is used for megamorphic calls and property accesses. |
| 41 // It maps (map, name, type)->Code* | 42 // It maps (map, name, type)->Code* |
| 42 | 43 |
| 43 // The design of the table uses the inline cache stubs used for | 44 // The design of the table uses the inline cache stubs used for |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 JSArray* receiver); | 138 JSArray* receiver); |
| 138 | 139 |
| 139 MUST_USE_RESULT MaybeObject* ComputeKeyedLoadStringLength( | 140 MUST_USE_RESULT MaybeObject* ComputeKeyedLoadStringLength( |
| 140 String* name, | 141 String* name, |
| 141 String* receiver); | 142 String* receiver); |
| 142 | 143 |
| 143 MUST_USE_RESULT MaybeObject* ComputeKeyedLoadFunctionPrototype( | 144 MUST_USE_RESULT MaybeObject* ComputeKeyedLoadFunctionPrototype( |
| 144 String* name, | 145 String* name, |
| 145 JSFunction* receiver); | 146 JSFunction* receiver); |
| 146 | 147 |
| 147 MUST_USE_RESULT MaybeObject* ComputeKeyedLoadSpecialized( | |
| 148 JSObject* receiver); | |
| 149 | |
| 150 // --- | 148 // --- |
| 151 | 149 |
| 152 MUST_USE_RESULT MaybeObject* ComputeStoreField( | 150 MUST_USE_RESULT MaybeObject* ComputeStoreField( |
| 153 String* name, | 151 String* name, |
| 154 JSObject* receiver, | 152 JSObject* receiver, |
| 155 int field_index, | 153 int field_index, |
| 156 Map* transition, | 154 Map* transition, |
| 157 StrictModeFlag strict_mode); | 155 StrictModeFlag strict_mode); |
| 158 | 156 |
| 159 MUST_USE_RESULT MaybeObject* ComputeStoreNormal( | 157 MUST_USE_RESULT MaybeObject* ComputeStoreNormal( |
| (...skipping 18 matching lines...) Expand all Loading... |
| 178 | 176 |
| 179 // --- | 177 // --- |
| 180 | 178 |
| 181 MUST_USE_RESULT MaybeObject* ComputeKeyedStoreField( | 179 MUST_USE_RESULT MaybeObject* ComputeKeyedStoreField( |
| 182 String* name, | 180 String* name, |
| 183 JSObject* receiver, | 181 JSObject* receiver, |
| 184 int field_index, | 182 int field_index, |
| 185 Map* transition, | 183 Map* transition, |
| 186 StrictModeFlag strict_mode); | 184 StrictModeFlag strict_mode); |
| 187 | 185 |
| 188 MUST_USE_RESULT MaybeObject* ComputeKeyedStoreSpecialized( | |
| 189 JSObject* receiver, | |
| 190 StrictModeFlag strict_mode); | |
| 191 | |
| 192 | |
| 193 MUST_USE_RESULT MaybeObject* ComputeKeyedLoadOrStoreExternalArray( | 186 MUST_USE_RESULT MaybeObject* ComputeKeyedLoadOrStoreExternalArray( |
| 194 JSObject* receiver, | 187 JSObject* receiver, |
| 195 bool is_store, | 188 bool is_store, |
| 196 StrictModeFlag strict_mode); | 189 StrictModeFlag strict_mode); |
| 197 | 190 |
| 198 // --- | 191 // --- |
| 199 | 192 |
| 200 MUST_USE_RESULT MaybeObject* ComputeCallField(int argc, | 193 MUST_USE_RESULT MaybeObject* ComputeCallField(int argc, |
| 201 InLoopFlag in_loop, | 194 InLoopFlag in_loop, |
| 202 Code::Kind, | 195 Code::Kind, |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 | 455 |
| 463 static void GenerateStoreField(MacroAssembler* masm, | 456 static void GenerateStoreField(MacroAssembler* masm, |
| 464 JSObject* object, | 457 JSObject* object, |
| 465 int index, | 458 int index, |
| 466 Map* transition, | 459 Map* transition, |
| 467 Register receiver_reg, | 460 Register receiver_reg, |
| 468 Register name_reg, | 461 Register name_reg, |
| 469 Register scratch, | 462 Register scratch, |
| 470 Label* miss_label); | 463 Label* miss_label); |
| 471 | 464 |
| 472 static void GenerateLoadMiss(MacroAssembler* masm, Code::Kind kind); | 465 static void GenerateLoadMiss(MacroAssembler* masm, |
| 466 Code::Kind kind); |
| 467 |
| 468 static void GenerateKeyedLoadMissForceGeneric(MacroAssembler* masm); |
| 473 | 469 |
| 474 // Generates code that verifies that the property holder has not changed | 470 // Generates code that verifies that the property holder has not changed |
| 475 // (checking maps of objects in the prototype chain for fast and global | 471 // (checking maps of objects in the prototype chain for fast and global |
| 476 // objects or doing negative lookup for slow objects, ensures that the | 472 // objects or doing negative lookup for slow objects, ensures that the |
| 477 // property cells for global objects are still empty) and checks that the map | 473 // property cells for global objects are still empty) and checks that the map |
| 478 // of the holder has not changed. If necessary the function also generates | 474 // of the holder has not changed. If necessary the function also generates |
| 479 // code for security check in case of global object holders. Helps to make | 475 // code for security check in case of global object holders. Helps to make |
| 480 // sure that the current IC is still valid. | 476 // sure that the current IC is still valid. |
| 481 // | 477 // |
| 482 // The scratch and holder registers are always clobbered, but the object | 478 // The scratch and holder registers are always clobbered, but the object |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 627 Object* value); | 623 Object* value); |
| 628 | 624 |
| 629 MUST_USE_RESULT MaybeObject* CompileLoadInterceptor(JSObject* object, | 625 MUST_USE_RESULT MaybeObject* CompileLoadInterceptor(JSObject* object, |
| 630 JSObject* holder, | 626 JSObject* holder, |
| 631 String* name); | 627 String* name); |
| 632 | 628 |
| 633 MUST_USE_RESULT MaybeObject* CompileLoadArrayLength(String* name); | 629 MUST_USE_RESULT MaybeObject* CompileLoadArrayLength(String* name); |
| 634 MUST_USE_RESULT MaybeObject* CompileLoadStringLength(String* name); | 630 MUST_USE_RESULT MaybeObject* CompileLoadStringLength(String* name); |
| 635 MUST_USE_RESULT MaybeObject* CompileLoadFunctionPrototype(String* name); | 631 MUST_USE_RESULT MaybeObject* CompileLoadFunctionPrototype(String* name); |
| 636 | 632 |
| 637 MUST_USE_RESULT MaybeObject* CompileLoadSpecialized(JSObject* receiver); | 633 MUST_USE_RESULT MaybeObject* CompileLoadFastElement(Map* receiver_map); |
| 634 |
| 635 MUST_USE_RESULT MaybeObject* CompileLoadMegamorphic( |
| 636 MapList* receiver_maps, |
| 637 CodeList* handler_ics); |
| 638 |
| 639 static void GenerateLoadExternalArray(MacroAssembler* masm, |
| 640 ExternalArrayType array_type); |
| 641 |
| 642 static void GenerateLoadFastElement(MacroAssembler* masm); |
| 638 | 643 |
| 639 private: | 644 private: |
| 640 MaybeObject* GetCode(PropertyType type, String* name); | 645 MaybeObject* GetCode(PropertyType type, |
| 646 String* name, |
| 647 InlineCacheState state = MONOMORPHIC); |
| 641 }; | 648 }; |
| 642 | 649 |
| 643 | 650 |
| 644 class StoreStubCompiler: public StubCompiler { | 651 class StoreStubCompiler: public StubCompiler { |
| 645 public: | 652 public: |
| 646 explicit StoreStubCompiler(StrictModeFlag strict_mode) | 653 explicit StoreStubCompiler(StrictModeFlag strict_mode) |
| 647 : strict_mode_(strict_mode) { } | 654 : strict_mode_(strict_mode) { } |
| 648 | 655 |
| 649 MUST_USE_RESULT MaybeObject* CompileStoreField(JSObject* object, | 656 MUST_USE_RESULT MaybeObject* CompileStoreField(JSObject* object, |
| 650 int index, | 657 int index, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 671 class KeyedStoreStubCompiler: public StubCompiler { | 678 class KeyedStoreStubCompiler: public StubCompiler { |
| 672 public: | 679 public: |
| 673 explicit KeyedStoreStubCompiler(StrictModeFlag strict_mode) | 680 explicit KeyedStoreStubCompiler(StrictModeFlag strict_mode) |
| 674 : strict_mode_(strict_mode) { } | 681 : strict_mode_(strict_mode) { } |
| 675 | 682 |
| 676 MUST_USE_RESULT MaybeObject* CompileStoreField(JSObject* object, | 683 MUST_USE_RESULT MaybeObject* CompileStoreField(JSObject* object, |
| 677 int index, | 684 int index, |
| 678 Map* transition, | 685 Map* transition, |
| 679 String* name); | 686 String* name); |
| 680 | 687 |
| 681 MUST_USE_RESULT MaybeObject* CompileStoreSpecialized(JSObject* receiver); | 688 MUST_USE_RESULT MaybeObject* CompileStoreFastElement(Map* receiver_map); |
| 689 |
| 690 MUST_USE_RESULT MaybeObject* CompileStoreMegamorphic( |
| 691 MapList* receiver_maps, |
| 692 CodeList* handler_ics); |
| 693 |
| 694 static void GenerateStoreFastElement(MacroAssembler* masm, |
| 695 bool is_js_array); |
| 696 |
| 697 static void GenerateStoreExternalArray(MacroAssembler* masm, |
| 698 ExternalArrayType array_type); |
| 682 | 699 |
| 683 private: | 700 private: |
| 684 MaybeObject* GetCode(PropertyType type, String* name); | 701 MaybeObject* GetCode(PropertyType type, |
| 702 String* name, |
| 703 InlineCacheState state = MONOMORPHIC); |
| 685 | 704 |
| 686 StrictModeFlag strict_mode_; | 705 StrictModeFlag strict_mode_; |
| 687 }; | 706 }; |
| 688 | 707 |
| 689 | 708 |
| 690 // Subset of FUNCTIONS_WITH_ID_LIST with custom constant/global call | 709 // Subset of FUNCTIONS_WITH_ID_LIST with custom constant/global call |
| 691 // IC stubs. | 710 // IC stubs. |
| 692 #define CUSTOM_CALL_IC_GENERATORS(V) \ | 711 #define CUSTOM_CALL_IC_GENERATORS(V) \ |
| 693 V(ArrayPush) \ | 712 V(ArrayPush) \ |
| 694 V(ArrayPop) \ | 713 V(ArrayPop) \ |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 841 // Determines whether the given function can be called using the | 860 // Determines whether the given function can be called using the |
| 842 // fast api call builtin. | 861 // fast api call builtin. |
| 843 void AnalyzePossibleApiFunction(JSFunction* function); | 862 void AnalyzePossibleApiFunction(JSFunction* function); |
| 844 | 863 |
| 845 JSFunction* constant_function_; | 864 JSFunction* constant_function_; |
| 846 bool is_simple_api_call_; | 865 bool is_simple_api_call_; |
| 847 FunctionTemplateInfo* expected_receiver_type_; | 866 FunctionTemplateInfo* expected_receiver_type_; |
| 848 CallHandlerInfo* api_call_info_; | 867 CallHandlerInfo* api_call_info_; |
| 849 }; | 868 }; |
| 850 | 869 |
| 851 class ExternalArrayStubCompiler: public StubCompiler { | 870 class ExternalArrayLoadStubCompiler: public StubCompiler { |
| 852 public: | 871 public: |
| 853 explicit ExternalArrayStubCompiler() {} | 872 explicit ExternalArrayLoadStubCompiler() {} |
| 854 | 873 |
| 855 MUST_USE_RESULT MaybeObject* CompileKeyedLoadStub( | 874 MUST_USE_RESULT MaybeObject* CompileLoad( |
| 856 JSObject* receiver, ExternalArrayType array_type, Code::Flags flags); | 875 JSObject* receiver, ExternalArrayType array_type); |
| 857 | |
| 858 MUST_USE_RESULT MaybeObject* CompileKeyedStoreStub( | |
| 859 JSObject* receiver, ExternalArrayType array_type, Code::Flags flags); | |
| 860 | 876 |
| 861 private: | 877 private: |
| 862 MaybeObject* GetCode(Code::Flags flags); | 878 MaybeObject* GetCode(); |
| 863 }; | 879 }; |
| 864 | 880 |
| 881 |
| 882 class ExternalArrayStoreStubCompiler: public StubCompiler { |
| 883 public: |
| 884 explicit ExternalArrayStoreStubCompiler() {} |
| 885 |
| 886 MUST_USE_RESULT MaybeObject* CompileStore( |
| 887 JSObject* receiver, ExternalArrayType array_type); |
| 888 |
| 889 private: |
| 890 MaybeObject* GetCode(); |
| 891 }; |
| 892 |
| 893 |
| 865 } } // namespace v8::internal | 894 } } // namespace v8::internal |
| 866 | 895 |
| 867 #endif // V8_STUB_CACHE_H_ | 896 #endif // V8_STUB_CACHE_H_ |
| OLD | NEW |