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

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

Issue 14251023: Merge (x & y) == 0 pattern to emit a single test instruction. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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
OLDNEW
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 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 M(BoxInteger) \ 497 M(BoxInteger) \
498 M(BinaryMintOp) \ 498 M(BinaryMintOp) \
499 M(ShiftMintOp) \ 499 M(ShiftMintOp) \
500 M(UnaryMintOp) \ 500 M(UnaryMintOp) \
501 M(CheckArrayBound) \ 501 M(CheckArrayBound) \
502 M(Constraint) \ 502 M(Constraint) \
503 M(StringFromCharCode) \ 503 M(StringFromCharCode) \
504 M(InvokeMathCFunction) \ 504 M(InvokeMathCFunction) \
505 M(GuardField) \ 505 M(GuardField) \
506 M(IfThenElse) \ 506 M(IfThenElse) \
507 M(TestSmi) \
507 508
508 #define FORWARD_DECLARATION(type) class type##Instr; 509 #define FORWARD_DECLARATION(type) class type##Instr;
509 FOR_EACH_INSTRUCTION(FORWARD_DECLARATION) 510 FOR_EACH_INSTRUCTION(FORWARD_DECLARATION)
510 #undef FORWARD_DECLARATION 511 #undef FORWARD_DECLARATION
511 512
512 513
513 // Functions required in all concrete instruction classes. 514 // Functions required in all concrete instruction classes.
514 #define DECLARE_INSTRUCTION(type) \ 515 #define DECLARE_INSTRUCTION(type) \
515 virtual Tag tag() const { return k##type; } \ 516 virtual Tag tag() const { return k##type; } \
516 virtual void Accept(FlowGraphVisitor* visitor); \ 517 virtual void Accept(FlowGraphVisitor* visitor); \
(...skipping 1962 matching lines...) Expand 10 before | Expand all | Expand 10 after
2479 2480
2480 Token::Kind kind() const { return kind_; } 2481 Token::Kind kind() const { return kind_; }
2481 2482
2482 virtual void EmitBranchCode(FlowGraphCompiler* compiler, 2483 virtual void EmitBranchCode(FlowGraphCompiler* compiler,
2483 BranchInstr* branch) = 0; 2484 BranchInstr* branch) = 0;
2484 2485
2485 void SetDeoptId(intptr_t deopt_id) { 2486 void SetDeoptId(intptr_t deopt_id) {
2486 deopt_id_ = deopt_id; 2487 deopt_id_ = deopt_id;
2487 } 2488 }
2488 2489
2490 virtual bool IsSmiEquality() const {
2491 return false;
2492 }
2493
2489 protected: 2494 protected:
2490 Token::Kind kind_; 2495 Token::Kind kind_;
2491 }; 2496 };
2492 2497
2493 2498
2494 // Inlined functions from class BranchInstr that forward to their comparison. 2499 // Inlined functions from class BranchInstr that forward to their comparison.
2495 inline intptr_t BranchInstr::ArgumentCount() const { 2500 inline intptr_t BranchInstr::ArgumentCount() const {
2496 return comparison()->ArgumentCount(); 2501 return comparison()->ArgumentCount();
2497 } 2502 }
2498 2503
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
2578 2583
2579 private: 2584 private:
2580 // True if the comparison must check for double, Mint or Bigint and 2585 // True if the comparison must check for double, Mint or Bigint and
2581 // use value comparison instead. 2586 // use value comparison instead.
2582 bool needs_number_check_; 2587 bool needs_number_check_;
2583 2588
2584 DISALLOW_COPY_AND_ASSIGN(StrictCompareInstr); 2589 DISALLOW_COPY_AND_ASSIGN(StrictCompareInstr);
2585 }; 2590 };
2586 2591
2587 2592
2593 class TestSmiInstr : public ComparisonInstr {
srdjan 2013/04/15 20:27:27 Maybe add comment what this instruction is for.
Vyacheslav Egorov (Google) 2013/04/16 11:51:16 Done.
2594 public:
2595 TestSmiInstr(Token::Kind kind, Value* left, Value* right)
2596 : ComparisonInstr(kind, left, right) {
2597 }
2598
2599 DECLARE_INSTRUCTION(TestSmi);
2600
2601 virtual CompileType ComputeType() const {
2602 return CompileType::Bool();
2603 }
2604
2605 virtual bool CanDeoptimize() const {
2606 return false;
2607 }
2608
2609 virtual bool HasSideEffect() const {
2610 return false;
2611 }
2612
2613 virtual void EmitBranchCode(FlowGraphCompiler* compiler,
2614 BranchInstr* branch);
2615
2616 virtual Representation RequiredInputRepresentation(intptr_t idx) const {
2617 return kTagged;
2618 }
2619
2620 private:
2621 DISALLOW_COPY_AND_ASSIGN(TestSmiInstr);
2622 };
2623
2624
2588 class EqualityCompareInstr : public ComparisonInstr { 2625 class EqualityCompareInstr : public ComparisonInstr {
2589 public: 2626 public:
2590 EqualityCompareInstr(intptr_t token_pos, 2627 EqualityCompareInstr(intptr_t token_pos,
2591 Token::Kind kind, 2628 Token::Kind kind,
2592 Value* left, 2629 Value* left,
2593 Value* right) 2630 Value* right)
2594 : ComparisonInstr(kind, left, right), 2631 : ComparisonInstr(kind, left, right),
2595 token_pos_(token_pos), 2632 token_pos_(token_pos),
2596 receiver_class_id_(kIllegalCid) { 2633 receiver_class_id_(kIllegalCid) {
2597 // deopt_id() checks receiver_class_id_ value. 2634 // deopt_id() checks receiver_class_id_ value.
2598 ic_data_ = Isolate::Current()->GetICDataForDeoptId(deopt_id()); 2635 ic_data_ = Isolate::Current()->GetICDataForDeoptId(deopt_id());
2599 ASSERT((kind == Token::kEQ) || (kind == Token::kNE)); 2636 ASSERT((kind == Token::kEQ) ||
2637 (kind == Token::kNE));
srdjan 2013/04/15 20:27:27 Back to one line?
Vyacheslav Egorov (Google) 2013/04/16 11:51:16 Done.
2600 } 2638 }
2601 2639
2602 DECLARE_INSTRUCTION(EqualityCompare) 2640 DECLARE_INSTRUCTION(EqualityCompare)
2603 virtual CompileType ComputeType() const; 2641 virtual CompileType ComputeType() const;
2604 virtual bool RecomputeType(); 2642 virtual bool RecomputeType();
2605 2643
2606 const ICData* ic_data() const { return ic_data_; } 2644 const ICData* ic_data() const { return ic_data_; }
2607 bool HasICData() const { 2645 bool HasICData() const {
2608 return (ic_data() != NULL) && !ic_data()->IsNull(); 2646 return (ic_data() != NULL) && !ic_data()->IsNull();
2609 } 2647 }
(...skipping 30 matching lines...) Expand all
2640 2678
2641 virtual Representation RequiredInputRepresentation(intptr_t idx) const { 2679 virtual Representation RequiredInputRepresentation(intptr_t idx) const {
2642 ASSERT((idx == 0) || (idx == 1)); 2680 ASSERT((idx == 0) || (idx == 1));
2643 if (receiver_class_id() == kDoubleCid) return kUnboxedDouble; 2681 if (receiver_class_id() == kDoubleCid) return kUnboxedDouble;
2644 if (receiver_class_id() == kMintCid) return kUnboxedMint; 2682 if (receiver_class_id() == kMintCid) return kUnboxedMint;
2645 return kTagged; 2683 return kTagged;
2646 } 2684 }
2647 2685
2648 bool IsPolymorphic() const; 2686 bool IsPolymorphic() const;
2649 2687
2688 virtual bool IsSmiEquality() const {
2689 return receiver_class_id() == kSmiCid;
2690 }
2691
2650 private: 2692 private:
2651 const ICData* ic_data_; 2693 const ICData* ic_data_;
2652 const intptr_t token_pos_; 2694 const intptr_t token_pos_;
2653 intptr_t receiver_class_id_; // Set by optimizer. 2695 intptr_t receiver_class_id_; // Set by optimizer.
2654 2696
2655 DISALLOW_COPY_AND_ASSIGN(EqualityCompareInstr); 2697 DISALLOW_COPY_AND_ASSIGN(EqualityCompareInstr);
2656 }; 2698 };
2657 2699
2658 2700
2659 class RelationalOpInstr : public ComparisonInstr { 2701 class RelationalOpInstr : public ComparisonInstr {
(...skipping 2224 matching lines...) Expand 10 before | Expand all | Expand 10 after
4884 ForwardInstructionIterator* current_iterator_; 4926 ForwardInstructionIterator* current_iterator_;
4885 4927
4886 private: 4928 private:
4887 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 4929 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
4888 }; 4930 };
4889 4931
4890 4932
4891 } // namespace dart 4933 } // namespace dart
4892 4934
4893 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 4935 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698