Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: src/stub-cache.h

Issue 155723005: A64: Synchronize with r19001. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/string.js ('k') | src/stub-cache.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
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 static bool HasCustomCallGenerator(Handle<JSFunction> function);
925
926 private:
927 // Compiles a custom call constant/global IC. For constant calls cell is
928 // NULL. Returns an empty handle if there is no custom call code for the
929 // given function.
930 Handle<Code> CompileCustomCall(Handle<Object> object,
931 Handle<JSObject> holder,
932 Handle<Cell> cell,
933 Handle<JSFunction> function,
934 Handle<String> name,
935 Code::StubType type);
936
937 Handle<Code> CompileFastApiCall(const CallOptimization& optimization,
938 Handle<Object> object,
939 Handle<JSObject> holder,
940 Handle<Cell> cell,
941 Handle<JSFunction> function,
942 Handle<String> name);
943
944 Handle<Code> GetCode(Code::StubType type, Handle<Name> name);
945 Handle<Code> GetCode(Handle<JSFunction> function);
946
947 const ParameterCount& arguments() { return arguments_; }
948
949 void GenerateNameCheck(Handle<Name> name, Label* miss);
950
951 // Generates code to load the function from the cell checking that
952 // it still contains the same function.
953 void GenerateLoadFunctionFromCell(Handle<Cell> cell,
954 Handle<JSFunction> function,
955 Label* miss);
956
957 void GenerateFunctionCheck(Register function, Register scratch, Label* miss);
958
959 // Generates a jump to CallIC miss stub.
960 void GenerateMissBranch();
961
962 const ParameterCount arguments_;
963 const Code::Kind kind_;
964 const InlineCacheHolderFlag cache_holder_;
965 };
966
967
968 // Holds information about possible function call optimizations. 791 // Holds information about possible function call optimizations.
969 class CallOptimization BASE_EMBEDDED { 792 class CallOptimization BASE_EMBEDDED {
970 public: 793 public:
971 explicit CallOptimization(LookupResult* lookup); 794 explicit CallOptimization(LookupResult* lookup);
972 795
973 explicit CallOptimization(Handle<JSFunction> function); 796 explicit CallOptimization(Handle<JSFunction> function);
974 797
975 bool is_constant_call() const { 798 bool is_constant_call() const {
976 return !constant_function_.is_null(); 799 return !constant_function_.is_null();
977 } 800 }
(...skipping 13 matching lines...) Expand all
991 } 814 }
992 815
993 Handle<CallHandlerInfo> api_call_info() const { 816 Handle<CallHandlerInfo> api_call_info() const {
994 ASSERT(is_simple_api_call()); 817 ASSERT(is_simple_api_call());
995 return api_call_info_; 818 return api_call_info_;
996 } 819 }
997 820
998 enum HolderLookup { 821 enum HolderLookup {
999 kHolderNotFound, 822 kHolderNotFound,
1000 kHolderIsReceiver, 823 kHolderIsReceiver,
1001 kHolderIsPrototypeOfMap 824 kHolderFound
1002 }; 825 };
1003 // Returns a map whose prototype has the expected type in the 826 Handle<JSObject> LookupHolderOfExpectedType(
1004 // prototype chain between the two arguments 827 Handle<Map> receiver_map,
1005 // null will be returned if the first argument has that property 828 HolderLookup* holder_lookup) const;
1006 // lookup will be set accordingly
1007 Handle<Map> LookupHolderOfExpectedType(Handle<JSObject> receiver,
1008 Handle<JSObject> object,
1009 Handle<JSObject> holder,
1010 HolderLookup* holder_lookup) const;
1011 829
1012 bool IsCompatibleReceiver(Object* receiver) { 830 bool IsCompatibleReceiver(Object* receiver) {
1013 ASSERT(is_simple_api_call()); 831 ASSERT(is_simple_api_call());
1014 if (expected_receiver_type_.is_null()) return true; 832 if (expected_receiver_type_.is_null()) return true;
1015 return expected_receiver_type_->IsTemplateFor(receiver); 833 return expected_receiver_type_->IsTemplateFor(receiver);
1016 } 834 }
1017 835
1018 private: 836 private:
1019 void Initialize(Handle<JSFunction> function); 837 void Initialize(Handle<JSFunction> function);
1020 838
1021 // Determines whether the given function can be called using the 839 // Determines whether the given function can be called using the
1022 // fast api call builtin. 840 // fast api call builtin.
1023 void AnalyzePossibleApiFunction(Handle<JSFunction> function); 841 void AnalyzePossibleApiFunction(Handle<JSFunction> function);
1024 842
1025 Handle<JSFunction> constant_function_; 843 Handle<JSFunction> constant_function_;
1026 bool is_simple_api_call_; 844 bool is_simple_api_call_;
1027 Handle<FunctionTemplateInfo> expected_receiver_type_; 845 Handle<FunctionTemplateInfo> expected_receiver_type_;
1028 Handle<CallHandlerInfo> api_call_info_; 846 Handle<CallHandlerInfo> api_call_info_;
1029 }; 847 };
1030 848
1031 849
1032 } } // namespace v8::internal 850 } } // namespace v8::internal
1033 851
1034 #endif // V8_STUB_CACHE_H_ 852 #endif // V8_STUB_CACHE_H_
OLDNEW
« no previous file with comments | « src/string.js ('k') | src/stub-cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698