- Timestamp:
- Oct 11, 2011, 5:42:20 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Deliverables/D2.2/8051-indexed-labels-branch/src/ASM/ASMInterpret.ml
r1349 r1357 132 132 exit_addr : BitVectors.word; 133 133 134 (* 134 135 ind_0s : int BitVectors.WordMap.t; 135 136 ind_incs : int BitVectors.WordMap.t; 136 137 cost_labels : CostLabel.t BitVectors.WordMap.t 138 *) 137 139 } 138 140 … … 287 289 288 290 exit_addr = BitVectors.zero `Sixteen; 291 (* 289 292 ind_0s = BitVectors.WordMap.empty; 290 293 ind_incs = BitVectors.WordMap.empty; 291 294 cost_labels = BitVectors.WordMap.empty 295 *) 292 296 } 293 297 … … 1981 1985 let load_program p = 1982 1986 let st = load p.ASM.code initialize in 1983 { st with exit_addr = p.ASM.exit_addr ; cost_labels = p.ASM.cost_labels}1987 { st with exit_addr = p.ASM.exit_addr (* ; cost_labels = p.ASM.cost_labels *)} 1984 1988 1985 1989 type cost_trace = { … … 1988 1992 } 1989 1993 1990 (* TODO: indexes *) 1991 let observe_trace trace st = 1992 let update_ct_labels = 1993 try 1994 let cost_label = BitVectors.WordMap.find st.pc st.cost_labels in 1995 trace.ct_labels <- cost_label :: trace.ct_labels 1996 with Not_found -> () in 1997 update_ct_labels; 1994 (* TODO: supposing only one index reset or increment per instruction *) 1995 let update_indexes trace p st = 1996 try 1997 let i = BitVectors.WordMap.find st.pc p.ASM.inds in 1998 CostLabel.enter_loop trace.ct_inds i 1999 with Not_found -> (); 2000 try 2001 let i = BitVectors.WordMap.find st.pc p.ASM.incs in 2002 CostLabel.continue_loop trace.ct_inds i 2003 with Not_found -> (); 2004 let instr,_,_ = fetch st.code_memory st.pc in 2005 match instr with 2006 | `ACALL _ | `LCALL _ -> 2007 trace.ct_inds <- CostLabel.new_const_ind trace.ct_inds 2008 | `RET -> 2009 trace.ct_inds <- CostLabel.forget_const_ind trace.ct_inds 2010 | _ -> () 2011 2012 let update_labels trace p st = 2013 try 2014 let cost_label = BitVectors.WordMap.find st.pc p.cost_labels in 2015 let ind = CostLabel.curr_const_ind trace.ct_inds in 2016 let cost_label = CostLabel.ev_indexing ind cost_label in 2017 trace.ct_labels <- cost_label :: trace.ct_labels 2018 with Not_found -> () 2019 2020 2021 2022 let update_trace trace p st = 2023 update_labels trace p st; 2024 update_indexes trace p st; 1998 2025 if st.pc = st.exit_addr (* <=> end of program *) then raise Halt else st 1999 2026 … … 2014 2041 let st = load_program p in 2015 2042 let trace = {ct_labels = []; ct_inds = []} in 2016 let callback = observe_trace tracein2043 let callback = update_trace trace p in 2017 2044 let st = execute callback st in 2018 2045 let res = result st in
Note: See TracChangeset
for help on using the changeset viewer.