OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 30 matching lines...) Expand all Loading... |
41 | 41 |
42 | 42 |
43 // The stub cache is used for megamorphic calls and property accesses. | 43 // The stub cache is used for megamorphic calls and property accesses. |
44 // It maps (map, name, type)->Code* | 44 // It maps (map, name, type)->Code* |
45 | 45 |
46 // The design of the table uses the inline cache stubs used for | 46 // The design of the table uses the inline cache stubs used for |
47 // mono-morphic calls. The beauty of this, we do not have to | 47 // mono-morphic calls. The beauty of this, we do not have to |
48 // invalidate the cache whenever a prototype map is changed. The stub | 48 // invalidate the cache whenever a prototype map is changed. The stub |
49 // validates the map chain as in the mono-morphic case. | 49 // validates the map chain as in the mono-morphic case. |
50 | 50 |
51 | |
52 class CallOptimization; | |
53 class SmallMapList; | 51 class SmallMapList; |
54 class StubCache; | 52 class StubCache; |
55 | 53 |
56 | 54 |
57 class SCTableReference { | 55 class SCTableReference { |
58 public: | 56 public: |
59 Address address() const { return address_; } | 57 Address address() const { return address_; } |
60 | 58 |
61 private: | 59 private: |
62 explicit SCTableReference(Address address) : address_(address) {} | 60 explicit SCTableReference(Address address) : address_(address) {} |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 Handle<JSObject> object, | 129 Handle<JSObject> object, |
132 Handle<JSObject> holder, | 130 Handle<JSObject> holder, |
133 PropertyIndex field_index, | 131 PropertyIndex field_index, |
134 Representation representation); | 132 Representation representation); |
135 | 133 |
136 Handle<Code> ComputeLoadCallback(Handle<Name> name, | 134 Handle<Code> ComputeLoadCallback(Handle<Name> name, |
137 Handle<JSObject> object, | 135 Handle<JSObject> object, |
138 Handle<JSObject> holder, | 136 Handle<JSObject> holder, |
139 Handle<ExecutableAccessorInfo> callback); | 137 Handle<ExecutableAccessorInfo> callback); |
140 | 138 |
141 Handle<Code> ComputeLoadCallback(Handle<Name> name, | |
142 Handle<JSObject> object, | |
143 Handle<JSObject> holder, | |
144 const CallOptimization& call_optimization); | |
145 | |
146 Handle<Code> ComputeLoadViaGetter(Handle<Name> name, | 139 Handle<Code> ComputeLoadViaGetter(Handle<Name> name, |
147 Handle<JSObject> object, | 140 Handle<JSObject> object, |
148 Handle<JSObject> holder, | 141 Handle<JSObject> holder, |
149 Handle<JSFunction> getter); | 142 Handle<JSFunction> getter); |
150 | 143 |
151 Handle<Code> ComputeLoadConstant(Handle<Name> name, | 144 Handle<Code> ComputeLoadConstant(Handle<Name> name, |
152 Handle<JSObject> object, | 145 Handle<JSObject> object, |
153 Handle<JSObject> holder, | 146 Handle<JSObject> holder, |
154 Handle<Object> value); | 147 Handle<Object> value); |
155 | 148 |
(...skipping 17 matching lines...) Expand all Loading... |
173 Handle<JSObject> holder, | 166 Handle<JSObject> holder, |
174 PropertyIndex field_index, | 167 PropertyIndex field_index, |
175 Representation representation); | 168 Representation representation); |
176 | 169 |
177 Handle<Code> ComputeKeyedLoadCallback( | 170 Handle<Code> ComputeKeyedLoadCallback( |
178 Handle<Name> name, | 171 Handle<Name> name, |
179 Handle<JSObject> object, | 172 Handle<JSObject> object, |
180 Handle<JSObject> holder, | 173 Handle<JSObject> holder, |
181 Handle<ExecutableAccessorInfo> callback); | 174 Handle<ExecutableAccessorInfo> callback); |
182 | 175 |
183 Handle<Code> ComputeKeyedLoadCallback( | |
184 Handle<Name> name, | |
185 Handle<JSObject> object, | |
186 Handle<JSObject> holder, | |
187 const CallOptimization& call_optimization); | |
188 | |
189 Handle<Code> ComputeKeyedLoadConstant(Handle<Name> name, | 176 Handle<Code> ComputeKeyedLoadConstant(Handle<Name> name, |
190 Handle<JSObject> object, | 177 Handle<JSObject> object, |
191 Handle<JSObject> holder, | 178 Handle<JSObject> holder, |
192 Handle<Object> value); | 179 Handle<Object> value); |
193 | 180 |
194 Handle<Code> ComputeKeyedLoadInterceptor(Handle<Name> name, | 181 Handle<Code> ComputeKeyedLoadInterceptor(Handle<Name> name, |
195 Handle<JSObject> object, | 182 Handle<JSObject> object, |
196 Handle<JSObject> holder); | 183 Handle<JSObject> holder); |
197 | 184 |
198 // --- | 185 // --- |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
711 Handle<JSObject> holder, | 698 Handle<JSObject> holder, |
712 Handle<Name> name, | 699 Handle<Name> name, |
713 PropertyIndex index, | 700 PropertyIndex index, |
714 Representation representation); | 701 Representation representation); |
715 | 702 |
716 Handle<Code> CompileLoadCallback(Handle<JSObject> object, | 703 Handle<Code> CompileLoadCallback(Handle<JSObject> object, |
717 Handle<JSObject> holder, | 704 Handle<JSObject> holder, |
718 Handle<Name> name, | 705 Handle<Name> name, |
719 Handle<ExecutableAccessorInfo> callback); | 706 Handle<ExecutableAccessorInfo> callback); |
720 | 707 |
721 Handle<Code> CompileLoadCallback(Handle<JSObject> object, | |
722 Handle<JSObject> holder, | |
723 Handle<Name> name, | |
724 const CallOptimization& call_optimization); | |
725 | |
726 Handle<Code> CompileLoadConstant(Handle<JSObject> object, | 708 Handle<Code> CompileLoadConstant(Handle<JSObject> object, |
727 Handle<JSObject> holder, | 709 Handle<JSObject> holder, |
728 Handle<Name> name, | 710 Handle<Name> name, |
729 Handle<Object> value); | 711 Handle<Object> value); |
730 | 712 |
731 Handle<Code> CompileLoadInterceptor(Handle<JSObject> object, | 713 Handle<Code> CompileLoadInterceptor(Handle<JSObject> object, |
732 Handle<JSObject> holder, | 714 Handle<JSObject> holder, |
733 Handle<Name> name); | 715 Handle<Name> name); |
734 | 716 |
735 protected: | 717 protected: |
736 virtual Register HandlerFrontendHeader(Handle<JSObject> object, | 718 virtual Register HandlerFrontendHeader(Handle<JSObject> object, |
737 Register object_reg, | 719 Register object_reg, |
738 Handle<JSObject> holder, | 720 Handle<JSObject> holder, |
739 Handle<Name> name, | 721 Handle<Name> name, |
740 Label* miss); | 722 Label* miss); |
741 | 723 |
742 virtual void HandlerFrontendFooter(Handle<Name> name, | 724 virtual void HandlerFrontendFooter(Handle<Name> name, |
743 Label* success, | 725 Label* success, |
744 Label* miss); | 726 Label* miss); |
745 | 727 |
746 Register CallbackHandlerFrontend(Handle<JSObject> object, | 728 Register CallbackHandlerFrontend(Handle<JSObject> object, |
747 Register object_reg, | 729 Register object_reg, |
748 Handle<JSObject> holder, | 730 Handle<JSObject> holder, |
749 Handle<Name> name, | 731 Handle<Name> name, |
750 Label* success, | 732 Label* success, |
751 Handle<Object> callback); | 733 Handle<ExecutableAccessorInfo> callback); |
752 void NonexistentHandlerFrontend(Handle<JSObject> object, | 734 void NonexistentHandlerFrontend(Handle<JSObject> object, |
753 Handle<JSObject> last, | 735 Handle<JSObject> last, |
754 Handle<Name> name, | 736 Handle<Name> name, |
755 Label* success, | 737 Label* success, |
756 Handle<GlobalObject> global); | 738 Handle<GlobalObject> global); |
757 | 739 |
758 void GenerateLoadField(Register reg, | 740 void GenerateLoadField(Register reg, |
759 Handle<JSObject> holder, | 741 Handle<JSObject> holder, |
760 PropertyIndex field, | 742 PropertyIndex field, |
761 Representation representation); | 743 Representation representation); |
762 void GenerateLoadConstant(Handle<Object> value); | 744 void GenerateLoadConstant(Handle<Object> value); |
763 void GenerateLoadCallback(Register reg, | 745 void GenerateLoadCallback(Register reg, |
764 Handle<ExecutableAccessorInfo> callback); | 746 Handle<ExecutableAccessorInfo> callback); |
765 void GenerateLoadCallback(const CallOptimization& call_optimization); | |
766 void GenerateLoadInterceptor(Register holder_reg, | 747 void GenerateLoadInterceptor(Register holder_reg, |
767 Handle<JSObject> object, | 748 Handle<JSObject> object, |
768 Handle<JSObject> holder, | 749 Handle<JSObject> holder, |
769 LookupResult* lookup, | 750 LookupResult* lookup, |
770 Handle<Name> name); | 751 Handle<Name> name); |
771 void GenerateLoadPostInterceptor(Register reg, | 752 void GenerateLoadPostInterceptor(Register reg, |
772 Handle<JSObject> interceptor_holder, | 753 Handle<JSObject> interceptor_holder, |
773 Handle<Name> name, | 754 Handle<Name> name, |
774 LookupResult* lookup); | 755 LookupResult* lookup); |
775 | 756 |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1040 V(StringFromCharCode) \ | 1021 V(StringFromCharCode) \ |
1041 V(MathFloor) \ | 1022 V(MathFloor) \ |
1042 V(MathAbs) \ | 1023 V(MathAbs) \ |
1043 V(ArrayCode) | 1024 V(ArrayCode) |
1044 | 1025 |
1045 | 1026 |
1046 #define SITE_SPECIFIC_CALL_GENERATORS(V) \ | 1027 #define SITE_SPECIFIC_CALL_GENERATORS(V) \ |
1047 V(ArrayCode) | 1028 V(ArrayCode) |
1048 | 1029 |
1049 | 1030 |
| 1031 class CallOptimization; |
| 1032 |
1050 class CallStubCompiler: public StubCompiler { | 1033 class CallStubCompiler: public StubCompiler { |
1051 public: | 1034 public: |
1052 CallStubCompiler(Isolate* isolate, | 1035 CallStubCompiler(Isolate* isolate, |
1053 int argc, | 1036 int argc, |
1054 Code::Kind kind, | 1037 Code::Kind kind, |
1055 Code::ExtraICState extra_state, | 1038 Code::ExtraICState extra_state, |
1056 InlineCacheHolderFlag cache_holder); | 1039 InlineCacheHolderFlag cache_holder); |
1057 | 1040 |
1058 Handle<Code> CompileCallField(Handle<JSObject> object, | 1041 Handle<Code> CompileCallField(Handle<JSObject> object, |
1059 Handle<JSObject> holder, | 1042 Handle<JSObject> holder, |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1171 Handle<CallHandlerInfo> api_call_info() const { | 1154 Handle<CallHandlerInfo> api_call_info() const { |
1172 ASSERT(is_simple_api_call()); | 1155 ASSERT(is_simple_api_call()); |
1173 return api_call_info_; | 1156 return api_call_info_; |
1174 } | 1157 } |
1175 | 1158 |
1176 // Returns the depth of the object having the expected type in the | 1159 // Returns the depth of the object having the expected type in the |
1177 // prototype chain between the two arguments. | 1160 // prototype chain between the two arguments. |
1178 int GetPrototypeDepthOfExpectedType(Handle<JSObject> object, | 1161 int GetPrototypeDepthOfExpectedType(Handle<JSObject> object, |
1179 Handle<JSObject> holder) const; | 1162 Handle<JSObject> holder) const; |
1180 | 1163 |
1181 bool IsCompatibleReceiver(Object* receiver) { | |
1182 ASSERT(is_simple_api_call()); | |
1183 if (expected_receiver_type_.is_null()) return true; | |
1184 return receiver->IsInstanceOf(*expected_receiver_type_); | |
1185 } | |
1186 | |
1187 private: | 1164 private: |
1188 void Initialize(Handle<JSFunction> function); | 1165 void Initialize(Handle<JSFunction> function); |
1189 | 1166 |
1190 // Determines whether the given function can be called using the | 1167 // Determines whether the given function can be called using the |
1191 // fast api call builtin. | 1168 // fast api call builtin. |
1192 void AnalyzePossibleApiFunction(Handle<JSFunction> function); | 1169 void AnalyzePossibleApiFunction(Handle<JSFunction> function); |
1193 | 1170 |
1194 Handle<JSFunction> constant_function_; | 1171 Handle<JSFunction> constant_function_; |
1195 bool is_simple_api_call_; | 1172 bool is_simple_api_call_; |
1196 Handle<FunctionTemplateInfo> expected_receiver_type_; | 1173 Handle<FunctionTemplateInfo> expected_receiver_type_; |
1197 Handle<CallHandlerInfo> api_call_info_; | 1174 Handle<CallHandlerInfo> api_call_info_; |
1198 }; | 1175 }; |
1199 | 1176 |
1200 | 1177 |
1201 } } // namespace v8::internal | 1178 } } // namespace v8::internal |
1202 | 1179 |
1203 #endif // V8_STUB_CACHE_H_ | 1180 #endif // V8_STUB_CACHE_H_ |
OLD | NEW |