| Index: vm/intermediate_language.h
|
| ===================================================================
|
| --- vm/intermediate_language.h (revision 10287)
|
| +++ vm/intermediate_language.h (working copy)
|
| @@ -310,12 +310,6 @@
|
| virtual ComputationType computation_type() const { \
|
| return Computation::k##ShortName; \
|
| } \
|
| - virtual intptr_t InputCount() const { return 0; } \
|
| - virtual Value* InputAt(intptr_t i) const { \
|
| - UNREACHABLE(); \
|
| - return NULL; \
|
| - } \
|
| - virtual void SetInputAt(intptr_t i, Value* value) { UNREACHABLE(); } \
|
| virtual const char* DebugName() const { return #ShortName; } \
|
| virtual RawAbstractType* StaticType() const; \
|
| virtual LocationSummary* MakeLocationSummary() const; \
|
| @@ -476,7 +470,7 @@
|
| };
|
|
|
|
|
| -class ClosureCallComp : public Computation {
|
| +class ClosureCallComp : public TemplateComputation<0> {
|
| public:
|
| ClosureCallComp(ClosureCallNode* node,
|
| intptr_t try_index,
|
| @@ -509,7 +503,7 @@
|
| };
|
|
|
|
|
| -class InstanceCallComp : public Computation {
|
| +class InstanceCallComp : public TemplateComputation<0> {
|
| public:
|
| InstanceCallComp(intptr_t token_pos,
|
| intptr_t try_index,
|
| @@ -565,7 +559,7 @@
|
| };
|
|
|
|
|
| -class PolymorphicInstanceCallComp : public Computation {
|
| +class PolymorphicInstanceCallComp : public TemplateComputation<0> {
|
| public:
|
| explicit PolymorphicInstanceCallComp(InstanceCallComp* comp)
|
| : instance_call_(comp) {
|
| @@ -574,13 +568,6 @@
|
|
|
| InstanceCallComp* instance_call() const { return instance_call_; }
|
|
|
| - virtual intptr_t InputCount() const { return 0; }
|
| - virtual Value* InputAt(intptr_t i) const {
|
| - UNREACHABLE();
|
| - return NULL;
|
| - }
|
| - virtual void SetInputAt(intptr_t i, Value* value) { UNREACHABLE(); }
|
| -
|
| void PrintTo(BufferFormatter* f) const;
|
|
|
| DECLARE_COMPUTATION(PolymorphicInstanceCall)
|
| @@ -707,7 +694,7 @@
|
| };
|
|
|
|
|
| -class StaticCallComp : public Computation {
|
| +class StaticCallComp : public TemplateComputation<0> {
|
| public:
|
| StaticCallComp(intptr_t token_pos,
|
| intptr_t try_index,
|
| @@ -1179,7 +1166,7 @@
|
| };
|
|
|
|
|
| -class CreateArrayComp : public Computation {
|
| +class CreateArrayComp : public TemplateComputation<1> {
|
| public:
|
| CreateArrayComp(intptr_t token_pos,
|
| intptr_t try_index,
|
| @@ -1194,17 +1181,18 @@
|
| }
|
| ASSERT(element_type != NULL);
|
| #endif
|
| + inputs_[0] = element_type;
|
| }
|
|
|
| DECLARE_CALL_COMPUTATION(CreateArray)
|
|
|
| - virtual intptr_t ArgumentCount() const { return ElementCount() + 1; }
|
| + virtual intptr_t ArgumentCount() const { return ElementCount(); }
|
|
|
| intptr_t token_pos() const { return token_pos_; }
|
| intptr_t try_index() const { return try_index_; }
|
| intptr_t ElementCount() const { return elements_->length(); }
|
| Value* ElementAt(intptr_t i) const { return (*elements_)[i]; }
|
| - Value* element_type() const { return element_type_; }
|
| + Value* element_type() const { return inputs_[0]; }
|
|
|
| virtual void PrintOperandsTo(BufferFormatter* f) const;
|
|
|
| @@ -1214,13 +1202,12 @@
|
| const intptr_t token_pos_;
|
| const intptr_t try_index_;
|
| ZoneGrowableArray<Value*>* const elements_;
|
| - Value* element_type_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(CreateArrayComp);
|
| };
|
|
|
|
|
| -class CreateClosureComp : public Computation {
|
| +class CreateClosureComp : public TemplateComputation<0> {
|
| public:
|
| CreateClosureComp(ClosureNode* node,
|
| intptr_t try_index,
|
| @@ -1561,7 +1548,7 @@
|
| };
|
|
|
|
|
| -class DoubleBinaryOpComp : public Computation {
|
| +class DoubleBinaryOpComp : public TemplateComputation<0> {
|
| public:
|
| DoubleBinaryOpComp(Token::Kind op_kind, InstanceCallComp* instance_call)
|
| : op_kind_(op_kind), instance_call_(instance_call) { }
|
| @@ -1746,29 +1733,11 @@
|
| virtual void Accept(FlowGraphVisitor* visitor); \
|
| virtual bool Is##type() const { return true; } \
|
| virtual type##Instr* As##type() { return this; } \
|
| - virtual intptr_t InputCount() const; \
|
| - virtual Value* InputAt(intptr_t i) const; \
|
| - virtual void SetInputAt(intptr_t i, Value* value); \
|
| virtual const char* DebugName() const { return #type; } \
|
| virtual void PrintTo(BufferFormatter* f) const; \
|
| virtual void PrintToVisualizer(BufferFormatter* f) const;
|
|
|
|
|
| -#define DECLARE_CALL_INSTRUCTION(type) \
|
| - virtual void Accept(FlowGraphVisitor* visitor); \
|
| - virtual bool Is##type() const { return true; } \
|
| - virtual type##Instr* As##type() { return this; } \
|
| - virtual intptr_t InputCount() const { return 0; } \
|
| - virtual Value* InputAt(intptr_t i) const { \
|
| - UNREACHABLE(); \
|
| - return NULL; \
|
| - } \
|
| - virtual void SetInputAt(intptr_t i, Value* value) { UNREACHABLE(); } \
|
| - virtual const char* DebugName() const { return #type; } \
|
| - virtual void PrintTo(BufferFormatter* f) const; \
|
| - virtual void PrintToVisualizer(BufferFormatter* f) const;
|
| -
|
| -
|
| class Instruction : public ZoneAllocated {
|
| public:
|
| Instruction()
|
| @@ -1896,10 +1865,15 @@
|
| };
|
|
|
|
|
| -class InstructionWithInputs : public Instruction {
|
| +template<intptr_t N>
|
| +class TemplateInstruction: public Instruction {
|
| public:
|
| - InstructionWithInputs() : locs_(NULL) { }
|
| + TemplateInstruction<N>() : locs_(NULL) { }
|
|
|
| + virtual intptr_t InputCount() const { return N; }
|
| + virtual Value* InputAt(intptr_t i) const { return inputs_[i]; }
|
| + virtual void SetInputAt(intptr_t i, Value* value) { inputs_[i] = value; }
|
| +
|
| virtual LocationSummary* locs() {
|
| if (locs_ == NULL) {
|
| locs_ = MakeLocationSummary();
|
| @@ -1909,9 +1883,11 @@
|
|
|
| virtual LocationSummary* MakeLocationSummary() const = 0;
|
|
|
| + protected:
|
| + EmbeddedArray<Value*, N> inputs_;
|
| +
|
| private:
|
| LocationSummary* locs_;
|
| - DISALLOW_COPY_AND_ASSIGN(InstructionWithInputs);
|
| };
|
|
|
|
|
| @@ -1973,7 +1949,7 @@
|
| };
|
|
|
|
|
| -class ParallelMoveInstr : public Instruction {
|
| +class ParallelMoveInstr : public TemplateInstruction<0> {
|
| public:
|
| ParallelMoveInstr() : moves_(4) { }
|
|
|
| @@ -1996,6 +1972,10 @@
|
|
|
| intptr_t NumMoves() const { return moves_.length(); }
|
|
|
| + LocationSummary* MakeLocationSummary() const { return NULL; }
|
| +
|
| + void EmitNativeCode(FlowGraphCompiler* compiler) { UNREACHABLE(); }
|
| +
|
| private:
|
| GrowableArray<MoveOperands*> moves_; // Elements cannot be null.
|
|
|
| @@ -2069,6 +2049,13 @@
|
| intptr_t variable_count,
|
| intptr_t fixed_parameter_count);
|
|
|
| + virtual intptr_t InputCount() const { return 0; }
|
| + virtual Value* InputAt(intptr_t i) const {
|
| + UNREACHABLE();
|
| + return NULL;
|
| + }
|
| + virtual void SetInputAt(intptr_t i, Value* value) { UNREACHABLE(); }
|
| +
|
| virtual intptr_t ArgumentCount() const { return 0; }
|
|
|
| virtual bool CanDeoptimize() const { return false; }
|
| @@ -2339,7 +2326,14 @@
|
| virtual intptr_t ArgumentCount() const {
|
| return computation()->ArgumentCount();
|
| }
|
| + intptr_t InputCount() const { return computation()->InputCount(); }
|
|
|
| + Value* InputAt(intptr_t i) const { return computation()->InputAt(i); }
|
| +
|
| + void SetInputAt(intptr_t i, Value* value) {
|
| + computation()->SetInputAt(i, value);
|
| + }
|
| +
|
| virtual bool CanDeoptimize() const { return computation()->CanDeoptimize(); }
|
|
|
| Computation* computation() const { return computation_; }
|
| @@ -2381,6 +2375,12 @@
|
|
|
| virtual intptr_t ArgumentCount() const { return 0; }
|
|
|
| + intptr_t InputCount() const { return inputs_.length(); }
|
| +
|
| + Value* InputAt(intptr_t i) const { return inputs_[i]; }
|
| +
|
| + void SetInputAt(intptr_t i, Value* value) { inputs_[i] = value; }
|
| +
|
| virtual bool CanDeoptimize() const { return false; }
|
|
|
| DECLARE_INSTRUCTION(Phi)
|
| @@ -2405,6 +2405,14 @@
|
|
|
| virtual intptr_t ArgumentCount() const { return 0; }
|
|
|
| + intptr_t InputCount() const { return 0; }
|
| + Value* InputAt(intptr_t i) const {
|
| + UNREACHABLE();
|
| + return NULL;
|
| + }
|
| + void SetInputAt(intptr_t i, Value* value) { UNREACHABLE(); }
|
| +
|
| +
|
| virtual bool CanDeoptimize() const { return false; }
|
|
|
| private:
|
| @@ -2414,15 +2422,18 @@
|
| };
|
|
|
|
|
| -class PushArgumentInstr : public InstructionWithInputs {
|
| +class PushArgumentInstr : public TemplateInstruction<1> {
|
| public:
|
| - explicit PushArgumentInstr(Value* value) : value_(value) { }
|
| + explicit PushArgumentInstr(Value* value) {
|
| + ASSERT(value != NULL);
|
| + inputs_[0] = value;
|
| + }
|
|
|
| DECLARE_INSTRUCTION(PushArgument)
|
|
|
| virtual intptr_t ArgumentCount() const { return 0; }
|
|
|
| - Value* value() const { return value_; }
|
| + Value* value() const { return inputs_[0]; }
|
|
|
| virtual LocationSummary* MakeLocationSummary() const;
|
|
|
| @@ -2431,20 +2442,17 @@
|
| virtual bool CanDeoptimize() const { return false; }
|
|
|
| private:
|
| - Value* value_;
|
| -
|
| DISALLOW_COPY_AND_ASSIGN(PushArgumentInstr);
|
| };
|
|
|
|
|
| -class ReturnInstr : public InstructionWithInputs {
|
| +class ReturnInstr : public TemplateInstruction<1> {
|
| public:
|
| ReturnInstr(intptr_t token_pos, Value* value)
|
| - : InstructionWithInputs(),
|
| - cid_(Isolate::Current()->GetNextCid()),
|
| - token_pos_(token_pos),
|
| - value_(value) {
|
| - ASSERT(value_ != NULL);
|
| + : cid_(Isolate::Current()->GetNextCid()),
|
| + token_pos_(token_pos) {
|
| + ASSERT(value != NULL);
|
| + inputs_[0] = value;
|
| }
|
|
|
| DECLARE_INSTRUCTION(Return)
|
| @@ -2453,7 +2461,7 @@
|
|
|
| intptr_t cid() const { return cid_; }
|
| intptr_t token_pos() const { return token_pos_; }
|
| - Value* value() const { return value_; }
|
| + Value* value() const { return inputs_[0]; }
|
|
|
| virtual LocationSummary* MakeLocationSummary() const;
|
|
|
| @@ -2464,21 +2472,19 @@
|
| private:
|
| const intptr_t cid_; // Computation/instruction id.
|
| const intptr_t token_pos_;
|
| - Value* value_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(ReturnInstr);
|
| };
|
|
|
|
|
| -class ThrowInstr : public InstructionWithInputs {
|
| +class ThrowInstr : public TemplateInstruction<0> {
|
| public:
|
| ThrowInstr(intptr_t token_pos, intptr_t try_index)
|
| - : InstructionWithInputs(),
|
| - cid_(Isolate::Current()->GetNextCid()),
|
| + : cid_(Isolate::Current()->GetNextCid()),
|
| token_pos_(token_pos),
|
| try_index_(try_index) { }
|
|
|
| - DECLARE_CALL_INSTRUCTION(Throw)
|
| + DECLARE_INSTRUCTION(Throw)
|
|
|
| virtual intptr_t ArgumentCount() const { return 1; }
|
|
|
| @@ -2501,16 +2507,15 @@
|
| };
|
|
|
|
|
| -class ReThrowInstr : public InstructionWithInputs {
|
| +class ReThrowInstr : public TemplateInstruction<0> {
|
| public:
|
| ReThrowInstr(intptr_t token_pos,
|
| intptr_t try_index)
|
| - : InstructionWithInputs(),
|
| - cid_(Isolate::Current()->GetNextCid()),
|
| + : cid_(Isolate::Current()->GetNextCid()),
|
| token_pos_(token_pos),
|
| try_index_(try_index) { }
|
|
|
| - DECLARE_CALL_INSTRUCTION(ReThrow)
|
| + DECLARE_INSTRUCTION(ReThrow)
|
|
|
| virtual intptr_t ArgumentCount() const { return 2; }
|
|
|
| @@ -2533,12 +2538,11 @@
|
| };
|
|
|
|
|
| -class GotoInstr : public InstructionWithInputs {
|
| +class GotoInstr : public TemplateInstruction<0> {
|
| public:
|
| explicit GotoInstr(JoinEntryInstr* entry)
|
| : successor_(entry),
|
| - parallel_move_(NULL) {
|
| - }
|
| + parallel_move_(NULL) { }
|
|
|
| DECLARE_INSTRUCTION(Goto)
|
|
|
| @@ -2579,25 +2583,24 @@
|
| };
|
|
|
|
|
| -class BranchInstr : public InstructionWithInputs {
|
| +class BranchInstr : public TemplateInstruction<2> {
|
| public:
|
| BranchInstr(intptr_t token_pos,
|
| intptr_t try_index,
|
| Value* left,
|
| Value* right,
|
| Token::Kind kind)
|
| - : InstructionWithInputs(),
|
| - cid_(Computation::kNoCid),
|
| + : cid_(Computation::kNoCid),
|
| ic_data_(NULL),
|
| token_pos_(token_pos),
|
| try_index_(try_index),
|
| - left_(left),
|
| - right_(right),
|
| kind_(kind),
|
| true_successor_(NULL),
|
| false_successor_(NULL) {
|
| - ASSERT(left_ != NULL);
|
| - ASSERT(right_ != NULL);
|
| + ASSERT(left != NULL);
|
| + ASSERT(right != NULL);
|
| + inputs_[0] = left;
|
| + inputs_[1] = right;
|
| ASSERT(Token::IsEqualityOperator(kind) ||
|
| Token::IsRelationalOperator(kind) ||
|
| Token::IsTypeTestOperator(kind));
|
| @@ -2610,8 +2613,8 @@
|
|
|
| virtual intptr_t ArgumentCount() const { return 0; }
|
|
|
| - Value* left() const { return left_; }
|
| - Value* right() const { return right_; }
|
| + Value* left() const { return inputs_[0]; }
|
| + Value* right() const { return inputs_[1]; }
|
| Token::Kind kind() const { return kind_; }
|
| void set_kind(Token::Kind kind) {
|
| ASSERT(Token::IsEqualityOperator(kind) ||
|
| @@ -2662,8 +2665,6 @@
|
| ICData* ic_data_;
|
| const intptr_t token_pos_;
|
| const intptr_t try_index_;
|
| - Value* left_;
|
| - Value* right_;
|
| Token::Kind kind_;
|
| TargetEntryInstr* true_successor_;
|
| TargetEntryInstr* false_successor_;
|
|
|