Chromium Code Reviews| Index: vm/intermediate_language.h |
| =================================================================== |
| --- vm/intermediate_language.h (revision 7878) |
| +++ vm/intermediate_language.h (working copy) |
| @@ -79,7 +79,7 @@ |
| public: |
| static const int kNoCid = -1; |
| - Computation() : cid_(-1), ic_data_(NULL) { |
| + Computation() : cid_(-1), ic_data_(NULL), locs_(NULL) { |
| Isolate* isolate = Isolate::Current(); |
| cid_ = GetNextCid(isolate); |
| ic_data_ = GetICDataForCid(cid_, isolate); |
| @@ -112,17 +112,18 @@ |
| // Returns structure describing location constraints required |
| // to emit native code for this computation. |
| - virtual LocationSummary* locs() const { |
| - // TODO(vegorov): This should be pure virtual method. |
| - // However we are temporary using NULL for instructions that |
| - // were not converted to the location based code generation yet. |
| - return NULL; |
| + LocationSummary* locs() { |
| + if (locs_ == NULL) locs_ = MakeLocationSummary(); |
|
Ivan Posva
2012/05/22 23:36:07
Where are the {}s?
Florian Schneider
2012/05/23 00:02:01
Done.
|
| + return locs_; |
| } |
| - virtual void EmitNativeCode(FlowGraphCompiler* compiler) { |
| - UNIMPLEMENTED(); |
| - } |
| + // Create a location summary for this computation. |
| + // TODO(fschneider): Temporarily returns NULL for instructions |
| + // that are not yet converted to the location based code generation. |
| + virtual LocationSummary* MakeLocationSummary() const = 0; |
| + virtual void EmitNativeCode(FlowGraphCompiler* compiler) = 0; |
|
Ivan Posva
2012/05/22 23:36:07
Can this be const?
Florian Schneider
2012/05/23 00:02:01
Not yet. locs() needs to be const as well for that
|
| + |
| private: |
| friend class Instruction; |
| static intptr_t GetNextCid(Isolate* isolate) { |
| @@ -145,6 +146,7 @@ |
| intptr_t cid_; |
| ICData* ic_data_; |
| + LocationSummary* locs_; |
| DISALLOW_COPY_AND_ASSIGN(Computation); |
| }; |
| @@ -232,7 +234,9 @@ |
| #define DECLARE_COMPUTATION(ShortName) \ |
| virtual void Accept(FlowGraphVisitor* visitor); \ |
| virtual const char* DebugName() const { return #ShortName; } \ |
| - virtual RawAbstractType* StaticType() const; |
| + virtual RawAbstractType* StaticType() const; \ |
| + virtual LocationSummary* MakeLocationSummary() const; \ |
| + virtual void EmitNativeCode(FlowGraphCompiler* compiler); |
| // Functions defined in all concrete value classes. |
| #define DECLARE_VALUE(ShortName) \ |
| @@ -262,8 +266,7 @@ |
| class ConstantVal: public Value { |
| public: |
| explicit ConstantVal(const Object& value) |
| - : value_(value), |
| - location_summary_(MakeLocationSummary()) { |
| + : value_(value) { |
| ASSERT(value.IsZoneHandle()); |
| } |
| @@ -271,18 +274,8 @@ |
| const Object& value() const { return value_; } |
| - virtual LocationSummary* locs() const { |
| - return location_summary_; |
| - } |
| - |
| - // Platform specific summary factory for this instruction. |
| - LocationSummary* MakeLocationSummary(); |
| - |
| - virtual void EmitNativeCode(FlowGraphCompiler* compiler); |
| - |
| private: |
| const Object& value_; |
| - LocationSummary* location_summary_; |
| DISALLOW_COPY_AND_ASSIGN(ConstantVal); |
| }; |
| @@ -374,46 +367,27 @@ |
| // a computation, not a value, because it's mutable. |
| class CurrentContextComp : public TemplateComputation<0> { |
| public: |
| - CurrentContextComp() : location_summary_(MakeLocationSummary()) { } |
| + CurrentContextComp() { } |
| DECLARE_COMPUTATION(CurrentContext) |
| - virtual LocationSummary* locs() const { |
| - return location_summary_; |
| - } |
| - |
| - static LocationSummary* MakeLocationSummary(); |
| - |
| - virtual void EmitNativeCode(FlowGraphCompiler* compiler); |
| - |
| private: |
| - LocationSummary* location_summary_; |
| DISALLOW_COPY_AND_ASSIGN(CurrentContextComp); |
| }; |
| class StoreContextComp : public TemplateComputation<1> { |
| public: |
| - explicit StoreContextComp(Value* value) |
| - : location_summary_(MakeLocationSummary()) { |
| + explicit StoreContextComp(Value* value) { |
| ASSERT(value != NULL); |
| inputs_[0] = value; |
| } |
| DECLARE_COMPUTATION(StoreContext); |
| - virtual LocationSummary* locs() const { |
| - return location_summary_; |
| - } |
| - |
| - static LocationSummary* MakeLocationSummary(); |
| - |
| - virtual void EmitNativeCode(FlowGraphCompiler* compiler); |
| - |
| Value* value() const { return inputs_[0]; } |
| private: |
| - LocationSummary* location_summary_; |
| DISALLOW_COPY_AND_ASSIGN(StoreContextComp); |
| }; |
| @@ -425,8 +399,7 @@ |
| ZoneGrowableArray<Value*>* arguments) |
| : ast_node_(*node), |
| try_index_(try_index), |
| - arguments_(arguments), |
| - location_summary_(MakeLocationSummary()) { } |
| + arguments_(arguments) { } |
| DECLARE_COMPUTATION(ClosureCall) |
| @@ -442,20 +415,10 @@ |
| virtual void PrintOperandsTo(BufferFormatter* f) const; |
| - virtual LocationSummary* locs() const { |
| - return location_summary_; |
| - } |
| - |
| - // Platform specific summary factory for this instruction. |
| - LocationSummary* MakeLocationSummary(); |
| - |
| - virtual void EmitNativeCode(FlowGraphCompiler* compiler); |
| - |
| private: |
| const ClosureCallNode& ast_node_; |
| const intptr_t try_index_; |
| ZoneGrowableArray<Value*>* arguments_; |
| - LocationSummary* location_summary_; |
| DISALLOW_COPY_AND_ASSIGN(ClosureCallComp); |
| }; |
| @@ -474,8 +437,7 @@ |
| function_name_(function_name), |
| arguments_(arguments), |
| argument_names_(argument_names), |
| - checked_argument_count_(checked_argument_count), |
| - location_summary_(MakeLocationSummary()) { |
| + checked_argument_count_(checked_argument_count) { |
| ASSERT(function_name.IsZoneHandle()); |
| ASSERT(!arguments->is_empty()); |
| ASSERT(argument_names.IsZoneHandle()); |
| @@ -496,15 +458,6 @@ |
| virtual void PrintOperandsTo(BufferFormatter* f) const; |
| - virtual LocationSummary* locs() const { |
| - return location_summary_; |
| - } |
| - |
| - // Platform specific summary factory for this instruction. |
| - LocationSummary* MakeLocationSummary(); |
| - |
| - virtual void EmitNativeCode(FlowGraphCompiler* compiler); |
| - |
| private: |
| const intptr_t token_index_; |
| const intptr_t try_index_; |
| @@ -512,7 +465,6 @@ |
| ZoneGrowableArray<Value*>* const arguments_; |
| const Array& argument_names_; |
| const intptr_t checked_argument_count_; |
| - LocationSummary* location_summary_; |
| DISALLOW_COPY_AND_ASSIGN(InstanceCallComp); |
| }; |
| @@ -525,7 +477,6 @@ |
| ASSERT((kind_ == Token::kEQ_STRICT) || (kind_ == Token::kNE_STRICT)); |
| inputs_[0] = left; |
| inputs_[1] = right; |
| - location_summary_ = MakeLocationSummary(); |
| } |
| DECLARE_COMPUTATION(StrictCompare) |
| @@ -536,20 +487,9 @@ |
| virtual void PrintOperandsTo(BufferFormatter* f) const; |
| - virtual LocationSummary* locs() const { |
| - return location_summary_; |
| - } |
| - |
| - // Platform specific summary factory for this instruction. |
| - LocationSummary* MakeLocationSummary(); |
| - |
| - virtual void EmitNativeCode(FlowGraphCompiler* compiler); |
| - |
| private: |
| const Token::Kind kind_; |
| - LocationSummary* location_summary_; |
| - |
| DISALLOW_COPY_AND_ASSIGN(StrictCompareComp); |
| }; |
| @@ -596,8 +536,7 @@ |
| try_index_(try_index), |
| function_(function), |
| argument_names_(argument_names), |
| - arguments_(arguments), |
| - location_summary_(MakeLocationSummary()) { |
| + arguments_(arguments) { |
| ASSERT(function.IsZoneHandle()); |
| ASSERT(argument_names.IsZoneHandle()); |
| } |
| @@ -618,22 +557,12 @@ |
| virtual void PrintOperandsTo(BufferFormatter* f) const; |
| - virtual LocationSummary* locs() const { |
| - return location_summary_; |
| - } |
| - |
| - // Platform specific summary factory for this instruction. |
| - LocationSummary* MakeLocationSummary(); |
| - |
| - virtual void EmitNativeCode(FlowGraphCompiler* compiler); |
| - |
| private: |
| const intptr_t token_index_; |
| const intptr_t try_index_; |
| const Function& function_; |
| const Array& argument_names_; |
| ZoneGrowableArray<Value*>* arguments_; |
| - LocationSummary* location_summary_; |
| DISALLOW_COPY_AND_ASSIGN(StaticCallComp); |
| }; |
| @@ -643,8 +572,7 @@ |
| public: |
| LoadLocalComp(const LocalVariable& local, intptr_t context_level) |
| : local_(local), |
| - context_level_(context_level), |
| - location_summary_(MakeLocationSummary()) { } |
| + context_level_(context_level) { } |
| DECLARE_COMPUTATION(LoadLocal) |
| @@ -653,19 +581,9 @@ |
| virtual void PrintOperandsTo(BufferFormatter* f) const; |
| - virtual LocationSummary* locs() const { |
| - return location_summary_; |
| - } |
| - |
| - // Platform specific summary factory for this instruction. |
| - LocationSummary* MakeLocationSummary(); |
| - |
| - virtual void EmitNativeCode(FlowGraphCompiler* compiler); |
| - |
| private: |
| const LocalVariable& local_; |
| const intptr_t context_level_; |
| - LocationSummary* location_summary_; |
| DISALLOW_COPY_AND_ASSIGN(LoadLocalComp); |
| }; |
| @@ -677,8 +595,7 @@ |
| Value* value, |
| intptr_t context_level) |
| : local_(local), |
| - context_level_(context_level), |
| - location_summary_(MakeLocationSummary()) { |
| + context_level_(context_level) { |
| inputs_[0] = value; |
| } |
| @@ -692,19 +609,9 @@ |
| virtual void PrintOperandsTo(BufferFormatter* f) const; |
| - virtual LocationSummary* locs() const { |
| - return location_summary_; |
| - } |
| - |
| - // Platform specific summary factory for this instruction. |
| - LocationSummary* MakeLocationSummary(); |
| - |
| - virtual void EmitNativeCode(FlowGraphCompiler* compiler); |
| - |
| private: |
| const LocalVariable& local_; |
| const intptr_t context_level_; |
| - LocationSummary* location_summary_; |
| DISALLOW_COPY_AND_ASSIGN(StoreLocalComp); |
| }; |