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 25 matching lines...) Expand all Loading... |
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 | |
47 class DartCompilationPipeline : public CompilationPipeline { | 46 class DartCompilationPipeline : public CompilationPipeline { |
48 public: | 47 public: |
49 virtual void ParseFunction(ParsedFunction* parsed_function); | 48 virtual void ParseFunction(ParsedFunction* parsed_function); |
50 | 49 |
51 virtual FlowGraph* BuildFlowGraph( | 50 virtual FlowGraph* BuildFlowGraph( |
52 Zone* zone, | 51 Zone* zone, |
53 ParsedFunction* parsed_function, | 52 ParsedFunction* parsed_function, |
54 const ZoneGrowableArray<const ICData*>& ic_data_array, | 53 const ZoneGrowableArray<const ICData*>& ic_data_array, |
55 intptr_t osr_id); | 54 intptr_t osr_id); |
56 | 55 |
57 virtual void FinalizeCompilation(FlowGraph* flow_graph); | 56 virtual void FinalizeCompilation(FlowGraph* flow_graph); |
58 }; | 57 }; |
59 | 58 |
60 | |
61 class IrregexpCompilationPipeline : public CompilationPipeline { | 59 class IrregexpCompilationPipeline : public CompilationPipeline { |
62 public: | 60 public: |
63 IrregexpCompilationPipeline() : backtrack_goto_(NULL) {} | 61 IrregexpCompilationPipeline() : backtrack_goto_(NULL) {} |
64 | 62 |
65 virtual void ParseFunction(ParsedFunction* parsed_function); | 63 virtual void ParseFunction(ParsedFunction* parsed_function); |
66 | 64 |
67 virtual FlowGraph* BuildFlowGraph( | 65 virtual FlowGraph* BuildFlowGraph( |
68 Zone* zone, | 66 Zone* zone, |
69 ParsedFunction* parsed_function, | 67 ParsedFunction* parsed_function, |
70 const ZoneGrowableArray<const ICData*>& ic_data_array, | 68 const ZoneGrowableArray<const ICData*>& ic_data_array, |
71 intptr_t osr_id); | 69 intptr_t osr_id); |
72 | 70 |
73 virtual void FinalizeCompilation(FlowGraph* flow_graph); | 71 virtual void FinalizeCompilation(FlowGraph* flow_graph); |
74 | 72 |
75 private: | 73 private: |
76 IndirectGotoInstr* backtrack_goto_; | 74 IndirectGotoInstr* backtrack_goto_; |
77 }; | 75 }; |
78 | 76 |
79 | |
80 class Compiler : public AllStatic { | 77 class Compiler : public AllStatic { |
81 public: | 78 public: |
82 static const intptr_t kNoOSRDeoptId = Thread::kNoDeoptId; | 79 static const intptr_t kNoOSRDeoptId = Thread::kNoDeoptId; |
83 | 80 |
84 static bool IsBackgroundCompilation(); | 81 static bool IsBackgroundCompilation(); |
85 // The result for a function may change if debugging gets turned on/off. | 82 // The result for a function may change if debugging gets turned on/off. |
86 static bool CanOptimizeFunction(Thread* thread, const Function& function); | 83 static bool CanOptimizeFunction(Thread* thread, const Function& function); |
87 | 84 |
88 // Extracts top level entities from the script and populates | 85 // Extracts top level entities from the script and populates |
89 // the class dictionary of the library. | 86 // the class dictionary of the library. |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 static RawError* CompileAllFunctions(const Class& cls); | 147 static RawError* CompileAllFunctions(const Class& cls); |
151 static RawError* ParseAllFunctions(const Class& cls); | 148 static RawError* ParseAllFunctions(const Class& cls); |
152 | 149 |
153 // Notify the compiler that background (optimized) compilation has failed | 150 // Notify the compiler that background (optimized) compilation has failed |
154 // because the mutator thread changed the state (e.g., deoptimization, | 151 // because the mutator thread changed the state (e.g., deoptimization, |
155 // deferred loading). The background compilation may retry to compile | 152 // deferred loading). The background compilation may retry to compile |
156 // the same function later. | 153 // the same function later. |
157 static void AbortBackgroundCompilation(intptr_t deopt_id, const char* msg); | 154 static void AbortBackgroundCompilation(intptr_t deopt_id, const char* msg); |
158 }; | 155 }; |
159 | 156 |
160 | |
161 // Class to run optimizing compilation in a background thread. | 157 // Class to run optimizing compilation in a background thread. |
162 // Current implementation: one task per isolate, it dies with the owning | 158 // Current implementation: one task per isolate, it dies with the owning |
163 // isolate. | 159 // isolate. |
164 // No OSR compilation in the background compiler. | 160 // No OSR compilation in the background compiler. |
165 class BackgroundCompiler : public ThreadPool::Task { | 161 class BackgroundCompiler : public ThreadPool::Task { |
166 public: | 162 public: |
167 virtual ~BackgroundCompiler(); | 163 virtual ~BackgroundCompiler(); |
168 | 164 |
169 static void EnsureInit(Thread* thread); | 165 static void EnsureInit(Thread* thread); |
170 | 166 |
(...skipping 28 matching lines...) Expand all Loading... |
199 Monitor* done_monitor_; // Notify/wait that the thread is done. | 195 Monitor* done_monitor_; // Notify/wait that the thread is done. |
200 | 196 |
201 BackgroundCompilationQueue* function_queue_; | 197 BackgroundCompilationQueue* function_queue_; |
202 | 198 |
203 DISALLOW_IMPLICIT_CONSTRUCTORS(BackgroundCompiler); | 199 DISALLOW_IMPLICIT_CONSTRUCTORS(BackgroundCompiler); |
204 }; | 200 }; |
205 | 201 |
206 } // namespace dart | 202 } // namespace dart |
207 | 203 |
208 #endif // RUNTIME_VM_COMPILER_H_ | 204 #endif // RUNTIME_VM_COMPILER_H_ |
OLD | NEW |