Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/js/GCHashTable.h
Line
Count
Source (jump to first uncovered line)
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 GCHashTable_h
8
#define GCHashTable_h
9
10
#include "mozilla/Maybe.h"
11
12
#include "js/GCPolicyAPI.h"
13
#include "js/HashTable.h"
14
#include "js/RootingAPI.h"
15
#include "js/SweepingAPI.h"
16
#include "js/TracingAPI.h"
17
18
namespace JS {
19
20
// Define a reasonable default GC policy for GC-aware Maps.
21
template <typename Key, typename Value>
22
struct DefaultMapSweepPolicy {
23
177
    static bool needsSweep(Key* key, Value* value) {
24
177
        return GCPolicy<Key>::needsSweep(key) || GCPolicy<Value>::needsSweep(value);
25
177
    }
Unexecuted instantiation: JS::DefaultMapSweepPolicy<JS::Heap<JSObject*>, mozilla::jsipc::ObjectId>::needsSweep(JS::Heap<JSObject*>*, mozilla::jsipc::ObjectId*)
Unexecuted instantiation: JS::DefaultMapSweepPolicy<JS::Heap<JSObject*>, JS::Heap<JSObject*> >::needsSweep(JS::Heap<JSObject*>*, JS::Heap<JSObject*>*)
Unexecuted instantiation: JS::DefaultMapSweepPolicy<js::CrossCompartmentKey, js::detail::UnsafeBareReadBarriered<JS::Value> >::needsSweep(js::CrossCompartmentKey*, js::detail::UnsafeBareReadBarriered<JS::Value>*)
Unexecuted instantiation: JS::DefaultMapSweepPolicy<js::ReadBarriered<JSObject*>, js::LiveEnvironmentVal>::needsSweep(js::ReadBarriered<JSObject*>*, js::LiveEnvironmentVal*)
JS::DefaultMapSweepPolicy<js::ObjectGroupRealm::AllocationSiteKey, js::ReadBarriered<js::ObjectGroup*> >::needsSweep(js::ObjectGroupRealm::AllocationSiteKey*, js::ReadBarriered<js::ObjectGroup*>*)
Line
Count
Source
23
177
    static bool needsSweep(Key* key, Value* value) {
24
177
        return GCPolicy<Key>::needsSweep(key) || GCPolicy<Value>::needsSweep(value);
25
177
    }
Unexecuted instantiation: JS::DefaultMapSweepPolicy<js::ObjectGroupRealm::ArrayObjectKey, js::ReadBarriered<js::ObjectGroup*> >::needsSweep(js::ObjectGroupRealm::ArrayObjectKey*, js::ReadBarriered<js::ObjectGroup*>*)
Unexecuted instantiation: JS::DefaultMapSweepPolicy<js::SavedStacks::PCKey, js::SavedStacks::LocationValue>::needsSweep(js::SavedStacks::PCKey*, js::SavedStacks::LocationValue*)
Unexecuted instantiation: JS::DefaultMapSweepPolicy<unsigned int, js::ReadBarriered<js::WasmFunctionScope*> >::needsSweep(unsigned int*, js::ReadBarriered<js::WasmFunctionScope*>*)
26
};
27
28
// A GCHashMap is a GC-aware HashMap, meaning that it has additional trace and
29
// sweep methods that know how to visit all keys and values in the table.
30
// HashMaps that contain GC pointers will generally want to use this GCHashMap
31
// specialization instead of HashMap, because this conveniently supports tracing
32
// keys and values, and cleaning up weak entries.
33
//
34
// GCHashMap::trace applies GCPolicy<T>::trace to each entry's key and value.
35
// Most types of GC pointers already have appropriate specializations of
36
// GCPolicy, so they should just work as keys and values. Any struct type with a
37
// default constructor and trace and sweep functions should work as well. If you
38
// need to define your own GCPolicy specialization, generic helpers can be found
39
// in js/public/TracingAPI.h.
40
//
41
// The MapSweepPolicy template parameter controls how the table drops entries
42
// when swept. GCHashMap::sweep applies MapSweepPolicy::needsSweep to each table
43
// entry; if it returns true, the entry is dropped. The default MapSweepPolicy
44
// drops the entry if either the key or value is about to be finalized,
45
// according to its GCPolicy<T>::needsSweep method. (This default is almost
46
// always fine: it's hard to imagine keeping such an entry around anyway.)
47
//
48
// Note that this HashMap only knows *how* to trace and sweep, but it does not
49
// itself cause tracing or sweeping to be invoked. For tracing, it must be used
50
// with Rooted or PersistentRooted, or barriered and traced manually. For
51
// sweeping, currently it requires an explicit call to <map>.sweep().
52
template <typename Key,
53
          typename Value,
54
          typename HashPolicy = js::DefaultHasher<Key>,
55
          typename AllocPolicy = js::TempAllocPolicy,
56
          typename MapSweepPolicy = DefaultMapSweepPolicy<Key, Value>>
57
class GCHashMap : public js::HashMap<Key, Value, HashPolicy, AllocPolicy>
58
{
59
    using Base = js::HashMap<Key, Value, HashPolicy, AllocPolicy>;
60
61
  public:
62
52
    explicit GCHashMap(AllocPolicy a = AllocPolicy()) : Base(a)  {}
JS::GCHashMap<RefPtr<mozilla::BasePrincipal>, JS::Heap<JSObject*>, XPCJSRuntime::Hasher, js::SystemAllocPolicy, XPCJSRuntime::SweepPolicy>::GCHashMap(js::SystemAllocPolicy)
Line
Count
Source
62
3
    explicit GCHashMap(AllocPolicy a = AllocPolicy()) : Base(a)  {}
Unexecuted instantiation: JS::GCHashMap<JS::Heap<JSObject*>, RefPtr<nsAtom>, js::MovableCellHasher<JS::Heap<JSObject*> >, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<JS::Heap<JSObject*>, RefPtr<nsAtom> > >::GCHashMap(js::SystemAllocPolicy)
Unexecuted instantiation: JS::GCHashMap<nsJSObjWrapperKey, nsJSObjWrapper*, JSObjWrapperHasher, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<nsJSObjWrapperKey, nsJSObjWrapper*> >::GCHashMap(js::SystemAllocPolicy)
JS::GCHashMap<JSObject*, unsigned int, js::MovableCellHasher<JSObject*>, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<JSObject*, unsigned int> >::GCHashMap(js::SystemAllocPolicy)
Line
Count
Source
62
3
    explicit GCHashMap(AllocPolicy a = AllocPolicy()) : Base(a)  {}
Unexecuted instantiation: JS::GCHashMap<JSAtom*, js::ImportEntryObject*, mozilla::DefaultHasher<JSAtom*>, js::TempAllocPolicy, JS::DefaultMapSweepPolicy<JSAtom*, js::ImportEntryObject*> >::GCHashMap(js::TempAllocPolicy)
JS::GCHashMap<js::gc::Cell*, unsigned long, mozilla::PointerHasher<js::gc::Cell*>, js::SystemAllocPolicy, js::gc::UniqueIdGCPolicy>::GCHashMap(js::SystemAllocPolicy)
Line
Count
Source
62
9
    explicit GCHashMap(AllocPolicy a = AllocPolicy()) : Base(a)  {}
JS::GCHashMap<js::jit::CacheIRStubKey, js::ReadBarriered<js::jit::JitCode*>, js::jit::CacheIRStubKey, js::SystemAllocPolicy, js::jit::IcStubCodeMapGCPolicy<js::jit::CacheIRStubKey> >::GCHashMap(js::SystemAllocPolicy)
Line
Count
Source
62
4
    explicit GCHashMap(AllocPolicy a = AllocPolicy()) : Base(a)  {}
JS::GCHashMap<unsigned int, js::ReadBarriered<js::jit::JitCode*>, mozilla::DefaultHasher<unsigned int>, js::ZoneAllocPolicy, js::jit::IcStubCodeMapGCPolicy<unsigned int> >::GCHashMap(js::ZoneAllocPolicy)
Line
Count
Source
62
4
    explicit GCHashMap(AllocPolicy a = AllocPolicy()) : Base(a)  {}
Unexecuted instantiation: JS::GCHashMap<js::ReadBarriered<JSObject*>, js::LiveEnvironmentVal, js::MovableCellHasher<js::ReadBarriered<JSObject*> >, js::ZoneAllocPolicy, JS::DefaultMapSweepPolicy<js::ReadBarriered<JSObject*>, js::LiveEnvironmentVal> >::GCHashMap(js::ZoneAllocPolicy)
JS::GCHashMap<js::ObjectGroupRealm::ArrayObjectKey, js::ReadBarriered<js::ObjectGroup*>, js::ObjectGroupRealm::ArrayObjectKey, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<js::ObjectGroupRealm::ArrayObjectKey, js::ReadBarriered<js::ObjectGroup*> > >::GCHashMap(js::SystemAllocPolicy)
Line
Count
Source
62
3
    explicit GCHashMap(AllocPolicy a = AllocPolicy()) : Base(a)  {}
JS::GCHashMap<js::ObjectGroupRealm::PlainObjectKey, js::ObjectGroupRealm::PlainObjectEntry, js::ObjectGroupRealm::PlainObjectKey, js::SystemAllocPolicy, js::ObjectGroupRealm::PlainObjectTableSweepPolicy>::GCHashMap(js::SystemAllocPolicy)
Line
Count
Source
62
1
    explicit GCHashMap(AllocPolicy a = AllocPolicy()) : Base(a)  {}
JS::GCHashMap<js::ObjectGroupRealm::AllocationSiteKey, js::ReadBarriered<js::ObjectGroup*>, js::ObjectGroupRealm::AllocationSiteKey, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<js::ObjectGroupRealm::AllocationSiteKey, js::ReadBarriered<js::ObjectGroup*> > >::GCHashMap(js::SystemAllocPolicy)
Line
Count
Source
62
4
    explicit GCHashMap(AllocPolicy a = AllocPolicy()) : Base(a)  {}
JS::GCHashMap<js::SavedStacks::PCKey, js::SavedStacks::LocationValue, js::SavedStacks::PCLocationHasher, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<js::SavedStacks::PCKey, js::SavedStacks::LocationValue> >::GCHashMap(js::SystemAllocPolicy)
Line
Count
Source
62
9
    explicit GCHashMap(AllocPolicy a = AllocPolicy()) : Base(a)  {}
JS::GCHashMap<JSObject*, mozilla::Vector<js::ArrayBufferViewObject*, 1ul, js::SystemAllocPolicy>, js::MovableCellHasher<JSObject*>, js::SystemAllocPolicy, js::InnerViewTable::MapGCPolicy>::GCHashMap(js::SystemAllocPolicy)
Line
Count
Source
62
9
    explicit GCHashMap(AllocPolicy a = AllocPolicy()) : Base(a)  {}
JS::GCHashMap<JSAtom*, JSAtom*, js::intl::SharedIntlData::TimeZoneHasher, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<JSAtom*, JSAtom*> >::GCHashMap(js::SystemAllocPolicy)
Line
Count
Source
62
3
    explicit GCHashMap(AllocPolicy a = AllocPolicy()) : Base(a)  {}
Unexecuted instantiation: JS::GCHashMap<unsigned int, js::HeapPtr<JSFunction*>, mozilla::DefaultHasher<unsigned int>, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<unsigned int, js::HeapPtr<JSFunction*> > >::GCHashMap(js::SystemAllocPolicy)
Unexecuted instantiation: JS::GCHashMap<unsigned int, js::ReadBarriered<js::WasmFunctionScope*>, mozilla::DefaultHasher<unsigned int>, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<unsigned int, js::ReadBarriered<js::WasmFunctionScope*> > >::GCHashMap(js::SystemAllocPolicy)
63
9
    explicit GCHashMap(size_t length) : Base(length)  {}
Unexecuted instantiation: JS::GCHashMap<JS::Heap<JSObject*>, JS::Heap<JSObject*>, js::MovableCellHasher<JS::Heap<JSObject*> >, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<JS::Heap<JSObject*>, JS::Heap<JSObject*> > >::GCHashMap(unsigned long)
Unexecuted instantiation: JS::GCHashMap<js::HeapPtr<JSFlatString*>, js::ctypes::FieldInfo, js::ctypes::FieldHashPolicy, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<js::HeapPtr<JSFlatString*>, js::ctypes::FieldInfo> >::GCHashMap(unsigned long)
JS::GCHashMap<JS::Compartment*, js::NurseryAwareHashMap<js::CrossCompartmentKey, JS::Value, js::CrossCompartmentKey::Hasher, js::SystemAllocPolicy>, mozilla::DefaultHasher<JS::Compartment*>, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<JS::Compartment*, js::NurseryAwareHashMap<js::CrossCompartmentKey, JS::Value, js::CrossCompartmentKey::Hasher, js::SystemAllocPolicy> > >::GCHashMap(unsigned long)
Line
Count
Source
63
9
    explicit GCHashMap(size_t length) : Base(length)  {}
Unexecuted instantiation: JS::GCHashMap<js::CrossCompartmentKey, js::detail::UnsafeBareReadBarriered<JS::Value>, js::CrossCompartmentKey::Hasher, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<js::CrossCompartmentKey, js::detail::UnsafeBareReadBarriered<JS::Value> > >::GCHashMap(unsigned long)
64
0
    GCHashMap(AllocPolicy a, size_t length) : Base(a, length)  {}
65
66
    static void trace(GCHashMap* map, JSTracer* trc) { map->trace(trc); }
67
54
    void trace(JSTracer* trc) {
68
54
        for (typename Base::Enum e(*this); !e.empty(); e.popFront()) {
69
0
            GCPolicy<Value>::trace(trc, &e.front().value(), "hashmap value");
70
0
            GCPolicy<Key>::trace(trc, &e.front().mutableKey(), "hashmap key");
71
0
        }
72
54
    }
Unexecuted instantiation: JS::GCHashMap<JS::Heap<JSObject*>, mozilla::jsipc::ObjectId, js::MovableCellHasher<JS::Heap<JSObject*> >, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<JS::Heap<JSObject*>, mozilla::jsipc::ObjectId> >::trace(JSTracer*)
Unexecuted instantiation: JS::GCHashMap<nsJSObjWrapperKey, nsJSObjWrapper*, JSObjWrapperHasher, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<nsJSObjWrapperKey, nsJSObjWrapper*> >::trace(JSTracer*)
Unexecuted instantiation: JS::GCHashMap<js::HeapPtr<JSFlatString*>, js::ctypes::FieldInfo, js::ctypes::FieldHashPolicy, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<js::HeapPtr<JSFlatString*>, js::ctypes::FieldInfo> >::trace(JSTracer*)
Unexecuted instantiation: JS::GCHashMap<JSObject*, unsigned int, js::MovableCellHasher<JSObject*>, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<JSObject*, unsigned int> >::trace(JSTracer*)
Unexecuted instantiation: JS::GCHashMap<JSAtom*, js::ImportEntryObject*, mozilla::DefaultHasher<JSAtom*>, js::TempAllocPolicy, JS::DefaultMapSweepPolicy<JSAtom*, js::ImportEntryObject*> >::trace(JSTracer*)
JS::GCHashMap<js::SavedStacks::PCKey, js::SavedStacks::LocationValue, js::SavedStacks::PCLocationHasher, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<js::SavedStacks::PCKey, js::SavedStacks::LocationValue> >::trace(JSTracer*)
Line
Count
Source
67
36
    void trace(JSTracer* trc) {
68
36
        for (typename Base::Enum e(*this); !e.empty(); e.popFront()) {
69
0
            GCPolicy<Value>::trace(trc, &e.front().value(), "hashmap value");
70
0
            GCPolicy<Key>::trace(trc, &e.front().mutableKey(), "hashmap key");
71
0
        }
72
36
    }
JS::GCHashMap<JSAtom*, JSAtom*, js::intl::SharedIntlData::TimeZoneHasher, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<JSAtom*, JSAtom*> >::trace(JSTracer*)
Line
Count
Source
67
18
    void trace(JSTracer* trc) {
68
18
        for (typename Base::Enum e(*this); !e.empty(); e.popFront()) {
69
0
            GCPolicy<Value>::trace(trc, &e.front().value(), "hashmap value");
70
0
            GCPolicy<Key>::trace(trc, &e.front().mutableKey(), "hashmap key");
71
0
        }
72
18
    }
Unexecuted instantiation: JS::GCHashMap<unsigned int, js::HeapPtr<JSFunction*>, mozilla::DefaultHasher<unsigned int>, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<unsigned int, js::HeapPtr<JSFunction*> > >::trace(JSTracer*)
73
74
54
    bool needsSweep() const {
75
54
        return !this->empty();
76
54
    }
JS::GCHashMap<JSObject*, mozilla::Vector<js::ArrayBufferViewObject*, 1ul, js::SystemAllocPolicy>, js::MovableCellHasher<JSObject*>, js::SystemAllocPolicy, js::InnerViewTable::MapGCPolicy>::needsSweep() const
Line
Count
Source
74
36
    bool needsSweep() const {
75
36
        return !this->empty();
76
36
    }
JS::GCHashMap<js::ObjectGroupRealm::AllocationSiteKey, js::ReadBarriered<js::ObjectGroup*>, js::ObjectGroupRealm::AllocationSiteKey, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<js::ObjectGroupRealm::AllocationSiteKey, js::ReadBarriered<js::ObjectGroup*> > >::needsSweep() const
Line
Count
Source
74
18
    bool needsSweep() const {
75
18
        return !this->empty();
76
18
    }
Unexecuted instantiation: JS::GCHashMap<unsigned int, js::ReadBarriered<js::WasmFunctionScope*>, mozilla::DefaultHasher<unsigned int>, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<unsigned int, js::ReadBarriered<js::WasmFunctionScope*> > >::needsSweep() const
77
78
144
    void sweep() {
79
1.63M
        for (typename Base::Enum e(*this); !e.empty(); e.popFront()) {
80
1.63M
            if (MapSweepPolicy::needsSweep(&e.front().mutableKey(), &e.front().value())) {
81
1.55M
                e.removeFront();
82
1.55M
            }
83
1.63M
        }
84
144
    }
Unexecuted instantiation: JS::GCHashMap<JS::Heap<JSObject*>, mozilla::jsipc::ObjectId, js::MovableCellHasher<JS::Heap<JSObject*> >, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<JS::Heap<JSObject*>, mozilla::jsipc::ObjectId> >::sweep()
Unexecuted instantiation: JS::GCHashMap<JS::Heap<JSObject*>, JS::Heap<JSObject*>, js::MovableCellHasher<JS::Heap<JSObject*> >, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<JS::Heap<JSObject*>, JS::Heap<JSObject*> > >::sweep()
JS::GCHashMap<RefPtr<mozilla::BasePrincipal>, JS::Heap<JSObject*>, XPCJSRuntime::Hasher, js::SystemAllocPolicy, XPCJSRuntime::SweepPolicy>::sweep()
Line
Count
Source
78
18
    void sweep() {
79
18
        for (typename Base::Enum e(*this); !e.empty(); e.popFront()) {
80
0
            if (MapSweepPolicy::needsSweep(&e.front().mutableKey(), &e.front().value())) {
81
0
                e.removeFront();
82
0
            }
83
0
        }
84
18
    }
JS::GCHashMap<unsigned int, js::ReadBarriered<js::jit::JitCode*>, mozilla::DefaultHasher<unsigned int>, js::ZoneAllocPolicy, js::jit::IcStubCodeMapGCPolicy<unsigned int> >::sweep()
Line
Count
Source
78
18
    void sweep() {
79
222
        for (typename Base::Enum e(*this); !e.empty(); e.popFront()) {
80
204
            if (MapSweepPolicy::needsSweep(&e.front().mutableKey(), &e.front().value())) {
81
24
                e.removeFront();
82
24
            }
83
204
        }
84
18
    }
JS::GCHashMap<js::jit::CacheIRStubKey, js::ReadBarriered<js::jit::JitCode*>, js::jit::CacheIRStubKey, js::SystemAllocPolicy, js::jit::IcStubCodeMapGCPolicy<js::jit::CacheIRStubKey> >::sweep()
Line
Count
Source
78
18
    void sweep() {
79
103
        for (typename Base::Enum e(*this); !e.empty(); e.popFront()) {
80
85
            if (MapSweepPolicy::needsSweep(&e.front().mutableKey(), &e.front().value())) {
81
31
                e.removeFront();
82
31
            }
83
85
        }
84
18
    }
Unexecuted instantiation: JS::GCHashMap<JSObject*, mozilla::Vector<js::ArrayBufferViewObject*, 1ul, js::SystemAllocPolicy>, js::MovableCellHasher<JSObject*>, js::SystemAllocPolicy, js::InnerViewTable::MapGCPolicy>::sweep()
Unexecuted instantiation: JS::GCHashMap<js::ReadBarriered<JSObject*>, js::LiveEnvironmentVal, js::MovableCellHasher<js::ReadBarriered<JSObject*> >, js::ZoneAllocPolicy, JS::DefaultMapSweepPolicy<js::ReadBarriered<JSObject*>, js::LiveEnvironmentVal> >::sweep()
JS::GCHashMap<js::ObjectGroupRealm::AllocationSiteKey, js::ReadBarriered<js::ObjectGroup*>, js::ObjectGroupRealm::AllocationSiteKey, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<js::ObjectGroupRealm::AllocationSiteKey, js::ReadBarriered<js::ObjectGroup*> > >::sweep()
Line
Count
Source
78
18
    void sweep() {
79
195
        for (typename Base::Enum e(*this); !e.empty(); e.popFront()) {
80
177
            if (MapSweepPolicy::needsSweep(&e.front().mutableKey(), &e.front().value())) {
81
51
                e.removeFront();
82
51
            }
83
177
        }
84
18
    }
JS::GCHashMap<js::ObjectGroupRealm::PlainObjectKey, js::ObjectGroupRealm::PlainObjectEntry, js::ObjectGroupRealm::PlainObjectKey, js::SystemAllocPolicy, js::ObjectGroupRealm::PlainObjectTableSweepPolicy>::sweep()
Line
Count
Source
78
18
    void sweep() {
79
36
        for (typename Base::Enum e(*this); !e.empty(); e.popFront()) {
80
18
            if (MapSweepPolicy::needsSweep(&e.front().mutableKey(), &e.front().value())) {
81
0
                e.removeFront();
82
0
            }
83
18
        }
84
18
    }
JS::GCHashMap<js::SavedStacks::PCKey, js::SavedStacks::LocationValue, js::SavedStacks::PCLocationHasher, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<js::SavedStacks::PCKey, js::SavedStacks::LocationValue> >::sweep()
Line
Count
Source
78
36
    void sweep() {
79
36
        for (typename Base::Enum e(*this); !e.empty(); e.popFront()) {
80
0
            if (MapSweepPolicy::needsSweep(&e.front().mutableKey(), &e.front().value())) {
81
0
                e.removeFront();
82
0
            }
83
0
        }
84
36
    }
Unexecuted instantiation: JS::GCHashMap<unsigned int, js::ReadBarriered<js::WasmFunctionScope*>, mozilla::DefaultHasher<unsigned int>, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<unsigned int, js::ReadBarriered<js::WasmFunctionScope*> > >::sweep()
JS::GCHashMap<js::gc::Cell*, unsigned long, mozilla::PointerHasher<js::gc::Cell*>, js::SystemAllocPolicy, js::gc::UniqueIdGCPolicy>::sweep()
Line
Count
Source
78
18
    void sweep() {
79
1.63M
        for (typename Base::Enum e(*this); !e.empty(); e.popFront()) {
80
1.63M
            if (MapSweepPolicy::needsSweep(&e.front().mutableKey(), &e.front().value())) {
81
1.55M
                e.removeFront();
82
1.55M
            }
83
1.63M
        }
84
18
    }
85
86
    // GCHashMap is movable
87
3
    GCHashMap(GCHashMap&& rhs) : Base(std::move(rhs)) {}
Unexecuted instantiation: JS::GCHashMap<js::HeapPtr<JSFlatString*>, js::ctypes::FieldInfo, js::ctypes::FieldHashPolicy, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<js::HeapPtr<JSFlatString*>, js::ctypes::FieldInfo> >::GCHashMap(JS::GCHashMap<js::HeapPtr<JSFlatString*>, js::ctypes::FieldInfo, js::ctypes::FieldHashPolicy, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<js::HeapPtr<JSFlatString*>, js::ctypes::FieldInfo> >&&)
JS::GCHashMap<JSObject*, unsigned int, js::MovableCellHasher<JSObject*>, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<JSObject*, unsigned int> >::GCHashMap(JS::GCHashMap<JSObject*, unsigned int, js::MovableCellHasher<JSObject*>, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<JSObject*, unsigned int> >&&)
Line
Count
Source
87
3
    GCHashMap(GCHashMap&& rhs) : Base(std::move(rhs)) {}
Unexecuted instantiation: JS::GCHashMap<JSAtom*, js::ImportEntryObject*, mozilla::DefaultHasher<JSAtom*>, js::TempAllocPolicy, JS::DefaultMapSweepPolicy<JSAtom*, js::ImportEntryObject*> >::GCHashMap(JS::GCHashMap<JSAtom*, js::ImportEntryObject*, mozilla::DefaultHasher<JSAtom*>, js::TempAllocPolicy, JS::DefaultMapSweepPolicy<JSAtom*, js::ImportEntryObject*> >&&)
Unexecuted instantiation: JS::GCHashMap<js::CrossCompartmentKey, js::detail::UnsafeBareReadBarriered<JS::Value>, js::CrossCompartmentKey::Hasher, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<js::CrossCompartmentKey, js::detail::UnsafeBareReadBarriered<JS::Value> > >::GCHashMap(JS::GCHashMap<js::CrossCompartmentKey, js::detail::UnsafeBareReadBarriered<JS::Value>, js::CrossCompartmentKey::Hasher, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<js::CrossCompartmentKey, js::detail::UnsafeBareReadBarriered<JS::Value> > >&&)
88
0
    void operator=(GCHashMap&& rhs) {
89
0
        MOZ_ASSERT(this != &rhs, "self-move assignment is prohibited");
90
0
        Base::operator=(std::move(rhs));
91
0
    }
92
93
  private:
94
    // GCHashMap is not copyable or assignable
95
    GCHashMap(const GCHashMap& hm) = delete;
96
    GCHashMap& operator=(const GCHashMap& hm) = delete;
97
};
98
99
} // namespace JS
100
101
namespace js {
102
103
// HashMap that supports rekeying.
104
//
105
// If your keys are pointers to something like JSObject that can be tenured or
106
// compacted, prefer to use GCHashMap with MovableCellHasher, which takes
107
// advantage of the Zone's stable id table to make rekeying unnecessary.
108
template <typename Key,
109
          typename Value,
110
          typename HashPolicy = DefaultHasher<Key>,
111
          typename AllocPolicy = TempAllocPolicy,
112
          typename MapSweepPolicy = JS::DefaultMapSweepPolicy<Key, Value>>
113
class GCRekeyableHashMap : public JS::GCHashMap<Key, Value, HashPolicy, AllocPolicy, MapSweepPolicy>
114
{
115
    using Base = JS::GCHashMap<Key, Value, HashPolicy, AllocPolicy>;
116
117
  public:
118
3
    explicit GCRekeyableHashMap(AllocPolicy a = AllocPolicy()) : Base(a) {}
119
0
    explicit GCRekeyableHashMap(size_t length) : Base(length) {}
120
    GCRekeyableHashMap(AllocPolicy a, size_t length) : Base(a, length) {}
121
122
0
    void sweep() {
123
0
        for (typename Base::Enum e(*this); !e.empty(); e.popFront()) {
124
0
            Key key(e.front().key());
125
0
            if (MapSweepPolicy::needsSweep(&key, &e.front().value())) {
126
0
                e.removeFront();
127
0
            } else if (!HashPolicy::match(key, e.front().key())) {
128
0
                e.rekeyFront(key);
129
0
            }
130
0
        }
131
0
    }
Unexecuted instantiation: js::GCRekeyableHashMap<js::CrossCompartmentKey, js::detail::UnsafeBareReadBarriered<JS::Value>, js::CrossCompartmentKey::Hasher, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<js::CrossCompartmentKey, js::detail::UnsafeBareReadBarriered<JS::Value> > >::sweep()
Unexecuted instantiation: js::GCRekeyableHashMap<js::ObjectGroupRealm::ArrayObjectKey, js::ReadBarriered<js::ObjectGroup*>, js::ObjectGroupRealm::ArrayObjectKey, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<js::ObjectGroupRealm::ArrayObjectKey, js::ReadBarriered<js::ObjectGroup*> > >::sweep()
132
133
    // GCRekeyableHashMap is movable
134
0
    GCRekeyableHashMap(GCRekeyableHashMap&& rhs) : Base(std::move(rhs)) {}
135
0
    void operator=(GCRekeyableHashMap&& rhs) {
136
0
        MOZ_ASSERT(this != &rhs, "self-move assignment is prohibited");
137
0
        Base::operator=(std::move(rhs));
138
0
    }
139
};
140
141
template <typename Wrapper, typename... Args>
142
class WrappedPtrOperations<JS::GCHashMap<Args...>, Wrapper>
143
{
144
    using Map = JS::GCHashMap<Args...>;
145
    using Lookup = typename Map::Lookup;
146
147
0
    const Map& map() const { return static_cast<const Wrapper*>(this)->get(); }
Unexecuted instantiation: js::WrappedPtrOperations<JS::GCHashMap<JSObject*, unsigned int, js::MovableCellHasher<JSObject*>, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<JSObject*, unsigned int> >, JS::Rooted<JS::GCHashMap<JSObject*, unsigned int, js::MovableCellHasher<JSObject*>, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<JSObject*, unsigned int> > > >::map() const
Unexecuted instantiation: js::WrappedPtrOperations<JS::GCHashMap<JSAtom*, js::ImportEntryObject*, mozilla::DefaultHasher<JSAtom*>, js::TempAllocPolicy, JS::DefaultMapSweepPolicy<JSAtom*, js::ImportEntryObject*> >, JS::Rooted<JS::GCHashMap<JSAtom*, js::ImportEntryObject*, mozilla::DefaultHasher<JSAtom*>, js::TempAllocPolicy, JS::DefaultMapSweepPolicy<JSAtom*, js::ImportEntryObject*> > > >::map() const
148
149
  public:
150
    using AddPtr = typename Map::AddPtr;
151
    using Ptr = typename Map::Ptr;
152
    using Range = typename Map::Range;
153
154
0
    Ptr lookup(const Lookup& l) const          { return map().lookup(l); }
Unexecuted instantiation: js::WrappedPtrOperations<JS::GCHashMap<JSObject*, unsigned int, js::MovableCellHasher<JSObject*>, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<JSObject*, unsigned int> >, JS::Rooted<JS::GCHashMap<JSObject*, unsigned int, js::MovableCellHasher<JSObject*>, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<JSObject*, unsigned int> > > >::lookup(JSObject* const&) const
Unexecuted instantiation: js::WrappedPtrOperations<JS::GCHashMap<JSAtom*, js::ImportEntryObject*, mozilla::DefaultHasher<JSAtom*>, js::TempAllocPolicy, JS::DefaultMapSweepPolicy<JSAtom*, js::ImportEntryObject*> >, JS::Rooted<JS::GCHashMap<JSAtom*, js::ImportEntryObject*, mozilla::DefaultHasher<JSAtom*>, js::TempAllocPolicy, JS::DefaultMapSweepPolicy<JSAtom*, js::ImportEntryObject*> > > >::lookup(JSAtom* const&) const
155
0
    Range all() const                          { return map().all(); }
156
    bool empty() const                         { return map().empty(); }
157
0
    uint32_t count() const                     { return map().count(); }
Unexecuted instantiation: js::WrappedPtrOperations<JS::GCHashMap<JSObject*, unsigned int, js::MovableCellHasher<JSObject*>, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<JSObject*, unsigned int> >, JS::Rooted<JS::GCHashMap<JSObject*, unsigned int, js::MovableCellHasher<JSObject*>, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<JSObject*, unsigned int> > > >::count() const
Unexecuted instantiation: js::WrappedPtrOperations<JS::GCHashMap<JSAtom*, js::ImportEntryObject*, mozilla::DefaultHasher<JSAtom*>, js::TempAllocPolicy, JS::DefaultMapSweepPolicy<JSAtom*, js::ImportEntryObject*> >, JS::Rooted<JS::GCHashMap<JSAtom*, js::ImportEntryObject*, mozilla::DefaultHasher<JSAtom*>, js::TempAllocPolicy, JS::DefaultMapSweepPolicy<JSAtom*, js::ImportEntryObject*> > > >::count() const
158
    size_t capacity() const                    { return map().capacity(); }
159
    bool has(const Lookup& l) const            { return map().lookup(l).found(); }
160
    size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const {
161
        return map().sizeOfExcludingThis(mallocSizeOf);
162
    }
163
    size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const {
164
        return mallocSizeOf(this) + map().sizeOfExcludingThis(mallocSizeOf);
165
    }
166
};
167
168
template <typename Wrapper, typename... Args>
169
class MutableWrappedPtrOperations<JS::GCHashMap<Args...>, Wrapper>
170
  : public WrappedPtrOperations<JS::GCHashMap<Args...>, Wrapper>
171
{
172
    using Map = JS::GCHashMap<Args...>;
173
    using Lookup = typename Map::Lookup;
174
175
3
    Map& map() { return static_cast<Wrapper*>(this)->get(); }
Unexecuted instantiation: js::MutableWrappedPtrOperations<JS::GCHashMap<js::HeapPtr<JSFlatString*>, js::ctypes::FieldInfo, js::ctypes::FieldHashPolicy, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<js::HeapPtr<JSFlatString*>, js::ctypes::FieldInfo> >, JS::Rooted<JS::GCHashMap<js::HeapPtr<JSFlatString*>, js::ctypes::FieldInfo, js::ctypes::FieldHashPolicy, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<js::HeapPtr<JSFlatString*>, js::ctypes::FieldInfo> > > >::map()
js::MutableWrappedPtrOperations<JS::GCHashMap<JSObject*, unsigned int, js::MovableCellHasher<JSObject*>, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<JSObject*, unsigned int> >, JS::Rooted<JS::GCHashMap<JSObject*, unsigned int, js::MovableCellHasher<JSObject*>, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<JSObject*, unsigned int> > > >::map()
Line
Count
Source
175
3
    Map& map() { return static_cast<Wrapper*>(this)->get(); }
Unexecuted instantiation: js::MutableWrappedPtrOperations<JS::GCHashMap<JSAtom*, js::ImportEntryObject*, mozilla::DefaultHasher<JSAtom*>, js::TempAllocPolicy, JS::DefaultMapSweepPolicy<JSAtom*, js::ImportEntryObject*> >, JS::Rooted<JS::GCHashMap<JSAtom*, js::ImportEntryObject*, mozilla::DefaultHasher<JSAtom*>, js::TempAllocPolicy, JS::DefaultMapSweepPolicy<JSAtom*, js::ImportEntryObject*> > > >::map()
176
177
  public:
178
    using AddPtr = typename Map::AddPtr;
179
    struct Enum : public Map::Enum { explicit Enum(Wrapper& o) : Map::Enum(o.map()) {} };
180
    using Ptr = typename Map::Ptr;
181
    using Range = typename Map::Range;
182
183
3
    void clear()                 { map().clear(); }
184
    void clearAndCompact()       { map().clearAndCompact(); }
185
0
    void remove(Ptr p)           { map().remove(p); }
186
0
    AddPtr lookupForAdd(const Lookup& l) { return map().lookupForAdd(l); }
Unexecuted instantiation: js::MutableWrappedPtrOperations<JS::GCHashMap<js::HeapPtr<JSFlatString*>, js::ctypes::FieldInfo, js::ctypes::FieldHashPolicy, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<js::HeapPtr<JSFlatString*>, js::ctypes::FieldInfo> >, JS::Rooted<JS::GCHashMap<js::HeapPtr<JSFlatString*>, js::ctypes::FieldInfo, js::ctypes::FieldHashPolicy, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<js::HeapPtr<JSFlatString*>, js::ctypes::FieldInfo> > > >::lookupForAdd(JSFlatString* const&)
Unexecuted instantiation: js::MutableWrappedPtrOperations<JS::GCHashMap<JSObject*, unsigned int, js::MovableCellHasher<JSObject*>, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<JSObject*, unsigned int> >, JS::Rooted<JS::GCHashMap<JSObject*, unsigned int, js::MovableCellHasher<JSObject*>, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<JSObject*, unsigned int> > > >::lookupForAdd(JSObject* const&)
187
188
    template<typename KeyInput, typename ValueInput>
189
0
    bool add(AddPtr& p, KeyInput&& k, ValueInput&& v) {
190
0
        return map().add(p, std::forward<KeyInput>(k), std::forward<ValueInput>(v));
191
0
    }
Unexecuted instantiation: bool js::MutableWrappedPtrOperations<JS::GCHashMap<js::HeapPtr<JSFlatString*>, js::ctypes::FieldInfo, js::ctypes::FieldHashPolicy, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<js::HeapPtr<JSFlatString*>, js::ctypes::FieldInfo> >, JS::Rooted<JS::GCHashMap<js::HeapPtr<JSFlatString*>, js::ctypes::FieldInfo, js::ctypes::FieldHashPolicy, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<js::HeapPtr<JSFlatString*>, js::ctypes::FieldInfo> > > >::add<JS::Rooted<JSFlatString*>&, js::ctypes::FieldInfo&>(mozilla::detail::HashTable<mozilla::HashMapEntry<js::HeapPtr<JSFlatString*>, js::ctypes::FieldInfo>, mozilla::HashMap<js::HeapPtr<JSFlatString*>, js::ctypes::FieldInfo, js::ctypes::FieldHashPolicy, js::SystemAllocPolicy>::MapHashPolicy, js::SystemAllocPolicy>::AddPtr&, JS::Rooted<JSFlatString*>&, js::ctypes::FieldInfo&)
Unexecuted instantiation: bool js::MutableWrappedPtrOperations<JS::GCHashMap<JSObject*, unsigned int, js::MovableCellHasher<JSObject*>, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<JSObject*, unsigned int> >, JS::Rooted<JS::GCHashMap<JSObject*, unsigned int, js::MovableCellHasher<JSObject*>, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<JSObject*, unsigned int> > > >::add<JS::Handle<JSObject*>&, unsigned int>(mozilla::detail::HashTable<mozilla::HashMapEntry<JSObject*, unsigned int>, mozilla::HashMap<JSObject*, unsigned int, js::MovableCellHasher<JSObject*>, js::SystemAllocPolicy>::MapHashPolicy, js::SystemAllocPolicy>::AddPtr&, JS::Handle<JSObject*>&, unsigned int&&)
192
193
    template<typename KeyInput>
194
    bool add(AddPtr& p, KeyInput&& k) {
195
        return map().add(p, std::forward<KeyInput>(k), Map::Value());
196
    }
197
198
    template<typename KeyInput, typename ValueInput>
199
    bool relookupOrAdd(AddPtr& p, KeyInput&& k, ValueInput&& v) {
200
        return map().relookupOrAdd(p, k,
201
                                   std::forward<KeyInput>(k),
202
                                   std::forward<ValueInput>(v));
203
    }
204
205
    template<typename KeyInput, typename ValueInput>
206
0
    bool put(KeyInput&& k, ValueInput&& v) {
207
0
        return map().put(std::forward<KeyInput>(k), std::forward<ValueInput>(v));
208
0
    }
Unexecuted instantiation: bool js::MutableWrappedPtrOperations<JS::GCHashMap<JSObject*, unsigned int, js::MovableCellHasher<JSObject*>, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<JSObject*, unsigned int> >, JS::Rooted<JS::GCHashMap<JSObject*, unsigned int, js::MovableCellHasher<JSObject*>, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<JSObject*, unsigned int> > > >::put<JS::Rooted<JSObject*>&, unsigned int>(JS::Rooted<JSObject*>&, unsigned int&&)
Unexecuted instantiation: bool js::MutableWrappedPtrOperations<JS::GCHashMap<JSAtom*, js::ImportEntryObject*, mozilla::DefaultHasher<JSAtom*>, js::TempAllocPolicy, JS::DefaultMapSweepPolicy<JSAtom*, js::ImportEntryObject*> >, JS::Rooted<JS::GCHashMap<JSAtom*, js::ImportEntryObject*, mozilla::DefaultHasher<JSAtom*>, js::TempAllocPolicy, JS::DefaultMapSweepPolicy<JSAtom*, js::ImportEntryObject*> > > >::put<JSAtom*, JS::Handle<js::ImportEntryObject*>&>(JSAtom*&&, JS::Handle<js::ImportEntryObject*>&)
209
210
    template<typename KeyInput, typename ValueInput>
211
    bool putNew(KeyInput&& k, ValueInput&& v) {
212
        return map().putNew(std::forward<KeyInput>(k), std::forward<ValueInput>(v));
213
    }
214
};
215
216
} // namespace js
217
218
namespace JS {
219
220
// A GCHashSet is a HashSet with an additional trace method that knows
221
// be traced to be kept alive will generally want to use this GCHashSet
222
// specialization in lieu of HashSet.
223
//
224
// Most types of GC pointers can be traced with no extra infrastructure. For
225
// structs and non-gc-pointer members, ensure that there is a specialization of
226
// GCPolicy<T> with an appropriate trace method available to handle the custom
227
// type. Generic helpers can be found in js/public/TracingAPI.h.
228
//
229
// Note that although this HashSet's trace will deal correctly with moved
230
// elements, it does not itself know when to barrier or trace elements. To
231
// function properly it must either be used with Rooted or barriered and traced
232
// manually.
233
template <typename T,
234
          typename HashPolicy = js::DefaultHasher<T>,
235
          typename AllocPolicy = js::TempAllocPolicy>
236
class GCHashSet : public js::HashSet<T, HashPolicy, AllocPolicy>
237
{
238
    using Base = js::HashSet<T, HashPolicy, AllocPolicy>;
239
240
  public:
241
99
    explicit GCHashSet(AllocPolicy a = AllocPolicy()) : Base(a)  {}
JS::GCHashSet<JSObject*, JSStructuredCloneWriter::TransferableObjectsHasher, js::TempAllocPolicy>::GCHashSet(js::TempAllocPolicy)
Line
Count
Source
241
3
    explicit GCHashSet(AllocPolicy a = AllocPolicy()) : Base(a)  {}
Unexecuted instantiation: JS::GCHashSet<JSAtom*, mozilla::DefaultHasher<JSAtom*>, js::TempAllocPolicy>::GCHashSet(js::TempAllocPolicy)
JS::GCHashSet<JSObject*, js::MovableCellHasher<JSObject*>, js::SystemAllocPolicy>::GCHashSet(js::SystemAllocPolicy)
Line
Count
Source
241
9
    explicit GCHashSet(AllocPolicy a = AllocPolicy()) : Base(a)  {}
JS::GCHashSet<js::AtomStateEntry, js::AtomHasher, js::SystemAllocPolicy>::GCHashSet(js::SystemAllocPolicy)
Line
Count
Source
241
9
    explicit GCHashSet(AllocPolicy a = AllocPolicy()) : Base(a)  {}
JS::GCHashSet<js::ReadBarriered<js::UnownedBaseShape*>, js::StackBaseShape, js::SystemAllocPolicy>::GCHashSet(js::SystemAllocPolicy)
Line
Count
Source
241
9
    explicit GCHashSet(AllocPolicy a = AllocPolicy()) : Base(a)  {}
JS::GCHashSet<js::InitialShapeEntry, js::InitialShapeEntry, js::SystemAllocPolicy>::GCHashSet(js::SystemAllocPolicy)
Line
Count
Source
241
9
    explicit GCHashSet(AllocPolicy a = AllocPolicy()) : Base(a)  {}
Unexecuted instantiation: JS::GCHashSet<JSObject*, js::MovableCellHasher<JSObject*>, js::ZoneAllocPolicy>::GCHashSet(js::ZoneAllocPolicy)
JS::GCHashSet<js::ObjectGroupRealm::NewEntry, js::ObjectGroupRealm::NewEntry, js::SystemAllocPolicy>::GCHashSet(js::SystemAllocPolicy)
Line
Count
Source
241
18
    explicit GCHashSet(AllocPolicy a = AllocPolicy()) : Base(a)  {}
JS::GCHashSet<js::ReadBarriered<js::SavedFrame*>, js::SavedFrame::HashPolicy, js::SystemAllocPolicy>::GCHashSet(js::SystemAllocPolicy)
Line
Count
Source
241
9
    explicit GCHashSet(AllocPolicy a = AllocPolicy()) : Base(a)  {}
JS::GCHashSet<JSAtom*, mozilla::DefaultHasher<JSAtom*>, js::SystemAllocPolicy>::GCHashSet(js::SystemAllocPolicy)
Line
Count
Source
241
9
    explicit GCHashSet(AllocPolicy a = AllocPolicy()) : Base(a)  {}
JS::GCHashSet<js::ReadBarriered<js::RegExpShared*>, js::RegExpZone::Key, js::ZoneAllocPolicy>::GCHashSet(js::ZoneAllocPolicy)
Line
Count
Source
241
9
    explicit GCHashSet(AllocPolicy a = AllocPolicy()) : Base(a)  {}
JS::GCHashSet<js::ReadBarriered<JS::Symbol*>, js::HashSymbolsByDescription, js::SystemAllocPolicy>::GCHashSet(js::SystemAllocPolicy)
Line
Count
Source
241
3
    explicit GCHashSet(AllocPolicy a = AllocPolicy()) : Base(a)  {}
JS::GCHashSet<JSAtom*, js::intl::SharedIntlData::TimeZoneHasher, js::SystemAllocPolicy>::GCHashSet(js::SystemAllocPolicy)
Line
Count
Source
241
6
    explicit GCHashSet(AllocPolicy a = AllocPolicy()) : Base(a)  {}
JS::GCHashSet<JSAtom*, js::intl::SharedIntlData::LocaleHasher, js::SystemAllocPolicy>::GCHashSet(js::SystemAllocPolicy)
Line
Count
Source
241
3
    explicit GCHashSet(AllocPolicy a = AllocPolicy()) : Base(a)  {}
JS::GCHashSet<js::EvalCacheEntry, js::EvalCacheHashPolicy, js::SystemAllocPolicy>::GCHashSet(js::SystemAllocPolicy)
Line
Count
Source
241
3
    explicit GCHashSet(AllocPolicy a = AllocPolicy()) : Base(a)  {}
Unexecuted instantiation: JS::GCHashSet<js::ReadBarriered<js::WasmInstanceObject*>, js::MovableCellHasher<js::ReadBarriered<js::WasmInstanceObject*> >, js::SystemAllocPolicy>::GCHashSet(js::SystemAllocPolicy)
242
99
    explicit GCHashSet(size_t length) : Base(length)  {}
243
0
    GCHashSet(AllocPolicy a, size_t length) : Base(a, length)  {}
244
245
    static void trace(GCHashSet* set, JSTracer* trc) { set->trace(trc); }
246
90
    void trace(JSTracer* trc) {
247
90
        for (typename Base::Enum e(*this); !e.empty(); e.popFront()) {
248
0
            GCPolicy<T>::trace(trc, &e.mutableFront(), "hashset element");
249
0
        }
250
90
    }
Unexecuted instantiation: JS::GCHashSet<JSObject*, JSStructuredCloneWriter::TransferableObjectsHasher, js::TempAllocPolicy>::trace(JSTracer*)
Unexecuted instantiation: JS::GCHashSet<jsid, mozilla::DefaultHasher<jsid>, js::TempAllocPolicy>::trace(JSTracer*)
Unexecuted instantiation: JS::GCHashSet<JSAtom*, mozilla::DefaultHasher<JSAtom*>, js::TempAllocPolicy>::trace(JSTracer*)
Unexecuted instantiation: JS::GCHashSet<JSObject*, js::MovableCellHasher<JSObject*>, js::ZoneAllocPolicy>::trace(JSTracer*)
JS::GCHashSet<JSAtom*, mozilla::DefaultHasher<JSAtom*>, js::SystemAllocPolicy>::trace(JSTracer*)
Line
Count
Source
246
36
    void trace(JSTracer* trc) {
247
36
        for (typename Base::Enum e(*this); !e.empty(); e.popFront()) {
248
0
            GCPolicy<T>::trace(trc, &e.mutableFront(), "hashset element");
249
0
        }
250
36
    }
JS::GCHashSet<JSAtom*, js::intl::SharedIntlData::TimeZoneHasher, js::SystemAllocPolicy>::trace(JSTracer*)
Line
Count
Source
246
36
    void trace(JSTracer* trc) {
247
36
        for (typename Base::Enum e(*this); !e.empty(); e.popFront()) {
248
0
            GCPolicy<T>::trace(trc, &e.mutableFront(), "hashset element");
249
0
        }
250
36
    }
JS::GCHashSet<JSAtom*, js::intl::SharedIntlData::LocaleHasher, js::SystemAllocPolicy>::trace(JSTracer*)
Line
Count
Source
246
18
    void trace(JSTracer* trc) {
247
18
        for (typename Base::Enum e(*this); !e.empty(); e.popFront()) {
248
0
            GCPolicy<T>::trace(trc, &e.mutableFront(), "hashset element");
249
0
        }
250
18
    }
251
252
144
    bool needsSweep() const {
253
144
        return !this->empty();
254
144
    }
JS::GCHashSet<js::ReadBarriered<js::RegExpShared*>, js::RegExpZone::Key, js::ZoneAllocPolicy>::needsSweep() const
Line
Count
Source
252
18
    bool needsSweep() const {
253
18
        return !this->empty();
254
18
    }
JS::GCHashSet<js::InitialShapeEntry, js::InitialShapeEntry, js::SystemAllocPolicy>::needsSweep() const
Line
Count
Source
252
18
    bool needsSweep() const {
253
18
        return !this->empty();
254
18
    }
JS::GCHashSet<js::ReadBarriered<js::UnownedBaseShape*>, js::StackBaseShape, js::SystemAllocPolicy>::needsSweep() const
Line
Count
Source
252
18
    bool needsSweep() const {
253
18
        return !this->empty();
254
18
    }
JS::GCHashSet<JSObject*, js::MovableCellHasher<JSObject*>, js::SystemAllocPolicy>::needsSweep() const
Line
Count
Source
252
18
    bool needsSweep() const {
253
18
        return !this->empty();
254
18
    }
JS::GCHashSet<js::ObjectGroupRealm::NewEntry, js::ObjectGroupRealm::NewEntry, js::SystemAllocPolicy>::needsSweep() const
Line
Count
Source
252
72
    bool needsSweep() const {
253
72
        return !this->empty();
254
72
    }
Unexecuted instantiation: JS::GCHashSet<js::ReadBarriered<js::WasmInstanceObject*>, js::MovableCellHasher<js::ReadBarriered<js::WasmInstanceObject*> >, js::SystemAllocPolicy>::needsSweep() const
255
256
145
    void sweep() {
257
3.26M
        for (typename Base::Enum e(*this); !e.empty(); e.popFront()) {
258
3.26M
            if (GCPolicy<T>::needsSweep(&e.mutableFront())) {
259
3.11M
                e.removeFront();
260
3.11M
            }
261
3.26M
        }
262
145
    }
JS::GCHashSet<js::EvalCacheEntry, js::EvalCacheHashPolicy, js::SystemAllocPolicy>::sweep()
Line
Count
Source
256
1
    void sweep() {
257
1
        for (typename Base::Enum e(*this); !e.empty(); e.popFront()) {
258
0
            if (GCPolicy<T>::needsSweep(&e.mutableFront())) {
259
0
                e.removeFront();
260
0
            }
261
0
        }
262
1
    }
Unexecuted instantiation: JS::GCHashSet<js::ReadBarriered<js::RegExpShared*>, js::RegExpZone::Key, js::ZoneAllocPolicy>::sweep()
JS::GCHashSet<js::InitialShapeEntry, js::InitialShapeEntry, js::SystemAllocPolicy>::sweep()
Line
Count
Source
256
18
    void sweep() {
257
1.63M
        for (typename Base::Enum e(*this); !e.empty(); e.popFront()) {
258
1.63M
            if (GCPolicy<T>::needsSweep(&e.mutableFront())) {
259
1.55M
                e.removeFront();
260
1.55M
            }
261
1.63M
        }
262
18
    }
JS::GCHashSet<js::ReadBarriered<js::UnownedBaseShape*>, js::StackBaseShape, js::SystemAllocPolicy>::sweep()
Line
Count
Source
256
18
    void sweep() {
257
715
        for (typename Base::Enum e(*this); !e.empty(); e.popFront()) {
258
697
            if (GCPolicy<T>::needsSweep(&e.mutableFront())) {
259
13
                e.removeFront();
260
13
            }
261
697
        }
262
18
    }
Unexecuted instantiation: JS::GCHashSet<JSObject*, js::MovableCellHasher<JSObject*>, js::SystemAllocPolicy>::sweep()
JS::GCHashSet<js::ObjectGroupRealm::NewEntry, js::ObjectGroupRealm::NewEntry, js::SystemAllocPolicy>::sweep()
Line
Count
Source
256
72
    void sweep() {
257
1.63M
        for (typename Base::Enum e(*this); !e.empty(); e.popFront()) {
258
1.63M
            if (GCPolicy<T>::needsSweep(&e.mutableFront())) {
259
1.55M
                e.removeFront();
260
1.55M
            }
261
1.63M
        }
262
72
    }
Unexecuted instantiation: JS::GCHashSet<JSAtom*, mozilla::DefaultHasher<JSAtom*>, js::SystemAllocPolicy>::sweep()
JS::GCHashSet<js::ReadBarriered<js::SavedFrame*>, js::SavedFrame::HashPolicy, js::SystemAllocPolicy>::sweep()
Line
Count
Source
256
36
    void sweep() {
257
36
        for (typename Base::Enum e(*this); !e.empty(); e.popFront()) {
258
0
            if (GCPolicy<T>::needsSweep(&e.mutableFront())) {
259
0
                e.removeFront();
260
0
            }
261
0
        }
262
36
    }
Unexecuted instantiation: JS::GCHashSet<js::ReadBarriered<js::WasmInstanceObject*>, js::MovableCellHasher<js::ReadBarriered<js::WasmInstanceObject*> >, js::SystemAllocPolicy>::sweep()
Unexecuted instantiation: JS::GCHashSet<js::ReadBarriered<JS::Symbol*>, js::HashSymbolsByDescription, js::SystemAllocPolicy>::sweep()
263
264
    // GCHashSet is movable
265
3
    GCHashSet(GCHashSet&& rhs) : Base(std::move(rhs)) {}
JS::GCHashSet<JSObject*, JSStructuredCloneWriter::TransferableObjectsHasher, js::TempAllocPolicy>::GCHashSet(JS::GCHashSet<JSObject*, JSStructuredCloneWriter::TransferableObjectsHasher, js::TempAllocPolicy>&&)
Line
Count
Source
265
3
    GCHashSet(GCHashSet&& rhs) : Base(std::move(rhs)) {}
Unexecuted instantiation: JS::GCHashSet<jsid, mozilla::DefaultHasher<jsid>, js::TempAllocPolicy>::GCHashSet(JS::GCHashSet<jsid, mozilla::DefaultHasher<jsid>, js::TempAllocPolicy>&&)
Unexecuted instantiation: JS::GCHashSet<JSAtom*, mozilla::DefaultHasher<JSAtom*>, js::TempAllocPolicy>::GCHashSet(JS::GCHashSet<JSAtom*, mozilla::DefaultHasher<JSAtom*>, js::TempAllocPolicy>&&)
Unexecuted instantiation: JS::GCHashSet<JSObject*, js::MovableCellHasher<JSObject*>, js::ZoneAllocPolicy>::GCHashSet(JS::GCHashSet<JSObject*, js::MovableCellHasher<JSObject*>, js::ZoneAllocPolicy>&&)
266
    void operator=(GCHashSet&& rhs) {
267
        MOZ_ASSERT(this != &rhs, "self-move assignment is prohibited");
268
        Base::operator=(std::move(rhs));
269
    }
270
271
  private:
272
    // GCHashSet is not copyable or assignable
273
    GCHashSet(const GCHashSet& hs) = delete;
274
    GCHashSet& operator=(const GCHashSet& hs) = delete;
275
};
276
277
} // namespace JS
278
279
namespace js {
280
281
template <typename Wrapper, typename... Args>
282
class WrappedPtrOperations<JS::GCHashSet<Args...>, Wrapper>
283
{
284
    using Set = JS::GCHashSet<Args...>;
285
286
6
    const Set& set() const { return static_cast<const Wrapper*>(this)->get(); }
js::WrappedPtrOperations<JS::GCHashSet<JSObject*, JSStructuredCloneWriter::TransferableObjectsHasher, js::TempAllocPolicy>, JS::Rooted<JS::GCHashSet<JSObject*, JSStructuredCloneWriter::TransferableObjectsHasher, js::TempAllocPolicy> > >::set() const
Line
Count
Source
286
6
    const Set& set() const { return static_cast<const Wrapper*>(this)->get(); }
Unexecuted instantiation: js::WrappedPtrOperations<JS::GCHashSet<JSAtom*, mozilla::DefaultHasher<JSAtom*>, js::TempAllocPolicy>, JS::Rooted<JS::GCHashSet<JSAtom*, mozilla::DefaultHasher<JSAtom*>, js::TempAllocPolicy> > >::set() const
Unexecuted instantiation: js::WrappedPtrOperations<JS::GCHashSet<jsid, mozilla::DefaultHasher<jsid>, js::TempAllocPolicy>, JS::Rooted<JS::GCHashSet<jsid, mozilla::DefaultHasher<jsid>, js::TempAllocPolicy> > >::set() const
Unexecuted instantiation: js::WrappedPtrOperations<JS::GCHashSet<JSObject*, js::MovableCellHasher<JSObject*>, js::ZoneAllocPolicy>, JS::Handle<JS::GCHashSet<JSObject*, js::MovableCellHasher<JSObject*>, js::ZoneAllocPolicy> > >::set() const
287
288
  public:
289
    using Lookup = typename Set::Lookup;
290
    using AddPtr = typename Set::AddPtr;
291
    using Entry = typename Set::Entry;
292
    using Ptr = typename Set::Ptr;
293
    using Range = typename Set::Range;
294
295
0
    Ptr lookup(const Lookup& l) const          { return set().lookup(l); }
296
0
    Range all() const                          { return set().all(); }
Unexecuted instantiation: js::WrappedPtrOperations<JS::GCHashSet<JSObject*, JSStructuredCloneWriter::TransferableObjectsHasher, js::TempAllocPolicy>, JS::Rooted<JS::GCHashSet<JSObject*, JSStructuredCloneWriter::TransferableObjectsHasher, js::TempAllocPolicy> > >::all() const
Unexecuted instantiation: js::WrappedPtrOperations<JS::GCHashSet<jsid, mozilla::DefaultHasher<jsid>, js::TempAllocPolicy>, JS::Rooted<JS::GCHashSet<jsid, mozilla::DefaultHasher<jsid>, js::TempAllocPolicy> > >::all() const
297
6
    bool empty() const                         { return set().empty(); }
js::WrappedPtrOperations<JS::GCHashSet<JSObject*, JSStructuredCloneWriter::TransferableObjectsHasher, js::TempAllocPolicy>, JS::Rooted<JS::GCHashSet<JSObject*, JSStructuredCloneWriter::TransferableObjectsHasher, js::TempAllocPolicy> > >::empty() const
Line
Count
Source
297
6
    bool empty() const                         { return set().empty(); }
Unexecuted instantiation: js::WrappedPtrOperations<JS::GCHashSet<jsid, mozilla::DefaultHasher<jsid>, js::TempAllocPolicy>, JS::Rooted<JS::GCHashSet<jsid, mozilla::DefaultHasher<jsid>, js::TempAllocPolicy> > >::empty() const
298
0
    uint32_t count() const                     { return set().count(); }
Unexecuted instantiation: js::WrappedPtrOperations<JS::GCHashSet<JSObject*, JSStructuredCloneWriter::TransferableObjectsHasher, js::TempAllocPolicy>, JS::Rooted<JS::GCHashSet<JSObject*, JSStructuredCloneWriter::TransferableObjectsHasher, js::TempAllocPolicy> > >::count() const
Unexecuted instantiation: js::WrappedPtrOperations<JS::GCHashSet<JSObject*, js::MovableCellHasher<JSObject*>, js::ZoneAllocPolicy>, JS::Handle<JS::GCHashSet<JSObject*, js::MovableCellHasher<JSObject*>, js::ZoneAllocPolicy> > >::count() const
299
    size_t capacity() const                    { return set().capacity(); }
300
0
    bool has(const Lookup& l) const            { return set().lookup(l).found(); }
301
    size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const {
302
        return set().sizeOfExcludingThis(mallocSizeOf);
303
    }
304
    size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const {
305
        return mallocSizeOf(this) + set().sizeOfExcludingThis(mallocSizeOf);
306
    }
307
};
308
309
template <typename Wrapper, typename... Args>
310
class MutableWrappedPtrOperations<JS::GCHashSet<Args...>, Wrapper>
311
  : public WrappedPtrOperations<JS::GCHashSet<Args...>, Wrapper>
312
{
313
    using Set = JS::GCHashSet<Args...>;
314
    using Lookup = typename Set::Lookup;
315
316
0
    Set& set() { return static_cast<Wrapper*>(this)->get(); }
Unexecuted instantiation: js::MutableWrappedPtrOperations<JS::GCHashSet<JSObject*, JSStructuredCloneWriter::TransferableObjectsHasher, js::TempAllocPolicy>, JS::Rooted<JS::GCHashSet<JSObject*, JSStructuredCloneWriter::TransferableObjectsHasher, js::TempAllocPolicy> > >::set()
Unexecuted instantiation: js::MutableWrappedPtrOperations<JS::GCHashSet<jsid, mozilla::DefaultHasher<jsid>, js::TempAllocPolicy>, JS::Rooted<JS::GCHashSet<jsid, mozilla::DefaultHasher<jsid>, js::TempAllocPolicy> > >::set()
Unexecuted instantiation: js::MutableWrappedPtrOperations<JS::GCHashSet<JSAtom*, mozilla::DefaultHasher<JSAtom*>, js::TempAllocPolicy>, JS::Rooted<JS::GCHashSet<JSAtom*, mozilla::DefaultHasher<JSAtom*>, js::TempAllocPolicy> > >::set()
Unexecuted instantiation: js::MutableWrappedPtrOperations<JS::GCHashSet<JSObject*, js::MovableCellHasher<JSObject*>, js::ZoneAllocPolicy>, JS::Rooted<JS::GCHashSet<JSObject*, js::MovableCellHasher<JSObject*>, js::ZoneAllocPolicy> > >::set()
317
318
  public:
319
    using AddPtr = typename Set::AddPtr;
320
    using Entry = typename Set::Entry;
321
    struct Enum : public Set::Enum { explicit Enum(Wrapper& o) : Set::Enum(o.set()) {} };
322
    using Ptr = typename Set::Ptr;
323
    using Range = typename Set::Range;
324
325
    void clear()                 { set().clear(); }
326
    void clearAndCompact()       { set().clearAndCompact(); }
327
0
    MOZ_MUST_USE bool reserve(uint32_t len) { return set().reserve(len); }
328
0
    void remove(Ptr p)           { set().remove(p); }
329
    void remove(const Lookup& l) { set().remove(l); }
330
0
    AddPtr lookupForAdd(const Lookup& l) { return set().lookupForAdd(l); }
Unexecuted instantiation: js::MutableWrappedPtrOperations<JS::GCHashSet<JSObject*, JSStructuredCloneWriter::TransferableObjectsHasher, js::TempAllocPolicy>, JS::Rooted<JS::GCHashSet<JSObject*, JSStructuredCloneWriter::TransferableObjectsHasher, js::TempAllocPolicy> > >::lookupForAdd(JSObject* const&)
Unexecuted instantiation: js::MutableWrappedPtrOperations<JS::GCHashSet<jsid, mozilla::DefaultHasher<jsid>, js::TempAllocPolicy>, JS::Rooted<JS::GCHashSet<jsid, mozilla::DefaultHasher<jsid>, js::TempAllocPolicy> > >::lookupForAdd(jsid const&)
331
332
    template<typename TInput>
333
0
    bool add(AddPtr& p, TInput&& t) {
334
0
        return set().add(p, std::forward<TInput>(t));
335
0
    }
Unexecuted instantiation: bool js::MutableWrappedPtrOperations<JS::GCHashSet<JSObject*, JSStructuredCloneWriter::TransferableObjectsHasher, js::TempAllocPolicy>, JS::Rooted<JS::GCHashSet<JSObject*, JSStructuredCloneWriter::TransferableObjectsHasher, js::TempAllocPolicy> > >::add<JS::Rooted<JSObject*>&>(mozilla::detail::HashTable<JSObject* const, mozilla::HashSet<JSObject*, JSStructuredCloneWriter::TransferableObjectsHasher, js::TempAllocPolicy>::SetHashPolicy, js::TempAllocPolicy>::AddPtr&, JS::Rooted<JSObject*>&)
Unexecuted instantiation: bool js::MutableWrappedPtrOperations<JS::GCHashSet<jsid, mozilla::DefaultHasher<jsid>, js::TempAllocPolicy>, JS::Rooted<JS::GCHashSet<jsid, mozilla::DefaultHasher<jsid>, js::TempAllocPolicy> > >::add<JS::Rooted<jsid>&>(mozilla::detail::HashTable<jsid const, mozilla::HashSet<jsid, mozilla::DefaultHasher<jsid>, js::TempAllocPolicy>::SetHashPolicy, js::TempAllocPolicy>::AddPtr&, JS::Rooted<jsid>&)
Unexecuted instantiation: bool js::MutableWrappedPtrOperations<JS::GCHashSet<jsid, mozilla::DefaultHasher<jsid>, js::TempAllocPolicy>, JS::Rooted<JS::GCHashSet<jsid, mozilla::DefaultHasher<jsid>, js::TempAllocPolicy> > >::add<JS::MutableHandle<jsid> >(mozilla::detail::HashTable<jsid const, mozilla::HashSet<jsid, mozilla::DefaultHasher<jsid>, js::TempAllocPolicy>::SetHashPolicy, js::TempAllocPolicy>::AddPtr&, JS::MutableHandle<jsid>&&)
336
337
    template<typename TInput>
338
    bool relookupOrAdd(AddPtr& p, const Lookup& l, TInput&& t) {
339
        return set().relookupOrAdd(p, l, std::forward<TInput>(t));
340
    }
341
342
    template<typename TInput>
343
0
    bool put(TInput&& t) {
344
0
        return set().put(std::forward<TInput>(t));
345
0
    }
Unexecuted instantiation: bool js::MutableWrappedPtrOperations<JS::GCHashSet<JSAtom*, mozilla::DefaultHasher<JSAtom*>, js::TempAllocPolicy>, JS::Rooted<JS::GCHashSet<JSAtom*, mozilla::DefaultHasher<JSAtom*>, js::TempAllocPolicy> > >::put<JSAtom*&>(JSAtom*&)
Unexecuted instantiation: bool js::MutableWrappedPtrOperations<JS::GCHashSet<JSAtom*, mozilla::DefaultHasher<JSAtom*>, js::TempAllocPolicy>, JS::Rooted<JS::GCHashSet<JSAtom*, mozilla::DefaultHasher<JSAtom*>, js::TempAllocPolicy> > >::put<JS::Handle<JSAtom*>&>(JS::Handle<JSAtom*>&)
Unexecuted instantiation: bool js::MutableWrappedPtrOperations<JS::GCHashSet<JSObject*, js::MovableCellHasher<JSObject*>, js::ZoneAllocPolicy>, JS::Rooted<JS::GCHashSet<JSObject*, js::MovableCellHasher<JSObject*>, js::ZoneAllocPolicy> > >::put<js::ScriptSourceObject*&>(js::ScriptSourceObject*&)
Unexecuted instantiation: bool js::MutableWrappedPtrOperations<JS::GCHashSet<JSObject*, js::MovableCellHasher<JSObject*>, js::ZoneAllocPolicy>, JS::Rooted<JS::GCHashSet<JSObject*, js::MovableCellHasher<JSObject*>, js::ZoneAllocPolicy> > >::put<js::WasmInstanceObject*&>(js::WasmInstanceObject*&)
346
347
    template<typename TInput>
348
    bool putNew(TInput&& t) {
349
        return set().putNew(std::forward<TInput>(t));
350
    }
351
352
    template<typename TInput>
353
    bool putNew(const Lookup& l, TInput&& t) {
354
        return set().putNew(l, std::forward<TInput>(t));
355
    }
356
};
357
358
} /* namespace js */
359
360
namespace JS {
361
362
// Specialize WeakCache for GCHashMap to provide a barriered map that does not
363
// need to be swept immediately.
364
template <typename Key, typename Value,
365
          typename HashPolicy, typename AllocPolicy, typename MapSweepPolicy>
366
class WeakCache<GCHashMap<Key, Value, HashPolicy, AllocPolicy, MapSweepPolicy>>
367
  : protected detail::WeakCacheBase
368
{
369
    using Map = GCHashMap<Key, Value, HashPolicy, AllocPolicy, MapSweepPolicy>;
370
    using Self = WeakCache<Map>;
371
372
    Map map;
373
    bool needsBarrier;
374
375
  public:
376
    template <typename... Args>
377
    explicit WeakCache(Zone* zone, Args&&... args)
378
      : WeakCacheBase(zone), map(std::forward<Args>(args)...), needsBarrier(false)
379
4
    {}
JS::WeakCache<JS::GCHashMap<js::ObjectGroupRealm::AllocationSiteKey, js::ReadBarriered<js::ObjectGroup*>, js::ObjectGroupRealm::AllocationSiteKey, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<js::ObjectGroupRealm::AllocationSiteKey, js::ReadBarriered<js::ObjectGroup*> > > >::WeakCache<>(JS::Zone*)
Line
Count
Source
379
4
    {}
Unexecuted instantiation: JS::WeakCache<JS::GCHashMap<unsigned int, js::ReadBarriered<js::WasmFunctionScope*>, mozilla::DefaultHasher<unsigned int>, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<unsigned int, js::ReadBarriered<js::WasmFunctionScope*> > > >::WeakCache<>(JS::Zone*)
380
    template <typename... Args>
381
    explicit WeakCache(JSRuntime* rt, Args&&... args)
382
      : WeakCacheBase(rt), map(std::forward<Args>(args)...), needsBarrier(false)
383
    {}
384
0
    ~WeakCache() {
385
0
        MOZ_ASSERT(!needsBarrier);
386
0
    }
Unexecuted instantiation: JS::WeakCache<JS::GCHashMap<js::ObjectGroupRealm::AllocationSiteKey, js::ReadBarriered<js::ObjectGroup*>, js::ObjectGroupRealm::AllocationSiteKey, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<js::ObjectGroupRealm::AllocationSiteKey, js::ReadBarriered<js::ObjectGroup*> > > >::~WeakCache()
Unexecuted instantiation: JS::WeakCache<JS::GCHashMap<unsigned int, js::ReadBarriered<js::WasmFunctionScope*>, mozilla::DefaultHasher<unsigned int>, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<unsigned int, js::ReadBarriered<js::WasmFunctionScope*> > > >::~WeakCache()
387
388
18
    bool needsSweep() override {
389
18
        return map.needsSweep();
390
18
    }
JS::WeakCache<JS::GCHashMap<js::ObjectGroupRealm::AllocationSiteKey, js::ReadBarriered<js::ObjectGroup*>, js::ObjectGroupRealm::AllocationSiteKey, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<js::ObjectGroupRealm::AllocationSiteKey, js::ReadBarriered<js::ObjectGroup*> > > >::needsSweep()
Line
Count
Source
388
18
    bool needsSweep() override {
389
18
        return map.needsSweep();
390
18
    }
Unexecuted instantiation: JS::WeakCache<JS::GCHashMap<unsigned int, js::ReadBarriered<js::WasmFunctionScope*>, mozilla::DefaultHasher<unsigned int>, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<unsigned int, js::ReadBarriered<js::WasmFunctionScope*> > > >::needsSweep()
391
392
18
    size_t sweep() override {
393
18
        size_t steps = map.count();
394
18
        map.sweep();
395
18
        return steps;
396
18
    }
JS::WeakCache<JS::GCHashMap<js::ObjectGroupRealm::AllocationSiteKey, js::ReadBarriered<js::ObjectGroup*>, js::ObjectGroupRealm::AllocationSiteKey, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<js::ObjectGroupRealm::AllocationSiteKey, js::ReadBarriered<js::ObjectGroup*> > > >::sweep()
Line
Count
Source
392
18
    size_t sweep() override {
393
18
        size_t steps = map.count();
394
18
        map.sweep();
395
18
        return steps;
396
18
    }
Unexecuted instantiation: JS::WeakCache<JS::GCHashMap<unsigned int, js::ReadBarriered<js::WasmFunctionScope*>, mozilla::DefaultHasher<unsigned int>, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<unsigned int, js::ReadBarriered<js::WasmFunctionScope*> > > >::sweep()
397
398
36
    bool setNeedsIncrementalBarrier(bool needs) override {
399
36
        MOZ_ASSERT(needsBarrier != needs);
400
36
        needsBarrier = needs;
401
36
        return true;
402
36
    }
JS::WeakCache<JS::GCHashMap<js::ObjectGroupRealm::AllocationSiteKey, js::ReadBarriered<js::ObjectGroup*>, js::ObjectGroupRealm::AllocationSiteKey, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<js::ObjectGroupRealm::AllocationSiteKey, js::ReadBarriered<js::ObjectGroup*> > > >::setNeedsIncrementalBarrier(bool)
Line
Count
Source
398
36
    bool setNeedsIncrementalBarrier(bool needs) override {
399
36
        MOZ_ASSERT(needsBarrier != needs);
400
36
        needsBarrier = needs;
401
36
        return true;
402
36
    }
Unexecuted instantiation: JS::WeakCache<JS::GCHashMap<unsigned int, js::ReadBarriered<js::WasmFunctionScope*>, mozilla::DefaultHasher<unsigned int>, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<unsigned int, js::ReadBarriered<js::WasmFunctionScope*> > > >::setNeedsIncrementalBarrier(bool)
403
404
18
    bool needsIncrementalBarrier() const override {
405
18
        return needsBarrier;
406
18
    }
JS::WeakCache<JS::GCHashMap<js::ObjectGroupRealm::AllocationSiteKey, js::ReadBarriered<js::ObjectGroup*>, js::ObjectGroupRealm::AllocationSiteKey, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<js::ObjectGroupRealm::AllocationSiteKey, js::ReadBarriered<js::ObjectGroup*> > > >::needsIncrementalBarrier() const
Line
Count
Source
404
18
    bool needsIncrementalBarrier() const override {
405
18
        return needsBarrier;
406
18
    }
Unexecuted instantiation: JS::WeakCache<JS::GCHashMap<unsigned int, js::ReadBarriered<js::WasmFunctionScope*>, mozilla::DefaultHasher<unsigned int>, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<unsigned int, js::ReadBarriered<js::WasmFunctionScope*> > > >::needsIncrementalBarrier() const
407
408
  private:
409
    using Entry = typename Map::Entry;
410
411
0
    static bool entryNeedsSweep(const Entry& prior) {
412
0
        Key key(prior.key());
413
0
        Value value(prior.value());
414
0
        bool result = MapSweepPolicy::needsSweep(&key, &value);
415
0
        MOZ_ASSERT(prior.key() == key); // We shouldn't update here.
416
0
        MOZ_ASSERT(prior.value() == value); // We shouldn't update here.
417
0
        return result;
418
0
    }
Unexecuted instantiation: JS::WeakCache<JS::GCHashMap<js::ObjectGroupRealm::AllocationSiteKey, js::ReadBarriered<js::ObjectGroup*>, js::ObjectGroupRealm::AllocationSiteKey, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<js::ObjectGroupRealm::AllocationSiteKey, js::ReadBarriered<js::ObjectGroup*> > > >::entryNeedsSweep(mozilla::HashMapEntry<js::ObjectGroupRealm::AllocationSiteKey, js::ReadBarriered<js::ObjectGroup*> > const&)
Unexecuted instantiation: JS::WeakCache<JS::GCHashMap<unsigned int, js::ReadBarriered<js::WasmFunctionScope*>, mozilla::DefaultHasher<unsigned int>, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<unsigned int, js::ReadBarriered<js::WasmFunctionScope*> > > >::entryNeedsSweep(mozilla::HashMapEntry<unsigned int, js::ReadBarriered<js::WasmFunctionScope*> > const&)
419
420
  public:
421
    using Lookup = typename Map::Lookup;
422
    using Ptr = typename Map::Ptr;
423
    using AddPtr = typename Map::AddPtr;
424
425
    struct Range
426
    {
427
        explicit Range(const typename Map::Range& r)
428
          : range(r)
429
0
        {
430
0
            settle();
431
0
        }
432
        Range() {}
433
434
0
        bool empty() const { return range.empty(); }
435
0
        const Entry& front() const { return range.front(); }
436
437
0
        void popFront() {
438
0
            range.popFront();
439
0
            settle();
440
0
        }
441
442
      private:
443
        typename Map::Range range;
444
445
0
        void settle() {
446
0
            while (!empty() && entryNeedsSweep(front())) {
447
0
                popFront();
448
0
            }
449
0
        }
450
    };
451
452
    struct Enum : public Map::Enum
453
    {
454
        explicit Enum(Self& cache)
455
          : Map::Enum(cache.map)
456
        {
457
            // This operation is not allowed while barriers are in place as we
458
            // may also need to enumerate the set for sweeping.
459
            MOZ_ASSERT(!cache.needsBarrier);
460
        }
461
    };
462
463
0
    Ptr lookup(const Lookup& l) const {
464
0
        Ptr ptr = map.lookup(l);
465
0
        if (needsBarrier && ptr && entryNeedsSweep(*ptr)) {
466
0
            const_cast<Map&>(map).remove(ptr);
467
0
            return Ptr();
468
0
        }
469
0
        return ptr;
470
0
    }
Unexecuted instantiation: JS::WeakCache<JS::GCHashMap<js::ObjectGroupRealm::AllocationSiteKey, js::ReadBarriered<js::ObjectGroup*>, js::ObjectGroupRealm::AllocationSiteKey, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<js::ObjectGroupRealm::AllocationSiteKey, js::ReadBarriered<js::ObjectGroup*> > > >::lookup(js::ObjectGroupRealm::AllocationSiteKey const&) const
Unexecuted instantiation: JS::WeakCache<JS::GCHashMap<unsigned int, js::ReadBarriered<js::WasmFunctionScope*>, mozilla::DefaultHasher<unsigned int>, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<unsigned int, js::ReadBarriered<js::WasmFunctionScope*> > > >::lookup(unsigned int const&) const
471
472
115
    AddPtr lookupForAdd(const Lookup& l) {
473
115
        AddPtr ptr = map.lookupForAdd(l);
474
115
        if (needsBarrier && ptr && entryNeedsSweep(*ptr)) {
475
0
            const_cast<Map&>(map).remove(ptr);
476
0
            return map.lookupForAdd(l);
477
0
        }
478
115
        return ptr;
479
115
    }
480
481
0
    Range all() const {
482
0
        return Range(map.all());
483
0
    }
484
485
    bool empty() const {
486
        // This operation is not currently allowed while barriers are in place
487
        // as it would require iterating the map and the caller expects a
488
        // constant time operation.
489
        MOZ_ASSERT(!needsBarrier);
490
        return map.empty();
491
    }
492
493
    uint32_t count() const {
494
        // This operation is not currently allowed while barriers are in place
495
        // as it would require iterating the set and the caller expects a
496
        // constant time operation.
497
        MOZ_ASSERT(!needsBarrier);
498
        return map.count();
499
    }
500
501
    size_t capacity() const {
502
        return map.capacity();
503
    }
504
505
    bool has(const Lookup& l) const {
506
        return lookup(l).found();
507
    }
508
509
    size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const {
510
        return map.sizeOfExcludingThis(mallocSizeOf);
511
    }
512
0
    size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const {
513
0
        return mallocSizeOf(this) + map.shallowSizeOfExcludingThis(mallocSizeOf);
514
0
    }
515
516
0
    void clear() {
517
0
        // This operation is not currently allowed while barriers are in place
518
0
        // since it doesn't make sense to clear a cache while it is being swept.
519
0
        MOZ_ASSERT(!needsBarrier);
520
0
        map.clear();
521
0
    }
522
523
    void clearAndCompact() {
524
        // This operation is not currently allowed while barriers are in place
525
        // since it doesn't make sense to clear a cache while it is being swept.
526
        MOZ_ASSERT(!needsBarrier);
527
        map.clearAndCompact();
528
    }
529
530
0
    void remove(Ptr p) {
531
0
        // This currently supports removing entries during incremental
532
0
        // sweeping. If we allow these tables to be swept incrementally this may
533
0
        // no longer be possible.
534
0
        map.remove(p);
535
0
    }
536
537
    void remove(const Lookup& l) {
538
        Ptr p = lookup(l);
539
        if (p) {
540
            remove(p);
541
        }
542
    }
543
544
    template<typename KeyInput, typename ValueInput>
545
67
    bool add(AddPtr& p, KeyInput&& k, ValueInput&& v) {
546
67
        return map.add(p, std::forward<KeyInput>(k), std::forward<ValueInput>(v));
547
67
    }
548
549
    template<typename KeyInput, typename ValueInput>
550
    bool relookupOrAdd(AddPtr& p, KeyInput&& k, ValueInput&& v) {
551
        return map.relookupOrAdd(p, std::forward<KeyInput>(k), std::forward<ValueInput>(v));
552
    }
553
554
    template<typename KeyInput, typename ValueInput>
555
    bool put(KeyInput&& k, ValueInput&& v) {
556
        return map.put(std::forward<KeyInput>(k), std::forward<ValueInput>(v));
557
    }
558
559
    template<typename KeyInput, typename ValueInput>
560
0
    bool putNew(KeyInput&& k, ValueInput&& v) {
561
0
        return map.putNew(std::forward<KeyInput>(k), std::forward<ValueInput>(v));
562
0
    }
Unexecuted instantiation: bool JS::WeakCache<JS::GCHashMap<js::ObjectGroupRealm::AllocationSiteKey, js::ReadBarriered<js::ObjectGroup*>, js::ObjectGroupRealm::AllocationSiteKey, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<js::ObjectGroupRealm::AllocationSiteKey, js::ReadBarriered<js::ObjectGroup*> > > >::putNew<js::ObjectGroupRealm::AllocationSiteKey&, js::ObjectGroup*&>(js::ObjectGroupRealm::AllocationSiteKey&, js::ObjectGroup*&)
Unexecuted instantiation: bool JS::WeakCache<JS::GCHashMap<unsigned int, js::ReadBarriered<js::WasmFunctionScope*>, mozilla::DefaultHasher<unsigned int>, js::SystemAllocPolicy, JS::DefaultMapSweepPolicy<unsigned int, js::ReadBarriered<js::WasmFunctionScope*> > > >::putNew<unsigned int&, JS::Rooted<js::WasmFunctionScope*>&>(unsigned int&, JS::Rooted<js::WasmFunctionScope*>&)
563
};
564
565
// Specialize WeakCache for GCHashSet to provide a barriered set that does not
566
// need to be swept immediately.
567
template <typename T, typename HashPolicy, typename AllocPolicy>
568
class WeakCache<GCHashSet<T, HashPolicy, AllocPolicy>>
569
    : protected detail::WeakCacheBase
570
{
571
    using Set = GCHashSet<T, HashPolicy, AllocPolicy>;
572
    using Self = WeakCache<Set>;
573
574
    Set set;
575
    bool needsBarrier;
576
577
  public:
578
    using Entry = typename Set::Entry;
579
580
    template <typename... Args>
581
    explicit WeakCache(Zone* zone, Args&&... args)
582
      : WeakCacheBase(zone), set(std::forward<Args>(args)...), needsBarrier(false)
583
54
    {}
JS::WeakCache<JS::GCHashSet<JSObject*, js::MovableCellHasher<JSObject*>, js::SystemAllocPolicy> >::WeakCache<>(JS::Zone*)
Line
Count
Source
583
9
    {}
JS::WeakCache<JS::GCHashSet<js::ReadBarriered<js::UnownedBaseShape*>, js::StackBaseShape, js::SystemAllocPolicy> >::WeakCache<>(JS::Zone*)
Line
Count
Source
583
9
    {}
JS::WeakCache<JS::GCHashSet<js::InitialShapeEntry, js::InitialShapeEntry, js::SystemAllocPolicy> >::WeakCache<>(JS::Zone*)
Line
Count
Source
583
9
    {}
JS::WeakCache<JS::GCHashSet<js::ObjectGroupRealm::NewEntry, js::ObjectGroupRealm::NewEntry, js::SystemAllocPolicy> >::WeakCache<>(JS::Zone*)
Line
Count
Source
583
18
    {}
JS::WeakCache<JS::GCHashSet<js::ReadBarriered<js::RegExpShared*>, js::RegExpZone::Key, js::ZoneAllocPolicy> >::WeakCache<JS::Zone*&>(JS::Zone*, JS::Zone*&)
Line
Count
Source
583
9
    {}
Unexecuted instantiation: JS::WeakCache<JS::GCHashSet<js::ReadBarriered<js::WasmInstanceObject*>, js::MovableCellHasher<js::ReadBarriered<js::WasmInstanceObject*> >, js::SystemAllocPolicy> >::WeakCache<>(JS::Zone*)
584
    template <typename... Args>
585
    explicit WeakCache(JSRuntime* rt, Args&&... args)
586
      : WeakCacheBase(rt), set(std::forward<Args>(args)...), needsBarrier(false)
587
    {}
588
589
108
    size_t sweep() override {
590
108
        size_t steps = set.count();
591
108
        set.sweep();
592
108
        return steps;
593
108
    }
Unexecuted instantiation: JS::WeakCache<JS::GCHashSet<js::ReadBarriered<js::RegExpShared*>, js::RegExpZone::Key, js::ZoneAllocPolicy> >::sweep()
JS::WeakCache<JS::GCHashSet<js::InitialShapeEntry, js::InitialShapeEntry, js::SystemAllocPolicy> >::sweep()
Line
Count
Source
589
18
    size_t sweep() override {
590
18
        size_t steps = set.count();
591
18
        set.sweep();
592
18
        return steps;
593
18
    }
JS::WeakCache<JS::GCHashSet<js::ReadBarriered<js::UnownedBaseShape*>, js::StackBaseShape, js::SystemAllocPolicy> >::sweep()
Line
Count
Source
589
18
    size_t sweep() override {
590
18
        size_t steps = set.count();
591
18
        set.sweep();
592
18
        return steps;
593
18
    }
Unexecuted instantiation: JS::WeakCache<JS::GCHashSet<JSObject*, js::MovableCellHasher<JSObject*>, js::SystemAllocPolicy> >::sweep()
JS::WeakCache<JS::GCHashSet<js::ObjectGroupRealm::NewEntry, js::ObjectGroupRealm::NewEntry, js::SystemAllocPolicy> >::sweep()
Line
Count
Source
589
72
    size_t sweep() override {
590
72
        size_t steps = set.count();
591
72
        set.sweep();
592
72
        return steps;
593
72
    }
Unexecuted instantiation: JS::WeakCache<JS::GCHashSet<js::ReadBarriered<js::WasmInstanceObject*>, js::MovableCellHasher<js::ReadBarriered<js::WasmInstanceObject*> >, js::SystemAllocPolicy> >::sweep()
594
595
144
    bool needsSweep() override {
596
144
        return set.needsSweep();
597
144
    }
JS::WeakCache<JS::GCHashSet<js::ReadBarriered<js::RegExpShared*>, js::RegExpZone::Key, js::ZoneAllocPolicy> >::needsSweep()
Line
Count
Source
595
18
    bool needsSweep() override {
596
18
        return set.needsSweep();
597
18
    }
JS::WeakCache<JS::GCHashSet<js::InitialShapeEntry, js::InitialShapeEntry, js::SystemAllocPolicy> >::needsSweep()
Line
Count
Source
595
18
    bool needsSweep() override {
596
18
        return set.needsSweep();
597
18
    }
JS::WeakCache<JS::GCHashSet<js::ReadBarriered<js::UnownedBaseShape*>, js::StackBaseShape, js::SystemAllocPolicy> >::needsSweep()
Line
Count
Source
595
18
    bool needsSweep() override {
596
18
        return set.needsSweep();
597
18
    }
JS::WeakCache<JS::GCHashSet<JSObject*, js::MovableCellHasher<JSObject*>, js::SystemAllocPolicy> >::needsSweep()
Line
Count
Source
595
18
    bool needsSweep() override {
596
18
        return set.needsSweep();
597
18
    }
JS::WeakCache<JS::GCHashSet<js::ObjectGroupRealm::NewEntry, js::ObjectGroupRealm::NewEntry, js::SystemAllocPolicy> >::needsSweep()
Line
Count
Source
595
72
    bool needsSweep() override {
596
72
        return set.needsSweep();
597
72
    }
Unexecuted instantiation: JS::WeakCache<JS::GCHashSet<js::ReadBarriered<js::WasmInstanceObject*>, js::MovableCellHasher<js::ReadBarriered<js::WasmInstanceObject*> >, js::SystemAllocPolicy> >::needsSweep()
598
599
216
    bool setNeedsIncrementalBarrier(bool needs) override {
600
216
        MOZ_ASSERT(needsBarrier != needs);
601
216
        needsBarrier = needs;
602
216
        return true;
603
216
    }
Unexecuted instantiation: JS::WeakCache<JS::GCHashSet<js::ReadBarriered<js::RegExpShared*>, js::RegExpZone::Key, js::ZoneAllocPolicy> >::setNeedsIncrementalBarrier(bool)
JS::WeakCache<JS::GCHashSet<js::InitialShapeEntry, js::InitialShapeEntry, js::SystemAllocPolicy> >::setNeedsIncrementalBarrier(bool)
Line
Count
Source
599
36
    bool setNeedsIncrementalBarrier(bool needs) override {
600
36
        MOZ_ASSERT(needsBarrier != needs);
601
36
        needsBarrier = needs;
602
36
        return true;
603
36
    }
JS::WeakCache<JS::GCHashSet<js::ReadBarriered<js::UnownedBaseShape*>, js::StackBaseShape, js::SystemAllocPolicy> >::setNeedsIncrementalBarrier(bool)
Line
Count
Source
599
36
    bool setNeedsIncrementalBarrier(bool needs) override {
600
36
        MOZ_ASSERT(needsBarrier != needs);
601
36
        needsBarrier = needs;
602
36
        return true;
603
36
    }
Unexecuted instantiation: JS::WeakCache<JS::GCHashSet<JSObject*, js::MovableCellHasher<JSObject*>, js::SystemAllocPolicy> >::setNeedsIncrementalBarrier(bool)
JS::WeakCache<JS::GCHashSet<js::ObjectGroupRealm::NewEntry, js::ObjectGroupRealm::NewEntry, js::SystemAllocPolicy> >::setNeedsIncrementalBarrier(bool)
Line
Count
Source
599
144
    bool setNeedsIncrementalBarrier(bool needs) override {
600
144
        MOZ_ASSERT(needsBarrier != needs);
601
144
        needsBarrier = needs;
602
144
        return true;
603
144
    }
Unexecuted instantiation: JS::WeakCache<JS::GCHashSet<js::ReadBarriered<js::WasmInstanceObject*>, js::MovableCellHasher<js::ReadBarriered<js::WasmInstanceObject*> >, js::SystemAllocPolicy> >::setNeedsIncrementalBarrier(bool)
604
605
144
    bool needsIncrementalBarrier() const override {
606
144
        return needsBarrier;
607
144
    }
JS::WeakCache<JS::GCHashSet<js::ReadBarriered<js::RegExpShared*>, js::RegExpZone::Key, js::ZoneAllocPolicy> >::needsIncrementalBarrier() const
Line
Count
Source
605
18
    bool needsIncrementalBarrier() const override {
606
18
        return needsBarrier;
607
18
    }
JS::WeakCache<JS::GCHashSet<js::InitialShapeEntry, js::InitialShapeEntry, js::SystemAllocPolicy> >::needsIncrementalBarrier() const
Line
Count
Source
605
18
    bool needsIncrementalBarrier() const override {
606
18
        return needsBarrier;
607
18
    }
JS::WeakCache<JS::GCHashSet<js::ReadBarriered<js::UnownedBaseShape*>, js::StackBaseShape, js::SystemAllocPolicy> >::needsIncrementalBarrier() const
Line
Count
Source
605
18
    bool needsIncrementalBarrier() const override {
606
18
        return needsBarrier;
607
18
    }
JS::WeakCache<JS::GCHashSet<JSObject*, js::MovableCellHasher<JSObject*>, js::SystemAllocPolicy> >::needsIncrementalBarrier() const
Line
Count
Source
605
18
    bool needsIncrementalBarrier() const override {
606
18
        return needsBarrier;
607
18
    }
JS::WeakCache<JS::GCHashSet<js::ObjectGroupRealm::NewEntry, js::ObjectGroupRealm::NewEntry, js::SystemAllocPolicy> >::needsIncrementalBarrier() const
Line
Count
Source
605
72
    bool needsIncrementalBarrier() const override {
606
72
        return needsBarrier;
607
72
    }
Unexecuted instantiation: JS::WeakCache<JS::GCHashSet<js::ReadBarriered<js::WasmInstanceObject*>, js::MovableCellHasher<js::ReadBarriered<js::WasmInstanceObject*> >, js::SystemAllocPolicy> >::needsIncrementalBarrier() const
608
609
  private:
610
0
   static bool entryNeedsSweep(const Entry& prior) {
611
0
        Entry entry(prior);
612
0
        bool result = GCPolicy<T>::needsSweep(&entry);
613
0
        MOZ_ASSERT(prior == entry); // We shouldn't update here.
614
0
        return result;
615
0
    }
Unexecuted instantiation: JS::WeakCache<JS::GCHashSet<js::ReadBarriered<js::RegExpShared*>, js::RegExpZone::Key, js::ZoneAllocPolicy> >::entryNeedsSweep(js::ReadBarriered<js::RegExpShared*> const&)
Unexecuted instantiation: JS::WeakCache<JS::GCHashSet<js::ObjectGroupRealm::NewEntry, js::ObjectGroupRealm::NewEntry, js::SystemAllocPolicy> >::entryNeedsSweep(js::ObjectGroupRealm::NewEntry const&)
Unexecuted instantiation: JS::WeakCache<JS::GCHashSet<js::ReadBarriered<js::UnownedBaseShape*>, js::StackBaseShape, js::SystemAllocPolicy> >::entryNeedsSweep(js::ReadBarriered<js::UnownedBaseShape*> const&)
Unexecuted instantiation: JS::WeakCache<JS::GCHashSet<js::InitialShapeEntry, js::InitialShapeEntry, js::SystemAllocPolicy> >::entryNeedsSweep(js::InitialShapeEntry const&)
Unexecuted instantiation: JS::WeakCache<JS::GCHashSet<js::ReadBarriered<js::WasmInstanceObject*>, js::MovableCellHasher<js::ReadBarriered<js::WasmInstanceObject*> >, js::SystemAllocPolicy> >::entryNeedsSweep(js::ReadBarriered<js::WasmInstanceObject*> const&)
Unexecuted instantiation: JS::WeakCache<JS::GCHashSet<JSObject*, js::MovableCellHasher<JSObject*>, js::SystemAllocPolicy> >::entryNeedsSweep(JSObject* const&)
616
617
  public:
618
    using Lookup = typename Set::Lookup;
619
    using Ptr = typename Set::Ptr;
620
    using AddPtr = typename Set::AddPtr;
621
622
    struct Range
623
    {
624
        explicit Range(const typename Set::Range& r)
625
          : range(r)
626
0
        {
627
0
            settle();
628
0
        }
Unexecuted instantiation: JS::WeakCache<JS::GCHashSet<js::ReadBarriered<js::WasmInstanceObject*>, js::MovableCellHasher<js::ReadBarriered<js::WasmInstanceObject*> >, js::SystemAllocPolicy> >::Range::Range(mozilla::detail::HashTable<js::ReadBarriered<js::WasmInstanceObject*> const, mozilla::HashSet<js::ReadBarriered<js::WasmInstanceObject*>, js::MovableCellHasher<js::ReadBarriered<js::WasmInstanceObject*> >, js::SystemAllocPolicy>::SetHashPolicy, js::SystemAllocPolicy>::Range const&)
Unexecuted instantiation: JS::WeakCache<JS::GCHashSet<JSObject*, js::MovableCellHasher<JSObject*>, js::SystemAllocPolicy> >::Range::Range(mozilla::detail::HashTable<JSObject* const, mozilla::HashSet<JSObject*, js::MovableCellHasher<JSObject*>, js::SystemAllocPolicy>::SetHashPolicy, js::SystemAllocPolicy>::Range const&)
629
        Range() {}
630
631
0
        bool empty() const { return range.empty(); }
Unexecuted instantiation: JS::WeakCache<JS::GCHashSet<js::ReadBarriered<js::WasmInstanceObject*>, js::MovableCellHasher<js::ReadBarriered<js::WasmInstanceObject*> >, js::SystemAllocPolicy> >::Range::empty() const
Unexecuted instantiation: JS::WeakCache<JS::GCHashSet<JSObject*, js::MovableCellHasher<JSObject*>, js::SystemAllocPolicy> >::Range::empty() const
632
0
        const Entry& front() const { return range.front(); }
Unexecuted instantiation: JS::WeakCache<JS::GCHashSet<js::ReadBarriered<js::WasmInstanceObject*>, js::MovableCellHasher<js::ReadBarriered<js::WasmInstanceObject*> >, js::SystemAllocPolicy> >::Range::front() const
Unexecuted instantiation: JS::WeakCache<JS::GCHashSet<JSObject*, js::MovableCellHasher<JSObject*>, js::SystemAllocPolicy> >::Range::front() const
633
634
0
        void popFront() {
635
0
            range.popFront();
636
0
            settle();
637
0
        }
Unexecuted instantiation: JS::WeakCache<JS::GCHashSet<js::ReadBarriered<js::WasmInstanceObject*>, js::MovableCellHasher<js::ReadBarriered<js::WasmInstanceObject*> >, js::SystemAllocPolicy> >::Range::popFront()
Unexecuted instantiation: JS::WeakCache<JS::GCHashSet<JSObject*, js::MovableCellHasher<JSObject*>, js::SystemAllocPolicy> >::Range::popFront()
638
639
      private:
640
        typename Set::Range range;
641
642
0
        void settle() {
643
0
            while (!empty() && entryNeedsSweep(front())) {
644
0
                popFront();
645
0
            }
646
0
        }
Unexecuted instantiation: JS::WeakCache<JS::GCHashSet<js::ReadBarriered<js::WasmInstanceObject*>, js::MovableCellHasher<js::ReadBarriered<js::WasmInstanceObject*> >, js::SystemAllocPolicy> >::Range::settle()
Unexecuted instantiation: JS::WeakCache<JS::GCHashSet<JSObject*, js::MovableCellHasher<JSObject*>, js::SystemAllocPolicy> >::Range::settle()
647
    };
648
649
    struct Enum : public Set::Enum
650
    {
651
        explicit Enum(Self& cache)
652
          : Set::Enum(cache.set)
653
0
        {
654
0
            // This operation is not allowed while barriers are in place as we
655
0
            // may also need to enumerate the set for sweeping.
656
0
            MOZ_ASSERT(!cache.needsBarrier);
657
0
        }
Unexecuted instantiation: JS::WeakCache<JS::GCHashSet<js::ObjectGroupRealm::NewEntry, js::ObjectGroupRealm::NewEntry, js::SystemAllocPolicy> >::Enum::Enum(JS::WeakCache<JS::GCHashSet<js::ObjectGroupRealm::NewEntry, js::ObjectGroupRealm::NewEntry, js::SystemAllocPolicy> >&)
Unexecuted instantiation: JS::WeakCache<JS::GCHashSet<js::InitialShapeEntry, js::InitialShapeEntry, js::SystemAllocPolicy> >::Enum::Enum(JS::WeakCache<JS::GCHashSet<js::InitialShapeEntry, js::InitialShapeEntry, js::SystemAllocPolicy> >&)
658
    };
659
660
30
    Ptr lookup(const Lookup& l) const {
661
30
        Ptr ptr = set.lookup(l);
662
30
        if (needsBarrier && ptr && entryNeedsSweep(*ptr)) {
663
0
            const_cast<Set&>(set).remove(ptr);
664
0
            return Ptr();
665
0
        }
666
30
        return ptr;
667
30
    }
Unexecuted instantiation: JS::WeakCache<JS::GCHashSet<js::ReadBarriered<js::RegExpShared*>, js::RegExpZone::Key, js::ZoneAllocPolicy> >::lookup(js::RegExpZone::Key const&) const
JS::WeakCache<JS::GCHashSet<js::ObjectGroupRealm::NewEntry, js::ObjectGroupRealm::NewEntry, js::SystemAllocPolicy> >::lookup(js::ObjectGroupRealm::NewEntry::Lookup const&) const
Line
Count
Source
660
22
    Ptr lookup(const Lookup& l) const {
661
22
        Ptr ptr = set.lookup(l);
662
22
        if (needsBarrier && ptr && entryNeedsSweep(*ptr)) {
663
0
            const_cast<Set&>(set).remove(ptr);
664
0
            return Ptr();
665
0
        }
666
22
        return ptr;
667
22
    }
JS::WeakCache<JS::GCHashSet<js::InitialShapeEntry, js::InitialShapeEntry, js::SystemAllocPolicy> >::lookup(js::InitialShapeEntry::Lookup const&) const
Line
Count
Source
660
8
    Ptr lookup(const Lookup& l) const {
661
8
        Ptr ptr = set.lookup(l);
662
8
        if (needsBarrier && ptr && entryNeedsSweep(*ptr)) {
663
0
            const_cast<Set&>(set).remove(ptr);
664
0
            return Ptr();
665
0
        }
666
8
        return ptr;
667
8
    }
668
669
19.5M
    AddPtr lookupForAdd(const Lookup& l) {
670
19.5M
        AddPtr ptr = set.lookupForAdd(l);
671
19.5M
        if (needsBarrier && ptr && entryNeedsSweep(*ptr)) {
672
0
            const_cast<Set&>(set).remove(ptr);
673
0
            return set.lookupForAdd(l);
674
0
        }
675
19.5M
        return ptr;
676
19.5M
    }
JS::WeakCache<JS::GCHashSet<js::ObjectGroupRealm::NewEntry, js::ObjectGroupRealm::NewEntry, js::SystemAllocPolicy> >::lookupForAdd(js::ObjectGroupRealm::NewEntry::Lookup const&)
Line
Count
Source
669
9.78M
    AddPtr lookupForAdd(const Lookup& l) {
670
9.78M
        AddPtr ptr = set.lookupForAdd(l);
671
9.78M
        if (needsBarrier && ptr && entryNeedsSweep(*ptr)) {
672
0
            const_cast<Set&>(set).remove(ptr);
673
0
            return set.lookupForAdd(l);
674
0
        }
675
9.78M
        return ptr;
676
9.78M
    }
Unexecuted instantiation: JS::WeakCache<JS::GCHashSet<js::ReadBarriered<js::RegExpShared*>, js::RegExpZone::Key, js::ZoneAllocPolicy> >::lookupForAdd(js::RegExpZone::Key const&)
JS::WeakCache<JS::GCHashSet<js::ReadBarriered<js::UnownedBaseShape*>, js::StackBaseShape, js::SystemAllocPolicy> >::lookupForAdd(js::StackBaseShape::Lookup const&)
Line
Count
Source
669
1.62M
    AddPtr lookupForAdd(const Lookup& l) {
670
1.62M
        AddPtr ptr = set.lookupForAdd(l);
671
1.62M
        if (needsBarrier && ptr && entryNeedsSweep(*ptr)) {
672
0
            const_cast<Set&>(set).remove(ptr);
673
0
            return set.lookupForAdd(l);
674
0
        }
675
1.62M
        return ptr;
676
1.62M
    }
JS::WeakCache<JS::GCHashSet<js::InitialShapeEntry, js::InitialShapeEntry, js::SystemAllocPolicy> >::lookupForAdd(js::InitialShapeEntry::Lookup const&)
Line
Count
Source
669
8.16M
    AddPtr lookupForAdd(const Lookup& l) {
670
8.16M
        AddPtr ptr = set.lookupForAdd(l);
671
8.16M
        if (needsBarrier && ptr && entryNeedsSweep(*ptr)) {
672
0
            const_cast<Set&>(set).remove(ptr);
673
0
            return set.lookupForAdd(l);
674
0
        }
675
8.16M
        return ptr;
676
8.16M
    }
677
678
0
    Range all() const {
679
0
        return Range(set.all());
680
0
    }
Unexecuted instantiation: JS::WeakCache<JS::GCHashSet<js::ReadBarriered<js::WasmInstanceObject*>, js::MovableCellHasher<js::ReadBarriered<js::WasmInstanceObject*> >, js::SystemAllocPolicy> >::all() const
Unexecuted instantiation: JS::WeakCache<JS::GCHashSet<JSObject*, js::MovableCellHasher<JSObject*>, js::SystemAllocPolicy> >::all() const
681
682
0
    bool empty() const {
683
0
        // This operation is not currently allowed while barriers are in place
684
0
        // as it would require iterating the set and the caller expects a
685
0
        // constant time operation.
686
0
        MOZ_ASSERT(!needsBarrier);
687
0
        return set.empty();
688
0
    }
689
690
    uint32_t count() const {
691
        // This operation is not currently allowed while barriers are in place
692
        // as it would require iterating the set and the caller expects a
693
        // constant time operation.
694
        MOZ_ASSERT(!needsBarrier);
695
        return set.count();
696
    }
697
698
    size_t capacity() const {
699
        return set.capacity();
700
    }
701
702
    bool has(const Lookup& l) const {
703
        return lookup(l).found();
704
    }
705
706
0
    size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const {
707
0
        return set.shallowSizeOfExcludingThis(mallocSizeOf);
708
0
    }
Unexecuted instantiation: JS::WeakCache<JS::GCHashSet<js::ReadBarriered<js::RegExpShared*>, js::RegExpZone::Key, js::ZoneAllocPolicy> >::sizeOfExcludingThis(unsigned long (*)(void const*)) const
Unexecuted instantiation: JS::WeakCache<JS::GCHashSet<js::ReadBarriered<js::UnownedBaseShape*>, js::StackBaseShape, js::SystemAllocPolicy> >::sizeOfExcludingThis(unsigned long (*)(void const*)) const
Unexecuted instantiation: JS::WeakCache<JS::GCHashSet<js::InitialShapeEntry, js::InitialShapeEntry, js::SystemAllocPolicy> >::sizeOfExcludingThis(unsigned long (*)(void const*)) const
709
0
    size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const {
710
0
        return mallocSizeOf(this) + set.shallowSizeOfExcludingThis(mallocSizeOf);
711
0
    }
712
713
0
    void clear() {
714
0
        // This operation is not currently allowed while barriers are in place
715
0
        // since it doesn't make sense to clear a cache while it is being swept.
716
0
        MOZ_ASSERT(!needsBarrier);
717
0
        set.clear();
718
0
    }
Unexecuted instantiation: JS::WeakCache<JS::GCHashSet<js::ReadBarriered<js::UnownedBaseShape*>, js::StackBaseShape, js::SystemAllocPolicy> >::clear()
Unexecuted instantiation: JS::WeakCache<JS::GCHashSet<js::InitialShapeEntry, js::InitialShapeEntry, js::SystemAllocPolicy> >::clear()
Unexecuted instantiation: JS::WeakCache<JS::GCHashSet<js::ObjectGroupRealm::NewEntry, js::ObjectGroupRealm::NewEntry, js::SystemAllocPolicy> >::clear()
719
720
    void clearAndCompact() {
721
        // This operation is not currently allowed while barriers are in place
722
        // since it doesn't make sense to clear a cache while it is being swept.
723
        MOZ_ASSERT(!needsBarrier);
724
        set.clearAndCompact();
725
    }
726
727
0
    void remove(Ptr p) {
728
0
        // This currently supports removing entries during incremental
729
0
        // sweeping. If we allow these tables to be swept incrementally this may
730
0
        // no longer be possible.
731
0
        set.remove(p);
732
0
    }
733
734
    void remove(const Lookup& l) {
735
        Ptr p = lookup(l);
736
        if (p) {
737
            remove(p);
738
        }
739
    }
740
741
    template<typename TInput>
742
1.62M
    bool add(AddPtr& p, TInput&& t) {
743
1.62M
        return set.add(p, std::forward<TInput>(t));
744
1.62M
    }
745
746
    template<typename TInput>
747
1.62M
    bool relookupOrAdd(AddPtr& p, const Lookup& l, TInput&& t) {
748
1.62M
        return set.relookupOrAdd(p, l, std::forward<TInput>(t));
749
1.62M
    }
Unexecuted instantiation: bool JS::WeakCache<JS::GCHashSet<js::ReadBarriered<js::RegExpShared*>, js::RegExpZone::Key, js::ZoneAllocPolicy> >::relookupOrAdd<js::RegExpShared* const&>(mozilla::detail::HashTable<js::ReadBarriered<js::RegExpShared*> const, mozilla::HashSet<js::ReadBarriered<js::RegExpShared*>, js::RegExpZone::Key, js::ZoneAllocPolicy>::SetHashPolicy, js::ZoneAllocPolicy>::AddPtr&, js::RegExpZone::Key const&, js::RegExpShared* const&)
bool JS::WeakCache<JS::GCHashSet<js::ReadBarriered<js::UnownedBaseShape*>, js::StackBaseShape, js::SystemAllocPolicy> >::relookupOrAdd<js::UnownedBaseShape* const&>(mozilla::detail::HashTable<js::ReadBarriered<js::UnownedBaseShape*> const, mozilla::HashSet<js::ReadBarriered<js::UnownedBaseShape*>, js::StackBaseShape, js::SystemAllocPolicy>::SetHashPolicy, js::SystemAllocPolicy>::AddPtr&, js::StackBaseShape::Lookup const&, js::UnownedBaseShape* const&)
Line
Count
Source
747
167
    bool relookupOrAdd(AddPtr& p, const Lookup& l, TInput&& t) {
748
167
        return set.relookupOrAdd(p, l, std::forward<TInput>(t));
749
167
    }
bool JS::WeakCache<JS::GCHashSet<js::InitialShapeEntry, js::InitialShapeEntry, js::SystemAllocPolicy> >::relookupOrAdd<js::InitialShapeEntry const&>(mozilla::detail::HashTable<js::InitialShapeEntry const, mozilla::HashSet<js::InitialShapeEntry, js::InitialShapeEntry, js::SystemAllocPolicy>::SetHashPolicy, js::SystemAllocPolicy>::AddPtr&, js::InitialShapeEntry::Lookup const&, js::InitialShapeEntry const&)
Line
Count
Source
747
1.62M
    bool relookupOrAdd(AddPtr& p, const Lookup& l, TInput&& t) {
748
1.62M
        return set.relookupOrAdd(p, l, std::forward<TInput>(t));
749
1.62M
    }
750
751
    template<typename TInput>
752
0
    bool put(TInput&& t) {
753
0
        return set.put(std::forward<TInput>(t));
754
0
    }
755
756
    template<typename TInput>
757
0
    bool putNew(TInput&& t) {
758
0
        return set.putNew(std::forward<TInput>(t));
759
0
    }
760
761
    template<typename TInput>
762
0
    bool putNew(const Lookup& l, TInput&& t) {
763
0
        return set.putNew(l, std::forward<TInput>(t));
764
0
    }
765
};
766
767
} // namespace JS
768
769
#endif /* GCHashTable_h */