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

Side by Side Diff: runtime/vm/intermediate_language.h

Issue 59613005: Merge (x & y) == 0 pattern to emit a single test instruction. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 1 month 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 (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_INTERMEDIATE_LANGUAGE_H_ 5 #ifndef VM_INTERMEDIATE_LANGUAGE_H_
6 #define VM_INTERMEDIATE_LANGUAGE_H_ 6 #define VM_INTERMEDIATE_LANGUAGE_H_
7 7
8 #include "vm/allocation.h" 8 #include "vm/allocation.h"
9 #include "vm/ast.h" 9 #include "vm/ast.h"
10 #include "vm/growable_array.h" 10 #include "vm/growable_array.h"
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 M(CheckSmi) \ 654 M(CheckSmi) \
655 M(Constant) \ 655 M(Constant) \
656 M(CheckEitherNonSmi) \ 656 M(CheckEitherNonSmi) \
657 M(BinaryDoubleOp) \ 657 M(BinaryDoubleOp) \
658 M(MathUnary) \ 658 M(MathUnary) \
659 M(MathMinMax) \ 659 M(MathMinMax) \
660 M(UnboxDouble) \ 660 M(UnboxDouble) \
661 M(BoxDouble) \ 661 M(BoxDouble) \
662 M(BoxFloat32x4) \ 662 M(BoxFloat32x4) \
663 M(UnboxFloat32x4) \ 663 M(UnboxFloat32x4) \
664 M(BoxInt32x4) \ 664 M(BoxInt32x4) \
665 M(UnboxInt32x4) \ 665 M(UnboxInt32x4) \
666 M(UnboxInteger) \ 666 M(UnboxInteger) \
667 M(BoxInteger) \ 667 M(BoxInteger) \
668 M(BinaryMintOp) \ 668 M(BinaryMintOp) \
669 M(ShiftMintOp) \ 669 M(ShiftMintOp) \
670 M(UnaryMintOp) \ 670 M(UnaryMintOp) \
671 M(CheckArrayBound) \ 671 M(CheckArrayBound) \
672 M(Constraint) \ 672 M(Constraint) \
673 M(StringFromCharCode) \ 673 M(StringFromCharCode) \
674 M(StringInterpolate) \ 674 M(StringInterpolate) \
675 M(InvokeMathCFunction) \ 675 M(InvokeMathCFunction) \
676 M(GuardField) \ 676 M(GuardField) \
677 M(IfThenElse) \ 677 M(IfThenElse) \
678 M(BinaryFloat32x4Op) \ 678 M(BinaryFloat32x4Op) \
679 M(Simd32x4Shuffle) \ 679 M(Simd32x4Shuffle) \
680 M(Simd32x4ShuffleMix) \ 680 M(Simd32x4ShuffleMix) \
681 M(Simd32x4GetSignMask) \ 681 M(Simd32x4GetSignMask) \
682 M(Float32x4Constructor) \ 682 M(Float32x4Constructor) \
683 M(Float32x4Zero) \ 683 M(Float32x4Zero) \
684 M(Float32x4Splat) \ 684 M(Float32x4Splat) \
685 M(Float32x4Comparison) \ 685 M(Float32x4Comparison) \
686 M(Float32x4MinMax) \ 686 M(Float32x4MinMax) \
687 M(Float32x4Scale) \ 687 M(Float32x4Scale) \
688 M(Float32x4Sqrt) \ 688 M(Float32x4Sqrt) \
689 M(Float32x4ZeroArg) \ 689 M(Float32x4ZeroArg) \
690 M(Float32x4Clamp) \ 690 M(Float32x4Clamp) \
691 M(Float32x4With) \ 691 M(Float32x4With) \
692 M(Float32x4ToInt32x4) \ 692 M(Float32x4ToInt32x4) \
693 M(MaterializeObject) \ 693 M(MaterializeObject) \
694 M(Int32x4BoolConstructor) \ 694 M(Int32x4BoolConstructor) \
695 M(Int32x4GetFlag) \ 695 M(Int32x4GetFlag) \
696 M(Int32x4Select) \ 696 M(Int32x4Select) \
697 M(Int32x4SetFlag) \ 697 M(Int32x4SetFlag) \
698 M(Int32x4ToFloat32x4) \ 698 M(Int32x4ToFloat32x4) \
699 M(BinaryInt32x4Op) \ 699 M(BinaryInt32x4Op) \
700 M(TestSmi) \
700 701
701 702
702 #define FORWARD_DECLARATION(type) class type##Instr; 703 #define FORWARD_DECLARATION(type) class type##Instr;
703 FOR_EACH_INSTRUCTION(FORWARD_DECLARATION) 704 FOR_EACH_INSTRUCTION(FORWARD_DECLARATION)
704 #undef FORWARD_DECLARATION 705 #undef FORWARD_DECLARATION
705 706
706 707
707 // Functions required in all concrete instruction classes. 708 // Functions required in all concrete instruction classes.
708 #define DECLARE_INSTRUCTION(type) \ 709 #define DECLARE_INSTRUCTION(type) \
709 virtual Tag tag() const { return k##type; } \ 710 virtual Tag tag() const { return k##type; } \
(...skipping 2268 matching lines...) Expand 10 before | Expand all | Expand 10 after
2978 2979
2979 private: 2980 private:
2980 // True if the comparison must check for double, Mint or Bigint and 2981 // True if the comparison must check for double, Mint or Bigint and
2981 // use value comparison instead. 2982 // use value comparison instead.
2982 bool needs_number_check_; 2983 bool needs_number_check_;
2983 2984
2984 DISALLOW_COPY_AND_ASSIGN(StrictCompareInstr); 2985 DISALLOW_COPY_AND_ASSIGN(StrictCompareInstr);
2985 }; 2986 };
2986 2987
2987 2988
2989 // Comparison instruction that is equivalent to the (left & right) == 0
2990 // comparison pattern.
2991 class TestSmiInstr : public ComparisonInstr {
2992 public:
2993 TestSmiInstr(intptr_t token_pos, Token::Kind kind, Value* left, Value* right)
2994 : ComparisonInstr(token_pos, kind, left, right) {
2995 ASSERT(kind == Token::kEQ || kind == Token::kNE);
2996 }
2997
2998 DECLARE_INSTRUCTION(TestSmi);
2999 virtual CompileType ComputeType() const;
3000
3001 virtual bool CanDeoptimize() const { return false; }
3002
3003 virtual bool CanBecomeDeoptimizationTarget() const {
3004 // TestSmi can be merged into Branch and thus needs an environment.
3005 return true;
3006 }
3007
3008 virtual intptr_t DeoptimizationTarget() const {
3009 return GetDeoptId();
3010 }
3011
3012 virtual Representation RequiredInputRepresentation(intptr_t idx) const {
3013 return kTagged;
3014 }
3015
3016 virtual EffectSet Effects() const { return EffectSet::None(); }
3017
3018 virtual bool MayThrow() const { return false; }
3019
3020 virtual void EmitBranchCode(FlowGraphCompiler* compiler,
3021 BranchInstr* branch);
3022
3023 private:
3024 DISALLOW_COPY_AND_ASSIGN(TestSmiInstr);
3025 };
3026
3027
2988 class EqualityCompareInstr : public ComparisonInstr { 3028 class EqualityCompareInstr : public ComparisonInstr {
2989 public: 3029 public:
2990 EqualityCompareInstr(intptr_t token_pos, 3030 EqualityCompareInstr(intptr_t token_pos,
2991 Token::Kind kind, 3031 Token::Kind kind,
2992 Value* left, 3032 Value* left,
2993 Value* right, 3033 Value* right,
2994 intptr_t cid, 3034 intptr_t cid,
2995 intptr_t deopt_id) 3035 intptr_t deopt_id)
2996 : ComparisonInstr(token_pos, kind, left, right) { 3036 : ComparisonInstr(token_pos, kind, left, right) {
2997 ASSERT(Token::IsEqualityOperator(kind)); 3037 ASSERT(Token::IsEqualityOperator(kind));
2998 set_operation_cid(cid); 3038 set_operation_cid(cid);
2999 deopt_id_ = deopt_id; // Override generated deopt-id. 3039 deopt_id_ = deopt_id; // Override generated deopt-id.
3000 } 3040 }
3001 3041
3002 DECLARE_INSTRUCTION(EqualityCompare) 3042 DECLARE_INSTRUCTION(EqualityCompare)
3003 virtual CompileType ComputeType() const; 3043 virtual CompileType ComputeType() const;
3004 virtual bool RecomputeType();
3005 3044
3006 virtual void PrintOperandsTo(BufferFormatter* f) const; 3045 virtual void PrintOperandsTo(BufferFormatter* f) const;
3007 3046
3008 virtual bool CanDeoptimize() const { return false; } 3047 virtual bool CanDeoptimize() const { return false; }
3009 3048
3010 virtual bool CanBecomeDeoptimizationTarget() const { 3049 virtual bool CanBecomeDeoptimizationTarget() const {
3011 // EqualityCompare can be merged into Branch and thus needs an environment. 3050 // EqualityCompare can be merged into Branch and thus needs an environment.
3012 return true; 3051 return true;
3013 } 3052 }
3014 3053
(...skipping 29 matching lines...) Expand all
3044 intptr_t cid, 3083 intptr_t cid,
3045 intptr_t deopt_id) 3084 intptr_t deopt_id)
3046 : ComparisonInstr(token_pos, kind, left, right) { 3085 : ComparisonInstr(token_pos, kind, left, right) {
3047 ASSERT(Token::IsRelationalOperator(kind)); 3086 ASSERT(Token::IsRelationalOperator(kind));
3048 set_operation_cid(cid); 3087 set_operation_cid(cid);
3049 deopt_id_ = deopt_id; // Override generated deopt-id. 3088 deopt_id_ = deopt_id; // Override generated deopt-id.
3050 } 3089 }
3051 3090
3052 DECLARE_INSTRUCTION(RelationalOp) 3091 DECLARE_INSTRUCTION(RelationalOp)
3053 virtual CompileType ComputeType() const; 3092 virtual CompileType ComputeType() const;
3054 virtual bool RecomputeType();
3055 3093
3056 virtual void PrintOperandsTo(BufferFormatter* f) const; 3094 virtual void PrintOperandsTo(BufferFormatter* f) const;
3057 3095
3058 virtual bool CanDeoptimize() const { return false; } 3096 virtual bool CanDeoptimize() const { return false; }
3059 3097
3060 virtual bool CanBecomeDeoptimizationTarget() const { 3098 virtual bool CanBecomeDeoptimizationTarget() const {
3061 // RelationalOp can be merged into Branch and thus needs an environment. 3099 // RelationalOp can be merged into Branch and thus needs an environment.
3062 return true; 3100 return true;
3063 } 3101 }
3064 3102
(...skipping 3836 matching lines...) Expand 10 before | Expand all | Expand 10 after
6901 ForwardInstructionIterator* current_iterator_; 6939 ForwardInstructionIterator* current_iterator_;
6902 6940
6903 private: 6941 private:
6904 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 6942 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
6905 }; 6943 };
6906 6944
6907 6945
6908 } // namespace dart 6946 } // namespace dart
6909 6947
6910 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 6948 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698