blob: 827a2aa18d6703c2c14afc20059fa239b070010b (
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
|
// 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 "src/contexts.h"
#include "src/handles.h"
namespace v8 {
namespace internal {
class SharedFunctionInfo;
class UnoptimizedCompileJob;
class V8_EXPORT_PRIVATE CompilerDispatcherJob {
public:
enum class Type { kUnoptimizedCompile };
enum class Status {
kInitial,
kReadyToFinalize,
kDone,
kFailed,
};
CompilerDispatcherJob(Type type) : type_(type), status_(Status::kInitial) {}
virtual ~CompilerDispatcherJob() = default;
Type type() const { return type_; }
// Returns the current status of the compile
Status status() const { return status_; }
// Returns true if this CompilerDispatcherJob has finished (either with a
// success or a failure).
bool IsFinished() const {
return status() == Status::kDone || status() == Status::kFailed;
}
// Returns true if this CompilerDispatcherJob has failed.
bool IsFailed() const { return status() == Status::kFailed; }
// Return true if the next step can be run on any thread.
bool NextStepCanRunOnAnyThread() const {
return status() == Status::kInitial;
}
// Casts to implementations.
const UnoptimizedCompileJob* AsUnoptimizedCompileJob() const;
// Transition from kInitial to kReadyToFinalize.
virtual void Compile(bool on_background_thread) = 0;
// Transition from kReadyToFinalize to kDone (or kFailed). Must only be
// invoked on the main thread.
virtual void FinalizeOnMainThread(Isolate* isolate,
Handle<SharedFunctionInfo> shared) = 0;
// Free all resources. Must only be invoked on the main thread.
virtual void ResetOnMainThread(Isolate* isolate) = 0;
// Estimate how long the next step will take using the tracer.
virtual double EstimateRuntimeOfNextStepInMs() const = 0;
protected:
void set_status(Status status) { status_ = status; }
private:
Type type_;
Status status_;
};
} // namespace internal
} // namespace v8
#endif // V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_JOB_H_
|