aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Pierre-Marie Pédrot <pierre-marie.pedrot@inria.fr>2017-11-23 14:48:05 +0100
committerGravatar Pierre-Marie Pédrot <pierre-marie.pedrot@inria.fr>2018-02-14 16:16:12 +0100
commit8fa3c26adb1bc2c0201a61adede278a0e889eef4 (patch)
treed0763354c3b05da2e80780d057af068beb3be539
parent8cd6ddb98c12b6aba002781158180ffb68aba02f (diff)
Move the call to the computation of bytecode inside Cemitcodes.
This shouldn't matter because the tcode_of_code function is pure, its only effect being allocating a string and filling it with the translated bytecode.
-rw-r--r--kernel/cemitcodes.ml11
-rw-r--r--kernel/cemitcodes.mli4
-rw-r--r--kernel/csymtable.ml4
3 files changed, 8 insertions, 11 deletions
diff --git a/kernel/cemitcodes.ml b/kernel/cemitcodes.ml
index bc6140ef4..41494441b 100644
--- a/kernel/cemitcodes.ml
+++ b/kernel/cemitcodes.ml
@@ -15,6 +15,10 @@ open Cbytecodes
open Copcodes
open Mod_subst
+type emitcodes = String.t
+
+external tcode_of_code : emitcodes -> int -> Vmvalues.tcode = "coq_tcode_of_code"
+
(* Relocation information *)
type reloc_info =
| Reloc_annot of annot_switch
@@ -57,9 +61,10 @@ let patch_int buff patches =
let patch buff pl f =
let map (r, pos) = (pos, f r) in
+ (** Order seems important here? *)
let patches = CList.map_left map pl in
let buff = patch_int buff patches in
- buff
+ tcode_of_code buff (String.length buff)
(* Buffering of bytecode *)
@@ -327,10 +332,6 @@ let init () =
label_table := Array.make 16 (Label_undefined []);
reloc_info := []
-type emitcodes = String.t
-
-let length = String.length
-
type to_patch = emitcodes * (patch list) * fv
(* Substitution *)
diff --git a/kernel/cemitcodes.mli b/kernel/cemitcodes.mli
index a2ff2d301..aa055dcb0 100644
--- a/kernel/cemitcodes.mli
+++ b/kernel/cemitcodes.mli
@@ -9,9 +9,7 @@ type reloc_info =
type patches
type emitcodes
-val length : emitcodes -> int
-
-val patch : emitcodes -> patches -> (reloc_info -> int) -> emitcodes
+val patch : emitcodes -> patches -> (reloc_info -> int) -> Vmvalues.tcode
type to_patch = emitcodes * patches * fv
diff --git a/kernel/csymtable.ml b/kernel/csymtable.ml
index 38044071f..8022eae7d 100644
--- a/kernel/csymtable.ml
+++ b/kernel/csymtable.ml
@@ -25,7 +25,6 @@ open Cbytegen
module NamedDecl = Context.Named.Declaration
module RelDecl = Context.Rel.Declaration
-external tcode_of_code : emitcodes -> int -> tcode = "coq_tcode_of_code"
external eval_tcode : tcode -> values array -> values = "coq_eval_tcode"
(*******************)
@@ -210,9 +209,8 @@ and eval_to_patch env (buff,pl,fv) =
| Reloc_const sc -> slot_for_str_cst sc
| Reloc_getglobal kn -> slot_for_getglobal env kn
in
- let buff = patch buff pl slots in
+ let tc = patch buff pl slots in
let vm_env = Array.map (slot_for_fv env) fv in
- let tc = tcode_of_code buff (length buff) in
eval_tcode tc vm_env
and val_of_constr env c =