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 CompilationJob; |
19 class Isolate; | 19 class Isolate; |
20 class JSFunction; | |
21 class ParseInfo; | 20 class ParseInfo; |
22 class Parser; | 21 class Parser; |
| 22 class SharedFunctionInfo; |
23 class String; | 23 class String; |
24 class UnicodeCache; | 24 class UnicodeCache; |
25 class Utf16CharacterStream; | 25 class Utf16CharacterStream; |
26 class Zone; | 26 class Zone; |
27 | 27 |
28 enum class CompileJobStatus { | 28 enum class CompileJobStatus { |
29 kInitial, | 29 kInitial, |
30 kReadyToParse, | 30 kReadyToParse, |
31 kParsed, | 31 kParsed, |
32 kReadyToAnalyse, | 32 kReadyToAnalyse, |
33 kReadyToCompile, | 33 kReadyToCompile, |
34 kCompiled, | 34 kCompiled, |
35 kFailed, | 35 kFailed, |
36 kDone, | 36 kDone, |
37 }; | 37 }; |
38 | 38 |
39 class CompilerDispatcherJob { | 39 class CompilerDispatcherJob { |
40 public: | 40 public: |
41 CompilerDispatcherJob(Isolate* isolate, Handle<JSFunction> function, | 41 CompilerDispatcherJob(Isolate* isolate, Handle<SharedFunctionInfo> shared, |
42 size_t max_stack_size); | 42 size_t max_stack_size); |
43 ~CompilerDispatcherJob(); | 43 ~CompilerDispatcherJob(); |
44 | 44 |
45 CompileJobStatus status() const { return status_; } | 45 CompileJobStatus status() const { return status_; } |
46 bool can_parse_on_background_thread() const { | 46 bool can_parse_on_background_thread() const { |
47 return can_parse_on_background_thread_; | 47 return can_parse_on_background_thread_; |
48 } | 48 } |
49 // Should only be called after kReadyToCompile. | 49 // Should only be called after kReadyToCompile. |
50 bool can_compile_on_background_thread() const { | 50 bool can_compile_on_background_thread() const { |
51 DCHECK(compile_job_.get()); | 51 DCHECK(compile_job_.get()); |
(...skipping 22 matching lines...) Expand all Loading... |
74 bool FinalizeCompilingOnMainThread(); | 74 bool FinalizeCompilingOnMainThread(); |
75 | 75 |
76 // Transition from any state to kInitial and free all resources. | 76 // Transition from any state to kInitial and free all resources. |
77 void ResetOnMainThread(); | 77 void ResetOnMainThread(); |
78 | 78 |
79 private: | 79 private: |
80 FRIEND_TEST(CompilerDispatcherJobTest, ScopeChain); | 80 FRIEND_TEST(CompilerDispatcherJobTest, ScopeChain); |
81 | 81 |
82 CompileJobStatus status_ = CompileJobStatus::kInitial; | 82 CompileJobStatus status_ = CompileJobStatus::kInitial; |
83 Isolate* isolate_; | 83 Isolate* isolate_; |
84 Handle<JSFunction> function_; // Global handle. | 84 Handle<SharedFunctionInfo> shared_; // Global handle. |
85 Handle<String> source_; // Global handle. | 85 Handle<String> source_; // Global handle. |
86 size_t max_stack_size_; | 86 size_t max_stack_size_; |
87 | 87 |
88 // Members required for parsing. | 88 // Members required for parsing. |
89 std::unique_ptr<UnicodeCache> unicode_cache_; | 89 std::unique_ptr<UnicodeCache> unicode_cache_; |
90 std::unique_ptr<Zone> zone_; | 90 std::unique_ptr<Zone> zone_; |
91 std::unique_ptr<Utf16CharacterStream> character_stream_; | 91 std::unique_ptr<Utf16CharacterStream> character_stream_; |
92 std::unique_ptr<ParseInfo> parse_info_; | 92 std::unique_ptr<ParseInfo> parse_info_; |
93 std::unique_ptr<Parser> parser_; | 93 std::unique_ptr<Parser> parser_; |
94 std::unique_ptr<DeferredHandles> handles_from_parsing_; | 94 std::unique_ptr<DeferredHandles> handles_from_parsing_; |
95 | 95 |
96 // Members required for compiling. | 96 // Members required for compiling. |
97 std::unique_ptr<CompilationInfo> compile_info_; | 97 std::unique_ptr<CompilationInfo> compile_info_; |
98 std::unique_ptr<CompilationJob> compile_job_; | 98 std::unique_ptr<CompilationJob> compile_job_; |
99 | 99 |
100 bool can_parse_on_background_thread_; | 100 bool can_parse_on_background_thread_; |
101 bool can_compile_on_background_thread_; | 101 bool can_compile_on_background_thread_; |
102 | 102 |
103 DISALLOW_COPY_AND_ASSIGN(CompilerDispatcherJob); | 103 DISALLOW_COPY_AND_ASSIGN(CompilerDispatcherJob); |
104 }; | 104 }; |
105 | 105 |
106 } // namespace internal | 106 } // namespace internal |
107 } // namespace v8 | 107 } // namespace v8 |
108 | 108 |
109 #endif // V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_JOB_H_ | 109 #endif // V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_JOB_H_ |
OLD | NEW |