LCOV - code coverage report
Current view: top level - js/src/gc - ZoneGroup.h (source / functions) Hit Total Coverage
Test: output.info Lines: 8 11 72.7 %
Date: 2017-07-14 16:53:18 Functions: 7 8 87.5 %
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 gc_ZoneGroup_h
       8             : #define gc_ZoneGroup_h
       9             : 
      10             : #include "jsgc.h"
      11             : 
      12             : #include "gc/Statistics.h"
      13             : #include "vm/Caches.h"
      14             : #include "vm/Stack.h"
      15             : 
      16             : namespace js {
      17             : 
      18             : namespace jit { class JitZoneGroup; }
      19             : 
      20             : class AutoKeepAtoms;
      21             : 
      22             : typedef Vector<JS::Zone*, 4, SystemAllocPolicy> ZoneVector;
      23             : 
      24             : // Zone groups encapsulate data about a group of zones that are logically
      25             : // related in some way.
      26             : //
      27             : // Zone groups are the primary means by which threads ensure exclusive access
      28             : // to the data they are using. Most data in a zone group, its zones,
      29             : // compartments, GC things and so forth may only be used by the thread that has
      30             : // entered the zone group.
      31             : 
      32             : class ZoneGroup
      33             : {
      34             :   public:
      35             :     JSRuntime* const runtime;
      36             : 
      37             :   private:
      38             :     // The context with exclusive access to this zone group.
      39             :     UnprotectedData<CooperatingContext> ownerContext_;
      40             : 
      41             :     // The number of times the context has entered this zone group.
      42             :     UnprotectedData<size_t> enterCount;
      43             : 
      44             :     // If this flag is true, then we may need to block before entering this zone
      45             :     // group. Blocking happens using JSContext::yieldToEmbedding.
      46             :     UnprotectedData<bool> useExclusiveLocking;
      47             : 
      48             :   public:
      49     1034383 :     CooperatingContext& ownerContext() { return ownerContext_.ref(); }
      50        3800 :     void* addressOfOwnerContext() { return &ownerContext_.ref().cx; }
      51             : 
      52             :     void enter(JSContext* cx);
      53             :     void leave();
      54             :     bool ownedByCurrentThread();
      55             : 
      56             :     // All zones in the group.
      57             :   private:
      58             :     ZoneGroupOrGCTaskData<ZoneVector> zones_;
      59             :   public:
      60        8169 :     ZoneVector& zones() { return zones_.ref(); }
      61             : 
      62             :     // Whether a zone in this group is in use by a helper thread.
      63             :     mozilla::Atomic<bool> usedByHelperThread;
      64             : 
      65             :     explicit ZoneGroup(JSRuntime* runtime);
      66             :     ~ZoneGroup();
      67             : 
      68             :     bool init();
      69             : 
      70             :     inline Nursery& nursery();
      71             :     inline gc::StoreBuffer& storeBuffer();
      72             : 
      73             :     inline bool isCollecting();
      74             :     inline bool isGCScheduled();
      75             : 
      76             :     // See the useExclusiveLocking field above.
      77           4 :     void setUseExclusiveLocking() { useExclusiveLocking = true; }
      78             : 
      79             : #ifdef DEBUG
      80             :   private:
      81             :     // The number of possible bailing places encounters before forcefully bailing
      82             :     // in that place. Zero means inactive.
      83             :     ZoneGroupData<uint32_t> ionBailAfter_;
      84             : 
      85             :   public:
      86         181 :     void* addressOfIonBailAfter() { return &ionBailAfter_; }
      87             : 
      88             :     // Set after how many bailing places we should forcefully bail.
      89             :     // Zero disables this feature.
      90           0 :     void setIonBailAfter(uint32_t after) {
      91           0 :         ionBailAfter_ = after;
      92           0 :     }
      93             : #endif
      94             : 
      95             :     ZoneGroupData<jit::JitZoneGroup*> jitZoneGroup;
      96             : 
      97             :   private:
      98             :     /* Linked list of all Debugger objects in the group. */
      99             :     ZoneGroupData<mozilla::LinkedList<js::Debugger>> debuggerList_;
     100             :   public:
     101         175 :     mozilla::LinkedList<js::Debugger>& debuggerList() { return debuggerList_.ref(); }
     102             : 
     103             :     // Number of Ion compilations which were finished off thread and are
     104             :     // waiting to be lazily linked. This is only set while holding the helper
     105             :     // thread state lock, but may be read from at other times.
     106             :     mozilla::Atomic<size_t> numFinishedBuilders;
     107             : 
     108             :   private:
     109             :     /* List of Ion compilation waiting to get linked. */
     110             :     typedef mozilla::LinkedList<js::jit::IonBuilder> IonBuilderList;
     111             : 
     112             :     js::HelperThreadLockData<IonBuilderList> ionLazyLinkList_;
     113             :     js::HelperThreadLockData<size_t> ionLazyLinkListSize_;
     114             : 
     115             :   public:
     116             :     IonBuilderList& ionLazyLinkList();
     117             : 
     118           7 :     size_t ionLazyLinkListSize() {
     119           7 :         return ionLazyLinkListSize_;
     120             :     }
     121             : 
     122             :     void ionLazyLinkListRemove(js::jit::IonBuilder* builder);
     123             :     void ionLazyLinkListAdd(js::jit::IonBuilder* builder);
     124             : };
     125             : 
     126             : } // namespace js
     127             : 
     128             : #endif // gc_Zone_h

Generated by: LCOV version 1.13