Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 3 additions & 19 deletions src/vm/dt_evmc_vm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,6 @@ struct DTVM : evmc_vm {
Isolation *Iso = nullptr;

// ---- Module & instance cache (shared by interpreter and multipass) ----
// L0: pointer-based inline cache (fastest, 2 integer comparisons)
const uint8_t *LastCodePtr = nullptr;
size_t LastCodeSize = 0;
EVMModule *L0Mod = nullptr;
// L1: address-based cache map (code_address + rev -> module)
std::unordered_map<CodeAddrRevKey, EVMModule *, CodeAddrRevHash,
CodeAddrRevEqual>
Expand Down Expand Up @@ -282,9 +278,9 @@ EVMModule *loadTransientModule(DTVM *VM, const uint8_t *Code, size_t CodeSize,
}

/// Find or load a cached EVMModule using two-level cache:
/// L0 (code pointer+size) -> L1 (address map) -> Cold load.
/// Shared by both interpreter and multipass paths.
/// Returns nullptr on failure.
/// L1 address-based lookup (code_address + revision) + validateCodeMatch()
/// followed by a cold module load on miss or validation failure.
/// Shared by both interpreter and multipass paths. Returns nullptr on failure.
EVMModule *findModuleCached(DTVM *VM, const uint8_t *Code, size_t CodeSize,
evmc_revision Rev, const evmc_message *Msg,
bool &IsTransient) {
Expand Down Expand Up @@ -312,8 +308,6 @@ EVMModule *findModuleCached(DTVM *VM, const uint8_t *Code, size_t CodeSize,
// If validation failed for an existing entry, evict the stale module
if (It != VM->AddrCache.end()) {
EVMModule *OldMod = It->second;
if (VM->L0Mod == OldMod && Msg->depth == 0)
VM->L0Mod = nullptr;
VM->RT->unloadEVMModule(OldMod);
VM->AddrCache.erase(It);
}
Expand All @@ -325,16 +319,6 @@ EVMModule *findModuleCached(DTVM *VM, const uint8_t *Code, size_t CodeSize,
VM->AddrCache[AddrKey] = Mod;
}

// Update L0 cache members. Even though L0 lookup is disabled, we maintain
// these state variables for two reasons:
// 1. Eviction tracking: If a stale L1 entry is replaced, we need to
// invalidate
// L0Mod if it pointed to the old module (done in the eviction path above).
// 2. Future extensibility: It keeps the door open for re-enabling L0 later
// with a safer validation scheme (e.g., pointer + size + hash).
VM->LastCodePtr = Code;
VM->LastCodeSize = CodeSize;
VM->L0Mod = Mod;
return Mod;
Comment on lines 319 to 322
}

Expand Down
Loading