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

Side by Side Diff: vm/intermediate_language.h

Issue 10829141: Support Throw and ReThrow in SSA-based compiler. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
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
« 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 1782 matching lines...) Expand 10 before | Expand all | Expand 10 after
1793 virtual bool Is##type() const { return true; } \ 1793 virtual bool Is##type() const { return true; } \
1794 virtual type##Instr* As##type() { return this; } \ 1794 virtual type##Instr* As##type() { return this; } \
1795 virtual intptr_t InputCount() const; \ 1795 virtual intptr_t InputCount() const; \
1796 virtual Value* InputAt(intptr_t i) const; \ 1796 virtual Value* InputAt(intptr_t i) const; \
1797 virtual void SetInputAt(intptr_t i, Value* value); \ 1797 virtual void SetInputAt(intptr_t i, Value* value); \
1798 virtual const char* DebugName() const { return #type; } \ 1798 virtual const char* DebugName() const { return #type; } \
1799 virtual void PrintTo(BufferFormatter* f) const; \ 1799 virtual void PrintTo(BufferFormatter* f) const; \
1800 virtual void PrintToVisualizer(BufferFormatter* f) const; 1800 virtual void PrintToVisualizer(BufferFormatter* f) const;
1801 1801
1802 1802
1803 #define DECLARE_CALL_INSTRUCTION(type) \
1804 virtual void Accept(FlowGraphVisitor* visitor); \
1805 virtual bool Is##type() const { return true; } \
1806 virtual type##Instr* As##type() { return this; } \
1807 virtual intptr_t InputCount() const { return 0; } \
1808 virtual Value* InputAt(intptr_t i) const { \
1809 UNREACHABLE(); \
1810 return NULL; \
1811 } \
1812 virtual void SetInputAt(intptr_t i, Value* value) { UNREACHABLE(); } \
1813 virtual const char* DebugName() const { return #type; } \
1814 virtual void PrintTo(BufferFormatter* f) const; \
1815 virtual void PrintToVisualizer(BufferFormatter* f) const;
1816
1817
1803 class Instruction : public ZoneAllocated { 1818 class Instruction : public ZoneAllocated {
1804 public: 1819 public:
1805 Instruction() 1820 Instruction()
1806 : lifetime_position_(-1), previous_(NULL), next_(NULL), env_(NULL) { } 1821 : lifetime_position_(-1), previous_(NULL), next_(NULL), env_(NULL) { }
1807 1822
1808 virtual bool IsBlockEntry() const { return false; } 1823 virtual bool IsBlockEntry() const { return false; }
1809 BlockEntryInstr* AsBlockEntry() { 1824 BlockEntryInstr* AsBlockEntry() {
1810 return IsBlockEntry() ? reinterpret_cast<BlockEntryInstr*>(this) : NULL; 1825 return IsBlockEntry() ? reinterpret_cast<BlockEntryInstr*>(this) : NULL;
1811 } 1826 }
1812 virtual bool IsDefinition() const { return false; } 1827 virtual bool IsDefinition() const { return false; }
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1924 Instruction* next_; 1939 Instruction* next_;
1925 Environment* env_; 1940 Environment* env_;
1926 DISALLOW_COPY_AND_ASSIGN(Instruction); 1941 DISALLOW_COPY_AND_ASSIGN(Instruction);
1927 }; 1942 };
1928 1943
1929 1944
1930 class InstructionWithInputs : public Instruction { 1945 class InstructionWithInputs : public Instruction {
1931 public: 1946 public:
1932 InstructionWithInputs() : locs_(NULL) { } 1947 InstructionWithInputs() : locs_(NULL) { }
1933 1948
1934 virtual intptr_t ArgumentCount() const { return 0; }
1935
1936 virtual LocationSummary* locs() { 1949 virtual LocationSummary* locs() {
1937 if (locs_ == NULL) { 1950 if (locs_ == NULL) {
1938 locs_ = MakeLocationSummary(); 1951 locs_ = MakeLocationSummary();
1939 } 1952 }
1940 return locs_; 1953 return locs_;
1941 } 1954 }
1942 1955
1943 virtual LocationSummary* MakeLocationSummary() const = 0; 1956 virtual LocationSummary* MakeLocationSummary() const = 0;
1944 1957
1945 private: 1958 private:
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
2446 DISALLOW_COPY_AND_ASSIGN(ParameterInstr); 2459 DISALLOW_COPY_AND_ASSIGN(ParameterInstr);
2447 }; 2460 };
2448 2461
2449 2462
2450 class PushArgumentInstr : public InstructionWithInputs { 2463 class PushArgumentInstr : public InstructionWithInputs {
2451 public: 2464 public:
2452 explicit PushArgumentInstr(Value* value) : value_(value) { } 2465 explicit PushArgumentInstr(Value* value) : value_(value) { }
2453 2466
2454 DECLARE_INSTRUCTION(PushArgument) 2467 DECLARE_INSTRUCTION(PushArgument)
2455 2468
2469 virtual intptr_t ArgumentCount() const { return 0; }
2470
2456 Value* value() const { return value_; } 2471 Value* value() const { return value_; }
2457 2472
2458 virtual LocationSummary* MakeLocationSummary() const; 2473 virtual LocationSummary* MakeLocationSummary() const;
2459 2474
2460 virtual void EmitNativeCode(FlowGraphCompiler* compiler); 2475 virtual void EmitNativeCode(FlowGraphCompiler* compiler);
2461 2476
2462 virtual bool CanDeoptimize() const { return false; } 2477 virtual bool CanDeoptimize() const { return false; }
2463 2478
2464 private: 2479 private:
2465 Value* value_; 2480 Value* value_;
2466 2481
2467 DISALLOW_COPY_AND_ASSIGN(PushArgumentInstr); 2482 DISALLOW_COPY_AND_ASSIGN(PushArgumentInstr);
2468 }; 2483 };
2469 2484
2470 2485
2471 class ReturnInstr : public InstructionWithInputs { 2486 class ReturnInstr : public InstructionWithInputs {
2472 public: 2487 public:
2473 ReturnInstr(intptr_t token_pos, Value* value) 2488 ReturnInstr(intptr_t token_pos, Value* value)
2474 : InstructionWithInputs(), 2489 : InstructionWithInputs(),
2475 cid_(Isolate::Current()->GetNextCid()), 2490 cid_(Isolate::Current()->GetNextCid()),
2476 token_pos_(token_pos), 2491 token_pos_(token_pos),
2477 value_(value) { 2492 value_(value) {
2478 ASSERT(value_ != NULL); 2493 ASSERT(value_ != NULL);
2479 } 2494 }
2480 2495
2481 DECLARE_INSTRUCTION(Return) 2496 DECLARE_INSTRUCTION(Return)
2482 2497
2498 virtual intptr_t ArgumentCount() const { return 0; }
2499
2483 intptr_t cid() const { return cid_; } 2500 intptr_t cid() const { return cid_; }
2484 intptr_t token_pos() const { return token_pos_; } 2501 intptr_t token_pos() const { return token_pos_; }
2485 Value* value() const { return value_; } 2502 Value* value() const { return value_; }
2486 2503
2487 virtual LocationSummary* MakeLocationSummary() const; 2504 virtual LocationSummary* MakeLocationSummary() const;
2488 2505
2489 virtual void EmitNativeCode(FlowGraphCompiler* compiler); 2506 virtual void EmitNativeCode(FlowGraphCompiler* compiler);
2490 2507
2491 virtual bool CanDeoptimize() const { return false; } 2508 virtual bool CanDeoptimize() const { return false; }
2492 2509
2493 private: 2510 private:
2494 const intptr_t cid_; // Computation/instruction id. 2511 const intptr_t cid_; // Computation/instruction id.
2495 const intptr_t token_pos_; 2512 const intptr_t token_pos_;
2496 Value* value_; 2513 Value* value_;
2497 2514
2498 DISALLOW_COPY_AND_ASSIGN(ReturnInstr); 2515 DISALLOW_COPY_AND_ASSIGN(ReturnInstr);
2499 }; 2516 };
2500 2517
2501 2518
2502 class ThrowInstr : public InstructionWithInputs { 2519 class ThrowInstr : public InstructionWithInputs {
2503 public: 2520 public:
2504 ThrowInstr(intptr_t token_pos, 2521 ThrowInstr(intptr_t token_pos, intptr_t try_index)
2505 intptr_t try_index,
2506 Value* exception)
2507 : InstructionWithInputs(), 2522 : InstructionWithInputs(),
2508 cid_(Isolate::Current()->GetNextCid()), 2523 cid_(Isolate::Current()->GetNextCid()),
2509 token_pos_(token_pos), 2524 token_pos_(token_pos),
2510 try_index_(try_index), 2525 try_index_(try_index) { }
2511 exception_(exception) {
2512 ASSERT(exception_ != NULL);
2513 }
2514 2526
2515 DECLARE_INSTRUCTION(Throw) 2527 DECLARE_CALL_INSTRUCTION(Throw)
2528
2529 virtual intptr_t ArgumentCount() const { return 1; }
2516 2530
2517 intptr_t cid() const { return cid_; } 2531 intptr_t cid() const { return cid_; }
2518 intptr_t token_pos() const { return token_pos_; } 2532 intptr_t token_pos() const { return token_pos_; }
2519 intptr_t try_index() const { return try_index_; } 2533 intptr_t try_index() const { return try_index_; }
2520 Value* exception() const { return exception_; }
2521 2534
2522 virtual LocationSummary* MakeLocationSummary() const; 2535 virtual LocationSummary* MakeLocationSummary() const;
2523 2536
2524 virtual void EmitNativeCode(FlowGraphCompiler* compiler); 2537 virtual void EmitNativeCode(FlowGraphCompiler* compiler);
2525 2538
2526 virtual bool CanDeoptimize() const { return false; } 2539 virtual bool CanDeoptimize() const { return false; }
2527 2540
2528 private: 2541 private:
2529 const intptr_t cid_; // Computation/instruction id. 2542 const intptr_t cid_; // Computation/instruction id.
2530 const intptr_t token_pos_; 2543 const intptr_t token_pos_;
2531 const intptr_t try_index_; 2544 const intptr_t try_index_;
2532 Value* exception_;
2533 2545
2534 DISALLOW_COPY_AND_ASSIGN(ThrowInstr); 2546 DISALLOW_COPY_AND_ASSIGN(ThrowInstr);
2535 }; 2547 };
2536 2548
2537 2549
2538 class ReThrowInstr : public InstructionWithInputs { 2550 class ReThrowInstr : public InstructionWithInputs {
2539 public: 2551 public:
2540 ReThrowInstr(intptr_t token_pos, 2552 ReThrowInstr(intptr_t token_pos,
2541 intptr_t try_index, 2553 intptr_t try_index)
2542 Value* exception,
2543 Value* stack_trace)
2544 : InstructionWithInputs(), 2554 : InstructionWithInputs(),
2545 cid_(Isolate::Current()->GetNextCid()), 2555 cid_(Isolate::Current()->GetNextCid()),
2546 token_pos_(token_pos), 2556 token_pos_(token_pos),
2547 try_index_(try_index), 2557 try_index_(try_index) { }
2548 exception_(exception),
2549 stack_trace_(stack_trace) {
2550 ASSERT(exception_ != NULL);
2551 ASSERT(stack_trace_ != NULL);
2552 }
2553 2558
2554 DECLARE_INSTRUCTION(ReThrow) 2559 DECLARE_CALL_INSTRUCTION(ReThrow)
2560
2561 virtual intptr_t ArgumentCount() const { return 2; }
2555 2562
2556 intptr_t cid() const { return cid_; } 2563 intptr_t cid() const { return cid_; }
2557 intptr_t token_pos() const { return token_pos_; } 2564 intptr_t token_pos() const { return token_pos_; }
2558 intptr_t try_index() const { return try_index_; } 2565 intptr_t try_index() const { return try_index_; }
2559 Value* exception() const { return exception_; }
2560 Value* stack_trace() const { return stack_trace_; }
2561 2566
2562 virtual LocationSummary* MakeLocationSummary() const; 2567 virtual LocationSummary* MakeLocationSummary() const;
2563 2568
2564 virtual void EmitNativeCode(FlowGraphCompiler* compiler); 2569 virtual void EmitNativeCode(FlowGraphCompiler* compiler);
2565 2570
2566 virtual bool CanDeoptimize() const { return false; } 2571 virtual bool CanDeoptimize() const { return false; }
2567 2572
2568 private: 2573 private:
2569 const intptr_t cid_; // Computation/instruction id. 2574 const intptr_t cid_; // Computation/instruction id.
2570 const intptr_t token_pos_; 2575 const intptr_t token_pos_;
2571 const intptr_t try_index_; 2576 const intptr_t try_index_;
2572 Value* exception_;
2573 Value* stack_trace_;
2574 2577
2575 DISALLOW_COPY_AND_ASSIGN(ReThrowInstr); 2578 DISALLOW_COPY_AND_ASSIGN(ReThrowInstr);
2576 }; 2579 };
2577 2580
2578 2581
2579 class GotoInstr : public InstructionWithInputs { 2582 class GotoInstr : public InstructionWithInputs {
2580 public: 2583 public:
2581 explicit GotoInstr(JoinEntryInstr* entry) 2584 explicit GotoInstr(JoinEntryInstr* entry)
2582 : successor_(entry), 2585 : successor_(entry),
2583 parallel_move_(NULL) { 2586 parallel_move_(NULL) {
2584 } 2587 }
2585 2588
2586 DECLARE_INSTRUCTION(Goto) 2589 DECLARE_INSTRUCTION(Goto)
2587 2590
2591 virtual intptr_t ArgumentCount() const { return 0; }
2592
2588 JoinEntryInstr* successor() const { return successor_; } 2593 JoinEntryInstr* successor() const { return successor_; }
2589 void set_successor(JoinEntryInstr* successor) { successor_ = successor; } 2594 void set_successor(JoinEntryInstr* successor) { successor_ = successor; }
2590 virtual intptr_t SuccessorCount() const; 2595 virtual intptr_t SuccessorCount() const;
2591 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const; 2596 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const;
2592 2597
2593 virtual LocationSummary* MakeLocationSummary() const; 2598 virtual LocationSummary* MakeLocationSummary() const;
2594 2599
2595 virtual void EmitNativeCode(FlowGraphCompiler* compiler); 2600 virtual void EmitNativeCode(FlowGraphCompiler* compiler);
2596 2601
2597 virtual bool CanDeoptimize() const { return false; } 2602 virtual bool CanDeoptimize() const { return false; }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2642 ASSERT(Token::IsEqualityOperator(kind) || 2647 ASSERT(Token::IsEqualityOperator(kind) ||
2643 Token::IsRelationalOperator(kind) || 2648 Token::IsRelationalOperator(kind) ||
2644 Token::IsTypeTestOperator(kind)); 2649 Token::IsTypeTestOperator(kind));
2645 Isolate* isolate = Isolate::Current(); 2650 Isolate* isolate = Isolate::Current();
2646 cid_ = isolate->GetNextCid(); 2651 cid_ = isolate->GetNextCid();
2647 ic_data_ = isolate->GetICDataForCid(cid_); 2652 ic_data_ = isolate->GetICDataForCid(cid_);
2648 } 2653 }
2649 2654
2650 DECLARE_INSTRUCTION(Branch) 2655 DECLARE_INSTRUCTION(Branch)
2651 2656
2657 virtual intptr_t ArgumentCount() const { return 0; }
2658
2652 Value* left() const { return left_; } 2659 Value* left() const { return left_; }
2653 Value* right() const { return right_; } 2660 Value* right() const { return right_; }
2654 Token::Kind kind() const { return kind_; } 2661 Token::Kind kind() const { return kind_; }
2655 void set_kind(Token::Kind kind) { 2662 void set_kind(Token::Kind kind) {
2656 ASSERT(Token::IsEqualityOperator(kind) || 2663 ASSERT(Token::IsEqualityOperator(kind) ||
2657 Token::IsRelationalOperator(kind) || 2664 Token::IsRelationalOperator(kind) ||
2658 Token::IsTypeTestOperator(kind)); 2665 Token::IsTypeTestOperator(kind));
2659 kind_ = kind; 2666 kind_ = kind;
2660 } 2667 }
2661 2668
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
2789 const GrowableArray<BlockEntryInstr*>& block_order_; 2796 const GrowableArray<BlockEntryInstr*>& block_order_;
2790 2797
2791 private: 2798 private:
2792 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 2799 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
2793 }; 2800 };
2794 2801
2795 2802
2796 } // namespace dart 2803 } // namespace dart
2797 2804
2798 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 2805 #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