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.03 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
19
20

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

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

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

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

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

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

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

        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();

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

        ret
    }
}
qinsoon's avatar
qinsoon committed
64
65
66

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