forked from M-Labs/nac3
string_store: update embedding map after compilation
This commit is contained in:
parent
ae09a0d444
commit
964945d244
@ -577,7 +577,7 @@ impl Nac3 {
|
|||||||
field_to_val: RwLock::default(),
|
field_to_val: RwLock::default(),
|
||||||
name_to_pyid,
|
name_to_pyid,
|
||||||
module: module.to_object(py),
|
module: module.to_object(py),
|
||||||
helper,
|
helper: helper.clone(),
|
||||||
string_store: self.string_store.clone(),
|
string_store: self.string_store.clone(),
|
||||||
exception_ids: self.exception_ids.clone(),
|
exception_ids: self.exception_ids.clone(),
|
||||||
deferred_eval_store: self.deferred_eval_store.clone(),
|
deferred_eval_store: self.deferred_eval_store.clone(),
|
||||||
@ -822,6 +822,20 @@ impl Nac3 {
|
|||||||
panic!("Failed to run optimization for module `main`: {}", err.to_string());
|
panic!("Failed to run optimization for module `main`: {}", err.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Python::with_gil(|py| {
|
||||||
|
let string_store = self.string_store.read();
|
||||||
|
let mut string_store_vec = string_store.iter().collect::<Vec<_>>();
|
||||||
|
string_store_vec.sort_by(|(_s1, key1), (_s2, key2)| key1.cmp(key2));
|
||||||
|
for (s, key) in string_store_vec {
|
||||||
|
let embed_key: i32 = helper.store_str.call1(py, (s,)).unwrap().extract(py).unwrap();
|
||||||
|
assert_eq!(
|
||||||
|
embed_key, *key,
|
||||||
|
"string {s} is out of sync between embedding map (key={embed_key}) and \
|
||||||
|
the internal string store (key={key})"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
link_fn(&main)
|
link_fn(&main)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1536,10 +1536,7 @@ impl SymbolResolver for Resolver {
|
|||||||
if let Some(id) = string_store.get(s) {
|
if let Some(id) = string_store.get(s) {
|
||||||
*id
|
*id
|
||||||
} else {
|
} else {
|
||||||
let id = Python::with_gil(|py| -> PyResult<i32> {
|
let id = string_store.len() as i32;
|
||||||
self.0.helper.store_str.call1(py, (s,))?.extract(py)
|
|
||||||
})
|
|
||||||
.unwrap();
|
|
||||||
string_store.insert(s.into(), id);
|
string_store.insert(s.into(), id);
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user