Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 class BitVector; | 17 class BitVector; |
| 18 class BlockEntryInstr; | 18 class BlockEntryInstr; |
| 19 class BufferFormatter; | 19 class BufferFormatter; |
| 20 class CatchBlockEntryInstr; | 20 class CatchBlockEntryInstr; |
| 21 class ComparisonInstr; | 21 class ComparisonInstr; |
| 22 class ControlInstruction; | 22 class ControlInstruction; |
| 23 class Definition; | 23 class Definition; |
| 24 class Environment; | 24 class Environment; |
| 25 class FlowGraph; | 25 class FlowGraph; |
| 26 class FlowGraphBuilder; | |
| 26 class FlowGraphCompiler; | 27 class FlowGraphCompiler; |
| 27 class FlowGraphVisitor; | 28 class FlowGraphVisitor; |
| 28 class Instruction; | 29 class Instruction; |
| 29 class LocalVariable; | 30 class LocalVariable; |
| 30 class ParsedFunction; | 31 class ParsedFunction; |
| 31 class Range; | 32 class Range; |
| 32 | 33 |
| 33 | 34 |
| 34 // TODO(srdjan): Unify with INTRINSIC_LIST. | 35 // TODO(srdjan): Unify with INTRINSIC_LIST. |
| 35 // (class-name, function-name, recognized enum, fingerprint). | 36 // (class-name, function-name, recognized enum, fingerprint). |
| (...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 861 | 862 |
| 862 protected: | 863 protected: |
| 863 // Fetch deopt id without checking if this computation can deoptimize. | 864 // Fetch deopt id without checking if this computation can deoptimize. |
| 864 intptr_t GetDeoptId() const { | 865 intptr_t GetDeoptId() const { |
| 865 return deopt_id_; | 866 return deopt_id_; |
| 866 } | 867 } |
| 867 | 868 |
| 868 private: | 869 private: |
| 869 friend class Definition; // Needed for InsertBefore, InsertAfter. | 870 friend class Definition; // Needed for InsertBefore, InsertAfter. |
| 870 | 871 |
| 871 // Classes that set deopt_id_. | 872 // Classes that set or read deopt_id_. |
| 872 friend class UnboxIntegerInstr; | 873 friend class UnboxIntegerInstr; |
| 873 friend class UnboxDoubleInstr; | 874 friend class UnboxDoubleInstr; |
| 874 friend class UnboxFloat32x4Instr; | 875 friend class UnboxFloat32x4Instr; |
| 875 friend class UnboxUint32x4Instr; | 876 friend class UnboxUint32x4Instr; |
| 876 friend class BinaryDoubleOpInstr; | 877 friend class BinaryDoubleOpInstr; |
| 877 friend class BinaryFloat32x4OpInstr; | 878 friend class BinaryFloat32x4OpInstr; |
| 878 friend class Float32x4ZeroInstr; | 879 friend class Float32x4ZeroInstr; |
| 879 friend class Float32x4SplatInstr; | 880 friend class Float32x4SplatInstr; |
| 880 friend class Float32x4ShuffleInstr; | 881 friend class Float32x4ShuffleInstr; |
| 881 friend class Float32x4ConstructorInstr; | 882 friend class Float32x4ConstructorInstr; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 914 friend class StoreInstanceFieldInstr; | 915 friend class StoreInstanceFieldInstr; |
| 915 friend class ControlInstruction; | 916 friend class ControlInstruction; |
| 916 friend class ComparisonInstr; | 917 friend class ComparisonInstr; |
| 917 friend class TargetEntryInstr; | 918 friend class TargetEntryInstr; |
| 918 friend class JoinEntryInstr; | 919 friend class JoinEntryInstr; |
| 919 friend class InstanceOfInstr; | 920 friend class InstanceOfInstr; |
| 920 friend class PolymorphicInstanceCallInstr; | 921 friend class PolymorphicInstanceCallInstr; |
| 921 friend class SmiToDoubleInstr; | 922 friend class SmiToDoubleInstr; |
| 922 friend class DoubleToIntegerInstr; | 923 friend class DoubleToIntegerInstr; |
| 923 friend class BranchSimplifier; | 924 friend class BranchSimplifier; |
| 925 friend class BlockEntryInstr; | |
| 924 | 926 |
| 925 virtual void RawSetInputAt(intptr_t i, Value* value) = 0; | 927 virtual void RawSetInputAt(intptr_t i, Value* value) = 0; |
| 926 | 928 |
| 927 enum { | 929 enum { |
| 928 kNoExprId = -1 | 930 kNoExprId = -1 |
| 929 }; | 931 }; |
| 930 | 932 |
| 931 intptr_t deopt_id_; | 933 intptr_t deopt_id_; |
| 932 intptr_t lifetime_position_; // Position used by register allocator. | 934 intptr_t lifetime_position_; // Position used by register allocator. |
| 933 Instruction* previous_; | 935 Instruction* previous_; |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1136 // block entry instructions of predecessor blocks) and also the last | 1138 // block entry instructions of predecessor blocks) and also the last |
| 1137 // instruction in the block is recorded in each entry instruction. | 1139 // instruction in the block is recorded in each entry instruction. |
| 1138 void DiscoverBlocks( | 1140 void DiscoverBlocks( |
| 1139 BlockEntryInstr* predecessor, | 1141 BlockEntryInstr* predecessor, |
| 1140 GrowableArray<BlockEntryInstr*>* preorder, | 1142 GrowableArray<BlockEntryInstr*>* preorder, |
| 1141 GrowableArray<BlockEntryInstr*>* postorder, | 1143 GrowableArray<BlockEntryInstr*>* postorder, |
| 1142 GrowableArray<intptr_t>* parent, | 1144 GrowableArray<intptr_t>* parent, |
| 1143 intptr_t variable_count, | 1145 intptr_t variable_count, |
| 1144 intptr_t fixed_parameter_count); | 1146 intptr_t fixed_parameter_count); |
| 1145 | 1147 |
| 1148 // Perform a depth first search to prune code not reachable from an OSR | |
| 1149 // entry point. | |
| 1150 bool PruneUnreachable(FlowGraphBuilder* builder, | |
| 1151 GraphEntryInstr* graph_entry, | |
| 1152 intptr_t osr_id, | |
| 1153 BitVector* block_marks); | |
| 1154 | |
| 1146 virtual intptr_t InputCount() const { return 0; } | 1155 virtual intptr_t InputCount() const { return 0; } |
| 1147 virtual Value* InputAt(intptr_t i) const { | 1156 virtual Value* InputAt(intptr_t i) const { |
| 1148 UNREACHABLE(); | 1157 UNREACHABLE(); |
| 1149 return NULL; | 1158 return NULL; |
| 1150 } | 1159 } |
| 1151 | 1160 |
| 1152 virtual intptr_t ArgumentCount() const { return 0; } | 1161 virtual intptr_t ArgumentCount() const { return 0; } |
| 1153 | 1162 |
| 1154 virtual bool CanBecomeDeoptimizationTarget() const { | 1163 virtual bool CanBecomeDeoptimizationTarget() const { |
| 1155 // BlockEntry environment is copied to Goto and Branch instructions | 1164 // BlockEntry environment is copied to Goto and Branch instructions |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1274 | 1283 |
| 1275 private: | 1284 private: |
| 1276 BlockEntryInstr* block_entry_; | 1285 BlockEntryInstr* block_entry_; |
| 1277 Instruction* current_; | 1286 Instruction* current_; |
| 1278 }; | 1287 }; |
| 1279 | 1288 |
| 1280 | 1289 |
| 1281 class GraphEntryInstr : public BlockEntryInstr { | 1290 class GraphEntryInstr : public BlockEntryInstr { |
| 1282 public: | 1291 public: |
| 1283 GraphEntryInstr(const ParsedFunction& parsed_function, | 1292 GraphEntryInstr(const ParsedFunction& parsed_function, |
| 1284 TargetEntryInstr* normal_entry); | 1293 TargetEntryInstr* normal_entry, |
| 1294 intptr_t osr_id); | |
| 1285 | 1295 |
| 1286 DECLARE_INSTRUCTION(GraphEntry) | 1296 DECLARE_INSTRUCTION(GraphEntry) |
| 1287 | 1297 |
| 1288 virtual intptr_t PredecessorCount() const { return 0; } | 1298 virtual intptr_t PredecessorCount() const { return 0; } |
| 1289 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const { | 1299 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const { |
| 1290 UNREACHABLE(); | 1300 UNREACHABLE(); |
| 1291 return NULL; | 1301 return NULL; |
| 1292 } | 1302 } |
| 1293 virtual intptr_t SuccessorCount() const; | 1303 virtual intptr_t SuccessorCount() const; |
| 1294 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const; | 1304 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const; |
| 1295 | 1305 |
| 1296 void AddCatchEntry(CatchBlockEntryInstr* entry) { catch_entries_.Add(entry); } | 1306 void AddCatchEntry(CatchBlockEntryInstr* entry) { catch_entries_.Add(entry); } |
| 1297 | 1307 |
| 1298 CatchBlockEntryInstr* GetCatchEntry(intptr_t index); | 1308 CatchBlockEntryInstr* GetCatchEntry(intptr_t index); |
| 1299 | 1309 |
| 1300 GrowableArray<Definition*>* initial_definitions() { | 1310 GrowableArray<Definition*>* initial_definitions() { |
| 1301 return &initial_definitions_; | 1311 return &initial_definitions_; |
| 1302 } | 1312 } |
| 1303 ConstantInstr* constant_null(); | 1313 ConstantInstr* constant_null(); |
| 1304 | 1314 |
| 1315 bool IsCompiledForOsr() const { return osr_id_ != Isolate::kNoDeoptId; } | |
| 1316 | |
| 1305 intptr_t spill_slot_count() const { return spill_slot_count_; } | 1317 intptr_t spill_slot_count() const { return spill_slot_count_; } |
| 1306 void set_spill_slot_count(intptr_t count) { | 1318 void set_spill_slot_count(intptr_t count) { |
| 1307 ASSERT(count >= 0); | 1319 ASSERT(count >= 0); |
| 1308 spill_slot_count_ = count; | 1320 spill_slot_count_ = count; |
| 1309 } | 1321 } |
| 1310 | 1322 |
| 1311 // Number of stack slots reserved for compiling try-catch. For functions | 1323 // Number of stack slots reserved for compiling try-catch. For functions |
| 1312 // without try-catch, this is 0. Otherwise, it is the number of local | 1324 // without try-catch, this is 0. Otherwise, it is the number of local |
| 1313 // variables. | 1325 // variables. |
| 1314 intptr_t fixed_slot_count() const { return fixed_slot_count_; } | 1326 intptr_t fixed_slot_count() const { return fixed_slot_count_; } |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 1329 virtual void PrintTo(BufferFormatter* f) const; | 1341 virtual void PrintTo(BufferFormatter* f) const; |
| 1330 | 1342 |
| 1331 private: | 1343 private: |
| 1332 virtual void ClearPredecessors() {} | 1344 virtual void ClearPredecessors() {} |
| 1333 virtual void AddPredecessor(BlockEntryInstr* predecessor) { UNREACHABLE(); } | 1345 virtual void AddPredecessor(BlockEntryInstr* predecessor) { UNREACHABLE(); } |
| 1334 | 1346 |
| 1335 const ParsedFunction& parsed_function_; | 1347 const ParsedFunction& parsed_function_; |
| 1336 TargetEntryInstr* normal_entry_; | 1348 TargetEntryInstr* normal_entry_; |
| 1337 GrowableArray<CatchBlockEntryInstr*> catch_entries_; | 1349 GrowableArray<CatchBlockEntryInstr*> catch_entries_; |
| 1338 GrowableArray<Definition*> initial_definitions_; | 1350 GrowableArray<Definition*> initial_definitions_; |
| 1351 const intptr_t osr_id_; | |
| 1339 intptr_t spill_slot_count_; | 1352 intptr_t spill_slot_count_; |
| 1340 intptr_t fixed_slot_count_; // For try-catch in optimized code. | 1353 intptr_t fixed_slot_count_; // For try-catch in optimized code. |
| 1341 | 1354 |
| 1342 DISALLOW_COPY_AND_ASSIGN(GraphEntryInstr); | 1355 DISALLOW_COPY_AND_ASSIGN(GraphEntryInstr); |
| 1343 }; | 1356 }; |
| 1344 | 1357 |
| 1345 | 1358 |
| 1346 class JoinEntryInstr : public BlockEntryInstr { | 1359 class JoinEntryInstr : public BlockEntryInstr { |
| 1347 public: | 1360 public: |
| 1348 JoinEntryInstr(intptr_t block_id, intptr_t try_index) | 1361 JoinEntryInstr(intptr_t block_id, intptr_t try_index) |
| (...skipping 4547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5896 | 5909 |
| 5897 private: | 5910 private: |
| 5898 const Token::Kind op_kind_; | 5911 const Token::Kind op_kind_; |
| 5899 | 5912 |
| 5900 DISALLOW_COPY_AND_ASSIGN(UnarySmiOpInstr); | 5913 DISALLOW_COPY_AND_ASSIGN(UnarySmiOpInstr); |
| 5901 }; | 5914 }; |
| 5902 | 5915 |
| 5903 | 5916 |
| 5904 class CheckStackOverflowInstr : public TemplateInstruction<0> { | 5917 class CheckStackOverflowInstr : public TemplateInstruction<0> { |
| 5905 public: | 5918 public: |
| 5906 explicit CheckStackOverflowInstr(intptr_t token_pos) | 5919 CheckStackOverflowInstr(intptr_t token_pos, bool is_loop) |
| 5907 : token_pos_(token_pos) {} | 5920 : token_pos_(token_pos), is_loop_(is_loop) {} |
| 5908 | 5921 |
| 5909 intptr_t token_pos() const { return token_pos_; } | 5922 intptr_t token_pos() const { return token_pos_; } |
| 5923 bool is_loop() const { return is_loop_; } | |
|
srdjan
2013/06/11 17:12:02
Maybe call it 'in_loop' instead?
Kevin Millikin (Google)
2013/06/14 10:10:42
Done.
| |
| 5910 | 5924 |
| 5911 DECLARE_INSTRUCTION(CheckStackOverflow) | 5925 DECLARE_INSTRUCTION(CheckStackOverflow) |
| 5912 | 5926 |
| 5913 virtual intptr_t ArgumentCount() const { return 0; } | 5927 virtual intptr_t ArgumentCount() const { return 0; } |
| 5914 | 5928 |
| 5915 virtual bool CanDeoptimize() const { return true; } | 5929 virtual bool CanDeoptimize() const { return true; } |
| 5916 | 5930 |
| 5917 virtual EffectSet Effects() const { return EffectSet::None(); } | 5931 virtual EffectSet Effects() const { return EffectSet::None(); } |
| 5918 | 5932 |
| 5919 virtual bool MayThrow() const { return false; } | 5933 virtual bool MayThrow() const { return false; } |
| 5920 | 5934 |
| 5935 virtual void PrintOperandsTo(BufferFormatter* f) const; | |
| 5936 | |
| 5921 private: | 5937 private: |
| 5922 const intptr_t token_pos_; | 5938 const intptr_t token_pos_; |
| 5939 const bool is_loop_; | |
| 5923 | 5940 |
| 5924 DISALLOW_COPY_AND_ASSIGN(CheckStackOverflowInstr); | 5941 DISALLOW_COPY_AND_ASSIGN(CheckStackOverflowInstr); |
| 5925 }; | 5942 }; |
| 5926 | 5943 |
| 5927 | 5944 |
| 5928 class SmiToDoubleInstr : public TemplateDefinition<1> { | 5945 class SmiToDoubleInstr : public TemplateDefinition<1> { |
| 5929 public: | 5946 public: |
| 5930 explicit SmiToDoubleInstr(Value* value) { | 5947 explicit SmiToDoubleInstr(Value* value) { |
| 5931 SetInputAt(0, value); | 5948 SetInputAt(0, value); |
| 5932 } | 5949 } |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6467 ForwardInstructionIterator* current_iterator_; | 6484 ForwardInstructionIterator* current_iterator_; |
| 6468 | 6485 |
| 6469 private: | 6486 private: |
| 6470 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 6487 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
| 6471 }; | 6488 }; |
| 6472 | 6489 |
| 6473 | 6490 |
| 6474 } // namespace dart | 6491 } // namespace dart |
| 6475 | 6492 |
| 6476 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 6493 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |