GitLab will be partched to the latest stable version on 15 July 2020 at 2.00pm (AEDT) to 2.30pm (AEDT) due to Security Patch Availability. During the update, GitLab and Mattermost services will not be available. If you have any concerns with this, please talk to us at N110 (b) CSIT building.

Commit 5c3c66af authored by qinsoon's avatar qinsoon

refactor logging for vm

parent 4e26dce4
use log;
use simple_logger;
use utils;
use ast::ir::*;
use vm::VM;
......@@ -176,7 +175,7 @@ pub const PRIMORDIAL_ENTRY : &'static str = "src/runtime/main.c";
#[no_mangle]
pub extern fn mu_trace_level_log() {
simple_logger::init_with_level(log::LogLevel::Trace).ok();
VM::start_logging_trace();
}
#[no_mangle]
......
extern crate log;
extern crate simple_logger;
extern crate libloading as ll;
use compiler::*;
......@@ -40,7 +38,8 @@ pub fn exec (mut cmd: Command) -> Output {
}
pub fn compile_fnc<'a>(fnc_name: &'static str, build_fnc: &'a Fn() -> VM) -> ll::Library {
simple_logger::init_with_level(log::LogLevel::Trace).ok();
VM::start_logging_trace();
let vm = Arc::new(build_fnc());
let compiler = Compiler::new(CompilerPolicy::default(), vm.clone());
let func_id = vm.id_of(fnc_name);
......
......@@ -12,7 +12,6 @@ use runtime::thread::*;
use runtime::ValueLocation;
use utils::ByteSize;
use runtime::mm as gc;
use rustc_serialize::{Encodable, Encoder, Decodable, Decoder};
use std::path;
......@@ -306,6 +305,8 @@ impl Decodable for VM {
impl <'a> VM {
pub fn new() -> VM {
VM::start_logging();
let ret = VM {
next_id: ATOMIC_USIZE_INIT,
is_running: ATOMIC_BOOL_INIT,
......@@ -352,6 +353,19 @@ impl <'a> VM {
ret
}
pub fn start_logging() {
VM::start_logging_trace();
}
pub fn start_logging_trace() {
use simple_logger;
match simple_logger::init() {
Ok(_) => {},
Err(_) => {}
}
}
pub fn resume_vm(serialized_vm: &str) -> VM {
use rustc_serialize::json;
......
extern crate mu;
#[macro_use]
extern crate log;
extern crate simple_logger;
#[macro_use]
extern crate maplit;
......
......@@ -12,7 +12,7 @@ use self::rustc_serialize::base64::STANDARD;
#[test]
fn test_vm_serialize_factorial() {
::simple_logger::init_with_level(::log::LogLevel::Trace).ok();
VM::start_logging_trace();
let vm = Arc::new(factorial());
......
extern crate log;
extern crate simple_logger;
extern crate libloading;
extern crate mu;
......@@ -16,7 +15,7 @@ use self::mu::testutil::aot;
#[test]
fn test_instruction_new() {
simple_logger::init_with_level(log::LogLevel::Trace).ok();
VM::start_logging_trace();
let vm = Arc::new(alloc_new());
......
extern crate mu;
extern crate log;
extern crate simple_logger;
extern crate libloading;
use self::mu::ast::types::*;
......
extern crate log;
extern crate simple_logger;
extern crate libloading;
extern crate mu;
......@@ -17,8 +16,7 @@ use std::collections::HashMap;
#[test]
fn test_exception_simple_throw_catch() {
simple_logger::init_with_level(log::LogLevel::Trace).ok();
VM::start_logging_trace();
let vm = Arc::new(simple_throw_catch());
let compiler = Compiler::new(CompilerPolicy::default(), vm.clone());
......
extern crate mu;
extern crate log;
extern crate simple_logger;
extern crate libloading;
use self::mu::ast::types::*;
......@@ -16,7 +15,7 @@ use mu::testutil::aot;
#[test]
fn test_fp_add() {
simple_logger::init_with_level(log::LogLevel::Trace).ok();
VM::start_logging_trace();
let vm = Arc::new(fp_add());
......
extern crate mu;
extern crate log;
extern crate simple_logger;
use test_ir::test_ir::global_access;
use self::mu::compiler::*;
use self::mu::vm::VM;
use std::sync::Arc;
#[test]
fn test_global_access() {
simple_logger::init_with_level(log::LogLevel::Trace).ok();
VM::start_logging_trace();
let vm = Arc::new(global_access());
let compiler = Compiler::new(CompilerPolicy::default(), vm.clone());
......
extern crate mu;
extern crate log;
extern crate simple_logger;
use test_ir::test_ir::factorial;
use self::mu::compiler::*;
use self::mu::vm::VM;
use std::sync::Arc;
#[test]
fn test_instsel_fac() {
simple_logger::init_with_level(log::LogLevel::Trace).ok();
VM::start_logging_trace();
let vm = Arc::new(factorial());
......
extern crate mu;
extern crate log;
extern crate simple_logger;
extern crate libloading;
use self::mu::ast::types::*;
......
extern crate mu;
extern crate log;
extern crate simple_logger;
use common::*;
use test_ir::test_ir::factorial;
use test_ir::test_ir::sum;
use self::mu::ast::ir::*;
use self::mu::compiler::*;
use self::mu::vm::VM;
use std::sync::Arc;
#[test]
fn test_use_count() {
simple_logger::init_with_level(log::LogLevel::Trace).ok();
VM::start_logging_trace();
let vm = Arc::new(factorial());
let compiler = Compiler::new(CompilerPolicy::new(
......@@ -38,7 +37,7 @@ fn test_use_count() {
#[test]
fn test_build_tree() {
simple_logger::init_with_level(log::LogLevel::Trace).ok();
VM::start_logging_trace();
let vm = Arc::new(factorial());
let compiler = Compiler::new(CompilerPolicy::new(
......@@ -57,7 +56,7 @@ fn test_build_tree() {
#[test]
fn test_cfa_factorial() {
simple_logger::init_with_level(log::LogLevel::Trace).ok();
VM::start_logging_trace();
let vm = Arc::new(factorial());
let compiler = Compiler::new(CompilerPolicy::new(vec![
......@@ -97,7 +96,7 @@ fn test_cfa_factorial() {
#[test]
fn test_cfa_sum() {
simple_logger::init_with_level(log::LogLevel::Trace).ok();
VM::start_logging_trace();
let vm = Arc::new(sum());
let compiler = Compiler::new(CompilerPolicy::new(vec![
......@@ -147,7 +146,7 @@ fn block_edges_into_vec(edges: &Vec<BlockEdge>) -> Vec<MuID> {
#[test]
fn test_trace_factorial() {
simple_logger::init_with_level(log::LogLevel::Trace).ok();
VM::start_logging_trace();
let vm = Arc::new(factorial());
let compiler = Compiler::new(CompilerPolicy::new(vec![
......@@ -170,7 +169,7 @@ fn test_trace_factorial() {
#[test]
fn test_trace_sum() {
simple_logger::init_with_level(log::LogLevel::Trace).ok();
VM::start_logging_trace();
let vm = Arc::new(sum());
let compiler = Compiler::new(CompilerPolicy::new(vec![
......
extern crate mu;
extern crate log;
extern crate simple_logger;
extern crate libloading;
use mu::testutil::aot;
......@@ -19,7 +17,7 @@ use std::collections::HashMap;
#[test]
fn test_ir_liveness_fac() {
simple_logger::init_with_level(log::LogLevel::Trace).ok();
VM::start_logging_trace();
let vm = Arc::new(factorial());
......@@ -77,7 +75,7 @@ fn test_ir_liveness_fac() {
#[test]
#[allow(unused_variables)]
fn test_spill1() {
simple_logger::init_with_level(log::LogLevel::Trace).ok();
VM::start_logging_trace();
let vm = Arc::new(create_spill1());
......@@ -279,7 +277,7 @@ fn create_spill1() -> VM {
#[test]
fn test_simple_spill() {
simple_logger::init_with_level(log::LogLevel::Trace).ok();
VM::start_logging_trace();
let vm = Arc::new(create_simple_spill());
......
#![allow(unused_imports)]
extern crate mu;
extern crate log;
extern crate simple_logger;
use self::mu::ast::types::*;
use self::mu::ast::ir::*;
......@@ -19,7 +17,7 @@ use std::collections::HashMap;
#[test]
fn test_thread_create() {
simple_logger::init_with_level(log::LogLevel::Trace).ok();
VM::start_logging_trace();
let vm = Arc::new(primordial_main());
......
......@@ -2,9 +2,6 @@
#![allow(dead_code)]
extern crate mu;
extern crate log;
extern crate simple_logger;
use self::mu::ast::types::*;
use self::mu::ast::ir::*;
use self::mu::ast::inst::*;
......@@ -36,7 +33,7 @@ fn builder_factorial() {
#[allow(unused_variables)]
fn test_startup_shutdown() {
unsafe {
simple_logger::init_with_level(log::LogLevel::Trace).ok();
VM::start_logging_trace();
info!("Starting micro VM...");
......@@ -76,7 +73,7 @@ fn test_types_sigs_loading() {
let mut csp: CStringPool = Default::default();
unsafe {
simple_logger::init_with_level(log::LogLevel::Trace).ok();
VM::start_logging_trace();
info!("Starting micro VM...");
......@@ -128,7 +125,7 @@ fn test_consts_loading() {
let mut csp: CStringPool = Default::default();
unsafe {
simple_logger::init_with_level(log::LogLevel::Trace).ok();
VM::start_logging_trace();
info!("Starting micro VM...");
......@@ -163,7 +160,7 @@ fn test_function_loading() {
let mut csp: CStringPool = Default::default();
unsafe {
simple_logger::init_with_level(log::LogLevel::Trace).ok();
VM::start_logging_trace();
info!("Starting micro VM...");
......@@ -382,7 +379,7 @@ fn test_insts_call() {
let mut csp: CStringPool = Default::default();
unsafe {
simple_logger::init_with_level(log::LogLevel::Trace).ok();
VM::start_logging_trace();
info!("Starting micro VM...");
......@@ -523,7 +520,7 @@ fn test_insts_new() {
let mut csp: CStringPool = Default::default();
unsafe {
simple_logger::init_with_level(log::LogLevel::Trace).ok();
VM::start_logging_trace();
info!("Starting micro VM...");
......
......@@ -13,8 +13,6 @@ use mu::runtime::mm::heap::freelist;
use mu::runtime::mm::heap::freelist::FreeListSpace;
use std::mem::size_of;
use std::sync::atomic::Ordering;
use log;
use simple_logger;
extern crate time;
......
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