summaryrefslogtreecommitdiff
path: root/deps/v8/src/compiler-dispatcher/unoptimized-compile-job.h
blob: 8352e4e7950a18d5788b3984f07ee2e2cd6cc2e5 (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
86
87
88
89
// 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_UNOPTIMIZED_COMPILE_JOB_H_
#define V8_COMPILER_DISPATCHER_UNOPTIMIZED_COMPILE_JOB_H_

#include <memory>

#include "include/v8.h"
#include "src/base/macros.h"
#include "src/compiler-dispatcher/compiler-dispatcher-job.h"
#include "src/globals.h"

namespace v8 {
namespace internal {

class AstValueFactory;
class AstStringConstants;
class CompilerDispatcherTracer;
class DeferredHandles;
class FunctionLiteral;
class Isolate;
class ParseInfo;
class Parser;
class SharedFunctionInfo;
class String;
class UnicodeCache;
class UnoptimizedCompilationJob;
class Utf16CharacterStream;

class V8_EXPORT_PRIVATE UnoptimizedCompileJob : public CompilerDispatcherJob {
 public:
  // Creates a UnoptimizedCompileJob in the initial state.
  UnoptimizedCompileJob(Isolate* isolate, CompilerDispatcherTracer* tracer,
                        Handle<SharedFunctionInfo> shared,
                        size_t max_stack_size);
  ~UnoptimizedCompileJob() override;

  Handle<SharedFunctionInfo> shared() const { return shared_; }

  // Returns true if this UnoptimizedCompileJob was created for the given
  // function.
  bool IsAssociatedWith(Handle<SharedFunctionInfo> shared) const;

  // CompilerDispatcherJob implementation.
  void PrepareOnMainThread(Isolate* isolate) override;
  void Compile(bool on_background_thread) override;
  void FinalizeOnMainThread(Isolate* isolate) override;
  void ReportErrorsOnMainThread(Isolate* isolate) override;
  void ResetOnMainThread(Isolate* isolate) override;
  double EstimateRuntimeOfNextStepInMs() const override;
  void ShortPrintOnMainThread() override;

 private:
  friend class CompilerDispatcherTest;
  friend class UnoptimizedCompileJobTest;

  void ResetDataOnMainThread(Isolate* isolate);

  Context* context() { return *context_; }

  int main_thread_id_;
  CompilerDispatcherTracer* tracer_;
  AccountingAllocator* allocator_;
  Handle<Context> context_;            // Global handle.
  Handle<SharedFunctionInfo> shared_;  // Global handle.
  Handle<String> source_;              // Global handle.
  Handle<String> wrapper_;             // Global handle.
  std::unique_ptr<v8::String::ExternalStringResourceBase> source_wrapper_;
  size_t max_stack_size_;

  // Members required for parsing.
  std::unique_ptr<UnicodeCache> unicode_cache_;
  std::unique_ptr<ParseInfo> parse_info_;
  std::unique_ptr<Parser> parser_;

  // Members required for compiling.
  std::unique_ptr<UnoptimizedCompilationJob> compilation_job_;

  bool trace_compiler_dispatcher_jobs_;

  DISALLOW_COPY_AND_ASSIGN(UnoptimizedCompileJob);
};

}  // namespace internal
}  // namespace v8

#endif  // V8_COMPILER_DISPATCHER_UNOPTIMIZED_COMPILE_JOB_H_