Commit bdca1777 authored by qinsoon's avatar qinsoon

Merge branch 'develop' into perf-tweak

parents 7d23f95f 15066724
......@@ -159,5 +159,5 @@ mubench:
rustfmt:
stage: rustfmt
script:
- cargo-fmt -- --write-mode=diff --verbose -- src/ast/src/lib.rs src/gc/src/lib.rs src/utils/src/lib.rs
- cargo-fmt -- --write-mode=diff --verbose -- src/lib.rs src/ast/src/lib.rs src/gc/src/lib.rs src/utils/src/lib.rs
......@@ -804,13 +804,18 @@ impl MuType_ {
}
/// MuFuncSig represents a Mu function signature
#[derive(PartialEq, Debug)]
#[derive(Debug)]
pub struct MuFuncSig {
pub hdr: MuEntityHeader,
pub ret_tys: Vec<P<MuType>>,
pub arg_tys: Vec<P<MuType>>
}
impl PartialEq for MuFuncSig {
fn eq(&self, other: &MuFuncSig) -> bool {
self.ret_tys == other.ret_tys && self.arg_tys == other.arg_tys
}
}
rodal_struct!(MuFuncSig{hdr, ret_tys, arg_tys});
impl fmt::Display for MuFuncSig {
......
......@@ -60,7 +60,7 @@ pub fn link_primordial(funcs: Vec<MuName>, out: &str, vm: &VM) -> PathBuf {
ret.push(dest);
// include mu static lib
if vm.vm_options.flag_link_statically {
if vm.vm_options.flag_aot_link_static {
ret.push(get_path_under_zebu(if cfg!(debug_assertions) {
"target/debug/libmu.a"
} else {
......@@ -75,7 +75,7 @@ pub fn link_primordial(funcs: Vec<MuName>, out: &str, vm: &VM) -> PathBuf {
out_path.push(out);
link_executable_internal(
!vm.vm_options.flag_link_statically,
!vm.vm_options.flag_aot_link_static,
files,
&vm.vm_options.flag_bootimage_external_lib,
&vm.vm_options.flag_bootimage_external_libpath,
......@@ -103,7 +103,7 @@ pub fn link_test_primordial(funcs: Vec<MuName>, out: &str, vm: &VM) -> PathBuf {
ret.push(get_path_for_mu_context(vm));
// copy primoridal entry
let source = get_path_under_zebu(runtime::PRIMORDIAL_ENTRY);
let source = get_path_under_zebu(runtime::TEST_PRIMORDIAL_ENTRY);
let dest = {
let mut ret = PathBuf::from(&vm.vm_options.flag_aot_emit_dir);
ret.push("main_test.c");
......@@ -120,7 +120,7 @@ pub fn link_test_primordial(funcs: Vec<MuName>, out: &str, vm: &VM) -> PathBuf {
ret.push(dest);
// include mu static lib
if vm.vm_options.flag_link_statically {
if vm.vm_options.flag_aot_link_static {
ret.push(get_path_under_zebu(if cfg!(debug_assertions) {
"target/debug/libmu.a"
} else {
......@@ -135,7 +135,7 @@ pub fn link_test_primordial(funcs: Vec<MuName>, out: &str, vm: &VM) -> PathBuf {
out_path.push(out);
link_executable_internal(
!vm.vm_options.flag_link_statically,
!vm.vm_options.flag_aot_link_static,
files,
&vm.vm_options.flag_bootimage_external_lib,
&vm.vm_options.flag_bootimage_external_libpath,
......
// 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.
......@@ -27,7 +27,15 @@ extern void* rodal_realloc(void*, size_t);
extern uint32_t mu_retval;
extern void* STRUCT_TAG_MAP;
extern void* HYBRID_TAG_MAP;
extern void* STRUCT_TAG_MAP_LOC;
extern void* HYBRID_TAG_MAP_LOC;
int main(int argc, char** argv) {
STRUCT_TAG_MAP_LOC = &STRUCT_TAG_MAP;
HYBRID_TAG_MAP_LOC = &HYBRID_TAG_MAP;
rodal_init_deallocate();
mu_main(&RODAL_END, &vm, argc, argv);
assert(mu_retval == 0);
......@@ -35,4 +43,4 @@ int main(int argc, char** argv) {
}
void free(void* ptr) { return rodal_free(ptr); };
void* realloc(void* ptr, size_t s) { return rodal_realloc(ptr, s); };
void* realloc(void* ptr, size_t s) { return rodal_realloc(ptr, s); };
\ No newline at end of file
......@@ -21,9 +21,11 @@ use utils::math::align_up;
use utils::bit_utils::bits_ones;
use std;
pub static mut VALIDATE_IR: bool = true;
macro_rules! assert_ir {
($ cond : expr ) => { debug_assert!($cond) };
($ cond : expr , $ ( $ arg : tt ) + ) => { debug_assert!($cond, $($arg)+)};
($ cond : expr ) => [{if unsafe{VALIDATE_IR} {assert!($cond)} }];
($ cond : expr , $ ( $ arg : tt ) + ) => [{if unsafe{VALIDATE_IR} {assert!($cond, $($arg)+)} }];
}
pub struct MuIRBuilder {
......@@ -1283,7 +1285,8 @@ struct BundleLoader<'lb, 'lvm> {
built_uptr_of: IdPMap<MuType>,
built_constint_of: HashMap<u64, P<Value>>,
current_sig: Option<P<MuFuncSig>>
current_sig: Option<P<MuFuncSig>>,
current_entry: MuID
}
fn load_bundle(b: &mut MuIRBuilder) {
......@@ -1322,7 +1325,8 @@ fn load_bundle(b: &mut MuIRBuilder) {
built_iref_of: Default::default(),
built_uptr_of: Default::default(),
built_constint_of: Default::default(),
current_sig: Default::default()
current_sig: Default::default(),
current_entry: Default::default()
};
bl.load_bundle();
......@@ -2258,6 +2262,7 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
let mut fcb: FuncCtxBuilder = Default::default();
let entry_id = *fv.bbs.first().unwrap();
self.current_entry = entry_id;
let mut blocks = fv.bbs
.iter()
.map(|bbid| {
......@@ -3581,12 +3586,10 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
inst_result_ids: &[MuID],
blocks: &LinkedHashMap<MuID, Block>
) -> Destination {
// Note: according to the mu spec you can't branch to the entry block
// but we allow that here anyway
let dest_clause = self.b.bundle.dest_clauses.get(&id).unwrap();
let target = dest_clause.dest;
assert_ir!(target != self.current_entry);
let target_block = blocks[&target].content.as_ref().unwrap();
assert_ir!(target_block.args.len() == dest_clause.vars.len());
......
......@@ -53,3 +53,5 @@ mod deps {
pub use vm::handle::APIHandle;
extern crate mu_ast as ast;
}
pub use self::api_impl::VALIDATE_IR;
\ No newline at end of file
......@@ -33,12 +33,13 @@ VM:
Compiler:
--disable-inline disable compiler function inlining
--disable-regalloc-validate disable register allocation validation
--disable-ir-validate disable IR validation
--emit-debug-info emit debugging information
AOT Compiler:
--aot-emit-dir=<dir> the emit directory for ahead-of-time compiling
[default: emit]
--link-statically link boot image to libmu statically (defaults to dynamic)
--aot-link-static link boot image to libmu statically (defaults to dynamic)
--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
......@@ -57,24 +58,25 @@ Garbage Collection:
pub struct VMOptions {
// The comments here indicate the offset into the struct
// VM
pub flag_log_level: MuLogLevel, // +96
pub flag_log_level: MuLogLevel,
// Compiler
pub flag_disable_inline: bool, // +97
pub flag_disable_regalloc_validate: bool, // +98
pub flag_emit_debug_info: bool, // +99
pub flag_disable_inline: bool,
pub flag_disable_regalloc_validate: bool,
pub flag_disable_ir_validate: bool,
pub flag_emit_debug_info: bool,
// AOT compiler
pub flag_aot_emit_dir: String, // +0
pub flag_link_statically: bool, // +100
pub flag_bootimage_external_lib: Vec<String>, // +24
pub flag_bootimage_external_libpath: Vec<String>, // +48
pub flag_aot_emit_dir: String,
pub flag_aot_link_static: bool,
pub flag_bootimage_external_lib: Vec<String>,
pub flag_bootimage_external_libpath: Vec<String>,
// GC
pub flag_gc_disable_collection: bool, // +101
pub flag_gc_immixspace_size: usize, // +72
pub flag_gc_lospace_size: usize, // +80
pub flag_gc_nthreads: usize // +88
pub flag_gc_disable_collection: bool,
pub flag_gc_immixspace_size: usize,
pub flag_gc_lospace_size: usize,
pub flag_gc_nthreads: usize
}
// The fields need to be listed here in the order rust stores them in
......@@ -88,8 +90,9 @@ rodal_struct!(VMOptions {
flag_log_level,
flag_disable_inline,
flag_disable_regalloc_validate,
flag_disable_ir_validate,
flag_emit_debug_info,
flag_link_statically,
flag_aot_link_static,
flag_gc_disable_collection
});
......@@ -154,12 +157,13 @@ impl VMOptions {
}
if cfg!(target_os = "macos") {
if !ret.flag_link_statically {
if !ret.flag_aot_link_static {
warn!("link-statically is forced to true (opposite to user setting)");
ret.flag_link_statically = true;
ret.flag_aot_link_static = true;
}
}
unsafe { super::api::VALIDATE_IR = !ret.flag_disable_ir_validate };
ret
}
}
......
......@@ -87,7 +87,7 @@ def test_except_stack_args():
.funcdef test_except_stack_args <main_sig>
{
entry(<int<32>>argc <uptr<uptr<char>>>argv):
CALL <stack_sig> stack_args(<int<32>>0 <int<32>>1 <int<32>>2 <int<32>>3 <int<32>>4 <int<32>>5 <int<32>>6 <int<32>>7 <int<32>>8)
CALL <stack_sig> stack_args(<int<64>>0 <int<64>>1 <int<64>>2 <int<64>>3 <int<64>>4 <int<64>>5 <int<64>>6 <int<64>>7 <int<64>>8)
EXC (exit(<int<32>> 0) exit(<int<32>> 1))
exit(<int<32>> status):
......
......@@ -320,7 +320,6 @@ def test_newthread_threadlocal():
.funcdef test_newthread_threadlocal <main_sig>
{
entry(<int<32>>argc <uptr<uptr<char>>>argv):
cs = COMMINST uvm.current_stack()
s = COMMINST uvm.new_stack<[()->()]>(test_newthread_threadlocal_thread)
tr = NEW <int<32>>
......@@ -362,4 +361,35 @@ def test_newthread_stack_args():
COMMINST uvm.thread_exit()
}
""", "test_newthread_stack_args");
assert(execute("test_newthread_stack_args", []) == 45);
\ No newline at end of file
assert(execute("test_newthread_stack_args", []) == 45);
def test_swapstack_threadlocal():
compile_bundle(
"""
.funcdef test_swapstack_threadlocal_stack <(stackref)->()>
{
entry(<stackref>s):
tr = NEW <int<32>>
tri = GETIREF <int<32>> tr
STORE <int<32>> tri <int<32>> 3
tl = REFCAST <ref<int<32>> ref<void>> tr
t = NEWTHREAD s THREADLOCAL (tl) PASS_VALUES<>()
COMMINST uvm.thread_exit()
}
.funcdef test_swapstack_threadlocal <main_sig>
{
entry(<int<32>>argc <uptr<uptr<char>>>argv):
cs = COMMINST uvm.current_stack()
s = COMMINST uvm.new_stack<[(stackref)->()]>(test_swapstack_threadlocal_stack)
SWAPSTACK s RET_WITH<> PASS_VALUES<stackref>(cs)
tv = COMMINST uvm.get_threadlocal()
tr = REFCAST <ref<void> ref<int<32>>> tv
tvi = GETIREF <int<32>> tr
tv = LOAD <int<32>> tvi
RET (tv)
}
""", "test_swapstack_threadlocal");
assert(execute("test_swapstack_threadlocal", []) == 3);
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment