Index: vm/intermediate_language.h |
=================================================================== |
--- vm/intermediate_language.h (revision 9281) |
+++ vm/intermediate_language.h (working copy) |
@@ -328,7 +328,7 @@ |
DECLARE_VALUE(Use) |
- Definition* definition() const { return definition_; } |
+ inline Definition* definition() const; |
void set_definition(Definition* definition) { |
definition_ = definition; |
} |
@@ -1734,7 +1734,7 @@ |
class Instruction : public ZoneAllocated { |
public: |
- Instruction() : cid_(-1), ic_data_(NULL) { |
+ Instruction() : cid_(-1), ic_data_(NULL), successor_(NULL), previous_(NULL) { |
Isolate* isolate = Isolate::Current(); |
cid_ = Computation::GetNextCid(isolate); |
ic_data_ = Computation::GetICDataForCid(cid_, isolate); |
@@ -1760,9 +1760,30 @@ |
// Visiting support. |
virtual Instruction* Accept(FlowGraphVisitor* visitor) = 0; |
- virtual Instruction* StraightLineSuccessor() const = 0; |
- virtual void SetSuccessor(Instruction* instr) = 0; |
+ Instruction* successor() const { return successor_; } |
+ void set_successor(Instruction* instr) { |
+ ASSERT(!IsGraphEntry()); |
+ ASSERT(!IsReturn()); |
+ ASSERT(!IsBranch()); |
+ ASSERT(!IsPhi()); |
+ // TODO(fschneider): Also add Throw and ReThrow to the list of instructions |
+ // that do not have a successor. Currently, the graph builder will continue |
+ // to append instruction in case of a Throw inside an expression. This |
+ // condition should be handled in the graph builder |
+ successor_ = instr; |
+ } |
+ Instruction* previous() const { return previous_; } |
+ void set_previous(Instruction* instr) { |
+ ASSERT(!IsBlockEntry()); |
+ previous_ = instr; |
+ } |
+ |
+ bool is_linked() const; |
+ |
+ // Remove instruction from the graph. |
+ void RemoveFromGraph(); |
+ |
// Normal instructions can have 0 (inside a block) or 1 (last instruction in |
// a block) successors. Branch instruction with >1 successors override this |
// function. |
@@ -1832,6 +1853,8 @@ |
private: |
intptr_t cid_; |
ICData* ic_data_; |
+ Instruction* successor_; |
+ Instruction* previous_; |
DISALLOW_COPY_AND_ASSIGN(Instruction); |
}; |
@@ -1940,9 +1963,6 @@ |
} |
virtual void AddPredecessor(BlockEntryInstr* predecessor) { UNREACHABLE(); } |
- virtual Instruction* StraightLineSuccessor() const { return NULL; } |
- virtual void SetSuccessor(Instruction* instr) { UNREACHABLE(); } |
- |
virtual intptr_t SuccessorCount() const; |
virtual BlockEntryInstr* SuccessorAt(intptr_t index) const; |
@@ -1975,7 +1995,6 @@ |
JoinEntryInstr() |
: BlockEntryInstr(), |
predecessors_(2), // Two is the assumed to be the common case. |
- successor_(NULL), |
phis_(NULL), |
phi_count_(0) { } |
@@ -1989,13 +2008,6 @@ |
predecessors_.Add(predecessor); |
} |
- virtual Instruction* StraightLineSuccessor() const { |
- return successor_; |
- } |
- virtual void SetSuccessor(Instruction* instr) { |
- successor_ = instr; |
- } |
- |
ZoneGrowableArray<PhiInstr*>* phis() const { return phis_; } |
virtual void PrepareEntry(FlowGraphCompiler* compiler); |
@@ -2006,7 +2018,6 @@ |
private: |
ZoneGrowableArray<BlockEntryInstr*> predecessors_; |
- Instruction* successor_; |
ZoneGrowableArray<PhiInstr*>* phis_; |
intptr_t phi_count_; |
@@ -2019,14 +2030,12 @@ |
TargetEntryInstr() |
: BlockEntryInstr(), |
predecessor_(NULL), |
- successor_(NULL), |
try_index_(CatchClauseNode::kInvalidTryIndex) { } |
// Used for exception catch entries. |
explicit TargetEntryInstr(intptr_t try_index) |
: BlockEntryInstr(), |
predecessor_(NULL), |
- successor_(NULL), |
try_index_(try_index) { } |
DECLARE_INSTRUCTION(TargetEntry) |
@@ -2043,13 +2052,6 @@ |
predecessor_ = predecessor; |
} |
- virtual Instruction* StraightLineSuccessor() const { |
- return successor_; |
- } |
- virtual void SetSuccessor(Instruction* instr) { |
- successor_ = instr; |
- } |
- |
bool HasTryIndex() const { |
return try_index_ != CatchClauseNode::kInvalidTryIndex; |
} |
@@ -2063,7 +2065,6 @@ |
private: |
BlockEntryInstr* predecessor_; |
- Instruction* successor_; |
const intptr_t try_index_; |
DISALLOW_COPY_AND_ASSIGN(TargetEntryInstr); |
@@ -2073,7 +2074,7 @@ |
class DoInstr : public Instruction { |
public: |
explicit DoInstr(Computation* computation) |
- : computation_(computation), successor_(NULL) { |
+ : computation_(computation) { |
ASSERT(computation != NULL); |
computation->set_instr(this); |
} |
@@ -2083,14 +2084,6 @@ |
Computation* computation() const { return computation_; } |
virtual void replace_computation(Computation* value) { computation_ = value; } |
- virtual Instruction* StraightLineSuccessor() const { |
- return successor_; |
- } |
- |
- virtual void SetSuccessor(Instruction* instr) { |
- successor_ = instr; |
- } |
- |
virtual void RecordAssignedVars(BitVector* assigned_vars); |
virtual LocationSummary* locs() { |
@@ -2103,7 +2096,6 @@ |
private: |
Computation* computation_; |
- Instruction* successor_; |
DISALLOW_COPY_AND_ASSIGN(DoInstr); |
}; |
@@ -2131,10 +2123,18 @@ |
}; |
+Definition* UseVal::definition() const { |
+ // Check that the definition is either a Phi or a linked in the the IR. |
+ ASSERT(definition_ != NULL); |
+ ASSERT(!definition_->IsPhi() || definition_->is_linked()); |
+ return definition_; |
+} |
+ |
+ |
class BindInstr : public Definition { |
public: |
explicit BindInstr(Computation* computation) |
- : computation_(computation), successor_(NULL) { |
+ : computation_(computation) { |
ASSERT(computation != NULL); |
computation->set_instr(this); |
} |
@@ -2144,14 +2144,6 @@ |
Computation* computation() const { return computation_; } |
virtual void replace_computation(Computation* value) { computation_ = value; } |
- virtual Instruction* StraightLineSuccessor() const { |
- return successor_; |
- } |
- |
- virtual void SetSuccessor(Instruction* instr) { |
- successor_ = instr; |
- } |
- |
// Static type of the underlying computation. |
virtual RawAbstractType* StaticType() const { |
return computation()->StaticType(); |
@@ -2167,7 +2159,6 @@ |
private: |
Computation* computation_; |
- Instruction* successor_; |
DISALLOW_COPY_AND_ASSIGN(BindInstr); |
}; |
@@ -2183,9 +2174,6 @@ |
DECLARE_INSTRUCTION(Phi) |
- virtual Instruction* StraightLineSuccessor() const { return NULL; } |
- virtual void SetSuccessor(Instruction* instr) { UNREACHABLE(); } |
- |
private: |
GrowableArray<Value*> inputs_; |
@@ -2205,9 +2193,6 @@ |
Value* value() const { return value_; } |
intptr_t token_pos() const { return token_pos_; } |
- virtual Instruction* StraightLineSuccessor() const { return NULL; } |
- virtual void SetSuccessor(Instruction* instr) { UNREACHABLE(); } |
- |
virtual LocationSummary* MakeLocationSummary() const; |
virtual void EmitNativeCode(FlowGraphCompiler* compiler); |
@@ -2228,8 +2213,7 @@ |
: InstructionWithInputs(), |
token_pos_(token_pos), |
try_index_(try_index), |
- exception_(exception), |
- successor_(NULL) { |
+ exception_(exception) { |
ASSERT(exception_ != NULL); |
} |
@@ -2239,13 +2223,6 @@ |
intptr_t try_index() const { return try_index_; } |
Value* exception() const { return exception_; } |
- // Parser can generate a throw within an expression tree. We never |
- // add successor instructions to the graph. |
- virtual Instruction* StraightLineSuccessor() const { return NULL; } |
- virtual void SetSuccessor(Instruction* instr) { |
- ASSERT(successor_ == NULL); |
- } |
- |
virtual LocationSummary* MakeLocationSummary() const; |
virtual void EmitNativeCode(FlowGraphCompiler* compiler); |
@@ -2254,7 +2231,6 @@ |
const intptr_t token_pos_; |
const intptr_t try_index_; |
Value* exception_; |
- Instruction* successor_; |
DISALLOW_COPY_AND_ASSIGN(ThrowInstr); |
}; |
@@ -2270,8 +2246,7 @@ |
token_pos_(token_pos), |
try_index_(try_index), |
exception_(exception), |
- stack_trace_(stack_trace), |
- successor_(NULL) { |
+ stack_trace_(stack_trace) { |
ASSERT(exception_ != NULL); |
ASSERT(stack_trace_ != NULL); |
} |
@@ -2283,15 +2258,6 @@ |
Value* exception() const { return exception_; } |
Value* stack_trace() const { return stack_trace_; } |
- // Parser can generate a rethrow within an expression tree. We |
- // never add successor instructions to the graph. |
- virtual Instruction* StraightLineSuccessor() const { |
- return NULL; |
- } |
- virtual void SetSuccessor(Instruction* instr) { |
- ASSERT(successor_ == NULL); |
- } |
- |
virtual LocationSummary* MakeLocationSummary() const; |
virtual void EmitNativeCode(FlowGraphCompiler* compiler); |
@@ -2301,7 +2267,6 @@ |
const intptr_t try_index_; |
Value* exception_; |
Value* stack_trace_; |
- Instruction* successor_; |
DISALLOW_COPY_AND_ASSIGN(ReThrowInstr); |
}; |
@@ -2326,9 +2291,6 @@ |
TargetEntryInstr** true_successor_address() { return &true_successor_; } |
TargetEntryInstr** false_successor_address() { return &false_successor_; } |
- virtual Instruction* StraightLineSuccessor() const { return NULL; } |
- virtual void SetSuccessor(Instruction* instr) { UNREACHABLE(); } |
- |
virtual intptr_t SuccessorCount() const; |
virtual BlockEntryInstr* SuccessorAt(intptr_t index) const; |