OLD | NEW |
---|---|
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/handles.h" | 11 #include "src/handles.h" |
12 #include "testing/gtest/include/gtest/gtest_prod.h" | 12 #include "testing/gtest/include/gtest/gtest_prod.h" |
13 | 13 |
14 namespace v8 { | 14 namespace v8 { |
15 namespace internal { | 15 namespace internal { |
16 | 16 |
17 class CompilationInfo; | 17 class CompilationInfo; |
18 class CompilationJob; | |
18 class Isolate; | 19 class Isolate; |
19 class JSFunction; | 20 class JSFunction; |
20 class ParseInfo; | 21 class ParseInfo; |
21 class Parser; | 22 class Parser; |
22 class String; | 23 class String; |
23 class UnicodeCache; | 24 class UnicodeCache; |
24 class Utf16CharacterStream; | 25 class Utf16CharacterStream; |
25 class Zone; | 26 class Zone; |
26 | 27 |
27 enum class CompileJobStatus { | 28 enum class CompileJobStatus { |
28 kInitial, | 29 kInitial, |
29 kReadyToParse, | 30 kReadyToParse, |
30 kParsed, | 31 kParsed, |
32 kReadyToAnalyse, | |
31 kReadyToCompile, | 33 kReadyToCompile, |
34 kCompiled, | |
32 kFailed, | 35 kFailed, |
33 kDone, | 36 kDone, |
34 }; | 37 }; |
35 | 38 |
36 class CompilerDispatcherJob { | 39 class CompilerDispatcherJob { |
37 public: | 40 public: |
38 CompilerDispatcherJob(Isolate* isolate, Handle<JSFunction> function, | 41 CompilerDispatcherJob(Isolate* isolate, Handle<JSFunction> function, |
39 size_t max_stack_size); | 42 size_t max_stack_size); |
40 ~CompilerDispatcherJob(); | 43 ~CompilerDispatcherJob(); |
41 | 44 |
42 CompileJobStatus status() const { return status_; } | 45 CompileJobStatus status() const { return status_; } |
43 bool can_parse_on_background_thread() const { | 46 bool can_parse_on_background_thread() const { |
44 return can_parse_on_background_thread_; | 47 return can_parse_on_background_thread_; |
45 } | 48 } |
jochen (gone - plz use gerrit)
2016/08/23 12:04:26
can you also expose this information for the compi
rmcilroy
2016/08/23 15:55:10
The thing is, this can only return the right value
jochen (gone - plz use gerrit)
2016/08/23 16:06:22
DCHECK and return false, maybe?
rmcilroy
2016/08/23 16:58:29
Done.
| |
46 | 49 |
47 // Transition from kInitial to kReadyToParse. | 50 // Transition from kInitial to kReadyToParse. |
48 void PrepareToParseOnMainThread(); | 51 void PrepareToParseOnMainThread(); |
49 | 52 |
50 // Transition from kReadyToParse to kParsed. | 53 // Transition from kReadyToParse to kParsed. |
51 void Parse(); | 54 void Parse(); |
52 | 55 |
53 // Transition from kParsed to kReadyToCompile (or kFailed). | 56 // Transition from kParsed to kReadyToAnalyse. |
54 void FinalizeParsingOnMainThread(); | 57 void FinalizeParsingOnMainThread(); |
55 | 58 |
59 // Transition from kReadyToAnalyse to kReadyToCompile (or kFailed). | |
60 void PrepareToCompileOnMainThread(); | |
61 | |
62 // Transition from kReadyToCompile to kCompiled (or kFailed). | |
63 void Compile(); | |
64 | |
65 // Transition from kCompiled to kDone (or kFailed). | |
66 void FinalizeCompilingOnMainThread(); | |
67 | |
56 // Transition from kFailed to kDone. | 68 // Transition from kFailed to kDone. |
57 void ReportErrorsOnMainThread(); | 69 void ReportErrorsOnMainThread(); |
58 | 70 |
59 // Transition from any state to kInitial and free all resources. | 71 // Transition from any state to kInitial and free all resources. |
60 void ResetOnMainThread(); | 72 void ResetOnMainThread(); |
61 | 73 |
62 private: | 74 private: |
63 FRIEND_TEST(CompilerDispatcherJobTest, ScopeChain); | 75 FRIEND_TEST(CompilerDispatcherJobTest, ScopeChain); |
64 | 76 |
65 void InternalizeParsingResult(); | 77 void InternalizeParsingResult(); |
66 | 78 |
67 CompileJobStatus status_ = CompileJobStatus::kInitial; | 79 CompileJobStatus status_ = CompileJobStatus::kInitial; |
68 Isolate* isolate_; | 80 Isolate* isolate_; |
69 Handle<JSFunction> function_; // Global handle. | 81 Handle<JSFunction> function_; // Global handle. |
70 Handle<String> source_; // Global handle. | 82 Handle<String> source_; // Global handle. |
71 size_t max_stack_size_; | 83 size_t max_stack_size_; |
72 | 84 |
73 // Members required for parsing. | 85 // Members required for parsing. |
74 std::unique_ptr<UnicodeCache> unicode_cache_; | 86 std::unique_ptr<UnicodeCache> unicode_cache_; |
75 std::unique_ptr<Zone> zone_; | 87 std::unique_ptr<Zone> zone_; |
76 std::unique_ptr<Utf16CharacterStream> character_stream_; | 88 std::unique_ptr<Utf16CharacterStream> character_stream_; |
77 std::unique_ptr<ParseInfo> parse_info_; | 89 std::unique_ptr<ParseInfo> parse_info_; |
78 std::unique_ptr<Parser> parser_; | 90 std::unique_ptr<Parser> parser_; |
79 | 91 |
92 // Members required for compiling. | |
93 std::unique_ptr<CompilationInfo> compile_info_; | |
94 std::unique_ptr<CompilationJob> compile_job_; | |
95 | |
80 bool can_parse_on_background_thread_; | 96 bool can_parse_on_background_thread_; |
81 | 97 |
82 DISALLOW_COPY_AND_ASSIGN(CompilerDispatcherJob); | 98 DISALLOW_COPY_AND_ASSIGN(CompilerDispatcherJob); |
83 }; | 99 }; |
84 | 100 |
85 } // namespace internal | 101 } // namespace internal |
86 } // namespace v8 | 102 } // namespace v8 |
87 | 103 |
88 #endif // V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_JOB_H_ | 104 #endif // V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_JOB_H_ |
OLD | NEW |