Commit 1168f297 authored by qinsoon's avatar qinsoon

[wip] get handle from global, and create handle from int

parent 55aa2fe5
Pipeline #242 failed with stage
in 24 minutes and 15 seconds
use ir::*;
use ptr::*;
use types::*;
use utils::Address;
use std::collections::HashMap;
......@@ -35,121 +34,4 @@ impl MuBundle {
// name_id_map: HashMap::new()
}
}
}
#[derive(Copy, Clone, Debug)]
pub struct APIHandleKey {
pub id: MuID,
pub v: APIHandleKeyKind
}
#[derive(Copy, Clone, Debug)]
pub enum APIHandleKeyKind {
Int,
Float,
Double,
UPtr,
UFP,
// SeqValue
Struct,
Array,
Vector,
// GenRef
Ref,
IRef,
TagRef64,
FuncRef,
ThreadRef,
StackRef,
FCRef, // frame cursor ref
// GenRef->IR
Bundle,
// GenRef->IR->Child
Type,
FuncSig,
FuncVer,
BB,
Inst,
// GenRef->IR->Child->Var->Global
Const,
Global,
Func,
ExpFunc,
// GenRef->IR->Child->Var->Local
NorParam,
ExcParam,
InstRes,
}
macro_rules! handle_constructor {
($fn_name: ident, $kind: ident) => {
pub fn $fn_name(id: MuID) -> APIHandleKey {
APIHandleKey{
id: id, v: APIHandleKeyKind::$kind
}
}
}
}
handle_constructor!(handle_int, Int);
handle_constructor!(handle_float, Float);
handle_constructor!(handle_double, Double);
handle_constructor!(handle_uptr, UPtr);
handle_constructor!(handle_ufp, UFP);
handle_constructor!(handle_struct, Struct);
handle_constructor!(handle_array, Array);
handle_constructor!(handle_vector, Vector);
handle_constructor!(handle_ref, Ref);
handle_constructor!(handle_iref, IRef);
handle_constructor!(handle_tagref64, TagRef64);
handle_constructor!(handle_funcref, FuncRef);
handle_constructor!(handle_threadref, ThreadRef);
handle_constructor!(handle_stackref, StackRef);
handle_constructor!(handle_fcref, FCRef);
handle_constructor!(handle_bundle, Bundle);
handle_constructor!(handle_type, Type);
handle_constructor!(handle_funcsig, FuncSig);
handle_constructor!(handle_funcver, FuncVer);
handle_constructor!(handle_bb, BB);
handle_constructor!(handle_inst, Inst);
handle_constructor!(handle_const, Const);
handle_constructor!(handle_global, Global);
handle_constructor!(handle_func, Func);
handle_constructor!(handle_expfunc, ExpFunc);
handle_constructor!(handle_norparam, NorParam);
handle_constructor!(handle_excparam, ExcParam);
handle_constructor!(handle_instres, InstRes);
#[derive(Clone)]
pub enum APIHandleValue {
Int(u64),
Float(f32),
Double(f64),
UPtr(Address),
UFP(Address),
Struct(Vec<APIHandleValue>),
Array(Vec<APIHandleValue>),
Vector(Vec<APIHandleValue>),
Ref(Address),
IRef(Address),
TagRef64(u64),
FuncRef(MuID),
ThreadRef,
StackRef,
FCRef,
IBRef
}
\ No newline at end of file
......@@ -488,4 +488,4 @@ impl DestArg {
&DestArg::Freshbound(n) => format!("${}", n)
}
}
}
\ No newline at end of file
}
......@@ -42,4 +42,4 @@ pub mod inst;
pub mod types;
pub mod ir_semantics;
pub mod ptr;
pub mod op;
\ No newline at end of file
pub mod op;
......@@ -104,4 +104,4 @@ pub fn P<T>(value: T) -> P<T> {
// fn encode<S: Encoder> (&self, s: &mut S) -> Result<(), S::Error> {
// s.emit_usize(self.id())
// }
//}
\ No newline at end of file
//}
......@@ -2898,4 +2898,4 @@ pub fn spill_rewrite(
cf.mc().trace_mc();
new_nodes
}
\ No newline at end of file
}
......@@ -184,4 +184,4 @@ pub trait CodeGenerator {
// fp conversion
fn emit_cvtsi2sd_f64_r (&mut self, dest: Reg, src: Reg);
fn emit_cvtsd2si_r_f64 (&mut self, dest: Reg, src: Reg);
}
\ No newline at end of file
}
......@@ -518,4 +518,4 @@ pub fn estimate_insts_for_ir(inst: &Instruction) -> usize {
Move(_) => 0,
ExnInstruction{ref inner, ..} => estimate_insts_for_ir(&inner)
}
}
\ No newline at end of file
}
......@@ -306,4 +306,4 @@ impl RegGroup {
_ => unimplemented!()
}
}
}
\ No newline at end of file
}
pub mod graph_coloring;
pub use compiler::backend::reg_alloc::graph_coloring::RegisterAllocation;
\ No newline at end of file
pub use compiler::backend::reg_alloc::graph_coloring::RegisterAllocation;
......@@ -127,4 +127,4 @@ impl FrameSlot {
)
})
}
}
\ No newline at end of file
}
......@@ -144,4 +144,4 @@ pub trait MachineCode {
pub trait MachineInst {
}
\ No newline at end of file
}
......@@ -82,4 +82,4 @@ impl Default for CompilerPolicy {
CompilerPolicy{passes: passes}
}
}
\ No newline at end of file
}
......@@ -272,4 +272,4 @@ fn process_dest(dest: Destination, blocks_to_insert: &mut Vec<IntermediateBlockI
dest
}
}
\ No newline at end of file
}
......@@ -464,4 +464,4 @@ impl CompilerPass for Inlining {
debug!("after inlining: {:?}", func);
}
}
}
\ No newline at end of file
}
......@@ -71,4 +71,4 @@ impl AddressBitmap {
pub fn print(&self) {
self.bitmap.print();
}
}
\ No newline at end of file
}
......@@ -41,4 +41,4 @@ impl <T> AddressMap<T> where T: Copy{
let index = (addr.diff(self.start) >> LOG_POINTER_SIZE) as isize;
unsafe {*self.ptr.offset(index)}
}
}
\ No newline at end of file
}
......@@ -145,4 +145,4 @@ mod test {
assert_eq!(bitmap.length_until_next_bit(5), 1);
assert_eq!(bitmap.length_until_next_bit(6), 0);
}
}
\ No newline at end of file
}
......@@ -174,4 +174,4 @@ mod tests {
assert_eq!(vec[1].gen_ref_offsets(), vec![0, 16, 32, 48, 64, 80, 96, 112, 128, 144]);
assert_eq!(vec[2].gen_ref_offsets(), (0..100).map(|x| x * 16).collect::<Vec<ByteSize>>());
}
}
\ No newline at end of file
}
......@@ -4,4 +4,4 @@ mod address_map;
pub mod gctype;
pub use self::address_bitmap::AddressBitmap;
pub use self::address_map::AddressMap;
\ No newline at end of file
pub use self::address_map::AddressMap;
......@@ -124,4 +124,4 @@ impl fmt::Display for FreeListNode {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "FreeListNode#{}(start={:#X}, size={}, state={:?})", self.id, self.start, self.size, self.mark)
}
}
\ No newline at end of file
}
......@@ -22,4 +22,4 @@ pub fn alloc_large(size: usize, align: usize, mutator: &mut immix::ImmixMutatorL
return ret_addr;
}
}
}
\ No newline at end of file
}
......@@ -362,4 +362,4 @@ mod tests {
println!("Allocation{}: {}", i, ret);
}
}
}
\ No newline at end of file
}
......@@ -567,4 +567,4 @@ pub fn steal_process_edge(base: Address, offset: usize, local_queue:&mut Vec<Obj
}
}
}
}
\ No newline at end of file
}
......@@ -344,4 +344,4 @@ impl fmt::Display for ImmixMutatorLocal {
write!(f, "block = {}", self.block.as_ref().unwrap())
}
}
}
\ No newline at end of file
}
......@@ -440,4 +440,4 @@ impl fmt::Debug for ImmixBlock {
}
write!(f, "]")
}
}
\ No newline at end of file
}
......@@ -36,4 +36,4 @@ pub enum LineMark {
pub enum BlockMark {
Usable,
Full
}
\ No newline at end of file
}
......@@ -87,4 +87,4 @@ pub trait Space {
pub fn fill_alignment_gap(start : Address, end : Address) -> () {
debug_assert!(end >= start);
start.memset(ALIGNMENT_VALUE, end.diff(start));
}
\ No newline at end of file
}
......@@ -208,4 +208,4 @@ pub extern fn muentry_alloc_large(mutator: *mut ImmixMutatorLocal, size: usize,
#[no_mangle]
pub extern fn force_gc() {
heap::gc::trigger_gc();
}
\ No newline at end of file
}
......@@ -393,4 +393,4 @@ mod tests {
assert_eq!(header_get_hybrid_length(encode), 10);
assert_eq!(header_get_gctype_id(encode), 2);
}
}
\ No newline at end of file
}
......@@ -96,4 +96,4 @@ pub const SHORT_ENCODE_BIT : usize = 7;
#[inline(always)]
pub fn get_ref_byte(alloc_map:*mut u8, space_start: Address, obj: ObjectReference) -> u8 {
unsafe {*alloc_map.offset((obj.to_address().diff(space_start) >> LOG_POINTER_SIZE) as isize)}
}
\ No newline at end of file
}
mod test_gc_harness;
mod test_gcbench;
mod test_gc_linked_list;
\ No newline at end of file
mod test_gc_linked_list;
......@@ -275,4 +275,4 @@ fn test_alloc_trace() {
heap::gc::start_trace(&mut roots, shared_space, lo_space);
mutator.destroy();
}
\ No newline at end of file
}
......@@ -210,4 +210,4 @@ fn linked_list_survive_gc() {
}
mutator.destroy();
}
\ No newline at end of file
}
......@@ -205,4 +205,4 @@ fn start() {
println!("Finished with {} collections", heap::gc::GC_COUNT.load(Ordering::SeqCst));
mutator.destroy();
}
\ No newline at end of file
}
......@@ -95,4 +95,4 @@ lazy_static! {
aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_frem")),
jit: RwLock::new(None)
};
}
\ No newline at end of file
}
......@@ -208,4 +208,4 @@ fn find_func_for_address (cf: &RwLockReadGuard<HashMap<MuID, RwLock<CompiledFunc
}
panic!("cannot find compiled function for pc 0x{:x}", pc_addr);
}
\ No newline at end of file
}
......@@ -4,4 +4,4 @@ pub extern fn muentry_frem(a: f64, b: f64) -> f64 {
use std::ops::Rem;
a.rem(b)
}
\ No newline at end of file
}
......@@ -28,4 +28,4 @@ pub fn allocate_value(value: P<Value>, vm: &VM) -> ValueLocation {
let addr = allocate(backend_ty.size, backend_ty.alignment).to_address();
ValueLocation::Direct(RegGroup::GPR, addr)
}
\ No newline at end of file
}
......@@ -203,4 +203,4 @@ pub extern fn mu_main(serialized_vm : *const c_char) {
thread.join().unwrap();
}
}
\ No newline at end of file
}
......@@ -171,4 +171,4 @@ pub fn link_dylib_with_extra_srcs(funcs: Vec<MuName>, srcs: Vec<String>, out: &s
out_path.push(out);
link_dylib_internal(files, out_path)
}
\ No newline at end of file
}
......@@ -40,4 +40,4 @@ pub fn compile_run_c_test(test_file_path: &'static str) -> PathBuf {
let test_out = exec(test);
Path::new(&String::from_utf8(test_out.stdout).unwrap()).to_path_buf()
}
\ No newline at end of file
}
......@@ -99,4 +99,4 @@ pub fn compile_fncs<'a>(entry: &'static str, fnc_names: Vec<&'static str>, build
let libname = &get_dylib_name(entry);
let dylib = aot::link_dylib(fnc_names.iter().map(|x| Mu(x)).collect(), libname, &vm);
ll::Library::new(dylib.as_os_str()).unwrap()
}
\ No newline at end of file
}
......@@ -196,4 +196,4 @@ impl fmt::Debug for ObjectReference {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "0x{:X}", self.0)
}
}
\ No newline at end of file
}
......@@ -43,4 +43,4 @@ mod tests {
assert_eq!(set_nth_bit_u64(a, 2, 1), 0b100);
assert_eq!(set_nth_bit_u64(b, 2, 0), 0b1011);
}
}
\ No newline at end of file
}
......@@ -4,4 +4,4 @@ use ast::ptr::*;
pub fn make_i32_const(id: MuID, val: i32) -> P<Value> {
unimplemented!()
}
\ No newline at end of file
}
extern crate byteorder;
extern crate rustc_serialize;
pub type BitSize = usize;
pub type ByteOffset = isize;
pub type ByteSize = usize;
pub type Word = usize;
......@@ -46,4 +47,4 @@ pub use address::ObjectReference;
pub mod vec_utils;
pub mod bit_utils;
pub mod string_utils;
\ No newline at end of file
pub mod string_utils;
......@@ -1128,4 +1128,4 @@ impl<K: Hash + Eq, V, S: BuildHasher> IntoIterator for LinkedHashMap<K, V, S> {
marker: marker::PhantomData,
}
}
}
\ No newline at end of file
}
......@@ -44,4 +44,4 @@ mod tests{
assert_eq!(raw, a);
}
}
\ No newline at end of file
}
......@@ -9,4 +9,4 @@ pub fn replace(s: &mut String, index: usize, replace: &String, replace_len: usiz
vec[index + i] = ' ' as u8;
}
}
}
\ No newline at end of file
}
......@@ -142,4 +142,4 @@ pub fn map<T, Q, F> (vec: &Vec<T>, map_func: F) -> Vec<Q>
}
ret
}
\ No newline at end of file
}
......@@ -19,7 +19,7 @@ mod deps {
pub type MuName = String;
pub type CName = MuName;
pub struct APIHandleKey {
pub struct APIHandle {
// stub
}
......
......@@ -77,195 +77,195 @@ impl MuCtx {
panic!("Not implemented")
}
pub fn handle_from_sint8(&mut self, num: i8, len: c_int) -> *const APIHandleKey {
pub fn handle_from_sint8(&mut self, num: i8, len: c_int) -> *const APIHandle {
panic!("Not implemented")
}
pub fn handle_from_uint8(&mut self, num: u8, len: c_int) -> *const APIHandleKey {
pub fn handle_from_uint8(&mut self, num: u8, len: c_int) -> *const APIHandle {
panic!("Not implemented")
}
pub fn handle_from_sint16(&mut self, num: i16, len: c_int) -> *const APIHandleKey {
pub fn handle_from_sint16(&mut self, num: i16, len: c_int) -> *const APIHandle {
panic!("Not implemented")
}
pub fn handle_from_uint16(&mut self, num: u16, len: c_int) -> *const APIHandleKey {
pub fn handle_from_uint16(&mut self, num: u16, len: c_int) -> *const APIHandle {
panic!("Not implemented")
}
pub fn handle_from_sint32(&mut self, num: i32, len: c_int) -> *const APIHandleKey {
pub fn handle_from_sint32(&mut self, num: i32, len: c_int) -> *const APIHandle {
panic!("Not implemented")
}
pub fn handle_from_uint32(&mut self, num: u32, len: c_int) -> *const APIHandleKey {
pub fn handle_from_uint32(&mut self, num: u32, len: c_int) -> *const APIHandle {
panic!("Not implemented")
}
pub fn handle_from_sint64(&mut self, num: i64, len: c_int) -> *const APIHandleKey {
pub fn handle_from_sint64(&mut self, num: i64, len: c_int) -> *const APIHandle {
panic!("Not implemented")
}
pub fn handle_from_uint64(&mut self, num: u64, len: c_int) -> *const APIHandleKey {
pub fn handle_from_uint64(&mut self, num: u64, len: c_int) -> *const APIHandle {
panic!("Not implemented")
}
pub fn handle_from_uint64s(&mut self, nums: &[u64], len: c_int) -> *const APIHandleKey {
pub fn handle_from_uint64s(&mut self, nums: &[u64], len: c_int) -> *const APIHandle {
panic!("Not implemented")
}
pub fn handle_from_float(&mut self, num: f32) -> *const APIHandleKey {
pub fn handle_from_float(&mut self, num: f32) -> *const APIHandle {
panic!("Not implemented")
}
pub fn handle_from_double(&mut self, num: f64) -> *const APIHandleKey {
pub fn handle_from_double(&mut self, num: f64) -> *const APIHandle {
panic!("Not implemented")
}
pub fn handle_from_ptr(&mut self, mu_type: MuID, ptr: CMuCPtr) -> *const APIHandleKey {
pub fn handle_from_ptr(&mut self, mu_type: MuID, ptr: CMuCPtr) -> *const APIHandle {
panic!("Not implemented")
}
pub fn handle_from_fp(&mut self, mu_type: MuID, fp: CMuCFP) -> *const APIHandleKey {
pub fn handle_from_fp(&mut self, mu_type: MuID, fp: CMuCFP) -> *const APIHandle {
panic!("Not implemented")
}
pub fn handle_to_sint8(&mut self, opnd: &APIHandleKey) -> i8 {
pub fn handle_to_sint8(&mut self, opnd: &APIHandle) -> i8 {
panic!("Not implemented")
}
pub fn handle_to_uint8(&mut self, opnd: &APIHandleKey) -> u8 {
pub fn handle_to_uint8(&mut self, opnd: &APIHandle) -> u8 {
panic!("Not implemented")
}
pub fn handle_to_sint16(&mut self, opnd: &APIHandleKey) -> i16 {
pub fn handle_to_sint16(&mut self, opnd: &APIHandle) -> i16 {
panic!("Not implemented")
}
pub fn handle_to_uint16(&mut self, opnd: &APIHandleKey) -> u16 {
pub fn handle_to_uint16(&mut self, opnd: &APIHandle) -> u16 {
panic!("Not implemented")
}
pub fn handle_to_sint32(&mut self, opnd: &APIHandleKey) -> i32 {
pub fn handle_to_sint32(&mut self, opnd: &APIHandle) -> i32 {
panic!("Not implemented")
}
pub fn handle_to_uint32(&mut self, opnd: &APIHandleKey) -> u32 {
pub fn handle_to_uint32(&mut self, opnd: &APIHandle) -> u32 {
panic!("Not implemented")
}
pub fn handle_to_sint64(&mut self, opnd: &APIHandleKey) -> i64 {
pub fn handle_to_sint64(&mut self, opnd: &APIHandle) -> i64 {
panic!("Not implemented")
}
pub fn handle_to_uint64(&mut self, opnd: &APIHandleKey) -> u64 {
pub fn handle_to_uint64(&mut self, opnd: &APIHandle) -> u64 {
panic!("Not implemented")
}
pub fn handle_to_float(&mut self, opnd: &APIHandleKey) -> f32 {
pub fn handle_to_float(&mut self, opnd: &APIHandle) -> f32 {
panic!("Not implemented")
}
pub fn handle_to_double(&mut self, opnd: &APIHandleKey) -> f64 {
pub fn handle_to_double(&mut self, opnd: &APIHandle) -> f64 {
panic!("Not implemented")
}
pub fn handle_to_ptr(&mut self, opnd: &APIHandleKey) -> CMuCPtr {
pub fn handle_to_ptr(&mut self, opnd: &APIHandle) -> CMuCPtr {
panic!("Not implemented")
}
pub fn handle_to_fp(&mut self, opnd: &APIHandleKey) -> CMuCFP {
pub fn handle_to_fp(&mut self, opnd: &APIHandle) -> CMuCFP {
panic!("Not implemented")
}
pub fn handle_from_const(&mut self, id: MuID) -> *const APIHandleKey {
pub fn handle_from_const(&mut self, id: MuID) -> *const APIHandle {
panic!("Not implemented")
}
pub fn handle_from_global(&mut self, id: MuID) -> *const APIHandleKey {
pub fn handle_from_global(&mut self, id: MuID) -> *const APIHandle {
panic!("Not implemented")
}
pub fn handle_from_func(&mut self, id: MuID) -> *const APIHandleKey {
pub fn handle_from_func(&mut self, id: MuID) -> *const APIHandle {
panic!("Not implemented")
}
pub fn handle_from_expose(&mut self, id: MuID) -> *const APIHandleKey {
pub fn handle_from_expose(&mut self, id: MuID) -> *const APIHandle {
panic!("Not implemented")
}
pub fn delete_value(&mut self, opnd: &APIHandleKey) {
pub fn delete_value(&mut self, opnd: &APIHandle) {
panic!("Not implemented")
}
pub fn ref_eq(&mut self, lhs: &APIHandleKey, rhs: &APIHandleKey) -> bool {
pub fn ref_eq(&mut self, lhs: &APIHandle, rhs: &APIHandle) -> bool {
panic!("Not implemented")
}
pub fn ref_ult(&mut self, lhs: &APIHandleKey, rhs: &APIHandleKey) -> bool {
pub fn ref_ult(&mut self, lhs: &APIHandle, rhs: &APIHandle) -> bool {
panic!("Not implemented")
}
pub fn extract_value(&mut self, str: &APIHandleKey, index: c_int) -> *const APIHandleKey {
pub fn extract_value(&mut self, str: &APIHandle, index: c_int) -> *const APIHandle {
panic!("Not implemented")
}
pub fn insert_value(&mut self, str: &APIHandleKey, index: c_int, newval: &APIHandleKey) -> *const APIHandleKey {
pub fn insert_value(&mut self, str: &APIHandle, index: c_int, newval: &APIHandle) -> *const APIHandle {
panic!("Not implemented")
}
pub fn extract_element(&mut self, str: &APIHandleKey, index: &APIHandleKey) -> *const APIHandleKey {
pub fn extract_element(&mut self, str: &APIHandle, index: &APIHandle) -> *const APIHandle {
panic!("Not implemented")
}
pub fn insert_element(&mut self, str: &APIHandleKey, index: &APIHandleKey, newval: &APIHandleKey) -> *const APIHandleKey {
pub fn insert_element(&mut self, str: &APIHandle, index: &APIHandle, newval: &APIHandle) -> *const APIHandle {
panic!("Not implemented")
}
pub fn new_fixed(&mut self, mu_type: MuID) -> *const APIHandleKey {
pub fn new_fixed(&mut self, mu_type: MuID) -> *const APIHandle {
panic!("Not implemented")
}
pub fn new_hybrid(&mut self, mu_type: MuID, length: &APIHandleKey) -> *const APIHandleKey {
pub fn new_hybrid(&mut self, mu_type: MuID, length: &APIHandle) -> *const APIHandle {
panic!("Not implemented")
}
pub fn refcast(&mut self, opnd: &APIHandleKey, new_type: MuID) -> *const APIHandleKey {
pub fn refcast(&mut self, opnd: &APIHandle, new_type: MuID) -> *const APIHandle {
panic!("Not implemented")
}
pub fn get_iref(&mut self, opnd: &APIHandleKey) -> *const APIHandleKey {
pub fn get_iref(&mut self, opnd: &APIHandle) -> *const APIHandle {