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

Commit 59cde7c2 authored by Isaac Oscar Gariano's avatar Isaac Oscar Gariano
Browse files

Updated rustfmtint

parent 29035774
......@@ -25,7 +25,7 @@ use std::fmt;
#[derive(Clone)]
pub struct APIHandle {
pub id: MuID,
pub v: APIHandleValue
pub v: APIHandleValue,
}
/// when we returning an API handle to the client, we create a Box<APIHandle>,
......@@ -121,7 +121,7 @@ pub enum APIHandleValue {
ExcParam,
/// instruction result value
// TODO: unused
InstRes
InstRes,
}
impl fmt::Display for APIHandleValue {
......@@ -159,7 +159,7 @@ impl fmt::Debug for APIHandleValue {
&ExpFunc => write!(f, "IR.expfunc"),
&NorParam => write!(f, "IR.norparam"),
&ExcParam => write!(f, "IR.excparam"),
&InstRes => write!(f, "IR.instres")
&InstRes => write!(f, "IR.instres"),
}
}
}
......@@ -170,9 +170,9 @@ impl APIHandleValue {
match self {
&APIHandleValue::Ref(ref ty, addr) | &APIHandleValue::IRef(ref ty, addr) => (
ty.clone(),
addr
addr,
),
_ => panic!("expected Ref or IRef handle")
_ => panic!("expected Ref or IRef handle"),
}
}
......@@ -180,7 +180,7 @@ impl APIHandleValue {
pub fn as_ref(&self) -> (P<MuType>, Address) {
match self {
&APIHandleValue::Ref(ref ty, addr) => (ty.clone(), addr),
_ => panic!("expected Ref handle")
_ => panic!("expected Ref handle"),
}
}
......@@ -188,7 +188,7 @@ impl APIHandleValue {
pub fn as_iref(&self) -> (P<MuType>, Address) {
match self {
&APIHandleValue::IRef(ref ty, addr) => (ty.clone(), addr),
_ => panic!("expected IRef handle")
_ => panic!("expected IRef handle"),
}
}
......@@ -212,7 +212,7 @@ impl APIHandleValue {
pub fn as_int(&self) -> u64 {
match self {
&APIHandleValue::Int(val, _) => val,
_ => panic!("expected Int handle")
_ => panic!("expected Int handle"),
}
}
......@@ -220,7 +220,7 @@ impl APIHandleValue {
pub fn as_float(&self) -> f32 {
match self {
&APIHandleValue::Float(val) => val,
_ => panic!("expected Float handle")
_ => panic!("expected Float handle"),
}
}
......@@ -228,7 +228,7 @@ impl APIHandleValue {
pub fn as_double(&self) -> f64 {
match self {
&APIHandleValue::Double(val) => val,
_ => panic!("expected Double handle")
_ => panic!("expected Double handle"),
}
}
......@@ -236,7 +236,7 @@ impl APIHandleValue {
pub fn as_uptr(&self) -> (P<MuType>, Address) {
match self {
&APIHandleValue::UPtr(ref ty, addr) => (ty.clone(), addr),
_ => panic!("expected UPtr handle")
_ => panic!("expected UPtr handle"),
}
}
......@@ -244,7 +244,7 @@ impl APIHandleValue {
pub fn as_ufp(&self) -> (P<MuType>, Address) {
match self {
&APIHandleValue::UFP(ref ty, addr) => (ty.clone(), addr),
_ => panic!("expected UFP handle")
_ => panic!("expected UFP handle"),
}
}
......@@ -252,7 +252,7 @@ impl APIHandleValue {
pub fn as_funcref(&self) -> MuID {
match self {
&APIHandleValue::FuncRef(id) => id,
_ => panic!("expected FuncRef")
_ => panic!("expected FuncRef"),
}
}
......@@ -260,7 +260,7 @@ impl APIHandleValue {
pub fn as_tr64(&self) -> u64 {
match self {
&APIHandleValue::TagRef64(val) => val,
_ => panic!("expected TagRef64 handle")
_ => panic!("expected TagRef64 handle"),
}
}
}
......@@ -117,7 +117,7 @@ pub struct VM {
pub compiled_callsite_table: RwLock<HashMap<Address, CompiledCallsite>>, // 896
/// Nnmber of callsites in the callsite tables
pub callsite_count: AtomicUsize
pub callsite_count: AtomicUsize,
}
unsafe impl rodal::Dump for VM {
......@@ -141,23 +141,23 @@ unsafe impl rodal::Dump for VM {
// Dump empty maps so that we can safely read and modify them once loaded
dumper.dump_padding(&self.global_locations);
dumper.dump_object_here(&RwLock::new(
rodal::EmptyHashMap::<MuID, ValueLocation>::new()
rodal::EmptyHashMap::<MuID, ValueLocation>::new(),
));
dumper.dump_padding(&self.func_vers);
dumper.dump_object_here(&RwLock::new(
rodal::EmptyHashMap::<MuID, RwLock<MuFunctionVersion>>::new()
rodal::EmptyHashMap::<MuID, RwLock<MuFunctionVersion>>::new(),
));
dumper.dump_padding(&self.aot_pending_funcref_store);
dumper.dump_object_here(&RwLock::new(
rodal::EmptyHashMap::<Address, ValueLocation>::new()
rodal::EmptyHashMap::<Address, ValueLocation>::new(),
));
// Dump an emepty hashmap for the other hashmaps
dumper.dump_padding(&self.compiled_callsite_table);
dumper.dump_object_here(&RwLock::new(
rodal::EmptyHashMap::<Address, CompiledCallsite>::new()
rodal::EmptyHashMap::<Address, CompiledCallsite>::new(),
));
dumper.dump_object(&self.callsite_count);
}
......@@ -222,7 +222,7 @@ impl<'a> VM {
primordial: RwLock::new(None),
aot_pending_funcref_store: RwLock::new(HashMap::new()),
compiled_callsite_table: RwLock::new(HashMap::new()),
callsite_count: ATOMIC_USIZE_INIT
callsite_count: ATOMIC_USIZE_INIT,
};
// insert all internal types
......@@ -254,7 +254,7 @@ impl<'a> VM {
options.flag_gc_immixspace_size,
options.flag_gc_lospace_size,
options.flag_gc_nthreads,
!options.flag_gc_disable_collection
!options.flag_gc_disable_collection,
);
}
}
......@@ -298,7 +298,7 @@ impl<'a> VM {
LogLevel::Warn => 1,
LogLevel::Info => 2,
LogLevel::Debug => 3,
LogLevel::Trace => 4
LogLevel::Trace => 4,
};
match stderrlog::new().verbosity(verbose).init() {
......@@ -394,8 +394,8 @@ impl<'a> VM {
CompiledCallsite::new(
&callsite,
compiled_func.func_ver_id,
callee_saved_table.clone()
)
callee_saved_table.clone(),
),
);
}
}
......@@ -438,7 +438,7 @@ impl<'a> VM {
let map = self.name_id_map.read().unwrap();
match map.get(name) {
Some(id) => *id,
None => panic!("cannot find id for name: {}", name)
None => panic!("cannot find id for name: {}", name),
}
}
......@@ -455,7 +455,7 @@ impl<'a> VM {
let ret = P(Value {
hdr: entity,
ty: ty,
v: Value_::Constant(val)
v: Value_::Constant(val),
});
let mut constants = self.constants.write().unwrap();
......@@ -469,7 +469,7 @@ impl<'a> VM {
&self,
map: &mut RwLockWriteGuard<HashMap<MuID, P<Value>>>,
id: MuID,
val: P<Value>
val: P<Value>,
) {
debug_assert!(!map.contains_key(&id));
......@@ -482,7 +482,7 @@ impl<'a> VM {
let const_lock = self.constants.read().unwrap();
match const_lock.get(&id) {
Some(ret) => ret.clone(),
None => panic!("cannot find const #{}", id)
None => panic!("cannot find const #{}", id),
}
}
......@@ -503,9 +503,9 @@ impl<'a> VM {
hdr: entity,
ty: self.declare_type(
MuEntityHeader::unnamed(self.next_id()),
MuType_::iref(ty.clone())
MuType_::iref(ty.clone()),
),
v: Value_::Global(ty)
v: Value_::Global(ty),
});
let mut globals = self.globals.write().unwrap();
......@@ -521,7 +521,7 @@ impl<'a> VM {
globals: &mut RwLockWriteGuard<HashMap<MuID, P<Value>>>,
global_locs: &mut RwLockWriteGuard<HashMap<MuID, ValueLocation>>,
id: MuID,
val: P<Value>
val: P<Value>,
) {
self.declare_global_internal_no_alloc(globals, id, val.clone());
self.alloc_global(global_locs, id, val);
......@@ -534,7 +534,7 @@ impl<'a> VM {
&self,
globals: &mut RwLockWriteGuard<HashMap<MuID, P<Value>>>,
id: MuID,
val: P<Value>
val: P<Value>,
) {
debug_assert!(!globals.contains_key(&id));
......@@ -547,7 +547,7 @@ impl<'a> VM {
&self,
global_locs: &mut RwLockWriteGuard<HashMap<MuID, ValueLocation>>,
id: MuID,
val: P<Value>
val: P<Value>,
) {
let backend_ty = self.get_backend_type_info(val.ty.get_referent_ty().unwrap().id());
let loc = gc::allocate_global(val, backend_ty);
......@@ -570,7 +570,7 @@ impl<'a> VM {
&self,
types: &mut RwLockWriteGuard<HashMap<MuID, P<MuType>>>,
id: MuID,
ty: P<MuType>
ty: P<MuType>,
) {
debug_assert!(!types.contains_key(&id));
......@@ -596,7 +596,7 @@ impl<'a> VM {
let type_lock = self.types.read().unwrap();
match type_lock.get(&id) {
Some(ret) => ret.clone(),
None => panic!("cannot find type #{}", id)
None => panic!("cannot find type #{}", id),
}
}
......@@ -605,12 +605,12 @@ impl<'a> VM {
&self,
entity: MuEntityHeader,
ret_tys: Vec<P<MuType>>,
arg_tys: Vec<P<MuType>>
arg_tys: Vec<P<MuType>>,
) -> P<MuFuncSig> {
let ret = P(MuFuncSig {
hdr: entity,
ret_tys: ret_tys,
arg_tys: arg_tys
arg_tys: arg_tys,
});
let mut func_sigs = self.func_sigs.write().unwrap();
......@@ -624,7 +624,7 @@ impl<'a> VM {
&self,
sigs: &mut RwLockWriteGuard<HashMap<MuID, P<MuFuncSig>>>,
id: MuID,
sig: P<MuFuncSig>
sig: P<MuFuncSig>,
) {
debug_assert!(!sigs.contains_key(&id));
......@@ -637,7 +637,7 @@ impl<'a> VM {
let func_sig_lock = self.func_sigs.read().unwrap();
match func_sig_lock.get(&id) {
Some(ret) => ret.clone(),
None => panic!("cannot find func sig #{}", id)
None => panic!("cannot find func sig #{}", id),
}
}
......@@ -653,7 +653,7 @@ impl<'a> VM {
&self,
funcs: &mut RwLockWriteGuard<HashMap<MuID, RwLock<MuFunction>>>,
id: MuID,
func: MuFunction
func: MuFunction,
) {
debug_assert!(!funcs.contains_key(&id));
......@@ -668,7 +668,7 @@ impl<'a> VM {
let funcs_lock = self.funcs.read().unwrap();
match funcs_lock.get(&id) {
Some(func) => func.read().unwrap().name(),
None => panic!("cannot find name for Mu function #{}")
None => panic!("cannot find name for Mu function #{}"),
}
}
......@@ -677,7 +677,7 @@ impl<'a> VM {
let funcs_lock = self.funcs.read().unwrap();
match funcs_lock.get(&id) {
Some(func) => func.read().unwrap().sig.clone(),
None => panic!("cannot find Mu function #{}", id)
None => panic!("cannot find Mu function #{}", id),
}
}
......@@ -690,7 +690,7 @@ impl<'a> VM {
let func_guard = rwlock_func.read().unwrap();
func_guard.cur_ver
}
None => None
None => None,
}
}
......@@ -746,7 +746,7 @@ impl<'a> VM {
new_globals: &mut HashMap<MuID, P<Value>>,
new_funcs: &mut HashMap<MuID, Box<MuFunction>>,
new_func_vers: &mut HashMap<MuID, Box<MuFunctionVersion>>,
arc_vm: Arc<VM>
arc_vm: Arc<VM>,
) {
// Make sure other components, if ever acquiring multiple locks at the same time, acquire
// them in this order, to prevent deadlock.
......@@ -858,7 +858,7 @@ impl<'a> VM {
let types = self.types.read().unwrap();
let ty = match types.get(&tyid) {
Some(ty) => ty,
None => panic!("invalid type id during get_backend_type_info(): {}", tyid)
None => panic!("invalid type id during get_backend_type_info(): {}", tyid),
};
let resolved = Box::new(backend::BackendType::resolve(ty, self));
......@@ -922,7 +922,7 @@ impl<'a> VM {
*guard = Some(PrimordialThreadInfo {
func_id: func_id,
has_const_args: has_const_args,
args: args
args: args,
});
}
......@@ -955,7 +955,7 @@ impl<'a> VM {
sym_strings: Vec<String>,
reloc_fields: Vec<&APIHandle>,
reloc_strings: Vec<String>,
output_file: String
output_file: String,
) {
self.make_boot_image_internal(
whitelist,
......@@ -967,7 +967,7 @@ impl<'a> VM {
reloc_fields,
reloc_strings,
vec![],
output_file
output_file,
)
}
......@@ -986,7 +986,7 @@ impl<'a> VM {
reloc_fields: Vec<&APIHandle>,
reloc_strings: Vec<String>,
extra_sources_to_link: Vec<String>,
output_file: String
output_file: String,
) {
info!("Making boot image...");
......@@ -1010,7 +1010,7 @@ impl<'a> VM {
compiler.compile(&mut func_ver);
}
}
None => panic!("whitelist function {} has no version defined", f)
None => panic!("whitelist function {} has no version defined", f),
}
}
}
......@@ -1124,7 +1124,7 @@ impl<'a> VM {
Box::new(MuStack::new(
self.next_id(),
self.get_address_for_func(func_id),
func
func,
))
}
......@@ -1146,7 +1146,7 @@ impl<'a> VM {
self.new_handle(APIHandle {
id: self.next_id(),
v: APIHandleValue::Ref(ty, addr)
v: APIHandleValue::Ref(ty, addr),
})
}
......@@ -1168,7 +1168,7 @@ impl<'a> VM {
self.new_handle(APIHandle {
id: self.next_id(),
v: APIHandleValue::Ref(ty, addr)
v: APIHandleValue::Ref(ty, addr),
})
}
......@@ -1186,7 +1186,7 @@ impl<'a> VM {
self.new_handle(APIHandle {
id: handle_id,
v: APIHandleValue::Ref(inner_ty, addr)
v: APIHandleValue::Ref(inner_ty, addr),
})
}
APIHandleValue::IRef(_, addr) => {
......@@ -1195,12 +1195,12 @@ impl<'a> VM {
self.new_handle(APIHandle {
id: handle_id,
v: APIHandleValue::IRef(inner_ty, addr)
v: APIHandleValue::IRef(inner_ty, addr),
})
}
APIHandleValue::FuncRef(_) => unimplemented!(),
_ => panic!("unexpected operand for refcast: {:?}", from_op)
_ => panic!("unexpected operand for refcast: {:?}", from_op),
}
}
......@@ -1211,7 +1211,7 @@ impl<'a> VM {
// assume iref has the same address as ref
let ret = self.new_handle(APIHandle {
id: self.next_id(),
v: APIHandleValue::IRef(ty, addr)
v: APIHandleValue::IRef(ty, addr),
});
trace!("API: get iref from {:?}", handle_ref);
......@@ -1224,7 +1224,7 @@ impl<'a> VM {
pub fn handle_shift_iref(
&self,
handle_iref: APIHandleArg,
offset: APIHandleArg
offset: APIHandleArg,
) -> APIHandleResult {
let (ty, addr) = handle_iref.v.as_iref();
let offset = self.handle_to_uint64(offset);
......@@ -1239,7 +1239,7 @@ impl<'a> VM {
let ret = self.new_handle(APIHandle {
id: self.next_id(),
v: APIHandleValue::IRef(ty, offset_addr)
v: APIHandleValue::IRef(ty, offset_addr),
});
trace!("API: shift iref from {:?}", handle_iref);
......@@ -1252,14 +1252,14 @@ impl<'a> VM {
pub fn handle_get_elem_iref(
&self,
handle_iref: APIHandleArg,
index: APIHandleArg
index: APIHandleArg,
) -> APIHandleResult {
let (ty, addr) = handle_iref.v.as_iref();
let index = self.handle_to_uint64(index);
let ele_ty = match ty.get_elem_ty() {
Some(ty) => ty,
None => panic!("cannot get element ty from {}", ty)
None => panic!("cannot get element ty from {}", ty),
};
let elem_addr = {
use utils::math::align_up;
......@@ -1271,7 +1271,7 @@ impl<'a> VM {
let ret = self.new_handle(APIHandle {
id: self.next_id(),
v: APIHandleValue::IRef(ele_ty, elem_addr)
v: APIHandleValue::IRef(ele_ty, elem_addr),
});
trace!(
......@@ -1295,12 +1295,12 @@ impl<'a> VM {
let varpart_ty = match ty.get_hybrid_varpart_ty() {
Some(ty) => ty,
None => panic!("cannot get varpart ty from {}", ty)
None => panic!("cannot get varpart ty from {}", ty),
};
let ret = self.new_handle(APIHandle {
id: self.next_id(),
v: APIHandleValue::IRef(varpart_ty, varpart_addr)
v: APIHandleValue::IRef(varpart_ty, varpart_addr),
});
trace!("API: get var part iref from {:?}", handle_iref);
......@@ -1313,13 +1313,13 @@ impl<'a> VM {
pub fn handle_get_field_iref(
&self,
handle_iref: APIHandleArg,
field: usize
field: usize,
) -> APIHandleResult {
let (ty, addr) = handle_iref.v.as_iref();
let field_ty = match ty.get_field_ty(field) {
Some(ty) => ty,
None => panic!("ty is not struct ty: {}", ty)
None => panic!("ty is not struct ty: {}", ty),
};
let field_addr = {
......@@ -1330,7 +1330,7 @@ impl<'a> VM {
let ret = self.new_handle(APIHandle {
id: self.next_id(),
v: APIHandleValue::IRef(field_ty, field_addr)
v: APIHandleValue::IRef(field_ty, field_addr),
});
trace!(
......@@ -1355,7 +1355,7 @@ impl<'a> VM {
MemoryOrder::SeqCst => Ordering::SeqCst,
MemoryOrder::NotAtomic => Ordering::Relaxed, // use relax for not atomic
MemoryOrder::Consume => Ordering::Acquire, // use acquire for consume
_ => panic!("unsupported order {:?} for LOAD", ord)
_ => panic!("unsupported order {:?} for LOAD", ord),
};
let handle_id = self.next_id();
......@@ -1369,13 +1369,13 @@ impl<'a> VM {
MuType_::UPtr(ref ty) => APIHandleValue::UPtr(ty.clone(), addr.load::<Address>()),
MuType_::Tagref64 => APIHandleValue::TagRef64(addr.load::<u64>()),
_ => unimplemented!()
_ => unimplemented!(),
}
};
let ret = self.new_handle(APIHandle {
id: handle_id,
v: handle_value
v: handle_value,
});
trace!("API: load from {:?}", loc);
......@@ -1396,7 +1396,7 @@ impl<'a> VM {
MemoryOrder::Release => Ordering::Release,
MemoryOrder::SeqCst => Ordering::SeqCst,
MemoryOrder::NotAtomic => Ordering::Relaxed, // use relaxed for not atomic
_ => panic!("unsupported order {:?} for STORE", ord)
_ => panic!("unsupported order {:?} for STORE", ord),
};
// get value and store
......@@ -1410,7 +1410,7 @@ impl<'a> VM {
9...16 => addr.store::<u16>(trunc as u16),
17...32 => addr.store::<u32>(trunc as u32),
33...64 => addr.store::<u64>(trunc as u64),
_ => panic!("unimplemented int length")
_ => panic!("unimplemented int length"),
}
}
APIHandleValue::TagRef64(val) => addr.store::<u64>(val),
......@@ -1436,7 +1436,7 @@ impl<'a> VM {
}
}
_ => unimplemented!()
_ => unimplemented!(),
}
}
......@@ -1454,7 +1454,7 @@ impl<'a> VM {
let mut pending_funcref_guard = self.aot_pending_funcref_store.write().unwrap();
pending_funcref_guard.insert(
addr,
ValueLocation::Relocatable(backend::RegGroup::GPR, symbol)
ValueLocation::Relocatable(backend::RegGroup::GPR, symbol),
);
}
......@@ -1470,7 +1470,7 @@ impl<'a> VM {
let (ty, addr) = loc.v.as_ref_or_iref();
self.new_handle(APIHandle {
id: self.next_id(),
v: APIHandleValue::UPtr(ty, addr)
v: APIHandleValue::UPtr(ty, addr),
})
}
......@@ -1490,7 +1490,7 @@ impl<'a> VM {
let (ty, addr) = loc.v.as_ref_or_iref();
self.new_handle(APIHandle {
id: self.next_id(),
v: APIHandleValue::UPtr(ty, addr)
v: APIHandleValue::UPtr(ty, addr),
})
}
......@@ -1500,7 +1500,7 @@ impl<'a> VM {
self.new_handle(APIHandle {
id: handle_id,
v: APIHandleValue::FuncRef(id)
v: APIHandleValue::FuncRef(id),
})
}
......@@ -1520,7 +1520,7 @@ impl<'a> VM {
self.new_handle(APIHandle {
id: handle_id,
v: APIHandleValue::IRef(global_inner_ty, global_iref)
v: APIHandleValue::IRef(global_inner_ty, global_iref),
})
}
......@@ -1548,29 +1548,29 @@ impl<'a> VM {
APIHandle {
id: handle_id,
v: APIHandleValue::Int(val, len)
v: APIHandleValue::Int(val, len),
}
}
Value_::Constant(Constant::Float(val)) => {