Debian Codegraph @

js/src/jit/ICStubSpace.h

raw
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/. */
6
7 #ifndef jit_ICStubSpace_h
8 #define jit_ICStubSpace_h
9
10 #include "ds/LifoAlloc.h"
11
12 namespace js {
13 namespace jit {
14
15 // ICStubSpace is an abstraction for allocation policy and storage for CacheIR
16 // stub data. Each JitZone has a single ICStubSpace.
17 class ICStubSpace {
18 static constexpr size_t DefaultChunkSize = 4096;
19 LifoAlloc allocator_{DefaultChunkSize, js::BackgroundMallocArena};
20
21 public:
22 inline void* alloc(size_t size) { return allocator_.alloc(size); }
23
24 JS_DECLARE_NEW_METHODS(allocate, alloc, inline)
25
26 void freeAllAfterMinorGC(JS::Zone* zone);
27
28 void transferFrom(ICStubSpace& other) {
29 allocator_.transferFrom(&other.allocator_);
30 }
31
32 size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const {
33 return allocator_.sizeOfExcludingThis(mallocSizeOf);
34 }
35 };
36
37 } // namespace jit
38 } // namespace js
39
40 #endif /* jit_ICStubSpace_h */