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

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: Addressed review comments. 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
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 #ifdef DEBUG
2630 virtual void Verify();
2631 #endif
2632
2633 DECLARE_CONCRETE_INSTRUCTION(CheckSmiOrInt32)
2634
2635 protected:
2636 virtual bool DataEquals(HValue* other) { return true; }
2637 };
2638
2639
2615 class HPhi: public HValue { 2640 class HPhi: public HValue {
2616 public: 2641 public:
2617 HPhi(int merged_index, Zone* zone) 2642 HPhi(int merged_index, Zone* zone)
2618 : inputs_(2, zone), 2643 : inputs_(2, zone),
2619 merged_index_(merged_index), 2644 merged_index_(merged_index),
2620 phi_id_(-1), 2645 phi_id_(-1),
2621 is_live_(false), 2646 is_live_(false),
2622 is_convertible_to_integer_(true) { 2647 is_convertible_to_integer_(true) {
2623 for (int i = 0; i < Representation::kNumRepresentations; i++) { 2648 for (int i = 0; i < Representation::kNumRepresentations; i++) {
2624 non_phi_uses_[i] = 0; 2649 non_phi_uses_[i] = 0;
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
2800 virtual void PrintDataTo(StringStream* stream); 2825 virtual void PrintDataTo(StringStream* stream);
2801 virtual HType CalculateInferredType(); 2826 virtual HType CalculateInferredType();
2802 bool IsInteger() { return handle()->IsSmi(); } 2827 bool IsInteger() { return handle()->IsSmi(); }
2803 HConstant* CopyToRepresentation(Representation r, Zone* zone) const; 2828 HConstant* CopyToRepresentation(Representation r, Zone* zone) const;
2804 HConstant* CopyToTruncatedInt32(Zone* zone) const; 2829 HConstant* CopyToTruncatedInt32(Zone* zone) const;
2805 bool HasInteger32Value() const { return has_int32_value_; } 2830 bool HasInteger32Value() const { return has_int32_value_; }
2806 int32_t Integer32Value() const { 2831 int32_t Integer32Value() const {
2807 ASSERT(HasInteger32Value()); 2832 ASSERT(HasInteger32Value());
2808 return int32_value_; 2833 return int32_value_;
2809 } 2834 }
2835 bool HasSmiValue() const {
2836 return HasInteger32Value() && Smi::IsValid(Integer32Value());
2837 }
2810 bool HasDoubleValue() const { return has_double_value_; } 2838 bool HasDoubleValue() const { return has_double_value_; }
2811 double DoubleValue() const { 2839 double DoubleValue() const {
2812 ASSERT(HasDoubleValue()); 2840 ASSERT(HasDoubleValue());
2813 return double_value_; 2841 return double_value_;
2814 } 2842 }
2815 bool HasNumberValue() const { return has_double_value_; } 2843 bool HasNumberValue() const { return has_double_value_; }
2816 int32_t NumberValueAsInteger32() const { 2844 int32_t NumberValueAsInteger32() const {
2817 ASSERT(HasNumberValue()); 2845 ASSERT(HasNumberValue());
2818 // Irrespective of whether a numeric HConstant can be safely 2846 // Irrespective of whether a numeric HConstant can be safely
2819 // represented as an int32, we store the (in some cases lossy) 2847 // represented as an int32, we store the (in some cases lossy)
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
3079 virtual bool DataEquals(HValue* other) { return true; } 3107 virtual bool DataEquals(HValue* other) { return true; }
3080 }; 3108 };
3081 3109
3082 3110
3083 enum BoundsCheckKeyMode { 3111 enum BoundsCheckKeyMode {
3084 DONT_ALLOW_SMI_KEY, 3112 DONT_ALLOW_SMI_KEY,
3085 ALLOW_SMI_KEY 3113 ALLOW_SMI_KEY
3086 }; 3114 };
3087 3115
3088 3116
3117 class HGraphBuilder;
Jakob Kummerow 2013/02/07 16:17:14 still there?
Massi 2013/02/11 10:35:55 Done.
3118
3119
3089 class HBoundsCheck: public HTemplateInstruction<2> { 3120 class HBoundsCheck: public HTemplateInstruction<2> {
3090 public: 3121 public:
3122 // Normally HBoundsCheck should be created using the
3123 // HGraphBuilder::AddBoundsCheck() helper, which also guards the index with
3124 // a HCheckSmiOrInt32 check.
3125 // However when building stubs, where we know that the arguments are Int32,
3126 // it makes sense to invoke this constructor directly.
3091 HBoundsCheck(HValue* index, HValue* length, 3127 HBoundsCheck(HValue* index, HValue* length,
Jakob Kummerow 2013/02/07 16:17:14 nit: in function/method/ctor definitions (as oppos
Massi 2013/02/11 10:35:55 Done.
3092 BoundsCheckKeyMode key_mode = DONT_ALLOW_SMI_KEY, 3128 BoundsCheckKeyMode key_mode = DONT_ALLOW_SMI_KEY,
3093 Representation r = Representation::None()) 3129 Representation r = Representation::None())
3094 : key_mode_(key_mode) { 3130 : key_mode_(key_mode), skip_check_(false) {
Jakob Kummerow 2013/02/07 16:17:14 nit: now I want less indentation here :-) (the ':'
Massi 2013/02/11 10:35:55 Done.
3095 SetOperandAt(0, index); 3131 SetOperandAt(0, index);
3096 SetOperandAt(1, length); 3132 SetOperandAt(1, length);
3097 if (r.IsNone()) { 3133 if (r.IsNone()) {
3098 // In the normal compilation pipeline the representation is flexible 3134 // In the normal compilation pipeline the representation is flexible
3099 // (see comment to RequiredInputRepresentation). 3135 // (see InferRepresentation).
3100 SetFlag(kFlexibleRepresentation); 3136 SetFlag(kFlexibleRepresentation);
3101 } else { 3137 } else {
3102 // When compiling stubs we want to set the representation explicitly 3138 // When compiling stubs we want to set the representation explicitly
3103 // so the compilation pipeline can skip the HInferRepresentation phase. 3139 // so the compilation pipeline can skip the HInferRepresentation phase.
3104 set_representation(r); 3140 set_representation(r);
3105 } 3141 }
3106 SetFlag(kUseGVN); 3142 SetFlag(kUseGVN);
3107 } 3143 }
3108 3144
3145 bool skip_check() { return skip_check_; }
3146 void set_skip_check(bool skip_check) { skip_check_ = skip_check; }
3147
3109 virtual Representation RequiredInputRepresentation(int arg_index) { 3148 virtual Representation RequiredInputRepresentation(int arg_index) {
3110 return representation(); 3149 return representation();
3111 } 3150 }
3112 virtual Representation observed_input_representation(int index) { 3151 virtual Representation observed_input_representation(int index) {
3113 return Representation::Integer32(); 3152 return Representation::Integer32();
3114 } 3153 }
3115 3154
3116 virtual void PrintDataTo(StringStream* stream); 3155 virtual void PrintDataTo(StringStream* stream);
Jakob Kummerow 2013/02/07 16:17:14 I don't see an implementation of this. I guess ove
Massi 2013/02/11 10:35:55 HBoundsCheck::PrintDataTo and HBoundsCheck::InferR
3117 virtual void InferRepresentation(HInferRepresentation* h_infer); 3156 virtual void InferRepresentation(HInferRepresentation* h_infer);
3118 3157
3119 HValue* index() { return OperandAt(0); } 3158 HValue* index() { return OperandAt(0); }
3120 HValue* length() { return OperandAt(1); } 3159 HValue* length() { return OperandAt(1); }
3121 3160
3122 virtual int RedefinedOperandIndex() { return 0; } 3161 virtual int RedefinedOperandIndex() { return 0; }
3123 3162
3124 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck) 3163 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck)
3125 3164
3126 protected: 3165 protected:
3127 virtual bool DataEquals(HValue* other) { return true; } 3166 virtual bool DataEquals(HValue* other) { return true; }
3128 BoundsCheckKeyMode key_mode_; 3167 BoundsCheckKeyMode key_mode_;
3168 bool skip_check_;
3129 }; 3169 };
3130 3170
3131 3171
3132 class HBitwiseBinaryOperation: public HBinaryOperation { 3172 class HBitwiseBinaryOperation: public HBinaryOperation {
3133 public: 3173 public:
3134 HBitwiseBinaryOperation(HValue* context, HValue* left, HValue* right) 3174 HBitwiseBinaryOperation(HValue* context, HValue* left, HValue* right)
3135 : HBinaryOperation(context, left, right) { 3175 : HBinaryOperation(context, left, right) {
3136 SetFlag(kFlexibleRepresentation); 3176 SetFlag(kFlexibleRepresentation);
3137 SetFlag(kTruncatingToInt32); 3177 SetFlag(kTruncatingToInt32);
3138 SetAllSideEffects(); 3178 SetAllSideEffects();
(...skipping 2604 matching lines...) Expand 10 before | Expand all | Expand 10 after
5743 virtual bool IsDeletable() const { return true; } 5783 virtual bool IsDeletable() const { return true; }
5744 }; 5784 };
5745 5785
5746 5786
5747 #undef DECLARE_INSTRUCTION 5787 #undef DECLARE_INSTRUCTION
5748 #undef DECLARE_CONCRETE_INSTRUCTION 5788 #undef DECLARE_CONCRETE_INSTRUCTION
5749 5789
5750 } } // namespace v8::internal 5790 } } // namespace v8::internal
5751 5791
5752 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 5792 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698