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

Side by Side Diff: src/compiler-dispatcher/compiler-dispatcher-job.h

Issue 2611313002: [complier] Enable parallel eager inner function compilation with compiler dispatcher. (Closed)
Patch Set: Move flag Created 3 years, 11 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
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_JOB_H_ 5 #ifndef V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_JOB_H_
6 #define V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_JOB_H_ 6 #define V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_JOB_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "src/base/macros.h" 10 #include "src/base/macros.h"
11 #include "src/globals.h" 11 #include "src/globals.h"
12 #include "src/handles.h" 12 #include "src/handles.h"
13 #include "testing/gtest/include/gtest/gtest_prod.h" 13 #include "testing/gtest/include/gtest/gtest_prod.h"
14 14
15 namespace v8 { 15 namespace v8 {
16 namespace internal { 16 namespace internal {
17 17
18 class AstValueFactory;
18 class CompilerDispatcherTracer; 19 class CompilerDispatcherTracer;
19 class CompilationInfo; 20 class CompilationInfo;
20 class CompilationJob; 21 class CompilationJob;
22 class FunctionLiteral;
21 class Isolate; 23 class Isolate;
22 class ParseInfo; 24 class ParseInfo;
23 class Parser; 25 class Parser;
24 class SharedFunctionInfo; 26 class SharedFunctionInfo;
25 class String; 27 class String;
26 class UnicodeCache; 28 class UnicodeCache;
27 class Utf16CharacterStream; 29 class Utf16CharacterStream;
28 class Zone; 30 class Zone;
29 31
30 enum class CompileJobStatus { 32 enum class CompileJobStatus {
31 kInitial, 33 kInitial,
32 kReadyToParse, 34 kReadyToParse,
33 kParsed, 35 kParsed,
34 kReadyToAnalyse, 36 kReadyToAnalyze,
37 kAnalyzed,
35 kReadyToCompile, 38 kReadyToCompile,
36 kCompiled, 39 kCompiled,
37 kFailed, 40 kFailed,
38 kDone, 41 kDone,
39 }; 42 };
40 43
41 class V8_EXPORT_PRIVATE CompilerDispatcherJob { 44 class V8_EXPORT_PRIVATE CompilerDispatcherJob {
42 public: 45 public:
46 // Creates a CompilerDispatcherJob in the initial state.
43 CompilerDispatcherJob(Isolate* isolate, CompilerDispatcherTracer* tracer, 47 CompilerDispatcherJob(Isolate* isolate, CompilerDispatcherTracer* tracer,
44 Handle<SharedFunctionInfo> shared, 48 Handle<SharedFunctionInfo> shared,
45 size_t max_stack_size); 49 size_t max_stack_size);
50 // Creates a CompilerDispatcherJob in the analyzed state.
51 CompilerDispatcherJob(Isolate* isolate, CompilerDispatcherTracer* tracer,
52 Handle<SharedFunctionInfo> shared,
53 FunctionLiteral* literal,
54 AstValueFactory* ast_value_factory,
55 size_t max_stack_size);
46 ~CompilerDispatcherJob(); 56 ~CompilerDispatcherJob();
47 57
48 CompileJobStatus status() const { return status_; } 58 CompileJobStatus status() const { return status_; }
49 bool can_parse_on_background_thread() const { 59 bool can_parse_on_background_thread() const {
50 return can_parse_on_background_thread_; 60 return can_parse_on_background_thread_;
51 } 61 }
52 // Should only be called after kReadyToCompile. 62 // Should only be called after kReadyToCompile.
53 bool can_compile_on_background_thread() const { 63 bool can_compile_on_background_thread() const {
54 DCHECK(compile_job_.get()); 64 DCHECK(compile_job_.get());
55 return can_compile_on_background_thread_; 65 return can_compile_on_background_thread_;
56 } 66 }
57 67
58 // Returns true if this CompilerDispatcherJob was created for the given 68 // Returns true if this CompilerDispatcherJob was created for the given
59 // function. 69 // function.
60 bool IsAssociatedWith(Handle<SharedFunctionInfo> shared) const; 70 bool IsAssociatedWith(Handle<SharedFunctionInfo> shared) const;
61 71
62 // Transition from kInitial to kReadyToParse. 72 // Transition from kInitial to kReadyToParse.
63 void PrepareToParseOnMainThread(); 73 void PrepareToParseOnMainThread();
64 74
65 // Transition from kReadyToParse to kParsed. 75 // Transition from kReadyToParse to kParsed.
66 void Parse(); 76 void Parse();
67 77
68 // Transition from kParsed to kReadyToAnalyse (or kFailed). Returns false 78 // Transition from kParsed to kReadyToAnalyze (or kFailed). Returns false
69 // when transitioning to kFailed. In that case, an exception is pending. 79 // when transitioning to kFailed. In that case, an exception is pending.
70 bool FinalizeParsingOnMainThread(); 80 bool FinalizeParsingOnMainThread();
71 81
72 // Transition from kReadyToAnalyse to kReadyToCompile (or kFailed). Returns 82 // Transition from kReadyToAnalyze to kAnalyzed (or kFailed). Returns
83 // false when transitioning to kFailed. In that case, an exception is pending.
84 bool AnalyzeOnMainThread();
85
86 // Transition from kAnalyzed to kReadyToCompile (or kFailed). Returns
73 // false when transitioning to kFailed. In that case, an exception is pending. 87 // false when transitioning to kFailed. In that case, an exception is pending.
74 bool PrepareToCompileOnMainThread(); 88 bool PrepareToCompileOnMainThread();
75 89
76 // Transition from kReadyToCompile to kCompiled. 90 // Transition from kReadyToCompile to kCompiled.
77 void Compile(); 91 void Compile();
78 92
79 // Transition from kCompiled to kDone (or kFailed). Returns false when 93 // Transition from kCompiled to kDone (or kFailed). Returns false when
80 // transitioning to kFailed. In that case, an exception is pending. 94 // transitioning to kFailed. In that case, an exception is pending.
81 bool FinalizeCompilingOnMainThread(); 95 bool FinalizeCompilingOnMainThread();
82 96
83 // Transition from any state to kInitial and free all resources. 97 // Transition from any state to kInitial and free all resources.
84 void ResetOnMainThread(); 98 void ResetOnMainThread();
85 99
86 // Estimate how long the next step will take using the tracer. 100 // Estimate how long the next step will take using the tracer.
87 double EstimateRuntimeOfNextStepInMs() const; 101 double EstimateRuntimeOfNextStepInMs() const;
88 102
89 // Even though the name does not imply this, ShortPrint() must only be invoked 103 // Even though the name does not imply this, ShortPrint() must only be invoked
90 // on the main thread. 104 // on the main thread.
91 void ShortPrint(); 105 void ShortPrint();
92 106
93 private: 107 private:
94 FRIEND_TEST(CompilerDispatcherJobTest, ScopeChain); 108 FRIEND_TEST(CompilerDispatcherJobTest, ScopeChain);
95 109
96 CompileJobStatus status_ = CompileJobStatus::kInitial; 110 CompileJobStatus status_;
97 Isolate* isolate_; 111 Isolate* isolate_;
98 CompilerDispatcherTracer* tracer_; 112 CompilerDispatcherTracer* tracer_;
99 Handle<SharedFunctionInfo> shared_; // Global handle. 113 Handle<SharedFunctionInfo> shared_; // Global handle.
100 Handle<String> source_; // Global handle. 114 Handle<String> source_; // Global handle.
101 size_t max_stack_size_; 115 size_t max_stack_size_;
102 116
103 // Members required for parsing. 117 // Members required for parsing.
104 std::unique_ptr<UnicodeCache> unicode_cache_; 118 std::unique_ptr<UnicodeCache> unicode_cache_;
105 std::unique_ptr<Zone> zone_; 119 std::unique_ptr<Zone> zone_;
106 std::unique_ptr<Utf16CharacterStream> character_stream_; 120 std::unique_ptr<Utf16CharacterStream> character_stream_;
(...skipping 10 matching lines...) Expand all
117 131
118 bool trace_compiler_dispatcher_jobs_; 132 bool trace_compiler_dispatcher_jobs_;
119 133
120 DISALLOW_COPY_AND_ASSIGN(CompilerDispatcherJob); 134 DISALLOW_COPY_AND_ASSIGN(CompilerDispatcherJob);
121 }; 135 };
122 136
123 } // namespace internal 137 } // namespace internal
124 } // namespace v8 138 } // namespace v8
125 139
126 #endif // V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_JOB_H_ 140 #endif // V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_JOB_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698