Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 81 V(CallGlobal) \ | 81 V(CallGlobal) \ |
| 82 V(CallKeyed) \ | 82 V(CallKeyed) \ |
| 83 V(CallKnownGlobal) \ | 83 V(CallKnownGlobal) \ |
| 84 V(CallNamed) \ | 84 V(CallNamed) \ |
| 85 V(CallNew) \ | 85 V(CallNew) \ |
| 86 V(CallNewArray) \ | 86 V(CallNewArray) \ |
| 87 V(CallRuntime) \ | 87 V(CallRuntime) \ |
| 88 V(CallStub) \ | 88 V(CallStub) \ |
| 89 V(Change) \ | 89 V(Change) \ |
| 90 V(CheckFunction) \ | 90 V(CheckFunction) \ |
| 91 V(CheckHeapObject) \ | |
| 91 V(CheckInstanceType) \ | 92 V(CheckInstanceType) \ |
| 92 V(CheckMaps) \ | 93 V(CheckMaps) \ |
| 93 V(CheckNonSmi) \ | |
| 94 V(CheckPrototypeMaps) \ | 94 V(CheckPrototypeMaps) \ |
| 95 V(ClampToUint8) \ | 95 V(ClampToUint8) \ |
| 96 V(ClassOfTestAndBranch) \ | 96 V(ClassOfTestAndBranch) \ |
| 97 V(CompareIDAndBranch) \ | 97 V(CompareIDAndBranch) \ |
| 98 V(CompareGeneric) \ | 98 V(CompareGeneric) \ |
| 99 V(CompareObjectEqAndBranch) \ | 99 V(CompareObjectEqAndBranch) \ |
| 100 V(CompareMap) \ | 100 V(CompareMap) \ |
| 101 V(CompareConstantEqAndBranch) \ | 101 V(CompareConstantEqAndBranch) \ |
| 102 V(Constant) \ | 102 V(Constant) \ |
| 103 V(Context) \ | 103 V(Context) \ |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 426 ASSERT(type_ != kUninitialized); | 426 ASSERT(type_ != kUninitialized); |
| 427 return ((type_ & kJSObject) == kJSObject); | 427 return ((type_ & kJSObject) == kJSObject); |
| 428 } | 428 } |
| 429 | 429 |
| 430 bool IsUninitialized() const { | 430 bool IsUninitialized() const { |
| 431 return type_ == kUninitialized; | 431 return type_ == kUninitialized; |
| 432 } | 432 } |
| 433 | 433 |
| 434 bool IsHeapObject() const { | 434 bool IsHeapObject() const { |
| 435 ASSERT(type_ != kUninitialized); | 435 ASSERT(type_ != kUninitialized); |
| 436 return IsHeapNumber() || IsString() || IsNonPrimitive(); | 436 return IsHeapNumber() || IsString() || IsBoolean() || IsNonPrimitive(); |
| 437 } | 437 } |
| 438 | 438 |
| 439 static HType TypeFromValue(Handle<Object> value); | 439 static HType TypeFromValue(Handle<Object> value); |
| 440 | 440 |
| 441 const char* ToString(); | 441 const char* ToString(); |
| 442 | 442 |
| 443 private: | 443 private: |
| 444 enum Type { | 444 enum Type { |
| 445 kTagged = 0x1, // 0000 0000 0000 0001 | 445 kTagged = 0x1, // 0000 0000 0000 0001 |
| 446 kTaggedPrimitive = 0x5, // 0000 0000 0000 0101 | 446 kTaggedPrimitive = 0x5, // 0000 0000 0000 0101 |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 908 } | 908 } |
| 909 return r; | 909 return r; |
| 910 } | 910 } |
| 911 | 911 |
| 912 HType type() const { return type_; } | 912 HType type() const { return type_; } |
| 913 void set_type(HType new_type) { | 913 void set_type(HType new_type) { |
| 914 ASSERT(new_type.IsSubtypeOf(type_)); | 914 ASSERT(new_type.IsSubtypeOf(type_)); |
| 915 type_ = new_type; | 915 type_ = new_type; |
| 916 } | 916 } |
| 917 | 917 |
| 918 bool IsHeapObject() { | |
| 919 return representation_.IsHeapObject() || type_.IsHeapObject(); | |
|
ulan
2013/06/20 07:53:54
I am not sure that this guarantees that we can saf
Toon Verwaest
2013/06/20 12:38:42
This is safe. representation_.IsHeapObject() never
| |
| 920 } | |
| 921 | |
| 918 // An operation needs to override this function iff: | 922 // An operation needs to override this function iff: |
| 919 // 1) it can produce an int32 output. | 923 // 1) it can produce an int32 output. |
| 920 // 2) the true value of its output can potentially be minus zero. | 924 // 2) the true value of its output can potentially be minus zero. |
| 921 // The implementation must set a flag so that it bails out in the case where | 925 // The implementation must set a flag so that it bails out in the case where |
| 922 // it would otherwise output what should be a minus zero as an int32 zero. | 926 // it would otherwise output what should be a minus zero as an int32 zero. |
| 923 // If the operation also exists in a form that takes int32 and outputs int32 | 927 // If the operation also exists in a form that takes int32 and outputs int32 |
| 924 // then the operation should return its input value so that we can propagate | 928 // then the operation should return its input value so that we can propagate |
| 925 // back. There are three operations that need to propagate back to more than | 929 // back. There are three operations that need to propagate back to more than |
| 926 // one input. They are phi and binary div and mul. They always return NULL | 930 // one input. They are phi and binary div and mul. They always return NULL |
| 927 // and expect the caller to take care of things. | 931 // and expect the caller to take care of things. |
| (...skipping 2006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2934 HCheckInstanceType(HValue* value, Check check) | 2938 HCheckInstanceType(HValue* value, Check check) |
| 2935 : HUnaryOperation(value), check_(check) { | 2939 : HUnaryOperation(value), check_(check) { |
| 2936 set_representation(Representation::Tagged()); | 2940 set_representation(Representation::Tagged()); |
| 2937 SetFlag(kUseGVN); | 2941 SetFlag(kUseGVN); |
| 2938 } | 2942 } |
| 2939 | 2943 |
| 2940 const Check check_; | 2944 const Check check_; |
| 2941 }; | 2945 }; |
| 2942 | 2946 |
| 2943 | 2947 |
| 2944 class HCheckNonSmi: public HUnaryOperation { | 2948 class HCheckHeapObject: public HUnaryOperation { |
| 2945 public: | 2949 public: |
| 2946 explicit HCheckNonSmi(HValue* value) : HUnaryOperation(value) { | 2950 explicit HCheckHeapObject(HValue* value) : HUnaryOperation(value) { |
| 2947 set_representation(Representation::Tagged()); | 2951 set_representation(Representation::Tagged()); |
| 2948 SetFlag(kUseGVN); | 2952 SetFlag(kUseGVN); |
| 2949 } | 2953 } |
| 2950 | 2954 |
| 2951 virtual Representation RequiredInputRepresentation(int index) { | 2955 virtual Representation RequiredInputRepresentation(int index) { |
| 2952 return Representation::Tagged(); | 2956 return Representation::Tagged(); |
| 2953 } | 2957 } |
| 2954 | 2958 |
| 2955 virtual HType CalculateInferredType(); | 2959 virtual HType CalculateInferredType(); |
| 2956 | 2960 |
| 2957 #ifdef DEBUG | 2961 #ifdef DEBUG |
| 2958 virtual void Verify(); | 2962 virtual void Verify(); |
| 2959 #endif | 2963 #endif |
| 2960 | 2964 |
| 2961 virtual HValue* Canonicalize() { | 2965 virtual HValue* Canonicalize() { |
| 2962 HType value_type = value()->type(); | 2966 HType value_type = value()->type(); |
| 2963 if (!value_type.IsUninitialized() && | 2967 if (!value_type.IsUninitialized() && value_type.IsHeapObject()) { |
| 2964 (value_type.IsHeapNumber() || | |
| 2965 value_type.IsString() || | |
| 2966 value_type.IsBoolean() || | |
| 2967 value_type.IsNonPrimitive())) { | |
| 2968 return NULL; | 2968 return NULL; |
| 2969 } | 2969 } |
| 2970 return this; | 2970 return this; |
| 2971 } | 2971 } |
| 2972 | 2972 |
| 2973 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi) | 2973 DECLARE_CONCRETE_INSTRUCTION(CheckHeapObject) |
| 2974 | 2974 |
| 2975 protected: | 2975 protected: |
| 2976 virtual bool DataEquals(HValue* other) { return true; } | 2976 virtual bool DataEquals(HValue* other) { return true; } |
| 2977 }; | 2977 }; |
| 2978 | 2978 |
| 2979 | 2979 |
| 2980 class HCheckPrototypeMaps: public HTemplateInstruction<0> { | 2980 class HCheckPrototypeMaps: public HTemplateInstruction<0> { |
| 2981 public: | 2981 public: |
| 2982 HCheckPrototypeMaps(Handle<JSObject> prototype, | 2982 HCheckPrototypeMaps(Handle<JSObject> prototype, |
| 2983 Handle<JSObject> holder, | 2983 Handle<JSObject> holder, |
| (...skipping 3624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6608 virtual bool IsDeletable() const { return true; } | 6608 virtual bool IsDeletable() const { return true; } |
| 6609 }; | 6609 }; |
| 6610 | 6610 |
| 6611 | 6611 |
| 6612 #undef DECLARE_INSTRUCTION | 6612 #undef DECLARE_INSTRUCTION |
| 6613 #undef DECLARE_CONCRETE_INSTRUCTION | 6613 #undef DECLARE_CONCRETE_INSTRUCTION |
| 6614 | 6614 |
| 6615 } } // namespace v8::internal | 6615 } } // namespace v8::internal |
| 6616 | 6616 |
| 6617 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 6617 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
| OLD | NEW |