OLD | NEW |
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 RUNTIME_VM_COMPILER_H_ | 5 #ifndef RUNTIME_VM_COMPILER_H_ |
6 #define RUNTIME_VM_COMPILER_H_ | 6 #define RUNTIME_VM_COMPILER_H_ |
7 | 7 |
8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
9 #include "vm/growable_array.h" | 9 #include "vm/growable_array.h" |
10 #include "vm/runtime_entry.h" | 10 #include "vm/runtime_entry.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 public: | 33 public: |
34 static CompilationPipeline* New(Zone* zone, const Function& function); | 34 static CompilationPipeline* New(Zone* zone, const Function& function); |
35 | 35 |
36 virtual void ParseFunction(ParsedFunction* parsed_function) = 0; | 36 virtual void ParseFunction(ParsedFunction* parsed_function) = 0; |
37 virtual FlowGraph* BuildFlowGraph( | 37 virtual FlowGraph* BuildFlowGraph( |
38 Zone* zone, | 38 Zone* zone, |
39 ParsedFunction* parsed_function, | 39 ParsedFunction* parsed_function, |
40 const ZoneGrowableArray<const ICData*>& ic_data_array, | 40 const ZoneGrowableArray<const ICData*>& ic_data_array, |
41 intptr_t osr_id) = 0; | 41 intptr_t osr_id) = 0; |
42 virtual void FinalizeCompilation(FlowGraph* flow_graph) = 0; | 42 virtual void FinalizeCompilation(FlowGraph* flow_graph) = 0; |
43 virtual ~CompilationPipeline() { } | 43 virtual ~CompilationPipeline() {} |
44 }; | 44 }; |
45 | 45 |
46 | 46 |
47 class DartCompilationPipeline : public CompilationPipeline { | 47 class DartCompilationPipeline : public CompilationPipeline { |
48 public: | 48 public: |
49 virtual void ParseFunction(ParsedFunction* parsed_function); | 49 virtual void ParseFunction(ParsedFunction* parsed_function); |
50 | 50 |
51 virtual FlowGraph* BuildFlowGraph( | 51 virtual FlowGraph* BuildFlowGraph( |
52 Zone* zone, | 52 Zone* zone, |
53 ParsedFunction* parsed_function, | 53 ParsedFunction* parsed_function, |
54 const ZoneGrowableArray<const ICData*>& ic_data_array, | 54 const ZoneGrowableArray<const ICData*>& ic_data_array, |
55 intptr_t osr_id); | 55 intptr_t osr_id); |
56 | 56 |
57 virtual void FinalizeCompilation(FlowGraph* flow_graph); | 57 virtual void FinalizeCompilation(FlowGraph* flow_graph); |
58 }; | 58 }; |
59 | 59 |
60 | 60 |
61 class IrregexpCompilationPipeline : public CompilationPipeline { | 61 class IrregexpCompilationPipeline : public CompilationPipeline { |
62 public: | 62 public: |
63 IrregexpCompilationPipeline() : backtrack_goto_(NULL) { } | 63 IrregexpCompilationPipeline() : backtrack_goto_(NULL) {} |
64 | 64 |
65 virtual void ParseFunction(ParsedFunction* parsed_function); | 65 virtual void ParseFunction(ParsedFunction* parsed_function); |
66 | 66 |
67 virtual FlowGraph* BuildFlowGraph( | 67 virtual FlowGraph* BuildFlowGraph( |
68 Zone* zone, | 68 Zone* zone, |
69 ParsedFunction* parsed_function, | 69 ParsedFunction* parsed_function, |
70 const ZoneGrowableArray<const ICData*>& ic_data_array, | 70 const ZoneGrowableArray<const ICData*>& ic_data_array, |
71 intptr_t osr_id); | 71 intptr_t osr_id); |
72 | 72 |
73 virtual void FinalizeCompilation(FlowGraph* flow_graph); | 73 virtual void FinalizeCompilation(FlowGraph* flow_graph); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 105 |
106 // Generates unoptimized code if not present, current code is unchanged. | 106 // Generates unoptimized code if not present, current code is unchanged. |
107 static RawError* EnsureUnoptimizedCode(Thread* thread, | 107 static RawError* EnsureUnoptimizedCode(Thread* thread, |
108 const Function& function); | 108 const Function& function); |
109 | 109 |
110 // Generates optimized code for function. | 110 // Generates optimized code for function. |
111 // | 111 // |
112 // Returns Error::null() if there is no compilation error. | 112 // Returns Error::null() if there is no compilation error. |
113 // If 'result_code' is not NULL, then the generated code is returned but | 113 // If 'result_code' is not NULL, then the generated code is returned but |
114 // not installed. | 114 // not installed. |
115 static RawError* CompileOptimizedFunction( | 115 static RawError* CompileOptimizedFunction(Thread* thread, |
116 Thread* thread, | 116 const Function& function, |
117 const Function& function, | 117 intptr_t osr_id = kNoOSRDeoptId); |
118 intptr_t osr_id = kNoOSRDeoptId); | |
119 | 118 |
120 // Generates code for given parsed function (without parsing it again) and | 119 // Generates code for given parsed function (without parsing it again) and |
121 // sets its code field. | 120 // sets its code field. |
122 // | 121 // |
123 // Returns Error::null() if there is no compilation error. | 122 // Returns Error::null() if there is no compilation error. |
124 static RawError* CompileParsedFunction(ParsedFunction* parsed_function); | 123 static RawError* CompileParsedFunction(ParsedFunction* parsed_function); |
125 | 124 |
126 // Generates and executes code for a given code fragment, e.g. a | 125 // Generates and executes code for a given code fragment, e.g. a |
127 // compile time constant expression. Returns the result returned | 126 // compile time constant expression. Returns the result returned |
128 // by the fragment. | 127 // by the fragment. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 | 182 |
184 BackgroundCompilationQueue* function_queue() const { return function_queue_; } | 183 BackgroundCompilationQueue* function_queue() const { return function_queue_; } |
185 bool is_running() const { return running_; } | 184 bool is_running() const { return running_; } |
186 | 185 |
187 private: | 186 private: |
188 explicit BackgroundCompiler(Isolate* isolate); | 187 explicit BackgroundCompiler(Isolate* isolate); |
189 | 188 |
190 virtual void Run(); | 189 virtual void Run(); |
191 | 190 |
192 Isolate* isolate_; | 191 Isolate* isolate_; |
193 bool running_; // While true, will try to read queue and compile. | 192 bool running_; // While true, will try to read queue and compile. |
194 bool* done_; // True if the thread is done. | 193 bool* done_; // True if the thread is done. |
195 Monitor* queue_monitor_; // Controls access to the queue. | 194 Monitor* queue_monitor_; // Controls access to the queue. |
196 Monitor* done_monitor_; // Notify/wait that the thread is done. | 195 Monitor* done_monitor_; // Notify/wait that the thread is done. |
197 | 196 |
198 BackgroundCompilationQueue* function_queue_; | 197 BackgroundCompilationQueue* function_queue_; |
199 | 198 |
200 DISALLOW_IMPLICIT_CONSTRUCTORS(BackgroundCompiler); | 199 DISALLOW_IMPLICIT_CONSTRUCTORS(BackgroundCompiler); |
201 }; | 200 }; |
202 | 201 |
203 } // namespace dart | 202 } // namespace dart |
204 | 203 |
205 #endif // RUNTIME_VM_COMPILER_H_ | 204 #endif // RUNTIME_VM_COMPILER_H_ |
OLD | NEW |