| 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. |
| 12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
| 13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
| 14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
| 15 // | 15 // |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 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 "arguments.h" | 32 #include "arguments.h" |
| 32 #include "macro-assembler.h" | 33 #include "macro-assembler.h" |
| 34 #include "objects.h" |
| 33 #include "zone-inl.h" | 35 #include "zone-inl.h" |
| 34 | 36 |
| 35 namespace v8 { | 37 namespace v8 { |
| 36 namespace internal { | 38 namespace internal { |
| 37 | 39 |
| 38 | 40 |
| 39 // The stub cache is used for megamorphic calls and property accesses. | 41 // The stub cache is used for megamorphic calls and property accesses. |
| 40 // It maps (map, name, type)->Code* | 42 // It maps (map, name, type)->Code* |
| 41 | 43 |
| 42 // 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... |
| 136 JSArray* receiver); | 138 JSArray* receiver); |
| 137 | 139 |
| 138 MUST_USE_RESULT MaybeObject* ComputeKeyedLoadStringLength( | 140 MUST_USE_RESULT MaybeObject* ComputeKeyedLoadStringLength( |
| 139 String* name, | 141 String* name, |
| 140 String* receiver); | 142 String* receiver); |
| 141 | 143 |
| 142 MUST_USE_RESULT MaybeObject* ComputeKeyedLoadFunctionPrototype( | 144 MUST_USE_RESULT MaybeObject* ComputeKeyedLoadFunctionPrototype( |
| 143 String* name, | 145 String* name, |
| 144 JSFunction* receiver); | 146 JSFunction* receiver); |
| 145 | 147 |
| 146 MUST_USE_RESULT MaybeObject* ComputeKeyedLoadSpecialized( | |
| 147 JSObject* receiver); | |
| 148 | |
| 149 // --- | 148 // --- |
| 150 | 149 |
| 151 MUST_USE_RESULT MaybeObject* ComputeStoreField( | 150 MUST_USE_RESULT MaybeObject* ComputeStoreField( |
| 152 String* name, | 151 String* name, |
| 153 JSObject* receiver, | 152 JSObject* receiver, |
| 154 int field_index, | 153 int field_index, |
| 155 Map* transition, | 154 Map* transition, |
| 156 StrictModeFlag strict_mode); | 155 StrictModeFlag strict_mode); |
| 157 | 156 |
| 158 MUST_USE_RESULT MaybeObject* ComputeStoreNormal( | 157 MUST_USE_RESULT MaybeObject* ComputeStoreNormal( |
| (...skipping 18 matching lines...) Expand all Loading... |
| 177 | 176 |
| 178 // --- | 177 // --- |
| 179 | 178 |
| 180 MUST_USE_RESULT MaybeObject* ComputeKeyedStoreField( | 179 MUST_USE_RESULT MaybeObject* ComputeKeyedStoreField( |
| 181 String* name, | 180 String* name, |
| 182 JSObject* receiver, | 181 JSObject* receiver, |
| 183 int field_index, | 182 int field_index, |
| 184 Map* transition, | 183 Map* transition, |
| 185 StrictModeFlag strict_mode); | 184 StrictModeFlag strict_mode); |
| 186 | 185 |
| 187 MUST_USE_RESULT MaybeObject* ComputeKeyedStoreSpecialized( | |
| 188 JSObject* receiver, | |
| 189 StrictModeFlag strict_mode); | |
| 190 | |
| 191 | |
| 192 MUST_USE_RESULT MaybeObject* ComputeKeyedLoadOrStoreExternalArray( | 186 MUST_USE_RESULT MaybeObject* ComputeKeyedLoadOrStoreExternalArray( |
| 193 JSObject* receiver, | 187 JSObject* receiver, |
| 194 bool is_store, | 188 bool is_store, |
| 195 StrictModeFlag strict_mode); | 189 StrictModeFlag strict_mode); |
| 196 | 190 |
| 191 MUST_USE_RESULT MaybeObject* ComputeKeyedLoadOrStoreFastElement( |
| 192 JSObject* receiver, |
| 193 bool is_store, |
| 194 StrictModeFlag strict_mode); |
| 197 // --- | 195 // --- |
| 198 | 196 |
| 199 MUST_USE_RESULT MaybeObject* ComputeCallField(int argc, | 197 MUST_USE_RESULT MaybeObject* ComputeCallField(int argc, |
| 200 InLoopFlag in_loop, | 198 InLoopFlag in_loop, |
| 201 Code::Kind, | 199 Code::Kind, |
| 202 String* name, | 200 String* name, |
| 203 Object* object, | 201 Object* object, |
| 204 JSObject* holder, | 202 JSObject* holder, |
| 205 int index); | 203 int index); |
| 206 | 204 |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 | 459 |
| 462 static void GenerateStoreField(MacroAssembler* masm, | 460 static void GenerateStoreField(MacroAssembler* masm, |
| 463 JSObject* object, | 461 JSObject* object, |
| 464 int index, | 462 int index, |
| 465 Map* transition, | 463 Map* transition, |
| 466 Register receiver_reg, | 464 Register receiver_reg, |
| 467 Register name_reg, | 465 Register name_reg, |
| 468 Register scratch, | 466 Register scratch, |
| 469 Label* miss_label); | 467 Label* miss_label); |
| 470 | 468 |
| 471 static void GenerateLoadMiss(MacroAssembler* masm, Code::Kind kind); | 469 static void GenerateLoadMiss(MacroAssembler* masm, |
| 470 Code::Kind kind); |
| 471 |
| 472 static void GenerateKeyedLoadMissForceGeneric(MacroAssembler* masm); |
| 472 | 473 |
| 473 // Generates code that verifies that the property holder has not changed | 474 // Generates code that verifies that the property holder has not changed |
| 474 // (checking maps of objects in the prototype chain for fast and global | 475 // (checking maps of objects in the prototype chain for fast and global |
| 475 // objects or doing negative lookup for slow objects, ensures that the | 476 // objects or doing negative lookup for slow objects, ensures that the |
| 476 // property cells for global objects are still empty) and checks that the map | 477 // property cells for global objects are still empty) and checks that the map |
| 477 // of the holder has not changed. If necessary the function also generates | 478 // of the holder has not changed. If necessary the function also generates |
| 478 // code for security check in case of global object holders. Helps to make | 479 // code for security check in case of global object holders. Helps to make |
| 479 // sure that the current IC is still valid. | 480 // sure that the current IC is still valid. |
| 480 // | 481 // |
| 481 // The scratch and holder registers are always clobbered, but the object | 482 // The scratch and holder registers are always clobbered, but the object |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 Object* value); | 627 Object* value); |
| 627 | 628 |
| 628 MUST_USE_RESULT MaybeObject* CompileLoadInterceptor(JSObject* object, | 629 MUST_USE_RESULT MaybeObject* CompileLoadInterceptor(JSObject* object, |
| 629 JSObject* holder, | 630 JSObject* holder, |
| 630 String* name); | 631 String* name); |
| 631 | 632 |
| 632 MUST_USE_RESULT MaybeObject* CompileLoadArrayLength(String* name); | 633 MUST_USE_RESULT MaybeObject* CompileLoadArrayLength(String* name); |
| 633 MUST_USE_RESULT MaybeObject* CompileLoadStringLength(String* name); | 634 MUST_USE_RESULT MaybeObject* CompileLoadStringLength(String* name); |
| 634 MUST_USE_RESULT MaybeObject* CompileLoadFunctionPrototype(String* name); | 635 MUST_USE_RESULT MaybeObject* CompileLoadFunctionPrototype(String* name); |
| 635 | 636 |
| 636 MUST_USE_RESULT MaybeObject* CompileLoadSpecialized(JSObject* receiver); | 637 MUST_USE_RESULT MaybeObject* CompileLoadFastElement(Map* receiver_map); |
| 638 |
| 639 MUST_USE_RESULT MaybeObject* CompileLoadMegamorphic( |
| 640 MapList* receiver_maps, |
| 641 CodeList* handler_ics); |
| 642 |
| 643 static void GenerateLoadExternalArray(MacroAssembler* masm, |
| 644 ExternalArrayType array_type); |
| 645 |
| 646 static void GenerateLoadFastElement(MacroAssembler* masm); |
| 637 | 647 |
| 638 private: | 648 private: |
| 639 MaybeObject* GetCode(PropertyType type, String* name); | 649 MaybeObject* GetCode(PropertyType type, |
| 650 String* name, |
| 651 InlineCacheState state = MONOMORPHIC); |
| 640 }; | 652 }; |
| 641 | 653 |
| 642 | 654 |
| 643 class StoreStubCompiler: public StubCompiler { | 655 class StoreStubCompiler: public StubCompiler { |
| 644 public: | 656 public: |
| 645 explicit StoreStubCompiler(StrictModeFlag strict_mode) | 657 explicit StoreStubCompiler(StrictModeFlag strict_mode) |
| 646 : strict_mode_(strict_mode) { } | 658 : strict_mode_(strict_mode) { } |
| 647 | 659 |
| 648 MUST_USE_RESULT MaybeObject* CompileStoreField(JSObject* object, | 660 MUST_USE_RESULT MaybeObject* CompileStoreField(JSObject* object, |
| 649 int index, | 661 int index, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 670 class KeyedStoreStubCompiler: public StubCompiler { | 682 class KeyedStoreStubCompiler: public StubCompiler { |
| 671 public: | 683 public: |
| 672 explicit KeyedStoreStubCompiler(StrictModeFlag strict_mode) | 684 explicit KeyedStoreStubCompiler(StrictModeFlag strict_mode) |
| 673 : strict_mode_(strict_mode) { } | 685 : strict_mode_(strict_mode) { } |
| 674 | 686 |
| 675 MUST_USE_RESULT MaybeObject* CompileStoreField(JSObject* object, | 687 MUST_USE_RESULT MaybeObject* CompileStoreField(JSObject* object, |
| 676 int index, | 688 int index, |
| 677 Map* transition, | 689 Map* transition, |
| 678 String* name); | 690 String* name); |
| 679 | 691 |
| 680 MUST_USE_RESULT MaybeObject* CompileStoreSpecialized(JSObject* receiver); | 692 MUST_USE_RESULT MaybeObject* CompileStoreFastElement(Map* receiver_map); |
| 693 |
| 694 MUST_USE_RESULT MaybeObject* CompileStoreMegamorphic( |
| 695 MapList* receiver_maps, |
| 696 CodeList* handler_ics); |
| 697 |
| 698 static void GenerateStoreFastElement(MacroAssembler* masm, |
| 699 bool is_js_array); |
| 700 |
| 701 static void GenerateStoreExternalArray(MacroAssembler* masm, |
| 702 ExternalArrayType array_type); |
| 681 | 703 |
| 682 private: | 704 private: |
| 683 MaybeObject* GetCode(PropertyType type, String* name); | 705 MaybeObject* GetCode(PropertyType type, |
| 706 String* name, |
| 707 InlineCacheState state = MONOMORPHIC); |
| 684 | 708 |
| 685 StrictModeFlag strict_mode_; | 709 StrictModeFlag strict_mode_; |
| 686 }; | 710 }; |
| 687 | 711 |
| 688 | 712 |
| 689 // Subset of FUNCTIONS_WITH_ID_LIST with custom constant/global call | 713 // Subset of FUNCTIONS_WITH_ID_LIST with custom constant/global call |
| 690 // IC stubs. | 714 // IC stubs. |
| 691 #define CUSTOM_CALL_IC_GENERATORS(V) \ | 715 #define CUSTOM_CALL_IC_GENERATORS(V) \ |
| 692 V(ArrayPush) \ | 716 V(ArrayPush) \ |
| 693 V(ArrayPop) \ | 717 V(ArrayPop) \ |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 // Determines whether the given function can be called using the | 864 // Determines whether the given function can be called using the |
| 841 // fast api call builtin. | 865 // fast api call builtin. |
| 842 void AnalyzePossibleApiFunction(JSFunction* function); | 866 void AnalyzePossibleApiFunction(JSFunction* function); |
| 843 | 867 |
| 844 JSFunction* constant_function_; | 868 JSFunction* constant_function_; |
| 845 bool is_simple_api_call_; | 869 bool is_simple_api_call_; |
| 846 FunctionTemplateInfo* expected_receiver_type_; | 870 FunctionTemplateInfo* expected_receiver_type_; |
| 847 CallHandlerInfo* api_call_info_; | 871 CallHandlerInfo* api_call_info_; |
| 848 }; | 872 }; |
| 849 | 873 |
| 850 class ExternalArrayStubCompiler: public StubCompiler { | 874 class ExternalArrayLoadStubCompiler: public StubCompiler { |
| 851 public: | 875 public: |
| 852 explicit ExternalArrayStubCompiler() {} | 876 explicit ExternalArrayLoadStubCompiler(StrictModeFlag strict_mode) |
| 877 : strict_mode_(strict_mode) { } |
| 853 | 878 |
| 854 MUST_USE_RESULT MaybeObject* CompileKeyedLoadStub( | 879 MUST_USE_RESULT MaybeObject* CompileLoad( |
| 855 JSObject* receiver, ExternalArrayType array_type, Code::Flags flags); | 880 JSObject* receiver, ExternalArrayType array_type); |
| 856 | |
| 857 MUST_USE_RESULT MaybeObject* CompileKeyedStoreStub( | |
| 858 JSObject* receiver, ExternalArrayType array_type, Code::Flags flags); | |
| 859 | 881 |
| 860 private: | 882 private: |
| 861 MaybeObject* GetCode(Code::Flags flags); | 883 MaybeObject* GetCode(); |
| 884 |
| 885 StrictModeFlag strict_mode_; |
| 862 }; | 886 }; |
| 863 | 887 |
| 888 |
| 889 class ExternalArrayStoreStubCompiler: public StubCompiler { |
| 890 public: |
| 891 explicit ExternalArrayStoreStubCompiler(StrictModeFlag strict_mode) |
| 892 : strict_mode_(strict_mode) {} |
| 893 |
| 894 MUST_USE_RESULT MaybeObject* CompileStore( |
| 895 JSObject* receiver, ExternalArrayType array_type); |
| 896 |
| 897 private: |
| 898 MaybeObject* GetCode(); |
| 899 |
| 900 StrictModeFlag strict_mode_; |
| 901 }; |
| 902 |
| 903 |
| 864 } } // namespace v8::internal | 904 } } // namespace v8::internal |
| 865 | 905 |
| 866 #endif // V8_STUB_CACHE_H_ | 906 #endif // V8_STUB_CACHE_H_ |
| OLD | NEW |