diff options
| author | Pierre-Marie Pédrot | 2015-06-25 13:56:14 +0200 |
|---|---|---|
| committer | Maxime Dénès | 2015-10-16 15:29:40 +0200 |
| commit | 56925d60207f940ebb88d56981f8cdff41c58247 (patch) | |
| tree | eee529a29b75aa06d7bca37f7c2e785db8915c6f /kernel/csymtable.ml | |
| parent | cbd28511526dfb561017c3d27a73598f6ce5f68d (diff) | |
Exporting a purely functional interface to bytecode patching.
Diffstat (limited to 'kernel/csymtable.ml')
| -rw-r--r-- | kernel/csymtable.ml | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/kernel/csymtable.ml b/kernel/csymtable.ml index b3f0ba5b58..e242449b12 100644 --- a/kernel/csymtable.ml +++ b/kernel/csymtable.ml @@ -199,19 +199,13 @@ and slot_for_fv env fv = end and eval_to_patch env (buff,pl,fv) = - (* copy code *before* patching because of nested evaluations: - the code we are patching might be called (and thus "concurrently" patched) - and results in wrong results. Side-effects... *) - let buff = Cemitcodes.copy buff in let patch = function - | Reloc_annot a, pos -> patch_int buff pos (slot_for_annot a) - | Reloc_const sc, pos -> patch_int buff pos (slot_for_str_cst sc) - | Reloc_getglobal kn, pos -> -(* Pp.msgnl (str"patching global: "++str(debug_string_of_con kn));*) - patch_int buff pos (slot_for_getglobal env kn); -(* Pp.msgnl (str"patch done: "++str(debug_string_of_con kn))*) + | Reloc_annot a, pos -> (pos, slot_for_annot a) + | Reloc_const sc, pos -> (pos, slot_for_str_cst sc) + | Reloc_getglobal kn, pos -> (pos, slot_for_getglobal env kn) in - List.iter patch pl; + let patches = List.map_left patch pl in + let buff = patch_int buff patches in let vm_env = Array.map (slot_for_fv env) fv in let tc = tcode_of_code buff (length buff) in (*Pp.msgnl (str"execute code");*) |
