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 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 M(LoadField) \ | 570 M(LoadField) \ |
571 M(StoreVMField) \ | 571 M(StoreVMField) \ |
572 M(LoadUntagged) \ | 572 M(LoadUntagged) \ |
573 M(LoadClassId) \ | 573 M(LoadClassId) \ |
574 M(InstantiateType) \ | 574 M(InstantiateType) \ |
575 M(InstantiateTypeArguments) \ | 575 M(InstantiateTypeArguments) \ |
576 M(ExtractConstructorTypeArguments) \ | 576 M(ExtractConstructorTypeArguments) \ |
577 M(ExtractConstructorInstantiator) \ | 577 M(ExtractConstructorInstantiator) \ |
578 M(AllocateContext) \ | 578 M(AllocateContext) \ |
579 M(CloneContext) \ | 579 M(CloneContext) \ |
580 M(CatchEntry) \ | |
581 M(BinarySmiOp) \ | 580 M(BinarySmiOp) \ |
582 M(UnarySmiOp) \ | 581 M(UnarySmiOp) \ |
583 M(CheckStackOverflow) \ | 582 M(CheckStackOverflow) \ |
584 M(SmiToDouble) \ | 583 M(SmiToDouble) \ |
585 M(DoubleToInteger) \ | 584 M(DoubleToInteger) \ |
586 M(DoubleToSmi) \ | 585 M(DoubleToSmi) \ |
587 M(DoubleToDouble) \ | 586 M(DoubleToDouble) \ |
588 M(CheckClass) \ | 587 M(CheckClass) \ |
589 M(CheckSmi) \ | 588 M(CheckSmi) \ |
590 M(Constant) \ | 589 M(Constant) \ |
(...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1482 | 1481 |
1483 DISALLOW_COPY_AND_ASSIGN(TargetEntryInstr); | 1482 DISALLOW_COPY_AND_ASSIGN(TargetEntryInstr); |
1484 }; | 1483 }; |
1485 | 1484 |
1486 | 1485 |
1487 class CatchBlockEntryInstr : public BlockEntryInstr { | 1486 class CatchBlockEntryInstr : public BlockEntryInstr { |
1488 public: | 1487 public: |
1489 CatchBlockEntryInstr(intptr_t block_id, | 1488 CatchBlockEntryInstr(intptr_t block_id, |
1490 intptr_t try_index, | 1489 intptr_t try_index, |
1491 const Array& handler_types, | 1490 const Array& handler_types, |
1492 intptr_t catch_try_index) | 1491 intptr_t catch_try_index, |
| 1492 const LocalVariable& exception_var, |
| 1493 const LocalVariable& stacktrace_var) |
1493 : BlockEntryInstr(block_id, try_index), | 1494 : BlockEntryInstr(block_id, try_index), |
1494 predecessor_(NULL), | 1495 predecessor_(NULL), |
1495 catch_handler_types_(Array::ZoneHandle(handler_types.raw())), | 1496 catch_handler_types_(Array::ZoneHandle(handler_types.raw())), |
1496 catch_try_index_(catch_try_index) { } | 1497 catch_try_index_(catch_try_index), |
| 1498 exception_var_(exception_var), |
| 1499 stacktrace_var_(stacktrace_var) { } |
1497 | 1500 |
1498 DECLARE_INSTRUCTION(CatchBlockEntry) | 1501 DECLARE_INSTRUCTION(CatchBlockEntry) |
1499 | 1502 |
1500 virtual intptr_t PredecessorCount() const { | 1503 virtual intptr_t PredecessorCount() const { |
1501 return (predecessor_ == NULL) ? 0 : 1; | 1504 return (predecessor_ == NULL) ? 0 : 1; |
1502 } | 1505 } |
1503 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const { | 1506 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const { |
1504 ASSERT((index == 0) && (predecessor_ != NULL)); | 1507 ASSERT((index == 0) && (predecessor_ != NULL)); |
1505 return predecessor_; | 1508 return predecessor_; |
1506 } | 1509 } |
1507 | 1510 |
| 1511 const LocalVariable& exception_var() const { return exception_var_; } |
| 1512 const LocalVariable& stacktrace_var() const { return stacktrace_var_; } |
| 1513 |
1508 // Returns try index for the try block to which this catch handler | 1514 // Returns try index for the try block to which this catch handler |
1509 // corresponds. | 1515 // corresponds. |
1510 intptr_t catch_try_index() const { | 1516 intptr_t catch_try_index() const { |
1511 return catch_try_index_; | 1517 return catch_try_index_; |
1512 } | 1518 } |
1513 GrowableArray<Definition*>* initial_definitions() { | 1519 GrowableArray<Definition*>* initial_definitions() { |
1514 return &initial_definitions_; | 1520 return &initial_definitions_; |
1515 } | 1521 } |
1516 | 1522 |
1517 virtual void PrintTo(BufferFormatter* f) const; | 1523 virtual void PrintTo(BufferFormatter* f) const; |
1518 | 1524 |
1519 private: | 1525 private: |
1520 friend class BlockEntryInstr; // Access to predecessor_ when inlining. | 1526 friend class BlockEntryInstr; // Access to predecessor_ when inlining. |
1521 | 1527 |
1522 virtual void ClearPredecessors() { predecessor_ = NULL; } | 1528 virtual void ClearPredecessors() { predecessor_ = NULL; } |
1523 virtual void AddPredecessor(BlockEntryInstr* predecessor) { | 1529 virtual void AddPredecessor(BlockEntryInstr* predecessor) { |
1524 ASSERT(predecessor_ == NULL); | 1530 ASSERT(predecessor_ == NULL); |
1525 predecessor_ = predecessor; | 1531 predecessor_ = predecessor; |
1526 } | 1532 } |
1527 | 1533 |
1528 BlockEntryInstr* predecessor_; | 1534 BlockEntryInstr* predecessor_; |
1529 const Array& catch_handler_types_; | 1535 const Array& catch_handler_types_; |
1530 const intptr_t catch_try_index_; | 1536 const intptr_t catch_try_index_; |
1531 GrowableArray<Definition*> initial_definitions_; | 1537 GrowableArray<Definition*> initial_definitions_; |
| 1538 const LocalVariable& exception_var_; |
| 1539 const LocalVariable& stacktrace_var_; |
1532 | 1540 |
1533 DISALLOW_COPY_AND_ASSIGN(CatchBlockEntryInstr); | 1541 DISALLOW_COPY_AND_ASSIGN(CatchBlockEntryInstr); |
1534 }; | 1542 }; |
1535 | 1543 |
1536 | 1544 |
1537 // Abstract super-class of all instructions that define a value (Bind, Phi). | 1545 // Abstract super-class of all instructions that define a value (Bind, Phi). |
1538 class Definition : public Instruction { | 1546 class Definition : public Instruction { |
1539 public: | 1547 public: |
1540 enum UseKind { kEffect, kValue }; | 1548 enum UseKind { kEffect, kValue }; |
1541 | 1549 |
(...skipping 2746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4288 | 4296 |
4289 virtual bool MayThrow() const { return false; } | 4297 virtual bool MayThrow() const { return false; } |
4290 | 4298 |
4291 private: | 4299 private: |
4292 const intptr_t token_pos_; | 4300 const intptr_t token_pos_; |
4293 | 4301 |
4294 DISALLOW_COPY_AND_ASSIGN(CloneContextInstr); | 4302 DISALLOW_COPY_AND_ASSIGN(CloneContextInstr); |
4295 }; | 4303 }; |
4296 | 4304 |
4297 | 4305 |
4298 class CatchEntryInstr : public TemplateInstruction<0> { | |
4299 public: | |
4300 CatchEntryInstr(const LocalVariable& exception_var, | |
4301 const LocalVariable& stacktrace_var) | |
4302 : exception_var_(exception_var), stacktrace_var_(stacktrace_var) {} | |
4303 | |
4304 const LocalVariable& exception_var() const { return exception_var_; } | |
4305 const LocalVariable& stacktrace_var() const { return stacktrace_var_; } | |
4306 | |
4307 DECLARE_INSTRUCTION(CatchEntry) | |
4308 | |
4309 virtual intptr_t ArgumentCount() const { return 0; } | |
4310 | |
4311 virtual void PrintOperandsTo(BufferFormatter* f) const; | |
4312 | |
4313 virtual bool CanDeoptimize() const { return false; } | |
4314 | |
4315 virtual EffectSet Effects() const { return EffectSet::All(); } | |
4316 | |
4317 virtual bool MayThrow() const { return false; } | |
4318 | |
4319 private: | |
4320 const LocalVariable& exception_var_; | |
4321 const LocalVariable& stacktrace_var_; | |
4322 | |
4323 DISALLOW_COPY_AND_ASSIGN(CatchEntryInstr); | |
4324 }; | |
4325 | |
4326 | |
4327 class CheckEitherNonSmiInstr : public TemplateInstruction<2> { | 4306 class CheckEitherNonSmiInstr : public TemplateInstruction<2> { |
4328 public: | 4307 public: |
4329 CheckEitherNonSmiInstr(Value* left, | 4308 CheckEitherNonSmiInstr(Value* left, |
4330 Value* right, | 4309 Value* right, |
4331 intptr_t deopt_id) { | 4310 intptr_t deopt_id) { |
4332 SetInputAt(0, left); | 4311 SetInputAt(0, left); |
4333 SetInputAt(1, right); | 4312 SetInputAt(1, right); |
4334 // Override generated deopt-id. | 4313 // Override generated deopt-id. |
4335 deopt_id_ = deopt_id; | 4314 deopt_id_ = deopt_id; |
4336 } | 4315 } |
(...skipping 2305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6642 ForwardInstructionIterator* current_iterator_; | 6621 ForwardInstructionIterator* current_iterator_; |
6643 | 6622 |
6644 private: | 6623 private: |
6645 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 6624 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
6646 }; | 6625 }; |
6647 | 6626 |
6648 | 6627 |
6649 } // namespace dart | 6628 } // namespace dart |
6650 | 6629 |
6651 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 6630 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
OLD | NEW |