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

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

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