From 8cd6ddb98c12b6aba002781158180ffb68aba02f Mon Sep 17 00:00:00 2001 From: Pierre-Marie Pédrot Date: Thu, 23 Nov 2017 14:28:21 +0100 Subject: Abstract further the type of VM bytecode compilation. This reduces the possibility to wreak havoc while making the API nicer. --- kernel/cemitcodes.mli | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'kernel/cemitcodes.mli') diff --git a/kernel/cemitcodes.mli b/kernel/cemitcodes.mli index fee45aafd8..a2ff2d3019 100644 --- a/kernel/cemitcodes.mli +++ b/kernel/cemitcodes.mli @@ -6,18 +6,14 @@ type reloc_info = | Reloc_const of structured_constant | Reloc_getglobal of Constant.t -type patch = reloc_info * int - -(* A virer *) -val subst_patch : Mod_subst.substitution -> patch -> patch - +type patches type emitcodes val length : emitcodes -> int -val patch_int : emitcodes -> ((*pos*)int * int) list -> emitcodes +val patch : emitcodes -> patches -> (reloc_info -> int) -> emitcodes -type to_patch = emitcodes * (patch list) * fv +type to_patch = emitcodes * patches * fv val subst_to_patch : Mod_subst.substitution -> to_patch -> to_patch -- cgit v1.2.3 From 8fa3c26adb1bc2c0201a61adede278a0e889eef4 Mon Sep 17 00:00:00 2001 From: Pierre-Marie Pédrot Date: Thu, 23 Nov 2017 14:48:05 +0100 Subject: 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. --- kernel/cemitcodes.mli | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'kernel/cemitcodes.mli') diff --git a/kernel/cemitcodes.mli b/kernel/cemitcodes.mli index a2ff2d3019..aa055dcb02 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 -- cgit v1.2.3 From da659eeeb413c488f5efae0269c5d37837c62dc2 Mon Sep 17 00:00:00 2001 From: Pierre-Marie Pédrot Date: Thu, 23 Nov 2017 15:44:52 +0100 Subject: Use a more compact representation for bytecode relocations stored on disk. The previous implementation used a list of pairs, which has size 9n where n is the number of relocations. We instead use two arrays for a total memory cost of 2n + 5 words. The use of arrays may turn out to be problematic on 32-bit machines, I am unsure if we will hit this limitation in practice. --- kernel/cemitcodes.mli | 2 -- 1 file changed, 2 deletions(-) (limited to 'kernel/cemitcodes.mli') diff --git a/kernel/cemitcodes.mli b/kernel/cemitcodes.mli index aa055dcb02..03920dc1a3 100644 --- a/kernel/cemitcodes.mli +++ b/kernel/cemitcodes.mli @@ -13,8 +13,6 @@ val patch : emitcodes -> patches -> (reloc_info -> int) -> Vmvalues.tcode type to_patch = emitcodes * patches * fv -val subst_to_patch : Mod_subst.substitution -> to_patch -> to_patch - type body_code = | BCdefined of to_patch | BCalias of Constant.t -- cgit v1.2.3