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.7% of users enabled 2FA.

vm_options.rs 2.16 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
20
21

AOT Compiler:
22
23
24
25
  --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
26
27

Garbage Collection:
28
29
30
  --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
31
32
33
";

#[derive(Debug, RustcDecodable, RustcEncodable)]
qinsoon's avatar
qinsoon committed
34
pub struct VMOptions {
qinsoon's avatar
qinsoon committed
35
    pub flag_log_level: MuLogLevel,
36
    pub flag_disable_inline: bool,
qinsoon's avatar
qinsoon committed
37
    pub flag_disable_regalloc_validate: bool,
38

qinsoon's avatar
qinsoon committed
39
    pub flag_aot_emit_dir: String,
40
41
42
    pub flag_bootimage_external_lib: Vec<String>,
    pub flag_bootimage_external_libpath: Vec<String>,

qinsoon's avatar
qinsoon committed
43
44
45
    pub flag_gc_immixspace_size: usize,
    pub flag_gc_lospace_size: usize,
    pub flag_gc_nthreads: usize
qinsoon's avatar
qinsoon committed
46
47
}

qinsoon's avatar
qinsoon committed
48
49
50
51
52
53
54
#[derive(Debug, Clone, Copy, RustcDecodable, RustcEncodable)]
pub enum MuLogLevel {
    None, Error, Warn, Info, Debug, Trace
}

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

57
        let ret : VMOptions = Docopt::new(USAGE)
qinsoon's avatar
qinsoon committed
58
59
60
            .and_then(|d| d.argv(str.split_whitespace().into_iter()).parse())
            .unwrap_or_else(|e| e.exit()).decode().unwrap();

61
        info!("parsed as {:?}", ret);
qinsoon's avatar
qinsoon committed
62
63
64
65

        ret
    }
}
qinsoon's avatar
qinsoon committed
66
67
68

impl Default for VMOptions {
    fn default() -> VMOptions {
qinsoon's avatar
qinsoon committed
69
        VMOptions::init("")
qinsoon's avatar
qinsoon committed
70
    }
71
}