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

Side by Side Diff: vm/intermediate_language.h

Issue 10696090: Add deoptimization environments to instructions. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 5 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') | no next file » | 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 1695 matching lines...) Expand 10 before | Expand all | Expand 10 after
1706 M(Return) \ 1706 M(Return) \
1707 M(Throw) \ 1707 M(Throw) \
1708 M(ReThrow) \ 1708 M(ReThrow) \
1709 M(Branch) \ 1709 M(Branch) \
1710 M(ParallelMove) 1710 M(ParallelMove)
1711 1711
1712 1712
1713 // Forward declarations for Instruction classes. 1713 // Forward declarations for Instruction classes.
1714 class BlockEntryInstr; 1714 class BlockEntryInstr;
1715 class FlowGraphBuilder; 1715 class FlowGraphBuilder;
1716 class Environment;
1716 1717
1717 #define FORWARD_DECLARATION(type) class type##Instr; 1718 #define FORWARD_DECLARATION(type) class type##Instr;
1718 FOR_EACH_INSTRUCTION(FORWARD_DECLARATION) 1719 FOR_EACH_INSTRUCTION(FORWARD_DECLARATION)
1719 #undef FORWARD_DECLARATION 1720 #undef FORWARD_DECLARATION
1720 1721
1721 1722
1722 // Functions required in all concrete instruction classes. 1723 // Functions required in all concrete instruction classes.
1723 #define DECLARE_INSTRUCTION(type) \ 1724 #define DECLARE_INSTRUCTION(type) \
1724 virtual Instruction* Accept(FlowGraphVisitor* visitor); \ 1725 virtual Instruction* Accept(FlowGraphVisitor* visitor); \
1725 virtual bool Is##type() const { return true; } \ 1726 virtual bool Is##type() const { return true; } \
1726 virtual type##Instr* As##type() { return this; } \ 1727 virtual type##Instr* As##type() { return this; } \
1727 virtual intptr_t InputCount() const; \ 1728 virtual intptr_t InputCount() const; \
1728 virtual Value* InputAt(intptr_t i) const; \ 1729 virtual Value* InputAt(intptr_t i) const; \
1729 virtual void SetInputAt(intptr_t i, Value* value); \ 1730 virtual void SetInputAt(intptr_t i, Value* value); \
1730 virtual const char* DebugName() const { return #type; } \ 1731 virtual const char* DebugName() const { return #type; } \
1731 virtual void PrintTo(BufferFormatter* f) const; \ 1732 virtual void PrintTo(BufferFormatter* f) const; \
1732 virtual void PrintToVisualizer(BufferFormatter* f) const; 1733 virtual void PrintToVisualizer(BufferFormatter* f) const;
1733 1734
1734 1735
1735 class Instruction : public ZoneAllocated { 1736 class Instruction : public ZoneAllocated {
1736 public: 1737 public:
1737 Instruction() : cid_(-1), ic_data_(NULL), successor_(NULL), previous_(NULL) { 1738 Instruction()
1739 : cid_(-1),
1740 ic_data_(NULL),
1741 successor_(NULL),
1742 previous_(NULL),
1743 env_(NULL) {
1738 Isolate* isolate = Isolate::Current(); 1744 Isolate* isolate = Isolate::Current();
1739 cid_ = Computation::GetNextCid(isolate); 1745 cid_ = Computation::GetNextCid(isolate);
1740 ic_data_ = Computation::GetICDataForCid(cid_, isolate); 1746 ic_data_ = Computation::GetICDataForCid(cid_, isolate);
1741 } 1747 }
1742 1748
1743 // Unique computation/instruction id, used for deoptimization, e.g. for 1749 // Unique computation/instruction id, used for deoptimization, e.g. for
1744 // ReturnInstr, ThrowInstr and ReThrowInstr. 1750 // ReturnInstr, ThrowInstr and ReThrowInstr.
1745 intptr_t cid() const { return cid_; } 1751 intptr_t cid() const { return cid_; }
1746 1752
1747 const ICData* ic_data() const { return ic_data_; } 1753 const ICData* ic_data() const { return ic_data_; }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1842 // TODO(vegorov): This should be pure virtual method. 1848 // TODO(vegorov): This should be pure virtual method.
1843 // However we are temporary using NULL for instructions that 1849 // However we are temporary using NULL for instructions that
1844 // were not converted to the location based code generation yet. 1850 // were not converted to the location based code generation yet.
1845 return NULL; 1851 return NULL;
1846 } 1852 }
1847 1853
1848 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { 1854 virtual void EmitNativeCode(FlowGraphCompiler* compiler) {
1849 UNIMPLEMENTED(); 1855 UNIMPLEMENTED();
1850 } 1856 }
1851 1857
1858 Environment* env() const { return env_; }
1859 void set_env(Environment* env) { env_ = env; }
1860
1852 private: 1861 private:
1853 intptr_t cid_; 1862 intptr_t cid_;
1854 ICData* ic_data_; 1863 ICData* ic_data_;
1855 Instruction* successor_; 1864 Instruction* successor_;
1856 Instruction* previous_; 1865 Instruction* previous_;
1866 Environment* env_;
1857 DISALLOW_COPY_AND_ASSIGN(Instruction); 1867 DISALLOW_COPY_AND_ASSIGN(Instruction);
1858 }; 1868 };
1859 1869
1860 1870
1861 class InstructionWithInputs : public Instruction { 1871 class InstructionWithInputs : public Instruction {
1862 public: 1872 public:
1863 InstructionWithInputs() : locs_(NULL) { 1873 InstructionWithInputs() : locs_(NULL) {
1864 } 1874 }
1865 1875
1866 virtual LocationSummary* locs() { 1876 virtual LocationSummary* locs() {
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
2353 2363
2354 private: 2364 private:
2355 GrowableArray<MoveOperands> moves_; 2365 GrowableArray<MoveOperands> moves_;
2356 2366
2357 DISALLOW_COPY_AND_ASSIGN(ParallelMoveInstr); 2367 DISALLOW_COPY_AND_ASSIGN(ParallelMoveInstr);
2358 }; 2368 };
2359 2369
2360 #undef DECLARE_INSTRUCTION 2370 #undef DECLARE_INSTRUCTION
2361 2371
2362 2372
2373 class Environment : public ZoneAllocated {
2374 public:
2375 // Construct an environment by copying from an array of values.
2376 explicit Environment(ZoneGrowableArray<Value*>* values)
2377 : values_(values->length()) {
2378 values_.AddArray(*values);
2379 }
2380
2381 const ZoneGrowableArray<Value*>& values() const {
2382 return values_;
2383 }
2384
2385 void PrintTo(BufferFormatter* f) const;
2386
2387 private:
2388 ZoneGrowableArray<Value*> values_;
2389 DISALLOW_COPY_AND_ASSIGN(Environment);
2390 };
2391
2392
2363 // Visitor base class to visit each instruction and computation in a flow 2393 // Visitor base class to visit each instruction and computation in a flow
2364 // graph as defined by a reversed list of basic blocks. 2394 // graph as defined by a reversed list of basic blocks.
2365 class FlowGraphVisitor : public ValueObject { 2395 class FlowGraphVisitor : public ValueObject {
2366 public: 2396 public:
2367 explicit FlowGraphVisitor(const GrowableArray<BlockEntryInstr*>& block_order) 2397 explicit FlowGraphVisitor(const GrowableArray<BlockEntryInstr*>& block_order)
2368 : block_order_(block_order) { } 2398 : block_order_(block_order) { }
2369 virtual ~FlowGraphVisitor() { } 2399 virtual ~FlowGraphVisitor() { }
2370 2400
2371 // Visit each block in the block order, and for each block its 2401 // Visit each block in the block order, and for each block its
2372 // instructions in order from the block entry to exit. 2402 // instructions in order from the block entry to exit.
(...skipping 17 matching lines...) Expand all
2390 const GrowableArray<BlockEntryInstr*>& block_order_; 2420 const GrowableArray<BlockEntryInstr*>& block_order_;
2391 2421
2392 private: 2422 private:
2393 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 2423 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
2394 }; 2424 };
2395 2425
2396 2426
2397 } // namespace dart 2427 } // namespace dart
2398 2428
2399 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 2429 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW
« no previous file with comments | « vm/il_printer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698