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

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

Issue 8068026: Begin to handlify the stub cache. (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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 65
66 class StubCache { 66 class StubCache {
67 public: 67 public:
68 struct Entry { 68 struct Entry {
69 String* key; 69 String* key;
70 Code* value; 70 Code* value;
71 }; 71 };
72 72
73 void Initialize(bool create_heap_objects); 73 void Initialize(bool create_heap_objects);
74 74
75 Handle<Code> ComputeLoadNonexistent(Handle<String> name,
76 Handle<JSObject> receiver);
75 77
76 // Computes the right stub matching. Inserts the result in the 78 Handle<Code> ComputeLoadField(Handle<String> name,
77 // cache before returning. This might compile a stub if needed. 79 Handle<JSObject> receiver,
78 MUST_USE_RESULT MaybeObject* ComputeLoadNonexistent( 80 Handle<JSObject> holder,
79 String* name, 81 int field_index);
80 JSObject* receiver);
81 82
82 MUST_USE_RESULT MaybeObject* ComputeLoadField(String* name, 83 Handle<Code> ComputeLoadCallback(Handle<String> name,
83 JSObject* receiver, 84 Handle<JSObject> receiver,
84 JSObject* holder, 85 Handle<JSObject> holder,
85 int field_index); 86 Handle<AccessorInfo> callback);
86 87
87 MUST_USE_RESULT MaybeObject* ComputeLoadCallback( 88 Handle<Code> ComputeLoadConstant(Handle<String> name,
88 String* name, 89 Handle<JSObject> receiver,
89 JSObject* receiver, 90 Handle<JSObject> holder,
90 JSObject* holder, 91 Handle<Object> value);
91 AccessorInfo* callback);
92 92
93 MUST_USE_RESULT MaybeObject* ComputeLoadConstant(String* name, 93 Handle<Code> ComputeLoadInterceptor(Handle<String> name,
94 JSObject* receiver, 94 Handle<JSObject> receiver,
95 JSObject* holder, 95 Handle<JSObject> holder);
96 Object* value);
97 96
98 MUST_USE_RESULT MaybeObject* ComputeLoadInterceptor( 97 Handle<Code> ComputeLoadNormal();
99 String* name,
100 JSObject* receiver,
101 JSObject* holder);
102 98
103 MUST_USE_RESULT MaybeObject* ComputeLoadNormal(); 99 Handle<Code> ComputeLoadGlobal(Handle<String> name,
104 100 Handle<JSObject> receiver,
105 101 Handle<GlobalObject> holder,
106 MUST_USE_RESULT MaybeObject* ComputeLoadGlobal( 102 Handle<JSGlobalPropertyCell> cell,
107 String* name, 103 bool is_dont_delete);
108 JSObject* receiver,
109 GlobalObject* holder,
110 JSGlobalPropertyCell* cell,
111 bool is_dont_delete);
112 104
113 105
114 // --- 106 // ---
115 107
116 MUST_USE_RESULT MaybeObject* ComputeKeyedLoadField(String* name, 108 MUST_USE_RESULT MaybeObject* ComputeKeyedLoadField(String* name,
117 JSObject* receiver, 109 JSObject* receiver,
118 JSObject* holder, 110 JSObject* holder,
119 int field_index); 111 int field_index);
120 112
121 MUST_USE_RESULT MaybeObject* ComputeKeyedLoadCallback( 113 MUST_USE_RESULT MaybeObject* ComputeKeyedLoadCallback(
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 switch (table) { 314 switch (table) {
323 case StubCache::kPrimary: return StubCache::primary_; 315 case StubCache::kPrimary: return StubCache::primary_;
324 case StubCache::kSecondary: return StubCache::secondary_; 316 case StubCache::kSecondary: return StubCache::secondary_;
325 } 317 }
326 UNREACHABLE(); 318 UNREACHABLE();
327 return NULL; 319 return NULL;
328 } 320 }
329 321
330 Isolate* isolate() { return isolate_; } 322 Isolate* isolate() { return isolate_; }
331 Heap* heap() { return isolate()->heap(); } 323 Heap* heap() { return isolate()->heap(); }
324 Factory* factory() { return isolate()->factory(); }
332 325
333 private: 326 private:
334 explicit StubCache(Isolate* isolate); 327 explicit StubCache(Isolate* isolate);
335 328
336 friend class Isolate; 329 friend class Isolate;
337 friend class SCTableReference; 330 friend class SCTableReference;
338 static const int kPrimaryTableSize = 2048; 331 static const int kPrimaryTableSize = 2048;
339 static const int kSecondaryTableSize = 512; 332 static const int kSecondaryTableSize = 512;
340 Entry primary_[kPrimaryTableSize]; 333 Entry primary_[kPrimaryTableSize];
341 Entry secondary_[kSecondaryTableSize]; 334 Entry secondary_[kSecondaryTableSize];
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 DECLARE_RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorForLoad); 395 DECLARE_RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorForLoad);
403 DECLARE_RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorForCall); 396 DECLARE_RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorForCall);
404 DECLARE_RUNTIME_FUNCTION(MaybeObject*, StoreInterceptorProperty); 397 DECLARE_RUNTIME_FUNCTION(MaybeObject*, StoreInterceptorProperty);
405 DECLARE_RUNTIME_FUNCTION(MaybeObject*, CallInterceptorProperty); 398 DECLARE_RUNTIME_FUNCTION(MaybeObject*, CallInterceptorProperty);
406 DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedLoadPropertyWithInterceptor); 399 DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedLoadPropertyWithInterceptor);
407 400
408 401
409 // The stub compiler compiles stubs for the stub cache. 402 // The stub compiler compiles stubs for the stub cache.
410 class StubCompiler BASE_EMBEDDED { 403 class StubCompiler BASE_EMBEDDED {
411 public: 404 public:
412 StubCompiler() 405 explicit StubCompiler(Isolate* isolate)
413 : scope_(), masm_(Isolate::Current(), NULL, 256), failure_(NULL) { } 406 : isolate_(isolate), masm_(isolate, NULL, 256), failure_(NULL) { }
414 407
415 MUST_USE_RESULT MaybeObject* CompileCallInitialize(Code::Flags flags); 408 MUST_USE_RESULT MaybeObject* CompileCallInitialize(Code::Flags flags);
416 MUST_USE_RESULT MaybeObject* CompileCallPreMonomorphic(Code::Flags flags); 409 MUST_USE_RESULT MaybeObject* CompileCallPreMonomorphic(Code::Flags flags);
417 MUST_USE_RESULT MaybeObject* CompileCallNormal(Code::Flags flags); 410 MUST_USE_RESULT MaybeObject* CompileCallNormal(Code::Flags flags);
418 MUST_USE_RESULT MaybeObject* CompileCallMegamorphic(Code::Flags flags); 411 MUST_USE_RESULT MaybeObject* CompileCallMegamorphic(Code::Flags flags);
419 MUST_USE_RESULT MaybeObject* CompileCallArguments(Code::Flags flags); 412 MUST_USE_RESULT MaybeObject* CompileCallArguments(Code::Flags flags);
420 MUST_USE_RESULT MaybeObject* CompileCallMiss(Code::Flags flags); 413 MUST_USE_RESULT MaybeObject* CompileCallMiss(Code::Flags flags);
421 #ifdef ENABLE_DEBUGGER_SUPPORT 414 #ifdef ENABLE_DEBUGGER_SUPPORT
422 MUST_USE_RESULT MaybeObject* CompileCallDebugBreak(Code::Flags flags); 415 MUST_USE_RESULT MaybeObject* CompileCallDebugBreak(Code::Flags flags);
423 MUST_USE_RESULT MaybeObject* CompileCallDebugPrepareStepIn(Code::Flags flags); 416 MUST_USE_RESULT MaybeObject* CompileCallDebugPrepareStepIn(Code::Flags flags);
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 Register scratch1, 552 Register scratch1,
560 Register scratch2, 553 Register scratch2,
561 Register scratch3, 554 Register scratch3,
562 String* name, 555 String* name,
563 Label* miss); 556 Label* miss);
564 557
565 static void LookupPostInterceptor(JSObject* holder, 558 static void LookupPostInterceptor(JSObject* holder,
566 String* name, 559 String* name,
567 LookupResult* lookup); 560 LookupResult* lookup);
568 561
569 Isolate* isolate() { return scope_.isolate(); } 562 Isolate* isolate() { return isolate_; }
570 Heap* heap() { return isolate()->heap(); } 563 Heap* heap() { return isolate()->heap(); }
571 Factory* factory() { return isolate()->factory(); } 564 Factory* factory() { return isolate()->factory(); }
572 565
573 private: 566 private:
574 HandleScope scope_; 567 Isolate* isolate_;
575 MacroAssembler masm_; 568 MacroAssembler masm_;
576 Failure* failure_; 569 Failure* failure_;
577 }; 570 };
578 571
579 572
580 class LoadStubCompiler: public StubCompiler { 573 class LoadStubCompiler: public StubCompiler {
581 public: 574 public:
575 explicit LoadStubCompiler(Isolate* isolate) : StubCompiler(isolate) { }
576
582 MUST_USE_RESULT MaybeObject* CompileLoadNonexistent(String* name, 577 MUST_USE_RESULT MaybeObject* CompileLoadNonexistent(String* name,
583 JSObject* object, 578 JSObject* object,
584 JSObject* last); 579 JSObject* last);
585 580
586 MUST_USE_RESULT MaybeObject* CompileLoadField(JSObject* object, 581 MUST_USE_RESULT MaybeObject* CompileLoadField(JSObject* object,
587 JSObject* holder, 582 JSObject* holder,
588 int index, 583 int index,
589 String* name); 584 String* name);
590 585
591 MUST_USE_RESULT MaybeObject* CompileLoadCallback(String* name, 586 MUST_USE_RESULT MaybeObject* CompileLoadCallback(String* name,
(...skipping 16 matching lines...) Expand all
608 String* name, 603 String* name,
609 bool is_dont_delete); 604 bool is_dont_delete);
610 605
611 private: 606 private:
612 MUST_USE_RESULT MaybeObject* GetCode(PropertyType type, String* name); 607 MUST_USE_RESULT MaybeObject* GetCode(PropertyType type, String* name);
613 }; 608 };
614 609
615 610
616 class KeyedLoadStubCompiler: public StubCompiler { 611 class KeyedLoadStubCompiler: public StubCompiler {
617 public: 612 public:
613 explicit KeyedLoadStubCompiler(Isolate* isolate) : StubCompiler(isolate) { }
614
618 MUST_USE_RESULT MaybeObject* CompileLoadField(String* name, 615 MUST_USE_RESULT MaybeObject* CompileLoadField(String* name,
619 JSObject* object, 616 JSObject* object,
620 JSObject* holder, 617 JSObject* holder,
621 int index); 618 int index);
622 619
623 MUST_USE_RESULT MaybeObject* CompileLoadCallback(String* name, 620 MUST_USE_RESULT MaybeObject* CompileLoadCallback(String* name,
624 JSObject* object, 621 JSObject* object,
625 JSObject* holder, 622 JSObject* holder,
626 AccessorInfo* callback); 623 AccessorInfo* callback);
627 624
(...skipping 27 matching lines...) Expand all
655 652
656 private: 653 private:
657 MaybeObject* GetCode(PropertyType type, 654 MaybeObject* GetCode(PropertyType type,
658 String* name, 655 String* name,
659 InlineCacheState state = MONOMORPHIC); 656 InlineCacheState state = MONOMORPHIC);
660 }; 657 };
661 658
662 659
663 class StoreStubCompiler: public StubCompiler { 660 class StoreStubCompiler: public StubCompiler {
664 public: 661 public:
665 explicit StoreStubCompiler(StrictModeFlag strict_mode) 662 StoreStubCompiler(Isolate* isolate, StrictModeFlag strict_mode)
666 : strict_mode_(strict_mode) { } 663 : StubCompiler(isolate), strict_mode_(strict_mode) { }
667 664
668 MUST_USE_RESULT MaybeObject* CompileStoreField(JSObject* object, 665 MUST_USE_RESULT MaybeObject* CompileStoreField(JSObject* object,
669 int index, 666 int index,
670 Map* transition, 667 Map* transition,
671 String* name); 668 String* name);
672 669
673 MUST_USE_RESULT MaybeObject* CompileStoreCallback(JSObject* object, 670 MUST_USE_RESULT MaybeObject* CompileStoreCallback(JSObject* object,
674 AccessorInfo* callbacks, 671 AccessorInfo* callbacks,
675 String* name); 672 String* name);
676 MUST_USE_RESULT MaybeObject* CompileStoreInterceptor(JSObject* object, 673 MUST_USE_RESULT MaybeObject* CompileStoreInterceptor(JSObject* object,
677 String* name); 674 String* name);
678 MUST_USE_RESULT MaybeObject* CompileStoreGlobal(GlobalObject* object, 675 MUST_USE_RESULT MaybeObject* CompileStoreGlobal(GlobalObject* object,
679 JSGlobalPropertyCell* holder, 676 JSGlobalPropertyCell* holder,
680 String* name); 677 String* name);
681 678
682 679
683 private: 680 private:
684 MaybeObject* GetCode(PropertyType type, String* name); 681 MaybeObject* GetCode(PropertyType type, String* name);
685 682
686 StrictModeFlag strict_mode_; 683 StrictModeFlag strict_mode_;
687 }; 684 };
688 685
689 686
690 class KeyedStoreStubCompiler: public StubCompiler { 687 class KeyedStoreStubCompiler: public StubCompiler {
691 public: 688 public:
692 explicit KeyedStoreStubCompiler(StrictModeFlag strict_mode) 689 KeyedStoreStubCompiler(Isolate* isolate, StrictModeFlag strict_mode)
693 : strict_mode_(strict_mode) { } 690 : StubCompiler(isolate), strict_mode_(strict_mode) { }
694 691
695 MUST_USE_RESULT MaybeObject* CompileStoreField(JSObject* object, 692 MUST_USE_RESULT MaybeObject* CompileStoreField(JSObject* object,
696 int index, 693 int index,
697 Map* transition, 694 Map* transition,
698 String* name); 695 String* name);
699 696
700 MUST_USE_RESULT MaybeObject* CompileStoreElement(Map* receiver_map); 697 MUST_USE_RESULT MaybeObject* CompileStoreElement(Map* receiver_map);
701 698
702 MUST_USE_RESULT MaybeObject* CompileStoreMegamorphic( 699 MUST_USE_RESULT MaybeObject* CompileStoreMegamorphic(
703 MapList* receiver_maps, 700 MapList* receiver_maps,
(...skipping 29 matching lines...) Expand all
733 V(StringCharAt) \ 730 V(StringCharAt) \
734 V(StringFromCharCode) \ 731 V(StringFromCharCode) \
735 V(MathFloor) \ 732 V(MathFloor) \
736 V(MathAbs) 733 V(MathAbs)
737 734
738 735
739 class CallOptimization; 736 class CallOptimization;
740 737
741 class CallStubCompiler: public StubCompiler { 738 class CallStubCompiler: public StubCompiler {
742 public: 739 public:
743 CallStubCompiler(int argc, 740 CallStubCompiler(Isolate* isolate,
741 int argc,
744 Code::Kind kind, 742 Code::Kind kind,
745 Code::ExtraICState extra_ic_state, 743 Code::ExtraICState extra_ic_state,
746 InlineCacheHolderFlag cache_holder); 744 InlineCacheHolderFlag cache_holder);
747 745
748 MUST_USE_RESULT MaybeObject* CompileCallField( 746 MUST_USE_RESULT MaybeObject* CompileCallField(
749 JSObject* object, 747 JSObject* object,
750 JSObject* holder, 748 JSObject* holder,
751 int index, 749 int index,
752 String* name); 750 String* name);
753 751
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 Label* miss); 824 Label* miss);
827 825
828 // Generates a jump to CallIC miss stub. Returns Failure if the jump cannot 826 // Generates a jump to CallIC miss stub. Returns Failure if the jump cannot
829 // be generated. 827 // be generated.
830 MUST_USE_RESULT MaybeObject* GenerateMissBranch(); 828 MUST_USE_RESULT MaybeObject* GenerateMissBranch();
831 }; 829 };
832 830
833 831
834 class ConstructStubCompiler: public StubCompiler { 832 class ConstructStubCompiler: public StubCompiler {
835 public: 833 public:
836 explicit ConstructStubCompiler() {} 834 explicit ConstructStubCompiler(Isolate* isolate) : StubCompiler(isolate) { }
837 835
838 MUST_USE_RESULT MaybeObject* CompileConstructStub(JSFunction* function); 836 MUST_USE_RESULT MaybeObject* CompileConstructStub(JSFunction* function);
839 837
840 private: 838 private:
841 MaybeObject* GetCode(); 839 MaybeObject* GetCode();
842 }; 840 };
843 841
844 842
845 // Holds information about possible function call optimizations. 843 // Holds information about possible function call optimizations.
846 class CallOptimization BASE_EMBEDDED { 844 class CallOptimization BASE_EMBEDDED {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 JSFunction* constant_function_; 885 JSFunction* constant_function_;
888 bool is_simple_api_call_; 886 bool is_simple_api_call_;
889 FunctionTemplateInfo* expected_receiver_type_; 887 FunctionTemplateInfo* expected_receiver_type_;
890 CallHandlerInfo* api_call_info_; 888 CallHandlerInfo* api_call_info_;
891 }; 889 };
892 890
893 891
894 } } // namespace v8::internal 892 } } // namespace v8::internal
895 893
896 #endif // V8_STUB_CACHE_H_ 894 #endif // V8_STUB_CACHE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698