LCOV - code coverage report
Current view: top level - src - code-reference.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 1 31 3.2 %
Date: 2019-02-19 Functions: 2 18 11.1 %

          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             : #include "src/code-reference.h"
       6             : 
       7             : #include "src/code-desc.h"
       8             : #include "src/globals.h"
       9             : #include "src/handles-inl.h"
      10             : #include "src/objects-inl.h"
      11             : #include "src/wasm/wasm-code-manager.h"
      12             : 
      13             : namespace v8 {
      14             : namespace internal {
      15             : 
      16             : namespace {
      17             : struct JSOps {
      18             :   Handle<Code> code;
      19             : 
      20           0 :   Address constant_pool() const { return code->constant_pool(); }
      21           0 :   Address instruction_start() const { return code->InstructionStart(); }
      22           0 :   Address instruction_end() const { return code->InstructionEnd(); }
      23           0 :   int instruction_size() const { return code->InstructionSize(); }
      24           0 :   const byte* relocation_start() const { return code->relocation_start(); }
      25           0 :   const byte* relocation_end() const { return code->relocation_end(); }
      26           0 :   int relocation_size() const { return code->relocation_size(); }
      27           0 :   Address code_comments() const { return code->code_comments(); }
      28             : };
      29             : 
      30             : struct WasmOps {
      31             :   const wasm::WasmCode* code;
      32             : 
      33           0 :   Address constant_pool() const { return code->constant_pool(); }
      34             :   Address instruction_start() const {
      35           0 :     return reinterpret_cast<Address>(code->instructions().start());
      36             :   }
      37             :   Address instruction_end() const {
      38           0 :     return reinterpret_cast<Address>(code->instructions().start() +
      39           0 :                                      code->instructions().size());
      40             :   }
      41             :   int instruction_size() const { return code->instructions().length(); }
      42             :   const byte* relocation_start() const { return code->reloc_info().start(); }
      43             :   const byte* relocation_end() const {
      44           0 :     return code->reloc_info().start() + code->reloc_info().length();
      45             :   }
      46             :   int relocation_size() const { return code->reloc_info().length(); }
      47           0 :   Address code_comments() const { return code->code_comments(); }
      48             : };
      49             : 
      50             : struct CodeDescOps {
      51             :   const CodeDesc* code_desc;
      52             : 
      53             :   Address constant_pool() const {
      54           0 :     return instruction_start() + code_desc->constant_pool_offset;
      55             :   }
      56             :   Address instruction_start() const {
      57           0 :     return reinterpret_cast<Address>(code_desc->buffer);
      58             :   }
      59             :   Address instruction_end() const {
      60           0 :     return instruction_start() + code_desc->instr_size;
      61             :   }
      62           0 :   int instruction_size() const { return code_desc->instr_size; }
      63             :   const byte* relocation_start() const {
      64           0 :     return code_desc->buffer + code_desc->reloc_offset;
      65             :   }
      66             :   const byte* relocation_end() const {
      67           0 :     return code_desc->buffer + code_desc->buffer_size;
      68             :   }
      69           0 :   int relocation_size() const { return code_desc->reloc_size; }
      70             :   Address code_comments() const {
      71           0 :     return instruction_start() + code_desc->code_comments_offset;
      72             :   }
      73             : };
      74             : }  // namespace
      75             : 
      76             : #define DISPATCH(ret, method)                    \
      77             :   ret CodeReference::method() const {            \
      78             :     DCHECK(!is_null());                          \
      79             :     switch (kind_) {                             \
      80             :       case JS:                                   \
      81             :         return JSOps{js_code_}.method();         \
      82             :       case WASM:                                 \
      83             :         return WasmOps{wasm_code_}.method();     \
      84             :       case CODE_DESC:                            \
      85             :         return CodeDescOps{code_desc_}.method(); \
      86             :       default:                                   \
      87             :         UNREACHABLE();                           \
      88             :     }                                            \
      89             :   }
      90             : 
      91           0 : DISPATCH(Address, constant_pool)
      92           0 : DISPATCH(Address, instruction_start)
      93           0 : DISPATCH(Address, instruction_end)
      94           0 : DISPATCH(int, instruction_size)
      95           0 : DISPATCH(const byte*, relocation_start)
      96           0 : DISPATCH(const byte*, relocation_end)
      97           0 : DISPATCH(int, relocation_size)
      98           0 : DISPATCH(Address, code_comments)
      99             : 
     100             : #undef DISPATCH
     101             : 
     102             : }  // namespace internal
     103      178779 : }  // namespace v8

Generated by: LCOV version 1.10