LCOV - code coverage report
Current view: top level - src/wasm - js-to-wasm-wrapper-cache.h (source / functions) Hit Total Coverage
Test: app.info Lines: 6 6 100.0 %
Date: 2019-04-17 Functions: 1 1 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_JS_TO_WASM_WRAPPER_CACHE_H_
       6             : #define V8_WASM_JS_TO_WASM_WRAPPER_CACHE_H_
       7             : 
       8             : #include "src/compiler/wasm-compiler.h"
       9             : #include "src/counters.h"
      10             : #include "src/wasm/value-type.h"
      11             : #include "src/wasm/wasm-code-manager.h"
      12             : 
      13             : namespace v8 {
      14             : namespace internal {
      15             : namespace wasm {
      16             : 
      17      140434 : class JSToWasmWrapperCache {
      18             :  public:
      19      221124 :   Handle<Code> GetOrCompileJSToWasmWrapper(Isolate* isolate, FunctionSig* sig,
      20             :                                            bool is_import) {
      21             :     std::pair<bool, FunctionSig> key(is_import, *sig);
      22             :     Handle<Code>& cached = cache_[key];
      23      221124 :     if (cached.is_null()) {
      24      260988 :       cached = compiler::CompileJSToWasmWrapper(isolate, sig, is_import)
      25      130493 :                    .ToHandleChecked();
      26             :     }
      27      221122 :     return cached;
      28             :   }
      29             : 
      30             :  private:
      31             :   // We generate different code for calling imports than calling wasm functions
      32             :   // in this module. Both are cached separately.
      33             :   using CacheKey = std::pair<bool, FunctionSig>;
      34             :   std::unordered_map<CacheKey, Handle<Code>, base::hash<CacheKey>> cache_;
      35             : };
      36             : 
      37             : }  // namespace wasm
      38             : }  // namespace internal
      39             : }  // namespace v8
      40             : 
      41             : #endif  // V8_WASM_JS_TO_WASM_WRAPPER_CACHE_H_

Generated by: LCOV version 1.10