Backed out changeset 4191b252db9b (bug 1886734) for causing build bustages @netwerk...
[gecko.git] / js / src / gc / GCContext-inl.h
blob7b53d50b77b6daf137135d77b5178ff0adbc7d1a
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: set ts=8 sts=2 et sw=2 tw=80:
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/. */
7 #ifndef gc_GCContext_inl_h
8 #define gc_GCContext_inl_h
10 #include "gc/GCContext.h"
12 #include "gc/ZoneAllocator.h"
14 inline void JS::GCContext::free_(Cell* cell, void* p, size_t nbytes,
15 MemoryUse use) {
16 if (p) {
17 removeCellMemory(cell, nbytes, use);
18 js_free(p);
22 template <class T>
23 inline void JS::GCContext::release(Cell* cell, T* p, size_t nbytes,
24 MemoryUse use) {
25 if (p) {
26 removeCellMemory(cell, nbytes, use);
27 p->Release();
31 inline void JS::GCContext::removeCellMemory(Cell* cell, size_t nbytes,
32 MemoryUse use) {
33 // This may or may not be called as part of GC.
34 if (nbytes && cell->isTenured()) {
35 auto zone = js::ZoneAllocator::from(cell->asTenured().zoneFromAnyThread());
36 zone->removeCellMemory(cell, nbytes, use, isFinalizing());
40 #endif // gc_GCContext_inl_h