To protect your data, the CISO officer has suggested users to enable 2FA as soon as possible.
Currently 2.7% of users enabled 2FA.

Commit 2d919b3e authored by Isaac Oscar Gariano's avatar Isaac Oscar Gariano
Browse files

Fixed botched merge (hopefully)

parent a184c8d8
......@@ -948,7 +948,7 @@ impl fmt::Debug for BinOpStatus {
}
}
#[derive(Copy, Clone, Debug)]
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum MemoryOrder {
NotAtomic,
Relaxed,
......@@ -1072,4 +1072,4 @@ fn op_vector_str(vec: &Vec<OpIndex>, ops: &Vec<P<TreeNode>>) -> String {
}
}
ret
}
\ No newline at end of file
}
......@@ -75,6 +75,14 @@ lazy_static! {
MuType::new(new_internal_id(), MuType_::iref(VOID_TYPE.clone()))
);
pub static ref STACKREF_TYPE : P<MuType> = P(
MuType::new(new_internal_id(), MuType_::StackRef)
);
pub static ref THREADREF_TYPE : P<MuType> = P(
MuType::new(new_internal_id(), MuType_::ThreadRef)
);
pub static ref INTERNAL_TYPES : Vec<P<MuType>> = vec![
ADDRESS_TYPE.clone(),
UINT1_TYPE.clone(),
......@@ -89,6 +97,8 @@ lazy_static! {
VOID_TYPE.clone(),
REF_VOID_TYPE.clone(),
IREF_VOID_TYPE.clone(),
STACKREF_TYPE.clone(),
THREADREF_TYPE.clone(),
];
}
......@@ -106,7 +116,7 @@ pub fn init_types() {
}
/// MuType represents a Mu type
#[derive(PartialEq, Debug)]
#[derive(Debug)]
pub struct MuType {
pub hdr: MuEntityHeader,
pub v: MuType_
......@@ -138,9 +148,17 @@ impl MuType {
_ => false
}
}
pub fn is_stackref(&self) -> bool {
match self.v {
MuType_::StackRef => true,
_ => false
}
}
pub fn is_funcref(&self) -> bool {
match self.v {
MuType_::FuncRef(_) => true,
MuType_::Struct(_) => true,
_ => false
}
}
......@@ -153,6 +171,13 @@ impl MuType {
}
}
pub fn is_void(&self) -> bool {
match self.v {
MuType_::Void => true,
_ => false
}
}
/// is this type hybrid type?
pub fn is_hybrid(&self) -> bool {
match self.v {
......@@ -432,7 +457,7 @@ pub type StructTag = MuName;
pub type HybridTag = MuName;
/// MuType_ is used for pattern matching for MuType
#[derive(PartialEq, Debug)]
#[derive(PartialEq, Debug, Clone)]
pub enum MuType_ {
/// int <length>
Int(usize),
......@@ -480,7 +505,14 @@ pub enum MuType_ {
/// ufuncptr<@sig>
UFuncPtr(P<MuFuncSig>)
}
impl MuType_ {
pub fn strong_variant(&self) -> MuType_ {
match self {
&MuType_::WeakRef(ref t) => MuType_::Ref(t.clone()),
_ => self.clone()
}
}
}
rodal_enum!(MuType_{(Int: size), Float, Double, (Ref: ty), (IRef: ty), (WeakRef: ty), (UPtr: ty),
(Struct: tag), (Array: ty, size), (Hybrid: tag), Void, ThreadRef, StackRef, Tagref64,
(Vector: ty, size), (FuncRef: ty), (UFuncPtr: ty)});
......@@ -788,4 +820,4 @@ impl fmt::Display for MuFuncSig {
}
}
pub type CFuncSig = MuFuncSig;
\ No newline at end of file
pub type CFuncSig = MuFuncSig;
......@@ -307,7 +307,6 @@ fn dfs(cur: MuID, stack: &mut Vec<MuID>, visited: &mut Vec<MuID>, func: &mut MuF
// call
Call { ref resume, .. } |
CCall { ref resume, .. } |
SwapStackExc { ref resume, .. } |
ExnInstruction { ref resume, .. } => {
let ref normal = resume.normal_dest;
let ref exn = resume.exn_dest;
......
......@@ -216,7 +216,6 @@ fn emit_muir_dot_inner(file: &mut File, f_name: String, f_content: &FunctionCont
}
Call { ref resume, .. } |
CCall { ref resume, .. } |
SwapStackExc { ref resume, .. } |
ExnInstruction { ref resume, .. } => {
let ref normal = resume.normal_dest;
let ref exn = resume.exn_dest;
......@@ -295,7 +294,7 @@ fn emit_muir_dot_inner(file: &mut File, f_name: String, f_content: &FunctionCont
vec_utils::as_str(&enable_dest.get_arguments(&ops))
).unwrap();
}
Return(_) | Throw(_) | ThreadExit | TailCall(_) | SwapStackKill { .. } => {}
Return(_) | Throw(_) | TailCall(_) => {}
_ => {
panic!("unexpected terminating instruction: {}", inst);
......
......@@ -234,8 +234,6 @@ impl CompilerPass for GenMovPhi {
}
Instruction_::Watchpoint { .. } => unimplemented!(),
Instruction_::WPBranch { .. } => unimplemented!(),
Instruction_::SwapStackExc { .. } |
Instruction_::SwapStackKill { .. } => unimplemented!(),
Instruction_::ExnInstruction { .. } => unimplemented!(),
_ => {
trace!("no rewrite");
......
......@@ -584,7 +584,6 @@ fn copy_inline_blocks(
&Instruction_::Watchpoint { .. } |
&Instruction_::WPBranch { .. } |
&Instruction_::SwapStackExc { .. } |
&Instruction_::ExnInstruction { .. } => unimplemented!(),
_ => {
......
......@@ -22,8 +22,8 @@ use utils::bit_utils::bits_ones;
use std;
macro_rules! assert_ir {
($ cond : expr ) => { assert!($cond) };
($ cond : expr , $ ( $ arg : tt ) + ) => { assert!($cond, $($arg)+)};
($ cond : expr ) => { debug_assert!($cond) };
($ cond : expr , $ ( $ arg : tt ) + ) => { debug_assert!($cond, $($arg)+)};
}
pub struct MuIRBuilder {
......@@ -57,6 +57,8 @@ pub struct TransientBundle {
insts: IdBMap<NodeInst>,
dest_clauses: IdBMap<NodeDestClause>,
exc_clauses: IdBMap<NodeExcClause>,
cs_clauses: IdBMap<NodeCurrentStackClause>,
ns_clauses: IdBMap<NodeNewStackClause>,
ka_clauses: IdBMap<NodeKeepaliveClause>
}
......@@ -2376,7 +2378,7 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
ty,
opnd1,
opnd2,
exc_clause: _
exc_clause
} => {
let impl_optr = match optr {
CMU_BINOP_ADD => BinOp::Add,
......@@ -2405,7 +2407,7 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
assert_ir!(
impl_opnd1.ty() == impl_opnd2.ty() && impl_opnd1.ty() == impl_ty,
"Invalid instruction {:?}: Operand types {} and {} \
are not what was expected {}",
are not what was expected {}",
inst,
impl_opnd1.ty(),
impl_opnd2.ty(),
......@@ -2424,6 +2426,10 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
let impl_rv = self.new_ssa(fcb, result_id, impl_ty).clone_value();
if exc_clause.is_some() {
unimplemented!()
}
if flags == 0 {
// binop
Instruction {
......@@ -2561,6 +2567,7 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
let impl_i1 = self.ensure_i1();
let impl_opnd1 = self.get_treenode(fcb, opnd1);
let impl_opnd2 = self.get_treenode(fcb, opnd2);
let impl_ty = self.get_built_type(ty);
let impl_rv = self.new_ssa(fcb, result_id, impl_i1).clone_value();
assert_ir!(
......@@ -2709,6 +2716,9 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
let impl_rv = self.new_ssa(fcb, result_id, impl_opnd_ty.clone())
.clone_value();
assert_ir!(impl_cond_ty.is_int() && impl_cond_ty.get_int_length().unwrap() == 1);
assert_ir!(impl_if_true.ty() == impl_opnd_ty && impl_if_false.ty() == impl_opnd_ty);
Instruction {
hdr: hdr,
value: Some(vec![impl_rv]),
......@@ -2771,7 +2781,10 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
} => {
let mut ops: Vec<P<TreeNode>> = Vec::new();
self.add_opnd(fcb, &mut ops, opnd);
let impl_opnd = self.add_opnd(fcb, &mut ops, opnd);
let impl_opnd_ty = self.get_built_type(opnd_ty);
assert_ir!(impl_opnd_ty.is_eq_comparable());
assert_ir!(impl_opnd.ty() == impl_opnd_ty);
let impl_dest_def =
self.build_destination(fcb, default_dest, &mut ops, &[], blocks);
......@@ -2813,11 +2826,13 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
exc_clause,
keepalive_clause
} => {
let impl_sig = self.ensure_sig_rec(sig);
self.build_call_or_ccall(
fcb,
hdr,
result_ids,
sig,
&impl_sig,
callee,
args,
exc_clause,
......@@ -2876,7 +2891,7 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
}
NodeInst::NodeThrow { id: _, exc } => {
let impl_exc = self.get_treenode(fcb, exc);
assert_ir!(impl_exc.ty().is_ref());
Instruction {
hdr: hdr,
value: None,
......@@ -2895,6 +2910,7 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
"exc_clause is not implemented for NEW"
);
let impl_allocty = self.get_built_type(allocty);
assert_ir!(!impl_allocty.is_hybrid());
let impl_rvtype = self.ensure_ref(allocty);
let impl_rv = self.new_ssa(fcb, result_id, impl_rvtype).clone_value();
Instruction {
......@@ -2917,9 +2933,14 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
"exc_clause is not implemented for NEWHYBRID"
);
let impl_allocty = self.get_built_type(allocty);
let impl_lenty = self.get_built_type(lenty);
let impl_length = self.get_treenode(fcb, length);
let impl_rvtype = self.ensure_ref(allocty);
let impl_rv = self.new_ssa(fcb, result_id, impl_rvtype).clone_value();
assert_ir!(impl_allocty.is_hybrid() && impl_lenty.is_int());
assert_ir!(impl_lenty == impl_length.ty());
Instruction {
hdr: hdr,
value: Some(vec![impl_rv]),
......@@ -2940,6 +2961,8 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
let impl_allocty = self.get_built_type(allocty);
let impl_rvtype = self.ensure_iref(allocty);
let impl_rv = self.new_ssa(fcb, result_id, impl_rvtype).clone_value();
assert_ir!(!impl_allocty.is_hybrid());
Instruction {
hdr: hdr,
value: Some(vec![impl_rv]),
......@@ -2960,9 +2983,14 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
"exc_clause is not implemented for ALLOCAHYBRID"
);
let impl_allocty = self.get_built_type(allocty);
let impl_lenty = self.get_built_type(lenty);
let impl_length = self.get_treenode(fcb, length);
let impl_rvtype = self.ensure_iref(allocty);
let impl_rv = self.new_ssa(fcb, result_id, impl_rvtype).clone_value();
assert_ir!(impl_allocty.is_hybrid() && impl_lenty.is_int());
assert_ir!(impl_lenty == impl_length.ty());
Instruction {
hdr: hdr,
value: Some(vec![impl_rv]),
......@@ -2976,9 +3004,16 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
refty,
opnd
} => {
let impl_refty = self.get_built_type(refty);
let impl_opnd = self.get_treenode(fcb, opnd);
let impl_rvtype = self.ensure_iref(refty);
let impl_rv = self.new_ssa(fcb, result_id, impl_rvtype).clone_value();
assert_ir!(match impl_opnd.ty().v {
MuType_::Ref(ref r) => *r == impl_refty,
_ => false
});
Instruction {
hdr: hdr,
value: Some(vec![impl_rv]),
......@@ -2996,6 +3031,7 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
} => {
let impl_opnd = self.get_treenode(fcb, opnd);
let index = index as usize;
let impl_refty = self.get_built_type(refty);
let refty_node = self.b.bundle.types.get(&refty).unwrap();
assert_ir!(
......@@ -3047,12 +3083,14 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
result_id,
is_ptr,
refty,
indty: _,
indty,
opnd,
index
} => {
let impl_opnd = self.get_treenode(fcb, opnd);
let impl_index = self.get_treenode(fcb, index);
let impl_refty = self.get_built_type(refty);
let impl_indty = self.get_built_type(indty);
let refty_node = self.b.bundle.types.get(&refty).unwrap();
assert_ir!(impl_indty.is_int() && impl_index.ty() == impl_indty);
......@@ -3105,7 +3143,7 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
result_id,
is_ptr,
refty,
offty: _,
offty,
opnd,
offset
} => {
......@@ -3201,8 +3239,8 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
let impl_ord = self.build_mem_ord(ord);
let impl_loc = self.get_treenode(fcb, loc);
let impl_rvtype = self.get_built_type(refty);
let impl_rv = self.new_ssa(fcb, result_id, self.vm.make_strong_type(impl_rvtype))
.clone_value();
let impl_rv = self.new_ssa(fcb, result_id,
self.vm.make_strong_type(impl_rvtype)).clone_value();
let impl_refty = self.get_built_type(refty);
assert_ir!(impl_ord != MemoryOrder::Release && impl_ord != MemoryOrder::AcqRel);
......@@ -3282,8 +3320,8 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
NodeInst::NodeCCall {
id: _,
ref result_ids,
callconv: _,
callee_ty: _,
callconv,
callee_ty,
sig,
callee,
ref args,
......@@ -3303,7 +3341,7 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
fcb,
hdr,
result_ids,
sig,
&impl_sig,
callee,
args,
exc_clause,
......@@ -3393,7 +3431,8 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
opnd: MuID
) -> P<TreeNode> {
let impl_opnd = self.get_treenode(fcb, opnd);
ops.push(impl_opnd);
ops.push(impl_opnd.clone());
impl_opnd
}
fn add_opnds(
......@@ -3404,8 +3443,9 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
) -> Vec<P<TreeNode>> {
let mut res = Vec::<P<TreeNode>>::new();
for opnd in opnds {
self.add_opnd(fcb, ops, *opnd)
res.push(self.add_opnd(fcb, ops, *opnd))
}
res
}
fn build_call_data(
......@@ -3414,10 +3454,12 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
ops: &mut Vec<P<TreeNode>>,
callee: MuID,
args: &[MuID],
sig: &P<MuFuncSig>,
is_ccall: bool,
call_conv: CallConvention
) -> CallData {
let func_index = ops.len();
self.add_opnd(fcb, ops, callee);
let callee = self.add_opnd(fcb, ops, callee);
let args_begin_index = ops.len();
let impl_args = self.add_opnds(fcb, ops, args);
......@@ -3450,7 +3492,7 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
fcb: &mut FuncCtxBuilder,
hdr: MuEntityHeader,
result_ids: &[MuID],
sig: MuID,
sig: &P<MuFuncSig>,
callee: MuID,
args: &[MuID],
exc_clause: Option<MuID>,
......@@ -3471,12 +3513,13 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
CallConvention::Mu
);
let rettys = &sig.ret_tys;
assert_ir!(result_ids.len() == rettys.len());
let rvs = result_ids
.iter()
.zip(rettys_ids)
.map(|(rvid, rvty)| {
let impl_rvty = self.get_built_type(*rvty);
self.new_ssa(fcb, *rvid, impl_rvty).clone_value()
.zip(rettys)
.map(|(rvid, rty)| {
self.new_ssa(fcb, *rvid, rty.clone()).clone_value()
})
.collect::<Vec<_>>();
......@@ -3600,6 +3643,8 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
let op_ty = self.ensure_type_rec(tys[0]);
let op = self.get_treenode(fcb, args[0]);
assert_ir!(op_ty.is_iref() || op_ty.is_ref());
assert_ir!(op.ty() == op_ty);
let referent_ty = match op_ty.get_referent_ty() {
Some(ty) => ty,
......@@ -3626,6 +3671,8 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
let op_ty = self.ensure_type_rec(tys[0]);
let op = self.get_treenode(fcb, args[0]);
assert_ir!(op_ty.is_iref() || op_ty.is_ref());
assert_ir!(op.ty() == op_ty);
Instruction {
hdr: hdr,
......@@ -3654,12 +3701,12 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
);
assert!(result_ids.len() == 1);
assert!(args.len() == 1);
assert!(tys.len() == 0);
// int<1>
let impl_i1 = self.ensure_i1();
let impl_opnd = self.get_treenode(fcb, args[0]);
let impl_rv = self.new_ssa(fcb, result_ids[0], impl_i1).clone_value();
assert_ir!(impl_opnd.ty().is_tagref64());
Instruction {
hdr: hdr,
......@@ -3675,12 +3722,12 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
);
assert!(result_ids.len() == 1);
assert!(args.len() == 1);
assert!(tys.len() == 0);
// int<1>
let impl_i1 = self.ensure_i1();
let impl_opnd = self.get_treenode(fcb, args[0]);
let impl_rv = self.new_ssa(fcb, result_ids[0], impl_i1).clone_value();
assert_ir!(impl_opnd.ty().is_tagref64());
Instruction {
hdr: hdr,
......@@ -3696,12 +3743,12 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
);
assert!(result_ids.len() == 1);
assert!(args.len() == 1);
assert!(tys.len() == 0);
// int<1>
let impl_i1 = self.ensure_i1();
let impl_opnd = self.get_treenode(fcb, args[0]);
let impl_rv = self.new_ssa(fcb, result_ids[0], impl_i1).clone_value();
assert_ir!(impl_opnd.ty().is_tagref64());
Instruction {
hdr: hdr,
......@@ -3717,13 +3764,13 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
);
assert!(result_ids.len() == 1);
assert!(args.len() == 1);
assert!(tys.len() == 0);
// tagref64
let impl_tagref64 = self.ensure_tagref64();
let impl_opnd = self.get_treenode(fcb, args[0]);
let impl_rv = self.new_ssa(fcb, result_ids[0], impl_tagref64)
.clone_value();
assert_ir!(impl_opnd.ty().is_double());
Instruction {
hdr: hdr,
......@@ -3739,7 +3786,6 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
);
assert!(result_ids.len() == 1);
assert!(args.len() == 1);
assert!(tys.len() == 0);
// tagref64
let impl_tagref64 = self.ensure_tagref64();
......@@ -3764,7 +3810,6 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
);
assert!(result_ids.len() == 1);
assert!(args.len() == 2);
assert!(tys.len() == 0);
// tagref64
let impl_tagref64 = self.ensure_tagref64();
......@@ -3794,13 +3839,13 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
);
assert!(result_ids.len() == 1);
assert!(args.len() == 1);
assert!(tys.len() == 0);
// tagref64
let impl_tagref64 = self.ensure_double();
let impl_opnd = self.get_treenode(fcb, args[0]);
let impl_rv = self.new_ssa(fcb, result_ids[0], impl_tagref64)
.clone_value();
assert_ir!(impl_opnd.ty().is_tagref64());
Instruction {
hdr: hdr,
......@@ -3816,13 +3861,13 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
);
assert!(result_ids.len() == 1);
assert!(args.len() == 1);
assert!(tys.len() == 0);
// tagref64
let impl_tagref64 = self.ensure_i52();
let impl_opnd = self.get_treenode(fcb, args[0]);
let impl_rv = self.new_ssa(fcb, result_ids[0], impl_tagref64)
.clone_value();
assert_ir!(impl_opnd.ty().is_tagref64());
Instruction {
hdr: hdr,
......@@ -3838,13 +3883,13 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
);
assert!(result_ids.len() == 1);
assert!(args.len() == 1);
assert!(tys.len() == 0);
// tagref64
let impl_tagref64 = self.ensure_ref_void();
let impl_opnd = self.get_treenode(fcb, args[0]);
let impl_rv = self.new_ssa(fcb, result_ids[0], impl_tagref64)
.clone_value();
assert_ir!(impl_opnd.ty().is_tagref64());
Instruction {
hdr: hdr,
......@@ -3860,13 +3905,13 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
);
assert!(result_ids.len() == 1);
assert!(args.len() == 1);
assert!(tys.len() == 0);
// tagref64
let impl_tagref64 = self.ensure_i6();
let impl_opnd = self.get_treenode(fcb, args[0]);
let impl_rv = self.new_ssa(fcb, result_ids[0], impl_tagref64)
.clone_value();
assert_ir!(impl_opnd.ty().is_tagref64());
Instruction {
hdr: hdr,
......@@ -3911,4 +3956,4 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
trace!("Bundle loaded to the VM!");
}
}
\ No newline at end of file
}
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