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

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

Issue 9638018: [v8-dev] Optimise Math.floor(x/y) to use integer division for specific divisor.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 years, 9 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 V(LoadFunctionPrototype) \ 133 V(LoadFunctionPrototype) \
134 V(LoadGlobalCell) \ 134 V(LoadGlobalCell) \
135 V(LoadGlobalGeneric) \ 135 V(LoadGlobalGeneric) \
136 V(LoadKeyedFastDoubleElement) \ 136 V(LoadKeyedFastDoubleElement) \
137 V(LoadKeyedFastElement) \ 137 V(LoadKeyedFastElement) \
138 V(LoadKeyedGeneric) \ 138 V(LoadKeyedGeneric) \
139 V(LoadKeyedSpecializedArrayElement) \ 139 V(LoadKeyedSpecializedArrayElement) \
140 V(LoadNamedField) \ 140 V(LoadNamedField) \
141 V(LoadNamedFieldPolymorphic) \ 141 V(LoadNamedFieldPolymorphic) \
142 V(LoadNamedGeneric) \ 142 V(LoadNamedGeneric) \
143 V(MathFloorOfDiv) \
143 V(Mod) \ 144 V(Mod) \
144 V(Mul) \ 145 V(Mul) \
145 V(ObjectLiteral) \ 146 V(ObjectLiteral) \
146 V(OsrEntry) \ 147 V(OsrEntry) \
147 V(OuterContext) \ 148 V(OuterContext) \
148 V(Parameter) \ 149 V(Parameter) \
149 V(Power) \ 150 V(Power) \
150 V(PushArgument) \ 151 V(PushArgument) \
151 V(Random) \ 152 V(Random) \
152 V(RegExpLiteral) \ 153 V(RegExpLiteral) \
(...skipping 1768 matching lines...) Expand 10 before | Expand all | Expand 10 after
1921 return Representation::Double(); 1922 return Representation::Double();
1922 case kMathAbs: 1923 case kMathAbs:
1923 return representation(); 1924 return representation();
1924 default: 1925 default:
1925 UNREACHABLE(); 1926 UNREACHABLE();
1926 return Representation::None(); 1927 return Representation::None();
1927 } 1928 }
1928 } 1929 }
1929 } 1930 }
1930 1931
1931 virtual HValue* Canonicalize() { 1932 virtual HValue* Canonicalize();
1932 // If the input is integer32 then we replace the floor instruction
1933 // with its inputs. This happens before the representation changes are
1934 // introduced.
1935 if (op() == kMathFloor) {
1936 if (value()->representation().IsInteger32()) return value();
1937 }
1938 return this;
1939 }
1940 1933
1941 BuiltinFunctionId op() const { return op_; } 1934 BuiltinFunctionId op() const { return op_; }
1942 const char* OpName() const; 1935 const char* OpName() const;
1943 1936
1944 DECLARE_CONCRETE_INSTRUCTION(UnaryMathOperation) 1937 DECLARE_CONCRETE_INSTRUCTION(UnaryMathOperation)
1945 1938
1946 protected: 1939 protected:
1947 virtual bool DataEquals(HValue* other) { 1940 virtual bool DataEquals(HValue* other) {
1948 HUnaryMathOperation* b = HUnaryMathOperation::cast(other); 1941 HUnaryMathOperation* b = HUnaryMathOperation::cast(other);
1949 return op_ == b->op(); 1942 return op_ == b->op();
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
2647 SetFlag(kUseGVN); 2640 SetFlag(kUseGVN);
2648 } 2641 }
2649 } 2642 }
2650 2643
2651 virtual HType CalculateInferredType(); 2644 virtual HType CalculateInferredType();
2652 2645
2653 DECLARE_ABSTRACT_INSTRUCTION(BitwiseBinaryOperation) 2646 DECLARE_ABSTRACT_INSTRUCTION(BitwiseBinaryOperation)
2654 }; 2647 };
2655 2648
2656 2649
2650 class HMathFloorOfDiv: public HBinaryOperation {
2651 public:
2652 HMathFloorOfDiv(HValue* context, HValue* left, HValue* right)
2653 : HBinaryOperation(context, left, right) {
2654 set_representation(Representation::Integer32());
fschneider 2012/03/28 09:59:18 I think you can make GVN handle this instruction b
Alexandre 2012/03/28 16:27:38 Done.
2655 }
2656
2657 virtual Representation RequiredInputRepresentation(int index) {
2658 return Representation::Integer32();
2659 }
2660
2661 DECLARE_CONCRETE_INSTRUCTION(MathFloorOfDiv)
2662 };
2663
2664
2657 class HArithmeticBinaryOperation: public HBinaryOperation { 2665 class HArithmeticBinaryOperation: public HBinaryOperation {
2658 public: 2666 public:
2659 HArithmeticBinaryOperation(HValue* context, HValue* left, HValue* right) 2667 HArithmeticBinaryOperation(HValue* context, HValue* left, HValue* right)
2660 : HBinaryOperation(context, left, right) { 2668 : HBinaryOperation(context, left, right) {
2661 set_representation(Representation::Tagged()); 2669 set_representation(Representation::Tagged());
2662 SetFlag(kFlexibleRepresentation); 2670 SetFlag(kFlexibleRepresentation);
2663 SetAllSideEffects(); 2671 SetAllSideEffects();
2664 } 2672 }
2665 2673
2666 virtual void RepresentationChanged(Representation to) { 2674 virtual void RepresentationChanged(Representation to) {
(...skipping 2110 matching lines...) Expand 10 before | Expand all | Expand 10 after
4777 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex); 4785 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex);
4778 }; 4786 };
4779 4787
4780 4788
4781 #undef DECLARE_INSTRUCTION 4789 #undef DECLARE_INSTRUCTION
4782 #undef DECLARE_CONCRETE_INSTRUCTION 4790 #undef DECLARE_CONCRETE_INSTRUCTION
4783 4791
4784 } } // namespace v8::internal 4792 } } // namespace v8::internal
4785 4793
4786 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 4794 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698