// Number of bytes represented by a bit in the CodeCacheBitmap. Value is reasonable for all // architectures. static constexpr int kJitCodeAccountingBytes = 16;
// Helper to get the size required for emitting `number_of_roots` in the // data portion of a JIT memory region.
uint32_t inline ComputeRootTableSize(uint32_t number_of_roots) { returnsizeof(uint32_t) + number_of_roots * sizeof(GcRoot<mirror::Object>);
}
// Represents a memory region for the JIT, where code and data are stored. This class // provides allocation and deallocation primitives. class JitMemoryRegion { public:
JitMemoryRegion()
: initial_capacity_(0),
max_capacity_(0),
current_capacity_(0),
data_end_(0),
exec_end_(0),
used_memory_for_code_(0),
used_memory_for_data_(0),
data_pages_(),
writable_data_pages_(),
exec_pages_(),
non_exec_pages_(),
data_mspace_(nullptr),
exec_mspace_(nullptr) {}
// Try to increase the current capacity of the code cache. Return whether we // succeeded at doing so. bool IncreaseCodeCacheCapacity() REQUIRES(Locks::jit_lock_);
// Set the footprint limit of the code cache. void SetFootprintLimit(size_t new_footprint) REQUIRES(Locks::jit_lock_);
// Emit header and code into the memory pointed by `reserved_code` (despite it being const). // Returns pointer to copied code (within reserved_code region; after OatQuickMethodHeader). const uint8_t* CommitCode(ArrayRef<const uint8_t> reserved_code,
ArrayRef<const uint8_t> code, const uint8_t* stack_map)
REQUIRES(Locks::jit_lock_);
// Emit roots and stack map into the memory pointed by `roots_data` (despite it being const). bool CommitData(ArrayRef<const uint8_t> reserved_data, const std::vector<Handle<mirror::Object>>& roots,
ArrayRef<const uint8_t> stack_map)
REQUIRES(Locks::jit_lock_)
REQUIRES_SHARED(Locks::mutator_lock_);
void ResetWritableMappings() REQUIRES(Locks::jit_lock_) {
non_exec_pages_.ResetInForkedProcess();
writable_data_pages_.ResetInForkedProcess(); // Also clear the mspaces, which, in their implementation, // point to the discarded mappings.
exec_mspace_ = nullptr;
data_mspace_ = nullptr;
}
template <typename T> void FillData(const T* address, size_t n, const T& t) REQUIRES(Locks::jit_lock_) {
std::fill_n(GetWritableDataAddress(address), n, t);
}
// Generic helper for writing abritrary data in the data portion of the // region. template <typename T> void WriteData(const T* address, const T& value) {
*GetWritableDataAddress(address) = value;
}
// The initial capacity in bytes this code region starts with.
size_t initial_capacity_ GUARDED_BY(Locks::jit_lock_);
// The maximum capacity in bytes this region can go to.
size_t max_capacity_ GUARDED_BY(Locks::jit_lock_);
// The current capacity in bytes of the region.
size_t current_capacity_ GUARDED_BY(Locks::jit_lock_);
// The current footprint in bytes of the data portion of the region.
size_t data_end_ GUARDED_BY(Locks::jit_lock_);
// The current footprint in bytes of the code portion of the region.
size_t exec_end_ GUARDED_BY(Locks::jit_lock_);
// The size in bytes of used memory for the code portion of the region.
size_t used_memory_for_code_ GUARDED_BY(Locks::jit_lock_);
// The size in bytes of used memory for the data portion of the region.
size_t used_memory_for_data_ GUARDED_BY(Locks::jit_lock_);
// Mem map which holds data (stack maps and profiling info).
MemMap data_pages_;
// Mem map which holds data with writable permission. Only valid for dual view // JIT when this is the writable view and data_pages_ is the readable view.
MemMap writable_data_pages_;
// Mem map which holds code and has executable permission.
MemMap exec_pages_;
// Mem map which holds code with non executable permission. Only valid for dual view JIT when // this is the non-executable view of code used to write updates.
MemMap non_exec_pages_;
// The opaque mspace for allocating data. void* data_mspace_ GUARDED_BY(Locks::jit_lock_);
// The opaque mspace for allocating code. void* exec_mspace_ GUARDED_BY(Locks::jit_lock_);
friendclass ScopedCodeCacheWrite; // For GetUpdatableCodeMapping friendclass TestZygoteMemory;
};
} // namespace jit
} // namespace art
#endif// ART_RUNTIME_JIT_JIT_MEMORY_REGION_H_
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.1 Sekunden
(vorverarbeitet am 2026-06-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.