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

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

Issue 16240003: Improve smi support in crankshaft (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
« 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 867 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 ASSERT(CheckFlag(kFlexibleRepresentation)); 878 ASSERT(CheckFlag(kFlexibleRepresentation));
879 RepresentationChanged(r); 879 RepresentationChanged(r);
880 representation_ = r; 880 representation_ = r;
881 if (r.IsTagged()) { 881 if (r.IsTagged()) {
882 // Tagged is the bottom of the lattice, don't go any further. 882 // Tagged is the bottom of the lattice, don't go any further.
883 ClearFlag(kFlexibleRepresentation); 883 ClearFlag(kFlexibleRepresentation);
884 } 884 }
885 } 885 }
886 virtual void AssumeRepresentation(Representation r); 886 virtual void AssumeRepresentation(Representation r);
887 887
888 virtual bool IsConvertibleToInteger() const { return true; } 888 virtual Representation KnownOptimalRepresentation() {
889 Representation r = representation();
890 if (r.IsTagged()) {
891 HType t = type();
892 if (t.IsSmi()) return Representation::Smi();
893 if (t.IsHeapNumber()) return Representation::Double();
894 if (t.IsHeapObject()) return r;
895 return Representation::None();
896 }
897 return r;
898 }
889 899
890 HType type() const { return type_; } 900 HType type() const { return type_; }
891 void set_type(HType new_type) { 901 void set_type(HType new_type) {
892 ASSERT(new_type.IsSubtypeOf(type_)); 902 ASSERT(new_type.IsSubtypeOf(type_));
893 type_ = new_type; 903 type_ = new_type;
894 } 904 }
895 905
896 // An operation needs to override this function iff: 906 // An operation needs to override this function iff:
897 // 1) it can produce an int32 output. 907 // 1) it can produce an int32 output.
898 // 2) the true value of its output can potentially be minus zero. 908 // 2) the true value of its output can potentially be minus zero.
(...skipping 1543 matching lines...) Expand 10 before | Expand all | Expand 10 after
2442 2452
2443 private: 2453 private:
2444 virtual bool IsDeletable() const { return true; } 2454 virtual bool IsDeletable() const { return true; }
2445 }; 2455 };
2446 2456
2447 2457
2448 class HMapEnumLength: public HUnaryOperation { 2458 class HMapEnumLength: public HUnaryOperation {
2449 public: 2459 public:
2450 explicit HMapEnumLength(HValue* value) : HUnaryOperation(value) { 2460 explicit HMapEnumLength(HValue* value) : HUnaryOperation(value) {
2451 set_type(HType::Smi()); 2461 set_type(HType::Smi());
2452 set_representation(Representation::Tagged()); 2462 set_representation(Representation::Smi());
2453 SetFlag(kUseGVN); 2463 SetFlag(kUseGVN);
2454 SetGVNFlag(kDependsOnMaps); 2464 SetGVNFlag(kDependsOnMaps);
2455 } 2465 }
2456 2466
2457 virtual Representation RequiredInputRepresentation(int index) { 2467 virtual Representation RequiredInputRepresentation(int index) {
2458 return Representation::Tagged(); 2468 return Representation::Tagged();
2459 } 2469 }
2460 2470
2461 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength) 2471 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength)
2462 2472
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
2933 UniqueValueId first_prototype_unique_id_; 2943 UniqueValueId first_prototype_unique_id_;
2934 UniqueValueId last_prototype_unique_id_; 2944 UniqueValueId last_prototype_unique_id_;
2935 }; 2945 };
2936 2946
2937 2947
2938 class HPhi: public HValue { 2948 class HPhi: public HValue {
2939 public: 2949 public:
2940 HPhi(int merged_index, Zone* zone) 2950 HPhi(int merged_index, Zone* zone)
2941 : inputs_(2, zone), 2951 : inputs_(2, zone),
2942 merged_index_(merged_index), 2952 merged_index_(merged_index),
2943 phi_id_(-1), 2953 phi_id_(-1) {
2944 is_convertible_to_integer_(true) {
2945 for (int i = 0; i < Representation::kNumRepresentations; i++) { 2954 for (int i = 0; i < Representation::kNumRepresentations; i++) {
2946 non_phi_uses_[i] = 0; 2955 non_phi_uses_[i] = 0;
2947 indirect_uses_[i] = 0; 2956 indirect_uses_[i] = 0;
2948 } 2957 }
2949 ASSERT(merged_index >= 0); 2958 ASSERT(merged_index >= 0);
2950 SetFlag(kFlexibleRepresentation); 2959 SetFlag(kFlexibleRepresentation);
2951 SetFlag(kAllowUndefinedAsNaN); 2960 SetFlag(kAllowUndefinedAsNaN);
2952 } 2961 }
2953 2962
2954 virtual Representation RepresentationFromInputs(); 2963 virtual Representation RepresentationFromInputs();
2955 2964
2956 virtual Range* InferRange(Zone* zone); 2965 virtual Range* InferRange(Zone* zone);
2957 virtual void InferRepresentation(HInferRepresentation* h_infer); 2966 virtual void InferRepresentation(HInferRepresentation* h_infer);
2958 Representation RepresentationFromUseRequirements(); 2967 Representation RepresentationFromUseRequirements();
2959 virtual Representation RequiredInputRepresentation(int index) { 2968 virtual Representation RequiredInputRepresentation(int index) {
2960 return representation(); 2969 return representation();
2961 } 2970 }
2971 virtual Representation KnownOptimalRepresentation() {
2972 return representation();
2973 }
2962 virtual HType CalculateInferredType(); 2974 virtual HType CalculateInferredType();
2963 virtual int OperandCount() { return inputs_.length(); } 2975 virtual int OperandCount() { return inputs_.length(); }
2964 virtual HValue* OperandAt(int index) const { return inputs_[index]; } 2976 virtual HValue* OperandAt(int index) const { return inputs_[index]; }
2965 HValue* GetRedundantReplacement(); 2977 HValue* GetRedundantReplacement();
2966 void AddInput(HValue* value); 2978 void AddInput(HValue* value);
2967 bool HasRealUses(); 2979 bool HasRealUses();
2968 2980
2969 bool IsReceiver() const { return merged_index_ == 0; } 2981 bool IsReceiver() const { return merged_index_ == 0; }
2970 2982
2971 int merged_index() const { return merged_index_; } 2983 int merged_index() const { return merged_index_; }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
3007 return indirect_uses_[Representation::kDouble]; 3019 return indirect_uses_[Representation::kDouble];
3008 } 3020 }
3009 int phi_id() { return phi_id_; } 3021 int phi_id() { return phi_id_; }
3010 3022
3011 static HPhi* cast(HValue* value) { 3023 static HPhi* cast(HValue* value) {
3012 ASSERT(value->IsPhi()); 3024 ASSERT(value->IsPhi());
3013 return reinterpret_cast<HPhi*>(value); 3025 return reinterpret_cast<HPhi*>(value);
3014 } 3026 }
3015 virtual Opcode opcode() const { return HValue::kPhi; } 3027 virtual Opcode opcode() const { return HValue::kPhi; }
3016 3028
3017 virtual bool IsConvertibleToInteger() const {
3018 return is_convertible_to_integer_;
3019 }
3020
3021 void set_is_convertible_to_integer(bool b) {
3022 is_convertible_to_integer_ = b;
3023 }
3024
3025 bool AllOperandsConvertibleToInteger() {
3026 for (int i = 0; i < OperandCount(); ++i) {
3027 if (!OperandAt(i)->IsConvertibleToInteger()) {
3028 if (FLAG_trace_representation) {
3029 HValue* input = OperandAt(i);
3030 PrintF("#%d %s: Input #%d %s at %d is NCTI\n",
3031 id(), Mnemonic(), input->id(), input->Mnemonic(), i);
3032 }
3033 return false;
3034 }
3035 }
3036 return true;
3037 }
3038
3039 void SimplifyConstantInputs(); 3029 void SimplifyConstantInputs();
3040 3030
3041 // TODO(titzer): we can't eliminate the receiver for generating backtraces 3031 // TODO(titzer): we can't eliminate the receiver for generating backtraces
3042 virtual bool IsDeletable() const { return !IsReceiver(); } 3032 virtual bool IsDeletable() const { return !IsReceiver(); }
3043 3033
3044 protected: 3034 protected:
3045 virtual void DeleteFromGraph(); 3035 virtual void DeleteFromGraph();
3046 virtual void InternalSetOperandAt(int index, HValue* value) { 3036 virtual void InternalSetOperandAt(int index, HValue* value) {
3047 inputs_[index] = value; 3037 inputs_[index] = value;
3048 } 3038 }
3049 3039
3050 virtual bool IsRelationTrueInternal(NumericRelation relation, 3040 virtual bool IsRelationTrueInternal(NumericRelation relation,
3051 HValue* other, 3041 HValue* other,
3052 int offset = 0, 3042 int offset = 0,
3053 int scale = 0); 3043 int scale = 0);
3054 3044
3055 private: 3045 private:
3056 ZoneList<HValue*> inputs_; 3046 ZoneList<HValue*> inputs_;
3057 int merged_index_; 3047 int merged_index_;
3058 3048
3059 int non_phi_uses_[Representation::kNumRepresentations]; 3049 int non_phi_uses_[Representation::kNumRepresentations];
3060 int indirect_uses_[Representation::kNumRepresentations]; 3050 int indirect_uses_[Representation::kNumRepresentations];
3061 int phi_id_; 3051 int phi_id_;
3062 bool is_convertible_to_integer_;
3063 }; 3052 };
3064 3053
3065 3054
3066 class HInductionVariableAnnotation : public HUnaryOperation { 3055 class HInductionVariableAnnotation : public HUnaryOperation {
3067 public: 3056 public:
3068 static HInductionVariableAnnotation* AddToGraph(HPhi* phi, 3057 static HInductionVariableAnnotation* AddToGraph(HPhi* phi,
3069 NumericRelation relation, 3058 NumericRelation relation,
3070 int operand_index); 3059 int operand_index);
3071 3060
3072 NumericRelation relation() { return relation_; } 3061 NumericRelation relation() { return relation_; }
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
3189 unique_id_ == UniqueValueId(heap->true_value()) || 3178 unique_id_ == UniqueValueId(heap->true_value()) ||
3190 unique_id_ == UniqueValueId(heap->false_value()) || 3179 unique_id_ == UniqueValueId(heap->false_value()) ||
3191 unique_id_ == UniqueValueId(heap->the_hole_value()) || 3180 unique_id_ == UniqueValueId(heap->the_hole_value()) ||
3192 unique_id_ == UniqueValueId(heap->empty_string()); 3181 unique_id_ == UniqueValueId(heap->empty_string());
3193 } 3182 }
3194 3183
3195 virtual Representation RequiredInputRepresentation(int index) { 3184 virtual Representation RequiredInputRepresentation(int index) {
3196 return Representation::None(); 3185 return Representation::None();
3197 } 3186 }
3198 3187
3199 virtual bool IsConvertibleToInteger() const { 3188 virtual Representation KnownOptimalRepresentation() {
3200 return has_int32_value_; 3189 if (HasSmiValue()) return Representation::Smi();
3190 if (HasInteger32Value()) return Representation::Integer32();
3191 if (HasNumberValue()) return Representation::Double();
3192 return Representation::Tagged();
3201 } 3193 }
3202 3194
3203 virtual bool EmitAtUses() { return !representation().IsDouble(); } 3195 virtual bool EmitAtUses() { return !representation().IsDouble(); }
3204 virtual void PrintDataTo(StringStream* stream); 3196 virtual void PrintDataTo(StringStream* stream);
3205 virtual HType CalculateInferredType(); 3197 virtual HType CalculateInferredType();
3206 bool IsInteger() { return handle()->IsSmi(); } 3198 bool IsInteger() { return handle()->IsSmi(); }
3207 HConstant* CopyToRepresentation(Representation r, Zone* zone) const; 3199 HConstant* CopyToRepresentation(Representation r, Zone* zone) const;
3208 HConstant* CopyToTruncatedInt32(Zone* zone) const; 3200 HConstant* CopyToTruncatedInt32(Zone* zone) const;
3209 bool HasInteger32Value() const { return has_int32_value_; } 3201 bool HasInteger32Value() const { return has_int32_value_; }
3210 int32_t Integer32Value() const { 3202 int32_t Integer32Value() const {
3211 ASSERT(HasInteger32Value()); 3203 ASSERT(HasInteger32Value());
3212 return int32_value_; 3204 return int32_value_;
3213 } 3205 }
3214 bool HasSmiValue() const { 3206 bool HasSmiValue() const { return has_smi_value_; }
3215 return has_smi_value_;
3216 }
3217 bool HasDoubleValue() const { return has_double_value_; } 3207 bool HasDoubleValue() const { return has_double_value_; }
3218 double DoubleValue() const { 3208 double DoubleValue() const {
3219 ASSERT(HasDoubleValue()); 3209 ASSERT(HasDoubleValue());
3220 return double_value_; 3210 return double_value_;
3221 } 3211 }
3222 bool IsTheHole() const { 3212 bool IsTheHole() const {
3223 if (HasDoubleValue() && FixedDoubleArray::is_the_hole_nan(double_value_)) { 3213 if (HasDoubleValue() && FixedDoubleArray::is_the_hole_nan(double_value_)) {
3224 return true; 3214 return true;
3225 } 3215 }
3226 Heap* heap = isolate()->heap(); 3216 Heap* heap = isolate()->heap();
(...skipping 1482 matching lines...) Expand 10 before | Expand all | Expand 10 after
4709 } 4699 }
4710 4700
4711 void set_incoming_value(HPhi* value) { 4701 void set_incoming_value(HPhi* value) {
4712 incoming_value_ = value; 4702 incoming_value_ = value;
4713 } 4703 }
4714 4704
4715 HPhi* incoming_value() { 4705 HPhi* incoming_value() {
4716 return incoming_value_; 4706 return incoming_value_;
4717 } 4707 }
4718 4708
4709 virtual Representation KnownOptimalRepresentation() {
4710 if (incoming_value_ == NULL) return Representation::None();
4711 return incoming_value_->KnownOptimalRepresentation();
4712 }
4713
4719 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue) 4714 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue)
4720 4715
4721 private: 4716 private:
4722 HPhi* incoming_value_; 4717 HPhi* incoming_value_;
4723 }; 4718 };
4724 4719
4725 4720
4726 class HLoadGlobalCell: public HTemplateInstruction<0> { 4721 class HLoadGlobalCell: public HTemplateInstruction<0> {
4727 public: 4722 public:
4728 HLoadGlobalCell(Handle<JSGlobalPropertyCell> cell, PropertyDetails details) 4723 HLoadGlobalCell(Handle<JSGlobalPropertyCell> cell, PropertyDetails details)
(...skipping 1771 matching lines...) Expand 10 before | Expand all | Expand 10 after
6500 virtual bool IsDeletable() const { return true; } 6495 virtual bool IsDeletable() const { return true; }
6501 }; 6496 };
6502 6497
6503 6498
6504 #undef DECLARE_INSTRUCTION 6499 #undef DECLARE_INSTRUCTION
6505 #undef DECLARE_CONCRETE_INSTRUCTION 6500 #undef DECLARE_CONCRETE_INSTRUCTION
6506 6501
6507 } } // namespace v8::internal 6502 } } // namespace v8::internal
6508 6503
6509 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 6504 #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