LCOV - code coverage report
Current view: top level - src/wasm - wasm-import-wrapper-cache.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 16 16 100.0 %
Date: 2019-04-17 Functions: 3 3 100.0 %

          Line data    Source code
       1             : // Copyright 2019 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/wasm/wasm-import-wrapper-cache.h"
       6             : 
       7             : #include <vector>
       8             : 
       9             : #include "src/counters.h"
      10             : #include "src/wasm/wasm-code-manager.h"
      11             : 
      12             : namespace v8 {
      13             : namespace internal {
      14             : namespace wasm {
      15             : 
      16     2485962 : WasmImportWrapperCache::~WasmImportWrapperCache() {
      17             :   std::vector<WasmCode*> ptrs;
      18     1242981 :   ptrs.reserve(entry_map_.size());
      19     1250063 :   for (auto& e : entry_map_) ptrs.push_back(e.second);
      20     1242981 :   WasmCode::DecrementRefCount(VectorOf(ptrs));
      21     1242981 : }
      22             : 
      23       12889 : WasmCode* WasmImportWrapperCache::GetOrCompile(
      24             :     WasmEngine* wasm_engine, Counters* counters,
      25             :     compiler::WasmImportCallKind kind, FunctionSig* sig) {
      26       12889 :   base::MutexGuard lock(&mutex_);
      27             :   CacheKey key(static_cast<uint8_t>(kind), *sig);
      28             :   WasmCode*& cached = entry_map_[key];
      29       12889 :   if (cached == nullptr) {
      30             :     // TODO(wasm): no need to hold the lock while compiling an import wrapper.
      31        7082 :     bool source_positions = native_module_->module()->origin == kAsmJsOrigin;
      32             :     // Keep the {WasmCode} alive until we explicitly call {IncRef}.
      33       14164 :     WasmCodeRefScope code_ref_scope;
      34        7082 :     cached = compiler::CompileWasmImportCallWrapper(
      35        7082 :         wasm_engine, native_module_, kind, sig, source_positions);
      36             :     cached->IncRef();
      37             :     counters->wasm_generated_code_size()->Increment(
      38       14164 :         cached->instructions().length());
      39       14164 :     counters->wasm_reloc_size()->Increment(cached->reloc_info().length());
      40             :   }
      41       25778 :   return cached;
      42             : }
      43             : 
      44             : }  // namespace wasm
      45             : }  // namespace internal
      46      122004 : }  // namespace v8

Generated by: LCOV version 1.10