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

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

Issue 18054002: Refactor HInferRepresentation into an HPhase and use the phase zone. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rename hydrogen-phase.{cc,h} to hydrogen-infer-representation.{cc,h} Created 7 years, 5 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/hydrogen-infer-representation.cc ('k') | src/hydrogen-instructions.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 27 matching lines...) Expand all
38 #include "v8conversions.h" 38 #include "v8conversions.h"
39 #include "v8utils.h" 39 #include "v8utils.h"
40 #include "zone.h" 40 #include "zone.h"
41 41
42 namespace v8 { 42 namespace v8 {
43 namespace internal { 43 namespace internal {
44 44
45 // Forward declarations. 45 // Forward declarations.
46 class HBasicBlock; 46 class HBasicBlock;
47 class HEnvironment; 47 class HEnvironment;
48 class HInferRepresentation; 48 class HInferRepresentationPhase;
49 class HInstruction; 49 class HInstruction;
50 class HLoopInformation; 50 class HLoopInformation;
51 class HValue; 51 class HValue;
52 class LInstruction; 52 class LInstruction;
53 class LChunkBuilder; 53 class LChunkBuilder;
54 54
55 55
56 #define HYDROGEN_ABSTRACT_INSTRUCTION_LIST(V) \ 56 #define HYDROGEN_ABSTRACT_INSTRUCTION_LIST(V) \
57 V(ArithmeticBinaryOperation) \ 57 V(ArithmeticBinaryOperation) \
58 V(BinaryOperation) \ 58 V(BinaryOperation) \
(...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after
1060 } 1060 }
1061 void AddNewRange(Range* r, Zone* zone); 1061 void AddNewRange(Range* r, Zone* zone);
1062 void RemoveLastAddedRange(); 1062 void RemoveLastAddedRange();
1063 void ComputeInitialRange(Zone* zone); 1063 void ComputeInitialRange(Zone* zone);
1064 1064
1065 // Representation helpers. 1065 // Representation helpers.
1066 virtual Representation observed_input_representation(int index) { 1066 virtual Representation observed_input_representation(int index) {
1067 return Representation::None(); 1067 return Representation::None();
1068 } 1068 }
1069 virtual Representation RequiredInputRepresentation(int index) = 0; 1069 virtual Representation RequiredInputRepresentation(int index) = 0;
1070 virtual void InferRepresentation(HInferRepresentation* h_infer); 1070 virtual void InferRepresentation(HInferRepresentationPhase* h_infer);
1071 1071
1072 // This gives the instruction an opportunity to replace itself with an 1072 // This gives the instruction an opportunity to replace itself with an
1073 // instruction that does the same in some better way. To replace an 1073 // instruction that does the same in some better way. To replace an
1074 // instruction with a new one, first add the new instruction to the graph, 1074 // instruction with a new one, first add the new instruction to the graph,
1075 // then return it. Return NULL to have the instruction deleted. 1075 // then return it. Return NULL to have the instruction deleted.
1076 virtual HValue* Canonicalize() { return this; } 1076 virtual HValue* Canonicalize() { return this; }
1077 1077
1078 bool Equals(HValue* other); 1078 bool Equals(HValue* other);
1079 virtual intptr_t Hashcode(); 1079 virtual intptr_t Hashcode();
1080 1080
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1152 UNREACHABLE(); 1152 UNREACHABLE();
1153 return false; 1153 return false;
1154 } 1154 }
1155 1155
1156 virtual Representation RepresentationFromInputs() { 1156 virtual Representation RepresentationFromInputs() {
1157 return representation(); 1157 return representation();
1158 } 1158 }
1159 Representation RepresentationFromUses(); 1159 Representation RepresentationFromUses();
1160 Representation RepresentationFromUseRequirements(); 1160 Representation RepresentationFromUseRequirements();
1161 virtual void UpdateRepresentation(Representation new_rep, 1161 virtual void UpdateRepresentation(Representation new_rep,
1162 HInferRepresentation* h_infer, 1162 HInferRepresentationPhase* h_infer,
1163 const char* reason); 1163 const char* reason);
1164 void AddDependantsToWorklist(HInferRepresentation* h_infer); 1164 void AddDependantsToWorklist(HInferRepresentationPhase* h_infer);
1165 1165
1166 virtual void RepresentationChanged(Representation to) { } 1166 virtual void RepresentationChanged(Representation to) { }
1167 1167
1168 virtual Range* InferRange(Zone* zone); 1168 virtual Range* InferRange(Zone* zone);
1169 virtual void DeleteFromGraph() = 0; 1169 virtual void DeleteFromGraph() = 0;
1170 virtual void InternalSetOperandAt(int index, HValue* value) = 0; 1170 virtual void InternalSetOperandAt(int index, HValue* value) = 0;
1171 void clear_block() { 1171 void clear_block() {
1172 ASSERT(block_ != NULL); 1172 ASSERT(block_ != NULL);
1173 block_ = NULL; 1173 block_ = NULL;
1174 } 1174 }
(...skipping 1891 matching lines...) Expand 10 before | Expand all | Expand 10 after
3066 indirect_uses_[i] = 0; 3066 indirect_uses_[i] = 0;
3067 } 3067 }
3068 ASSERT(merged_index >= 0); 3068 ASSERT(merged_index >= 0);
3069 SetFlag(kFlexibleRepresentation); 3069 SetFlag(kFlexibleRepresentation);
3070 SetFlag(kAllowUndefinedAsNaN); 3070 SetFlag(kAllowUndefinedAsNaN);
3071 } 3071 }
3072 3072
3073 virtual Representation RepresentationFromInputs(); 3073 virtual Representation RepresentationFromInputs();
3074 3074
3075 virtual Range* InferRange(Zone* zone); 3075 virtual Range* InferRange(Zone* zone);
3076 virtual void InferRepresentation(HInferRepresentation* h_infer); 3076 virtual void InferRepresentation(HInferRepresentationPhase* h_infer);
3077 virtual Representation RequiredInputRepresentation(int index) { 3077 virtual Representation RequiredInputRepresentation(int index) {
3078 return representation(); 3078 return representation();
3079 } 3079 }
3080 virtual Representation KnownOptimalRepresentation() { 3080 virtual Representation KnownOptimalRepresentation() {
3081 return representation(); 3081 return representation();
3082 } 3082 }
3083 virtual HType CalculateInferredType(); 3083 virtual HType CalculateInferredType();
3084 virtual int OperandCount() { return inputs_.length(); } 3084 virtual int OperandCount() { return inputs_.length(); }
3085 virtual HValue* OperandAt(int index) const { return inputs_[index]; } 3085 virtual HValue* OperandAt(int index) const { return inputs_[index]; }
3086 HValue* GetRedundantReplacement(); 3086 HValue* GetRedundantReplacement();
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
3488 3488
3489 virtual void initialize_output_representation(Representation observed) { 3489 virtual void initialize_output_representation(Representation observed) {
3490 observed_output_representation_ = observed; 3490 observed_output_representation_ = observed;
3491 } 3491 }
3492 3492
3493 virtual Representation observed_input_representation(int index) { 3493 virtual Representation observed_input_representation(int index) {
3494 if (index == 0) return Representation::Tagged(); 3494 if (index == 0) return Representation::Tagged();
3495 return observed_input_representation_[index - 1]; 3495 return observed_input_representation_[index - 1];
3496 } 3496 }
3497 3497
3498 virtual void InferRepresentation(HInferRepresentation* h_infer); 3498 virtual void InferRepresentation(HInferRepresentationPhase* h_infer);
3499 virtual Representation RepresentationFromInputs(); 3499 virtual Representation RepresentationFromInputs();
3500 virtual void AssumeRepresentation(Representation r); 3500 virtual void AssumeRepresentation(Representation r);
3501 3501
3502 virtual void UpdateRepresentation(Representation new_rep, 3502 virtual void UpdateRepresentation(Representation new_rep,
3503 HInferRepresentation* h_infer, 3503 HInferRepresentationPhase* h_infer,
3504 const char* reason) { 3504 const char* reason) {
3505 // By default, binary operations don't handle Smis. 3505 // By default, binary operations don't handle Smis.
3506 if (new_rep.IsSmi()) { 3506 if (new_rep.IsSmi()) {
3507 new_rep = Representation::Integer32(); 3507 new_rep = Representation::Integer32();
3508 } 3508 }
3509 HValue::UpdateRepresentation(new_rep, h_infer, reason); 3509 HValue::UpdateRepresentation(new_rep, h_infer, reason);
3510 } 3510 }
3511 3511
3512 virtual bool IsCommutative() const { return false; } 3512 virtual bool IsCommutative() const { return false; }
3513 3513
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
3705 virtual Representation RequiredInputRepresentation(int arg_index) { 3705 virtual Representation RequiredInputRepresentation(int arg_index) {
3706 return representation(); 3706 return representation();
3707 } 3707 }
3708 3708
3709 virtual bool IsRelationTrueInternal(NumericRelation relation, 3709 virtual bool IsRelationTrueInternal(NumericRelation relation,
3710 HValue* related_value, 3710 HValue* related_value,
3711 int offset = 0, 3711 int offset = 0,
3712 int scale = 0); 3712 int scale = 0);
3713 3713
3714 virtual void PrintDataTo(StringStream* stream); 3714 virtual void PrintDataTo(StringStream* stream);
3715 virtual void InferRepresentation(HInferRepresentation* h_infer); 3715 virtual void InferRepresentation(HInferRepresentationPhase* h_infer);
3716 3716
3717 HValue* index() { return OperandAt(0); } 3717 HValue* index() { return OperandAt(0); }
3718 HValue* length() { return OperandAt(1); } 3718 HValue* length() { return OperandAt(1); }
3719 3719
3720 virtual int RedefinedOperandIndex() { return 0; } 3720 virtual int RedefinedOperandIndex() { return 0; }
3721 virtual bool IsPurelyInformativeDefinition() { return skip_check(); } 3721 virtual bool IsPurelyInformativeDefinition() { return skip_check(); }
3722 virtual void AddInformativeDefinitions(); 3722 virtual void AddInformativeDefinitions();
3723 3723
3724 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck) 3724 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck)
3725 3725
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
3802 ASSERT(to.IsInteger32()); 3802 ASSERT(to.IsInteger32());
3803 ClearAllSideEffects(); 3803 ClearAllSideEffects();
3804 SetFlag(kUseGVN); 3804 SetFlag(kUseGVN);
3805 } else { 3805 } else {
3806 SetAllSideEffects(); 3806 SetAllSideEffects();
3807 ClearFlag(kUseGVN); 3807 ClearFlag(kUseGVN);
3808 } 3808 }
3809 } 3809 }
3810 3810
3811 virtual void UpdateRepresentation(Representation new_rep, 3811 virtual void UpdateRepresentation(Representation new_rep,
3812 HInferRepresentation* h_infer, 3812 HInferRepresentationPhase* h_infer,
3813 const char* reason) { 3813 const char* reason) {
3814 // We only generate either int32 or generic tagged bitwise operations. 3814 // We only generate either int32 or generic tagged bitwise operations.
3815 if (new_rep.IsSmi() || new_rep.IsDouble()) { 3815 if (new_rep.IsSmi() || new_rep.IsDouble()) {
3816 new_rep = Representation::Integer32(); 3816 new_rep = Representation::Integer32();
3817 } 3817 }
3818 HValue::UpdateRepresentation(new_rep, h_infer, reason); 3818 HValue::UpdateRepresentation(new_rep, h_infer, reason);
3819 } 3819 }
3820 3820
3821 virtual void initialize_output_representation(Representation observed) { 3821 virtual void initialize_output_representation(Representation observed) {
3822 if (observed.IsDouble()) observed = Representation::Integer32(); 3822 if (observed.IsDouble()) observed = Representation::Integer32();
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
3937 HValue* left() { return OperandAt(0); } 3937 HValue* left() { return OperandAt(0); }
3938 HValue* right() { return OperandAt(1); } 3938 HValue* right() { return OperandAt(1); }
3939 Token::Value token() const { return token_; } 3939 Token::Value token() const { return token_; }
3940 3940
3941 void set_observed_input_representation(Representation left, 3941 void set_observed_input_representation(Representation left,
3942 Representation right) { 3942 Representation right) {
3943 observed_input_representation_[0] = left; 3943 observed_input_representation_[0] = left;
3944 observed_input_representation_[1] = right; 3944 observed_input_representation_[1] = right;
3945 } 3945 }
3946 3946
3947 virtual void InferRepresentation(HInferRepresentation* h_infer); 3947 virtual void InferRepresentation(HInferRepresentationPhase* h_infer);
3948 3948
3949 virtual Representation RequiredInputRepresentation(int index) { 3949 virtual Representation RequiredInputRepresentation(int index) {
3950 return representation(); 3950 return representation();
3951 } 3951 }
3952 virtual Representation observed_input_representation(int index) { 3952 virtual Representation observed_input_representation(int index) {
3953 return observed_input_representation_[index]; 3953 return observed_input_representation_[index];
3954 } 3954 }
3955 virtual void PrintDataTo(StringStream* stream); 3955 virtual void PrintDataTo(StringStream* stream);
3956 3956
3957 virtual void AddInformativeDefinitions(); 3957 virtual void AddInformativeDefinitions();
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
4554 4554
4555 virtual Representation RequiredInputRepresentation(int index) { 4555 virtual Representation RequiredInputRepresentation(int index) {
4556 return index == 0 ? Representation::Tagged() 4556 return index == 0 ? Representation::Tagged()
4557 : representation(); 4557 : representation();
4558 } 4558 }
4559 4559
4560 virtual Representation observed_input_representation(int index) { 4560 virtual Representation observed_input_representation(int index) {
4561 return RequiredInputRepresentation(index); 4561 return RequiredInputRepresentation(index);
4562 } 4562 }
4563 4563
4564 virtual void InferRepresentation(HInferRepresentation* h_infer); 4564 virtual void InferRepresentation(HInferRepresentationPhase* h_infer);
4565 4565
4566 virtual Representation RepresentationFromInputs() { 4566 virtual Representation RepresentationFromInputs() {
4567 Representation left_rep = left()->representation(); 4567 Representation left_rep = left()->representation();
4568 Representation right_rep = right()->representation(); 4568 Representation right_rep = right()->representation();
4569 if ((left_rep.IsNone() || left_rep.IsInteger32()) && 4569 if ((left_rep.IsNone() || left_rep.IsInteger32()) &&
4570 (right_rep.IsNone() || right_rep.IsInteger32())) { 4570 (right_rep.IsNone() || right_rep.IsInteger32())) {
4571 return Representation::Integer32(); 4571 return Representation::Integer32();
4572 } 4572 }
4573 return Representation::Double(); 4573 return Representation::Double();
4574 } 4574 }
(...skipping 2064 matching lines...) Expand 10 before | Expand all | Expand 10 after
6639 virtual bool IsDeletable() const { return true; } 6639 virtual bool IsDeletable() const { return true; }
6640 }; 6640 };
6641 6641
6642 6642
6643 #undef DECLARE_INSTRUCTION 6643 #undef DECLARE_INSTRUCTION
6644 #undef DECLARE_CONCRETE_INSTRUCTION 6644 #undef DECLARE_CONCRETE_INSTRUCTION
6645 6645
6646 } } // namespace v8::internal 6646 } } // namespace v8::internal
6647 6647
6648 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 6648 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW
« no previous file with comments | « src/hydrogen-infer-representation.cc ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698