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 1.68 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
15
16
const USAGE: &'static str = "
zebu (mu implementation). Pass arguments as a strings to init it.

Usage:
  init_mu [options]

VM:
  --log-level=<level>               logging level: none, error, warn, info, debug, trace [default: trace]

17
Compiler:
18
  --disable-inline                  disable compiler function inlining
19
20

AOT Compiler:
qinsoon's avatar
qinsoon committed
21
22
23
  --aot-emit-dir=<dir>              the emit directory for ahead-of-time compiling [default: emit]

Garbage Collection:
qinsoon's avatar
qinsoon committed
24
25
  --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]
qinsoon's avatar
qinsoon committed
26
27
28
29
  --gc-nthreads=<n>                 number of threads for parallel gc [default: 8]
";

#[derive(Debug, RustcDecodable, RustcEncodable)]
qinsoon's avatar
qinsoon committed
30
pub struct VMOptions {
qinsoon's avatar
qinsoon committed
31
    pub flag_log_level: MuLogLevel,
32
    pub flag_disable_inline: bool,
qinsoon's avatar
qinsoon committed
33
34
35
36
    pub flag_aot_emit_dir: String,
    pub flag_gc_immixspace_size: usize,
    pub flag_gc_lospace_size: usize,
    pub flag_gc_nthreads: usize
qinsoon's avatar
qinsoon committed
37
38
}

qinsoon's avatar
qinsoon committed
39
40
41
42
43
44
45
#[derive(Debug, Clone, Copy, RustcDecodable, RustcEncodable)]
pub enum MuLogLevel {
    None, Error, Warn, Info, Debug, Trace
}

impl VMOptions {
    pub fn init(str: &str) -> VMOptions {
46
        info!("init vm options with: {:?}", str);
qinsoon's avatar
qinsoon committed
47
48
49
50
51

        let ret : VMOptions = Docopt::new(USAGE)
            .and_then(|d| d.argv(str.split_whitespace().into_iter()).parse())
            .unwrap_or_else(|e| e.exit()).decode().unwrap();

52
        info!("parsed as {:?}", ret);
qinsoon's avatar
qinsoon committed
53
54
55
56

        ret
    }
}
qinsoon's avatar
qinsoon committed
57
58
59

impl Default for VMOptions {
    fn default() -> VMOptions {
qinsoon's avatar
qinsoon committed
60
        VMOptions::init("")
qinsoon's avatar
qinsoon committed
61
    }
62
}