11cb0ef41Sopenharmony_ci// Copyright 2018 the V8 project authors. All rights reserved.
21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be
31cb0ef41Sopenharmony_ci// found in the LICENSE file.
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ci#ifndef V8_CODEGEN_UNOPTIMIZED_COMPILATION_INFO_H_
61cb0ef41Sopenharmony_ci#define V8_CODEGEN_UNOPTIMIZED_COMPILATION_INFO_H_
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ci#include <memory>
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_ci#include "src/codegen/source-position-table.h"
111cb0ef41Sopenharmony_ci#include "src/common/globals.h"
121cb0ef41Sopenharmony_ci#include "src/handles/handles.h"
131cb0ef41Sopenharmony_ci#include "src/objects/feedback-vector.h"
141cb0ef41Sopenharmony_ci#include "src/objects/objects.h"
151cb0ef41Sopenharmony_ci#include "src/parsing/parse-info.h"
161cb0ef41Sopenharmony_ci#include "src/utils/utils.h"
171cb0ef41Sopenharmony_ci
181cb0ef41Sopenharmony_cinamespace v8 {
191cb0ef41Sopenharmony_cinamespace internal {
201cb0ef41Sopenharmony_ci
211cb0ef41Sopenharmony_ciclass AsmWasmData;
221cb0ef41Sopenharmony_ciclass CoverageInfo;
231cb0ef41Sopenharmony_ciclass DeclarationScope;
241cb0ef41Sopenharmony_ciclass FunctionLiteral;
251cb0ef41Sopenharmony_ciclass Isolate;
261cb0ef41Sopenharmony_ciclass ParseInfo;
271cb0ef41Sopenharmony_ciclass SourceRangeMap;
281cb0ef41Sopenharmony_ciclass Zone;
291cb0ef41Sopenharmony_ci
301cb0ef41Sopenharmony_ci// UnoptimizedCompilationInfo encapsulates the information needed to compile
311cb0ef41Sopenharmony_ci// unoptimized code for a given function, and the results of the compilation.
321cb0ef41Sopenharmony_ciclass V8_EXPORT_PRIVATE UnoptimizedCompilationInfo final {
331cb0ef41Sopenharmony_ci public:
341cb0ef41Sopenharmony_ci  UnoptimizedCompilationInfo(Zone* zone, ParseInfo* parse_info,
351cb0ef41Sopenharmony_ci                             FunctionLiteral* literal);
361cb0ef41Sopenharmony_ci
371cb0ef41Sopenharmony_ci  const UnoptimizedCompileFlags& flags() const { return flags_; }
381cb0ef41Sopenharmony_ci  LazyCompileDispatcher* dispatcher() { return dispatcher_; }
391cb0ef41Sopenharmony_ci  const Utf16CharacterStream* character_stream() const {
401cb0ef41Sopenharmony_ci    return character_stream_;
411cb0ef41Sopenharmony_ci  }
421cb0ef41Sopenharmony_ci
431cb0ef41Sopenharmony_ci  // Accessors for the input data of the function being compiled.
441cb0ef41Sopenharmony_ci
451cb0ef41Sopenharmony_ci  FunctionLiteral* literal() const { return literal_; }
461cb0ef41Sopenharmony_ci  void set_literal(FunctionLiteral* literal) {
471cb0ef41Sopenharmony_ci    DCHECK_NOT_NULL(literal);
481cb0ef41Sopenharmony_ci    literal_ = literal;
491cb0ef41Sopenharmony_ci  }
501cb0ef41Sopenharmony_ci  void ClearLiteral() { literal_ = nullptr; }
511cb0ef41Sopenharmony_ci
521cb0ef41Sopenharmony_ci  DeclarationScope* scope() const;
531cb0ef41Sopenharmony_ci
541cb0ef41Sopenharmony_ci  int num_parameters() const;
551cb0ef41Sopenharmony_ci  int num_parameters_including_this() const;
561cb0ef41Sopenharmony_ci
571cb0ef41Sopenharmony_ci  // Accessors for optional compilation features.
581cb0ef41Sopenharmony_ci
591cb0ef41Sopenharmony_ci  SourcePositionTableBuilder::RecordingMode SourcePositionRecordingMode() const;
601cb0ef41Sopenharmony_ci
611cb0ef41Sopenharmony_ci  bool has_source_range_map() const { return source_range_map_ != nullptr; }
621cb0ef41Sopenharmony_ci  SourceRangeMap* source_range_map() const { return source_range_map_; }
631cb0ef41Sopenharmony_ci  void set_source_range_map(SourceRangeMap* source_range_map) {
641cb0ef41Sopenharmony_ci    source_range_map_ = source_range_map;
651cb0ef41Sopenharmony_ci  }
661cb0ef41Sopenharmony_ci
671cb0ef41Sopenharmony_ci  bool has_coverage_info() const { return !coverage_info_.is_null(); }
681cb0ef41Sopenharmony_ci  Handle<CoverageInfo> coverage_info() const { return coverage_info_; }
691cb0ef41Sopenharmony_ci  void set_coverage_info(Handle<CoverageInfo> coverage_info) {
701cb0ef41Sopenharmony_ci    coverage_info_ = coverage_info;
711cb0ef41Sopenharmony_ci  }
721cb0ef41Sopenharmony_ci
731cb0ef41Sopenharmony_ci  // Accessors for the output of compilation.
741cb0ef41Sopenharmony_ci
751cb0ef41Sopenharmony_ci  bool has_bytecode_array() const { return !bytecode_array_.is_null(); }
761cb0ef41Sopenharmony_ci  Handle<BytecodeArray> bytecode_array() const { return bytecode_array_; }
771cb0ef41Sopenharmony_ci  void SetBytecodeArray(Handle<BytecodeArray> bytecode_array) {
781cb0ef41Sopenharmony_ci    bytecode_array_ = bytecode_array;
791cb0ef41Sopenharmony_ci  }
801cb0ef41Sopenharmony_ci
811cb0ef41Sopenharmony_ci  bool has_asm_wasm_data() const { return !asm_wasm_data_.is_null(); }
821cb0ef41Sopenharmony_ci  Handle<AsmWasmData> asm_wasm_data() const { return asm_wasm_data_; }
831cb0ef41Sopenharmony_ci  void SetAsmWasmData(Handle<AsmWasmData> asm_wasm_data) {
841cb0ef41Sopenharmony_ci    asm_wasm_data_ = asm_wasm_data;
851cb0ef41Sopenharmony_ci  }
861cb0ef41Sopenharmony_ci
871cb0ef41Sopenharmony_ci  FeedbackVectorSpec* feedback_vector_spec() { return &feedback_vector_spec_; }
881cb0ef41Sopenharmony_ci
891cb0ef41Sopenharmony_ci private:
901cb0ef41Sopenharmony_ci  // Compilation flags.
911cb0ef41Sopenharmony_ci  const UnoptimizedCompileFlags flags_;
921cb0ef41Sopenharmony_ci
931cb0ef41Sopenharmony_ci  // For dispatching eager compilation of lazily compiled functions.
941cb0ef41Sopenharmony_ci  LazyCompileDispatcher* dispatcher_;
951cb0ef41Sopenharmony_ci  const Utf16CharacterStream* character_stream_;
961cb0ef41Sopenharmony_ci
971cb0ef41Sopenharmony_ci  // The root AST node of the function literal being compiled.
981cb0ef41Sopenharmony_ci  FunctionLiteral* literal_;
991cb0ef41Sopenharmony_ci
1001cb0ef41Sopenharmony_ci  // Used when block coverage is enabled.
1011cb0ef41Sopenharmony_ci  SourceRangeMap* source_range_map_;
1021cb0ef41Sopenharmony_ci
1031cb0ef41Sopenharmony_ci  // Encapsulates coverage information gathered by the bytecode generator.
1041cb0ef41Sopenharmony_ci  // Needs to be stored on the shared function info once compilation completes.
1051cb0ef41Sopenharmony_ci  Handle<CoverageInfo> coverage_info_;
1061cb0ef41Sopenharmony_ci
1071cb0ef41Sopenharmony_ci  // Holds the bytecode array generated by the interpreter.
1081cb0ef41Sopenharmony_ci  Handle<BytecodeArray> bytecode_array_;
1091cb0ef41Sopenharmony_ci
1101cb0ef41Sopenharmony_ci  // Holds the asm_wasm data struct generated by the asmjs compiler.
1111cb0ef41Sopenharmony_ci  Handle<AsmWasmData> asm_wasm_data_;
1121cb0ef41Sopenharmony_ci
1131cb0ef41Sopenharmony_ci  // Holds the feedback vector spec generated during compilation
1141cb0ef41Sopenharmony_ci  FeedbackVectorSpec feedback_vector_spec_;
1151cb0ef41Sopenharmony_ci};
1161cb0ef41Sopenharmony_ci
1171cb0ef41Sopenharmony_ci}  // namespace internal
1181cb0ef41Sopenharmony_ci}  // namespace v8
1191cb0ef41Sopenharmony_ci
1201cb0ef41Sopenharmony_ci#endif  // V8_CODEGEN_UNOPTIMIZED_COMPILATION_INFO_H_
121