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

Side by Side Diff: vm/intermediate_language.h

Issue 10850014: Separate double binary operation into a separate instruction class. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: added ia32 Created 8 years, 4 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 | « vm/il_printer.cc ('k') | 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 M(LoadVMField, LoadVMFieldComp) \ 90 M(LoadVMField, LoadVMFieldComp) \
91 M(StoreVMField, StoreVMFieldComp) \ 91 M(StoreVMField, StoreVMFieldComp) \
92 M(InstantiateTypeArguments, InstantiateTypeArgumentsComp) \ 92 M(InstantiateTypeArguments, InstantiateTypeArgumentsComp) \
93 M(ExtractConstructorTypeArguments, ExtractConstructorTypeArgumentsComp) \ 93 M(ExtractConstructorTypeArguments, ExtractConstructorTypeArgumentsComp) \
94 M(ExtractConstructorInstantiator, ExtractConstructorInstantiatorComp) \ 94 M(ExtractConstructorInstantiator, ExtractConstructorInstantiatorComp) \
95 M(AllocateContext, AllocateContextComp) \ 95 M(AllocateContext, AllocateContextComp) \
96 M(ChainContext, ChainContextComp) \ 96 M(ChainContext, ChainContextComp) \
97 M(CloneContext, CloneContextComp) \ 97 M(CloneContext, CloneContextComp) \
98 M(CatchEntry, CatchEntryComp) \ 98 M(CatchEntry, CatchEntryComp) \
99 M(BinaryOp, BinaryOpComp) \ 99 M(BinaryOp, BinaryOpComp) \
100 M(DoubleBinaryOp, DoubleBinaryOpComp) \
100 M(UnarySmiOp, UnarySmiOpComp) \ 101 M(UnarySmiOp, UnarySmiOpComp) \
101 M(NumberNegate, NumberNegateComp) \ 102 M(NumberNegate, NumberNegateComp) \
102 M(CheckStackOverflow, CheckStackOverflowComp) \ 103 M(CheckStackOverflow, CheckStackOverflowComp) \
103 M(ToDouble, ToDoubleComp) \ 104 M(ToDouble, ToDoubleComp) \
104 105
105 106
106 #define FORWARD_DECLARATION(ShortName, ClassName) class ClassName; 107 #define FORWARD_DECLARATION(ShortName, ClassName) class ClassName;
107 FOR_EACH_COMPUTATION(FORWARD_DECLARATION) 108 FOR_EACH_COMPUTATION(FORWARD_DECLARATION)
108 #undef FORWARD_DECLARATION 109 #undef FORWARD_DECLARATION
109 110
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 : ast_node_(*node), 486 : ast_node_(*node),
486 try_index_(try_index), 487 try_index_(try_index),
487 arguments_(arguments) { } 488 arguments_(arguments) { }
488 489
489 DECLARE_CALL_COMPUTATION(ClosureCall) 490 DECLARE_CALL_COMPUTATION(ClosureCall)
490 491
491 const Array& argument_names() const { return ast_node_.arguments()->names(); } 492 const Array& argument_names() const { return ast_node_.arguments()->names(); }
492 intptr_t token_pos() const { return ast_node_.token_pos(); } 493 intptr_t token_pos() const { return ast_node_.token_pos(); }
493 intptr_t try_index() const { return try_index_; } 494 intptr_t try_index() const { return try_index_; }
494 495
495 intptr_t ArgumentCount() const { return arguments_->length(); } 496 virtual intptr_t ArgumentCount() const { return arguments_->length(); }
496 PushArgumentInstr* ArgumentAt(intptr_t index) const { 497 PushArgumentInstr* ArgumentAt(intptr_t index) const {
497 return (*arguments_)[index]; 498 return (*arguments_)[index];
498 } 499 }
499 500
500 virtual void PrintOperandsTo(BufferFormatter* f) const; 501 virtual void PrintOperandsTo(BufferFormatter* f) const;
501 502
502 virtual bool CanDeoptimize() const { return false; } 503 virtual bool CanDeoptimize() const { return false; }
503 504
504 private: 505 private:
505 const ClosureCallNode& ast_node_; 506 const ClosureCallNode& ast_node_;
(...skipping 28 matching lines...) Expand all
534 token_kind == Token::kGET || 535 token_kind == Token::kGET ||
535 token_kind == Token::kILLEGAL); 536 token_kind == Token::kILLEGAL);
536 } 537 }
537 538
538 DECLARE_CALL_COMPUTATION(InstanceCall) 539 DECLARE_CALL_COMPUTATION(InstanceCall)
539 540
540 intptr_t token_pos() const { return token_pos_; } 541 intptr_t token_pos() const { return token_pos_; }
541 intptr_t try_index() const { return try_index_; } 542 intptr_t try_index() const { return try_index_; }
542 const String& function_name() const { return function_name_; } 543 const String& function_name() const { return function_name_; }
543 Token::Kind token_kind() const { return token_kind_; } 544 Token::Kind token_kind() const { return token_kind_; }
544 intptr_t ArgumentCount() const { return arguments_->length(); } 545 virtual intptr_t ArgumentCount() const { return arguments_->length(); }
545 PushArgumentInstr* ArgumentAt(intptr_t index) const { 546 PushArgumentInstr* ArgumentAt(intptr_t index) const {
546 return (*arguments_)[index]; 547 return (*arguments_)[index];
547 } 548 }
548 const Array& argument_names() const { return argument_names_; } 549 const Array& argument_names() const { return argument_names_; }
549 intptr_t checked_argument_count() const { return checked_argument_count_; } 550 intptr_t checked_argument_count() const { return checked_argument_count_; }
550 551
551 virtual void PrintOperandsTo(BufferFormatter* f) const; 552 virtual void PrintOperandsTo(BufferFormatter* f) const;
552 553
553 virtual bool CanDeoptimize() const { return false; } 554 virtual bool CanDeoptimize() const { return false; }
554 555
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 } 726 }
726 727
727 DECLARE_CALL_COMPUTATION(StaticCall) 728 DECLARE_CALL_COMPUTATION(StaticCall)
728 729
729 // Accessors forwarded to the AST node. 730 // Accessors forwarded to the AST node.
730 const Function& function() const { return function_; } 731 const Function& function() const { return function_; }
731 const Array& argument_names() const { return argument_names_; } 732 const Array& argument_names() const { return argument_names_; }
732 intptr_t token_pos() const { return token_pos_; } 733 intptr_t token_pos() const { return token_pos_; }
733 intptr_t try_index() const { return try_index_; } 734 intptr_t try_index() const { return try_index_; }
734 735
735 intptr_t ArgumentCount() const { return arguments_->length(); } 736 virtual intptr_t ArgumentCount() const { return arguments_->length(); }
736 PushArgumentInstr* ArgumentAt(intptr_t index) const { 737 PushArgumentInstr* ArgumentAt(intptr_t index) const {
737 return (*arguments_)[index]; 738 return (*arguments_)[index];
738 } 739 }
739 740
740 MethodRecognizer::Kind recognized() const { return recognized_; } 741 MethodRecognizer::Kind recognized() const { return recognized_; }
741 void set_recognized(MethodRecognizer::Kind kind) { recognized_ = kind; } 742 void set_recognized(MethodRecognizer::Kind kind) { recognized_ = kind; }
742 743
743 virtual void PrintOperandsTo(BufferFormatter* f) const; 744 virtual void PrintOperandsTo(BufferFormatter* f) const;
744 745
745 virtual bool CanDeoptimize() const { return false; } 746 virtual bool CanDeoptimize() const { return false; }
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
1052 try_index_(try_index), 1053 try_index_(try_index),
1053 field_name_(field_name), 1054 field_name_(field_name),
1054 arguments_(arguments) { } 1055 arguments_(arguments) { }
1055 1056
1056 DECLARE_CALL_COMPUTATION(InstanceSetter) 1057 DECLARE_CALL_COMPUTATION(InstanceSetter)
1057 1058
1058 intptr_t token_pos() const { return token_pos_; } 1059 intptr_t token_pos() const { return token_pos_; }
1059 intptr_t try_index() const { return try_index_; } 1060 intptr_t try_index() const { return try_index_; }
1060 const String& field_name() const { return field_name_; } 1061 const String& field_name() const { return field_name_; }
1061 1062
1062 intptr_t ArgumentCount() const { return arguments_->length(); } 1063 virtual intptr_t ArgumentCount() const { return arguments_->length(); }
1063 PushArgumentInstr* ArgumentAt(intptr_t index) const { 1064 PushArgumentInstr* ArgumentAt(intptr_t index) const {
1064 return (*arguments_)[index]; 1065 return (*arguments_)[index];
1065 } 1066 }
1066 1067
1067 virtual bool CanDeoptimize() const { return true; } 1068 virtual bool CanDeoptimize() const { return true; }
1068 1069
1069 virtual void PrintOperandsTo(BufferFormatter* f) const; 1070 virtual void PrintOperandsTo(BufferFormatter* f) const;
1070 1071
1071 private: 1072 private:
1072 const intptr_t token_pos_; 1073 const intptr_t token_pos_;
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
1299 : ast_node_(*node), 1300 : ast_node_(*node),
1300 try_index_(try_index), 1301 try_index_(try_index),
1301 arguments_(arguments) { } 1302 arguments_(arguments) { }
1302 1303
1303 DECLARE_CALL_COMPUTATION(CreateClosure) 1304 DECLARE_CALL_COMPUTATION(CreateClosure)
1304 1305
1305 intptr_t token_pos() const { return ast_node_.token_pos(); } 1306 intptr_t token_pos() const { return ast_node_.token_pos(); }
1306 intptr_t try_index() const { return try_index_; } 1307 intptr_t try_index() const { return try_index_; }
1307 const Function& function() const { return ast_node_.function(); } 1308 const Function& function() const { return ast_node_.function(); }
1308 1309
1309 intptr_t ArgumentCount() const { return arguments_->length(); } 1310 virtual intptr_t ArgumentCount() const { return arguments_->length(); }
1310 PushArgumentInstr* ArgumentAt(intptr_t index) const { 1311 PushArgumentInstr* ArgumentAt(intptr_t index) const {
1311 return (*arguments_)[index]; 1312 return (*arguments_)[index];
1312 } 1313 }
1313 1314
1314 virtual void PrintOperandsTo(BufferFormatter* f) const; 1315 virtual void PrintOperandsTo(BufferFormatter* f) const;
1315 1316
1316 virtual bool CanDeoptimize() const { return false; } 1317 virtual bool CanDeoptimize() const { return false; }
1317 1318
1318 private: 1319 private:
1319 const ClosureNode& ast_node_; 1320 const ClosureNode& ast_node_;
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
1625 1626
1626 private: 1627 private:
1627 const Token::Kind op_kind_; 1628 const Token::Kind op_kind_;
1628 const OperandsType operands_type_; 1629 const OperandsType operands_type_;
1629 InstanceCallComp* instance_call_; 1630 InstanceCallComp* instance_call_;
1630 1631
1631 DISALLOW_COPY_AND_ASSIGN(BinaryOpComp); 1632 DISALLOW_COPY_AND_ASSIGN(BinaryOpComp);
1632 }; 1633 };
1633 1634
1634 1635
1636 class DoubleBinaryOpComp : public Computation {
1637 public:
1638 DoubleBinaryOpComp(Token::Kind op_kind, InstanceCallComp* instance_call)
1639 : op_kind_(op_kind), instance_call_(instance_call) { }
1640
1641 Token::Kind op_kind() const { return op_kind_; }
1642
1643 InstanceCallComp* instance_call() const { return instance_call_; }
1644
1645 virtual void PrintOperandsTo(BufferFormatter* f) const;
1646
1647 DECLARE_CALL_COMPUTATION(DoubleBinaryOp)
1648
1649 virtual intptr_t ArgumentCount() const { return 2; }
1650
1651 virtual bool CanDeoptimize() const { return true; }
1652
1653 private:
1654 const Token::Kind op_kind_;
1655 InstanceCallComp* instance_call_;
1656
1657 DISALLOW_COPY_AND_ASSIGN(DoubleBinaryOpComp);
1658 };
1659
1660
1635 // Handles both Smi operations: BIT_OR and NEGATE. 1661 // Handles both Smi operations: BIT_OR and NEGATE.
1636 class UnarySmiOpComp : public TemplateComputation<1> { 1662 class UnarySmiOpComp : public TemplateComputation<1> {
1637 public: 1663 public:
1638 UnarySmiOpComp(Token::Kind op_kind, 1664 UnarySmiOpComp(Token::Kind op_kind,
1639 InstanceCallComp* instance_call, 1665 InstanceCallComp* instance_call,
1640 Value* value) 1666 Value* value)
1641 : op_kind_(op_kind), instance_call_(instance_call) { 1667 : op_kind_(op_kind), instance_call_(instance_call) {
1642 ASSERT(value != NULL); 1668 ASSERT(value != NULL);
1643 inputs_[0] = value; 1669 inputs_[0] = value;
1644 } 1670 }
(...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after
2789 const GrowableArray<BlockEntryInstr*>& block_order_; 2815 const GrowableArray<BlockEntryInstr*>& block_order_;
2790 2816
2791 private: 2817 private:
2792 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 2818 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
2793 }; 2819 };
2794 2820
2795 2821
2796 } // namespace dart 2822 } // namespace dart
2797 2823
2798 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 2824 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW
« no previous file with comments | « vm/il_printer.cc ('k') | vm/intermediate_language.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698