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

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

Issue 16026023: Avoid Unnecessary Smi Checks (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: address review 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 V(CallGlobal) \ 82 V(CallGlobal) \
83 V(CallKeyed) \ 83 V(CallKeyed) \
84 V(CallKnownGlobal) \ 84 V(CallKnownGlobal) \
85 V(CallNamed) \ 85 V(CallNamed) \
86 V(CallNew) \ 86 V(CallNew) \
87 V(CallNewArray) \ 87 V(CallNewArray) \
88 V(CallRuntime) \ 88 V(CallRuntime) \
89 V(CallStub) \ 89 V(CallStub) \
90 V(Change) \ 90 V(Change) \
91 V(CheckFunction) \ 91 V(CheckFunction) \
92 V(CheckHeapObject) \
92 V(CheckInstanceType) \ 93 V(CheckInstanceType) \
93 V(CheckMaps) \ 94 V(CheckMaps) \
94 V(CheckNonSmi) \
95 V(CheckPrototypeMaps) \ 95 V(CheckPrototypeMaps) \
96 V(ClampToUint8) \ 96 V(ClampToUint8) \
97 V(ClassOfTestAndBranch) \ 97 V(ClassOfTestAndBranch) \
98 V(CompareIDAndBranch) \ 98 V(CompareIDAndBranch) \
99 V(CompareGeneric) \ 99 V(CompareGeneric) \
100 V(CompareObjectEqAndBranch) \ 100 V(CompareObjectEqAndBranch) \
101 V(CompareMap) \ 101 V(CompareMap) \
102 V(CompareConstantEqAndBranch) \ 102 V(CompareConstantEqAndBranch) \
103 V(Constant) \ 103 V(Constant) \
104 V(Context) \ 104 V(Context) \
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 ASSERT(type_ != kUninitialized); 427 ASSERT(type_ != kUninitialized);
428 return ((type_ & kJSObject) == kJSObject); 428 return ((type_ & kJSObject) == kJSObject);
429 } 429 }
430 430
431 bool IsUninitialized() const { 431 bool IsUninitialized() const {
432 return type_ == kUninitialized; 432 return type_ == kUninitialized;
433 } 433 }
434 434
435 bool IsHeapObject() const { 435 bool IsHeapObject() const {
436 ASSERT(type_ != kUninitialized); 436 ASSERT(type_ != kUninitialized);
437 return IsHeapNumber() || IsString() || IsNonPrimitive(); 437 return IsHeapNumber() || IsString() || IsBoolean() || IsNonPrimitive();
438 } 438 }
439 439
440 static HType TypeFromValue(Handle<Object> value); 440 static HType TypeFromValue(Handle<Object> value);
441 441
442 const char* ToString(); 442 const char* ToString();
443 443
444 private: 444 private:
445 enum Type { 445 enum Type {
446 kTagged = 0x1, // 0000 0000 0000 0001 446 kTagged = 0x1, // 0000 0000 0000 0001
447 kTaggedPrimitive = 0x5, // 0000 0000 0000 0101 447 kTaggedPrimitive = 0x5, // 0000 0000 0000 0101
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 } 911 }
912 return r; 912 return r;
913 } 913 }
914 914
915 HType type() const { return type_; } 915 HType type() const { return type_; }
916 void set_type(HType new_type) { 916 void set_type(HType new_type) {
917 ASSERT(new_type.IsSubtypeOf(type_)); 917 ASSERT(new_type.IsSubtypeOf(type_));
918 type_ = new_type; 918 type_ = new_type;
919 } 919 }
920 920
921 bool IsHeapObject() {
922 return representation_.IsHeapObject() || type_.IsHeapObject();
923 }
924
921 // An operation needs to override this function iff: 925 // An operation needs to override this function iff:
922 // 1) it can produce an int32 output. 926 // 1) it can produce an int32 output.
923 // 2) the true value of its output can potentially be minus zero. 927 // 2) the true value of its output can potentially be minus zero.
924 // The implementation must set a flag so that it bails out in the case where 928 // The implementation must set a flag so that it bails out in the case where
925 // it would otherwise output what should be a minus zero as an int32 zero. 929 // it would otherwise output what should be a minus zero as an int32 zero.
926 // If the operation also exists in a form that takes int32 and outputs int32 930 // If the operation also exists in a form that takes int32 and outputs int32
927 // then the operation should return its input value so that we can propagate 931 // then the operation should return its input value so that we can propagate
928 // back. There are three operations that need to propagate back to more than 932 // back. There are three operations that need to propagate back to more than
929 // one input. They are phi and binary div and mul. They always return NULL 933 // one input. They are phi and binary div and mul. They always return NULL
930 // and expect the caller to take care of things. 934 // and expect the caller to take care of things.
(...skipping 2010 matching lines...) Expand 10 before | Expand all | Expand 10 after
2941 HCheckInstanceType(HValue* value, Check check) 2945 HCheckInstanceType(HValue* value, Check check)
2942 : HUnaryOperation(value), check_(check) { 2946 : HUnaryOperation(value), check_(check) {
2943 set_representation(Representation::Tagged()); 2947 set_representation(Representation::Tagged());
2944 SetFlag(kUseGVN); 2948 SetFlag(kUseGVN);
2945 } 2949 }
2946 2950
2947 const Check check_; 2951 const Check check_;
2948 }; 2952 };
2949 2953
2950 2954
2951 class HCheckNonSmi: public HUnaryOperation { 2955 class HCheckHeapObject: public HUnaryOperation {
2952 public: 2956 public:
2953 explicit HCheckNonSmi(HValue* value) : HUnaryOperation(value) { 2957 explicit HCheckHeapObject(HValue* value) : HUnaryOperation(value) {
2954 set_representation(Representation::Tagged()); 2958 set_representation(Representation::Tagged());
2955 SetFlag(kUseGVN); 2959 SetFlag(kUseGVN);
2956 } 2960 }
2957 2961
2958 virtual Representation RequiredInputRepresentation(int index) { 2962 virtual Representation RequiredInputRepresentation(int index) {
2959 return Representation::Tagged(); 2963 return Representation::Tagged();
2960 } 2964 }
2961 2965
2962 virtual HType CalculateInferredType(); 2966 virtual HType CalculateInferredType();
2963 2967
2964 #ifdef DEBUG 2968 #ifdef DEBUG
2965 virtual void Verify(); 2969 virtual void Verify();
2966 #endif 2970 #endif
2967 2971
2968 virtual HValue* Canonicalize() { 2972 virtual HValue* Canonicalize() {
2969 HType value_type = value()->type(); 2973 HType value_type = value()->type();
2970 if (!value_type.IsUninitialized() && 2974 if (!value_type.IsUninitialized() && value_type.IsHeapObject()) {
2971 (value_type.IsHeapNumber() ||
2972 value_type.IsString() ||
2973 value_type.IsBoolean() ||
2974 value_type.IsNonPrimitive())) {
2975 return NULL; 2975 return NULL;
2976 } 2976 }
2977 return this; 2977 return this;
2978 } 2978 }
2979 2979
2980 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi) 2980 DECLARE_CONCRETE_INSTRUCTION(CheckHeapObject)
2981 2981
2982 protected: 2982 protected:
2983 virtual bool DataEquals(HValue* other) { return true; } 2983 virtual bool DataEquals(HValue* other) { return true; }
2984 }; 2984 };
2985 2985
2986 2986
2987 class HCheckPrototypeMaps: public HTemplateInstruction<0> { 2987 class HCheckPrototypeMaps: public HTemplateInstruction<0> {
2988 public: 2988 public:
2989 HCheckPrototypeMaps(Handle<JSObject> prototype, 2989 HCheckPrototypeMaps(Handle<JSObject> prototype,
2990 Handle<JSObject> holder, 2990 Handle<JSObject> holder,
(...skipping 3650 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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698