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/atomic-utils.h" | |
11 #include "src/base/macros.h" | 10 #include "src/base/macros.h" |
12 #include "src/handles.h" | 11 #include "src/handles.h" |
13 | 12 |
14 namespace v8 { | 13 namespace v8 { |
15 namespace internal { | 14 namespace internal { |
16 | 15 |
17 class CompilationInfo; | 16 class CompilationInfo; |
18 class Isolate; | 17 class Isolate; |
19 class JSFunction; | 18 class JSFunction; |
20 class ParseInfo; | 19 class ParseInfo; |
21 class Parser; | 20 class Parser; |
22 class UnicodeCache; | 21 class UnicodeCache; |
23 class Utf16CharacterStream; | 22 class Utf16CharacterStream; |
24 class Zone; | 23 class Zone; |
25 | 24 |
26 enum class CompileJobStatus { | 25 enum class CompileJobStatus { |
27 kInitial, | 26 kInitial, |
28 kReadyToParse, | 27 kReadyToParse, |
29 kParsed, | 28 kParsed, |
30 }; | 29 }; |
31 | 30 |
32 class CompilerDispatcherJob { | 31 class CompilerDispatcherJob { |
33 public: | 32 public: |
34 CompilerDispatcherJob(Isolate* isolate, Handle<JSFunction> function, | 33 CompilerDispatcherJob(Isolate* isolate, Handle<JSFunction> function, |
35 size_t max_stack_size); | 34 size_t max_stack_size); |
36 ~CompilerDispatcherJob(); | 35 ~CompilerDispatcherJob(); |
37 | 36 |
38 CompileJobStatus status() const { return status_.Value(); } | 37 CompileJobStatus status() const { return status_; } |
39 bool can_parse_on_background_thread() const { | 38 bool can_parse_on_background_thread() const { |
40 return can_parse_on_background_thread_; | 39 return can_parse_on_background_thread_; |
41 } | 40 } |
42 | 41 |
43 // Transition from kInitial to kReadyToParse. | 42 // Transition from kInitial to kReadyToParse. |
44 void PrepareToParseOnMainThread(); | 43 void PrepareToParseOnMainThread(); |
45 | 44 |
46 // Transition from kReadyToParse to kParsed. | 45 // Transition from kReadyToParse to kParsed. |
47 void Parse(); | 46 void Parse(); |
48 | 47 |
49 private: | 48 private: |
50 base::AtomicValue<CompileJobStatus> status_ = | 49 CompileJobStatus status_ = CompileJobStatus::kInitial; |
51 base::AtomicValue<CompileJobStatus>(CompileJobStatus::kInitial); | |
52 Isolate* isolate_; | 50 Isolate* isolate_; |
53 Handle<JSFunction> function_; // Global handle. | 51 Handle<JSFunction> function_; // Global handle. |
54 size_t max_stack_size_; | 52 size_t max_stack_size_; |
55 | 53 |
56 // Members required for parsing. | 54 // Members required for parsing. |
57 std::unique_ptr<UnicodeCache> unicode_cache_; | 55 std::unique_ptr<UnicodeCache> unicode_cache_; |
58 std::unique_ptr<Zone> zone_; | 56 std::unique_ptr<Zone> zone_; |
59 std::unique_ptr<Utf16CharacterStream> character_stream_; | 57 std::unique_ptr<Utf16CharacterStream> character_stream_; |
60 std::unique_ptr<ParseInfo> parse_info_; | 58 std::unique_ptr<ParseInfo> parse_info_; |
61 std::unique_ptr<Parser> parser_; | 59 std::unique_ptr<Parser> parser_; |
62 | 60 |
63 bool can_parse_on_background_thread_; | 61 bool can_parse_on_background_thread_; |
64 | 62 |
65 DISALLOW_COPY_AND_ASSIGN(CompilerDispatcherJob); | 63 DISALLOW_COPY_AND_ASSIGN(CompilerDispatcherJob); |
66 }; | 64 }; |
67 | 65 |
68 } // namespace internal | 66 } // namespace internal |
69 } // namespace v8 | 67 } // namespace v8 |
70 | 68 |
71 #endif // V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_JOB_H_ | 69 #endif // V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_JOB_H_ |
OLD | NEW |