Kaido Kert | f309f9a | 2021-04-30 12:09:15 -0700 | [diff] [blame] | 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 | |
| 37 | const UnoptimizedCompileFlags& flags() const { return flags_; } |
| 38 | |
| 39 | // Accessors for the input data of the function being compiled. |
| 40 | |
| 41 | FunctionLiteral* literal() const { return literal_; } |
| 42 | void set_literal(FunctionLiteral* literal) { |
| 43 | DCHECK_NOT_NULL(literal); |
| 44 | literal_ = literal; |
| 45 | } |
| 46 | void ClearLiteral() { literal_ = nullptr; } |
| 47 | |
| 48 | DeclarationScope* scope() const; |
| 49 | |
| 50 | int num_parameters() const; |
| 51 | int num_parameters_including_this() const; |
| 52 | |
| 53 | // Accessors for optional compilation features. |
| 54 | |
| 55 | SourcePositionTableBuilder::RecordingMode SourcePositionRecordingMode() const; |
| 56 | |
| 57 | bool has_source_range_map() const { return source_range_map_ != nullptr; } |
| 58 | SourceRangeMap* source_range_map() const { return source_range_map_; } |
| 59 | void set_source_range_map(SourceRangeMap* source_range_map) { |
| 60 | source_range_map_ = source_range_map; |
| 61 | } |
| 62 | |
| 63 | bool has_coverage_info() const { return !coverage_info_.is_null(); } |
| 64 | Handle<CoverageInfo> coverage_info() const { return coverage_info_; } |
| 65 | void set_coverage_info(Handle<CoverageInfo> coverage_info) { |
| 66 | coverage_info_ = coverage_info; |
| 67 | } |
| 68 | |
| 69 | // Accessors for the output of compilation. |
| 70 | |
| 71 | bool has_bytecode_array() const { return !bytecode_array_.is_null(); } |
| 72 | Handle<BytecodeArray> bytecode_array() const { return bytecode_array_; } |
| 73 | void SetBytecodeArray(Handle<BytecodeArray> bytecode_array) { |
| 74 | bytecode_array_ = bytecode_array; |
| 75 | } |
| 76 | |
| 77 | bool has_asm_wasm_data() const { return !asm_wasm_data_.is_null(); } |
| 78 | Handle<AsmWasmData> asm_wasm_data() const { return asm_wasm_data_; } |
| 79 | void SetAsmWasmData(Handle<AsmWasmData> asm_wasm_data) { |
| 80 | asm_wasm_data_ = asm_wasm_data; |
| 81 | } |
| 82 | |
| 83 | FeedbackVectorSpec* feedback_vector_spec() { return &feedback_vector_spec_; } |
| 84 | |
| 85 | private: |
| 86 | // Compilation flags. |
| 87 | const UnoptimizedCompileFlags flags_; |
| 88 | |
| 89 | // The root AST node of the function literal being compiled. |
| 90 | FunctionLiteral* literal_; |
| 91 | |
| 92 | // Used when block coverage is enabled. |
| 93 | SourceRangeMap* source_range_map_; |
| 94 | |
| 95 | // Encapsulates coverage information gathered by the bytecode generator. |
| 96 | // Needs to be stored on the shared function info once compilation completes. |
| 97 | Handle<CoverageInfo> coverage_info_; |
| 98 | |
| 99 | // Holds the bytecode array generated by the interpreter. |
| 100 | Handle<BytecodeArray> bytecode_array_; |
| 101 | |
| 102 | // Holds the asm_wasm data struct generated by the asmjs compiler. |
| 103 | Handle<AsmWasmData> asm_wasm_data_; |
| 104 | |
| 105 | // Holds the feedback vector spec generated during compilation |
| 106 | FeedbackVectorSpec feedback_vector_spec_; |
| 107 | }; |
| 108 | |
| 109 | } // namespace internal |
| 110 | } // namespace v8 |
| 111 | |
| 112 | #endif // V8_CODEGEN_UNOPTIMIZED_COMPILATION_INFO_H_ |