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

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

Issue 1419533011: Redo background compilation queues to allocate queue and its element in the C-heap (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Address comments Created 5 years, 1 month 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
« no previous file with comments | « no previous file | runtime/vm/compiler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_COMPILER_H_ 5 #ifndef VM_COMPILER_H_
6 #define VM_COMPILER_H_ 6 #define 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"
11 #include "vm/thread_pool.h" 11 #include "vm/thread_pool.h"
12 12
13 namespace dart { 13 namespace dart {
14 14
15 // Forward declarations. 15 // Forward declarations.
16 class BackgroundCompilationQueue;
16 class Class; 17 class Class;
17 class Code; 18 class Code;
18 class CompilationWorkQueue; 19 class CompilationWorkQueue;
19 class Function; 20 class Function;
20 class Library; 21 class Library;
21 class ParsedFunction; 22 class ParsedFunction;
23 class QueueElement;
22 class RawInstance; 24 class RawInstance;
23 class Script; 25 class Script;
24 class SequenceNode; 26 class SequenceNode;
25 27
26 // Carries result from background compilation: code and generation counters 28 // Carries result from background compilation: code and generation counters
27 // that help check if the code may have become invalid during background 29 // that help check if the code may have become invalid during background
28 // compilation. 30 // compilation.
29 class BackgroundCompilationResult : public ValueObject { 31 class BackgroundCompilationResult : public ValueObject {
30 public: 32 public:
31 BackgroundCompilationResult(); 33 BackgroundCompilationResult();
32 34
33 // Initializes with current isolate-stored generations 35 // Initializes with current isolate-stored generations
34 void Init(); 36 void Init();
35 37
36 void set_result_code(const Code& value) { result_code_ = value.raw(); } 38 void set_result_code(const Code& value) { result_code_ = value.raw(); }
37 const Code& result_code() const { return result_code_; } 39 const Code& result_code() const { return result_code_; }
38 40
41 uint32_t cha_invalidation_gen() const { return cha_invalidation_gen_; }
42 uint32_t field_invalidation_gen() const { return field_invalidation_gen_; }
43 uint32_t prefix_invalidation_gen() const { return prefix_invalidation_gen_; }
44
45 void SetFromQElement(QueueElement* value);
46
39 // Returns true if all relevant gen-counts are current and code is valid. 47 // Returns true if all relevant gen-counts are current and code is valid.
40 bool IsValid() const; 48 bool IsValid() const;
41 49
42 // Remove gen-counts from validation check. 50 // Remove gen-counts from validation check.
43 void ClearCHAInvalidationGen() { 51 void ClearCHAInvalidationGen() {
44 cha_invalidation_gen_ = Integer::null(); 52 cha_invalidation_gen_ = Isolate::kInvalidGen;
45 } 53 }
46 void ClearFieldInnvalidationGen() { 54 void ClearFieldInnvalidationGen() {
47 field_invalidation_gen_ = Integer::null(); 55 field_invalidation_gen_ = Isolate::kInvalidGen;
48 } 56 }
49 void ClearPrefixInnvalidationGen() { 57 void ClearPrefixInnvalidationGen() {
50 prefix_invalidation_gen_ = Integer::null(); 58 prefix_invalidation_gen_ = Isolate::kInvalidGen;
51 } 59 }
52 60
53 void PushOnQueue(CompilationWorkQueue* queue) const;
54 void PopFromQueue(CompilationWorkQueue* queue);
55
56 void PrintValidity() const; 61 void PrintValidity() const;
57 62
58 private: 63 private:
59 Code& result_code_; 64 Code& result_code_;
60 Integer& cha_invalidation_gen_; 65 uint32_t cha_invalidation_gen_;
61 Integer& field_invalidation_gen_; 66 uint32_t field_invalidation_gen_;
62 Integer& prefix_invalidation_gen_; 67 uint32_t prefix_invalidation_gen_;
63 }; 68 };
64 69
65 70
66 class Compiler : public AllStatic { 71 class Compiler : public AllStatic {
67 public: 72 public:
68 static const intptr_t kNoOSRDeoptId = Thread::kNoDeoptId; 73 static const intptr_t kNoOSRDeoptId = Thread::kNoDeoptId;
69 74
70 static bool IsBackgroundCompilation(); 75 static bool IsBackgroundCompilation();
71 76
72 // Extracts top level entities from the script and populates 77 // Extracts top level entities from the script and populates
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 165
161 static void Stop(BackgroundCompiler* task); 166 static void Stop(BackgroundCompiler* task);
162 167
163 // Call to optimize a function in the background, enters the function in the 168 // Call to optimize a function in the background, enters the function in the
164 // compilation queue. 169 // compilation queue.
165 void CompileOptimized(const Function& function); 170 void CompileOptimized(const Function& function);
166 171
167 // Call to activate/install optimized code (must occur in the mutator thread). 172 // Call to activate/install optimized code (must occur in the mutator thread).
168 void InstallGeneratedCode(); 173 void InstallGeneratedCode();
169 174
170 // Access to queue length is guarded with queue_monitor_;
171 intptr_t function_queue_length() const { return function_queue_length_; }
172 void set_function_queue_length(intptr_t value) {
173 function_queue_length_ = value;
174 }
175 175
176 void VisitPointers(ObjectPointerVisitor* visitor); 176 void VisitPointers(ObjectPointerVisitor* visitor);
177 177
178 BackgroundCompilationQueue* function_queue() const { return function_queue_; }
179 BackgroundCompilationQueue* result_queue() const { return result_queue_; }
180
178 private: 181 private:
179 explicit BackgroundCompiler(Isolate* isolate); 182 explicit BackgroundCompiler(Isolate* isolate);
180 183
181 void set_compilation_function_queue(const GrowableObjectArray& value);
182 void set_compilation_result_queue(const GrowableObjectArray& value);
183
184 GrowableObjectArray* FunctionsQueue() const;
185 GrowableObjectArray* ResultQueue() const;
186
187 virtual void Run(); 184 virtual void Run();
188 185
189 void AddFunction(const Function& f);
190 RawFunction* RemoveFunctionOrNull();
191 RawFunction* LastFunctionOrNull() const;
192
193 void AddResult(const BackgroundCompilationResult& value); 186 void AddResult(const BackgroundCompilationResult& value);
194 187
195 Isolate* isolate_; 188 Isolate* isolate_;
196 bool running_; // While true, will try to read queue and compile. 189 bool running_; // While true, will try to read queue and compile.
197 bool* done_; // True if the thread is done. 190 bool* done_; // True if the thread is done.
198 Monitor* queue_monitor_; // Controls access to the queue. 191 Monitor* queue_monitor_; // Controls access to the queue.
199 Monitor* done_monitor_; // Notify/wait that the thread is done. 192 Monitor* done_monitor_; // Notify/wait that the thread is done.
200 193
201 // Lightweight access to length of compiler queue. 194 BackgroundCompilationQueue* function_queue_;
202 intptr_t function_queue_length_; 195 BackgroundCompilationQueue* result_queue_;
203
204 RawGrowableObjectArray* compilation_function_queue_;
205 RawGrowableObjectArray* compilation_result_queue_;
206 196
207 DISALLOW_IMPLICIT_CONSTRUCTORS(BackgroundCompiler); 197 DISALLOW_IMPLICIT_CONSTRUCTORS(BackgroundCompiler);
208 }; 198 };
209 199
210 } // namespace dart 200 } // namespace dart
211 201
212 #endif // VM_COMPILER_H_ 202 #endif // VM_COMPILER_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698