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