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

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

Issue 10538024: Implemented missing instructions in ia32, more sharing, removed bailouts, enable optimiziations on … (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 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"
11 #include "vm/handles_impl.h" 11 #include "vm/handles_impl.h"
12 #include "vm/object.h" 12 #include "vm/object.h"
13 13
14 namespace dart { 14 namespace dart {
15 15
16 class BitVector; 16 class BitVector;
17 class FlowGraphCompiler; 17 class FlowGraphCompilerShared;
18 class FlowGraphVisitor; 18 class FlowGraphVisitor;
19 class LocalVariable; 19 class LocalVariable;
20 class LocationSummary; 20 class LocationSummary;
21 21
22 // M is a two argument macro. It is applied to each concrete value's 22 // M is a two argument macro. It is applied to each concrete value's
23 // typename and classname. 23 // typename and classname.
24 #define FOR_EACH_VALUE(M) \ 24 #define FOR_EACH_VALUE(M) \
25 M(Use, UseVal) \ 25 M(Use, UseVal) \
26 M(Constant, ConstantVal) \ 26 M(Constant, ConstantVal) \
27 27
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 // it acts as a DoInstr, otherwise a BindInstr. 128 // it acts as a DoInstr, otherwise a BindInstr.
129 void set_instr(Instruction* value) { instr_ = value; } 129 void set_instr(Instruction* value) { instr_ = value; }
130 Instruction* instr() const { return instr_; } 130 Instruction* instr() const { return instr_; }
131 131
132 // Create a location summary for this computation. 132 // Create a location summary for this computation.
133 // TODO(fschneider): Temporarily returns NULL for instructions 133 // TODO(fschneider): Temporarily returns NULL for instructions
134 // that are not yet converted to the location based code generation. 134 // that are not yet converted to the location based code generation.
135 virtual LocationSummary* MakeLocationSummary() const = 0; 135 virtual LocationSummary* MakeLocationSummary() const = 0;
136 136
137 // TODO(fschneider): Make EmitNativeCode and locs const. 137 // TODO(fschneider): Make EmitNativeCode and locs const.
138 virtual void EmitNativeCode(FlowGraphCompiler* compiler) = 0; 138 virtual void EmitNativeCode(FlowGraphCompilerShared* compiler) = 0;
139 139
140 static LocationSummary* MakeCallSummary(); 140 static LocationSummary* MakeCallSummary();
141 141
142 private: 142 private:
143 friend class Instruction; 143 friend class Instruction;
144 static intptr_t GetNextCid(Isolate* isolate) { 144 static intptr_t GetNextCid(Isolate* isolate) {
145 intptr_t tmp = isolate->computation_id(); 145 intptr_t tmp = isolate->computation_id();
146 isolate->set_computation_id(tmp + 1); 146 isolate->set_computation_id(tmp + 1);
147 return tmp; 147 return tmp;
148 } 148 }
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 DISALLOW_COPY_AND_ASSIGN(Value); 247 DISALLOW_COPY_AND_ASSIGN(Value);
248 }; 248 };
249 249
250 250
251 // Functions defined in all concrete computation classes. 251 // Functions defined in all concrete computation classes.
252 #define DECLARE_COMPUTATION(ShortName) \ 252 #define DECLARE_COMPUTATION(ShortName) \
253 virtual void Accept(FlowGraphVisitor* visitor); \ 253 virtual void Accept(FlowGraphVisitor* visitor); \
254 virtual const char* DebugName() const { return #ShortName; } \ 254 virtual const char* DebugName() const { return #ShortName; } \
255 virtual RawAbstractType* StaticType() const; \ 255 virtual RawAbstractType* StaticType() const; \
256 virtual LocationSummary* MakeLocationSummary() const; \ 256 virtual LocationSummary* MakeLocationSummary() const; \
257 virtual void EmitNativeCode(FlowGraphCompiler* compiler); 257 virtual void EmitNativeCode(FlowGraphCompilerShared* compiler);
258 258
259 // Functions defined in all concrete value classes. 259 // Functions defined in all concrete value classes.
260 #define DECLARE_VALUE(ShortName) \ 260 #define DECLARE_VALUE(ShortName) \
261 DECLARE_COMPUTATION(ShortName) \ 261 DECLARE_COMPUTATION(ShortName) \
262 virtual ShortName##Val* As##ShortName() { return this; } \ 262 virtual ShortName##Val* As##ShortName() { return this; } \
263 virtual void PrintTo(BufferFormatter* f) const; 263 virtual void PrintTo(BufferFormatter* f) const;
264 264
265 265
266 class BindInstr; 266 class BindInstr;
267 267
(...skipping 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after
1493 1493
1494 // Returns structure describing location constraints required 1494 // Returns structure describing location constraints required
1495 // to emit native code for this instruction. 1495 // to emit native code for this instruction.
1496 virtual LocationSummary* locs() { 1496 virtual LocationSummary* locs() {
1497 // TODO(vegorov): This should be pure virtual method. 1497 // TODO(vegorov): This should be pure virtual method.
1498 // However we are temporary using NULL for instructions that 1498 // However we are temporary using NULL for instructions that
1499 // were not converted to the location based code generation yet. 1499 // were not converted to the location based code generation yet.
1500 return NULL; 1500 return NULL;
1501 } 1501 }
1502 1502
1503 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { 1503 virtual void EmitNativeCode(FlowGraphCompilerShared* compiler) {
1504 UNIMPLEMENTED(); 1504 UNIMPLEMENTED();
1505 } 1505 }
1506 1506
1507 private: 1507 private:
1508 intptr_t cid_; 1508 intptr_t cid_;
1509 ICData* ic_data_; 1509 ICData* ic_data_;
1510 DISALLOW_COPY_AND_ASSIGN(Instruction); 1510 DISALLOW_COPY_AND_ASSIGN(Instruction);
1511 }; 1511 };
1512 1512
1513 1513
(...skipping 22 matching lines...) Expand all
1536 // predecessors. Targets are all other basic block entries. The types 1536 // predecessors. Targets are all other basic block entries. The types
1537 // enforce edge-split form---joins are forbidden as the successors of 1537 // enforce edge-split form---joins are forbidden as the successors of
1538 // branches. 1538 // branches.
1539 class BlockEntryInstr : public Instruction { 1539 class BlockEntryInstr : public Instruction {
1540 public: 1540 public:
1541 virtual bool IsBlockEntry() const { return true; } 1541 virtual bool IsBlockEntry() const { return true; }
1542 1542
1543 virtual intptr_t PredecessorCount() const = 0; 1543 virtual intptr_t PredecessorCount() const = 0;
1544 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const = 0; 1544 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const = 0;
1545 virtual void AddPredecessor(BlockEntryInstr* predecessor) = 0; 1545 virtual void AddPredecessor(BlockEntryInstr* predecessor) = 0;
1546 virtual void PrepareEntry(FlowGraphCompiler* compiler) = 0; 1546 virtual void PrepareEntry(FlowGraphCompilerShared* compiler) = 0;
1547 1547
1548 intptr_t preorder_number() const { return preorder_number_; } 1548 intptr_t preorder_number() const { return preorder_number_; }
1549 void set_preorder_number(intptr_t number) { preorder_number_ = number; } 1549 void set_preorder_number(intptr_t number) { preorder_number_ = number; }
1550 1550
1551 intptr_t postorder_number() const { return postorder_number_; } 1551 intptr_t postorder_number() const { return postorder_number_; }
1552 void set_postorder_number(intptr_t number) { postorder_number_ = number; } 1552 void set_postorder_number(intptr_t number) { postorder_number_ = number; }
1553 1553
1554 intptr_t block_id() const { return block_id_; } 1554 intptr_t block_id() const { return block_id_; }
1555 void set_block_id(intptr_t value) { block_id_ = value; } 1555 void set_block_id(intptr_t value) { block_id_ = value; }
1556 1556
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1610 virtual void DiscoverBlocks( 1610 virtual void DiscoverBlocks(
1611 BlockEntryInstr* current_block, 1611 BlockEntryInstr* current_block,
1612 GrowableArray<BlockEntryInstr*>* preorder, 1612 GrowableArray<BlockEntryInstr*>* preorder,
1613 GrowableArray<BlockEntryInstr*>* postorder, 1613 GrowableArray<BlockEntryInstr*>* postorder,
1614 GrowableArray<intptr_t>* parent, 1614 GrowableArray<intptr_t>* parent,
1615 GrowableArray<BitVector*>* assigned_vars, 1615 GrowableArray<BitVector*>* assigned_vars,
1616 intptr_t variable_count); 1616 intptr_t variable_count);
1617 1617
1618 void AddCatchEntry(TargetEntryInstr* entry) { catch_entries_.Add(entry); } 1618 void AddCatchEntry(TargetEntryInstr* entry) { catch_entries_.Add(entry); }
1619 1619
1620 virtual void PrepareEntry(FlowGraphCompiler* compiler); 1620 virtual void PrepareEntry(FlowGraphCompilerShared* compiler);
1621 1621
1622 private: 1622 private:
1623 TargetEntryInstr* normal_entry_; 1623 TargetEntryInstr* normal_entry_;
1624 GrowableArray<TargetEntryInstr*> catch_entries_; 1624 GrowableArray<TargetEntryInstr*> catch_entries_;
1625 1625
1626 DISALLOW_COPY_AND_ASSIGN(GraphEntryInstr); 1626 DISALLOW_COPY_AND_ASSIGN(GraphEntryInstr);
1627 }; 1627 };
1628 1628
1629 1629
1630 class JoinEntryInstr : public BlockEntryInstr { 1630 class JoinEntryInstr : public BlockEntryInstr {
(...skipping 14 matching lines...) Expand all
1645 } 1645 }
1646 1646
1647 virtual Instruction* StraightLineSuccessor() const { 1647 virtual Instruction* StraightLineSuccessor() const {
1648 return successor_; 1648 return successor_;
1649 } 1649 }
1650 virtual void SetSuccessor(Instruction* instr) { 1650 virtual void SetSuccessor(Instruction* instr) {
1651 ASSERT(successor_ == NULL); 1651 ASSERT(successor_ == NULL);
1652 successor_ = instr; 1652 successor_ = instr;
1653 } 1653 }
1654 1654
1655 virtual void PrepareEntry(FlowGraphCompiler* compiler); 1655 virtual void PrepareEntry(FlowGraphCompilerShared* compiler);
1656 1656
1657 private: 1657 private:
1658 ZoneGrowableArray<BlockEntryInstr*> predecessors_; 1658 ZoneGrowableArray<BlockEntryInstr*> predecessors_;
1659 Instruction* successor_; 1659 Instruction* successor_;
1660 1660
1661 DISALLOW_COPY_AND_ASSIGN(JoinEntryInstr); 1661 DISALLOW_COPY_AND_ASSIGN(JoinEntryInstr);
1662 }; 1662 };
1663 1663
1664 1664
1665 class TargetEntryInstr : public BlockEntryInstr { 1665 class TargetEntryInstr : public BlockEntryInstr {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1701 1701
1702 bool HasTryIndex() const { 1702 bool HasTryIndex() const {
1703 return try_index_ != CatchClauseNode::kInvalidTryIndex; 1703 return try_index_ != CatchClauseNode::kInvalidTryIndex;
1704 } 1704 }
1705 1705
1706 intptr_t try_index() const { 1706 intptr_t try_index() const {
1707 ASSERT(HasTryIndex()); 1707 ASSERT(HasTryIndex());
1708 return try_index_; 1708 return try_index_;
1709 } 1709 }
1710 1710
1711 virtual void PrepareEntry(FlowGraphCompiler* compiler); 1711 virtual void PrepareEntry(FlowGraphCompilerShared* compiler);
1712 1712
1713 private: 1713 private:
1714 BlockEntryInstr* predecessor_; 1714 BlockEntryInstr* predecessor_;
1715 Instruction* successor_; 1715 Instruction* successor_;
1716 const intptr_t try_index_; 1716 const intptr_t try_index_;
1717 1717
1718 DISALLOW_COPY_AND_ASSIGN(TargetEntryInstr); 1718 DISALLOW_COPY_AND_ASSIGN(TargetEntryInstr);
1719 }; 1719 };
1720 1720
1721 1721
(...skipping 18 matching lines...) Expand all
1740 ASSERT(successor_ == NULL); 1740 ASSERT(successor_ == NULL);
1741 successor_ = instr; 1741 successor_ = instr;
1742 } 1742 }
1743 1743
1744 virtual void RecordAssignedVars(BitVector* assigned_vars); 1744 virtual void RecordAssignedVars(BitVector* assigned_vars);
1745 1745
1746 virtual LocationSummary* locs() { 1746 virtual LocationSummary* locs() {
1747 return computation()->locs(); 1747 return computation()->locs();
1748 } 1748 }
1749 1749
1750 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { 1750 virtual void EmitNativeCode(FlowGraphCompilerShared* compiler) {
1751 computation()->EmitNativeCode(compiler); 1751 computation()->EmitNativeCode(compiler);
1752 } 1752 }
1753 1753
1754 private: 1754 private:
1755 Computation* computation_; 1755 Computation* computation_;
1756 Instruction* successor_; 1756 Instruction* successor_;
1757 1757
1758 DISALLOW_COPY_AND_ASSIGN(DoInstr); 1758 DISALLOW_COPY_AND_ASSIGN(DoInstr);
1759 }; 1759 };
1760 1760
(...skipping 30 matching lines...) Expand all
1791 virtual RawAbstractType* StaticType() const { 1791 virtual RawAbstractType* StaticType() const {
1792 return computation()->StaticType(); 1792 return computation()->StaticType();
1793 } 1793 }
1794 1794
1795 virtual void RecordAssignedVars(BitVector* assigned_vars); 1795 virtual void RecordAssignedVars(BitVector* assigned_vars);
1796 1796
1797 virtual LocationSummary* locs() { 1797 virtual LocationSummary* locs() {
1798 return computation()->locs(); 1798 return computation()->locs();
1799 } 1799 }
1800 1800
1801 virtual void EmitNativeCode(FlowGraphCompiler* compiler); 1801 virtual void EmitNativeCode(FlowGraphCompilerShared* compiler);
1802 1802
1803 private: 1803 private:
1804 intptr_t temp_index_; 1804 intptr_t temp_index_;
1805 Computation* computation_; 1805 Computation* computation_;
1806 Instruction* successor_; 1806 Instruction* successor_;
1807 1807
1808 DISALLOW_COPY_AND_ASSIGN(BindInstr); 1808 DISALLOW_COPY_AND_ASSIGN(BindInstr);
1809 }; 1809 };
1810 1810
1811 1811
1812 class ReturnInstr : public InstructionWithInputs { 1812 class ReturnInstr : public InstructionWithInputs {
1813 public: 1813 public:
1814 ReturnInstr(intptr_t token_index, Value* value) 1814 ReturnInstr(intptr_t token_index, Value* value)
1815 : InstructionWithInputs(), token_index_(token_index), value_(value) { 1815 : InstructionWithInputs(), token_index_(token_index), value_(value) {
1816 ASSERT(value_ != NULL); 1816 ASSERT(value_ != NULL);
1817 } 1817 }
1818 1818
1819 DECLARE_INSTRUCTION(Return) 1819 DECLARE_INSTRUCTION(Return)
1820 1820
1821 Value* value() const { return value_; } 1821 Value* value() const { return value_; }
1822 intptr_t token_index() const { return token_index_; } 1822 intptr_t token_index() const { return token_index_; }
1823 1823
1824 virtual Instruction* StraightLineSuccessor() const { return NULL; } 1824 virtual Instruction* StraightLineSuccessor() const { return NULL; }
1825 virtual void SetSuccessor(Instruction* instr) { UNREACHABLE(); } 1825 virtual void SetSuccessor(Instruction* instr) { UNREACHABLE(); }
1826 1826
1827 virtual LocationSummary* MakeLocationSummary() const; 1827 virtual LocationSummary* MakeLocationSummary() const;
1828 1828
1829 virtual void EmitNativeCode(FlowGraphCompiler* compiler); 1829 virtual void EmitNativeCode(FlowGraphCompilerShared* compiler);
1830 1830
1831 private: 1831 private:
1832 const intptr_t token_index_; 1832 const intptr_t token_index_;
1833 Value* value_; 1833 Value* value_;
1834 1834
1835 DISALLOW_COPY_AND_ASSIGN(ReturnInstr); 1835 DISALLOW_COPY_AND_ASSIGN(ReturnInstr);
1836 }; 1836 };
1837 1837
1838 1838
1839 class ThrowInstr : public InstructionWithInputs { 1839 class ThrowInstr : public InstructionWithInputs {
(...skipping 17 matching lines...) Expand all
1857 1857
1858 // Parser can generate a throw within an expression tree. We never 1858 // Parser can generate a throw within an expression tree. We never
1859 // add successor instructions to the graph. 1859 // add successor instructions to the graph.
1860 virtual Instruction* StraightLineSuccessor() const { return NULL; } 1860 virtual Instruction* StraightLineSuccessor() const { return NULL; }
1861 virtual void SetSuccessor(Instruction* instr) { 1861 virtual void SetSuccessor(Instruction* instr) {
1862 ASSERT(successor_ == NULL); 1862 ASSERT(successor_ == NULL);
1863 } 1863 }
1864 1864
1865 virtual LocationSummary* MakeLocationSummary() const; 1865 virtual LocationSummary* MakeLocationSummary() const;
1866 1866
1867 virtual void EmitNativeCode(FlowGraphCompiler* compiler); 1867 virtual void EmitNativeCode(FlowGraphCompilerShared* compiler);
1868 1868
1869 private: 1869 private:
1870 const intptr_t token_index_; 1870 const intptr_t token_index_;
1871 const intptr_t try_index_; 1871 const intptr_t try_index_;
1872 Value* exception_; 1872 Value* exception_;
1873 Instruction* successor_; 1873 Instruction* successor_;
1874 1874
1875 DISALLOW_COPY_AND_ASSIGN(ThrowInstr); 1875 DISALLOW_COPY_AND_ASSIGN(ThrowInstr);
1876 }; 1876 };
1877 1877
(...skipping 25 matching lines...) Expand all
1903 // never add successor instructions to the graph. 1903 // never add successor instructions to the graph.
1904 virtual Instruction* StraightLineSuccessor() const { 1904 virtual Instruction* StraightLineSuccessor() const {
1905 return NULL; 1905 return NULL;
1906 } 1906 }
1907 virtual void SetSuccessor(Instruction* instr) { 1907 virtual void SetSuccessor(Instruction* instr) {
1908 ASSERT(successor_ == NULL); 1908 ASSERT(successor_ == NULL);
1909 } 1909 }
1910 1910
1911 virtual LocationSummary* MakeLocationSummary() const; 1911 virtual LocationSummary* MakeLocationSummary() const;
1912 1912
1913 virtual void EmitNativeCode(FlowGraphCompiler* compiler); 1913 virtual void EmitNativeCode(FlowGraphCompilerShared* compiler);
1914 1914
1915 private: 1915 private:
1916 const intptr_t token_index_; 1916 const intptr_t token_index_;
1917 const intptr_t try_index_; 1917 const intptr_t try_index_;
1918 Value* exception_; 1918 Value* exception_;
1919 Value* stack_trace_; 1919 Value* stack_trace_;
1920 Instruction* successor_; 1920 Instruction* successor_;
1921 1921
1922 DISALLOW_COPY_AND_ASSIGN(ReThrowInstr); 1922 DISALLOW_COPY_AND_ASSIGN(ReThrowInstr);
1923 }; 1923 };
(...skipping 25 matching lines...) Expand all
1949 virtual void DiscoverBlocks( 1949 virtual void DiscoverBlocks(
1950 BlockEntryInstr* current_block, 1950 BlockEntryInstr* current_block,
1951 GrowableArray<BlockEntryInstr*>* preorder, 1951 GrowableArray<BlockEntryInstr*>* preorder,
1952 GrowableArray<BlockEntryInstr*>* postorder, 1952 GrowableArray<BlockEntryInstr*>* postorder,
1953 GrowableArray<intptr_t>* parent, 1953 GrowableArray<intptr_t>* parent,
1954 GrowableArray<BitVector*>* assigned_vars, 1954 GrowableArray<BitVector*>* assigned_vars,
1955 intptr_t variable_count); 1955 intptr_t variable_count);
1956 1956
1957 virtual LocationSummary* MakeLocationSummary() const; 1957 virtual LocationSummary* MakeLocationSummary() const;
1958 1958
1959 virtual void EmitNativeCode(FlowGraphCompiler* compiler); 1959 virtual void EmitNativeCode(FlowGraphCompilerShared* compiler);
1960 1960
1961 private: 1961 private:
1962 Value* value_; 1962 Value* value_;
1963 TargetEntryInstr* true_successor_; 1963 TargetEntryInstr* true_successor_;
1964 TargetEntryInstr* false_successor_; 1964 TargetEntryInstr* false_successor_;
1965 1965
1966 DISALLOW_COPY_AND_ASSIGN(BranchInstr); 1966 DISALLOW_COPY_AND_ASSIGN(BranchInstr);
1967 }; 1967 };
1968 1968
1969 #undef DECLARE_INSTRUCTION 1969 #undef DECLARE_INSTRUCTION
(...skipping 29 matching lines...) Expand all
1999 const GrowableArray<BlockEntryInstr*>& block_order_; 1999 const GrowableArray<BlockEntryInstr*>& block_order_;
2000 2000
2001 private: 2001 private:
2002 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 2002 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
2003 }; 2003 };
2004 2004
2005 2005
2006 } // namespace dart 2006 } // namespace dart
2007 2007
2008 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 2008 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698