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.

vm_options.rs 2.6 KB
Newer Older
qinsoon's avatar
qinsoon committed
1 2 3 4 5
extern crate rustc_serialize;
extern crate docopt;

use self::docopt::Docopt;

qinsoon's avatar
qinsoon committed
6 7
use std::default::Default;

qinsoon's avatar
qinsoon committed
8 9 10 11 12 13 14
const USAGE: &'static str = "
zebu (mu implementation). Pass arguments as a strings to init it.

Usage:
  init_mu [options]

VM:
15
  --log-level=<level>                   logging level: none, error, warn, info, debug, trace [default: trace]
qinsoon's avatar
qinsoon committed
16

17
Compiler:
18
  --disable-inline                      disable compiler function inlining
qinsoon's avatar
qinsoon committed
19
  --disable-regalloc-validate           disable register allocation validation
qinsoon's avatar
qinsoon committed
20
  --emit-debug-info                     emit debugging information
21 22

AOT Compiler:
23 24 25 26
  --aot-emit-dir=<dir>                  the emit directory for ahead-of-time compiling [default: emit]

  --bootimage-external-lib=<lib> ...           library that will be linked against when making bootimage [default: ]
  --bootimage-external-libpath=<path> ...      path for the libraries during bootimage generation [default: ]
qinsoon's avatar
qinsoon committed
27 28

Garbage Collection:
29
  --gc-disable-collection               disable collection
30 31 32
  --gc-immixspace-size=<kb>             immix space size (default 65536kb = 64mb) [default: 67108864]
  --gc-lospace-size=<kb>                large object space size (default 65536kb = 64mb) [default: 67108864]
  --gc-nthreads=<n>                     number of threads for parallel gc [default: 8]
qinsoon's avatar
qinsoon committed
33 34 35
";

#[derive(Debug, RustcDecodable, RustcEncodable)]
qinsoon's avatar
qinsoon committed
36
pub struct VMOptions {
qinsoon's avatar
qinsoon committed
37
    // VM
qinsoon's avatar
qinsoon committed
38
    pub flag_log_level: MuLogLevel,
qinsoon's avatar
qinsoon committed
39 40

    // Compiler
41
    pub flag_disable_inline: bool,
qinsoon's avatar
qinsoon committed
42
    pub flag_disable_regalloc_validate: bool,
qinsoon's avatar
qinsoon committed
43
    pub flag_emit_debug_info: bool,
44

qinsoon's avatar
qinsoon committed
45
    // AOT compiler
qinsoon's avatar
qinsoon committed
46
    pub flag_aot_emit_dir: String,
47 48 49
    pub flag_bootimage_external_lib: Vec<String>,
    pub flag_bootimage_external_libpath: Vec<String>,

qinsoon's avatar
qinsoon committed
50
    // GC
51
    pub flag_gc_disable_collection: bool,
qinsoon's avatar
qinsoon committed
52 53 54
    pub flag_gc_immixspace_size: usize,
    pub flag_gc_lospace_size: usize,
    pub flag_gc_nthreads: usize
qinsoon's avatar
qinsoon committed
55 56
}

qinsoon's avatar
qinsoon committed
57 58 59 60 61 62 63
#[derive(Debug, Clone, Copy, RustcDecodable, RustcEncodable)]
pub enum MuLogLevel {
    None, Error, Warn, Info, Debug, Trace
}

impl VMOptions {
    pub fn init(str: &str) -> VMOptions {
64
        info!("init vm options with: {:?}", str);
qinsoon's avatar
qinsoon committed
65

qinsoon's avatar
qinsoon committed
66
        let mut ret : VMOptions = Docopt::new(USAGE)
qinsoon's avatar
qinsoon committed
67 68 69
            .and_then(|d| d.argv(str.split_whitespace().into_iter()).parse())
            .unwrap_or_else(|e| e.exit()).decode().unwrap();

70
        info!("parsed as {:?}", ret);
qinsoon's avatar
qinsoon committed
71

qinsoon's avatar
qinsoon committed
72 73
        // at the moment disable collection for debugging
        ret.flag_gc_disable_collection = true;
qinsoon's avatar
qinsoon committed
74 75
        // at the moment always emit debug info
        ret.flag_emit_debug_info = true;
qinsoon's avatar
qinsoon committed
76

qinsoon's avatar
qinsoon committed
77 78 79
        ret
    }
}
qinsoon's avatar
qinsoon committed
80 81 82

impl Default for VMOptions {
    fn default() -> VMOptions {
qinsoon's avatar
qinsoon committed
83
        VMOptions::init("")
qinsoon's avatar
qinsoon committed
84
    }
85
}