Chromium Code Reviews| Index: vm/intermediate_language.h |
| =================================================================== |
| --- vm/intermediate_language.h (revision 7705) |
| +++ vm/intermediate_language.h (working copy) |
| @@ -68,6 +68,11 @@ |
| FOR_EACH_COMPUTATION(FORWARD_DECLARATION) |
| #undef FORWARD_DECLARATION |
| +// Forward declarations. |
| +class BufferFormatter; |
| +class Value; |
| + |
| + |
| class Computation : public ZoneAllocated { |
| public: |
| static const int kNoCid = -1; |
| @@ -87,11 +92,19 @@ |
| virtual void Accept(FlowGraphVisitor* visitor) = 0; |
| virtual intptr_t InputCount() const = 0; |
| + virtual Value* InputAt(intptr_t i) = 0; |
|
srdjan
2012/05/17 22:59:22
const (and in all overriden methods)
Florian Schneider
2012/05/18 00:28:38
Done.
|
| // Mutate assigned_vars to add the local variable index for all |
| // frame-allocated locals assigned to by the computation. |
| virtual void RecordAssignedVars(BitVector* assigned_vars); |
| + virtual const char* DebugName() const = 0; |
| + |
| + // Printing support. These functions are sometimes overridden for custom |
| + // formatting. Otherwise, it prints in the format "opcode(op1, op2, op3)". |
| + virtual void PrintTo(BufferFormatter* f); |
| + virtual void PrintOperandsTo(BufferFormatter* f); |
|
srdjan
2012/05/17 22:59:22
Can they both be const?
Florian Schneider
2012/05/18 00:28:38
Done.
|
| + |
| private: |
| friend class Instruction; |
| static intptr_t GetNextCid(Isolate* isolate) { |
| @@ -149,12 +162,11 @@ |
| }; |
| -class Value; |
| - |
| template<intptr_t N> |
| class TemplateComputation : public Computation { |
| public: |
| virtual intptr_t InputCount() const { return N; } |
| + virtual Value* InputAt(intptr_t i) { return inputs_[i]; } |
| protected: |
| EmbeddedArray<Value*, N> inputs_; |
| @@ -180,11 +192,13 @@ |
| // Functions defined in all concrete computation classes. |
| #define DECLARE_COMPUTATION(ShortName) \ |
| virtual void Accept(FlowGraphVisitor* visitor); \ |
| + virtual const char* DebugName() const { return #ShortName; } \ |
| // Functions defined in all concrete value classes. |
| #define DECLARE_VALUE(ShortName) \ |
| DECLARE_COMPUTATION(ShortName) \ |
| - virtual ShortName##Val* As##ShortName() { return this; } |
| + virtual ShortName##Val* As##ShortName() { return this; } \ |
| + virtual void PrintTo(BufferFormatter* f); \ |
| // Definitions and uses are mutually recursive. |
| @@ -255,7 +269,14 @@ |
| const String& dst_name() const { return dst_name_; } |
| virtual intptr_t InputCount() const; |
| + virtual Value* InputAt(intptr_t i) { |
| + if (i == 0) return value(); |
| + if (i == 1) return instantiator_type_arguments(); |
| + return NULL; |
| + } |
| + virtual void PrintOperandsTo(BufferFormatter* f); |
| + |
| private: |
| const intptr_t token_index_; |
| const intptr_t try_index_; |
| @@ -346,7 +367,12 @@ |
| Value* ArgumentAt(intptr_t index) const { return (*arguments_)[index]; } |
| virtual intptr_t InputCount() const; |
| + virtual Value* InputAt(intptr_t i) { |
| + return i == 0 ? context() : ArgumentAt(i - 1); |
| + } |
| + virtual void PrintOperandsTo(BufferFormatter* f); |
| + |
| private: |
| const ClosureCallNode& ast_node_; |
| const intptr_t try_index_; |
| @@ -387,7 +413,10 @@ |
| intptr_t checked_argument_count() const { return checked_argument_count_; } |
| virtual intptr_t InputCount() const; |
| + virtual Value* InputAt(intptr_t i) { return ArgumentAt(i); } |
| + virtual void PrintOperandsTo(BufferFormatter* f); |
| + |
| private: |
| const intptr_t token_index_; |
| const intptr_t try_index_; |
| @@ -415,6 +444,8 @@ |
| Value* left() { return inputs_[0]; } |
| Value* right() { return inputs_[1]; } |
| + virtual void PrintOperandsTo(BufferFormatter* f); |
| + |
| private: |
| const Token::Kind kind_; |
| @@ -443,6 +474,8 @@ |
| Value* left() { return inputs_[0]; } |
| Value* right() { return inputs_[1]; } |
| + virtual void PrintOperandsTo(BufferFormatter* f); |
| + |
| private: |
| const intptr_t token_index_; |
| const intptr_t try_index_; |
| @@ -479,7 +512,10 @@ |
| Value* ArgumentAt(intptr_t index) const { return (*arguments_)[index]; } |
| virtual intptr_t InputCount() const; |
| + virtual Value* InputAt(intptr_t i) { return ArgumentAt(i); } |
| + virtual void PrintOperandsTo(BufferFormatter* f); |
| + |
| private: |
| const intptr_t token_index_; |
| const intptr_t try_index_; |
| @@ -501,6 +537,8 @@ |
| const LocalVariable& local() const { return local_; } |
| intptr_t context_level() const { return context_level_; } |
| + virtual void PrintOperandsTo(BufferFormatter* f); |
| + |
| private: |
| const LocalVariable& local_; |
| const intptr_t context_level_; |
| @@ -526,6 +564,8 @@ |
| virtual void RecordAssignedVars(BitVector* assigned_vars); |
| + virtual void PrintOperandsTo(BufferFormatter* f); |
| + |
| private: |
| const LocalVariable& local_; |
| const intptr_t context_level_; |
| @@ -558,6 +598,8 @@ |
| return ast_node_.has_optional_parameters(); |
| } |
| + virtual void PrintOperandsTo(BufferFormatter* f); |
| + |
| private: |
| const NativeBodyNode& ast_node_; |
| const intptr_t try_index_; |
| @@ -580,6 +622,8 @@ |
| Value* instance() { return inputs_[0]; } |
| + virtual void PrintOperandsTo(BufferFormatter* f); |
| + |
| private: |
| const LoadInstanceFieldNode& ast_node_; |
| @@ -607,6 +651,8 @@ |
| Value* instance() { return inputs_[0]; } |
| Value* value() { return inputs_[1]; } |
| + virtual void PrintOperandsTo(BufferFormatter* f); |
| + |
| private: |
| const StoreInstanceFieldNode& ast_node_; |
| @@ -622,6 +668,8 @@ |
| const Field& field() const { return field_; } |
| + virtual void PrintOperandsTo(BufferFormatter* f); |
| + |
| private: |
| const Field& field_; |
| @@ -643,6 +691,8 @@ |
| const Field& field() const { return field_; } |
| Value* value() { return inputs_[0]; } |
| + virtual void PrintOperandsTo(BufferFormatter* f); |
| + |
| private: |
| const Field& field_; |
| @@ -789,7 +839,14 @@ |
| intptr_t try_index() const { return try_index_; } |
| virtual intptr_t InputCount() const; |
| + virtual Value* InputAt(intptr_t i) { |
| + if (i == 0) return value(); |
| + if (i == 1) return type_arguments(); |
| + return NULL; |
| + } |
| + virtual void PrintOperandsTo(BufferFormatter* f); |
| + |
| private: |
| const intptr_t token_index_; |
| const intptr_t try_index_; |
| @@ -820,7 +877,10 @@ |
| const ZoneGrowableArray<Value*>& arguments() const { return *arguments_; } |
| virtual intptr_t InputCount() const; |
| + virtual Value* InputAt(intptr_t i) { return arguments()[i]; } |
| + virtual void PrintOperandsTo(BufferFormatter* f); |
| + |
| private: |
| const ConstructorCallNode& ast_node_; |
| const intptr_t try_index_; |
| @@ -847,7 +907,10 @@ |
| const ZoneGrowableArray<Value*>& arguments() const { return *arguments_; } |
| virtual intptr_t InputCount() const; |
| + virtual Value* InputAt(intptr_t i) { return arguments()[i]; } |
| + virtual void PrintOperandsTo(BufferFormatter* f); |
| + |
| private: |
| const ConstructorCallNode& ast_node_; |
| const intptr_t try_index_; |
| @@ -883,7 +946,10 @@ |
| Value* element_type() const { return element_type_; } |
| virtual intptr_t InputCount() const; |
| + virtual Value* InputAt(intptr_t i) { return ElementAt(i); } |
| + virtual void PrintOperandsTo(BufferFormatter* f); |
| + |
| private: |
| const intptr_t token_index_; |
| const intptr_t try_index_; |
| @@ -912,7 +978,12 @@ |
| Value* type_arguments() const { return type_arguments_; } |
| virtual intptr_t InputCount() const; |
| + virtual Value* InputAt(intptr_t i) { |
| + return i == 0 ? type_arguments() : NULL; |
| + } |
| + virtual void PrintOperandsTo(BufferFormatter* f); |
| + |
| private: |
| const ClosureNode& ast_node_; |
| const intptr_t try_index_; |
| @@ -935,6 +1006,8 @@ |
| Value* value() { return inputs_[0]; } |
| intptr_t offset_in_bytes() const { return offset_in_bytes_; } |
| + virtual void PrintOperandsTo(BufferFormatter* f); |
| + |
| private: |
| const intptr_t offset_in_bytes_; |
| @@ -957,6 +1030,8 @@ |
| Value* value() { return inputs_[1]; } |
| intptr_t offset_in_bytes() const { return offset_in_bytes_; } |
| + virtual void PrintOperandsTo(BufferFormatter* f); |
| + |
| private: |
| const intptr_t offset_in_bytes_; |
| @@ -986,6 +1061,8 @@ |
| intptr_t token_index() const { return token_index_; } |
| intptr_t try_index() const { return try_index_; } |
| + virtual void PrintOperandsTo(BufferFormatter* f); |
| + |
| private: |
| const intptr_t token_index_; |
| const intptr_t try_index_; |
| @@ -1018,6 +1095,8 @@ |
| intptr_t token_index() const { return token_index_; } |
| intptr_t try_index() const { return try_index_; } |
| + virtual void PrintOperandsTo(BufferFormatter* f); |
| + |
| private: |
| const intptr_t token_index_; |
| const intptr_t try_index_; |
| @@ -1067,6 +1146,8 @@ |
| intptr_t try_index() const { return try_index_; } |
| intptr_t num_context_variables() const { return num_context_variables_; } |
| + virtual void PrintOperandsTo(BufferFormatter* f); |
| + |
| private: |
| const intptr_t token_index_; |
| const intptr_t try_index_; |
| @@ -1128,6 +1209,8 @@ |
| DECLARE_COMPUTATION(CatchEntry) |
| + virtual void PrintOperandsTo(BufferFormatter* f); |
| + |
| private: |
| const LocalVariable& exception_var_; |
| const LocalVariable& stacktrace_var_; |
| @@ -1165,6 +1248,8 @@ |
| // Forward declarations for Instruction classes. |
| class BlockEntryInstr; |
| +class FlowGraphBuilder; |
| + |
| #define FORWARD_DECLARATION(type) class type##Instr; |
| FOR_EACH_INSTRUCTION(FORWARD_DECLARATION) |
| #undef FORWARD_DECLARATION |
| @@ -1176,6 +1261,8 @@ |
| virtual bool Is##type() const { return true; } \ |
| virtual type##Instr* As##type() { return this; } \ |
| virtual intptr_t InputCount() const; \ |
| + virtual const char* DebugName() const { return #type; } \ |
| + virtual void PrintTo(BufferFormatter* f); |
| class Instruction : public ZoneAllocated { |
| @@ -1224,8 +1311,7 @@ |
| // instruction in the block is recorded in each entry instruction. |
| virtual void DiscoverBlocks( |
| BlockEntryInstr* current_block, |
| - GrowableArray<BlockEntryInstr*>* preorder, |
| - GrowableArray<BlockEntryInstr*>* postorder, |
| + FlowGraphBuilder* builder, |
| GrowableArray<intptr_t>* parent, |
| GrowableArray<BitVector*>* assigned_vars, |
| intptr_t variable_count) { |
| @@ -1237,6 +1323,9 @@ |
| // frame-allocated locals assigned to by the instruction. |
| virtual void RecordAssignedVars(BitVector* assigned_vars); |
| + // Printing support. |
| + virtual void PrintTo(BufferFormatter* f) = 0; |
| + |
| #define INSTRUCTION_TYPE_CHECK(type) \ |
| virtual bool Is##type() const { return false; } \ |
| virtual type##Instr* As##type() { return NULL; } |
| @@ -1269,6 +1358,9 @@ |
| intptr_t postorder_number() const { return postorder_number_; } |
| void set_postorder_number(intptr_t number) { postorder_number_ = number; } |
| + intptr_t block_id() const { return block_id_; } |
| + void set_block_id(intptr_t number) { block_id_ = number; } |
|
srdjan
2012/05/17 22:59:22
intptr_t value
Florian Schneider
2012/05/18 00:28:38
Done.
|
| + |
| BlockEntryInstr* dominator() const { return dominator_; } |
| void set_dominator(BlockEntryInstr* instr) { dominator_ = instr; } |
| @@ -1277,8 +1369,7 @@ |
| virtual void DiscoverBlocks( |
| BlockEntryInstr* current_block, |
| - GrowableArray<BlockEntryInstr*>* preorder, |
| - GrowableArray<BlockEntryInstr*>* postorder, |
| + FlowGraphBuilder* builder, |
|
srdjan
2012/05/17 22:59:22
It seems that you can revert this change and pass
Florian Schneider
2012/05/18 00:28:38
Done.
|
| GrowableArray<intptr_t>* parent, |
| GrowableArray<BitVector*>* assigned_vars, |
| intptr_t variable_count); |
| @@ -1287,12 +1378,14 @@ |
| BlockEntryInstr() |
| : preorder_number_(-1), |
| postorder_number_(-1), |
| + block_id_(-1), |
| dominator_(NULL), |
| last_instruction_(NULL) { } |
| private: |
| intptr_t preorder_number_; |
| intptr_t postorder_number_; |
| + intptr_t block_id_; |
| BlockEntryInstr* dominator_; // Immediate dominator, NULL for graph entry. |
| Instruction* last_instruction_; |
| @@ -1319,8 +1412,7 @@ |
| virtual void DiscoverBlocks( |
| BlockEntryInstr* current_block, |
| - GrowableArray<BlockEntryInstr*>* preorder, |
| - GrowableArray<BlockEntryInstr*>* postorder, |
| + FlowGraphBuilder* builder, |
| GrowableArray<intptr_t>* parent, |
| GrowableArray<BitVector*>* assigned_vars, |
| intptr_t variable_count); |
| @@ -1614,8 +1706,7 @@ |
| virtual void DiscoverBlocks( |
| BlockEntryInstr* current_block, |
| - GrowableArray<BlockEntryInstr*>* preorder, |
| - GrowableArray<BlockEntryInstr*>* postorder, |
| + FlowGraphBuilder* builder, |
| GrowableArray<intptr_t>* parent, |
| GrowableArray<BitVector*>* assigned_vars, |
| intptr_t variable_count); |