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

Side by Side Diff: src/code-stubs.h

Issue 26968004: Turn Load/StoreGlobal into a handler. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 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/arm/stub-cache-arm.cc ('k') | src/ia32/stub-cache-ia32.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 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 545
546 void Generate(MacroAssembler* masm); 546 void Generate(MacroAssembler* masm);
547 547
548 private: 548 private:
549 int slots_; 549 int slots_;
550 550
551 Major MajorKey() { return FastNewBlockContext; } 551 Major MajorKey() { return FastNewBlockContext; }
552 int MinorKey() { return slots_; } 552 int MinorKey() { return slots_; }
553 }; 553 };
554 554
555 class StoreGlobalStub : public HydrogenCodeStub {
556 public:
557 StoreGlobalStub(StrictModeFlag strict_mode, bool is_constant) {
558 bit_field_ = StrictModeBits::encode(strict_mode) |
559 IsConstantBits::encode(is_constant);
560 }
561
562 virtual Handle<Code> GenerateCode(Isolate* isolate);
563
564 virtual void InitializeInterfaceDescriptor(
565 Isolate* isolate,
566 CodeStubInterfaceDescriptor* descriptor);
567
568 virtual Code::Kind GetCodeKind() const { return Code::STORE_IC; }
569 virtual InlineCacheState GetICState() { return MONOMORPHIC; }
570 virtual Code::ExtraICState GetExtraICState() { return bit_field_; }
571
572 bool is_constant() {
573 return IsConstantBits::decode(bit_field_);
574 }
575 void set_is_constant(bool value) {
576 bit_field_ = IsConstantBits::update(bit_field_, value);
577 }
578
579 Representation representation() {
580 return Representation::FromKind(RepresentationBits::decode(bit_field_));
581 }
582 void set_representation(Representation r) {
583 bit_field_ = RepresentationBits::update(bit_field_, r.kind());
584 }
585
586 private:
587 virtual int NotMissMinorKey() { return GetExtraICState(); }
588 Major MajorKey() { return StoreGlobal; }
589
590 class StrictModeBits: public BitField<StrictModeFlag, 0, 1> {};
591 class IsConstantBits: public BitField<bool, 1, 1> {};
592 class RepresentationBits: public BitField<Representation::Kind, 2, 8> {};
593
594 int bit_field_;
595
596 DISALLOW_COPY_AND_ASSIGN(StoreGlobalStub);
597 };
598
599
600 class FastCloneShallowArrayStub : public HydrogenCodeStub { 555 class FastCloneShallowArrayStub : public HydrogenCodeStub {
601 public: 556 public:
602 // Maximum length of copied elements array. 557 // Maximum length of copied elements array.
603 static const int kMaximumClonedLength = 8; 558 static const int kMaximumClonedLength = 8;
604 enum Mode { 559 enum Mode {
605 CLONE_ELEMENTS, 560 CLONE_ELEMENTS,
606 CLONE_DOUBLE_ELEMENTS, 561 CLONE_DOUBLE_ELEMENTS,
607 COPY_ON_WRITE_ELEMENTS, 562 COPY_ON_WRITE_ELEMENTS,
608 CLONE_ANY_ELEMENTS, 563 CLONE_ANY_ELEMENTS,
609 LAST_CLONE_MODE = CLONE_ANY_ELEMENTS 564 LAST_CLONE_MODE = CLONE_ANY_ELEMENTS
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 virtual CodeStub::Major MajorKey() { return StoreArrayLength; } 846 virtual CodeStub::Major MajorKey() { return StoreArrayLength; }
892 }; 847 };
893 848
894 849
895 class HICStub: public HydrogenCodeStub { 850 class HICStub: public HydrogenCodeStub {
896 public: 851 public:
897 virtual Code::Kind GetCodeKind() const { return kind(); } 852 virtual Code::Kind GetCodeKind() const { return kind(); }
898 virtual InlineCacheState GetICState() { return MONOMORPHIC; } 853 virtual InlineCacheState GetICState() { return MONOMORPHIC; }
899 854
900 protected: 855 protected:
901 HICStub() { }
902 class KindBits: public BitField<Code::Kind, 0, 4> {}; 856 class KindBits: public BitField<Code::Kind, 0, 4> {};
903 virtual Code::Kind kind() const = 0; 857 virtual Code::Kind kind() const = 0;
904 }; 858 };
905 859
906 860
907 class HandlerStub: public HICStub { 861 class HandlerStub: public HICStub {
908 public: 862 public:
909 virtual Code::Kind GetCodeKind() const { return Code::HANDLER; } 863 virtual Code::Kind GetCodeKind() const { return Code::HANDLER; }
910 virtual int GetStubFlags() { return kind(); } 864 virtual int GetStubFlags() { return kind(); }
911
912 protected:
913 HandlerStub() : HICStub() { }
914 }; 865 };
915 866
916 867
917 class LoadFieldStub: public HandlerStub { 868 class LoadFieldStub: public HandlerStub {
918 public: 869 public:
919 LoadFieldStub(bool inobject, int index, Representation representation) 870 LoadFieldStub(bool inobject, int index, Representation representation) {
920 : HandlerStub() {
921 Initialize(Code::LOAD_IC, inobject, index, representation); 871 Initialize(Code::LOAD_IC, inobject, index, representation);
922 } 872 }
923 873
924 virtual Handle<Code> GenerateCode(Isolate* isolate); 874 virtual Handle<Code> GenerateCode(Isolate* isolate);
925 875
926 virtual void InitializeInterfaceDescriptor( 876 virtual void InitializeInterfaceDescriptor(
927 Isolate* isolate, 877 Isolate* isolate,
928 CodeStubInterfaceDescriptor* descriptor); 878 CodeStubInterfaceDescriptor* descriptor);
929 879
930 Representation representation() { 880 Representation representation() {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 class InobjectBits: public BitField<bool, 4, 1> {}; 922 class InobjectBits: public BitField<bool, 4, 1> {};
973 class IndexBits: public BitField<int, 5, 11> {}; 923 class IndexBits: public BitField<int, 5, 11> {};
974 class UnboxedDoubleBits: public BitField<bool, 16, 1> {}; 924 class UnboxedDoubleBits: public BitField<bool, 16, 1> {};
975 virtual CodeStub::Major MajorKey() { return LoadField; } 925 virtual CodeStub::Major MajorKey() { return LoadField; }
976 virtual int NotMissMinorKey() { return bit_field_; } 926 virtual int NotMissMinorKey() { return bit_field_; }
977 927
978 int bit_field_; 928 int bit_field_;
979 }; 929 };
980 930
981 931
932 class StoreGlobalStub : public HandlerStub {
933 public:
934 StoreGlobalStub(StrictModeFlag strict_mode, bool is_constant) {
935 bit_field_ = StrictModeBits::encode(strict_mode) |
936 IsConstantBits::encode(is_constant);
937 }
938
939 Handle<Code> GetCodeCopyFromTemplate(Isolate* isolate,
940 Map* receiver_map,
941 PropertyCell* cell) {
942 Handle<Code> code = CodeStub::GetCodeCopyFromTemplate(isolate);
943 // Replace the placeholder cell and global object map with the actual global
944 // cell and receiver map.
945 Map* cell_map = isolate->heap()->global_property_cell_map();
946 code->ReplaceNthObject(1, cell_map, cell);
947 code->ReplaceNthObject(1, isolate->heap()->meta_map(), receiver_map);
948 return code;
949 }
950
951 virtual Code::Kind kind() const { return Code::STORE_IC; }
952
953 virtual Handle<Code> GenerateCode(Isolate* isolate);
954
955 virtual void InitializeInterfaceDescriptor(
956 Isolate* isolate,
957 CodeStubInterfaceDescriptor* descriptor);
958
959 virtual Code::ExtraICState GetExtraICState() { return bit_field_; }
960
961 bool is_constant() {
962 return IsConstantBits::decode(bit_field_);
963 }
964 void set_is_constant(bool value) {
965 bit_field_ = IsConstantBits::update(bit_field_, value);
966 }
967
968 Representation representation() {
969 return Representation::FromKind(RepresentationBits::decode(bit_field_));
970 }
971 void set_representation(Representation r) {
972 bit_field_ = RepresentationBits::update(bit_field_, r.kind());
973 }
974
975 private:
976 virtual int NotMissMinorKey() { return GetExtraICState(); }
977 Major MajorKey() { return StoreGlobal; }
978
979 class StrictModeBits: public BitField<StrictModeFlag, 0, 1> {};
980 class IsConstantBits: public BitField<bool, 1, 1> {};
981 class RepresentationBits: public BitField<Representation::Kind, 2, 8> {};
982
983 int bit_field_;
984
985 DISALLOW_COPY_AND_ASSIGN(StoreGlobalStub);
986 };
987
988
982 class KeyedLoadFieldStub: public LoadFieldStub { 989 class KeyedLoadFieldStub: public LoadFieldStub {
983 public: 990 public:
984 KeyedLoadFieldStub(bool inobject, int index, Representation representation) 991 KeyedLoadFieldStub(bool inobject, int index, Representation representation)
985 : LoadFieldStub() { 992 : LoadFieldStub() {
986 Initialize(Code::KEYED_LOAD_IC, inobject, index, representation); 993 Initialize(Code::KEYED_LOAD_IC, inobject, index, representation);
987 } 994 }
988 995
989 virtual void InitializeInterfaceDescriptor( 996 virtual void InitializeInterfaceDescriptor(
990 Isolate* isolate, 997 Isolate* isolate,
991 CodeStubInterfaceDescriptor* descriptor); 998 CodeStubInterfaceDescriptor* descriptor);
(...skipping 1364 matching lines...) Expand 10 before | Expand all | Expand 10 after
2356 int MinorKey() { return 0; } 2363 int MinorKey() { return 0; }
2357 2364
2358 void Generate(MacroAssembler* masm); 2365 void Generate(MacroAssembler* masm);
2359 2366
2360 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub); 2367 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub);
2361 }; 2368 };
2362 2369
2363 } } // namespace v8::internal 2370 } } // namespace v8::internal
2364 2371
2365 #endif // V8_CODE_STUBS_H_ 2372 #endif // V8_CODE_STUBS_H_
OLDNEW
« no previous file with comments | « src/arm/stub-cache-arm.cc ('k') | src/ia32/stub-cache-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698