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

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

Issue 470413002: Switch to a fix-point based range analysis to improve its precision. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 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 (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 1932 matching lines...) Expand 10 before | Expand all | Expand 10 after
1943 // formatting. Otherwise, it prints in the format "opcode(op1, op2, op3)". 1943 // formatting. Otherwise, it prints in the format "opcode(op1, op2, op3)".
1944 virtual void PrintTo(BufferFormatter* f) const; 1944 virtual void PrintTo(BufferFormatter* f) const;
1945 virtual void PrintOperandsTo(BufferFormatter* f) const; 1945 virtual void PrintOperandsTo(BufferFormatter* f) const;
1946 1946
1947 // A value in the constant propagation lattice. 1947 // A value in the constant propagation lattice.
1948 // - non-constant sentinel 1948 // - non-constant sentinel
1949 // - a constant (any non-sentinel value) 1949 // - a constant (any non-sentinel value)
1950 // - unknown sentinel 1950 // - unknown sentinel
1951 Object& constant_value() const { return constant_value_; } 1951 Object& constant_value() const { return constant_value_; }
1952 1952
1953 virtual void InferRange(); 1953 virtual void InferRange(Range* range);
1954 1954
1955 Range* range() const { return range_; } 1955 Range* range() const { return range_; }
1956 void set_range(const Range&);
1956 1957
1957 // Definitions can be canonicalized only into definitions to ensure 1958 // Definitions can be canonicalized only into definitions to ensure
1958 // this check statically we override base Canonicalize with a Canonicalize 1959 // this check statically we override base Canonicalize with a Canonicalize
1959 // returning Definition (return type is covariant). 1960 // returning Definition (return type is covariant).
1960 virtual Definition* Canonicalize(FlowGraph* flow_graph); 1961 virtual Definition* Canonicalize(FlowGraph* flow_graph);
1961 1962
1962 static const intptr_t kReplacementMarker = -2; 1963 static const intptr_t kReplacementMarker = -2;
1963 1964
1964 Definition* Replacement() { 1965 Definition* Replacement() {
1965 if (ssa_temp_index_ == kReplacementMarker) { 1966 if (ssa_temp_index_ == kReplacementMarker) {
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
2096 2097
2097 virtual intptr_t Hashcode() const { 2098 virtual intptr_t Hashcode() const {
2098 UNREACHABLE(); 2099 UNREACHABLE();
2099 return 0; 2100 return 0;
2100 } 2101 }
2101 2102
2102 DECLARE_INSTRUCTION(Phi) 2103 DECLARE_INSTRUCTION(Phi)
2103 2104
2104 virtual void PrintTo(BufferFormatter* f) const; 2105 virtual void PrintTo(BufferFormatter* f) const;
2105 2106
2106 virtual void InferRange(); 2107 virtual void InferRange(Range* range);
2107 2108
2108 BitVector* reaching_defs() const { 2109 BitVector* reaching_defs() const {
2109 return reaching_defs_; 2110 return reaching_defs_;
2110 } 2111 }
2111 2112
2112 void set_reaching_defs(BitVector* reaching_defs) { 2113 void set_reaching_defs(BitVector* reaching_defs) {
2113 reaching_defs_ = reaching_defs; 2114 reaching_defs_ = reaching_defs;
2114 } 2115 }
2115 2116
2116 virtual bool MayThrow() const { return false; } 2117 virtual bool MayThrow() const { return false; }
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
2593 return false; 2594 return false;
2594 } 2595 }
2595 2596
2596 virtual bool MayThrow() const { return false; } 2597 virtual bool MayThrow() const { return false; }
2597 2598
2598 virtual void PrintOperandsTo(BufferFormatter* f) const; 2599 virtual void PrintOperandsTo(BufferFormatter* f) const;
2599 2600
2600 Value* value() const { return inputs_[0]; } 2601 Value* value() const { return inputs_[0]; }
2601 Range* constraint() const { return constraint_; } 2602 Range* constraint() const { return constraint_; }
2602 2603
2603 virtual void InferRange(); 2604 virtual void InferRange(Range* range);
2604 2605
2605 void AddDependency(Definition* defn) { 2606 void AddDependency(Definition* defn) {
2606 Value* val = new Value(defn); 2607 Value* val = new Value(defn);
2607 defn->AddInputUse(val); 2608 defn->AddInputUse(val);
2608 SetInputAt(1, val); 2609 SetInputAt(1, val);
2609 } 2610 }
2610 2611
2611 // Constraints for branches have their target block stored in order 2612 // Constraints for branches have their target block stored in order
2612 // to find the the comparsion that generated the constraint: 2613 // to find the the comparsion that generated the constraint:
2613 // target->predecessor->last_instruction->comparison. 2614 // target->predecessor->last_instruction->comparison.
(...skipping 24 matching lines...) Expand all
2638 virtual CompileType ComputeType() const; 2639 virtual CompileType ComputeType() const;
2639 2640
2640 virtual Definition* Canonicalize(FlowGraph* flow_graph); 2641 virtual Definition* Canonicalize(FlowGraph* flow_graph);
2641 2642
2642 const Object& value() const { return value_; } 2643 const Object& value() const { return value_; }
2643 2644
2644 virtual void PrintOperandsTo(BufferFormatter* f) const; 2645 virtual void PrintOperandsTo(BufferFormatter* f) const;
2645 2646
2646 virtual bool CanDeoptimize() const { return false; } 2647 virtual bool CanDeoptimize() const { return false; }
2647 2648
2648 virtual void InferRange(); 2649 virtual void InferRange(Range* range);
2649 2650
2650 virtual bool AllowsCSE() const { return true; } 2651 virtual bool AllowsCSE() const { return true; }
2651 virtual EffectSet Effects() const { return EffectSet::None(); } 2652 virtual EffectSet Effects() const { return EffectSet::None(); }
2652 virtual EffectSet Dependencies() const { return EffectSet::None(); } 2653 virtual EffectSet Dependencies() const { return EffectSet::None(); }
2653 virtual bool AttributesEqual(Instruction* other) const; 2654 virtual bool AttributesEqual(Instruction* other) const;
2654 2655
2655 virtual bool MayThrow() const { return false; } 2656 virtual bool MayThrow() const { return false; }
2656 2657
2657 private: 2658 private:
2658 const Object& value_; 2659 const Object& value_;
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
3275 } 3276 }
3276 3277
3277 virtual Representation RequiredInputRepresentation(intptr_t i) const { 3278 virtual Representation RequiredInputRepresentation(intptr_t i) const {
3278 return comparison()->RequiredInputRepresentation(i); 3279 return comparison()->RequiredInputRepresentation(i);
3279 } 3280 }
3280 3281
3281 virtual void PrintOperandsTo(BufferFormatter* f) const; 3282 virtual void PrintOperandsTo(BufferFormatter* f) const;
3282 3283
3283 virtual CompileType ComputeType() const; 3284 virtual CompileType ComputeType() const;
3284 3285
3285 virtual void InferRange(); 3286 virtual void InferRange(Range* range);
3286 3287
3287 ComparisonInstr* comparison() const { return comparison_; } 3288 ComparisonInstr* comparison() const { return comparison_; }
3288 intptr_t if_true() const { return if_true_; } 3289 intptr_t if_true() const { return if_true_; }
3289 intptr_t if_false() const { return if_false_; } 3290 intptr_t if_false() const { return if_false_; }
3290 3291
3291 virtual bool AllowsCSE() const { return comparison()->AllowsCSE(); } 3292 virtual bool AllowsCSE() const { return comparison()->AllowsCSE(); }
3292 virtual EffectSet Effects() const { return comparison()->Effects(); } 3293 virtual EffectSet Effects() const { return comparison()->Effects(); }
3293 virtual EffectSet Dependencies() const { 3294 virtual EffectSet Dependencies() const {
3294 return comparison()->Dependencies(); 3295 return comparison()->Dependencies();
3295 } 3296 }
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
3909 3910
3910 virtual bool CanDeoptimize() const { 3911 virtual bool CanDeoptimize() const {
3911 return deopt_id_ != Isolate::kNoDeoptId; 3912 return deopt_id_ != Isolate::kNoDeoptId;
3912 } 3913 }
3913 3914
3914 bool Typed32BitIsSmi() const { 3915 bool Typed32BitIsSmi() const {
3915 return kSmiBits >= 32; 3916 return kSmiBits >= 32;
3916 } 3917 }
3917 3918
3918 virtual Representation representation() const; 3919 virtual Representation representation() const;
3919 virtual void InferRange(); 3920 virtual void InferRange(Range* range);
3920 3921
3921 virtual bool AllowsCSE() const { return false; } 3922 virtual bool AllowsCSE() const { return false; }
3922 virtual EffectSet Effects() const { return EffectSet::None(); } 3923 virtual EffectSet Effects() const { return EffectSet::None(); }
3923 virtual EffectSet Dependencies() const; 3924 virtual EffectSet Dependencies() const;
3924 virtual bool AttributesEqual(Instruction* other) const; 3925 virtual bool AttributesEqual(Instruction* other) const;
3925 3926
3926 virtual bool MayThrow() const { return false; } 3927 virtual bool MayThrow() const { return false; }
3927 3928
3928 private: 3929 private:
3929 const intptr_t index_scale_; 3930 const intptr_t index_scale_;
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
4478 return recognized_kind_; 4479 return recognized_kind_;
4479 } 4480 }
4480 4481
4481 DECLARE_INSTRUCTION(LoadField) 4482 DECLARE_INSTRUCTION(LoadField)
4482 virtual CompileType ComputeType() const; 4483 virtual CompileType ComputeType() const;
4483 4484
4484 virtual void PrintOperandsTo(BufferFormatter* f) const; 4485 virtual void PrintOperandsTo(BufferFormatter* f) const;
4485 4486
4486 virtual bool CanDeoptimize() const { return false; } 4487 virtual bool CanDeoptimize() const { return false; }
4487 4488
4488 virtual void InferRange(); 4489 virtual void InferRange(Range* range);
4489 4490
4490 bool IsImmutableLengthLoad() const; 4491 bool IsImmutableLengthLoad() const;
4491 4492
4492 virtual Definition* Canonicalize(FlowGraph* flow_graph); 4493 virtual Definition* Canonicalize(FlowGraph* flow_graph);
4493 4494
4494 static MethodRecognizer::Kind RecognizedKindFromArrayCid(intptr_t cid); 4495 static MethodRecognizer::Kind RecognizedKindFromArrayCid(intptr_t cid);
4495 4496
4496 static bool IsFixedLengthArrayCid(intptr_t cid); 4497 static bool IsFixedLengthArrayCid(intptr_t cid);
4497 4498
4498 virtual bool AllowsCSE() const { return immutable_; } 4499 virtual bool AllowsCSE() const { return immutable_; }
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
4877 4878
4878 virtual Representation RequiredInputRepresentation(intptr_t idx) const { 4879 virtual Representation RequiredInputRepresentation(intptr_t idx) const {
4879 ASSERT(idx == 0); 4880 ASSERT(idx == 0);
4880 return kUnboxedMint; 4881 return kUnboxedMint;
4881 } 4882 }
4882 4883
4883 DECLARE_INSTRUCTION(BoxInteger) 4884 DECLARE_INSTRUCTION(BoxInteger)
4884 virtual CompileType ComputeType() const; 4885 virtual CompileType ComputeType() const;
4885 virtual bool RecomputeType(); 4886 virtual bool RecomputeType();
4886 4887
4887 virtual void InferRange(); 4888 virtual void InferRange(Range* range);
4888 4889
4889 virtual bool AllowsCSE() const { return true; } 4890 virtual bool AllowsCSE() const { return true; }
4890 virtual EffectSet Effects() const { return EffectSet::None(); } 4891 virtual EffectSet Effects() const { return EffectSet::None(); }
4891 virtual EffectSet Dependencies() const { return EffectSet::None(); } 4892 virtual EffectSet Dependencies() const { return EffectSet::None(); }
4892 virtual bool AttributesEqual(Instruction* other) const { return true; } 4893 virtual bool AttributesEqual(Instruction* other) const { return true; }
4893 4894
4894 virtual bool MayThrow() const { return false; } 4895 virtual bool MayThrow() const { return false; }
4895 4896
4896 private: 4897 private:
4897 bool is_smi_; 4898 bool is_smi_;
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
5050 return (value()->Type()->ToCid() != kSmiCid) 5051 return (value()->Type()->ToCid() != kSmiCid)
5051 && (value()->Type()->ToCid() != kMintCid); 5052 && (value()->Type()->ToCid() != kMintCid);
5052 } 5053 }
5053 5054
5054 virtual Representation representation() const { 5055 virtual Representation representation() const {
5055 return kUnboxedMint; 5056 return kUnboxedMint;
5056 } 5057 }
5057 5058
5058 intptr_t deopt_id() const { return deopt_id_; } 5059 intptr_t deopt_id() const { return deopt_id_; }
5059 5060
5060 virtual void InferRange(); 5061 virtual void InferRange(Range* range);
5061 5062
5062 DECLARE_INSTRUCTION(UnboxInteger) 5063 DECLARE_INSTRUCTION(UnboxInteger)
5063 virtual CompileType ComputeType() const; 5064 virtual CompileType ComputeType() const;
5064 5065
5065 virtual bool AllowsCSE() const { return true; } 5066 virtual bool AllowsCSE() const { return true; }
5066 virtual EffectSet Effects() const { return EffectSet::None(); } 5067 virtual EffectSet Effects() const { return EffectSet::None(); }
5067 virtual EffectSet Dependencies() const { return EffectSet::None(); } 5068 virtual EffectSet Dependencies() const { return EffectSet::None(); }
5068 virtual bool AttributesEqual(Instruction* other) const { return true; } 5069 virtual bool AttributesEqual(Instruction* other) const { return true; }
5069 5070
5070 virtual bool MayThrow() const { return false; } 5071 virtual bool MayThrow() const { return false; }
(...skipping 1825 matching lines...) Expand 10 before | Expand all | Expand 10 after
6896 ASSERT((idx == 0) || (idx == 1)); 6897 ASSERT((idx == 0) || (idx == 1));
6897 return kUnboxedMint; 6898 return kUnboxedMint;
6898 } 6899 }
6899 6900
6900 virtual intptr_t DeoptimizationTarget() const { 6901 virtual intptr_t DeoptimizationTarget() const {
6901 // Direct access since this instruction cannot deoptimize, and the deopt-id 6902 // Direct access since this instruction cannot deoptimize, and the deopt-id
6902 // was inherited from another instruction that could deoptimize. 6903 // was inherited from another instruction that could deoptimize.
6903 return deopt_id_; 6904 return deopt_id_;
6904 } 6905 }
6905 6906
6906 virtual void InferRange(); 6907 virtual void InferRange(Range* range);
6907 6908
6908 virtual Definition* Canonicalize(FlowGraph* flow_graph); 6909 virtual Definition* Canonicalize(FlowGraph* flow_graph);
6909 6910
6910 DECLARE_INSTRUCTION(BinaryMintOp) 6911 DECLARE_INSTRUCTION(BinaryMintOp)
6911 virtual CompileType ComputeType() const; 6912 virtual CompileType ComputeType() const;
6912 6913
6913 virtual bool AllowsCSE() const { return true; } 6914 virtual bool AllowsCSE() const { return true; }
6914 virtual EffectSet Effects() const { return EffectSet::None(); } 6915 virtual EffectSet Effects() const { return EffectSet::None(); }
6915 virtual EffectSet Dependencies() const { return EffectSet::None(); } 6916 virtual EffectSet Dependencies() const { return EffectSet::None(); }
6916 virtual bool AttributesEqual(Instruction* other) const { 6917 virtual bool AttributesEqual(Instruction* other) const {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
6970 ASSERT((idx == 0) || (idx == 1)); 6971 ASSERT((idx == 0) || (idx == 1));
6971 return (idx == 0) ? kUnboxedMint : kTagged; 6972 return (idx == 0) ? kUnboxedMint : kTagged;
6972 } 6973 }
6973 6974
6974 virtual intptr_t DeoptimizationTarget() const { 6975 virtual intptr_t DeoptimizationTarget() const {
6975 // Direct access since this instruction cannot deoptimize, and the deopt-id 6976 // Direct access since this instruction cannot deoptimize, and the deopt-id
6976 // was inherited from another instruction that could deoptimize. 6977 // was inherited from another instruction that could deoptimize.
6977 return deopt_id_; 6978 return deopt_id_;
6978 } 6979 }
6979 6980
6980 virtual void InferRange(); 6981 virtual void InferRange(Range* range);
6981 6982
6982 DECLARE_INSTRUCTION(ShiftMintOp) 6983 DECLARE_INSTRUCTION(ShiftMintOp)
6983 6984
6984 virtual bool AllowsCSE() const { return true; } 6985 virtual bool AllowsCSE() const { return true; }
6985 virtual EffectSet Effects() const { return EffectSet::None(); } 6986 virtual EffectSet Effects() const { return EffectSet::None(); }
6986 virtual EffectSet Dependencies() const { return EffectSet::None(); } 6987 virtual EffectSet Dependencies() const { return EffectSet::None(); }
6987 virtual bool AttributesEqual(Instruction* other) const { 6988 virtual bool AttributesEqual(Instruction* other) const {
6988 return op_kind() == other->AsShiftMintOp()->op_kind(); 6989 return op_kind() == other->AsShiftMintOp()->op_kind();
6989 } 6990 }
6990 6991
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
7087 7088
7088 virtual bool CanDeoptimize() const; 7089 virtual bool CanDeoptimize() const;
7089 7090
7090 virtual bool AllowsCSE() const { return true; } 7091 virtual bool AllowsCSE() const { return true; }
7091 virtual EffectSet Effects() const { return EffectSet::None(); } 7092 virtual EffectSet Effects() const { return EffectSet::None(); }
7092 virtual EffectSet Dependencies() const { return EffectSet::None(); } 7093 virtual EffectSet Dependencies() const { return EffectSet::None(); }
7093 virtual bool AttributesEqual(Instruction* other) const; 7094 virtual bool AttributesEqual(Instruction* other) const;
7094 7095
7095 void PrintTo(BufferFormatter* f) const; 7096 void PrintTo(BufferFormatter* f) const;
7096 7097
7097 virtual void InferRange(); 7098 virtual void InferRange(Range* range);
7098 7099
7099 virtual Definition* Canonicalize(FlowGraph* flow_graph); 7100 virtual Definition* Canonicalize(FlowGraph* flow_graph);
7100 7101
7101 // Returns true if right is a non-zero Smi constant which absolute value is 7102 // Returns true if right is a non-zero Smi constant which absolute value is
7102 // a power of two. 7103 // a power of two.
7103 bool RightIsPowerOfTwoConstant() const; 7104 bool RightIsPowerOfTwoConstant() const;
7104 7105
7105 virtual bool MayThrow() const { return false; } 7106 virtual bool MayThrow() const { return false; }
7106 7107
7107 private: 7108 private:
(...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after
8367 ForwardInstructionIterator* current_iterator_; 8368 ForwardInstructionIterator* current_iterator_;
8368 8369
8369 private: 8370 private:
8370 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 8371 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
8371 }; 8372 };
8372 8373
8373 8374
8374 } // namespace dart 8375 } // namespace dart
8375 8376
8376 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 8377 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW
« runtime/vm/flow_graph_range_analysis_test.cc ('K') | « runtime/vm/flow_graph_range_analysis_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698