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" |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 416 | 416 |
| 417 // Instructions. | 417 // Instructions. |
| 418 | 418 |
| 419 // M is a single argument macro. It is applied to each concrete instruction | 419 // M is a single argument macro. It is applied to each concrete instruction |
| 420 // type name. The concrete instruction classes are the name with Instr | 420 // type name. The concrete instruction classes are the name with Instr |
| 421 // concatenated. | 421 // concatenated. |
| 422 #define FOR_EACH_INSTRUCTION(M) \ | 422 #define FOR_EACH_INSTRUCTION(M) \ |
| 423 M(GraphEntry) \ | 423 M(GraphEntry) \ |
| 424 M(JoinEntry) \ | 424 M(JoinEntry) \ |
| 425 M(TargetEntry) \ | 425 M(TargetEntry) \ |
| 426 M(IndirectEntry) \ | |
| 426 M(CatchBlockEntry) \ | 427 M(CatchBlockEntry) \ |
| 427 M(Phi) \ | 428 M(Phi) \ |
| 428 M(Redefinition) \ | 429 M(Redefinition) \ |
| 429 M(Parameter) \ | 430 M(Parameter) \ |
| 430 M(ParallelMove) \ | 431 M(ParallelMove) \ |
| 431 M(PushArgument) \ | 432 M(PushArgument) \ |
| 432 M(Return) \ | 433 M(Return) \ |
| 433 M(Throw) \ | 434 M(Throw) \ |
| 434 M(ReThrow) \ | 435 M(ReThrow) \ |
| 435 M(Goto) \ | 436 M(Goto) \ |
| 437 M(IndirectGoto) \ | |
| 436 M(Branch) \ | 438 M(Branch) \ |
| 437 M(AssertAssignable) \ | 439 M(AssertAssignable) \ |
| 438 M(AssertBoolean) \ | 440 M(AssertBoolean) \ |
| 439 M(CurrentContext) \ | 441 M(CurrentContext) \ |
| 440 M(StoreContext) \ | 442 M(StoreContext) \ |
| 441 M(ClosureCall) \ | 443 M(ClosureCall) \ |
| 442 M(InstanceCall) \ | 444 M(InstanceCall) \ |
| 443 M(PolymorphicInstanceCall) \ | 445 M(PolymorphicInstanceCall) \ |
| 444 M(StaticCall) \ | 446 M(StaticCall) \ |
| 445 M(LoadLocal) \ | 447 M(LoadLocal) \ |
| 446 M(PushTemp) \ | 448 M(PushTemp) \ |
| 447 M(DropTemps) \ | 449 M(DropTemps) \ |
| 448 M(StoreLocal) \ | 450 M(StoreLocal) \ |
| 449 M(StrictCompare) \ | 451 M(StrictCompare) \ |
| 450 M(EqualityCompare) \ | 452 M(EqualityCompare) \ |
| 451 M(RelationalOp) \ | 453 M(RelationalOp) \ |
| 452 M(NativeCall) \ | 454 M(NativeCall) \ |
| 453 M(DebugStepCheck) \ | 455 M(DebugStepCheck) \ |
| 454 M(LoadIndexed) \ | 456 M(LoadIndexed) \ |
| 457 M(LoadCodeUnits) \ | |
| 455 M(StoreIndexed) \ | 458 M(StoreIndexed) \ |
| 456 M(StoreInstanceField) \ | 459 M(StoreInstanceField) \ |
| 457 M(InitStaticField) \ | 460 M(InitStaticField) \ |
| 458 M(LoadStaticField) \ | 461 M(LoadStaticField) \ |
| 459 M(StoreStaticField) \ | 462 M(StoreStaticField) \ |
| 460 M(BooleanNegate) \ | 463 M(BooleanNegate) \ |
| 461 M(InstanceOf) \ | 464 M(InstanceOf) \ |
| 462 M(CreateArray) \ | 465 M(CreateArray) \ |
| 463 M(AllocateObject) \ | 466 M(AllocateObject) \ |
| 464 M(LoadField) \ | 467 M(LoadField) \ |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 484 M(FloatToDouble) \ | 487 M(FloatToDouble) \ |
| 485 M(CheckClass) \ | 488 M(CheckClass) \ |
| 486 M(CheckClassId) \ | 489 M(CheckClassId) \ |
| 487 M(CheckSmi) \ | 490 M(CheckSmi) \ |
| 488 M(Constant) \ | 491 M(Constant) \ |
| 489 M(UnboxedConstant) \ | 492 M(UnboxedConstant) \ |
| 490 M(CheckEitherNonSmi) \ | 493 M(CheckEitherNonSmi) \ |
| 491 M(BinaryDoubleOp) \ | 494 M(BinaryDoubleOp) \ |
| 492 M(MathUnary) \ | 495 M(MathUnary) \ |
| 493 M(MathMinMax) \ | 496 M(MathMinMax) \ |
| 497 M(CaseInsensitiveCompareUC16) \ | |
| 494 M(UnboxDouble) \ | 498 M(UnboxDouble) \ |
| 495 M(BoxDouble) \ | 499 M(BoxDouble) \ |
| 496 M(BoxFloat32x4) \ | 500 M(BoxFloat32x4) \ |
| 497 M(UnboxFloat32x4) \ | 501 M(UnboxFloat32x4) \ |
| 498 M(BoxInt32x4) \ | 502 M(BoxInt32x4) \ |
| 499 M(UnboxInt32x4) \ | 503 M(UnboxInt32x4) \ |
| 500 M(UnboxInteger) \ | 504 M(UnboxInteger) \ |
| 501 M(BoxInteger) \ | 505 M(BoxInteger) \ |
| 502 M(BinaryMintOp) \ | 506 M(BinaryMintOp) \ |
| 503 M(ShiftMintOp) \ | 507 M(ShiftMintOp) \ |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 879 friend class Int32x4BoolConstructorInstr; | 883 friend class Int32x4BoolConstructorInstr; |
| 880 friend class Int32x4GetFlagInstr; | 884 friend class Int32x4GetFlagInstr; |
| 881 friend class Int32x4SetFlagInstr; | 885 friend class Int32x4SetFlagInstr; |
| 882 friend class Int32x4SelectInstr; | 886 friend class Int32x4SelectInstr; |
| 883 friend class Int32x4ToFloat32x4Instr; | 887 friend class Int32x4ToFloat32x4Instr; |
| 884 friend class BinaryInt32x4OpInstr; | 888 friend class BinaryInt32x4OpInstr; |
| 885 friend class BinaryFloat64x2OpInstr; | 889 friend class BinaryFloat64x2OpInstr; |
| 886 friend class UnaryDoubleOpInstr; | 890 friend class UnaryDoubleOpInstr; |
| 887 friend class MathUnaryInstr; | 891 friend class MathUnaryInstr; |
| 888 friend class MathMinMaxInstr; | 892 friend class MathMinMaxInstr; |
| 893 friend class CaseInsensitiveCompareUC16Instr; | |
| 889 friend class CheckClassInstr; | 894 friend class CheckClassInstr; |
| 890 friend class CheckClassIdInstr; | 895 friend class CheckClassIdInstr; |
| 891 friend class GuardFieldInstr; | 896 friend class GuardFieldInstr; |
| 892 friend class CheckSmiInstr; | 897 friend class CheckSmiInstr; |
| 893 friend class CheckArrayBoundInstr; | 898 friend class CheckArrayBoundInstr; |
| 894 friend class CheckEitherNonSmiInstr; | 899 friend class CheckEitherNonSmiInstr; |
| 895 friend class LICM; | 900 friend class LICM; |
| 896 friend class DoubleToSmiInstr; | 901 friend class DoubleToSmiInstr; |
| 897 friend class DoubleToDoubleInstr; | 902 friend class DoubleToDoubleInstr; |
| 898 friend class DoubleToFloatInstr; | 903 friend class DoubleToFloatInstr; |
| 899 friend class FloatToDoubleInstr; | 904 friend class FloatToDoubleInstr; |
| 900 friend class InvokeMathCFunctionInstr; | 905 friend class InvokeMathCFunctionInstr; |
| 901 friend class MergedMathInstr; | 906 friend class MergedMathInstr; |
| 902 friend class FlowGraphOptimizer; | 907 friend class FlowGraphOptimizer; |
| 903 friend class LoadIndexedInstr; | 908 friend class LoadIndexedInstr; |
| 909 friend class LoadCodeUnitsInstr; | |
| 904 friend class StoreIndexedInstr; | 910 friend class StoreIndexedInstr; |
| 905 friend class StoreInstanceFieldInstr; | 911 friend class StoreInstanceFieldInstr; |
| 906 friend class ComparisonInstr; | 912 friend class ComparisonInstr; |
| 907 friend class TargetEntryInstr; | 913 friend class TargetEntryInstr; |
| 914 friend class IndirectEntryInstr; | |
| 908 friend class JoinEntryInstr; | 915 friend class JoinEntryInstr; |
| 909 friend class InstanceOfInstr; | 916 friend class InstanceOfInstr; |
| 910 friend class PolymorphicInstanceCallInstr; | 917 friend class PolymorphicInstanceCallInstr; |
| 911 friend class SmiToDoubleInstr; | 918 friend class SmiToDoubleInstr; |
| 912 friend class MintToDoubleInstr; | 919 friend class MintToDoubleInstr; |
| 913 friend class DoubleToIntegerInstr; | 920 friend class DoubleToIntegerInstr; |
| 914 friend class BranchSimplifier; | 921 friend class BranchSimplifier; |
| 915 friend class BlockEntryInstr; | 922 friend class BlockEntryInstr; |
| 916 friend class RelationalOpInstr; | 923 friend class RelationalOpInstr; |
| 917 friend class EqualityCompareInstr; | 924 friend class EqualityCompareInstr; |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1180 return const_cast<BlockEntryInstr*>(this); | 1187 return const_cast<BlockEntryInstr*>(this); |
| 1181 } | 1188 } |
| 1182 | 1189 |
| 1183 // Helper to mutate the graph during inlining. This block should be | 1190 // Helper to mutate the graph during inlining. This block should be |
| 1184 // replaced with new_block as a predecessor of all of this block's | 1191 // replaced with new_block as a predecessor of all of this block's |
| 1185 // successors. | 1192 // successors. |
| 1186 void ReplaceAsPredecessorWith(BlockEntryInstr* new_block); | 1193 void ReplaceAsPredecessorWith(BlockEntryInstr* new_block); |
| 1187 | 1194 |
| 1188 void set_block_id(intptr_t block_id) { block_id_ = block_id; } | 1195 void set_block_id(intptr_t block_id) { block_id_ = block_id; } |
| 1189 | 1196 |
| 1197 intptr_t offset() const { return offset_; } | |
| 1198 void set_offset(intptr_t offset) { offset_ = offset; } | |
| 1199 | |
| 1190 // For all instruction in this block: Remove all inputs (including in the | 1200 // For all instruction in this block: Remove all inputs (including in the |
| 1191 // environment) from their definition's use lists for all instructions. | 1201 // environment) from their definition's use lists for all instructions. |
| 1192 void ClearAllInstructions(); | 1202 void ClearAllInstructions(); |
| 1193 | 1203 |
| 1194 DEFINE_INSTRUCTION_TYPE_CHECK(BlockEntry) | 1204 DEFINE_INSTRUCTION_TYPE_CHECK(BlockEntry) |
| 1195 | 1205 |
| 1196 protected: | 1206 protected: |
| 1197 BlockEntryInstr(intptr_t block_id, intptr_t try_index) | 1207 BlockEntryInstr(intptr_t block_id, intptr_t try_index) |
| 1198 : block_id_(block_id), | 1208 : block_id_(block_id), |
| 1199 try_index_(try_index), | 1209 try_index_(try_index), |
| 1200 preorder_number_(-1), | 1210 preorder_number_(-1), |
| 1201 postorder_number_(-1), | 1211 postorder_number_(-1), |
| 1202 dominator_(NULL), | 1212 dominator_(NULL), |
| 1203 dominated_blocks_(1), | 1213 dominated_blocks_(1), |
| 1204 last_instruction_(NULL), | 1214 last_instruction_(NULL), |
| 1215 offset_(-1), | |
| 1205 parallel_move_(NULL), | 1216 parallel_move_(NULL), |
| 1206 loop_info_(NULL) { } | 1217 loop_info_(NULL) { } |
| 1207 | 1218 |
| 1208 private: | 1219 private: |
| 1209 virtual void RawSetInputAt(intptr_t i, Value* value) { UNREACHABLE(); } | 1220 virtual void RawSetInputAt(intptr_t i, Value* value) { UNREACHABLE(); } |
| 1210 | 1221 |
| 1211 virtual void ClearPredecessors() = 0; | 1222 virtual void ClearPredecessors() = 0; |
| 1212 virtual void AddPredecessor(BlockEntryInstr* predecessor) = 0; | 1223 virtual void AddPredecessor(BlockEntryInstr* predecessor) = 0; |
| 1213 | 1224 |
| 1214 void set_dominator(BlockEntryInstr* instr) { dominator_ = instr; } | 1225 void set_dominator(BlockEntryInstr* instr) { dominator_ = instr; } |
| 1215 | 1226 |
| 1216 intptr_t block_id_; | 1227 intptr_t block_id_; |
| 1217 const intptr_t try_index_; | 1228 const intptr_t try_index_; |
| 1218 intptr_t preorder_number_; | 1229 intptr_t preorder_number_; |
| 1219 intptr_t postorder_number_; | 1230 intptr_t postorder_number_; |
| 1220 // Starting and ending lifetime positions for this block. Used by | 1231 // Starting and ending lifetime positions for this block. Used by |
| 1221 // the linear scan register allocator. | 1232 // the linear scan register allocator. |
| 1222 intptr_t start_pos_; | 1233 intptr_t start_pos_; |
| 1223 intptr_t end_pos_; | 1234 intptr_t end_pos_; |
| 1224 BlockEntryInstr* dominator_; // Immediate dominator, NULL for graph entry. | 1235 BlockEntryInstr* dominator_; // Immediate dominator, NULL for graph entry. |
| 1225 // TODO(fschneider): Optimize the case of one child to save space. | 1236 // TODO(fschneider): Optimize the case of one child to save space. |
| 1226 GrowableArray<BlockEntryInstr*> dominated_blocks_; | 1237 GrowableArray<BlockEntryInstr*> dominated_blocks_; |
| 1227 Instruction* last_instruction_; | 1238 Instruction* last_instruction_; |
| 1228 | 1239 |
| 1240 // Offset of this block from the start of the emitted code. | |
| 1241 intptr_t offset_; | |
| 1242 | |
| 1229 // Parallel move that will be used by linear scan register allocator to | 1243 // Parallel move that will be used by linear scan register allocator to |
| 1230 // connect live ranges at the start of the block. | 1244 // connect live ranges at the start of the block. |
| 1231 ParallelMoveInstr* parallel_move_; | 1245 ParallelMoveInstr* parallel_move_; |
| 1232 | 1246 |
| 1233 // Bit vector containg loop blocks for a loop header indexed by block | 1247 // Bit vector containg loop blocks for a loop header indexed by block |
| 1234 // preorder number. | 1248 // preorder number. |
| 1235 BitVector* loop_info_; | 1249 BitVector* loop_info_; |
| 1236 | 1250 |
| 1237 DISALLOW_COPY_AND_ASSIGN(BlockEntryInstr); | 1251 DISALLOW_COPY_AND_ASSIGN(BlockEntryInstr); |
| 1238 }; | 1252 }; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1299 UNREACHABLE(); | 1313 UNREACHABLE(); |
| 1300 return NULL; | 1314 return NULL; |
| 1301 } | 1315 } |
| 1302 virtual intptr_t SuccessorCount() const; | 1316 virtual intptr_t SuccessorCount() const; |
| 1303 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const; | 1317 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const; |
| 1304 | 1318 |
| 1305 void AddCatchEntry(CatchBlockEntryInstr* entry) { catch_entries_.Add(entry); } | 1319 void AddCatchEntry(CatchBlockEntryInstr* entry) { catch_entries_.Add(entry); } |
| 1306 | 1320 |
| 1307 CatchBlockEntryInstr* GetCatchEntry(intptr_t index); | 1321 CatchBlockEntryInstr* GetCatchEntry(intptr_t index); |
| 1308 | 1322 |
| 1323 void AddIndirectEntry(IndirectEntryInstr* entry) { | |
| 1324 indirect_entries_.Add(entry); | |
| 1325 } | |
| 1326 | |
| 1327 JoinEntryInstr* GetIndirectTargetEntry(intptr_t index); | |
| 1328 | |
| 1309 GrowableArray<Definition*>* initial_definitions() { | 1329 GrowableArray<Definition*>* initial_definitions() { |
| 1310 return &initial_definitions_; | 1330 return &initial_definitions_; |
| 1311 } | 1331 } |
| 1312 ConstantInstr* constant_null(); | 1332 ConstantInstr* constant_null(); |
| 1313 | 1333 |
| 1314 bool IsCompiledForOsr() const { return osr_id_ != Isolate::kNoDeoptId; } | 1334 bool IsCompiledForOsr() const { return osr_id_ != Isolate::kNoDeoptId; } |
| 1315 | 1335 |
| 1316 intptr_t entry_count() const { return entry_count_; } | 1336 intptr_t entry_count() const { return entry_count_; } |
| 1317 void set_entry_count(intptr_t count) { entry_count_ = count; } | 1337 void set_entry_count(intptr_t count) { entry_count_ = count; } |
| 1318 | 1338 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 1333 TargetEntryInstr* normal_entry() const { return normal_entry_; } | 1353 TargetEntryInstr* normal_entry() const { return normal_entry_; } |
| 1334 | 1354 |
| 1335 const ParsedFunction& parsed_function() const { | 1355 const ParsedFunction& parsed_function() const { |
| 1336 return *parsed_function_; | 1356 return *parsed_function_; |
| 1337 } | 1357 } |
| 1338 | 1358 |
| 1339 const GrowableArray<CatchBlockEntryInstr*>& catch_entries() const { | 1359 const GrowableArray<CatchBlockEntryInstr*>& catch_entries() const { |
| 1340 return catch_entries_; | 1360 return catch_entries_; |
| 1341 } | 1361 } |
| 1342 | 1362 |
| 1363 const GrowableArray<IndirectEntryInstr*>& indirect_entries() const { | |
| 1364 return indirect_entries_; | |
| 1365 } | |
| 1366 | |
| 1343 virtual void PrintTo(BufferFormatter* f) const; | 1367 virtual void PrintTo(BufferFormatter* f) const; |
| 1344 | 1368 |
| 1345 private: | 1369 private: |
| 1346 virtual void ClearPredecessors() {} | 1370 virtual void ClearPredecessors() {} |
| 1347 virtual void AddPredecessor(BlockEntryInstr* predecessor) { UNREACHABLE(); } | 1371 virtual void AddPredecessor(BlockEntryInstr* predecessor) { UNREACHABLE(); } |
| 1348 | 1372 |
| 1349 const ParsedFunction* parsed_function_; | 1373 const ParsedFunction* parsed_function_; |
| 1350 TargetEntryInstr* normal_entry_; | 1374 TargetEntryInstr* normal_entry_; |
| 1351 GrowableArray<CatchBlockEntryInstr*> catch_entries_; | 1375 GrowableArray<CatchBlockEntryInstr*> catch_entries_; |
| 1376 // Indirect targets are blocks reachable only through indirect gotos. | |
| 1377 GrowableArray<IndirectEntryInstr*> indirect_entries_; | |
| 1352 GrowableArray<Definition*> initial_definitions_; | 1378 GrowableArray<Definition*> initial_definitions_; |
| 1353 const intptr_t osr_id_; | 1379 const intptr_t osr_id_; |
| 1354 intptr_t entry_count_; | 1380 intptr_t entry_count_; |
| 1355 intptr_t spill_slot_count_; | 1381 intptr_t spill_slot_count_; |
| 1356 intptr_t fixed_slot_count_; // For try-catch in optimized code. | 1382 intptr_t fixed_slot_count_; // For try-catch in optimized code. |
| 1357 | 1383 |
| 1358 DISALLOW_COPY_AND_ASSIGN(GraphEntryInstr); | 1384 DISALLOW_COPY_AND_ASSIGN(GraphEntryInstr); |
| 1359 }; | 1385 }; |
| 1360 | 1386 |
| 1361 | 1387 |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 1387 virtual void PrintTo(BufferFormatter* f) const; | 1413 virtual void PrintTo(BufferFormatter* f) const; |
| 1388 | 1414 |
| 1389 virtual EffectSet Effects() const { return EffectSet::None(); } | 1415 virtual EffectSet Effects() const { return EffectSet::None(); } |
| 1390 virtual EffectSet Dependencies() const { return EffectSet::None(); } | 1416 virtual EffectSet Dependencies() const { return EffectSet::None(); } |
| 1391 | 1417 |
| 1392 private: | 1418 private: |
| 1393 // Classes that have access to predecessors_ when inlining. | 1419 // Classes that have access to predecessors_ when inlining. |
| 1394 friend class BlockEntryInstr; | 1420 friend class BlockEntryInstr; |
| 1395 friend class InlineExitCollector; | 1421 friend class InlineExitCollector; |
| 1396 friend class PolymorphicInliner; | 1422 friend class PolymorphicInliner; |
| 1423 friend class IndirectEntryInstr; // Access in il_printer.cc. | |
| 1397 | 1424 |
| 1398 // Direct access to phis_ in order to resize it due to phi elimination. | 1425 // Direct access to phis_ in order to resize it due to phi elimination. |
| 1399 friend class ConstantPropagator; | 1426 friend class ConstantPropagator; |
| 1400 friend class DeadCodeElimination; | 1427 friend class DeadCodeElimination; |
| 1401 | 1428 |
| 1402 virtual void ClearPredecessors() { predecessors_.Clear(); } | 1429 virtual void ClearPredecessors() { predecessors_.Clear(); } |
| 1403 virtual void AddPredecessor(BlockEntryInstr* predecessor); | 1430 virtual void AddPredecessor(BlockEntryInstr* predecessor); |
| 1404 | 1431 |
| 1405 GrowableArray<BlockEntryInstr*> predecessors_; | 1432 GrowableArray<BlockEntryInstr*> predecessors_; |
| 1406 ZoneGrowableArray<PhiInstr*>* phis_; | 1433 ZoneGrowableArray<PhiInstr*>* phis_; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1466 predecessor_ = predecessor; | 1493 predecessor_ = predecessor; |
| 1467 } | 1494 } |
| 1468 | 1495 |
| 1469 BlockEntryInstr* predecessor_; | 1496 BlockEntryInstr* predecessor_; |
| 1470 double edge_weight_; | 1497 double edge_weight_; |
| 1471 | 1498 |
| 1472 DISALLOW_COPY_AND_ASSIGN(TargetEntryInstr); | 1499 DISALLOW_COPY_AND_ASSIGN(TargetEntryInstr); |
| 1473 }; | 1500 }; |
| 1474 | 1501 |
| 1475 | 1502 |
| 1503 class IndirectEntryInstr : public JoinEntryInstr { | |
| 1504 public: | |
| 1505 IndirectEntryInstr(intptr_t block_id, intptr_t try_index) | |
| 1506 : JoinEntryInstr(block_id, try_index) { } | |
| 1507 | |
| 1508 DECLARE_INSTRUCTION(IndirectEntry) | |
| 1509 | |
| 1510 virtual void PrintTo(BufferFormatter* f) const; | |
| 1511 }; | |
| 1512 | |
| 1513 | |
| 1476 class CatchBlockEntryInstr : public BlockEntryInstr { | 1514 class CatchBlockEntryInstr : public BlockEntryInstr { |
| 1477 public: | 1515 public: |
| 1478 CatchBlockEntryInstr(intptr_t block_id, | 1516 CatchBlockEntryInstr(intptr_t block_id, |
| 1479 intptr_t try_index, | 1517 intptr_t try_index, |
| 1480 const Array& handler_types, | 1518 const Array& handler_types, |
| 1481 intptr_t catch_try_index, | 1519 intptr_t catch_try_index, |
| 1482 const LocalVariable& exception_var, | 1520 const LocalVariable& exception_var, |
| 1483 const LocalVariable& stacktrace_var, | 1521 const LocalVariable& stacktrace_var, |
| 1484 bool needs_stacktrace) | 1522 bool needs_stacktrace) |
| 1485 : BlockEntryInstr(block_id, try_index), | 1523 : BlockEntryInstr(block_id, try_index), |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2134 private: | 2172 private: |
| 2135 JoinEntryInstr* successor_; | 2173 JoinEntryInstr* successor_; |
| 2136 double edge_weight_; | 2174 double edge_weight_; |
| 2137 | 2175 |
| 2138 // Parallel move that will be used by linear scan register allocator to | 2176 // Parallel move that will be used by linear scan register allocator to |
| 2139 // connect live ranges at the end of the block and resolve phis. | 2177 // connect live ranges at the end of the block and resolve phis. |
| 2140 ParallelMoveInstr* parallel_move_; | 2178 ParallelMoveInstr* parallel_move_; |
| 2141 }; | 2179 }; |
| 2142 | 2180 |
| 2143 | 2181 |
| 2182 // Targets of indirect gotos are never entered through any other means. | |
| 2183 class IndirectGotoInstr : public TemplateInstruction<1> { | |
| 2184 public: | |
| 2185 explicit IndirectGotoInstr(GrowableObjectArray* offsets, | |
| 2186 Value* offset_from_start) | |
|
srdjan
2014/09/22 22:34:07
remove explicit
jgruber1
2014/09/23 10:58:47
Done.
| |
| 2187 : offset_from_start_(offset_from_start), | |
| 2188 edge_weight_(0.0), | |
| 2189 offsets_(*offsets) { | |
| 2190 inputs_[0] = offset_from_start_; | |
| 2191 offset_from_start_->set_instruction(this); | |
| 2192 offset_from_start_->set_use_index(0); | |
| 2193 } | |
| 2194 | |
| 2195 DECLARE_INSTRUCTION(IndirectGoto) | |
| 2196 | |
| 2197 virtual intptr_t ArgumentCount() const { return 0; } | |
| 2198 | |
| 2199 double edge_weight() const { return edge_weight_; } | |
| 2200 void set_edge_weight(double weight) { edge_weight_ = weight; } | |
| 2201 void adjust_edge_weight(double scale_factor) { edge_weight_ *= scale_factor; } | |
|
srdjan
2014/09/22 22:34:07
s/adjust_edge_weight/scale_edge_weight/ to make it
jgruber1
2014/09/23 10:58:47
edge_weight_ was left over from duplicating GotoIn
| |
| 2202 | |
| 2203 void AddSuccessor(TargetEntryInstr* successor) { | |
| 2204 ASSERT(successor->next()->IsGoto()); | |
| 2205 ASSERT(successor->next()->AsGoto()->successor()->IsIndirectEntry()); | |
| 2206 successors_.Add(successor); | |
| 2207 } | |
| 2208 | |
| 2209 virtual intptr_t SuccessorCount() const { return successors_.length(); } | |
| 2210 virtual TargetEntryInstr* SuccessorAt(intptr_t index) const { | |
| 2211 ASSERT(index < SuccessorCount()); | |
| 2212 return successors_[index]; | |
| 2213 } | |
| 2214 | |
| 2215 virtual bool CanDeoptimize() const { return false; } | |
| 2216 virtual bool CanBecomeDeoptimizationTarget() const { return false; } | |
| 2217 | |
| 2218 virtual EffectSet Effects() const { return EffectSet::None(); } | |
| 2219 | |
| 2220 virtual void PrintTo(BufferFormatter* f) const; | |
| 2221 | |
| 2222 virtual bool MayThrow() const { return false; } | |
| 2223 | |
| 2224 const GrowableObjectArray& offsets() const { return offsets_; } | |
| 2225 void SetOffsetAt(Isolate* isolate, intptr_t index, intptr_t offset) { | |
| 2226 intptr_t minimal_length = index + 1; | |
| 2227 if (offsets_.Length() < minimal_length) { | |
| 2228 offsets_.Grow(minimal_length, Heap::kOld); | |
| 2229 offsets_.SetLength(minimal_length); | |
| 2230 } | |
| 2231 offsets_.SetAt(index, Smi::ZoneHandle(isolate, Smi::New(offset))); | |
| 2232 } | |
| 2233 | |
| 2234 private: | |
| 2235 Value* offset_from_start_; | |
| 2236 double edge_weight_; | |
| 2237 | |
| 2238 GrowableArray<TargetEntryInstr*> successors_; | |
| 2239 GrowableObjectArray& offsets_; | |
| 2240 }; | |
| 2241 | |
| 2242 | |
| 2144 class ComparisonInstr : public TemplateDefinition<2> { | 2243 class ComparisonInstr : public TemplateDefinition<2> { |
| 2145 public: | 2244 public: |
| 2146 Value* left() const { return inputs_[0]; } | 2245 Value* left() const { return inputs_[0]; } |
| 2147 Value* right() const { return inputs_[1]; } | 2246 Value* right() const { return inputs_[1]; } |
| 2148 | 2247 |
| 2149 virtual intptr_t token_pos() const { return token_pos_; } | 2248 virtual intptr_t token_pos() const { return token_pos_; } |
| 2150 Token::Kind kind() const { return kind_; } | 2249 Token::Kind kind() const { return kind_; } |
| 2151 | 2250 |
| 2152 virtual ComparisonInstr* CopyWithNewOperands(Value* left, Value* right) = 0; | 2251 virtual ComparisonInstr* CopyWithNewOperands(Value* left, Value* right) = 0; |
| 2153 | 2252 |
| (...skipping 1606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3760 | 3859 |
| 3761 private: | 3860 private: |
| 3762 const intptr_t index_scale_; | 3861 const intptr_t index_scale_; |
| 3763 const intptr_t class_id_; | 3862 const intptr_t class_id_; |
| 3764 const intptr_t token_pos_; | 3863 const intptr_t token_pos_; |
| 3765 | 3864 |
| 3766 DISALLOW_COPY_AND_ASSIGN(LoadIndexedInstr); | 3865 DISALLOW_COPY_AND_ASSIGN(LoadIndexedInstr); |
| 3767 }; | 3866 }; |
| 3768 | 3867 |
| 3769 | 3868 |
| 3869 class LoadCodeUnitsInstr : public TemplateDefinition<2> { | |
| 3870 public: | |
| 3871 LoadCodeUnitsInstr(Value* array, | |
| 3872 Value* index, | |
| 3873 intptr_t index_scale, | |
| 3874 intptr_t element_count, | |
| 3875 intptr_t class_id, | |
| 3876 intptr_t deopt_id, | |
| 3877 intptr_t token_pos) | |
| 3878 : index_scale_(index_scale), | |
| 3879 class_id_(class_id), | |
| 3880 token_pos_(token_pos), | |
| 3881 element_count_(element_count) { | |
| 3882 ASSERT(class_id == kOneByteStringCid || class_id == kTwoByteStringCid); | |
| 3883 SetInputAt(0, array); | |
| 3884 SetInputAt(1, index); | |
| 3885 deopt_id_ = deopt_id; | |
| 3886 } | |
| 3887 | |
| 3888 intptr_t token_pos() const { return token_pos_; } | |
| 3889 | |
| 3890 DECLARE_INSTRUCTION(LoadCodeUnits) | |
| 3891 virtual CompileType ComputeType() const; | |
| 3892 | |
| 3893 bool IsExternal() const { | |
| 3894 return array()->definition()->representation() == kUntagged; | |
| 3895 } | |
| 3896 | |
| 3897 Value* array() const { return inputs_[0]; } | |
| 3898 Value* index() const { return inputs_[1]; } | |
| 3899 intptr_t index_scale() const { return index_scale_; } | |
| 3900 intptr_t class_id() const { return class_id_; } | |
| 3901 intptr_t element_count() const { return element_count_; } | |
| 3902 | |
| 3903 virtual bool CanDeoptimize() const { | |
| 3904 return deopt_id_ != Isolate::kNoDeoptId; | |
| 3905 } | |
| 3906 | |
| 3907 virtual Representation representation() const; | |
| 3908 virtual void InferRange(RangeAnalysis* analysis, Range* range); | |
| 3909 | |
| 3910 virtual bool AllowsCSE() const { return false; } | |
| 3911 virtual EffectSet Effects() const { return EffectSet::None(); } | |
| 3912 virtual EffectSet Dependencies() const { return EffectSet::All(); } | |
| 3913 virtual bool AttributesEqual(Instruction* other) const; | |
| 3914 | |
| 3915 virtual bool MayThrow() const { return false; } | |
| 3916 | |
| 3917 private: | |
| 3918 const intptr_t index_scale_; | |
| 3919 const intptr_t class_id_; | |
| 3920 const intptr_t token_pos_; | |
| 3921 const intptr_t element_count_; | |
| 3922 | |
| 3923 DISALLOW_COPY_AND_ASSIGN(LoadCodeUnitsInstr); | |
| 3924 }; | |
| 3925 | |
| 3926 | |
| 3770 class StringFromCharCodeInstr : public TemplateDefinition<1> { | 3927 class StringFromCharCodeInstr : public TemplateDefinition<1> { |
| 3771 public: | 3928 public: |
| 3772 StringFromCharCodeInstr(Value* char_code, intptr_t cid) : cid_(cid) { | 3929 StringFromCharCodeInstr(Value* char_code, intptr_t cid) : cid_(cid) { |
| 3773 ASSERT(char_code != NULL); | 3930 ASSERT(char_code != NULL); |
| 3774 ASSERT(char_code->definition()->IsLoadIndexed()); | 3931 ASSERT(char_code->definition()->IsLoadIndexed()); |
| 3775 ASSERT(char_code->definition()->AsLoadIndexed()->class_id() == | 3932 ASSERT(char_code->definition()->AsLoadIndexed()->class_id() == |
| 3776 kOneByteStringCid); | 3933 kOneByteStringCid); |
| 3777 SetInputAt(0, char_code); | 3934 SetInputAt(0, char_code); |
| 3778 } | 3935 } |
| 3779 | 3936 |
| (...skipping 1208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4988 | 5145 |
| 4989 static const char* KindToCString(MathUnaryKind kind); | 5146 static const char* KindToCString(MathUnaryKind kind); |
| 4990 | 5147 |
| 4991 private: | 5148 private: |
| 4992 const MathUnaryKind kind_; | 5149 const MathUnaryKind kind_; |
| 4993 | 5150 |
| 4994 DISALLOW_COPY_AND_ASSIGN(MathUnaryInstr); | 5151 DISALLOW_COPY_AND_ASSIGN(MathUnaryInstr); |
| 4995 }; | 5152 }; |
| 4996 | 5153 |
| 4997 | 5154 |
| 5155 // TODO(jgruber): Remove this once (if) functions inherited from unibrow | |
| 5156 // are moved to dart code. | |
| 5157 class CaseInsensitiveCompareUC16Instr : public TemplateDefinition<4> { | |
| 5158 public: | |
| 5159 CaseInsensitiveCompareUC16Instr( | |
| 5160 Value* str, | |
| 5161 Value* lhs_index, | |
| 5162 Value* rhs_index, | |
| 5163 Value* length, | |
| 5164 intptr_t cid, | |
| 5165 intptr_t deopt_id) | |
| 5166 : cid_(cid) { | |
| 5167 ASSERT(cid == kTwoByteStringCid || cid == kExternalTwoByteStringCid); | |
| 5168 ASSERT(index_scale() == 2); | |
| 5169 SetInputAt(0, str); | |
| 5170 SetInputAt(1, lhs_index); | |
| 5171 SetInputAt(2, rhs_index); | |
| 5172 SetInputAt(3, length); | |
| 5173 deopt_id_ = deopt_id; | |
| 5174 } | |
| 5175 | |
| 5176 Value* str() const { return inputs_[0]; } | |
| 5177 Value* lhs_index() const { return inputs_[1]; } | |
| 5178 Value* rhs_index() const { return inputs_[2]; } | |
| 5179 Value* length() const { return inputs_[3]; } | |
| 5180 | |
| 5181 const RuntimeEntry& TargetFunction() const; | |
| 5182 bool IsExternal() const { return cid_ == kExternalTwoByteStringCid; } | |
| 5183 intptr_t class_id() const { return cid_; } | |
| 5184 intptr_t index_scale() const { return Instance::ElementSizeFor(cid_); } | |
| 5185 | |
| 5186 virtual void PrintOperandsTo(BufferFormatter* f) const; | |
| 5187 | |
| 5188 virtual bool CanDeoptimize() const { return false; } | |
| 5189 | |
| 5190 virtual Representation representation() const { | |
| 5191 return kTagged; | |
| 5192 } | |
| 5193 | |
| 5194 virtual intptr_t DeoptimizationTarget() const { | |
| 5195 // Direct access since this instruction cannot deoptimize, and the deopt-id | |
| 5196 // was inherited from another instruction that could deoptimize. | |
| 5197 return deopt_id_; | |
| 5198 } | |
| 5199 | |
| 5200 DECLARE_INSTRUCTION(CaseInsensitiveCompareUC16) | |
| 5201 virtual CompileType ComputeType() const; | |
| 5202 | |
| 5203 virtual bool AllowsCSE() const { return true; } | |
| 5204 virtual EffectSet Effects() const { return EffectSet::None(); } | |
| 5205 virtual EffectSet Dependencies() const { return EffectSet::None(); } | |
| 5206 | |
| 5207 virtual bool MayThrow() const { return false; } | |
| 5208 | |
| 5209 Definition* Canonicalize(FlowGraph* flow_graph); | |
| 5210 | |
| 5211 private: | |
| 5212 const intptr_t cid_; | |
| 5213 | |
| 5214 DISALLOW_COPY_AND_ASSIGN(CaseInsensitiveCompareUC16Instr); | |
| 5215 }; | |
| 5216 | |
| 5217 | |
| 4998 // Represents Math's static min and max functions. | 5218 // Represents Math's static min and max functions. |
| 4999 class MathMinMaxInstr : public TemplateDefinition<2> { | 5219 class MathMinMaxInstr : public TemplateDefinition<2> { |
| 5000 public: | 5220 public: |
| 5001 MathMinMaxInstr(MethodRecognizer::Kind op_kind, | 5221 MathMinMaxInstr(MethodRecognizer::Kind op_kind, |
| 5002 Value* left_value, | 5222 Value* left_value, |
| 5003 Value* right_value, | 5223 Value* right_value, |
| 5004 intptr_t deopt_id, | 5224 intptr_t deopt_id, |
| 5005 intptr_t result_cid) | 5225 intptr_t result_cid) |
| 5006 : op_kind_(op_kind), result_cid_(result_cid) { | 5226 : op_kind_(op_kind), result_cid_(result_cid) { |
| 5007 ASSERT((result_cid == kSmiCid) || (result_cid == kDoubleCid)); | 5227 ASSERT((result_cid == kSmiCid) || (result_cid == kDoubleCid)); |
| (...skipping 3354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8362 Isolate* isolate, bool opt) const { \ | 8582 Isolate* isolate, bool opt) const { \ |
| 8363 UNIMPLEMENTED(); \ | 8583 UNIMPLEMENTED(); \ |
| 8364 return NULL; \ | 8584 return NULL; \ |
| 8365 } \ | 8585 } \ |
| 8366 void Name::EmitNativeCode(FlowGraphCompiler* compiler) { UNIMPLEMENTED(); } | 8586 void Name::EmitNativeCode(FlowGraphCompiler* compiler) { UNIMPLEMENTED(); } |
| 8367 | 8587 |
| 8368 | 8588 |
| 8369 } // namespace dart | 8589 } // namespace dart |
| 8370 | 8590 |
| 8371 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 8591 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |