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

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

Powered by Google App Engine
This is Rietveld 408576698