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

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: Created 7 years, 6 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 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 1893 matching lines...) Expand 10 before | Expand all | Expand 10 after
3068 indirect_uses_[i] = 0; 3068 indirect_uses_[i] = 0;
3069 } 3069 }
3070 ASSERT(merged_index >= 0); 3070 ASSERT(merged_index >= 0);
3071 SetFlag(kFlexibleRepresentation); 3071 SetFlag(kFlexibleRepresentation);
3072 SetFlag(kAllowUndefinedAsNaN); 3072 SetFlag(kAllowUndefinedAsNaN);
3073 } 3073 }
3074 3074
3075 virtual Representation RepresentationFromInputs(); 3075 virtual Representation RepresentationFromInputs();
3076 3076
3077 virtual Range* InferRange(Zone* zone); 3077 virtual Range* InferRange(Zone* zone);
3078 virtual void InferRepresentation(HInferRepresentation* h_infer); 3078 virtual void InferRepresentation(HInferRepresentationPhase* h_infer);
3079 virtual Representation RequiredInputRepresentation(int index) { 3079 virtual Representation RequiredInputRepresentation(int index) {
3080 return representation(); 3080 return representation();
3081 } 3081 }
3082 virtual Representation KnownOptimalRepresentation() { 3082 virtual Representation KnownOptimalRepresentation() {
3083 return representation(); 3083 return representation();
3084 } 3084 }
3085 virtual HType CalculateInferredType(); 3085 virtual HType CalculateInferredType();
3086 virtual int OperandCount() { return inputs_.length(); } 3086 virtual int OperandCount() { return inputs_.length(); }
3087 virtual HValue* OperandAt(int index) const { return inputs_[index]; } 3087 virtual HValue* OperandAt(int index) const { return inputs_[index]; }
3088 HValue* GetRedundantReplacement(); 3088 HValue* GetRedundantReplacement();
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
3490 3490
3491 virtual void initialize_output_representation(Representation observed) { 3491 virtual void initialize_output_representation(Representation observed) {
3492 observed_output_representation_ = observed; 3492 observed_output_representation_ = observed;
3493 } 3493 }
3494 3494
3495 virtual Representation observed_input_representation(int index) { 3495 virtual Representation observed_input_representation(int index) {
3496 if (index == 0) return Representation::Tagged(); 3496 if (index == 0) return Representation::Tagged();
3497 return observed_input_representation_[index - 1]; 3497 return observed_input_representation_[index - 1];
3498 } 3498 }
3499 3499
3500 virtual void InferRepresentation(HInferRepresentation* h_infer); 3500 virtual void InferRepresentation(HInferRepresentationPhase* h_infer);
3501 virtual Representation RepresentationFromInputs(); 3501 virtual Representation RepresentationFromInputs();
3502 virtual void AssumeRepresentation(Representation r); 3502 virtual void AssumeRepresentation(Representation r);
3503 3503
3504 virtual void UpdateRepresentation(Representation new_rep, 3504 virtual void UpdateRepresentation(Representation new_rep,
3505 HInferRepresentation* h_infer, 3505 HInferRepresentationPhase* h_infer,
3506 const char* reason) { 3506 const char* reason) {
3507 // By default, binary operations don't handle Smis. 3507 // By default, binary operations don't handle Smis.
3508 if (new_rep.IsSmi()) { 3508 if (new_rep.IsSmi()) {
3509 new_rep = Representation::Integer32(); 3509 new_rep = Representation::Integer32();
3510 } 3510 }
3511 HValue::UpdateRepresentation(new_rep, h_infer, reason); 3511 HValue::UpdateRepresentation(new_rep, h_infer, reason);
3512 } 3512 }
3513 3513
3514 virtual bool IsCommutative() const { return false; } 3514 virtual bool IsCommutative() const { return false; }
3515 3515
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
3707 virtual Representation RequiredInputRepresentation(int arg_index) { 3707 virtual Representation RequiredInputRepresentation(int arg_index) {
3708 return representation(); 3708 return representation();
3709 } 3709 }
3710 3710
3711 virtual bool IsRelationTrueInternal(NumericRelation relation, 3711 virtual bool IsRelationTrueInternal(NumericRelation relation,
3712 HValue* related_value, 3712 HValue* related_value,
3713 int offset = 0, 3713 int offset = 0,
3714 int scale = 0); 3714 int scale = 0);
3715 3715
3716 virtual void PrintDataTo(StringStream* stream); 3716 virtual void PrintDataTo(StringStream* stream);
3717 virtual void InferRepresentation(HInferRepresentation* h_infer); 3717 virtual void InferRepresentation(HInferRepresentationPhase* h_infer);
3718 3718
3719 HValue* index() { return OperandAt(0); } 3719 HValue* index() { return OperandAt(0); }
3720 HValue* length() { return OperandAt(1); } 3720 HValue* length() { return OperandAt(1); }
3721 3721
3722 virtual int RedefinedOperandIndex() { return 0; } 3722 virtual int RedefinedOperandIndex() { return 0; }
3723 virtual bool IsPurelyInformativeDefinition() { return skip_check(); } 3723 virtual bool IsPurelyInformativeDefinition() { return skip_check(); }
3724 virtual void AddInformativeDefinitions(); 3724 virtual void AddInformativeDefinitions();
3725 3725
3726 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck) 3726 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck)
3727 3727
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
3804 ASSERT(to.IsInteger32()); 3804 ASSERT(to.IsInteger32());
3805 ClearAllSideEffects(); 3805 ClearAllSideEffects();
3806 SetFlag(kUseGVN); 3806 SetFlag(kUseGVN);
3807 } else { 3807 } else {
3808 SetAllSideEffects(); 3808 SetAllSideEffects();
3809 ClearFlag(kUseGVN); 3809 ClearFlag(kUseGVN);
3810 } 3810 }
3811 } 3811 }
3812 3812
3813 virtual void UpdateRepresentation(Representation new_rep, 3813 virtual void UpdateRepresentation(Representation new_rep,
3814 HInferRepresentation* h_infer, 3814 HInferRepresentationPhase* h_infer,
3815 const char* reason) { 3815 const char* reason) {
3816 // We only generate either int32 or generic tagged bitwise operations. 3816 // We only generate either int32 or generic tagged bitwise operations.
3817 if (new_rep.IsSmi() || new_rep.IsDouble()) { 3817 if (new_rep.IsSmi() || new_rep.IsDouble()) {
3818 new_rep = Representation::Integer32(); 3818 new_rep = Representation::Integer32();
3819 } 3819 }
3820 HValue::UpdateRepresentation(new_rep, h_infer, reason); 3820 HValue::UpdateRepresentation(new_rep, h_infer, reason);
3821 } 3821 }
3822 3822
3823 virtual void initialize_output_representation(Representation observed) { 3823 virtual void initialize_output_representation(Representation observed) {
3824 if (observed.IsDouble()) observed = Representation::Integer32(); 3824 if (observed.IsDouble()) observed = Representation::Integer32();
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
3939 HValue* left() { return OperandAt(0); } 3939 HValue* left() { return OperandAt(0); }
3940 HValue* right() { return OperandAt(1); } 3940 HValue* right() { return OperandAt(1); }
3941 Token::Value token() const { return token_; } 3941 Token::Value token() const { return token_; }
3942 3942
3943 void set_observed_input_representation(Representation left, 3943 void set_observed_input_representation(Representation left,
3944 Representation right) { 3944 Representation right) {
3945 observed_input_representation_[0] = left; 3945 observed_input_representation_[0] = left;
3946 observed_input_representation_[1] = right; 3946 observed_input_representation_[1] = right;
3947 } 3947 }
3948 3948
3949 virtual void InferRepresentation(HInferRepresentation* h_infer); 3949 virtual void InferRepresentation(HInferRepresentationPhase* h_infer);
3950 3950
3951 virtual Representation RequiredInputRepresentation(int index) { 3951 virtual Representation RequiredInputRepresentation(int index) {
3952 return representation(); 3952 return representation();
3953 } 3953 }
3954 virtual Representation observed_input_representation(int index) { 3954 virtual Representation observed_input_representation(int index) {
3955 return observed_input_representation_[index]; 3955 return observed_input_representation_[index];
3956 } 3956 }
3957 virtual void PrintDataTo(StringStream* stream); 3957 virtual void PrintDataTo(StringStream* stream);
3958 3958
3959 virtual void AddInformativeDefinitions(); 3959 virtual void AddInformativeDefinitions();
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
4556 4556
4557 virtual Representation RequiredInputRepresentation(int index) { 4557 virtual Representation RequiredInputRepresentation(int index) {
4558 return index == 0 ? Representation::Tagged() 4558 return index == 0 ? Representation::Tagged()
4559 : representation(); 4559 : representation();
4560 } 4560 }
4561 4561
4562 virtual Representation observed_input_representation(int index) { 4562 virtual Representation observed_input_representation(int index) {
4563 return RequiredInputRepresentation(index); 4563 return RequiredInputRepresentation(index);
4564 } 4564 }
4565 4565
4566 virtual void InferRepresentation(HInferRepresentation* h_infer); 4566 virtual void InferRepresentation(HInferRepresentationPhase* h_infer);
4567 4567
4568 virtual Representation RepresentationFromInputs() { 4568 virtual Representation RepresentationFromInputs() {
4569 Representation left_rep = left()->representation(); 4569 Representation left_rep = left()->representation();
4570 Representation right_rep = right()->representation(); 4570 Representation right_rep = right()->representation();
4571 if ((left_rep.IsNone() || left_rep.IsInteger32()) && 4571 if ((left_rep.IsNone() || left_rep.IsInteger32()) &&
4572 (right_rep.IsNone() || right_rep.IsInteger32())) { 4572 (right_rep.IsNone() || right_rep.IsInteger32())) {
4573 return Representation::Integer32(); 4573 return Representation::Integer32();
4574 } 4574 }
4575 return Representation::Double(); 4575 return Representation::Double();
4576 } 4576 }
(...skipping 2064 matching lines...) Expand 10 before | Expand all | Expand 10 after
6641 virtual bool IsDeletable() const { return true; } 6641 virtual bool IsDeletable() const { return true; }
6642 }; 6642 };
6643 6643
6644 6644
6645 #undef DECLARE_INSTRUCTION 6645 #undef DECLARE_INSTRUCTION
6646 #undef DECLARE_CONCRETE_INSTRUCTION 6646 #undef DECLARE_CONCRETE_INSTRUCTION
6647 6647
6648 } } // namespace v8::internal 6648 } } // namespace v8::internal
6649 6649
6650 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 6650 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW
« no previous file with comments | « src/hydrogen.cc ('k') | src/hydrogen-instructions.cc » ('j') | src/hydrogen-phases.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698