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 3.3 KB
Newer Older
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14
// Copyright 2017 The Australian National University
// 
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// 
//     http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

qinsoon's avatar
qinsoon committed
15 16 17 18 19
extern crate rustc_serialize;
extern crate docopt;

use self::docopt::Docopt;

qinsoon's avatar
qinsoon committed
20 21
use std::default::Default;

qinsoon's avatar
qinsoon committed
22 23 24 25 26 27 28
const USAGE: &'static str = "
zebu (mu implementation). Pass arguments as a strings to init it.

Usage:
  init_mu [options]

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

31
Compiler:
32
  --disable-inline                      disable compiler function inlining
qinsoon's avatar
qinsoon committed
33
  --disable-regalloc-validate           disable register allocation validation
qinsoon's avatar
qinsoon committed
34
  --emit-debug-info                     emit debugging information
35 36

AOT Compiler:
37 38 39 40
  --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
41 42

Garbage Collection:
43
  --gc-disable-collection               disable collection
44 45 46
  --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
47 48 49
";

#[derive(Debug, RustcDecodable, RustcEncodable)]
qinsoon's avatar
qinsoon committed
50
pub struct VMOptions {
qinsoon's avatar
qinsoon committed
51
    // VM
qinsoon's avatar
qinsoon committed
52
    pub flag_log_level: MuLogLevel,
qinsoon's avatar
qinsoon committed
53 54

    // Compiler
55
    pub flag_disable_inline: bool,
qinsoon's avatar
qinsoon committed
56
    pub flag_disable_regalloc_validate: bool,
qinsoon's avatar
qinsoon committed
57
    pub flag_emit_debug_info: bool,
58

qinsoon's avatar
qinsoon committed
59
    // AOT compiler
qinsoon's avatar
qinsoon committed
60
    pub flag_aot_emit_dir: String,
61 62 63
    pub flag_bootimage_external_lib: Vec<String>,
    pub flag_bootimage_external_libpath: Vec<String>,

qinsoon's avatar
qinsoon committed
64
    // GC
65
    pub flag_gc_disable_collection: bool,
qinsoon's avatar
qinsoon committed
66 67 68
    pub flag_gc_immixspace_size: usize,
    pub flag_gc_lospace_size: usize,
    pub flag_gc_nthreads: usize
qinsoon's avatar
qinsoon committed
69 70
}

qinsoon's avatar
qinsoon committed
71 72 73 74 75 76 77
#[derive(Debug, Clone, Copy, RustcDecodable, RustcEncodable)]
pub enum MuLogLevel {
    None, Error, Warn, Info, Debug, Trace
}

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

qinsoon's avatar
qinsoon committed
80
        let mut ret : VMOptions = Docopt::new(USAGE)
qinsoon's avatar
qinsoon committed
81 82 83
            .and_then(|d| d.argv(str.split_whitespace().into_iter()).parse())
            .unwrap_or_else(|e| e.exit()).decode().unwrap();

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

qinsoon's avatar
qinsoon committed
86 87
        // at the moment disable collection for debugging
        ret.flag_gc_disable_collection = true;
qinsoon's avatar
qinsoon committed
88 89
        // at the moment always emit debug info
        ret.flag_emit_debug_info = true;
90 91
        // always disable register validation
        ret.flag_disable_regalloc_validate = true;
qinsoon's avatar
qinsoon committed
92

qinsoon's avatar
qinsoon committed
93 94 95
        ret
    }
}
qinsoon's avatar
qinsoon committed
96 97 98

impl Default for VMOptions {
    fn default() -> VMOptions {
qinsoon's avatar
qinsoon committed
99
        VMOptions::init("")
qinsoon's avatar
qinsoon committed
100
    }
101
}