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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 ExtraICState extra_ic_state); | 97 ExtraICState extra_ic_state); |
98 | 98 |
99 Handle<Code> ComputeLoadNonexistent(Handle<Name> name, Handle<HeapType> type); | 99 Handle<Code> ComputeLoadNonexistent(Handle<Name> name, Handle<HeapType> type); |
100 | 100 |
101 Handle<Code> ComputeKeyedLoadElement(Handle<Map> receiver_map); | 101 Handle<Code> ComputeKeyedLoadElement(Handle<Map> receiver_map); |
102 | 102 |
103 Handle<Code> ComputeKeyedStoreElement(Handle<Map> receiver_map, | 103 Handle<Code> ComputeKeyedStoreElement(Handle<Map> receiver_map, |
104 StrictModeFlag strict_mode, | 104 StrictModeFlag strict_mode, |
105 KeyedAccessStoreMode store_mode); | 105 KeyedAccessStoreMode store_mode); |
106 | 106 |
107 Handle<Code> ComputeCallField(int argc, | |
108 Code::Kind, | |
109 ExtraICState extra_state, | |
110 Handle<Name> name, | |
111 Handle<Object> object, | |
112 Handle<JSObject> holder, | |
113 PropertyIndex index); | |
114 | |
115 Handle<Code> ComputeCallConstant(int argc, | |
116 Code::Kind, | |
117 ExtraICState extra_state, | |
118 Handle<Name> name, | |
119 Handle<Object> object, | |
120 Handle<JSObject> holder, | |
121 Handle<JSFunction> function); | |
122 | |
123 Handle<Code> ComputeCallInterceptor(int argc, | |
124 Code::Kind, | |
125 ExtraICState extra_state, | |
126 Handle<Name> name, | |
127 Handle<Object> object, | |
128 Handle<JSObject> holder); | |
129 | |
130 Handle<Code> ComputeCallGlobal(int argc, | |
131 Code::Kind, | |
132 ExtraICState extra_state, | |
133 Handle<Name> name, | |
134 Handle<JSObject> object, | |
135 Handle<GlobalObject> holder, | |
136 Handle<PropertyCell> cell, | |
137 Handle<JSFunction> function); | |
138 | |
139 // --- | |
140 | |
141 Handle<Code> ComputeCallInitialize(int argc); | |
142 | |
143 Handle<Code> ComputeKeyedCallInitialize(int argc); | |
144 | |
145 Handle<Code> ComputeCallPreMonomorphic(int argc, | |
146 Code::Kind kind, | |
147 ExtraICState extra_state); | |
148 | |
149 Handle<Code> ComputeCallNormal(int argc, | |
150 Code::Kind kind, | |
151 ExtraICState state); | |
152 | |
153 Handle<Code> ComputeCallArguments(int argc); | |
154 | |
155 Handle<Code> ComputeCallMegamorphic(int argc, | |
156 Code::Kind kind, | |
157 ExtraICState state); | |
158 | |
159 Handle<Code> ComputeCallMiss(int argc, | |
160 Code::Kind kind, | |
161 ExtraICState state); | |
162 | |
163 // --- | 107 // --- |
164 | 108 |
165 Handle<Code> ComputeLoad(InlineCacheState ic_state, ExtraICState extra_state); | 109 Handle<Code> ComputeLoad(InlineCacheState ic_state, ExtraICState extra_state); |
166 Handle<Code> ComputeStore(InlineCacheState ic_state, | 110 Handle<Code> ComputeStore(InlineCacheState ic_state, |
167 ExtraICState extra_state); | 111 ExtraICState extra_state); |
168 | 112 |
169 // --- | 113 // --- |
170 | 114 |
171 Handle<Code> ComputeCompareNil(Handle<Map> receiver_map, | 115 Handle<Code> ComputeCompareNil(Handle<Map> receiver_map, |
172 CompareNilICStub& stub); | 116 CompareNilICStub& stub); |
173 | 117 |
174 // --- | 118 // --- |
175 | 119 |
176 Handle<Code> ComputeLoadElementPolymorphic(MapHandleList* receiver_maps); | 120 Handle<Code> ComputeLoadElementPolymorphic(MapHandleList* receiver_maps); |
177 Handle<Code> ComputeStoreElementPolymorphic(MapHandleList* receiver_maps, | 121 Handle<Code> ComputeStoreElementPolymorphic(MapHandleList* receiver_maps, |
178 KeyedAccessStoreMode store_mode, | 122 KeyedAccessStoreMode store_mode, |
179 StrictModeFlag strict_mode); | 123 StrictModeFlag strict_mode); |
180 | 124 |
181 Handle<Code> ComputePolymorphicIC(TypeHandleList* types, | 125 Handle<Code> ComputePolymorphicIC(TypeHandleList* types, |
182 CodeHandleList* handlers, | 126 CodeHandleList* handlers, |
183 int number_of_valid_maps, | 127 int number_of_valid_maps, |
184 Handle<Name> name, | 128 Handle<Name> name, |
185 ExtraICState extra_ic_state); | 129 ExtraICState extra_ic_state); |
186 | 130 |
187 // Finds the Code object stored in the Heap::non_monomorphic_cache(). | 131 // Finds the Code object stored in the Heap::non_monomorphic_cache(). |
188 Code* FindCallInitialize(int argc, Code::Kind kind); | |
189 Code* FindPreMonomorphicIC(Code::Kind kind, ExtraICState extra_ic_state); | 132 Code* FindPreMonomorphicIC(Code::Kind kind, ExtraICState extra_ic_state); |
190 | 133 |
191 #ifdef ENABLE_DEBUGGER_SUPPORT | |
192 Handle<Code> ComputeCallDebugBreak(int argc, Code::Kind kind); | |
193 | |
194 Handle<Code> ComputeCallDebugPrepareStepIn(int argc, Code::Kind kind); | |
195 #endif | |
196 | |
197 // Update cache for entry hash(name, map). | 134 // Update cache for entry hash(name, map). |
198 Code* Set(Name* name, Map* map, Code* code); | 135 Code* Set(Name* name, Map* map, Code* code); |
199 | 136 |
200 // Clear the lookup table (@ mark compact collection). | 137 // Clear the lookup table (@ mark compact collection). |
201 void Clear(); | 138 void Clear(); |
202 | 139 |
203 // Collect all maps that match the name and flags. | 140 // Collect all maps that match the name and flags. |
204 void CollectMatchingMaps(SmallMapList* types, | 141 void CollectMatchingMaps(SmallMapList* types, |
205 Handle<Name> name, | 142 Handle<Name> name, |
206 Code::Flags flags, | 143 Code::Flags flags, |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 // LoadWithInterceptor. | 199 // LoadWithInterceptor. |
263 static const int kInterceptorArgsNameIndex = 0; | 200 static const int kInterceptorArgsNameIndex = 0; |
264 static const int kInterceptorArgsInfoIndex = 1; | 201 static const int kInterceptorArgsInfoIndex = 1; |
265 static const int kInterceptorArgsThisIndex = 2; | 202 static const int kInterceptorArgsThisIndex = 2; |
266 static const int kInterceptorArgsHolderIndex = 3; | 203 static const int kInterceptorArgsHolderIndex = 3; |
267 static const int kInterceptorArgsLength = 4; | 204 static const int kInterceptorArgsLength = 4; |
268 | 205 |
269 private: | 206 private: |
270 explicit StubCache(Isolate* isolate); | 207 explicit StubCache(Isolate* isolate); |
271 | 208 |
272 Handle<Code> ComputeCallInitialize(int argc, Code::Kind kind); | |
273 | |
274 // The stub cache has a primary and secondary level. The two levels have | 209 // The stub cache has a primary and secondary level. The two levels have |
275 // different hashing algorithms in order to avoid simultaneous collisions | 210 // different hashing algorithms in order to avoid simultaneous collisions |
276 // in both caches. Unlike a probing strategy (quadratic or otherwise) the | 211 // in both caches. Unlike a probing strategy (quadratic or otherwise) the |
277 // update strategy on updates is fairly clear and simple: Any existing entry | 212 // update strategy on updates is fairly clear and simple: Any existing entry |
278 // in the primary cache is moved to the secondary cache, and secondary cache | 213 // in the primary cache is moved to the secondary cache, and secondary cache |
279 // entries are overwritten. | 214 // entries are overwritten. |
280 | 215 |
281 // Hash algorithm for the primary table. This algorithm is replicated in | 216 // Hash algorithm for the primary table. This algorithm is replicated in |
282 // assembler for every architecture. Returns an index into the table that | 217 // assembler for every architecture. Returns an index into the table that |
283 // is scaled by 1 << kHeapObjectTagSize. | 218 // is scaled by 1 << kHeapObjectTagSize. |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 | 286 |
352 // Support functions for IC stubs for callbacks. | 287 // Support functions for IC stubs for callbacks. |
353 DECLARE_RUNTIME_FUNCTION(MaybeObject*, StoreCallbackProperty); | 288 DECLARE_RUNTIME_FUNCTION(MaybeObject*, StoreCallbackProperty); |
354 | 289 |
355 | 290 |
356 // Support functions for IC stubs for interceptors. | 291 // Support functions for IC stubs for interceptors. |
357 DECLARE_RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorOnly); | 292 DECLARE_RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorOnly); |
358 DECLARE_RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorForLoad); | 293 DECLARE_RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorForLoad); |
359 DECLARE_RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorForCall); | 294 DECLARE_RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorForCall); |
360 DECLARE_RUNTIME_FUNCTION(MaybeObject*, StoreInterceptorProperty); | 295 DECLARE_RUNTIME_FUNCTION(MaybeObject*, StoreInterceptorProperty); |
361 DECLARE_RUNTIME_FUNCTION(MaybeObject*, CallInterceptorProperty); | |
362 DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedLoadPropertyWithInterceptor); | 296 DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedLoadPropertyWithInterceptor); |
363 | 297 |
364 | 298 |
365 enum PrototypeCheckType { CHECK_ALL_MAPS, SKIP_RECEIVER }; | 299 enum PrototypeCheckType { CHECK_ALL_MAPS, SKIP_RECEIVER }; |
366 enum IcCheckType { ELEMENT, PROPERTY }; | 300 enum IcCheckType { ELEMENT, PROPERTY }; |
367 | 301 |
368 | 302 |
369 // The stub compilers compile stubs for the stub cache. | 303 // The stub compilers compile stubs for the stub cache. |
370 class StubCompiler BASE_EMBEDDED { | 304 class StubCompiler BASE_EMBEDDED { |
371 public: | 305 public: |
372 explicit StubCompiler(Isolate* isolate, | 306 explicit StubCompiler(Isolate* isolate, |
373 ExtraICState extra_ic_state = kNoExtraICState) | 307 ExtraICState extra_ic_state = kNoExtraICState) |
374 : isolate_(isolate), extra_ic_state_(extra_ic_state), | 308 : isolate_(isolate), extra_ic_state_(extra_ic_state), |
375 masm_(isolate, NULL, 256), failure_(NULL) { } | 309 masm_(isolate, NULL, 256), failure_(NULL) { } |
376 | 310 |
377 // Functions to compile either CallIC or KeyedCallIC. The specific kind | |
378 // is extracted from the code flags. | |
379 Handle<Code> CompileCallInitialize(Code::Flags flags); | |
380 Handle<Code> CompileCallPreMonomorphic(Code::Flags flags); | |
381 Handle<Code> CompileCallNormal(Code::Flags flags); | |
382 Handle<Code> CompileCallMegamorphic(Code::Flags flags); | |
383 Handle<Code> CompileCallArguments(Code::Flags flags); | |
384 Handle<Code> CompileCallMiss(Code::Flags flags); | |
385 | |
386 Handle<Code> CompileLoadInitialize(Code::Flags flags); | 311 Handle<Code> CompileLoadInitialize(Code::Flags flags); |
387 Handle<Code> CompileLoadPreMonomorphic(Code::Flags flags); | 312 Handle<Code> CompileLoadPreMonomorphic(Code::Flags flags); |
388 Handle<Code> CompileLoadMegamorphic(Code::Flags flags); | 313 Handle<Code> CompileLoadMegamorphic(Code::Flags flags); |
389 | 314 |
390 Handle<Code> CompileStoreInitialize(Code::Flags flags); | 315 Handle<Code> CompileStoreInitialize(Code::Flags flags); |
391 Handle<Code> CompileStorePreMonomorphic(Code::Flags flags); | 316 Handle<Code> CompileStorePreMonomorphic(Code::Flags flags); |
392 Handle<Code> CompileStoreGeneric(Code::Flags flags); | 317 Handle<Code> CompileStoreGeneric(Code::Flags flags); |
393 Handle<Code> CompileStoreMegamorphic(Code::Flags flags); | 318 Handle<Code> CompileStoreMegamorphic(Code::Flags flags); |
394 | 319 |
395 #ifdef ENABLE_DEBUGGER_SUPPORT | |
396 Handle<Code> CompileCallDebugBreak(Code::Flags flags); | |
397 Handle<Code> CompileCallDebugPrepareStepIn(Code::Flags flags); | |
398 #endif | |
399 | |
400 // Static functions for generating parts of stubs. | 320 // Static functions for generating parts of stubs. |
401 static void GenerateLoadGlobalFunctionPrototype(MacroAssembler* masm, | 321 static void GenerateLoadGlobalFunctionPrototype(MacroAssembler* masm, |
402 int index, | 322 int index, |
403 Register prototype); | 323 Register prototype); |
404 | 324 |
405 // Helper function used to check that the dictionary doesn't contain | 325 // Helper function used to check that the dictionary doesn't contain |
406 // the property. This function may return false negatives, so miss_label | 326 // the property. This function may return false negatives, so miss_label |
407 // must always call a backup property check that is complete. | 327 // must always call a backup property check that is complete. |
408 // This function is safe to call if the receiver has fast properties. | 328 // This function is safe to call if the receiver has fast properties. |
409 // Name must be unique and receiver must be a heap object. | 329 // Name must be unique and receiver must be a heap object. |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
861 } | 781 } |
862 | 782 |
863 Register transition_map() { | 783 Register transition_map() { |
864 return registers()[3]; | 784 return registers()[3]; |
865 } | 785 } |
866 | 786 |
867 friend class BaseLoadStoreStubCompiler; | 787 friend class BaseLoadStoreStubCompiler; |
868 }; | 788 }; |
869 | 789 |
870 | 790 |
871 class CallStubCompiler: public StubCompiler { | |
872 public: | |
873 CallStubCompiler(Isolate* isolate, | |
874 int argc, | |
875 Code::Kind kind, | |
876 ExtraICState extra_state, | |
877 InlineCacheHolderFlag cache_holder = OWN_MAP); | |
878 | |
879 Handle<Code> CompileCallField(Handle<JSObject> object, | |
880 Handle<JSObject> holder, | |
881 PropertyIndex index, | |
882 Handle<Name> name); | |
883 | |
884 // Patch the implicit receiver over the global object if the global object is | |
885 // the receiver. | |
886 void PatchImplicitReceiver(Handle<Object> object); | |
887 | |
888 // Returns the register containing the holder of |name|. | |
889 Register HandlerFrontendHeader(Handle<Object> object, | |
890 Handle<JSObject> holder, | |
891 Handle<Name> name, | |
892 CheckType check, | |
893 Label* miss); | |
894 void HandlerFrontendFooter(Label* miss); | |
895 | |
896 void GenerateJumpFunctionIgnoreReceiver(Handle<JSFunction> function); | |
897 void GenerateJumpFunction(Handle<Object> object, | |
898 Handle<JSFunction> function); | |
899 void GenerateJumpFunction(Handle<Object> object, | |
900 Register function, | |
901 Label* miss); | |
902 // Use to call |actual_closure|, a closure with the same shared function info | |
903 // as |function|. | |
904 void GenerateJumpFunction(Handle<Object> object, | |
905 Register actual_closure, | |
906 Handle<JSFunction> function); | |
907 | |
908 Handle<Code> CompileCallConstant(Handle<Object> object, | |
909 Handle<JSObject> holder, | |
910 Handle<Name> name, | |
911 CheckType check, | |
912 Handle<JSFunction> function); | |
913 | |
914 Handle<Code> CompileCallInterceptor(Handle<JSObject> object, | |
915 Handle<JSObject> holder, | |
916 Handle<Name> name); | |
917 | |
918 Handle<Code> CompileCallGlobal(Handle<JSObject> object, | |
919 Handle<GlobalObject> holder, | |
920 Handle<PropertyCell> cell, | |
921 Handle<JSFunction> function, | |
922 Handle<Name> name); | |
923 | |
924 private: | |
925 Handle<Code> GetCode(Code::StubType type, Handle<Name> name); | |
926 Handle<Code> GetCode(Handle<JSFunction> function); | |
927 | |
928 const ParameterCount& arguments() { return arguments_; } | |
929 | |
930 void GenerateNameCheck(Handle<Name> name, Label* miss); | |
931 | |
932 // Generates code to load the function from the cell checking that | |
933 // it still contains the same function. | |
934 void GenerateLoadFunctionFromCell(Handle<Cell> cell, | |
935 Handle<JSFunction> function, | |
936 Label* miss); | |
937 | |
938 void GenerateFunctionCheck(Register function, Register scratch, Label* miss); | |
939 | |
940 // Generates a jump to CallIC miss stub. | |
941 void GenerateMissBranch(); | |
942 | |
943 const ParameterCount arguments_; | |
944 const Code::Kind kind_; | |
945 const InlineCacheHolderFlag cache_holder_; | |
946 }; | |
947 | |
948 | |
949 // Holds information about possible function call optimizations. | 791 // Holds information about possible function call optimizations. |
950 class CallOptimization BASE_EMBEDDED { | 792 class CallOptimization BASE_EMBEDDED { |
951 public: | 793 public: |
952 explicit CallOptimization(LookupResult* lookup); | 794 explicit CallOptimization(LookupResult* lookup); |
953 | 795 |
954 explicit CallOptimization(Handle<JSFunction> function); | 796 explicit CallOptimization(Handle<JSFunction> function); |
955 | 797 |
956 bool is_constant_call() const { | 798 bool is_constant_call() const { |
957 return !constant_function_.is_null(); | 799 return !constant_function_.is_null(); |
958 } | 800 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1001 Handle<JSFunction> constant_function_; | 843 Handle<JSFunction> constant_function_; |
1002 bool is_simple_api_call_; | 844 bool is_simple_api_call_; |
1003 Handle<FunctionTemplateInfo> expected_receiver_type_; | 845 Handle<FunctionTemplateInfo> expected_receiver_type_; |
1004 Handle<CallHandlerInfo> api_call_info_; | 846 Handle<CallHandlerInfo> api_call_info_; |
1005 }; | 847 }; |
1006 | 848 |
1007 | 849 |
1008 } } // namespace v8::internal | 850 } } // namespace v8::internal |
1009 | 851 |
1010 #endif // V8_STUB_CACHE_H_ | 852 #endif // V8_STUB_CACHE_H_ |
OLD | NEW |