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

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

Issue 62133002: Cleanup of branch code generation (no change in functionality). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: rebased 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
« no previous file with comments | « runtime/vm/flow_graph_compiler_x64.cc ('k') | runtime/vm/intermediate_language.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 (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"
11 #include "vm/handles_impl.h" 11 #include "vm/handles_impl.h"
12 #include "vm/locations.h" 12 #include "vm/locations.h"
13 #include "vm/object.h" 13 #include "vm/object.h"
14 14
15 namespace dart { 15 namespace dart {
16 16
17 DECLARE_FLAG(bool, throw_on_javascript_int_overflow); 17 DECLARE_FLAG(bool, throw_on_javascript_int_overflow);
18 18
19 class BitVector; 19 class BitVector;
20 class BlockEntryInstr; 20 class BlockEntryInstr;
21 class BufferFormatter; 21 class BufferFormatter;
22 class CatchBlockEntryInstr; 22 class CatchBlockEntryInstr;
23 class ComparisonInstr; 23 class ComparisonInstr;
24 class ControlInstruction;
25 class Definition; 24 class Definition;
26 class Environment; 25 class Environment;
27 class FlowGraph; 26 class FlowGraph;
28 class FlowGraphBuilder; 27 class FlowGraphBuilder;
29 class FlowGraphCompiler; 28 class FlowGraphCompiler;
30 class FlowGraphVisitor; 29 class FlowGraphVisitor;
31 class Instruction; 30 class Instruction;
32 class LocalVariable; 31 class LocalVariable;
33 class ParsedFunction; 32 class ParsedFunction;
34 class Range; 33 class Range;
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 } 738 }
740 739
741 ICData* GetICData(const Array& ic_data_array) const; 740 ICData* GetICData(const Array& ic_data_array) const;
742 741
743 bool IsBlockEntry() { return (AsBlockEntry() != NULL); } 742 bool IsBlockEntry() { return (AsBlockEntry() != NULL); }
744 virtual BlockEntryInstr* AsBlockEntry() { return NULL; } 743 virtual BlockEntryInstr* AsBlockEntry() { return NULL; }
745 744
746 bool IsDefinition() { return (AsDefinition() != NULL); } 745 bool IsDefinition() { return (AsDefinition() != NULL); }
747 virtual Definition* AsDefinition() { return NULL; } 746 virtual Definition* AsDefinition() { return NULL; }
748 747
749 bool IsControl() { return (AsControl() != NULL); }
750 virtual ControlInstruction* AsControl() { return NULL; }
751
752 virtual intptr_t InputCount() const = 0; 748 virtual intptr_t InputCount() const = 0;
753 virtual Value* InputAt(intptr_t i) const = 0; 749 virtual Value* InputAt(intptr_t i) const = 0;
754 void SetInputAt(intptr_t i, Value* value) { 750 void SetInputAt(intptr_t i, Value* value) {
755 ASSERT(value != NULL); 751 ASSERT(value != NULL);
756 value->set_instruction(this); 752 value->set_instruction(this);
757 value->set_use_index(i); 753 value->set_use_index(i);
758 RawSetInputAt(i, value); 754 RawSetInputAt(i, value);
759 } 755 }
760 756
761 // Remove all inputs (including in the environment) from their 757 // Remove all inputs (including in the environment) from their
(...skipping 18 matching lines...) Expand all
780 Instruction* previous() const { return previous_; } 776 Instruction* previous() const { return previous_; }
781 void set_previous(Instruction* instr) { 777 void set_previous(Instruction* instr) {
782 ASSERT(!IsBlockEntry()); 778 ASSERT(!IsBlockEntry());
783 previous_ = instr; 779 previous_ = instr;
784 } 780 }
785 781
786 Instruction* next() const { return next_; } 782 Instruction* next() const { return next_; }
787 void set_next(Instruction* instr) { 783 void set_next(Instruction* instr) {
788 ASSERT(!IsGraphEntry()); 784 ASSERT(!IsGraphEntry());
789 ASSERT(!IsReturn()); 785 ASSERT(!IsReturn());
790 ASSERT(!IsControl() || (instr == NULL)); 786 ASSERT(!IsBranch() || (instr == NULL));
791 ASSERT(!IsPhi()); 787 ASSERT(!IsPhi());
792 ASSERT(instr == NULL || !instr->IsBlockEntry()); 788 ASSERT(instr == NULL || !instr->IsBlockEntry());
793 // TODO(fschneider): Also add Throw and ReThrow to the list of instructions 789 // TODO(fschneider): Also add Throw and ReThrow to the list of instructions
794 // that do not have a successor. Currently, the graph builder will continue 790 // that do not have a successor. Currently, the graph builder will continue
795 // to append instruction in case of a Throw inside an expression. This 791 // to append instruction in case of a Throw inside an expression. This
796 // condition should be handled in the graph builder 792 // condition should be handled in the graph builder
797 next_ = instr; 793 next_ = instr;
798 } 794 }
799 795
800 // Link together two instruction. 796 // Link together two instruction.
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 friend class CheckArrayBoundInstr; 995 friend class CheckArrayBoundInstr;
1000 friend class CheckEitherNonSmiInstr; 996 friend class CheckEitherNonSmiInstr;
1001 friend class LICM; 997 friend class LICM;
1002 friend class DoubleToSmiInstr; 998 friend class DoubleToSmiInstr;
1003 friend class DoubleToDoubleInstr; 999 friend class DoubleToDoubleInstr;
1004 friend class InvokeMathCFunctionInstr; 1000 friend class InvokeMathCFunctionInstr;
1005 friend class FlowGraphOptimizer; 1001 friend class FlowGraphOptimizer;
1006 friend class LoadIndexedInstr; 1002 friend class LoadIndexedInstr;
1007 friend class StoreIndexedInstr; 1003 friend class StoreIndexedInstr;
1008 friend class StoreInstanceFieldInstr; 1004 friend class StoreInstanceFieldInstr;
1009 friend class ControlInstruction;
1010 friend class ComparisonInstr; 1005 friend class ComparisonInstr;
1011 friend class TargetEntryInstr; 1006 friend class TargetEntryInstr;
1012 friend class JoinEntryInstr; 1007 friend class JoinEntryInstr;
1013 friend class InstanceOfInstr; 1008 friend class InstanceOfInstr;
1014 friend class PolymorphicInstanceCallInstr; 1009 friend class PolymorphicInstanceCallInstr;
1015 friend class SmiToDoubleInstr; 1010 friend class SmiToDoubleInstr;
1016 friend class DoubleToIntegerInstr; 1011 friend class DoubleToIntegerInstr;
1017 friend class BranchSimplifier; 1012 friend class BranchSimplifier;
1018 friend class BlockEntryInstr; 1013 friend class BlockEntryInstr;
1019 friend class RelationalOpInstr; 1014 friend class RelationalOpInstr;
(...skipping 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after
2126 private: 2121 private:
2127 JoinEntryInstr* successor_; 2122 JoinEntryInstr* successor_;
2128 double edge_weight_; 2123 double edge_weight_;
2129 2124
2130 // Parallel move that will be used by linear scan register allocator to 2125 // Parallel move that will be used by linear scan register allocator to
2131 // connect live ranges at the end of the block and resolve phis. 2126 // connect live ranges at the end of the block and resolve phis.
2132 ParallelMoveInstr* parallel_move_; 2127 ParallelMoveInstr* parallel_move_;
2133 }; 2128 };
2134 2129
2135 2130
2136 class ControlInstruction : public Instruction { 2131 class BranchInstr : public Instruction {
2137 public:
2138 ControlInstruction() : true_successor_(NULL), false_successor_(NULL) { }
2139
2140 virtual ControlInstruction* AsControl() { return this; }
2141
2142 TargetEntryInstr* true_successor() const { return true_successor_; }
2143 TargetEntryInstr* false_successor() const { return false_successor_; }
2144
2145 TargetEntryInstr** true_successor_address() { return &true_successor_; }
2146 TargetEntryInstr** false_successor_address() { return &false_successor_; }
2147
2148 virtual intptr_t SuccessorCount() const;
2149 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const;
2150
2151 void EmitBranchOnCondition(FlowGraphCompiler* compiler,
2152 Condition true_condition);
2153
2154 void EmitBranchOnValue(FlowGraphCompiler* compiler, bool result);
2155
2156 private:
2157 TargetEntryInstr* true_successor_;
2158 TargetEntryInstr* false_successor_;
2159
2160 DISALLOW_COPY_AND_ASSIGN(ControlInstruction);
2161 };
2162
2163
2164 class BranchInstr : public ControlInstruction {
2165 public: 2132 public:
2166 explicit BranchInstr(ComparisonInstr* comparison, bool is_checked = false); 2133 explicit BranchInstr(ComparisonInstr* comparison, bool is_checked = false);
2167 2134
2168 DECLARE_INSTRUCTION(Branch) 2135 DECLARE_INSTRUCTION(Branch)
2169 2136
2170 virtual intptr_t ArgumentCount() const; 2137 virtual intptr_t ArgumentCount() const;
2171 intptr_t InputCount() const; 2138 intptr_t InputCount() const;
2172 Value* InputAt(intptr_t i) const; 2139 Value* InputAt(intptr_t i) const;
2173 virtual bool CanDeoptimize() const; 2140 virtual bool CanDeoptimize() const;
2174 virtual bool CanBecomeDeoptimizationTarget() const; 2141 virtual bool CanBecomeDeoptimizationTarget() const;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2213 constant_target_ = target; 2180 constant_target_ = target;
2214 } 2181 }
2215 TargetEntryInstr* constant_target() const { 2182 TargetEntryInstr* constant_target() const {
2216 return constant_target_; 2183 return constant_target_;
2217 } 2184 }
2218 2185
2219 virtual void InheritDeoptTarget(Instruction* other); 2186 virtual void InheritDeoptTarget(Instruction* other);
2220 2187
2221 virtual bool MayThrow() const; 2188 virtual bool MayThrow() const;
2222 2189
2190 TargetEntryInstr* true_successor() const { return true_successor_; }
2191 TargetEntryInstr* false_successor() const { return false_successor_; }
2192
2193 TargetEntryInstr** true_successor_address() { return &true_successor_; }
2194 TargetEntryInstr** false_successor_address() { return &false_successor_; }
2195
2196 virtual intptr_t SuccessorCount() const;
2197 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const;
2198
2223 private: 2199 private:
2224 virtual void RawSetInputAt(intptr_t i, Value* value); 2200 virtual void RawSetInputAt(intptr_t i, Value* value);
2225 2201
2202 TargetEntryInstr* true_successor_;
2203 TargetEntryInstr* false_successor_;
2226 ComparisonInstr* comparison_; 2204 ComparisonInstr* comparison_;
2227 const bool is_checked_; 2205 const bool is_checked_;
2228
2229 ConstrainedCompileType* constrained_type_; 2206 ConstrainedCompileType* constrained_type_;
2230
2231 TargetEntryInstr* constant_target_; 2207 TargetEntryInstr* constant_target_;
2232 2208
2233 DISALLOW_COPY_AND_ASSIGN(BranchInstr); 2209 DISALLOW_COPY_AND_ASSIGN(BranchInstr);
2234 }; 2210 };
2235 2211
2236 2212
2237 class StoreContextInstr : public TemplateInstruction<1> { 2213 class StoreContextInstr : public TemplateInstruction<1> {
2238 public: 2214 public:
2239 explicit StoreContextInstr(Value* value) { 2215 explicit StoreContextInstr(Value* value) {
2240 SetInputAt(kValuePos, value); 2216 SetInputAt(kValuePos, value);
(...skipping 4698 matching lines...) Expand 10 before | Expand all | Expand 10 after
6939 ForwardInstructionIterator* current_iterator_; 6915 ForwardInstructionIterator* current_iterator_;
6940 6916
6941 private: 6917 private:
6942 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 6918 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
6943 }; 6919 };
6944 6920
6945 6921
6946 } // namespace dart 6922 } // namespace dart
6947 6923
6948 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 6924 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler_x64.cc ('k') | runtime/vm/intermediate_language.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698