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

Side by Side Diff: src/hydrogen-instructions.h

Issue 6690006: Improve GVN dependency tracking by adding parameters to certain flags.
Patch Set: Created 9 years, 9 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
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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 V(StringLength) \ 154 V(StringLength) \
155 V(Sub) \ 155 V(Sub) \
156 V(Test) \ 156 V(Test) \
157 V(Throw) \ 157 V(Throw) \
158 V(Typeof) \ 158 V(Typeof) \
159 V(TypeofIs) \ 159 V(TypeofIs) \
160 V(UnaryMathOperation) \ 160 V(UnaryMathOperation) \
161 V(UnknownOSRValue) \ 161 V(UnknownOSRValue) \
162 V(ValueOf) 162 V(ValueOf)
163 163
164 // The list of GVN flags. To improve memory usage it should start with
165 // the flags that allow parameters.
164 #define GVN_FLAG_LIST(V) \ 166 #define GVN_FLAG_LIST(V) \
165 V(Calls) \
166 V(InobjectFields) \ 167 V(InobjectFields) \
167 V(BackingStoreFields) \ 168 V(BackingStoreFields) \
169 V(GlobalVars) \
170 V(ContextSlots) \
171 V(Calls) \
168 V(ArrayElements) \ 172 V(ArrayElements) \
169 V(PixelArrayElements) \ 173 V(PixelArrayElements) \
170 V(GlobalVars) \
171 V(Maps) \ 174 V(Maps) \
172 V(ArrayLengths) \ 175 V(ArrayLengths) \
173 V(ContextSlots) \
174 V(OsrEntries) 176 V(OsrEntries)
175 177
176 #define DECLARE_INSTRUCTION(type) \ 178 #define DECLARE_INSTRUCTION(type) \
177 virtual bool Is##type() const { return true; } \ 179 virtual bool Is##type() const { return true; } \
178 static H##type* cast(HValue* value) { \ 180 static H##type* cast(HValue* value) { \
179 ASSERT(value->Is##type()); \ 181 ASSERT(value->Is##type()); \
180 return reinterpret_cast<H##type*>(value); \ 182 return reinterpret_cast<H##type*>(value); \
181 } \ 183 } \
182 Opcode opcode() const { return HValue::k##type; } 184 Opcode opcode() const { return HValue::k##type; }
183 185
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 // There must be one corresponding kDepends flag for every kChanges flag and 403 // There must be one corresponding kDepends flag for every kChanges flag and
402 // the order of the kChanges flags must be exactly the same as of the kDepends 404 // the order of the kChanges flags must be exactly the same as of the kDepends
403 // flags. 405 // flags.
404 enum Flag { 406 enum Flag {
405 // Declare global value numbering flags. 407 // Declare global value numbering flags.
406 #define DECLARE_DO(type) kChanges##type, kDependsOn##type, 408 #define DECLARE_DO(type) kChanges##type, kDependsOn##type,
407 GVN_FLAG_LIST(DECLARE_DO) 409 GVN_FLAG_LIST(DECLARE_DO)
408 #undef DECLARE_DO 410 #undef DECLARE_DO
409 kFlexibleRepresentation, 411 kFlexibleRepresentation,
410 kUseGVN, 412 kUseGVN,
413 kHasGVNParameter,
411 kCanOverflow, 414 kCanOverflow,
412 kBailoutOnMinusZero, 415 kBailoutOnMinusZero,
413 kCanBeDivByZero, 416 kCanBeDivByZero,
414 kIsArguments, 417 kIsArguments,
415 kTruncatingToInt32, 418 kTruncatingToInt32,
419 kFirstNonGVNFlag = kFlexibleRepresentation,
416 kLastFlag = kTruncatingToInt32 420 kLastFlag = kTruncatingToInt32
417 }; 421 };
418 422
419 STATIC_ASSERT(kLastFlag < kBitsPerInt); 423 STATIC_ASSERT(kLastFlag < kBitsPerInt);
420 424
421 static const int kChangesToDependsFlagsLeftShift = 1; 425 static const int kChangesToDependsFlagsLeftShift = 1;
422 426
423 static int ChangesFlagsMask() { 427 static int ChangesFlagsMask() {
424 int result = 0; 428 int result = 0;
425 // Create changes mask. 429 // Create changes mask.
426 #define DECLARE_DO(type) result |= (1 << kChanges##type); 430 #define DECLARE_DO(type) result |= (1 << kChanges##type);
427 GVN_FLAG_LIST(DECLARE_DO) 431 GVN_FLAG_LIST(DECLARE_DO)
428 #undef DECLARE_DO 432 #undef DECLARE_DO
429 return result; 433 return result;
430 } 434 }
431 435
432 static int DependsFlagsMask() { 436 static int DependsFlagsMask() {
433 return ConvertChangesToDependsFlags(ChangesFlagsMask()); 437 return ConvertChangesToDependsFlags(ChangesFlagsMask());
434 } 438 }
435 439
436 static int ConvertChangesToDependsFlags(int flags) { 440 static int ConvertChangesToDependsFlags(int flags) {
437 return flags << kChangesToDependsFlagsLeftShift; 441 return flags << kChangesToDependsFlagsLeftShift;
438 } 442 }
443 static int ConvertDependsToChangesFlags(int flags) {
444 return flags >> kChangesToDependsFlagsLeftShift;
445 }
439 446
440 static HValue* cast(HValue* value) { return value; } 447 static HValue* cast(HValue* value) { return value; }
441 448
442 enum Opcode { 449 enum Opcode {
443 // Declare a unique enum value for each hydrogen instruction. 450 // Declare a unique enum value for each hydrogen instruction.
444 #define DECLARE_DO(type) k##type, 451 #define DECLARE_DO(type) k##type,
445 HYDROGEN_ALL_INSTRUCTION_LIST(DECLARE_DO) 452 HYDROGEN_ALL_INSTRUCTION_LIST(DECLARE_DO)
446 #undef DECLARE_DO 453 #undef DECLARE_DO
447 kMaxInstructionClass 454 kMaxInstructionClass
448 }; 455 };
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 virtual HValue* Canonicalize() { return this; } 549 virtual HValue* Canonicalize() { return this; }
543 550
544 // Declare virtual type testers. 551 // Declare virtual type testers.
545 #define DECLARE_DO(type) virtual bool Is##type() const { return false; } 552 #define DECLARE_DO(type) virtual bool Is##type() const { return false; }
546 HYDROGEN_ALL_INSTRUCTION_LIST(DECLARE_DO) 553 HYDROGEN_ALL_INSTRUCTION_LIST(DECLARE_DO)
547 #undef DECLARE_DO 554 #undef DECLARE_DO
548 555
549 bool Equals(HValue* other); 556 bool Equals(HValue* other);
550 virtual intptr_t Hashcode(); 557 virtual intptr_t Hashcode();
551 558
559 virtual intptr_t GetGVNParameter() {
560 UNREACHABLE();
561 return 0;
562 }
563
552 // Printing support. 564 // Printing support.
553 virtual void PrintTo(StringStream* stream) = 0; 565 virtual void PrintTo(StringStream* stream) = 0;
554 void PrintNameTo(StringStream* stream); 566 void PrintNameTo(StringStream* stream);
555 static void PrintTypeTo(HType type, StringStream* stream); 567 static void PrintTypeTo(HType type, StringStream* stream);
556 568
557 virtual const char* Mnemonic() const = 0; 569 virtual const char* Mnemonic() const = 0;
558 virtual Opcode opcode() const = 0; 570 virtual Opcode opcode() const = 0;
559 571
560 // Updated the inferred type of this instruction and returns true if 572 // Updated the inferred type of this instruction and returns true if
561 // it has changed. 573 // it has changed.
(...skipping 2212 matching lines...) Expand 10 before | Expand all | Expand 10 after
2774 }; 2786 };
2775 2787
2776 2788
2777 class HLoadGlobal: public HTemplateInstruction<0> { 2789 class HLoadGlobal: public HTemplateInstruction<0> {
2778 public: 2790 public:
2779 HLoadGlobal(Handle<JSGlobalPropertyCell> cell, bool check_hole_value) 2791 HLoadGlobal(Handle<JSGlobalPropertyCell> cell, bool check_hole_value)
2780 : cell_(cell), check_hole_value_(check_hole_value) { 2792 : cell_(cell), check_hole_value_(check_hole_value) {
2781 set_representation(Representation::Tagged()); 2793 set_representation(Representation::Tagged());
2782 SetFlag(kUseGVN); 2794 SetFlag(kUseGVN);
2783 SetFlag(kDependsOnGlobalVars); 2795 SetFlag(kDependsOnGlobalVars);
2796 SetFlag(kHasGVNParameter);
2797 }
2798
2799 virtual intptr_t GetGVNParameter() {
2800 return reinterpret_cast<intptr_t>(*cell_);
2784 } 2801 }
2785 2802
2786 Handle<JSGlobalPropertyCell> cell() const { return cell_; } 2803 Handle<JSGlobalPropertyCell> cell() const { return cell_; }
2787 bool check_hole_value() const { return check_hole_value_; } 2804 bool check_hole_value() const { return check_hole_value_; }
2788 2805
2789 virtual void PrintDataTo(StringStream* stream); 2806 virtual void PrintDataTo(StringStream* stream);
2790 2807
2791 virtual intptr_t Hashcode() { 2808 virtual intptr_t Hashcode() {
2792 ASSERT(!Heap::allow_allocation(false)); 2809 ASSERT(!Heap::allow_allocation(false));
2793 return reinterpret_cast<intptr_t>(*cell_); 2810 return reinterpret_cast<intptr_t>(*cell_);
(...skipping 19 matching lines...) Expand all
2813 2830
2814 class HStoreGlobal: public HUnaryOperation { 2831 class HStoreGlobal: public HUnaryOperation {
2815 public: 2832 public:
2816 HStoreGlobal(HValue* value, 2833 HStoreGlobal(HValue* value,
2817 Handle<JSGlobalPropertyCell> cell, 2834 Handle<JSGlobalPropertyCell> cell,
2818 bool check_hole_value) 2835 bool check_hole_value)
2819 : HUnaryOperation(value), 2836 : HUnaryOperation(value),
2820 cell_(cell), 2837 cell_(cell),
2821 check_hole_value_(check_hole_value) { 2838 check_hole_value_(check_hole_value) {
2822 SetFlag(kChangesGlobalVars); 2839 SetFlag(kChangesGlobalVars);
2840 SetFlag(kHasGVNParameter);
2841 }
2842
2843 virtual intptr_t GetGVNParameter() {
2844 return reinterpret_cast<intptr_t>(*cell_);
2823 } 2845 }
2824 2846
2825 Handle<JSGlobalPropertyCell> cell() const { return cell_; } 2847 Handle<JSGlobalPropertyCell> cell() const { return cell_; }
2826 bool check_hole_value() const { return check_hole_value_; } 2848 bool check_hole_value() const { return check_hole_value_; }
2827 2849
2828 virtual Representation RequiredInputRepresentation(int index) const { 2850 virtual Representation RequiredInputRepresentation(int index) const {
2829 return Representation::Tagged(); 2851 return Representation::Tagged();
2830 } 2852 }
2831 virtual void PrintDataTo(StringStream* stream); 2853 virtual void PrintDataTo(StringStream* stream);
2832 2854
2833 DECLARE_CONCRETE_INSTRUCTION(StoreGlobal, "store_global") 2855 DECLARE_CONCRETE_INSTRUCTION(StoreGlobal, "store_global")
2834 2856
2835 private: 2857 private:
2836 Handle<JSGlobalPropertyCell> cell_; 2858 Handle<JSGlobalPropertyCell> cell_;
2837 bool check_hole_value_; 2859 bool check_hole_value_;
2838 }; 2860 };
2839 2861
2840 2862
2841 class HLoadContextSlot: public HUnaryOperation { 2863 class HLoadContextSlot: public HUnaryOperation {
2842 public: 2864 public:
2843 HLoadContextSlot(HValue* context , int slot_index) 2865 HLoadContextSlot(HValue* context , int slot_index)
2844 : HUnaryOperation(context), slot_index_(slot_index) { 2866 : HUnaryOperation(context), slot_index_(slot_index) {
2845 set_representation(Representation::Tagged()); 2867 set_representation(Representation::Tagged());
2846 SetFlag(kUseGVN); 2868 SetFlag(kUseGVN);
2847 SetFlag(kDependsOnContextSlots); 2869 SetFlag(kDependsOnContextSlots);
2870 SetFlag(kHasGVNParameter);
2848 } 2871 }
2849 2872
2873 virtual intptr_t GetGVNParameter() { return slot_index_; }
2874
2850 int slot_index() const { return slot_index_; } 2875 int slot_index() const { return slot_index_; }
2851 2876
2852 virtual Representation RequiredInputRepresentation(int index) const { 2877 virtual Representation RequiredInputRepresentation(int index) const {
2853 return Representation::Tagged(); 2878 return Representation::Tagged();
2854 } 2879 }
2855 2880
2856 virtual void PrintDataTo(StringStream* stream); 2881 virtual void PrintDataTo(StringStream* stream);
2857 2882
2858 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load_context_slot") 2883 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load_context_slot")
2859 2884
(...skipping 12 matching lines...) Expand all
2872 return !value->type().IsSmi() && 2897 return !value->type().IsSmi() &&
2873 !(value->IsConstant() && HConstant::cast(value)->InOldSpace()); 2898 !(value->IsConstant() && HConstant::cast(value)->InOldSpace());
2874 } 2899 }
2875 2900
2876 2901
2877 class HStoreContextSlot: public HBinaryOperation { 2902 class HStoreContextSlot: public HBinaryOperation {
2878 public: 2903 public:
2879 HStoreContextSlot(HValue* context, int slot_index, HValue* value) 2904 HStoreContextSlot(HValue* context, int slot_index, HValue* value)
2880 : HBinaryOperation(context, value), slot_index_(slot_index) { 2905 : HBinaryOperation(context, value), slot_index_(slot_index) {
2881 SetFlag(kChangesContextSlots); 2906 SetFlag(kChangesContextSlots);
2907 SetFlag(kHasGVNParameter);
2882 } 2908 }
2883 2909
2910 virtual intptr_t GetGVNParameter() { return slot_index_; }
2911
2884 HValue* context() { return OperandAt(0); } 2912 HValue* context() { return OperandAt(0); }
2885 HValue* value() { return OperandAt(1); } 2913 HValue* value() { return OperandAt(1); }
2886 int slot_index() const { return slot_index_; } 2914 int slot_index() const { return slot_index_; }
2887 2915
2888 bool NeedsWriteBarrier() { 2916 bool NeedsWriteBarrier() {
2889 return StoringValueNeedsWriteBarrier(value()); 2917 return StoringValueNeedsWriteBarrier(value());
2890 } 2918 }
2891 2919
2892 virtual Representation RequiredInputRepresentation(int index) const { 2920 virtual Representation RequiredInputRepresentation(int index) const {
2893 return Representation::Tagged(); 2921 return Representation::Tagged();
(...skipping 14 matching lines...) Expand all
2908 : HUnaryOperation(object), 2936 : HUnaryOperation(object),
2909 is_in_object_(is_in_object), 2937 is_in_object_(is_in_object),
2910 offset_(offset) { 2938 offset_(offset) {
2911 set_representation(Representation::Tagged()); 2939 set_representation(Representation::Tagged());
2912 SetFlag(kUseGVN); 2940 SetFlag(kUseGVN);
2913 if (is_in_object) { 2941 if (is_in_object) {
2914 SetFlag(kDependsOnInobjectFields); 2942 SetFlag(kDependsOnInobjectFields);
2915 } else { 2943 } else {
2916 SetFlag(kDependsOnBackingStoreFields); 2944 SetFlag(kDependsOnBackingStoreFields);
2917 } 2945 }
2946 SetFlag(kHasGVNParameter);
2947 }
2948
2949 virtual intptr_t GetGVNParameter() {
2950 return (offset_ << 1) || (is_in_object_ ? 1 : 0);
fschneider 2011/03/16 15:43:28 Shouldn't be this bitwise-or "|"?
2918 } 2951 }
2919 2952
2920 HValue* object() { return OperandAt(0); } 2953 HValue* object() { return OperandAt(0); }
2921 bool is_in_object() const { return is_in_object_; } 2954 bool is_in_object() const { return is_in_object_; }
2922 int offset() const { return offset_; } 2955 int offset() const { return offset_; }
2923 2956
2924 virtual Representation RequiredInputRepresentation(int index) const { 2957 virtual Representation RequiredInputRepresentation(int index) const {
2925 return Representation::Tagged(); 2958 return Representation::Tagged();
2926 } 2959 }
2927 virtual void PrintDataTo(StringStream* stream); 2960 virtual void PrintDataTo(StringStream* stream);
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
3076 int offset) 3109 int offset)
3077 : HBinaryOperation(obj, val), 3110 : HBinaryOperation(obj, val),
3078 name_(name), 3111 name_(name),
3079 is_in_object_(in_object), 3112 is_in_object_(in_object),
3080 offset_(offset) { 3113 offset_(offset) {
3081 if (is_in_object_) { 3114 if (is_in_object_) {
3082 SetFlag(kChangesInobjectFields); 3115 SetFlag(kChangesInobjectFields);
3083 } else { 3116 } else {
3084 SetFlag(kChangesBackingStoreFields); 3117 SetFlag(kChangesBackingStoreFields);
3085 } 3118 }
3119 SetFlag(kHasGVNParameter);
3120 }
3121
3122 virtual intptr_t GetGVNParameter() {
3123 return (offset_ << 1) || (is_in_object_ ? 1 : 0);
fschneider 2011/03/16 15:43:28 -> use "|" here as well.
3086 } 3124 }
3087 3125
3088 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store_named_field") 3126 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store_named_field")
3089 3127
3090 virtual Representation RequiredInputRepresentation(int index) const { 3128 virtual Representation RequiredInputRepresentation(int index) const {
3091 return Representation::Tagged(); 3129 return Representation::Tagged();
3092 } 3130 }
3093 virtual void PrintDataTo(StringStream* stream); 3131 virtual void PrintDataTo(StringStream* stream);
3094 3132
3095 HValue* object() { return OperandAt(0); } 3133 HValue* object() { return OperandAt(0); }
3096 HValue* value() { return OperandAt(1); } 3134 HValue* value() { return OperandAt(1); }
3097 3135
3098 Handle<String> name() const { return name_; } 3136 Handle<String> name() const { return name_; }
3099 bool is_in_object() const { return is_in_object_; } 3137 bool is_in_object() const { return is_in_object_; }
3100 int offset() const { return offset_; } 3138 int offset() const { return offset_; }
3101 Handle<Map> transition() const { return transition_; } 3139 Handle<Map> transition() const { return transition_; }
3102 void set_transition(Handle<Map> map) { transition_ = map; } 3140 void SetTransition(Handle<Map> map) {
3141 transition_ = map;
3142 // TODO(fschneider): Record the new map type of the object in the IR to
3143 // enable elimination of redundant checks after the transition store.
3144 SetFlag(kChangesMaps);
3145 // TODO(vitalyr): GVN parameter is only supported for instructions
3146 // that have a single GVN flag.
3147 ClearFlag(kHasGVNParameter);
3148 }
3103 3149
3104 bool NeedsWriteBarrier() { 3150 bool NeedsWriteBarrier() {
3105 return StoringValueNeedsWriteBarrier(value()); 3151 return StoringValueNeedsWriteBarrier(value());
3106 } 3152 }
3107 3153
3108 private: 3154 private:
3109 Handle<String> name_; 3155 Handle<String> name_;
3110 bool is_in_object_; 3156 bool is_in_object_;
3111 int offset_; 3157 int offset_;
3112 Handle<Map> transition_; 3158 Handle<Map> transition_;
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
3451 HValue* object() { return left(); } 3497 HValue* object() { return left(); }
3452 HValue* key() { return right(); } 3498 HValue* key() { return right(); }
3453 }; 3499 };
3454 3500
3455 #undef DECLARE_INSTRUCTION 3501 #undef DECLARE_INSTRUCTION
3456 #undef DECLARE_CONCRETE_INSTRUCTION 3502 #undef DECLARE_CONCRETE_INSTRUCTION
3457 3503
3458 } } // namespace v8::internal 3504 } } // namespace v8::internal
3459 3505
3460 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 3506 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW
« src/hydrogen.cc ('K') | « src/hydrogen.cc ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698