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

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

Issue 8357010: Handlify the stub cache lookup and patching for CallIC and KeyedCallIC. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Do not assume functions are compiled when specializing. Created 9 years, 2 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/objects.cc ('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 2011 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
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 Map* transition, 169 Map* transition,
170 StrictModeFlag strict_mode); 170 StrictModeFlag strict_mode);
171 171
172 MUST_USE_RESULT MaybeObject* ComputeKeyedLoadOrStoreElement( 172 MUST_USE_RESULT MaybeObject* ComputeKeyedLoadOrStoreElement(
173 JSObject* receiver, 173 JSObject* receiver,
174 KeyedIC::StubKind stub_kind, 174 KeyedIC::StubKind stub_kind,
175 StrictModeFlag strict_mode); 175 StrictModeFlag strict_mode);
176 176
177 // --- 177 // ---
178 178
179 MUST_USE_RESULT MaybeObject* ComputeCallField( 179 Handle<Code> ComputeCallField(int argc,
180 int argc, 180 Code::Kind,
181 Code::Kind, 181 Code::ExtraICState extra_state,
182 Code::ExtraICState extra_ic_state, 182 Handle<String> name,
183 String* name, 183 Handle<Object> object,
184 Object* object, 184 Handle<JSObject> holder,
185 JSObject* holder, 185 int index);
186 int index);
187 186
188 MUST_USE_RESULT MaybeObject* ComputeCallConstant( 187 Handle<Code> ComputeCallConstant(int argc,
189 int argc, 188 Code::Kind,
190 Code::Kind, 189 Code::ExtraICState extra_state,
191 Code::ExtraICState extra_ic_state, 190 Handle<String> name,
192 String* name, 191 Handle<Object> object,
193 Object* object, 192 Handle<JSObject> holder,
194 JSObject* holder, 193 Handle<JSFunction> function);
195 JSFunction* function);
196 194
197 MUST_USE_RESULT MaybeObject* ComputeCallNormal( 195 Handle<Code> ComputeCallInterceptor(int argc,
198 int argc, 196 Code::Kind,
199 Code::Kind, 197 Code::ExtraICState extra_state,
200 Code::ExtraICState extra_ic_state, 198 Handle<String> name,
201 String* name, 199 Handle<Object> object,
202 JSObject* receiver); 200 Handle<JSObject> holder);
203 201
204 MUST_USE_RESULT MaybeObject* ComputeCallInterceptor( 202 Handle<Code> ComputeCallGlobal(int argc,
205 int argc, 203 Code::Kind,
206 Code::Kind, 204 Code::ExtraICState extra_state,
207 Code::ExtraICState extra_ic_state, 205 Handle<String> name,
208 String* name, 206 Handle<JSObject> receiver,
209 Object* object, 207 Handle<GlobalObject> holder,
210 JSObject* holder); 208 Handle<JSGlobalPropertyCell> cell,
211 209 Handle<JSFunction> function);
212 MUST_USE_RESULT MaybeObject* ComputeCallGlobal(
213 int argc,
214 Code::Kind,
215 Code::ExtraICState extra_ic_state,
216 String* name,
217 JSObject* receiver,
218 GlobalObject* holder,
219 JSGlobalPropertyCell* cell,
220 JSFunction* function);
221 210
222 // --- 211 // ---
223 212
224 MUST_USE_RESULT MaybeObject* ComputeCallInitialize(int argc, 213 Handle<Code> ComputeCallInitialize(int argc, RelocInfo::Mode mode);
225 RelocInfo::Mode mode,
226 Code::Kind kind);
227
228 Handle<Code> ComputeCallInitialize(int argc,
229 RelocInfo::Mode mode);
230 214
231 Handle<Code> ComputeKeyedCallInitialize(int argc); 215 Handle<Code> ComputeKeyedCallInitialize(int argc);
232 216
233 MUST_USE_RESULT MaybeObject* ComputeCallPreMonomorphic( 217 Handle<Code> ComputeCallPreMonomorphic(int argc,
234 int argc, 218 Code::Kind kind,
235 Code::Kind kind, 219 Code::ExtraICState extra_state);
236 Code::ExtraICState extra_ic_state);
237 220
238 MUST_USE_RESULT MaybeObject* ComputeCallNormal(int argc, 221 Handle<Code> ComputeCallNormal(int argc,
239 Code::Kind kind, 222 Code::Kind kind,
240 Code::ExtraICState state); 223 Code::ExtraICState state);
241 224
242 MUST_USE_RESULT MaybeObject* ComputeCallArguments(int argc, 225 Handle<Code> ComputeCallArguments(int argc, Code::Kind kind);
243 Code::Kind kind);
244 226
245 MUST_USE_RESULT MaybeObject* ComputeCallMegamorphic(int argc, 227 Handle<Code> ComputeCallMegamorphic(int argc,
246 Code::Kind kind, 228 Code::Kind kind,
247 Code::ExtraICState state); 229 Code::ExtraICState state);
248 230
249 MUST_USE_RESULT MaybeObject* ComputeCallMiss(int argc, 231 Handle<Code> ComputeCallMiss(int argc,
250 Code::Kind kind, 232 Code::Kind kind,
251 Code::ExtraICState state); 233 Code::ExtraICState state);
234
235 MUST_USE_RESULT MaybeObject* TryComputeCallMiss(int argc,
236 Code::Kind kind,
237 Code::ExtraICState state);
252 238
253 // Finds the Code object stored in the Heap::non_monomorphic_cache(). 239 // Finds the Code object stored in the Heap::non_monomorphic_cache().
254 MUST_USE_RESULT Code* FindCallInitialize(int argc, 240 Code* FindCallInitialize(int argc, RelocInfo::Mode mode, Code::Kind kind);
255 RelocInfo::Mode mode,
256 Code::Kind kind);
257 241
258 #ifdef ENABLE_DEBUGGER_SUPPORT 242 #ifdef ENABLE_DEBUGGER_SUPPORT
259 MUST_USE_RESULT MaybeObject* ComputeCallDebugBreak(int argc, Code::Kind kind); 243 Handle<Code> ComputeCallDebugBreak(int argc, Code::Kind kind);
260 244
261 MUST_USE_RESULT MaybeObject* ComputeCallDebugPrepareStepIn(int argc, 245 Handle<Code> ComputeCallDebugPrepareStepIn(int argc, Code::Kind kind);
262 Code::Kind kind);
263 #endif 246 #endif
264 247
265 // Update cache for entry hash(name, map). 248 // Update cache for entry hash(name, map).
266 Code* Set(String* name, Map* map, Code* code); 249 Code* Set(String* name, Map* map, Code* code);
267 250
268 // Clear the lookup table (@ mark compact collection). 251 // Clear the lookup table (@ mark compact collection).
269 void Clear(); 252 void Clear();
270 253
271 // Collect all maps that match the name and flags. 254 // Collect all maps that match the name and flags.
272 void CollectMatchingMaps(SmallMapList* types, 255 void CollectMatchingMaps(SmallMapList* types,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 return NULL; 294 return NULL;
312 } 295 }
313 296
314 Isolate* isolate() { return isolate_; } 297 Isolate* isolate() { return isolate_; }
315 Heap* heap() { return isolate()->heap(); } 298 Heap* heap() { return isolate()->heap(); }
316 Factory* factory() { return isolate()->factory(); } 299 Factory* factory() { return isolate()->factory(); }
317 300
318 private: 301 private:
319 explicit StubCache(Isolate* isolate); 302 explicit StubCache(Isolate* isolate);
320 303
321 friend class Isolate; 304 Handle<Code> ComputeCallInitialize(int argc,
322 friend class SCTableReference; 305 RelocInfo::Mode mode,
323 static const int kPrimaryTableSize = 2048; 306 Code::Kind kind);
324 static const int kSecondaryTableSize = 512;
325 Entry primary_[kPrimaryTableSize];
326 Entry secondary_[kSecondaryTableSize];
327 307
328 // Computes the hashed offsets for primary and secondary caches. 308 // Computes the hashed offsets for primary and secondary caches.
329 static int PrimaryOffset(String* name, Code::Flags flags, Map* map) { 309 static int PrimaryOffset(String* name, Code::Flags flags, Map* map) {
330 // This works well because the heap object tag size and the hash 310 // This works well because the heap object tag size and the hash
331 // shift are equal. Shifting down the length field to get the 311 // shift are equal. Shifting down the length field to get the
332 // hash code would effectively throw away two bits of the hash 312 // hash code would effectively throw away two bits of the hash
333 // code. 313 // code.
334 STATIC_ASSERT(kHeapObjectTagSize == String::kHashShift); 314 STATIC_ASSERT(kHeapObjectTagSize == String::kHashShift);
335 // Compute the hash of the name (use entire hash field). 315 // Compute the hash of the name (use entire hash field).
336 ASSERT(name->HasHashCode()); 316 ASSERT(name->HasHashCode());
(...skipping 24 matching lines...) Expand all
361 // we do in generated code. We generate an hash code that already 341 // we do in generated code. We generate an hash code that already
362 // ends in String::kHashShift 0s. Then we shift it so it is a multiple 342 // ends in String::kHashShift 0s. Then we shift it so it is a multiple
363 // of sizeof(Entry). This makes it easier to avoid making mistakes 343 // of sizeof(Entry). This makes it easier to avoid making mistakes
364 // in the hashed offset computations. 344 // in the hashed offset computations.
365 static Entry* entry(Entry* table, int offset) { 345 static Entry* entry(Entry* table, int offset) {
366 const int shift_amount = kPointerSizeLog2 + 1 - String::kHashShift; 346 const int shift_amount = kPointerSizeLog2 + 1 - String::kHashShift;
367 return reinterpret_cast<Entry*>( 347 return reinterpret_cast<Entry*>(
368 reinterpret_cast<Address>(table) + (offset << shift_amount)); 348 reinterpret_cast<Address>(table) + (offset << shift_amount));
369 } 349 }
370 350
351 static const int kPrimaryTableSize = 2048;
352 static const int kSecondaryTableSize = 512;
353
354 Entry primary_[kPrimaryTableSize];
355 Entry secondary_[kSecondaryTableSize];
371 Isolate* isolate_; 356 Isolate* isolate_;
372 357
358 friend class Isolate;
359 friend class SCTableReference;
360
373 DISALLOW_COPY_AND_ASSIGN(StubCache); 361 DISALLOW_COPY_AND_ASSIGN(StubCache);
374 }; 362 };
375 363
376 364
377 // ------------------------------------------------------------------------ 365 // ------------------------------------------------------------------------
378 366
379 367
380 // Support functions for IC stubs for callbacks. 368 // Support functions for IC stubs for callbacks.
381 DECLARE_RUNTIME_FUNCTION(MaybeObject*, LoadCallbackProperty); 369 DECLARE_RUNTIME_FUNCTION(MaybeObject*, LoadCallbackProperty);
382 DECLARE_RUNTIME_FUNCTION(MaybeObject*, StoreCallbackProperty); 370 DECLARE_RUNTIME_FUNCTION(MaybeObject*, StoreCallbackProperty);
383 371
384 372
385 // Support functions for IC stubs for interceptors. 373 // Support functions for IC stubs for interceptors.
386 DECLARE_RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorOnly); 374 DECLARE_RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorOnly);
387 DECLARE_RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorForLoad); 375 DECLARE_RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorForLoad);
388 DECLARE_RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorForCall); 376 DECLARE_RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorForCall);
389 DECLARE_RUNTIME_FUNCTION(MaybeObject*, StoreInterceptorProperty); 377 DECLARE_RUNTIME_FUNCTION(MaybeObject*, StoreInterceptorProperty);
390 DECLARE_RUNTIME_FUNCTION(MaybeObject*, CallInterceptorProperty); 378 DECLARE_RUNTIME_FUNCTION(MaybeObject*, CallInterceptorProperty);
391 DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedLoadPropertyWithInterceptor); 379 DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedLoadPropertyWithInterceptor);
392 380
393 381
394 // The stub compiler compiles stubs for the stub cache. 382 // The stub compiler compiles stubs for the stub cache.
395 class StubCompiler BASE_EMBEDDED { 383 class StubCompiler BASE_EMBEDDED {
396 public: 384 public:
397 explicit StubCompiler(Isolate* isolate) 385 explicit StubCompiler(Isolate* isolate)
398 : isolate_(isolate), masm_(isolate, NULL, 256), failure_(NULL) { } 386 : isolate_(isolate), masm_(isolate, NULL, 256), failure_(NULL) { }
399 387
400 MUST_USE_RESULT MaybeObject* CompileCallInitialize(Code::Flags flags); 388 Handle<Code> CompileCallInitialize(Code::Flags flags);
401 MUST_USE_RESULT MaybeObject* CompileCallPreMonomorphic(Code::Flags flags); 389 MUST_USE_RESULT MaybeObject* TryCompileCallInitialize(Code::Flags flags);
402 MUST_USE_RESULT MaybeObject* CompileCallNormal(Code::Flags flags); 390
403 MUST_USE_RESULT MaybeObject* CompileCallMegamorphic(Code::Flags flags); 391 Handle<Code> CompileCallPreMonomorphic(Code::Flags flags);
404 MUST_USE_RESULT MaybeObject* CompileCallArguments(Code::Flags flags); 392 MUST_USE_RESULT MaybeObject* TryCompileCallPreMonomorphic(Code::Flags flags);
405 MUST_USE_RESULT MaybeObject* CompileCallMiss(Code::Flags flags); 393
394 Handle<Code> CompileCallNormal(Code::Flags flags);
395 MUST_USE_RESULT MaybeObject* TryCompileCallNormal(Code::Flags flags);
396
397 Handle<Code> CompileCallMegamorphic(Code::Flags flags);
398 MUST_USE_RESULT MaybeObject* TryCompileCallMegamorphic(Code::Flags flags);
399
400 Handle<Code> CompileCallArguments(Code::Flags flags);
401 MUST_USE_RESULT MaybeObject* TryCompileCallArguments(Code::Flags flags);
402
403 Handle<Code> CompileCallMiss(Code::Flags flags);
404 MUST_USE_RESULT MaybeObject* TryCompileCallMiss(Code::Flags flags);
405
406 #ifdef ENABLE_DEBUGGER_SUPPORT 406 #ifdef ENABLE_DEBUGGER_SUPPORT
407 MUST_USE_RESULT MaybeObject* CompileCallDebugBreak(Code::Flags flags); 407 Handle<Code> CompileCallDebugBreak(Code::Flags flags);
408 MUST_USE_RESULT MaybeObject* CompileCallDebugPrepareStepIn(Code::Flags flags); 408 MUST_USE_RESULT MaybeObject* TryCompileCallDebugBreak(Code::Flags flags);
409
410 Handle<Code> CompileCallDebugPrepareStepIn(Code::Flags flags);
411 MUST_USE_RESULT MaybeObject* TryCompileCallDebugPrepareStepIn(
412 Code::Flags flags);
409 #endif 413 #endif
410 414
411 // Static functions for generating parts of stubs. 415 // Static functions for generating parts of stubs.
412 static void GenerateLoadGlobalFunctionPrototype(MacroAssembler* masm, 416 static void GenerateLoadGlobalFunctionPrototype(MacroAssembler* masm,
413 int index, 417 int index,
414 Register prototype); 418 Register prototype);
415 419
416 // Generates prototype loading code that uses the objects from the 420 // Generates prototype loading code that uses the objects from the
417 // context we were in when this function was called. If the context 421 // context we were in when this function was called. If the context
418 // has changed, a jump to miss is performed. This ties the generated 422 // has changed, a jump to miss is performed. This ties the generated
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 V(MathAbs) 804 V(MathAbs)
801 805
802 806
803 class CallOptimization; 807 class CallOptimization;
804 808
805 class CallStubCompiler: public StubCompiler { 809 class CallStubCompiler: public StubCompiler {
806 public: 810 public:
807 CallStubCompiler(Isolate* isolate, 811 CallStubCompiler(Isolate* isolate,
808 int argc, 812 int argc,
809 Code::Kind kind, 813 Code::Kind kind,
810 Code::ExtraICState extra_ic_state, 814 Code::ExtraICState extra_state,
811 InlineCacheHolderFlag cache_holder); 815 InlineCacheHolderFlag cache_holder);
812 816
813 MUST_USE_RESULT MaybeObject* CompileCallField( 817 Handle<Code> CompileCallField(Handle<JSObject> object,
814 JSObject* object, 818 Handle<JSObject> holder,
815 JSObject* holder, 819 int index,
816 int index, 820 Handle<String> name);
817 String* name);
818 821
819 MUST_USE_RESULT MaybeObject* CompileCallConstant( 822 MUST_USE_RESULT MaybeObject* CompileCallField(JSObject* object,
820 Object* object, 823 JSObject* holder,
821 JSObject* holder, 824 int index,
822 JSFunction* function, 825 String* name);
823 String* name,
824 CheckType check);
825 826
826 MUST_USE_RESULT MaybeObject* CompileCallInterceptor( 827 Handle<Code> CompileCallConstant(Handle<Object> object,
827 JSObject* object, 828 Handle<JSObject> holder,
828 JSObject* holder, 829 Handle<JSFunction> function,
829 String* name); 830 Handle<String> name,
831 CheckType check);
830 832
831 MUST_USE_RESULT MaybeObject* CompileCallGlobal( 833 MUST_USE_RESULT MaybeObject* CompileCallConstant(Object* object,
832 JSObject* object, 834 JSObject* holder,
833 GlobalObject* holder, 835 JSFunction* function,
834 JSGlobalPropertyCell* cell, 836 String* name,
835 JSFunction* function, 837 CheckType check);
836 String* name); 838
839 Handle<Code> CompileCallInterceptor(Handle<JSObject> object,
840 Handle<JSObject> holder,
841 Handle<String> name);
842
843 MUST_USE_RESULT MaybeObject* CompileCallInterceptor(JSObject* object,
844 JSObject* holder,
845 String* name);
846
847 Handle<Code> CompileCallGlobal(Handle<JSObject> object,
848 Handle<GlobalObject> holder,
849 Handle<JSGlobalPropertyCell> cell,
850 Handle<JSFunction> function,
851 Handle<String> name);
852
853 MUST_USE_RESULT MaybeObject* CompileCallGlobal(JSObject* object,
854 GlobalObject* holder,
855 JSGlobalPropertyCell* cell,
856 JSFunction* function,
857 String* name);
837 858
838 static bool HasCustomCallGenerator(JSFunction* function); 859 static bool HasCustomCallGenerator(JSFunction* function);
839 860
840 private: 861 private:
841 // Compiles a custom call constant/global IC. For constant calls 862 // Compiles a custom call constant/global IC. For constant calls
842 // cell is NULL. Returns undefined if there is no custom call code 863 // cell is NULL. Returns undefined if there is no custom call code
843 // for the given function or it can't be generated. 864 // for the given function or it can't be generated.
844 MUST_USE_RESULT MaybeObject* CompileCustomCall(Object* object, 865 MUST_USE_RESULT MaybeObject* CompileCustomCall(Object* object,
845 JSObject* holder, 866 JSObject* holder,
846 JSGlobalPropertyCell* cell, 867 JSGlobalPropertyCell* cell,
(...skipping 12 matching lines...) Expand all
859 MUST_USE_RESULT MaybeObject* CompileFastApiCall( 880 MUST_USE_RESULT MaybeObject* CompileFastApiCall(
860 const CallOptimization& optimization, 881 const CallOptimization& optimization,
861 Object* object, 882 Object* object,
862 JSObject* holder, 883 JSObject* holder,
863 JSGlobalPropertyCell* cell, 884 JSGlobalPropertyCell* cell,
864 JSFunction* function, 885 JSFunction* function,
865 String* name); 886 String* name);
866 887
867 const ParameterCount arguments_; 888 const ParameterCount arguments_;
868 const Code::Kind kind_; 889 const Code::Kind kind_;
869 const Code::ExtraICState extra_ic_state_; 890 const Code::ExtraICState extra_state_;
870 const InlineCacheHolderFlag cache_holder_; 891 const InlineCacheHolderFlag cache_holder_;
871 892
872 const ParameterCount& arguments() { return arguments_; } 893 const ParameterCount& arguments() { return arguments_; }
873 894
874 MUST_USE_RESULT MaybeObject* GetCode(PropertyType type, String* name); 895 MUST_USE_RESULT MaybeObject* GetCode(PropertyType type, String* name);
875 896
876 // Convenience function. Calls GetCode above passing 897 // Convenience function. Calls GetCode above passing
877 // CONSTANT_FUNCTION type and the name of the given function. 898 // CONSTANT_FUNCTION type and the name of the given function.
878 MUST_USE_RESULT MaybeObject* GetCode(JSFunction* function); 899 MUST_USE_RESULT MaybeObject* GetCode(JSFunction* function);
879 900
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
952 JSFunction* constant_function_; 973 JSFunction* constant_function_;
953 bool is_simple_api_call_; 974 bool is_simple_api_call_;
954 FunctionTemplateInfo* expected_receiver_type_; 975 FunctionTemplateInfo* expected_receiver_type_;
955 CallHandlerInfo* api_call_info_; 976 CallHandlerInfo* api_call_info_;
956 }; 977 };
957 978
958 979
959 } } // namespace v8::internal 980 } } // namespace v8::internal
960 981
961 #endif // V8_STUB_CACHE_H_ 982 #endif // V8_STUB_CACHE_H_
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | src/stub-cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698