Skip to content

Commit

Permalink
Bugfix in LdcResolutionManager cache
Browse files Browse the repository at this point in the history
  • Loading branch information
hextriclosan committed Oct 12, 2024
1 parent 8ac9707 commit 5e4a939
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions vm/src/execution_engine/ldc_resolution_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type CPoolIndex = u16;
type Value = i32;

pub struct LdcResolutionManager {
cache: RwLock<HashMap<CPoolIndex, Value>>,
cache: RwLock<HashMap<String, HashMap<CPoolIndex, Value>>>,
}

impl LdcResolutionManager {
Expand All @@ -22,11 +22,12 @@ impl LdcResolutionManager {
current_class_name: &str,
cpoolindex: u16,
) -> crate::error::Result<i32> {
if let Some(value) = self
if let Some(Some(value)) = self
.cache
.read()
.expect("error getting cache lock")
.get(&cpoolindex)
.get(current_class_name)
.map(|map| map.get(&cpoolindex))
{
return Ok(*value);
}
Expand Down Expand Up @@ -54,6 +55,8 @@ impl LdcResolutionManager {
self.cache
.write()
.expect("error getting cache write lock")
.entry(current_class_name.to_string())
.or_insert_with(HashMap::new)
.insert(cpoolindex, result);

Ok(result)
Expand Down

0 comments on commit 5e4a939

Please sign in to comment.