Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

symbolic_lifter: make marshal dir configurable by env var #132

Open
wants to merge 1 commit into
base: partial_eval
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions libASL/symbolic_lifter.ml
Original file line number Diff line number Diff line change
Expand Up @@ -399,15 +399,15 @@ let run include_pc iset pat env : offline_result =
let offline_fns = Offline_transform.run fns env in
let offline_fns = Bindings.mapi (fun k -> fnsig_upd_body (Offline_opt.DeadContextSwitch.run k)) offline_fns in

let freachable k =
let k = match k with
let freachable k =
let k = match k with
| FIdent (n, _) -> Ident n
| n -> n in
Bindings.find k decoderst.instrs
Bindings.find k decoderst.instrs
in

let offline_fns = Bindings.mapi (fun k -> fnsig_upd_body (Offline_opt.RtCopyProp.run k (freachable k))) offline_fns in
Transforms.BDDSimp.print_unknown_prims ();
Transforms.BDDSimp.print_unknown_prims ();

let dsig = fnsig_upd_body (DecoderCleanup.run (unsupported_inst tests offline_fns)) dsig in
let dsig = fnsig_upd_body (Transforms.RemoveUnused.remove_unused IdentSet.empty) dsig in
Expand All @@ -416,22 +416,25 @@ let run include_pc iset pat env : offline_result =
(did,dsig,tests,offline_fns)


let run_marshal include_pc iset pat env : offline_result =
let fname = Printf.sprintf "marshalled-offline-lifter-%x"
(*FIXME: I don't think this is working as expected *)
let run_marshal include_pc iset pat env : offline_result =
let marshal_dir = Option.value ~default:"." (Sys.getenv_opt "ASLP_OFFLINE_MARSHAL_DIR") in
let fname = Printf.sprintf "%s/marshalled-offline-lifter-%x"
marshal_dir
(Hashtbl.seeded_hash 1234 (Printf.sprintf "%b %s %s" include_pc iset pat))
in
if (Sys.file_exists fname)
if (Sys.file_exists fname)
then begin
Printf.printf "Using marshalled lifter (pc: %b iset: %s pat: %s): %s\n" include_pc iset pat fname;
let ic = open_in_bin fname in
let r: offline_result = Marshal.from_channel ic in
close_in ic;
r
end
else
else
let r: offline_result = run include_pc iset pat env in
let oc = open_out_bin fname in
Printf.printf "Writing marshalled lifter (pc: %b iset: %s pat: %s): %s\n" include_pc iset pat fname;
Marshal.to_channel oc r []; close_out oc;
(try
Out_channel.with_open_bin fname (fun oc -> Marshal.to_channel oc r [])
with e ->
Printf.printf "... writing failed: %s\n" (Printexc.to_string e));
r