To protect your data, the CISO officer has suggested users to enable GitLab 2FA as soon as possible.

Commit 59611fc4 authored by Isaac Oscar Gariano's avatar Isaac Oscar Gariano
Browse files

I forgot to push a file (for the 100th time now?)

parent 34ed7eb4
......@@ -75,18 +75,20 @@ pub struct VM {
name_id_map: RwLock<HashMap<MuName, MuID>>, // +64
/// types declared to the VM
types: RwLock<HashMap<MuID, P<MuType>>>, // +120
/// Ref types declared by 'make_strong_type', the key is the ID of the Referant
ref_types: RwLock<HashMap<MuID, P<MuType>>>,
/// types that are resolved as BackendType
backend_type_info: RwLock<HashMap<MuID, Box<BackendType>>>, // +176
backend_type_info: RwLock<HashMap<MuID, Box<BackendType>>>,
/// constants declared to the VM
constants: RwLock<HashMap<MuID, P<Value>>>, // +232
constants: RwLock<HashMap<MuID, P<Value>>>,
/// globals declared to the VM
globals: RwLock<HashMap<MuID, P<Value>>>, // +288
globals: RwLock<HashMap<MuID, P<Value>>>,
/// function signatures declared
func_sigs: RwLock<HashMap<MuID, P<MuFuncSig>>>, // +400
func_sigs: RwLock<HashMap<MuID, P<MuFuncSig>>>,
/// functions declared to the VM
funcs: RwLock<HashMap<MuID, RwLock<MuFunction>>>, // +456
funcs: RwLock<HashMap<MuID, RwLock<MuFunction>>>,
/// primordial function that is set to make boot image
primordial: RwLock<Option<PrimordialThreadInfo>>, // +568
primordial: RwLock<Option<PrimordialThreadInfo>>,
/// current options for this VM
pub vm_options: VMOptions, // +624
......@@ -129,6 +131,7 @@ unsafe impl rodal::Dump for VM {
dumper.dump_object(&self.id_name_map);
dumper.dump_object(&self.name_id_map);
dumper.dump_object(&self.types);
dumper.dump_object(&self.ref_types);
dumper.dump_object(&self.backend_type_info);
dumper.dump_object(&self.constants);
dumper.dump_object(&self.globals);
......@@ -213,6 +216,7 @@ impl<'a> VM {
name_id_map: RwLock::new(HashMap::new()),
constants: RwLock::new(HashMap::new()),
types: RwLock::new(HashMap::new()),
ref_types: RwLock::new(HashMap::new()),
backend_type_info: RwLock::new(HashMap::new()),
globals: RwLock::new(HashMap::new()),
global_locations: RwLock::new(hashmap!{}),
......@@ -789,6 +793,27 @@ impl<'a> VM {
}
}
pub fn make_strong_type(&self, ty: P<MuType>) -> P<MuType> {
match &ty.v {
&MuType_::WeakRef(ref t) => {
let res = self.ref_types
.read()
.unwrap()
.get(&t.id())
.map(|x| x.clone());
match res {
Some(ty) => ty,
None => {
let ty = P(MuType::new(self.next_id(), MuType_::muref(t.clone())));
self.ref_types.write().unwrap().insert(t.id(), ty.clone());
ty
}
}
}
_ => ty.clone()
}
}
/// adds a new bundle into VM.
/// This function will drain the contents of all arguments. Ideally, this function should
/// happen atomically. e.g. The client should not see a new type added without also seeing
......@@ -1197,7 +1222,7 @@ impl<'a> VM {
pub fn new_stack(&self, func_id: MuID) -> Box<MuStack> {
let funcs = self.funcs.read().unwrap();
let func: &MuFunction = &funcs.get(&func_id).unwrap().read().unwrap();
Box::new(MuStack::new(
self.next_id(),
self.get_address_for_func(func_id),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment