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

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

Issue 11773040: Canonicalize away simple arithmetic equivalences. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add test, address comments Created 7 years, 11 months 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 | « no previous file | 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) 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 3501 matching lines...) Expand 10 before | Expand all | Expand 10 after
3512 virtual bool HasSideEffect() const { return false; } 3512 virtual bool HasSideEffect() const { return false; }
3513 3513
3514 virtual intptr_t ResultCid() const; 3514 virtual intptr_t ResultCid() const;
3515 3515
3516 virtual RawAbstractType* CompileType() const; 3516 virtual RawAbstractType* CompileType() const;
3517 3517
3518 virtual Representation representation() const { 3518 virtual Representation representation() const {
3519 return kUnboxedMint; 3519 return kUnboxedMint;
3520 } 3520 }
3521 3521
3522
3522 virtual bool AffectedBySideEffect() const { return false; } 3523 virtual bool AffectedBySideEffect() const { return false; }
3523 virtual bool AttributesEqual(Instruction* other) const { return true; } 3524 virtual bool AttributesEqual(Instruction* other) const { return true; }
3524 3525
3525 DECLARE_INSTRUCTION(UnboxInteger) 3526 DECLARE_INSTRUCTION(UnboxInteger)
3526 3527
3527 private: 3528 private:
3528 DISALLOW_COPY_AND_ASSIGN(UnboxIntegerInstr); 3529 DISALLOW_COPY_AND_ASSIGN(UnboxIntegerInstr);
3529 }; 3530 };
3530 3531
3531 3532
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
3569 virtual RawAbstractType* CompileType() const; 3570 virtual RawAbstractType* CompileType() const;
3570 3571
3571 private: 3572 private:
3572 DISALLOW_COPY_AND_ASSIGN(MathSqrtInstr); 3573 DISALLOW_COPY_AND_ASSIGN(MathSqrtInstr);
3573 }; 3574 };
3574 3575
3575 3576
3576 class BinaryDoubleOpInstr : public TemplateDefinition<2> { 3577 class BinaryDoubleOpInstr : public TemplateDefinition<2> {
3577 public: 3578 public:
3578 BinaryDoubleOpInstr(Token::Kind op_kind, 3579 BinaryDoubleOpInstr(Token::Kind op_kind,
3579 Value* left, 3580 Value* left,
3580 Value* right, 3581 Value* right,
3581 InstanceCallInstr* instance_call) 3582 InstanceCallInstr* instance_call)
3582 : op_kind_(op_kind) { 3583 : op_kind_(op_kind) {
3583 ASSERT(left != NULL); 3584 ASSERT(left != NULL);
3584 ASSERT(right != NULL); 3585 ASSERT(right != NULL);
3585 inputs_[0] = left; 3586 inputs_[0] = left;
3586 inputs_[1] = right; 3587 inputs_[1] = right;
3587 deopt_id_ = instance_call->deopt_id(); 3588 deopt_id_ = instance_call->deopt_id();
3588 } 3589 }
3589 3590
3590 Value* left() const { return inputs_[0]; } 3591 Value* left() const { return inputs_[0]; }
3591 Value* right() const { return inputs_[1]; } 3592 Value* right() const { return inputs_[1]; }
(...skipping 25 matching lines...) Expand all
3617 3618
3618 virtual intptr_t DeoptimizationTarget() const { 3619 virtual intptr_t DeoptimizationTarget() const {
3619 // Direct access since this instruction cannot deoptimize, and the deopt-id 3620 // Direct access since this instruction cannot deoptimize, and the deopt-id
3620 // was inherited from another instruction that could deoptimize. 3621 // was inherited from another instruction that could deoptimize.
3621 return deopt_id_; 3622 return deopt_id_;
3622 } 3623 }
3623 3624
3624 DECLARE_INSTRUCTION(BinaryDoubleOp) 3625 DECLARE_INSTRUCTION(BinaryDoubleOp)
3625 virtual RawAbstractType* CompileType() const; 3626 virtual RawAbstractType* CompileType() const;
3626 3627
3628 virtual Definition* Canonicalize(FlowGraphOptimizer* optimizer);
3629
3627 private: 3630 private:
3628 const Token::Kind op_kind_; 3631 const Token::Kind op_kind_;
3629 3632
3630 DISALLOW_COPY_AND_ASSIGN(BinaryDoubleOpInstr); 3633 DISALLOW_COPY_AND_ASSIGN(BinaryDoubleOpInstr);
3631 }; 3634 };
3632 3635
3633 3636
3634 class BinaryMintOpInstr : public TemplateDefinition<2> { 3637 class BinaryMintOpInstr : public TemplateDefinition<2> {
3635 public: 3638 public:
3636 BinaryMintOpInstr(Token::Kind op_kind, 3639 BinaryMintOpInstr(Token::Kind op_kind,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
3675 ASSERT((idx == 0) || (idx == 1)); 3678 ASSERT((idx == 0) || (idx == 1));
3676 return kUnboxedMint; 3679 return kUnboxedMint;
3677 } 3680 }
3678 3681
3679 virtual intptr_t DeoptimizationTarget() const { 3682 virtual intptr_t DeoptimizationTarget() const {
3680 // Direct access since this instruction cannot deoptimize, and the deopt-id 3683 // Direct access since this instruction cannot deoptimize, and the deopt-id
3681 // was inherited from another instruction that could deoptimize. 3684 // was inherited from another instruction that could deoptimize.
3682 return deopt_id_; 3685 return deopt_id_;
3683 } 3686 }
3684 3687
3688 virtual Definition* Canonicalize(FlowGraphOptimizer* optimizer);
3689
3685 DECLARE_INSTRUCTION(BinaryMintOp) 3690 DECLARE_INSTRUCTION(BinaryMintOp)
3686 3691
3687 private: 3692 private:
3688 const Token::Kind op_kind_; 3693 const Token::Kind op_kind_;
3689 3694
3690 DISALLOW_COPY_AND_ASSIGN(BinaryMintOpInstr); 3695 DISALLOW_COPY_AND_ASSIGN(BinaryMintOpInstr);
3691 }; 3696 };
3692 3697
3693 3698
3694 class ShiftMintOpInstr : public TemplateDefinition<2> { 3699 class ShiftMintOpInstr : public TemplateDefinition<2> {
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
3846 virtual intptr_t ResultCid() const; 3851 virtual intptr_t ResultCid() const;
3847 3852
3848 void set_overflow(bool overflow) { 3853 void set_overflow(bool overflow) {
3849 overflow_ = overflow; 3854 overflow_ = overflow;
3850 } 3855 }
3851 3856
3852 void PrintTo(BufferFormatter* f) const; 3857 void PrintTo(BufferFormatter* f) const;
3853 3858
3854 virtual void InferRange(); 3859 virtual void InferRange();
3855 3860
3861 virtual Definition* Canonicalize(FlowGraphOptimizer* optimizer);
3862
3856 private: 3863 private:
3857 const Token::Kind op_kind_; 3864 const Token::Kind op_kind_;
3858 InstanceCallInstr* instance_call_; 3865 InstanceCallInstr* instance_call_;
3859 bool overflow_; 3866 bool overflow_;
3860 3867
3861 DISALLOW_COPY_AND_ASSIGN(BinarySmiOpInstr); 3868 DISALLOW_COPY_AND_ASSIGN(BinarySmiOpInstr);
3862 }; 3869 };
3863 3870
3864 3871
3865 // Handles both Smi operations: BIT_OR and NEGATE. 3872 // Handles both Smi operations: BIT_OR and NEGATE.
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
4325 ForwardInstructionIterator* current_iterator_; 4332 ForwardInstructionIterator* current_iterator_;
4326 4333
4327 private: 4334 private:
4328 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 4335 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
4329 }; 4336 };
4330 4337
4331 4338
4332 } // namespace dart 4339 } // namespace dart
4333 4340
4334 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 4341 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/intermediate_language.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698