GitLab will continue to be upgraded from 11.4.5-ce.0 on November 25th 2019 at 4.00pm (AEDT) to 5.00pm (AEDT) due to Critical Security Patch Availability. During the update, GitLab and Mattermost services will not be available.

Commit a9cfbbe5 authored by qinsoon's avatar qinsoon

remove rwlock in ops field in Instruction

parent fb7d55f6
Pipeline #487 failed with stages
in 49 minutes
......@@ -7,14 +7,13 @@ use ir_semantics;
use utils::vec_utils;
use std::fmt;
use std::sync::RwLock;
#[derive(Debug)]
// this implements RustcEncodable, RustcDecodable, Clone and Display
pub struct Instruction {
pub hdr: MuEntityHeader,
pub value : Option<Vec<P<Value>>>,
pub ops : RwLock<Vec<P<TreeNode>>>,
pub ops : Vec<P<TreeNode>>,
pub v: Instruction_
}
......@@ -27,7 +26,7 @@ impl Encodable for Instruction {
try!(s.emit_struct_field("hdr", 0, |s| self.hdr.encode(s)));
try!(s.emit_struct_field("value", 1, |s| self.value.encode(s)));
let ops = &self.ops.read().unwrap();
let ref ops = self.ops;
try!(s.emit_struct_field("ops", 2, |s| ops.encode(s)));
try!(s.emit_struct_field("v", 3, |s| self.v.encode(s)));
......@@ -50,7 +49,7 @@ impl Decodable for Instruction {
Ok(Instruction{
hdr: hdr,
value: value,
ops: RwLock::new(ops),
ops: ops,
v: v
})
})
......@@ -62,7 +61,7 @@ impl Clone for Instruction {
Instruction {
hdr: self.hdr.clone(),
value: self.value.clone(),
ops: RwLock::new(self.ops.read().unwrap().clone()),
ops: self.ops.clone(),
v: self.v.clone()
}
}
......@@ -133,7 +132,7 @@ impl Instruction {
impl fmt::Display for Instruction {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let ops = &self.ops.read().unwrap();
let ref ops = self.ops;
if self.value.is_some() {
write!(f, "{} = {}", vec_utils::as_str(self.value.as_ref().unwrap()), self.v.debug_str(ops))
} else {
......
......@@ -242,7 +242,7 @@ impl MuFunctionVersion {
for inst in block_content.body.iter() {
match inst.v {
TreeNode_::Instruction(ref inst) => {
let ops = inst.ops.read().unwrap();
let ref ops = inst.ops;
match inst.v {
Instruction_::ExprCall{ref data, ..}
......@@ -535,7 +535,7 @@ impl BlockContent {
match last_inst.v {
TreeNode_::Instruction(ref inst) => {
let ops = inst.ops.read().unwrap();
let ref ops = inst.ops;
match inst.v {
Instruction_::Return(_)
| Instruction_::ThreadExit
......
......@@ -164,7 +164,7 @@ impl <'a> InstructionSelection {
}
};
let ops = inst.ops.read().unwrap();
let ref ops = inst.ops;
self.process_dest(&ops, fallthrough_dest, f_content, f_context, vm);
self.process_dest(&ops, branch_dest, f_content, f_context, vm);
......@@ -316,7 +316,7 @@ impl <'a> InstructionSelection {
use ast::op::CmpOp::*;
trace!("instsel on SELECT");
let ops = inst.ops.read().unwrap();
let ref ops = inst.ops;
let ref cond = ops[cond];
let ref true_val = ops[true_val];
......@@ -501,7 +501,7 @@ impl <'a> InstructionSelection {
use ast::op::CmpOp::*;
trace!("instsel on CMPOP");
let ops = inst.ops.read().unwrap();
let ref ops = inst.ops;
let ref op1 = ops[op1];
let ref op2 = ops[op2];
......@@ -536,7 +536,7 @@ impl <'a> InstructionSelection {
Instruction_::Branch1(ref dest) => {
trace!("instsel on BRANCH1");
let ops = inst.ops.read().unwrap();
let ref ops = inst.ops;
self.process_dest(&ops, dest, f_content, f_context, vm);
......@@ -549,7 +549,7 @@ impl <'a> InstructionSelection {
Instruction_::Switch{cond, ref default, ref branches} => {
trace!("instsel on SWITCH");
let ops = inst.ops.read().unwrap();
let ref ops = inst.ops;
let ref cond = ops[cond];
......@@ -709,7 +709,7 @@ impl <'a> InstructionSelection {
Instruction_::ConvOp{operation, ref from_ty, ref to_ty, operand} => {
trace!("instsel on CONVOP");
let ops = inst.ops.read().unwrap();
let ref ops = inst.ops;
let ref op = ops[operand];
......@@ -1099,7 +1099,7 @@ impl <'a> InstructionSelection {
Instruction_::Load{is_ptr, order, mem_loc} => {
trace!("instsel on LOAD");
let ops = inst.ops.read().unwrap();
let ref ops = inst.ops;
let ref loc_op = ops[mem_loc];
// check order
......@@ -1141,7 +1141,7 @@ impl <'a> InstructionSelection {
Instruction_::Store{is_ptr, order, mem_loc, value} => {
trace!("instsel on STORE");
let ops = inst.ops.read().unwrap();
let ref ops = inst.ops;
let ref loc_op = ops[mem_loc];
let ref val_op = ops[value];
......@@ -1237,7 +1237,7 @@ impl <'a> InstructionSelection {
Instruction_::CommonInst_SetThreadLocal(op) => {
trace!("instsel on SETTHREADLOCAL");
let ops = inst.ops.read().unwrap();
let ref ops = inst.ops;
let ref op = ops[op];
debug_assert!(self.match_ireg(op));
......@@ -1256,7 +1256,7 @@ impl <'a> InstructionSelection {
if !mm::GC_MOVES_OBJECT {
// non-moving GC: pin is a nop (move from op to result)
let ops = inst.ops.read().unwrap();
let ref ops = inst.ops;
let ref op = ops[op];
let tmp_res = self.get_result_value(node);
......@@ -1280,7 +1280,7 @@ impl <'a> InstructionSelection {
Instruction_::Move(op) => {
trace!("instsel on MOVE (internal IR)");
let ops = inst.ops.read().unwrap();
let ref ops = inst.ops;
let ref op = ops[op];
let tmp_res = self.get_result_value(node);
......@@ -1337,7 +1337,7 @@ impl <'a> InstructionSelection {
// actual size = fix_part_size + var_ty_size * len
let (actual_size, length) = {
let ops = inst.ops.read().unwrap();
let ref ops = inst.ops;
let ref var_len = ops[var_len];
if self.match_iimm(var_len) {
......@@ -1402,7 +1402,7 @@ impl <'a> InstructionSelection {
Instruction_::Throw(op_index) => {
trace!("instsel on THROW");
let ops = inst.ops.read().unwrap();
let ref ops = inst.ops;
let ref exception_obj = ops[op_index];
self.emit_runtime_entry(
......@@ -1415,7 +1415,7 @@ impl <'a> InstructionSelection {
Instruction_::PrintHex(index) => {
trace!("instsel on PRINTHEX");
let ops = inst.ops.read().unwrap();
let ref ops = inst.ops;
let ref op = ops[index];
self.emit_runtime_entry(
......@@ -1483,7 +1483,7 @@ impl <'a> InstructionSelection {
}
fn emit_binop (&mut self, node: &TreeNode, inst: &Instruction, op: BinOp, op1: OpIndex, op2: OpIndex, f_content: &FunctionContent, f_context: &mut FunctionContext, vm: &VM) {
let ops = inst.ops.read().unwrap();
let ref ops = inst.ops;
let res_tmp = self.get_result_value(node);
......@@ -3145,7 +3145,7 @@ impl <'a> InstructionSelection {
f_context: &mut FunctionContext,
vm: &VM)
{
let ops = inst.ops.read().unwrap();
let ref ops = inst.ops;
// prepare args (they could be instructions, we need to emit inst and get value)
let mut arg_values = vec![];
......@@ -3212,7 +3212,7 @@ impl <'a> InstructionSelection {
vm: &VM) {
trace!("deal with pre-call convention");
let ops = inst.ops.read().unwrap();
let ref ops = inst.ops;
let ref func = ops[calldata.func];
let ref func_sig = match func.v {
TreeNode_::Value(ref pv) => {
......@@ -3491,7 +3491,7 @@ impl <'a> InstructionSelection {
// FIXME: this may change in the future
// prepare return regs
let ref ops = ret_inst.ops.read().unwrap();
let ref ops = ret_inst.ops;
let ret_val_indices = match ret_inst.v {
Instruction_::Return(ref vals) => vals,
_ => panic!("expected ret inst")
......@@ -3597,7 +3597,7 @@ impl <'a> InstructionSelection {
fn emit_cmp_res(&mut self, cond: &TreeNode, f_content: &FunctionContent, f_context: &mut FunctionContext, vm: &VM) -> op::CmpOp {
match cond.v {
TreeNode_::Instruction(ref inst) => {
let ops = inst.ops.read().unwrap();
let ref ops = inst.ops;
match inst.v {
Instruction_::CmpOp(op, op1, op2) => {
......@@ -4132,7 +4132,7 @@ impl <'a> InstructionSelection {
fn emit_get_mem_from_inst_inner(&mut self, op: &TreeNode, f_content: &FunctionContent, f_context: &mut FunctionContext, vm: &VM) -> MemoryLocation { match op.v {
TreeNode_::Instruction(ref inst) => {
let ref ops = inst.ops.read().unwrap();
let ref ops = inst.ops;
match inst.v {
// GETIREF -> [base]
......
......@@ -222,7 +222,7 @@ fn emit_muir_dot_inner(file: &mut File,
match last_inst.v {
TreeNode_::Instruction(ref inst) => {
let ops = inst.ops.read().unwrap();
let ref ops = inst.ops;
match inst.v {
Branch1(ref dest) => {
......
......@@ -59,7 +59,7 @@ impl CompilerPass for DefUse {
// if an SSA appears in operands of instrs, its use count increases
match node.v {
TreeNode_::Instruction(ref inst) => {
for op in inst.ops.read().unwrap().iter() {
for op in inst.ops.iter() {
use_op(op, func_context);
}
},
......
......@@ -5,7 +5,6 @@ use vm::VM;
use compiler::CompilerPass;
use std::any::Any;
use std::sync::RwLock;
pub struct GenMovPhi {
name: &'static str,
......@@ -58,7 +57,7 @@ impl CompilerPass for GenMovPhi {
match last_inst.v {
TreeNode_::Instruction(inst) => {
let ops = inst.ops.read().unwrap();
let ref ops = inst.ops;
match inst.v {
Instruction_::Branch2{cond, true_dest, false_dest, true_prob} => {
......@@ -68,7 +67,7 @@ impl CompilerPass for GenMovPhi {
let new_inst = func.new_inst(Instruction{
hdr: inst.hdr.clone(),
value: inst.value.clone(),
ops: RwLock::new(ops.to_vec()),
ops: ops.to_vec(),
v: Instruction_::Branch2 {
cond: cond,
true_dest: true_dest,
......@@ -87,7 +86,7 @@ impl CompilerPass for GenMovPhi {
let new_inst = func.new_inst(Instruction{
hdr: inst.hdr.clone(),
value: inst.value.clone(),
ops: RwLock::new(ops.to_vec()),
ops: ops.to_vec(),
v: Instruction_::Call {
data: data.clone(),
resume: ResumptionData{
......@@ -107,7 +106,7 @@ impl CompilerPass for GenMovPhi {
let new_inst = func.new_inst(Instruction{
hdr: inst.hdr.clone(),
value: inst.value.clone(),
ops: RwLock::new(ops.to_vec()),
ops: ops.to_vec(),
v: Instruction_::Call {
data: data.clone(),
resume: ResumptionData{
......@@ -131,7 +130,7 @@ impl CompilerPass for GenMovPhi {
let new_inst = func.new_inst(Instruction{
hdr: inst.hdr.clone(),
value: inst.value.clone(),
ops: RwLock::new(ops.to_vec()),
ops: ops.to_vec(),
v: Instruction_::Switch {
cond: cond,
default: default_dest,
......@@ -206,7 +205,7 @@ impl CompilerPass for GenMovPhi {
let m = func.new_inst(Instruction{
hdr: MuEntityHeader::unnamed(vm.next_id()),
value: Some(vec![target_args[i].clone()]),
ops: RwLock::new(vec![arg.clone()]),
ops: vec![arg.clone()],
v: Instruction_::Move(0)
});
......@@ -219,7 +218,7 @@ impl CompilerPass for GenMovPhi {
let b = func.new_inst(Instruction{
hdr: MuEntityHeader::unnamed(vm.next_id()),
value: None,
ops: RwLock::new(vec![]),
ops: vec![],
v: Instruction_::Branch1(Destination{
target: target_id,
args: vec![]
......
......@@ -5,7 +5,6 @@ use vm::VM;
use compiler::CompilerPass;
use std::any::Any;
use std::sync::RwLock;
use std::collections::HashMap;
pub struct Inlining {
......@@ -149,7 +148,7 @@ impl Inlining {
// change current call insts to a branch
trace!("turning CALL instruction into a branch");
let ops = inst.ops.read().unwrap();
let ref ops = inst.ops;
match inst.v {
Instruction_::ExprCall {ref data, ..} => {
......@@ -159,7 +158,7 @@ impl Inlining {
let branch = TreeNode::new_boxed_inst(Instruction{
hdr: inst.hdr.clone(),
value: None,
ops: RwLock::new(arg_nodes.clone()),
ops: arg_nodes.clone(),
v: Instruction_::Branch1(Destination{
// this block doesnt exist yet, we will fix it later
target: new_inlined_entry_id,
......@@ -209,7 +208,7 @@ impl Inlining {
let branch = Instruction{
hdr: inst.hdr.clone(),
value: None,
ops: RwLock::new(arg_nodes),
ops: arg_nodes,
v: Instruction_::Branch1(Destination{
target: new_inlined_entry_id,
args: arg_indices.iter().map(|x| DestArg::Normal(*x)).collect()
......@@ -237,7 +236,7 @@ impl Inlining {
let branch = Instruction {
hdr: MuEntityHeader::unnamed(vm.next_id()),
value: None,
ops: RwLock::new(normal_dest_args),
ops: normal_dest_args,
v: Instruction_::Branch1(Destination {
target: resume.normal_dest.target,
args: (0..normal_dest_args_len).map(|x| DestArg::Normal(x)).collect()
......
......@@ -46,15 +46,15 @@ impl CompilerPass for TreeGen {
trace!("check block {}", label);
trace!("");
for node in body.into_iter() {
for mut node in body.into_iter() {
trace!("check inst: {}", node);
match &node.v {
&TreeNode_::Instruction(ref inst) => {
match &mut node.v {
&mut TreeNode_::Instruction(ref mut inst) => {
// check if any operands can be replaced by expression
{
trace!("check if we can replace any operand with inst");
let mut ops = inst.ops.write().unwrap();
let ref mut ops = inst.ops;
for index in 0..ops.len() {
let possible_ssa_id = ops[index].extract_ssa_id();
if possible_ssa_id.is_some() {
......
This diff is collapsed.
This diff is collapsed.
......@@ -12,7 +12,6 @@ use self::mu::utils::Address;
use self::mu::utils::LinkedHashMap;
use std::sync::Arc;
use std::sync::RwLock;
use self::mu::testutil;
use self::mu::testutil::aot;
......
......@@ -10,8 +10,6 @@ use self::mu::vm::*;
use self::mu::testutil;
use mu::utils::LinkedHashMap;
use std::sync::RwLock;
#[test]
fn test_udiv() {
let lib = testutil::compile_fnc("udiv", &udiv);
......
......@@ -8,7 +8,6 @@ use mu::ast::op::*;
use mu::vm::*;
use mu::compiler::*;
use std::sync::RwLock;
use std::sync::Arc;
use mu::testutil;
use mu::testutil::aot;
......
......@@ -8,8 +8,6 @@ use mu::vm::*;
use mu::testutil;
use mu::utils::LinkedHashMap;
use std::sync::RwLock;
#[test]
fn test_switch() {
let lib = testutil::compile_fnc("switch", &switch);
......@@ -66,12 +64,12 @@ fn switch() -> VM {
let blk_entry_switch = switch_v1.new_inst(Instruction {
hdr: MuEntityHeader::unnamed(vm.next_id()),
value: None,
ops: RwLock::new(vec![
ops: vec![
a.clone(), // 0
int64_0_local.clone(), // 1
int64_1_local.clone(), // 2
int64_2_local.clone(), // 3
]),
],
v: Instruction_::Switch {
cond: 0,
default: Destination {
......
......@@ -10,8 +10,6 @@ use self::mu::vm::*;
use self::mu::testutil;
use mu::utils::LinkedHashMap;
use std::sync::RwLock;
#[test]
fn test_truncate_then_call() {
let lib = testutil::compile_fncs("truncate_then_call", vec!["truncate_then_call", "dummy_call"], &truncate_then_call);
......
......@@ -14,7 +14,6 @@ use mu::testutil::aot;
use test_compiler::test_call::gen_ccall_exit;
use std::sync::Arc;
use std::sync::RwLock;
#[test]
fn test_exception_throw_catch_simple() {
......
......@@ -10,8 +10,6 @@ use self::mu::vm::*;
use self::mu::testutil;
use mu::utils::LinkedHashMap;
use std::sync::RwLock;
#[test]
fn test_double_add() {
let lib = testutil::compile_fnc("double_add", &double_add);
......
......@@ -17,7 +17,6 @@ use mu::testutil::aot;
use mu::vm::handle;
use mu::testutil;
use std::sync::RwLock;
use std::sync::Arc;
#[test]
......
......@@ -8,8 +8,6 @@ use mu::vm::*;
use mu::testutil;
use mu::utils::LinkedHashMap;
use std::sync::RwLock;
#[test]
fn test_inline_add_simple() {
let lib = testutil::compile_fncs("add_trampoline", vec!["add_trampoline", "add"], &inline_add);
......
......@@ -8,7 +8,6 @@ use self::mu::ast::op::*;
use self::mu::vm::*;
use self::mu::utils::LinkedHashMap;
use std::sync::RwLock;
use mu::testutil;
#[test]
......
......@@ -7,7 +7,6 @@ use mu::ast::types::*;
use mu::ast::op::*;
use mu::vm::*;
use std::sync::RwLock;
use mu::utils::LinkedHashMap;
use mu::testutil;
......
......@@ -9,7 +9,6 @@ use mu::compiler::*;
use mu::utils::LinkedHashMap;
use std::sync::Arc;
use std::sync::RwLock;
use mu::testutil::aot;
use mu::testutil;
......
......@@ -15,7 +15,6 @@ use self::mu::ast::op::*;
use self::mu::vm::VM;
use std::sync::Arc;
use std::sync::RwLock;
// NOTE: aarch64 has 28 usable GPRs (wheras x86-64 has 14) so there are slightly different tests for spilling on aarch64
......
......@@ -7,7 +7,6 @@ use self::mu::ast::op::*;
use self::mu::vm::*;
use self::mu::utils::LinkedHashMap;
use std::sync::RwLock;
use std::sync::Arc;
#[test]
......
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