LCOV - code coverage report
Current view: top level - src/wasm - function-compiler.h (source / functions) Hit Total Coverage
Test: app.info Lines: 4 4 100.0 %
Date: 2019-02-19 Functions: 6 6 100.0 %

          Line data    Source code
       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_WASM_FUNCTION_COMPILER_H_
       6             : #define V8_WASM_FUNCTION_COMPILER_H_
       7             : 
       8             : #include "src/code-desc.h"
       9             : #include "src/trap-handler/trap-handler.h"
      10             : #include "src/wasm/compilation-environment.h"
      11             : #include "src/wasm/function-body-decoder.h"
      12             : #include "src/wasm/wasm-limits.h"
      13             : #include "src/wasm/wasm-module.h"
      14             : #include "src/wasm/wasm-tier.h"
      15             : 
      16             : namespace v8 {
      17             : namespace internal {
      18             : 
      19             : class AssemblerBuffer;
      20             : class Counters;
      21             : 
      22             : namespace compiler {
      23             : class Pipeline;
      24             : class TurbofanWasmCompilationUnit;
      25             : }  // namespace compiler
      26             : 
      27             : namespace wasm {
      28             : 
      29             : class LiftoffCompilationUnit;
      30             : class NativeModule;
      31             : class WasmCode;
      32             : class WasmCompilationUnit;
      33             : class WasmEngine;
      34             : struct WasmFunction;
      35             : 
      36             : class WasmInstructionBuffer final {
      37             :  public:
      38             :   ~WasmInstructionBuffer();
      39             :   std::unique_ptr<AssemblerBuffer> CreateView();
      40             :   std::unique_ptr<uint8_t[]> ReleaseBuffer();
      41             : 
      42             :   static std::unique_ptr<WasmInstructionBuffer> New();
      43             : 
      44             :  private:
      45             :   WasmInstructionBuffer() = delete;
      46             :   DISALLOW_COPY_AND_ASSIGN(WasmInstructionBuffer);
      47             : };
      48             : 
      49    11913305 : struct WasmCompilationResult {
      50             :  public:
      51    10700106 :   MOVE_ONLY_WITH_DEFAULT_CONSTRUCTORS(WasmCompilationResult);
      52             : 
      53       61254 :   explicit WasmCompilationResult(WasmError error) : error(std::move(error)) {}
      54             : 
      55             :   bool succeeded() const {
      56             :     DCHECK_EQ(code_desc.buffer != nullptr, error.empty());
      57             :     return error.empty();
      58             :   }
      59             :   operator bool() const { return succeeded(); }
      60             : 
      61             :   CodeDesc code_desc;
      62             :   std::unique_ptr<uint8_t[]> instr_buffer;
      63             :   uint32_t frame_slot_count = 0;
      64             :   uint32_t tagged_parameter_slots = 0;
      65             :   OwnedVector<byte> source_positions;
      66             :   OwnedVector<trap_handler::ProtectedInstructionData> protected_instructions;
      67             : 
      68             :   WasmError error;
      69             : };
      70             : 
      71     2149587 : class WasmCompilationUnit final {
      72             :  public:
      73             :   static ExecutionTier GetDefaultExecutionTier(const WasmModule*);
      74             : 
      75             :   // If constructing from a background thread, pass in a Counters*, and ensure
      76             :   // that the Counters live at least as long as this compilation unit (which
      77             :   // typically means to hold a std::shared_ptr<Counters>).
      78             :   // If used exclusively from a foreground thread, Isolate::counters() may be
      79             :   // used by callers to pass Counters.
      80             :   WasmCompilationUnit(WasmEngine*, int index, ExecutionTier);
      81             : 
      82             :   ~WasmCompilationUnit();
      83             : 
      84             :   WasmCompilationResult ExecuteCompilation(
      85             :       CompilationEnv*, const std::shared_ptr<WireBytesStorage>&, Counters*,
      86             :       WasmFeatures* detected);
      87             : 
      88             :   WasmCode* Publish(WasmCompilationResult, NativeModule*);
      89             : 
      90             :   ExecutionTier requested_tier() const { return requested_tier_; }
      91             :   ExecutionTier executed_tier() const { return executed_tier_; }
      92             : 
      93             :   static void CompileWasmFunction(Isolate*, NativeModule*,
      94             :                                   WasmFeatures* detected, const WasmFunction*,
      95             :                                   ExecutionTier);
      96             : 
      97             :  private:
      98             :   friend class LiftoffCompilationUnit;
      99             :   friend class compiler::TurbofanWasmCompilationUnit;
     100             : 
     101             :   WasmEngine* const wasm_engine_;
     102             :   const int func_index_;
     103             :   ExecutionTier requested_tier_;
     104             :   ExecutionTier executed_tier_;
     105             : 
     106             :   // LiftoffCompilationUnit, set if {tier_ == kLiftoff}.
     107             :   std::unique_ptr<LiftoffCompilationUnit> liftoff_unit_;
     108             :   // TurbofanWasmCompilationUnit, set if {tier_ == kTurbofan}.
     109             :   std::unique_ptr<compiler::TurbofanWasmCompilationUnit> turbofan_unit_;
     110             : 
     111             :   void SwitchTier(ExecutionTier new_tier);
     112             : 
     113             :   DISALLOW_COPY_AND_ASSIGN(WasmCompilationUnit);
     114             : };
     115             : 
     116             : }  // namespace wasm
     117             : }  // namespace internal
     118             : }  // namespace v8
     119             : 
     120             : #endif  // V8_WASM_FUNCTION_COMPILER_H_

Generated by: LCOV version 1.10