LCOV - code coverage report
Current view: top level - js/src/jit - ICStubSpace.h (source / functions) Hit Total Coverage
Test: output.info Lines: 19 22 86.4 %
Date: 2017-07-14 16:53:18 Functions: 68 85 80.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
       2             :  * vim: set ts=8 sts=4 et sw=4 tw=99:
       3             :  * This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #ifndef jit_ICStubSpace_h
       8             : #define jit_ICStubSpace_h
       9             : 
      10             : #include "ds/LifoAlloc.h"
      11             : 
      12             : namespace js {
      13             : namespace jit {
      14             : 
      15             : // ICStubSpace is an abstraction for allocation policy and storage for stub data.
      16             : // There are two kinds of stubs: optimized stubs and fallback stubs (the latter
      17             : // also includes stubs that can make non-tail calls that can GC).
      18             : //
      19             : // Optimized stubs are allocated per-compartment and are always purged when
      20             : // JIT-code is discarded. Fallback stubs are allocated per BaselineScript and
      21             : // are only destroyed when the BaselineScript is destroyed.
      22        1187 : class ICStubSpace
      23             : {
      24             :   protected:
      25             :     LifoAlloc allocator_;
      26             : 
      27        1281 :     explicit ICStubSpace(size_t chunkSize)
      28        1281 :       : allocator_(chunkSize)
      29        1281 :     {}
      30             : 
      31             :   public:
      32       50522 :     inline void* alloc(size_t size) {
      33       50522 :         return allocator_.alloc(size);
      34             :     }
      35             : 
      36       44504 :     JS_DECLARE_NEW_METHODS(allocate, alloc, inline)
      37             : 
      38             :     void freeAllAfterMinorGC(JS::Zone* zone);
      39             : 
      40             : #ifdef DEBUG
      41         551 :     bool isEmpty() const {
      42         551 :         return allocator_.isEmpty();
      43             :     }
      44             : #endif
      45             : 
      46           0 :     size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const {
      47           0 :         return allocator_.sizeOfExcludingThis(mallocSizeOf);
      48             :     }
      49             : };
      50             : 
      51             : // Space for optimized stubs. Every JitCompartment has a single
      52             : // OptimizedICStubSpace.
      53           0 : struct OptimizedICStubSpace : public ICStubSpace
      54             : {
      55             :     static const size_t STUB_DEFAULT_CHUNK_SIZE = 4096;
      56             : 
      57             :   public:
      58          13 :     OptimizedICStubSpace()
      59          13 :       : ICStubSpace(STUB_DEFAULT_CHUNK_SIZE)
      60          13 :     {}
      61             : };
      62             : 
      63             : // Space for fallback stubs. Every BaselineScript has a
      64             : // FallbackICStubSpace.
      65        1187 : struct FallbackICStubSpace : public ICStubSpace
      66             : {
      67             :     static const size_t STUB_DEFAULT_CHUNK_SIZE = 4096;
      68             : 
      69             :   public:
      70        1268 :     FallbackICStubSpace()
      71        1268 :       : ICStubSpace(STUB_DEFAULT_CHUNK_SIZE)
      72        1268 :     {}
      73             : 
      74         632 :     inline void adoptFrom(FallbackICStubSpace* other) {
      75         632 :         allocator_.steal(&(other->allocator_));
      76         632 :     }
      77             : };
      78             : 
      79             : } // namespace jit
      80             : } // namespace js
      81             : 
      82             : #endif /* jit_ICStubSpace_h */

Generated by: LCOV version 1.13