blob: 50414af63948f6af96b6d9f74a8fcfb1b858b988 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_JOB_H_
#define V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_JOB_H_
#include <memory>
#include "src/base/macros.h"
#include "src/handles.h"
#include "testing/gtest/include/gtest/gtest_prod.h"
namespace v8 {
namespace internal {
class CompilationInfo;
class Isolate;
class JSFunction;
class ParseInfo;
class Parser;
class String;
class UnicodeCache;
class Utf16CharacterStream;
class Zone;
enum class CompileJobStatus {
kInitial,
kReadyToParse,
kParsed,
kReadyToCompile,
kFailed,
kDone,
};
class CompilerDispatcherJob {
public:
CompilerDispatcherJob(Isolate* isolate, Handle<JSFunction> function,
size_t max_stack_size);
~CompilerDispatcherJob();
CompileJobStatus status() const { return status_; }
bool can_parse_on_background_thread() const {
return can_parse_on_background_thread_;
}
// Transition from kInitial to kReadyToParse.
void PrepareToParseOnMainThread();
// Transition from kReadyToParse to kParsed.
void Parse();
// Transition from kParsed to kReadyToCompile (or kFailed). Returns false
// when transitioning to kFailed. In that case, an exception is pending.
bool FinalizeParsingOnMainThread();
// Transition from any state to kInitial and free all resources.
void ResetOnMainThread();
private:
FRIEND_TEST(CompilerDispatcherJobTest, ScopeChain);
CompileJobStatus status_ = CompileJobStatus::kInitial;
Isolate* isolate_;
Handle<JSFunction> function_; // Global handle.
Handle<String> source_; // Global handle.
size_t max_stack_size_;
// Members required for parsing.
std::unique_ptr<UnicodeCache> unicode_cache_;
std::unique_ptr<Zone> zone_;
std::unique_ptr<Utf16CharacterStream> character_stream_;
std::unique_ptr<ParseInfo> parse_info_;
std::unique_ptr<Parser> parser_;
std::unique_ptr<DeferredHandles> handles_from_parsing_;
bool can_parse_on_background_thread_;
DISALLOW_COPY_AND_ASSIGN(CompilerDispatcherJob);
};
} // namespace internal
} // namespace v8
#endif // V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_JOB_H_
|