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.

Commit f8aa25e3 authored by Isaac Oscar Gariano's avatar Isaac Oscar Gariano
Browse files

Merge branch 'primordial_threadlocal'

parents 7f1c3933 ed803641
......@@ -13,15 +13,12 @@
# limitations under the License.
set -e
if [ -z "$MU_ZEBU" ]
then
export MU_ZEBU=$PWD
fi
export MU_ZEBU=$(dirname $0)
export MU_LOG_LEVEL=none
export RUST_TEST_THREADS=1
export RUST_BACKTRACE=0
export PYTHONPATH="$MU_ZEBU/tests/test_jit/mu-client-pypy/:$MU_ZEBU/tests/test_jit/RPySOM/src"
export LD_LIBRARY_PATH="$MU_ZEBU/tests/test_jit/:$MU_ZEBU/tests/test_jit:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH="$MU_ZEBU/target/$ZEBU_BUILD:$MU_ZEBU/tests/test_jit/:$MU_ZEBU/tests/test_jit/emit/:$LD_LIBRARY_PATH"
export ZEBU_BUILD=release
rm -rf $MU_ZEBU/emit
......@@ -56,4 +53,7 @@ else
git -C ./RPySOM submodule update
fi
shopt -s extglob
pytest ./test_!(pypy).py -v --color=yes 2>&1 | tee $MU_ZEBU/pytest_out.txt
pytest ./test_!(pypy).py -v --color=yes 2>&1 | tee $MU_ZEBU/pytest_jit_out.txt
cd $MU_ZEBU/tests/test_muc
pytest ./test_*.py -v --color=yes 2>&1 | tee $MU_ZEBU/pytest_muc_out.txt
......@@ -3636,7 +3636,8 @@ use std::collections::HashMap;
pub fn emit_context_with_reloc(
vm: &VM,
symbols: HashMap<Address, MuName>,
fields: HashMap<Address, MuName>
fields: HashMap<Address, MuName>,
primordial_threadlocal: Option<Address>
) {
use std::path;
use std::io::prelude::*;
......@@ -3662,7 +3663,7 @@ pub fn emit_context_with_reloc(
// data
writeln!(file, ".data").unwrap();
{
let primordial_threadlocal = {
use runtime::mm;
// persist globals
......@@ -3778,6 +3779,11 @@ pub fn emit_context_with_reloc(
offset += POINTER_SIZE;
}
}
primordial_threadlocal.map(|a| relocatable_refs.get(&a).unwrap().clone())
};
{
let mut lock = vm.primordial_threadlocal.write().unwrap();
*lock = primordial_threadlocal;
}
// serialize vm
......@@ -3810,7 +3816,7 @@ pub fn emit_context_with_reloc(
}
pub fn emit_context(vm: &VM) {
emit_context_with_reloc(vm, hashmap!{}, hashmap!{});
emit_context_with_reloc(vm, hashmap!{}, hashmap!{}, None);
}
fn write_data_bytes(f: &mut File, from: Address, to: Address) {
......
......@@ -4165,7 +4165,8 @@ use std::collections::HashMap;
pub fn emit_context_with_reloc(
vm: &VM,
symbols: HashMap<Address, MuName>,
fields: HashMap<Address, MuName>
fields: HashMap<Address, MuName>,
primordial_threadlocal: Option<Address>
) {
use std::path;
use std::io::prelude::*;
......@@ -4195,7 +4196,7 @@ pub fn emit_context_with_reloc(
file.write("\t.data\n".as_bytes()).unwrap();
// persist heap - we traverse the heap from globals
{
let primordial_threadlocal = {
use runtime::mm;
let global_locs_lock = vm.global_locations().read().unwrap();
......@@ -4323,8 +4324,13 @@ pub fn emit_context_with_reloc(
offset += POINTER_SIZE;
}
}
}
primordial_threadlocal.map(|a| relocatable_refs.get(&a).unwrap().clone())
};
{
let mut lock = vm.primordial_threadlocal.write().unwrap();
*lock = primordial_threadlocal;
}
// serialize vm, and put it to boot image
// currently using rustc_serialize to persist vm as json string.
// Deserializing from this is extremely slow, we need to fix this. See Issue #41
......@@ -4355,7 +4361,7 @@ pub fn emit_context_with_reloc(
/// emit vm context for current session,
/// without consideration about relocation symbols/fields from the client
pub fn emit_context(vm: &VM) {
emit_context_with_reloc(vm, hashmap!{}, hashmap!{});
emit_context_with_reloc(vm, hashmap!{}, hashmap!{}, None);
}
/// writes raw bytes from memory between from_address (inclusive) to to_address (exclusive)
......
......@@ -313,8 +313,13 @@ pub extern "C" fn mu_main(
args
};
// FIXME: currently assumes no user defined thread local - See Issue #48
thread::MuThread::new_thread_normal(stack, unsafe { Address::zero() }, args, vm.clone());
let threadlocal = vm.primordial_threadlocal
.read()
.unwrap()
.as_ref()
.map(|name| resolve_symbol(Arc::new(name.clone())))
.unwrap_or(unsafe { Address::zero() });
thread::MuThread::new_thread_normal(stack, threadlocal, args, vm.clone());
loop {
let thread = vm.pop_join_handle();
......
......@@ -119,6 +119,7 @@ pub struct VM {
/// a map from callsite address to CompiledCallsite
compiled_callsite_table: RwLock<HashMap<Address, CompiledCallsite>>, // 896
pub primordial_threadlocal: RwLock<Option<String>>,
/// Nnmber of callsites in the callsite tables
callsite_count: AtomicUsize,
......@@ -166,6 +167,7 @@ unsafe impl rodal::Dump for VM {
RwLock::new(rodal::EmptyHashMap::<Address, CompiledCallsite>::new());
dumper.dump_object_here(&compiled_callsite_table);
dumper.dump_object(&self.primordial_threadlocal);
dumper.dump_object(&self.callsite_count);
dumper.dump_padding(&self.pending_joins);
......@@ -240,6 +242,7 @@ impl<'a> VM {
primordial: RwLock::new(None),
aot_pending_funcref_store: RwLock::new(HashMap::new()),
compiled_callsite_table: RwLock::new(HashMap::new()),
primordial_threadlocal: RwLock::new(None),
callsite_count: ATOMIC_USIZE_INIT,
pending_joins: Mutex::new(LinkedList::new())
};
......@@ -1136,11 +1139,6 @@ impl<'a> VM {
whitelist_funcs
};
if primordial_threadlocal.is_some() {
// we are going to need to persist this threadlocal
unimplemented!()
}
let has_primordial_func = primordial_func.is_some();
let has_primordial_stack = primordial_stack.is_some();
......@@ -1193,7 +1191,12 @@ impl<'a> VM {
};
// emit context (persist vm, etc)
backend::emit_context_with_reloc(self, symbols, fields);
backend::emit_context_with_reloc(
self,
symbols,
fields,
primordial_threadlocal.map(|x| x.v.as_ref().1)
);
// link
self.link_boot_image(whitelist_funcs, extra_sources_to_link, output_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