WARNING! Access to this system is limited to authorised users only.
Unauthorised users may be subject to prosecution.
Unauthorised access to this system is a criminal offence under Australian law (Federal Crimes Act 1914 Part VIA)
It is a criminal offence to:
(1) Obtain access to data without authority. -Penalty 2 years imprisonment.
(2) Damage, delete, alter or insert data without authority. -Penalty 10 years imprisonment.
User activity is monitored and recorded. Anyone using this system expressly consents to such monitoring and recording.

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

Commit 5e05fd11 authored by Isaac Oscar Gariano's avatar Isaac Oscar Gariano
Browse files

Changed MuName and CName to Arc<String>

parent 2e8bb439
......@@ -37,7 +37,7 @@ gcc = "*"
mu_ast = {path = "src/ast"}
mu_utils = {path = "src/utils"}
#mu_gc = {path = "src/gc"}
rodal = { git = "https://gitlab.anu.edu.au/mu/rodal", version = ">= 0.0.5" }
rodal = { git = "https://gitlab.anu.edu.au/mu/rodal", version = ">= 0.0.10" }
#rodal = { path = "../rodal_test/rodal", version = ">= 0.0.5" }
libc="*"
......
......@@ -25,6 +25,6 @@ mu_utils = {path = "../utils"}
lazy_static = "*"
log = "*"
simple_logger = "*"
rodal = { git = "https://gitlab.anu.edu.au/mu/rodal", version = ">= 0.0.5" }
rodal = { git = "https://gitlab.anu.edu.au/mu/rodal", version = ">= 0.0.10" }
regex = "*"
#rodal = { path = "../../../rodal_test/rodal", version = ">= 0.0.5" }
......@@ -22,21 +22,22 @@ use utils::LinkedHashSet;
use std;
use std::fmt;
pub use std::sync::Arc;
use std::default;
use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
pub type WPID = usize;
pub type MuID = usize;
pub type MuName = String;
pub type MuName = Arc<String>;
pub type CName = MuName;
#[allow(non_snake_case)]
pub fn Mu(str: &'static str) -> MuName {
str.to_string()
Arc::new(str.to_string())
}
#[allow(non_snake_case)]
pub fn C(str: &'static str) -> CName {
str.to_string()
Arc::new(str.to_string())
}
pub type OpIndex = usize;
......@@ -460,7 +461,7 @@ impl FunctionContent {
}
}
pub fn get_block_by_name(&self, name: String) -> &Block {
pub fn get_block_by_name(&self, name: MuName) -> &Block {
for block in self.blocks.values() {
if block.name() == name {
return block;
......@@ -1466,7 +1467,7 @@ pub fn is_valid_c_identifier(name: &MuName) -> bool {
/// changes name to mangled name
/// This will always return a valid C identifier
pub fn mangle_name(name: MuName) -> MuName {
pub fn mangle_name(name: MuName) -> String {
let name = name.replace('@', "");
if name.starts_with("__mu_") {
// TODO: Get rid of this, since it will be triggered if a client provides a name
......@@ -1488,7 +1489,7 @@ pub fn mangle_name(name: MuName) -> MuName {
/// demangles a Mu name
// WARNING: This only reverses mangle_name above when no warning is issued)
pub fn demangle_name(mut name: MuName) -> MuName {
pub fn demangle_name(mut name: String) -> MuName {
let name = if cfg!(target_os = "macos") && name.starts_with("___mu_") {
name.split_off(1)
} else {
......@@ -1507,13 +1508,13 @@ pub fn demangle_name(mut name: MuName) -> MuName {
.replace("Zh", "-")
.replace("Zd", ".")
.replace("ZZ", "Z");
name
Arc::new(name)
}
extern crate regex;
/// identifies mu names and demangles them
pub fn demangle_text(text: String) -> String {
pub fn demangle_text(text: &String) -> String {
use self::regex::Regex;
lazy_static!{
......@@ -1539,14 +1540,14 @@ impl MuEntityHeader {
pub fn unnamed(id: MuID) -> MuEntityHeader {
MuEntityHeader {
id: id,
name: format!("#{}", id)
name: Arc::new(format!("#{}", id))
}
}
pub fn named(id: MuID, name: MuName) -> MuEntityHeader {
MuEntityHeader {
id: id,
name: name.replace('@', "")
name: Arc::new(name.replace('@', ""))
}
}
......@@ -1559,7 +1560,7 @@ impl MuEntityHeader {
}
/// an abbreviate (easy reading) version of the name
fn abbreviate_name(&self) -> MuName {
fn abbreviate_name(&self) -> String {
let split: Vec<&str> = self.name.split('.').collect();
let mut ret = "".to_string();
......@@ -1580,7 +1581,7 @@ impl MuEntityHeader {
pub fn clone_with_id(&self, new_id: MuID) -> MuEntityHeader {
let mut clone = self.clone();
clone.id = new_id;
clone.name = format!("{}-#{}", clone.name, clone.id);
clone.name = Arc::new(format!("{}-#{}", clone.name, clone.id));
clone
}
}
......
......@@ -3444,7 +3444,7 @@ pub fn emit_code(fv: &mut MuFunctionVersion, vm: &VM) {
{
let mut demangled_path = path::PathBuf::new();
demangled_path.push(&vm.vm_options.flag_aot_emit_dir);
demangled_path.push(func.name() + ".demangled.S");
demangled_path.push(*func.name() + ".demangled.S");
let mut demangled_file = match File::create(demangled_path.as_path()) {
Err(why) => {
......@@ -3577,7 +3577,7 @@ use std::collections::HashMap;
pub fn emit_context_with_reloc(
vm: &VM,
symbols: HashMap<Address, String>,
symbols: HashMap<Address, MuName>,
fields: HashMap<Address, String>
) {
use std::path;
......
......@@ -5957,7 +5957,7 @@ impl<'a> InstructionSelection {
self.backend.end_block(cur_block.clone());
}
fn start_block(&mut self, block: String) {
fn start_block(&mut self, block: MuName) {
self.current_block = Some(block.clone());
self.backend.start_block(block.clone());
}
......
......@@ -59,7 +59,7 @@ macro_rules! REGISTER {
($id:expr, $name: expr, $ty: ident) => {
{
P(Value {
hdr: MuEntityHeader::named($id, $name.to_string()),
hdr: MuEntityHeader::named($id, Arc::new($name.to_string())),
ty: $ty.clone(),
v: Value_::SSAVar($id)
})
......
......@@ -226,7 +226,7 @@ pub trait CodeGenerator {
// call
fn emit_call_near_rel32(
&mut self,
callsite: String,
callsite: MuName,
func: MuName,
pe: Option<MuName>,
uses: Vec<P<Value>>,
......@@ -235,7 +235,7 @@ pub trait CodeGenerator {
) -> ValueLocation;
fn emit_call_near_r64(
&mut self,
callsite: String,
callsite: MuName,
func: &P<Value>,
pe: Option<MuName>,
uses: Vec<P<Value>>,
......@@ -243,7 +243,7 @@ pub trait CodeGenerator {
) -> ValueLocation;
fn emit_call_near_mem64(
&mut self,
callsite: String,
callsite: MuName,
func: &P<Value>,
pe: Option<MuName>,
uses: Vec<P<Value>>,
......@@ -253,7 +253,7 @@ pub trait CodeGenerator {
// sometimes we use jmp as a call (but without pushing return address)
fn emit_call_jmp(
&mut self,
callsite: String,
callsite: MuName,
func: MuName,
pe: Option<MuName>,
uses: Vec<P<Value>>,
......@@ -262,7 +262,7 @@ pub trait CodeGenerator {
) -> ValueLocation;
fn emit_call_jmp_indirect(
&mut self,
callsite: String,
callsite: MuName,
func: &P<Value>,
pe: Option<MuName>,
uses: Vec<P<Value>>,
......
......@@ -46,7 +46,7 @@ use utils::{BitSize, ByteSize};
use std::collections::HashMap;
use std::collections::LinkedList;
use std::sync::Arc;
use std::any::Any;
lazy_static! {
......@@ -176,7 +176,7 @@ impl<'a> InstructionSelection {
backend: Box::new(ASMCodeGen::new()),
current_fv_id: 0,
current_fv_name: String::new(),
current_fv_name: Arc::new(String::new()),
current_sig: None,
current_callsite_id: 0,
current_frame: None,
......@@ -4850,7 +4850,7 @@ impl<'a> InstructionSelection {
f_context: &mut FunctionContext,
vm: &VM
) {
let block_name = format!("{}:{}", self.current_fv_name, PROLOGUE_BLOCK_NAME);
let block_name = Arc::new(format!("{}:{}", self.current_fv_name, PROLOGUE_BLOCK_NAME));
self.backend.start_block(block_name.clone());
// push rbp
......@@ -6367,7 +6367,7 @@ impl<'a> InstructionSelection {
}
/// creates a callsite label that is globally unique
fn new_callsite_label(&mut self, cur_node: Option<&TreeNode>) -> String {
fn new_callsite_label(&mut self, cur_node: Option<&TreeNode>) -> MuName {
let ret = {
if cur_node.is_some() {
make_block_name(
......@@ -6375,11 +6375,11 @@ impl<'a> InstructionSelection {
format!("callsite_{}", self.current_callsite_id).as_str()
)
} else {
format!(
Arc::new(format!(
"{}:callsite_{}",
self.current_fv_name,
self.current_callsite_id
)
))
}
};
self.current_callsite_id += 1;
......@@ -6510,7 +6510,7 @@ impl<'a> InstructionSelection {
}
/// starts a new block
fn start_block(&mut self, block: String) {
fn start_block(&mut self, block: MuName) {
self.current_block = Some(block.clone());
self.backend.start_block(block);
}
......
......@@ -46,6 +46,7 @@ use ast::ir::*;
use ast::types::*;
use compiler::backend::RegGroup;
use vm::VM;
use std::sync::Arc;
use utils::LinkedHashMap;
use std::collections::HashMap;
......@@ -96,7 +97,7 @@ macro_rules! GPR {
($id:expr, $name: expr, $ty: ident) => {
{
P(Value {
hdr: MuEntityHeader::named($id, $name.to_string()),
hdr: MuEntityHeader::named($id, Arc::new($name.to_string())),
ty: $ty.clone(),
v: Value_::SSAVar($id)
})
......@@ -109,7 +110,7 @@ macro_rules! FPR {
($id:expr, $name: expr) => {
{
P(Value {
hdr: MuEntityHeader::named($id, $name.to_string()),
hdr: MuEntityHeader::named($id, Arc::new($name.to_string())),
ty: DOUBLE_TYPE.clone(),
v: Value_::SSAVar($id)
})
......
......@@ -146,7 +146,7 @@ fn emit_mc_dot(func: &MuFunctionVersion, vm: &VM) {
// create emit directory/file
create_emit_directory(vm);
let mut file = create_emit_file(func_name.clone() + ".mc.dot", &vm);
let mut file = create_emit_file((*func_name).clone() + ".mc.dot", &vm);
// diagraph func {
writeln!(file, "digraph {} {{", mangle_name(func_name)).unwrap();
......
......@@ -541,5 +541,5 @@ impl RegGroup {
}
fn make_block_name(inst: &MuName, label: &str) -> MuName {
format!("{}:{}", inst, label)
Arc::new(format!("{}:{}", inst, label))
}
......@@ -494,7 +494,7 @@ fn build_global_liveness(cf: &mut CompiledFunction, func: &MuFunctionVersion) {
/// CFGBlockNode represents a basic block as a whole for global liveness analysis
#[derive(Clone, Debug)]
struct CFGBlockNode {
block: String,
block: MuName,
pred: Vec<String>,
succ: Vec<String>,
uses: Vec<MuID>,
......@@ -507,7 +507,7 @@ struct CFGBlockNode {
/// * successors
/// * uses
/// * defs
fn build_cfg_nodes(cf: &mut CompiledFunction) -> LinkedHashMap<String, CFGBlockNode> {
fn build_cfg_nodes(cf: &mut CompiledFunction) -> LinkedHashMap<MuName, CFGBlockNode> {
info!("---local liveness analysis---");
let mc = cf.mc();
let mut ret = LinkedHashMap::new();
......@@ -634,7 +634,7 @@ fn build_cfg_nodes(cf: &mut CompiledFunction) -> LinkedHashMap<String, CFGBlockN
/// global analysis, the iterative algorithm to compute livenss until livein/out reaches a fix point
fn global_liveness_analysis(
blocks: LinkedHashMap<String, CFGBlockNode>,
blocks: LinkedHashMap<MuName, CFGBlockNode>,
cf: &mut CompiledFunction,
func: &MuFunctionVersion
) {
......@@ -642,14 +642,14 @@ fn global_liveness_analysis(
info!("{} blocks", blocks.len());
// init live in and live out
let mut livein: LinkedHashMap<String, LinkedHashSet<MuID>> = {
let mut livein: LinkedHashMap<MuName, LinkedHashSet<MuID>> = {
let mut ret = LinkedHashMap::new();
for name in blocks.keys() {
ret.insert(name.clone(), LinkedHashSet::new());
}
ret
};
let mut liveout: LinkedHashMap<String, LinkedHashSet<MuID>> = {
let mut liveout: LinkedHashMap<MuName, LinkedHashSet<MuID>> = {
let mut ret = LinkedHashMap::new();
for name in blocks.keys() {
ret.insert(name.clone(), LinkedHashSet::new());
......
......@@ -74,7 +74,7 @@ pub fn validate_regalloc(
let mut work_queue: LinkedHashMap<MuName, AliveEntries> = LinkedHashMap::new();
let mut visited: LinkedHashMap<MuName, AliveEntries> = LinkedHashMap::new();
// push entry block
work_queue.insert(PROLOGUE_BLOCK_NAME.to_string(), alive.clone());
work_queue.insert(Arc::new(PROLOGUE_BLOCK_NAME.to_string()), alive.clone());
while !work_queue.is_empty() {
// fetch next block
......
......@@ -73,7 +73,7 @@ fn emit_muir(suffix: &str, func: &MuFunctionVersion, vm: &VM) {
let mut file_path = path::PathBuf::new();
file_path.push(&vm.vm_options.flag_aot_emit_dir);
file_path.push(func_name.clone() + suffix + ".muir");
file_path.push((*func_name).clone() + suffix + ".muir");
let mut file = match File::create(file_path.as_path()) {
Err(why) => {
panic!(
......@@ -96,7 +96,7 @@ fn emit_muir_dot(suffix: &str, func: &MuFunctionVersion, vm: &VM) {
let mut file_path = path::PathBuf::new();
file_path.push(&vm.vm_options.flag_aot_emit_dir);
file_path.push(func_name.clone() + suffix + ".dot");
file_path.push((*func_name).clone() + suffix + ".dot");
let mut file = match File::create(file_path.as_path()) {
Err(why) => {
......@@ -112,7 +112,7 @@ fn emit_muir_dot(suffix: &str, func: &MuFunctionVersion, vm: &VM) {
emit_muir_dot_inner(&mut file, func_name.clone(), func.content.as_ref().unwrap());
}
fn emit_muir_dot_inner(file: &mut File, f_name: String, f_content: &FunctionContent) {
fn emit_muir_dot_inner(file: &mut File, f_name: MuName, f_content: &FunctionContent) {
use utils::vec_utils;
// digraph func {
......
......@@ -403,7 +403,7 @@ fn process_dest(
blocks_to_insert.push(IntermediateBlockInfo {
blk_id: new_blk_id,
blk_name: format!("{}:{}:#{}-#{}", inst, label, new_blk_id, target),
blk_name: Arc::new(format!("{}:{}:#{}-#{}", inst, label, new_blk_id, target)),
target: target,
from_args: from_args
});
......
......@@ -239,7 +239,7 @@ impl Inlining {
// which will receive results from inlined function
let old_name = cur_block.name();
let new_name =
format!("{}_cont_after_inline_{}", old_name, inst_id);
Arc::new(format!("{}_cont_after_inline_{}", old_name, inst_id));
trace!("create continue block for EXPRCALL/CCALL: {}", &new_name);
cur_block =
Block::new(MuEntityHeader::named(vm.next_id(), new_name));
......@@ -307,7 +307,8 @@ impl Inlining {
inlined_fv_guard.sig.ret_tys.len()
{
debug!("need an extra block for passing normal dest arguments");
let int_block_name = format!("inline_{}_arg_pass", inst_id);
let int_block_name =
Arc::new(format!("inline_{}_arg_pass", inst_id));
let mut intermediate_block = Block::new(
MuEntityHeader::named(vm.next_id(), int_block_name)
);
......@@ -420,7 +421,7 @@ fn copy_inline_blocks(
let mut block = Block {
hdr: MuEntityHeader::named(
new_id,
format!("{}:inlinedblock.#{}", old_block.name(), new_id)
Arc::new(format!("{}:inlinedblock.#{}", old_block.name(), new_id))
),
content: Some(old_block.content.as_ref().unwrap().clone_empty()),
trace_hint: TraceHint::None,
......
......@@ -50,7 +50,7 @@ impl CompilerPass for RetSink {
// create a return sink
let return_sink = {
let block_name = format!("{}:{}", func.name(), EPILOGUE_BLOCK_NAME);
let block_name = Arc::new(format!("{}:{}", func.name(), EPILOGUE_BLOCK_NAME));
trace!("created return sink {}", block_name);
let mut block = Block::new(MuEntityHeader::named(vm.next_id(), block_name));
......
......@@ -437,7 +437,8 @@ fn branch_adjustment(func: &mut MuFunctionVersion, vm: &VM) {
// Lnew_false (arg list):
// BRANCH Lfalse (arg list)
let new_false_block = {
let block_name = format!("{}:#{}:false", func.name(), node.id());
let block_name =
Arc::new(format!("{}:#{}:false", func.name(), node.id()));
let mut block =
Block::new(MuEntityHeader::named(vm.next_id(), block_name));
vm.set_name(block.as_entity());
......
......@@ -39,5 +39,5 @@ simple_logger = "*"
aligned_alloc = "*"
crossbeam = "*"
field-offset = "*"
rodal = { git = "https://gitlab.anu.edu.au/mu/rodal", version = ">= 0.0.5" }
rodal = { git = "https://gitlab.anu.edu.au/mu/rodal", version = ">= 0.0.10" }
#rodal = { path = "../../../rodal_test/rodal", version = ">= 0.0.5" }
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