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

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

Issue 12208013: Separated smi check from HBoundsCheck. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Removed platform specific code. Created 7 years, 10 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.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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 V(CallNew) \ 85 V(CallNew) \
86 V(CallRuntime) \ 86 V(CallRuntime) \
87 V(CallStub) \ 87 V(CallStub) \
88 V(Change) \ 88 V(Change) \
89 V(CheckFunction) \ 89 V(CheckFunction) \
90 V(CheckInstanceType) \ 90 V(CheckInstanceType) \
91 V(CheckMaps) \ 91 V(CheckMaps) \
92 V(CheckNonSmi) \ 92 V(CheckNonSmi) \
93 V(CheckPrototypeMaps) \ 93 V(CheckPrototypeMaps) \
94 V(CheckSmi) \ 94 V(CheckSmi) \
95 V(CheckSmiOrInt32) \
95 V(ClampToUint8) \ 96 V(ClampToUint8) \
96 V(ClassOfTestAndBranch) \ 97 V(ClassOfTestAndBranch) \
97 V(CompareIDAndBranch) \ 98 V(CompareIDAndBranch) \
98 V(CompareGeneric) \ 99 V(CompareGeneric) \
99 V(CompareObjectEqAndBranch) \ 100 V(CompareObjectEqAndBranch) \
100 V(CompareMap) \ 101 V(CompareMap) \
101 V(CompareConstantEqAndBranch) \ 102 V(CompareConstantEqAndBranch) \
102 V(Constant) \ 103 V(Constant) \
103 V(Context) \ 104 V(Context) \
104 V(DeclareGlobals) \ 105 V(DeclareGlobals) \
(...skipping 2500 matching lines...) Expand 10 before | Expand all | Expand 10 after
2605 virtual void Verify(); 2606 virtual void Verify();
2606 #endif 2607 #endif
2607 2608
2608 DECLARE_CONCRETE_INSTRUCTION(CheckSmi) 2609 DECLARE_CONCRETE_INSTRUCTION(CheckSmi)
2609 2610
2610 protected: 2611 protected:
2611 virtual bool DataEquals(HValue* other) { return true; } 2612 virtual bool DataEquals(HValue* other) { return true; }
2612 }; 2613 };
2613 2614
2614 2615
2616 class HCheckSmiOrInt32: public HUnaryOperation {
2617 public:
2618 explicit HCheckSmiOrInt32(HValue* value) : HUnaryOperation(value) {
2619 SetFlag(kFlexibleRepresentation);
2620 SetFlag(kUseGVN);
2621 }
2622
2623 virtual int RedefinedOperandIndex() { return 0; }
2624 virtual Representation RequiredInputRepresentation(int index) {
2625 return representation();
2626 }
2627 virtual void InferRepresentation(HInferRepresentation* h_infer);
2628
2629 virtual HValue* Canonicalize() {
2630 if (representation().IsTagged() && !type().IsSmi()) {
2631 return this;
2632 } else {
2633 return value();
2634 }
2635 }
2636
2637 DECLARE_CONCRETE_INSTRUCTION(CheckSmiOrInt32)
2638
2639 protected:
2640 virtual bool DataEquals(HValue* other) { return true; }
2641 };
2642
2643
2615 class HPhi: public HValue { 2644 class HPhi: public HValue {
2616 public: 2645 public:
2617 HPhi(int merged_index, Zone* zone) 2646 HPhi(int merged_index, Zone* zone)
2618 : inputs_(2, zone), 2647 : inputs_(2, zone),
2619 merged_index_(merged_index), 2648 merged_index_(merged_index),
2620 phi_id_(-1), 2649 phi_id_(-1),
2621 is_live_(false), 2650 is_live_(false),
2622 is_convertible_to_integer_(true) { 2651 is_convertible_to_integer_(true) {
2623 for (int i = 0; i < Representation::kNumRepresentations; i++) { 2652 for (int i = 0; i < Representation::kNumRepresentations; i++) {
2624 non_phi_uses_[i] = 0; 2653 non_phi_uses_[i] = 0;
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
2800 virtual void PrintDataTo(StringStream* stream); 2829 virtual void PrintDataTo(StringStream* stream);
2801 virtual HType CalculateInferredType(); 2830 virtual HType CalculateInferredType();
2802 bool IsInteger() { return handle()->IsSmi(); } 2831 bool IsInteger() { return handle()->IsSmi(); }
2803 HConstant* CopyToRepresentation(Representation r, Zone* zone) const; 2832 HConstant* CopyToRepresentation(Representation r, Zone* zone) const;
2804 HConstant* CopyToTruncatedInt32(Zone* zone) const; 2833 HConstant* CopyToTruncatedInt32(Zone* zone) const;
2805 bool HasInteger32Value() const { return has_int32_value_; } 2834 bool HasInteger32Value() const { return has_int32_value_; }
2806 int32_t Integer32Value() const { 2835 int32_t Integer32Value() const {
2807 ASSERT(HasInteger32Value()); 2836 ASSERT(HasInteger32Value());
2808 return int32_value_; 2837 return int32_value_;
2809 } 2838 }
2839 bool HasSmiValue() const {
2840 return HasInteger32Value() && Smi::IsValid(Integer32Value());
2841 }
2810 bool HasDoubleValue() const { return has_double_value_; } 2842 bool HasDoubleValue() const { return has_double_value_; }
2811 double DoubleValue() const { 2843 double DoubleValue() const {
2812 ASSERT(HasDoubleValue()); 2844 ASSERT(HasDoubleValue());
2813 return double_value_; 2845 return double_value_;
2814 } 2846 }
2815 bool HasNumberValue() const { return has_double_value_; } 2847 bool HasNumberValue() const { return has_double_value_; }
2816 int32_t NumberValueAsInteger32() const { 2848 int32_t NumberValueAsInteger32() const {
2817 ASSERT(HasNumberValue()); 2849 ASSERT(HasNumberValue());
2818 // Irrespective of whether a numeric HConstant can be safely 2850 // Irrespective of whether a numeric HConstant can be safely
2819 // represented as an int32, we store the (in some cases lossy) 2851 // represented as an int32, we store the (in some cases lossy)
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
3081 3113
3082 3114
3083 enum BoundsCheckKeyMode { 3115 enum BoundsCheckKeyMode {
3084 DONT_ALLOW_SMI_KEY, 3116 DONT_ALLOW_SMI_KEY,
3085 ALLOW_SMI_KEY 3117 ALLOW_SMI_KEY
3086 }; 3118 };
3087 3119
3088 3120
3089 class HBoundsCheck: public HTemplateInstruction<2> { 3121 class HBoundsCheck: public HTemplateInstruction<2> {
3090 public: 3122 public:
3091 HBoundsCheck(HValue* index, HValue* length, 3123 // Normally HBoundsCheck should be created using the
3124 // HGraphBuilder::AddBoundsCheck() helper, which also guards the index with
3125 // a HCheckSmiOrInt32 check.
3126 // However when building stubs, where we know that the arguments are Int32,
3127 // it makes sense to invoke this constructor directly.
3128 HBoundsCheck(HValue* index,
3129 HValue* length,
3092 BoundsCheckKeyMode key_mode = DONT_ALLOW_SMI_KEY, 3130 BoundsCheckKeyMode key_mode = DONT_ALLOW_SMI_KEY,
3093 Representation r = Representation::None()) 3131 Representation r = Representation::None())
3094 : key_mode_(key_mode) { 3132 : key_mode_(key_mode), skip_check_(false) {
3095 SetOperandAt(0, index); 3133 SetOperandAt(0, index);
3096 SetOperandAt(1, length); 3134 SetOperandAt(1, length);
3097 if (r.IsNone()) { 3135 if (r.IsNone()) {
3098 // In the normal compilation pipeline the representation is flexible 3136 // In the normal compilation pipeline the representation is flexible
3099 // (see comment to RequiredInputRepresentation). 3137 // (see InferRepresentation).
3100 SetFlag(kFlexibleRepresentation); 3138 SetFlag(kFlexibleRepresentation);
3101 } else { 3139 } else {
3102 // When compiling stubs we want to set the representation explicitly 3140 // When compiling stubs we want to set the representation explicitly
3103 // so the compilation pipeline can skip the HInferRepresentation phase. 3141 // so the compilation pipeline can skip the HInferRepresentation phase.
3104 set_representation(r); 3142 set_representation(r);
3105 } 3143 }
3106 SetFlag(kUseGVN); 3144 SetFlag(kUseGVN);
3107 } 3145 }
3108 3146
3147 bool skip_check() { return skip_check_; }
3148 void set_skip_check(bool skip_check) { skip_check_ = skip_check; }
3149
3109 virtual Representation RequiredInputRepresentation(int arg_index) { 3150 virtual Representation RequiredInputRepresentation(int arg_index) {
3110 return representation(); 3151 return representation();
3111 } 3152 }
3112 virtual Representation observed_input_representation(int index) { 3153 virtual Representation observed_input_representation(int index) {
3113 return Representation::Integer32(); 3154 return Representation::Integer32();
3114 } 3155 }
3115 3156
3116 virtual void PrintDataTo(StringStream* stream); 3157 virtual void PrintDataTo(StringStream* stream);
3117 virtual void InferRepresentation(HInferRepresentation* h_infer); 3158 virtual void InferRepresentation(HInferRepresentation* h_infer);
3118 3159
3119 HValue* index() { return OperandAt(0); } 3160 HValue* index() { return OperandAt(0); }
3120 HValue* length() { return OperandAt(1); } 3161 HValue* length() { return OperandAt(1); }
3121 3162
3122 virtual int RedefinedOperandIndex() { return 0; } 3163 virtual int RedefinedOperandIndex() { return 0; }
3123 3164
3124 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck) 3165 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck)
3125 3166
3126 protected: 3167 protected:
3127 virtual bool DataEquals(HValue* other) { return true; } 3168 virtual bool DataEquals(HValue* other) { return true; }
3128 BoundsCheckKeyMode key_mode_; 3169 BoundsCheckKeyMode key_mode_;
3170 bool skip_check_;
3129 }; 3171 };
3130 3172
3131 3173
3132 class HBitwiseBinaryOperation: public HBinaryOperation { 3174 class HBitwiseBinaryOperation: public HBinaryOperation {
3133 public: 3175 public:
3134 HBitwiseBinaryOperation(HValue* context, HValue* left, HValue* right) 3176 HBitwiseBinaryOperation(HValue* context, HValue* left, HValue* right)
3135 : HBinaryOperation(context, left, right) { 3177 : HBinaryOperation(context, left, right) {
3136 SetFlag(kFlexibleRepresentation); 3178 SetFlag(kFlexibleRepresentation);
3137 SetFlag(kTruncatingToInt32); 3179 SetFlag(kTruncatingToInt32);
3138 SetAllSideEffects(); 3180 SetAllSideEffects();
(...skipping 2604 matching lines...) Expand 10 before | Expand all | Expand 10 after
5743 virtual bool IsDeletable() const { return true; } 5785 virtual bool IsDeletable() const { return true; }
5744 }; 5786 };
5745 5787
5746 5788
5747 #undef DECLARE_INSTRUCTION 5789 #undef DECLARE_INSTRUCTION
5748 #undef DECLARE_CONCRETE_INSTRUCTION 5790 #undef DECLARE_CONCRETE_INSTRUCTION
5749 5791
5750 } } // namespace v8::internal 5792 } } // namespace v8::internal
5751 5793
5752 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 5794 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW
« no previous file with comments | « src/hydrogen.cc ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698