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

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

Issue 10832150: Get rid of ast node ids. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: 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
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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 class BindInstr; 111 class BindInstr;
112 class BranchInstr; 112 class BranchInstr;
113 class BufferFormatter; 113 class BufferFormatter;
114 class ComparisonComp; 114 class ComparisonComp;
115 class Instruction; 115 class Instruction;
116 class PushArgumentInstr; 116 class PushArgumentInstr;
117 class Value; 117 class Value;
118 118
119 class Computation : public ZoneAllocated { 119 class Computation : public ZoneAllocated {
120 public: 120 public:
121 static const intptr_t kNoCid = -1; 121 Computation() : deopt_id_(Isolate::kNoDeoptId), ic_data_(NULL), locs_(NULL) {
122
123 Computation() : cid_(kNoCid), ic_data_(NULL), locs_(NULL) {
124 Isolate* isolate = Isolate::Current(); 122 Isolate* isolate = Isolate::Current();
125 cid_ = isolate->GetNextCid(); 123 deopt_id_ = isolate->GetNextDeoptId();
126 ic_data_ = isolate->GetICDataForCid(cid_); 124 ic_data_ = isolate->GetICDataForDeoptId(deopt_id_);
127 } 125 }
128 126
129 // Unique computation/instruction id, used for deoptimization. 127 // Unique id used for deoptimization.
130 intptr_t cid() const { return cid_; } 128 intptr_t deopt_id() const { return deopt_id_; }
131 129
132 ICData* ic_data() const { return ic_data_; } 130 ICData* ic_data() const { return ic_data_; }
133 void set_ic_data(ICData* value) { ic_data_ = value; } 131 void set_ic_data(ICData* value) { ic_data_ = value; }
134 bool HasICData() const { 132 bool HasICData() const {
135 return (ic_data() != NULL) && !ic_data()->IsNull(); 133 return (ic_data() != NULL) && !ic_data()->IsNull();
136 } 134 }
137 135
138 // Visiting support. 136 // Visiting support.
139 virtual void Accept(FlowGraphVisitor* visitor, BindInstr* instr) = 0; 137 virtual void Accept(FlowGraphVisitor* visitor, BindInstr* instr) = 0;
140 138
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 196
199 // Declare predicate for each computation. 197 // Declare predicate for each computation.
200 #define DECLARE_PREDICATE(ShortName, ClassName) \ 198 #define DECLARE_PREDICATE(ShortName, ClassName) \
201 inline bool Is##ShortName() const; \ 199 inline bool Is##ShortName() const; \
202 inline const ClassName* As##ShortName() const; \ 200 inline const ClassName* As##ShortName() const; \
203 inline ClassName* As##ShortName(); 201 inline ClassName* As##ShortName();
204 FOR_EACH_COMPUTATION(DECLARE_PREDICATE) 202 FOR_EACH_COMPUTATION(DECLARE_PREDICATE)
205 #undef DECLARE_PREDICATE 203 #undef DECLARE_PREDICATE
206 204
207 private: 205 private:
208 intptr_t cid_; 206 intptr_t deopt_id_;
209 ICData* ic_data_; 207 ICData* ic_data_;
210 LocationSummary* locs_; 208 LocationSummary* locs_;
211 209
212 DISALLOW_COPY_AND_ASSIGN(Computation); 210 DISALLOW_COPY_AND_ASSIGN(Computation);
213 }; 211 };
214 212
215 213
216 // An embedded container with N elements of type T. Used (with partial 214 // An embedded container with N elements of type T. Used (with partial
217 // specialization for N=0) because embedded arrays cannot have size 0. 215 // specialization for N=0) because embedded arrays cannot have size 0.
218 template<typename T, intptr_t N> 216 template<typename T, intptr_t N>
(...skipping 2254 matching lines...) Expand 10 before | Expand all | Expand 10 after
2473 Value* value_; 2471 Value* value_;
2474 2472
2475 DISALLOW_COPY_AND_ASSIGN(PushArgumentInstr); 2473 DISALLOW_COPY_AND_ASSIGN(PushArgumentInstr);
2476 }; 2474 };
2477 2475
2478 2476
2479 class ReturnInstr : public InstructionWithInputs { 2477 class ReturnInstr : public InstructionWithInputs {
2480 public: 2478 public:
2481 ReturnInstr(intptr_t token_pos, Value* value) 2479 ReturnInstr(intptr_t token_pos, Value* value)
2482 : InstructionWithInputs(), 2480 : InstructionWithInputs(),
2483 cid_(Isolate::Current()->GetNextCid()), 2481 deopt_id_(Isolate::Current()->GetNextDeoptId()),
2484 token_pos_(token_pos), 2482 token_pos_(token_pos),
2485 value_(value) { 2483 value_(value) {
2486 ASSERT(value_ != NULL); 2484 ASSERT(value_ != NULL);
2487 } 2485 }
2488 2486
2489 DECLARE_INSTRUCTION(Return) 2487 DECLARE_INSTRUCTION(Return)
2490 2488
2491 virtual intptr_t ArgumentCount() const { return 0; } 2489 virtual intptr_t ArgumentCount() const { return 0; }
2492 2490
2493 intptr_t cid() const { return cid_; } 2491 intptr_t deopt_id() const { return deopt_id_; }
2494 intptr_t token_pos() const { return token_pos_; } 2492 intptr_t token_pos() const { return token_pos_; }
2495 Value* value() const { return value_; } 2493 Value* value() const { return value_; }
2496 2494
2497 virtual LocationSummary* MakeLocationSummary() const; 2495 virtual LocationSummary* MakeLocationSummary() const;
2498 2496
2499 virtual void EmitNativeCode(FlowGraphCompiler* compiler); 2497 virtual void EmitNativeCode(FlowGraphCompiler* compiler);
2500 2498
2501 virtual bool CanDeoptimize() const { return false; } 2499 virtual bool CanDeoptimize() const { return false; }
2502 2500
2503 private: 2501 private:
2504 const intptr_t cid_; // Computation/instruction id. 2502 const intptr_t deopt_id_;
2505 const intptr_t token_pos_; 2503 const intptr_t token_pos_;
2506 Value* value_; 2504 Value* value_;
2507 2505
2508 DISALLOW_COPY_AND_ASSIGN(ReturnInstr); 2506 DISALLOW_COPY_AND_ASSIGN(ReturnInstr);
2509 }; 2507 };
2510 2508
2511 2509
2512 class ThrowInstr : public InstructionWithInputs { 2510 class ThrowInstr : public InstructionWithInputs {
2513 public: 2511 public:
2514 ThrowInstr(intptr_t token_pos, intptr_t try_index) 2512 ThrowInstr(intptr_t token_pos, intptr_t try_index)
2515 : InstructionWithInputs(), 2513 : InstructionWithInputs(),
2516 cid_(Isolate::Current()->GetNextCid()), 2514 deopt_id_(Isolate::Current()->GetNextDeoptId()),
2517 token_pos_(token_pos), 2515 token_pos_(token_pos),
2518 try_index_(try_index) { } 2516 try_index_(try_index) { }
2519 2517
2520 DECLARE_CALL_INSTRUCTION(Throw) 2518 DECLARE_CALL_INSTRUCTION(Throw)
2521 2519
2522 virtual intptr_t ArgumentCount() const { return 1; } 2520 virtual intptr_t ArgumentCount() const { return 1; }
2523 2521
2524 intptr_t cid() const { return cid_; } 2522 intptr_t deopt_id() const { return deopt_id_; }
2525 intptr_t token_pos() const { return token_pos_; } 2523 intptr_t token_pos() const { return token_pos_; }
2526 intptr_t try_index() const { return try_index_; } 2524 intptr_t try_index() const { return try_index_; }
2527 2525
2528 virtual LocationSummary* MakeLocationSummary() const; 2526 virtual LocationSummary* MakeLocationSummary() const;
2529 2527
2530 virtual void EmitNativeCode(FlowGraphCompiler* compiler); 2528 virtual void EmitNativeCode(FlowGraphCompiler* compiler);
2531 2529
2532 virtual bool CanDeoptimize() const { return false; } 2530 virtual bool CanDeoptimize() const { return false; }
2533 2531
2534 private: 2532 private:
2535 const intptr_t cid_; // Computation/instruction id. 2533 const intptr_t deopt_id_;
2536 const intptr_t token_pos_; 2534 const intptr_t token_pos_;
2537 const intptr_t try_index_; 2535 const intptr_t try_index_;
2538 2536
2539 DISALLOW_COPY_AND_ASSIGN(ThrowInstr); 2537 DISALLOW_COPY_AND_ASSIGN(ThrowInstr);
2540 }; 2538 };
2541 2539
2542 2540
2543 class ReThrowInstr : public InstructionWithInputs { 2541 class ReThrowInstr : public InstructionWithInputs {
2544 public: 2542 public:
2545 ReThrowInstr(intptr_t token_pos, 2543 ReThrowInstr(intptr_t token_pos,
2546 intptr_t try_index) 2544 intptr_t try_index)
2547 : InstructionWithInputs(), 2545 : InstructionWithInputs(),
2548 cid_(Isolate::Current()->GetNextCid()), 2546 deopt_id_(Isolate::Current()->GetNextDeoptId()),
2549 token_pos_(token_pos), 2547 token_pos_(token_pos),
2550 try_index_(try_index) { } 2548 try_index_(try_index) { }
2551 2549
2552 DECLARE_CALL_INSTRUCTION(ReThrow) 2550 DECLARE_CALL_INSTRUCTION(ReThrow)
2553 2551
2554 virtual intptr_t ArgumentCount() const { return 2; } 2552 virtual intptr_t ArgumentCount() const { return 2; }
2555 2553
2556 intptr_t cid() const { return cid_; } 2554 intptr_t deopt_id() const { return deopt_id_; }
2557 intptr_t token_pos() const { return token_pos_; } 2555 intptr_t token_pos() const { return token_pos_; }
2558 intptr_t try_index() const { return try_index_; } 2556 intptr_t try_index() const { return try_index_; }
2559 2557
2560 virtual LocationSummary* MakeLocationSummary() const; 2558 virtual LocationSummary* MakeLocationSummary() const;
2561 2559
2562 virtual void EmitNativeCode(FlowGraphCompiler* compiler); 2560 virtual void EmitNativeCode(FlowGraphCompiler* compiler);
2563 2561
2564 virtual bool CanDeoptimize() const { return false; } 2562 virtual bool CanDeoptimize() const { return false; }
2565 2563
2566 private: 2564 private:
2567 const intptr_t cid_; // Computation/instruction id. 2565 const intptr_t deopt_id_;
2568 const intptr_t token_pos_; 2566 const intptr_t token_pos_;
2569 const intptr_t try_index_; 2567 const intptr_t try_index_;
2570 2568
2571 DISALLOW_COPY_AND_ASSIGN(ReThrowInstr); 2569 DISALLOW_COPY_AND_ASSIGN(ReThrowInstr);
2572 }; 2570 };
2573 2571
2574 2572
2575 class GotoInstr : public InstructionWithInputs { 2573 class GotoInstr : public InstructionWithInputs {
2576 public: 2574 public:
2577 explicit GotoInstr(JoinEntryInstr* entry) 2575 explicit GotoInstr(JoinEntryInstr* entry)
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2619 2617
2620 2618
2621 class BranchInstr : public InstructionWithInputs { 2619 class BranchInstr : public InstructionWithInputs {
2622 public: 2620 public:
2623 BranchInstr(intptr_t token_pos, 2621 BranchInstr(intptr_t token_pos,
2624 intptr_t try_index, 2622 intptr_t try_index,
2625 Value* left, 2623 Value* left,
2626 Value* right, 2624 Value* right,
2627 Token::Kind kind) 2625 Token::Kind kind)
2628 : InstructionWithInputs(), 2626 : InstructionWithInputs(),
2629 cid_(Computation::kNoCid), 2627 deopt_id_(Isolate::kNoDeoptId),
2630 ic_data_(NULL), 2628 ic_data_(NULL),
2631 token_pos_(token_pos), 2629 token_pos_(token_pos),
2632 try_index_(try_index), 2630 try_index_(try_index),
2633 left_(left), 2631 left_(left),
2634 right_(right), 2632 right_(right),
2635 kind_(kind), 2633 kind_(kind),
2636 true_successor_(NULL), 2634 true_successor_(NULL),
2637 false_successor_(NULL) { 2635 false_successor_(NULL) {
2638 ASSERT(left_ != NULL); 2636 ASSERT(left_ != NULL);
2639 ASSERT(right_ != NULL); 2637 ASSERT(right_ != NULL);
2640 ASSERT(Token::IsEqualityOperator(kind) || 2638 ASSERT(Token::IsEqualityOperator(kind) ||
2641 Token::IsRelationalOperator(kind) || 2639 Token::IsRelationalOperator(kind) ||
2642 Token::IsTypeTestOperator(kind)); 2640 Token::IsTypeTestOperator(kind));
2643 Isolate* isolate = Isolate::Current(); 2641 Isolate* isolate = Isolate::Current();
2644 cid_ = isolate->GetNextCid(); 2642 deopt_id_ = isolate->GetNextDeoptId();
2645 ic_data_ = isolate->GetICDataForCid(cid_); 2643 ic_data_ = isolate->GetICDataForDeoptId(deopt_id_);
2646 } 2644 }
2647 2645
2648 DECLARE_INSTRUCTION(Branch) 2646 DECLARE_INSTRUCTION(Branch)
2649 2647
2650 virtual intptr_t ArgumentCount() const { return 0; } 2648 virtual intptr_t ArgumentCount() const { return 0; }
2651 2649
2652 Value* left() const { return left_; } 2650 Value* left() const { return left_; }
2653 Value* right() const { return right_; } 2651 Value* right() const { return right_; }
2654 Token::Kind kind() const { return kind_; } 2652 Token::Kind kind() const { return kind_; }
2655 void set_kind(Token::Kind kind) { 2653 void set_kind(Token::Kind kind) {
2656 ASSERT(Token::IsEqualityOperator(kind) || 2654 ASSERT(Token::IsEqualityOperator(kind) ||
2657 Token::IsRelationalOperator(kind) || 2655 Token::IsRelationalOperator(kind) ||
2658 Token::IsTypeTestOperator(kind)); 2656 Token::IsTypeTestOperator(kind));
2659 kind_ = kind; 2657 kind_ = kind;
2660 } 2658 }
2661 2659
2662 intptr_t cid() const { return cid_; } 2660 intptr_t deopt_id() const { return deopt_id_; }
2663 2661
2664 const ICData* ic_data() const { return ic_data_; } 2662 const ICData* ic_data() const { return ic_data_; }
2665 bool HasICData() const { 2663 bool HasICData() const {
2666 return (ic_data() != NULL) && !ic_data()->IsNull(); 2664 return (ic_data() != NULL) && !ic_data()->IsNull();
2667 } 2665 }
2668 2666
2669 intptr_t token_pos() const { return token_pos_;} 2667 intptr_t token_pos() const { return token_pos_;}
2670 intptr_t try_index() const { return try_index_; } 2668 intptr_t try_index() const { return try_index_; }
2671 2669
2672 TargetEntryInstr* true_successor() const { return true_successor_; } 2670 TargetEntryInstr* true_successor() const { return true_successor_; }
(...skipping 17 matching lines...) Expand all
2690 virtual LocationSummary* MakeLocationSummary() const; 2688 virtual LocationSummary* MakeLocationSummary() const;
2691 2689
2692 virtual void EmitNativeCode(FlowGraphCompiler* compiler); 2690 virtual void EmitNativeCode(FlowGraphCompiler* compiler);
2693 2691
2694 void EmitBranchOnCondition(FlowGraphCompiler* compiler, 2692 void EmitBranchOnCondition(FlowGraphCompiler* compiler,
2695 Condition true_condition); 2693 Condition true_condition);
2696 2694
2697 virtual bool CanDeoptimize() const { return true; } 2695 virtual bool CanDeoptimize() const { return true; }
2698 2696
2699 private: 2697 private:
2700 intptr_t cid_; // Computation/instruction id. 2698 intptr_t deopt_id_;
2701 ICData* ic_data_; 2699 ICData* ic_data_;
2702 const intptr_t token_pos_; 2700 const intptr_t token_pos_;
2703 const intptr_t try_index_; 2701 const intptr_t try_index_;
2704 Value* left_; 2702 Value* left_;
2705 Value* right_; 2703 Value* right_;
2706 Token::Kind kind_; 2704 Token::Kind kind_;
2707 TargetEntryInstr* true_successor_; 2705 TargetEntryInstr* true_successor_;
2708 TargetEntryInstr* false_successor_; 2706 TargetEntryInstr* false_successor_;
2709 2707
2710 DISALLOW_COPY_AND_ASSIGN(BranchInstr); 2708 DISALLOW_COPY_AND_ASSIGN(BranchInstr);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
2789 const GrowableArray<BlockEntryInstr*>& block_order_; 2787 const GrowableArray<BlockEntryInstr*>& block_order_;
2790 2788
2791 private: 2789 private:
2792 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 2790 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
2793 }; 2791 };
2794 2792
2795 2793
2796 } // namespace dart 2794 } // namespace dart
2797 2795
2798 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 2796 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698