| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 M(CatchEntry) \ | 245 M(CatchEntry) \ |
| 246 M(BinarySmiOp) \ | 246 M(BinarySmiOp) \ |
| 247 M(UnarySmiOp) \ | 247 M(UnarySmiOp) \ |
| 248 M(CheckStackOverflow) \ | 248 M(CheckStackOverflow) \ |
| 249 M(DoubleToDouble) \ | 249 M(DoubleToDouble) \ |
| 250 M(SmiToDouble) \ | 250 M(SmiToDouble) \ |
| 251 M(CheckClass) \ | 251 M(CheckClass) \ |
| 252 M(CheckSmi) \ | 252 M(CheckSmi) \ |
| 253 M(Constant) \ | 253 M(Constant) \ |
| 254 M(CheckEitherNonSmi) \ | 254 M(CheckEitherNonSmi) \ |
| 255 M(UnboxedDoubleBinaryOp) \ | 255 M(BinaryDoubleOp) \ |
| 256 M(MathSqrt) \ | 256 M(MathSqrt) \ |
| 257 M(UnboxDouble) \ | 257 M(UnboxDouble) \ |
| 258 M(BoxDouble) \ | 258 M(BoxDouble) \ |
| 259 M(UnboxInteger) \ | 259 M(UnboxInteger) \ |
| 260 M(BoxInteger) \ | 260 M(BoxInteger) \ |
| 261 M(UnboxedMintBinaryOp) \ | 261 M(BinaryMintOp) \ |
| 262 M(UnboxedMintUnaryOp) \ | 262 M(UnaryMintOp) \ |
| 263 M(CheckArrayBound) \ | 263 M(CheckArrayBound) \ |
| 264 M(Constraint) \ | 264 M(Constraint) \ |
| 265 | 265 |
| 266 | 266 |
| 267 #define FORWARD_DECLARATION(type) class type##Instr; | 267 #define FORWARD_DECLARATION(type) class type##Instr; |
| 268 FOR_EACH_INSTRUCTION(FORWARD_DECLARATION) | 268 FOR_EACH_INSTRUCTION(FORWARD_DECLARATION) |
| 269 #undef FORWARD_DECLARATION | 269 #undef FORWARD_DECLARATION |
| 270 | 270 |
| 271 | 271 |
| 272 // Functions required in all concrete instruction classes. | 272 // Functions required in all concrete instruction classes. |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 intptr_t GetDeoptId() const { | 507 intptr_t GetDeoptId() const { |
| 508 return deopt_id_; | 508 return deopt_id_; |
| 509 } | 509 } |
| 510 | 510 |
| 511 private: | 511 private: |
| 512 friend class Definition; // Needed for InsertBefore, InsertAfter. | 512 friend class Definition; // Needed for InsertBefore, InsertAfter. |
| 513 | 513 |
| 514 // Classes that set deopt_id_. | 514 // Classes that set deopt_id_. |
| 515 friend class UnboxIntegerInstr; | 515 friend class UnboxIntegerInstr; |
| 516 friend class UnboxDoubleInstr; | 516 friend class UnboxDoubleInstr; |
| 517 friend class UnboxedDoubleBinaryOpInstr; | 517 friend class BinaryDoubleOpInstr; |
| 518 friend class UnboxedMintBinaryOpInstr; | 518 friend class BinaryMintOpInstr; |
| 519 friend class UnboxedMintUnaryOpInstr; | 519 friend class UnaryMintOpInstr; |
| 520 friend class MathSqrtInstr; | 520 friend class MathSqrtInstr; |
| 521 friend class CheckClassInstr; | 521 friend class CheckClassInstr; |
| 522 friend class CheckSmiInstr; | 522 friend class CheckSmiInstr; |
| 523 friend class CheckArrayBoundInstr; | 523 friend class CheckArrayBoundInstr; |
| 524 friend class CheckEitherNonSmiInstr; | 524 friend class CheckEitherNonSmiInstr; |
| 525 friend class LICM; | 525 friend class LICM; |
| 526 | 526 |
| 527 intptr_t deopt_id_; | 527 intptr_t deopt_id_; |
| 528 intptr_t lifetime_position_; // Position used by register allocator. | 528 intptr_t lifetime_position_; // Position used by register allocator. |
| 529 Instruction* previous_; | 529 Instruction* previous_; |
| (...skipping 2929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3459 } | 3459 } |
| 3460 | 3460 |
| 3461 DECLARE_INSTRUCTION(MathSqrt) | 3461 DECLARE_INSTRUCTION(MathSqrt) |
| 3462 virtual RawAbstractType* CompileType() const; | 3462 virtual RawAbstractType* CompileType() const; |
| 3463 | 3463 |
| 3464 private: | 3464 private: |
| 3465 DISALLOW_COPY_AND_ASSIGN(MathSqrtInstr); | 3465 DISALLOW_COPY_AND_ASSIGN(MathSqrtInstr); |
| 3466 }; | 3466 }; |
| 3467 | 3467 |
| 3468 | 3468 |
| 3469 class UnboxedDoubleBinaryOpInstr : public TemplateDefinition<2> { | 3469 class BinaryDoubleOpInstr : public TemplateDefinition<2> { |
| 3470 public: | 3470 public: |
| 3471 UnboxedDoubleBinaryOpInstr(Token::Kind op_kind, | 3471 BinaryDoubleOpInstr(Token::Kind op_kind, |
| 3472 Value* left, | 3472 Value* left, |
| 3473 Value* right, | 3473 Value* right, |
| 3474 InstanceCallInstr* instance_call) | 3474 InstanceCallInstr* instance_call) |
| 3475 : op_kind_(op_kind) { | 3475 : op_kind_(op_kind) { |
| 3476 ASSERT(left != NULL); | 3476 ASSERT(left != NULL); |
| 3477 ASSERT(right != NULL); | 3477 ASSERT(right != NULL); |
| 3478 inputs_[0] = left; | 3478 inputs_[0] = left; |
| 3479 inputs_[1] = right; | 3479 inputs_[1] = right; |
| 3480 deopt_id_ = instance_call->deopt_id(); | 3480 deopt_id_ = instance_call->deopt_id(); |
| 3481 } | 3481 } |
| 3482 | 3482 |
| 3483 Value* left() const { return inputs_[0]; } | 3483 Value* left() const { return inputs_[0]; } |
| 3484 Value* right() const { return inputs_[1]; } | 3484 Value* right() const { return inputs_[1]; } |
| 3485 | 3485 |
| 3486 Token::Kind op_kind() const { return op_kind_; } | 3486 Token::Kind op_kind() const { return op_kind_; } |
| 3487 | 3487 |
| 3488 virtual void PrintOperandsTo(BufferFormatter* f) const; | 3488 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 3489 | 3489 |
| 3490 virtual bool CanDeoptimize() const { return false; } | 3490 virtual bool CanDeoptimize() const { return false; } |
| 3491 | 3491 |
| 3492 virtual bool HasSideEffect() const { return false; } | 3492 virtual bool HasSideEffect() const { return false; } |
| 3493 | 3493 |
| 3494 virtual bool AffectedBySideEffect() const { return false; } | 3494 virtual bool AffectedBySideEffect() const { return false; } |
| 3495 | 3495 |
| 3496 virtual bool AttributesEqual(Instruction* other) const { | 3496 virtual bool AttributesEqual(Instruction* other) const { |
| 3497 return op_kind() == other->AsUnboxedDoubleBinaryOp()->op_kind(); | 3497 return op_kind() == other->AsBinaryDoubleOp()->op_kind(); |
| 3498 } | 3498 } |
| 3499 | 3499 |
| 3500 // The output is not an instance but when it is boxed it becomes double. | 3500 virtual intptr_t ResultCid() const; |
| 3501 virtual intptr_t ResultCid() const { return kDoubleCid; } | |
| 3502 | 3501 |
| 3503 virtual Representation representation() const { | 3502 virtual Representation representation() const { |
| 3504 return kUnboxedDouble; | 3503 return kUnboxedDouble; |
| 3505 } | 3504 } |
| 3506 | 3505 |
| 3507 virtual Representation RequiredInputRepresentation(intptr_t idx) const { | 3506 virtual Representation RequiredInputRepresentation(intptr_t idx) const { |
| 3508 ASSERT((idx == 0) || (idx == 1)); | 3507 ASSERT((idx == 0) || (idx == 1)); |
| 3509 return kUnboxedDouble; | 3508 return kUnboxedDouble; |
| 3510 } | 3509 } |
| 3511 | 3510 |
| 3512 virtual intptr_t DeoptimizationTarget() const { | 3511 virtual intptr_t DeoptimizationTarget() const { |
| 3513 // Direct access since this instuction cannot deoptimize, and the deopt-id | 3512 // Direct access since this instuction cannot deoptimize, and the deopt-id |
| 3514 // was inherited from another instuction that could deoptimize. | 3513 // was inherited from another instuction that could deoptimize. |
| 3515 return deopt_id_; | 3514 return deopt_id_; |
| 3516 } | 3515 } |
| 3517 | 3516 |
| 3518 DECLARE_INSTRUCTION(UnboxedDoubleBinaryOp) | 3517 DECLARE_INSTRUCTION(BinaryDoubleOp) |
| 3519 virtual RawAbstractType* CompileType() const; | 3518 virtual RawAbstractType* CompileType() const; |
| 3520 | 3519 |
| 3521 private: | 3520 private: |
| 3522 const Token::Kind op_kind_; | 3521 const Token::Kind op_kind_; |
| 3523 | 3522 |
| 3524 DISALLOW_COPY_AND_ASSIGN(UnboxedDoubleBinaryOpInstr); | 3523 DISALLOW_COPY_AND_ASSIGN(BinaryDoubleOpInstr); |
| 3525 }; | 3524 }; |
| 3526 | 3525 |
| 3527 | 3526 |
| 3528 class UnboxedMintBinaryOpInstr : public TemplateDefinition<2> { | 3527 class BinaryMintOpInstr : public TemplateDefinition<2> { |
| 3529 public: | 3528 public: |
| 3530 UnboxedMintBinaryOpInstr(Token::Kind op_kind, | 3529 BinaryMintOpInstr(Token::Kind op_kind, |
| 3531 Value* left, | 3530 Value* left, |
| 3532 Value* right, | 3531 Value* right, |
| 3533 InstanceCallInstr* instance_call) | 3532 InstanceCallInstr* instance_call) |
| 3534 : op_kind_(op_kind) { | 3533 : op_kind_(op_kind) { |
| 3535 ASSERT(left != NULL); | 3534 ASSERT(left != NULL); |
| 3536 ASSERT(right != NULL); | 3535 ASSERT(right != NULL); |
| 3537 inputs_[0] = left; | 3536 inputs_[0] = left; |
| 3538 inputs_[1] = right; | 3537 inputs_[1] = right; |
| 3539 deopt_id_ = instance_call->deopt_id(); | 3538 deopt_id_ = instance_call->deopt_id(); |
| 3540 } | 3539 } |
| 3541 | 3540 |
| 3542 Value* left() const { return inputs_[0]; } | 3541 Value* left() const { return inputs_[0]; } |
| 3543 Value* right() const { return inputs_[1]; } | 3542 Value* right() const { return inputs_[1]; } |
| 3544 | 3543 |
| 3545 Token::Kind op_kind() const { return op_kind_; } | 3544 Token::Kind op_kind() const { return op_kind_; } |
| 3546 | 3545 |
| 3547 virtual void PrintOperandsTo(BufferFormatter* f) const; | 3546 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 3548 | 3547 |
| 3549 virtual bool CanDeoptimize() const { | 3548 virtual bool CanDeoptimize() const { |
| 3550 return (op_kind() == Token::kADD) || (op_kind() == Token::kSUB); | 3549 return (op_kind() == Token::kADD) || (op_kind() == Token::kSUB); |
| 3551 } | 3550 } |
| 3552 | 3551 |
| 3553 virtual bool HasSideEffect() const { return false; } | 3552 virtual bool HasSideEffect() const { return false; } |
| 3554 | 3553 |
| 3555 virtual bool AffectedBySideEffect() const { return false; } | 3554 virtual bool AffectedBySideEffect() const { return false; } |
| 3556 | 3555 |
| 3557 virtual bool AttributesEqual(Instruction* other) const { | 3556 virtual bool AttributesEqual(Instruction* other) const { |
| 3558 return op_kind() == other->AsUnboxedMintBinaryOp()->op_kind(); | 3557 return op_kind() == other->AsBinaryMintOp()->op_kind(); |
| 3559 } | 3558 } |
| 3560 | 3559 |
| 3561 virtual intptr_t ResultCid() const; | 3560 virtual intptr_t ResultCid() const; |
| 3562 virtual RawAbstractType* CompileType() const; | 3561 virtual RawAbstractType* CompileType() const; |
| 3563 | 3562 |
| 3564 virtual Representation representation() const { | 3563 virtual Representation representation() const { |
| 3565 return kUnboxedMint; | 3564 return kUnboxedMint; |
| 3566 } | 3565 } |
| 3567 | 3566 |
| 3568 virtual Representation RequiredInputRepresentation(intptr_t idx) const { | 3567 virtual Representation RequiredInputRepresentation(intptr_t idx) const { |
| 3569 ASSERT((idx == 0) || (idx == 1)); | 3568 ASSERT((idx == 0) || (idx == 1)); |
| 3570 return kUnboxedMint; | 3569 return kUnboxedMint; |
| 3571 } | 3570 } |
| 3572 | 3571 |
| 3573 virtual intptr_t DeoptimizationTarget() const { | 3572 virtual intptr_t DeoptimizationTarget() const { |
| 3574 // Direct access since this instuction cannot deoptimize, and the deopt-id | 3573 // Direct access since this instuction cannot deoptimize, and the deopt-id |
| 3575 // was inherited from another instuction that could deoptimize. | 3574 // was inherited from another instuction that could deoptimize. |
| 3576 return deopt_id_; | 3575 return deopt_id_; |
| 3577 } | 3576 } |
| 3578 | 3577 |
| 3579 DECLARE_INSTRUCTION(UnboxedMintBinaryOp) | 3578 DECLARE_INSTRUCTION(BinaryMintOp) |
| 3580 | 3579 |
| 3581 private: | 3580 private: |
| 3582 const Token::Kind op_kind_; | 3581 const Token::Kind op_kind_; |
| 3583 | 3582 |
| 3584 DISALLOW_COPY_AND_ASSIGN(UnboxedMintBinaryOpInstr); | 3583 DISALLOW_COPY_AND_ASSIGN(BinaryMintOpInstr); |
| 3585 }; | 3584 }; |
| 3586 | 3585 |
| 3587 | 3586 |
| 3588 class UnboxedMintUnaryOpInstr : public TemplateDefinition<1> { | 3587 class UnaryMintOpInstr : public TemplateDefinition<1> { |
| 3589 public: | 3588 public: |
| 3590 UnboxedMintUnaryOpInstr(Token::Kind op_kind, | 3589 UnaryMintOpInstr(Token::Kind op_kind, |
| 3591 Value* value, | 3590 Value* value, |
| 3592 InstanceCallInstr* instance_call) | 3591 InstanceCallInstr* instance_call) |
| 3593 : op_kind_(op_kind) { | 3592 : op_kind_(op_kind) { |
| 3594 ASSERT(value != NULL); | 3593 ASSERT(value != NULL); |
| 3595 ASSERT(op_kind == Token::kBIT_NOT); | 3594 ASSERT(op_kind == Token::kBIT_NOT); |
| 3596 inputs_[0] = value; | 3595 inputs_[0] = value; |
| 3597 deopt_id_ = instance_call->deopt_id(); | 3596 deopt_id_ = instance_call->deopt_id(); |
| 3598 } | 3597 } |
| 3599 | 3598 |
| 3600 Value* value() const { return inputs_[0]; } | 3599 Value* value() const { return inputs_[0]; } |
| 3601 | 3600 |
| 3602 Token::Kind op_kind() const { return op_kind_; } | 3601 Token::Kind op_kind() const { return op_kind_; } |
| 3603 | 3602 |
| 3604 virtual void PrintOperandsTo(BufferFormatter* f) const; | 3603 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 3605 | 3604 |
| 3606 virtual bool CanDeoptimize() const { return false; } | 3605 virtual bool CanDeoptimize() const { return false; } |
| 3607 | 3606 |
| 3608 virtual bool HasSideEffect() const { return false; } | 3607 virtual bool HasSideEffect() const { return false; } |
| 3609 | 3608 |
| 3610 virtual bool AffectedBySideEffect() const { return false; } | 3609 virtual bool AffectedBySideEffect() const { return false; } |
| 3611 | 3610 |
| 3612 virtual bool AttributesEqual(Instruction* other) const { | 3611 virtual bool AttributesEqual(Instruction* other) const { |
| 3613 return op_kind() == other->AsUnboxedMintUnaryOp()->op_kind(); | 3612 return op_kind() == other->AsUnaryMintOp()->op_kind(); |
| 3614 } | 3613 } |
| 3615 | 3614 |
| 3616 virtual intptr_t ResultCid() const; | 3615 virtual intptr_t ResultCid() const; |
| 3617 virtual RawAbstractType* CompileType() const; | 3616 virtual RawAbstractType* CompileType() const; |
| 3618 | 3617 |
| 3619 virtual Representation representation() const { | 3618 virtual Representation representation() const { |
| 3620 return kUnboxedMint; | 3619 return kUnboxedMint; |
| 3621 } | 3620 } |
| 3622 | 3621 |
| 3623 virtual Representation RequiredInputRepresentation(intptr_t idx) const { | 3622 virtual Representation RequiredInputRepresentation(intptr_t idx) const { |
| 3624 ASSERT(idx == 0); | 3623 ASSERT(idx == 0); |
| 3625 return kUnboxedMint; | 3624 return kUnboxedMint; |
| 3626 } | 3625 } |
| 3627 | 3626 |
| 3628 virtual intptr_t DeoptimizationTarget() const { | 3627 virtual intptr_t DeoptimizationTarget() const { |
| 3629 // Direct access since this instuction cannot deoptimize, and the deopt-id | 3628 // Direct access since this instuction cannot deoptimize, and the deopt-id |
| 3630 // was inherited from another instuction that could deoptimize. | 3629 // was inherited from another instuction that could deoptimize. |
| 3631 return deopt_id_; | 3630 return deopt_id_; |
| 3632 } | 3631 } |
| 3633 | 3632 |
| 3634 DECLARE_INSTRUCTION(UnboxedMintUnaryOp) | 3633 DECLARE_INSTRUCTION(UnaryMintOp) |
| 3635 | 3634 |
| 3636 private: | 3635 private: |
| 3637 const Token::Kind op_kind_; | 3636 const Token::Kind op_kind_; |
| 3638 | 3637 |
| 3639 DISALLOW_COPY_AND_ASSIGN(UnboxedMintUnaryOpInstr); | 3638 DISALLOW_COPY_AND_ASSIGN(UnaryMintOpInstr); |
| 3640 }; | 3639 }; |
| 3641 | 3640 |
| 3642 | 3641 |
| 3643 class BinarySmiOpInstr : public TemplateDefinition<2> { | 3642 class BinarySmiOpInstr : public TemplateDefinition<2> { |
| 3644 public: | 3643 public: |
| 3645 BinarySmiOpInstr(Token::Kind op_kind, | 3644 BinarySmiOpInstr(Token::Kind op_kind, |
| 3646 InstanceCallInstr* instance_call, | 3645 InstanceCallInstr* instance_call, |
| 3647 Value* left, | 3646 Value* left, |
| 3648 Value* right) | 3647 Value* right) |
| 3649 : op_kind_(op_kind), | 3648 : op_kind_(op_kind), |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4124 ForwardInstructionIterator* current_iterator_; | 4123 ForwardInstructionIterator* current_iterator_; |
| 4125 | 4124 |
| 4126 private: | 4125 private: |
| 4127 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 4126 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
| 4128 }; | 4127 }; |
| 4129 | 4128 |
| 4130 | 4129 |
| 4131 } // namespace dart | 4130 } // namespace dart |
| 4132 | 4131 |
| 4133 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 4132 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |