• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2018 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef V8_CODEGEN_UNOPTIMIZED_COMPILATION_INFO_H_
6 #define V8_CODEGEN_UNOPTIMIZED_COMPILATION_INFO_H_
7 
8 #include <memory>
9 
10 #include "src/codegen/source-position-table.h"
11 #include "src/common/globals.h"
12 #include "src/handles/handles.h"
13 #include "src/objects/feedback-vector.h"
14 #include "src/objects/objects.h"
15 #include "src/parsing/parse-info.h"
16 #include "src/utils/utils.h"
17 
18 namespace v8 {
19 namespace internal {
20 
21 class AsmWasmData;
22 class CoverageInfo;
23 class DeclarationScope;
24 class FunctionLiteral;
25 class Isolate;
26 class ParseInfo;
27 class SourceRangeMap;
28 class Zone;
29 
30 // UnoptimizedCompilationInfo encapsulates the information needed to compile
31 // unoptimized code for a given function, and the results of the compilation.
32 class V8_EXPORT_PRIVATE UnoptimizedCompilationInfo final {
33  public:
34   UnoptimizedCompilationInfo(Zone* zone, ParseInfo* parse_info,
35                              FunctionLiteral* literal);
36 
flags()37   const UnoptimizedCompileFlags& flags() const { return flags_; }
dispatcher()38   LazyCompileDispatcher* dispatcher() { return dispatcher_; }
character_stream()39   const Utf16CharacterStream* character_stream() const {
40     return character_stream_;
41   }
42 
43   // Accessors for the input data of the function being compiled.
44 
literal()45   FunctionLiteral* literal() const { return literal_; }
set_literal(FunctionLiteral * literal)46   void set_literal(FunctionLiteral* literal) {
47     DCHECK_NOT_NULL(literal);
48     literal_ = literal;
49   }
ClearLiteral()50   void ClearLiteral() { literal_ = nullptr; }
51 
52   DeclarationScope* scope() const;
53 
54   int num_parameters() const;
55   int num_parameters_including_this() const;
56 
57   // Accessors for optional compilation features.
58 
59   SourcePositionTableBuilder::RecordingMode SourcePositionRecordingMode() const;
60 
has_source_range_map()61   bool has_source_range_map() const { return source_range_map_ != nullptr; }
source_range_map()62   SourceRangeMap* source_range_map() const { return source_range_map_; }
set_source_range_map(SourceRangeMap * source_range_map)63   void set_source_range_map(SourceRangeMap* source_range_map) {
64     source_range_map_ = source_range_map;
65   }
66 
has_coverage_info()67   bool has_coverage_info() const { return !coverage_info_.is_null(); }
coverage_info()68   Handle<CoverageInfo> coverage_info() const { return coverage_info_; }
set_coverage_info(Handle<CoverageInfo> coverage_info)69   void set_coverage_info(Handle<CoverageInfo> coverage_info) {
70     coverage_info_ = coverage_info;
71   }
72 
73   // Accessors for the output of compilation.
74 
has_bytecode_array()75   bool has_bytecode_array() const { return !bytecode_array_.is_null(); }
bytecode_array()76   Handle<BytecodeArray> bytecode_array() const { return bytecode_array_; }
SetBytecodeArray(Handle<BytecodeArray> bytecode_array)77   void SetBytecodeArray(Handle<BytecodeArray> bytecode_array) {
78     bytecode_array_ = bytecode_array;
79   }
80 
has_asm_wasm_data()81   bool has_asm_wasm_data() const { return !asm_wasm_data_.is_null(); }
asm_wasm_data()82   Handle<AsmWasmData> asm_wasm_data() const { return asm_wasm_data_; }
SetAsmWasmData(Handle<AsmWasmData> asm_wasm_data)83   void SetAsmWasmData(Handle<AsmWasmData> asm_wasm_data) {
84     asm_wasm_data_ = asm_wasm_data;
85   }
86 
feedback_vector_spec()87   FeedbackVectorSpec* feedback_vector_spec() { return &feedback_vector_spec_; }
88 
89  private:
90   // Compilation flags.
91   const UnoptimizedCompileFlags flags_;
92 
93   // For dispatching eager compilation of lazily compiled functions.
94   LazyCompileDispatcher* dispatcher_;
95   const Utf16CharacterStream* character_stream_;
96 
97   // The root AST node of the function literal being compiled.
98   FunctionLiteral* literal_;
99 
100   // Used when block coverage is enabled.
101   SourceRangeMap* source_range_map_;
102 
103   // Encapsulates coverage information gathered by the bytecode generator.
104   // Needs to be stored on the shared function info once compilation completes.
105   Handle<CoverageInfo> coverage_info_;
106 
107   // Holds the bytecode array generated by the interpreter.
108   Handle<BytecodeArray> bytecode_array_;
109 
110   // Holds the asm_wasm data struct generated by the asmjs compiler.
111   Handle<AsmWasmData> asm_wasm_data_;
112 
113   // Holds the feedback vector spec generated during compilation
114   FeedbackVectorSpec feedback_vector_spec_;
115 };
116 
117 }  // namespace internal
118 }  // namespace v8
119 
120 #endif  // V8_CODEGEN_UNOPTIMIZED_COMPILATION_INFO_H_
121