// Small fast thread-local cache for the interpreter. // It can hold arbitrary pointer-sized key-value pair. // The interpretation of the value depends on the key. // Presence of entry might imply some pre-conditions. // All operations must be done from the owning thread, // or at a point when the owning thread is suspended. // // The key-value pairs stored in the cache currently are: // iget/iput: The field offset. The field must be non-volatile. // sget/sput: The ArtField* pointer. The field must be non-volitile. // invoke: The ArtMethod* pointer (before vtable indirection, etc). // // We ensure consistency of the cache by clearing it // whenever any dex file is unloaded. // // Aligned to 16-bytes to make it easier to get the address of the cache // from assembly (it ensures that the offset is valid immediate value). class ALIGNED(16) InterpreterCache { public: // Aligned since we load the whole entry in single assembly instruction. using Entry ALIGNED(2 * sizeof(size_t)) = std::pair<constvoid*, size_t>;
// 2x size increase/decrease corresponds to ~0.5% interpreter performance change. // Value of 256 has around 75% cache hit rate. static constexpr size_t kSize = 256;
// The lowest bit of the key that's used for index calculation. static constexpr size_t kKeyLowBit = 2u;
InterpreterCache() { // We can not use the Clear() method since the constructor will not // be called from the owning thread.
data_.fill(Entry{});
}
// Clear the whole cache. It requires the owning thread for DCHECKs.
EXPORT void Clear(Thread* owning_thread);
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.