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

Side by Side Diff: runtime/vm/flow_graph_compiler_x64.h

Issue 9623005: Implement branching control flow in the non-optimizing graph compiler. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 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
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_FLOW_GRAPH_COMPILER_X64_H_ 5 #ifndef VM_FLOW_GRAPH_COMPILER_X64_H_
6 #define VM_FLOW_GRAPH_COMPILER_X64_H_ 6 #define VM_FLOW_GRAPH_COMPILER_X64_H_
7 7
8 #ifndef VM_FLOW_GRAPH_COMPILER_H_ 8 #ifndef VM_FLOW_GRAPH_COMPILER_H_
9 #error Include flow_graph_compiler.h instead of flow_graph_compiler_x64.h. 9 #error Include flow_graph_compiler.h instead of flow_graph_compiler_x64.h.
10 #endif 10 #endif
11 11
12 #include "vm/assembler.h" 12 #include "vm/assembler.h"
13 #include "vm/code_generator.h" 13 #include "vm/code_generator.h"
14 #include "vm/intermediate_language.h" 14 #include "vm/intermediate_language.h"
15 15
16 namespace dart { 16 namespace dart {
17 17
18 class Code; 18 class Code;
19 template <typename T> class GrowableArray; 19 template <typename T> class GrowableArray;
20 class ParsedFunction; 20 class ParsedFunction;
21 21
22 class FlowGraphCompiler : public FlowGraphVisitor { 22 class FlowGraphCompiler : public FlowGraphVisitor {
23 public: 23 public:
srdjan 2012/03/07 22:23:06 Maybe write (again) that blocks are in reversed or
24 FlowGraphCompiler(Assembler* assembler, 24 FlowGraphCompiler(Assembler* assembler,
25 const ParsedFunction& parsed_function, 25 const ParsedFunction& parsed_function,
26 const GrowableArray<BlockEntryInstr*>* blocks) 26 const GrowableArray<BlockEntryInstr*>* blocks);
27 : assembler_(assembler),
28 parsed_function_(parsed_function),
29 blocks_(blocks),
30 pc_descriptors_list_(new CodeGenerator::DescriptorList()),
31 stack_local_count_(0) { }
32 27
33 virtual ~FlowGraphCompiler() { } 28 virtual ~FlowGraphCompiler() { }
34 29
35 void CompileGraph(); 30 void CompileGraph();
36 31
37 // Infrastructure copied from class CodeGenerator or stubbed out. 32 // Infrastructure copied from class CodeGenerator or stubbed out.
38 void FinalizePcDescriptors(const Code& code); 33 void FinalizePcDescriptors(const Code& code);
39 void FinalizeVarDescriptors(const Code& code); 34 void FinalizeVarDescriptors(const Code& code);
40 void FinalizeExceptionHandlers(const Code& code); 35 void FinalizeExceptionHandlers(const Code& code);
41 36
42 private: 37 private:
38 struct BlockInfo : public ZoneAllocated {
39 public:
40 BlockInfo() : label() { }
41
42 Label label;
43 };
srdjan 2012/03/07 22:23:06 ZoneAllocated objects have their destructor never
Kevin Millikin (Google) 2012/03/08 09:59:53 I know, and I'm not certain this is best. Label h
44
43 int stack_local_count() const { return stack_local_count_; } 45 int stack_local_count() const { return stack_local_count_; }
44 void set_stack_local_count(int count) { stack_local_count_ = count; } 46 void set_stack_local_count(int count) { stack_local_count_ = count; }
47 BlockEntryInstr* current_block() const { return current_block_; }
45 48
46 // Bail out of the flow graph compiler. Does not return to the caller. 49 // Bail out of the flow graph compiler. Does not return to the caller.
47 void Bailout(const char* reason); 50 void Bailout(const char* reason);
48 51
52 virtual void VisitBlocks(const GrowableArray<BlockEntryInstr*>& blocks);
53
49 // Emit code to perform a computation, leaving its value in RAX. 54 // Emit code to perform a computation, leaving its value in RAX.
50 #define DECLARE_VISIT_COMPUTATION(ShortName, ClassName) \ 55 #define DECLARE_VISIT_COMPUTATION(ShortName, ClassName) \
51 virtual void Visit##ShortName(ClassName* comp); 56 virtual void Visit##ShortName(ClassName* comp);
52 57
53 // Each visit function compiles a type of instruction. 58 // Each visit function compiles a type of instruction.
54 #define DECLARE_VISIT_INSTRUCTION(ShortName) \ 59 #define DECLARE_VISIT_INSTRUCTION(ShortName) \
55 virtual void Visit##ShortName(ShortName##Instr* instr); 60 virtual void Visit##ShortName(ShortName##Instr* instr);
56 61
57 FOR_EACH_COMPUTATION(DECLARE_VISIT_COMPUTATION) 62 FOR_EACH_COMPUTATION(DECLARE_VISIT_COMPUTATION)
58 FOR_EACH_INSTRUCTION(DECLARE_VISIT_INSTRUCTION) 63 FOR_EACH_INSTRUCTION(DECLARE_VISIT_INSTRUCTION)
(...skipping 25 matching lines...) Expand all
84 89
85 void GenerateAssertAssignable(intptr_t node_id, 90 void GenerateAssertAssignable(intptr_t node_id,
86 intptr_t token_index, 91 intptr_t token_index,
87 const AbstractType& dst_type, 92 const AbstractType& dst_type,
88 const String& dst_name); 93 const String& dst_name);
89 94
90 Assembler* assembler_; 95 Assembler* assembler_;
91 const ParsedFunction& parsed_function_; 96 const ParsedFunction& parsed_function_;
92 const GrowableArray<BlockEntryInstr*>* blocks_; 97 const GrowableArray<BlockEntryInstr*>* blocks_;
93 98
99 // Compiler specific per-block state. Indexed by block number, so not
100 // necessarily the same order as the array of blocks.
101 GrowableArray<BlockInfo*> block_info_;
102
103 BlockEntryInstr* current_block_;
104
94 CodeGenerator::DescriptorList* pc_descriptors_list_; 105 CodeGenerator::DescriptorList* pc_descriptors_list_;
95 int stack_local_count_; 106 int stack_local_count_;
96 107
97 DISALLOW_COPY_AND_ASSIGN(FlowGraphCompiler); 108 DISALLOW_COPY_AND_ASSIGN(FlowGraphCompiler);
98 }; 109 };
99 110
100 } // namespace dart 111 } // namespace dart
101 112
102 #endif // VM_FLOW_GRAPH_COMPILER_X64_H_ 113 #endif // VM_FLOW_GRAPH_COMPILER_X64_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/flow_graph_compiler_x64.cc » ('j') | runtime/vm/flow_graph_compiler_x64.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698