summaryrefslogtreecommitdiff
path: root/bytecomp/emitcode.ml
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>1995-06-18 14:44:56 +0000
committerXavier Leroy <xavier.leroy@inria.fr>1995-06-18 14:44:56 +0000
commite0f3c043e5dd7ad4dbec7feb15b9c7a23ebecb2d (patch)
tree1a849245370f2b163150bc021a8577ba10ef3a41 /bytecomp/emitcode.ml
parent170fb62ccd2509eb7b5cd0da9cb3fc4a9d2f1edc (diff)
downloadocaml-e0f3c043e5dd7ad4dbec7feb15b9c7a23ebecb2d.tar.gz
Changement representation des constructeurs constants.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@40 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'bytecomp/emitcode.ml')
-rw-r--r--bytecomp/emitcode.ml23
1 files changed, 14 insertions, 9 deletions
diff --git a/bytecomp/emitcode.ml b/bytecomp/emitcode.ml
index df97932a7d..fe81650f83 100644
--- a/bytecomp/emitcode.ml
+++ b/bytecomp/emitcode.ml
@@ -25,7 +25,7 @@ type compilation_unit =
cu_interfaces: (string * int) list } (* Names and CRC of intfs imported *)
(* Format of a .cmo file:
- Obj.magic number (Config.cmo_magic_number)
+ magic number (Config.cmo_magic_number)
absolute offset of compilation unit descriptor
block of relocatable bytecode
compilation unit descriptor *)
@@ -155,11 +155,13 @@ let emit_instr = function
| Kconst sc ->
begin match sc with
Const_base(Const_int i) when i >= immed_min & i <= immed_max ->
- out opCONSTINT; out_int i
+ if i >= 0 & i <= 3
+ then out (opCONST0 + i)
+ else (out opCONSTINT; out_int i)
| Const_base(Const_char c) ->
out opCONSTINT; out_int (Char.code c)
| Const_block(t, []) ->
- if t < 4 then out (opATOM0 + t) else (out opATOM; out_int t)
+ if t = 0 then out opATOM0 else (out opATOM; out_int t)
| _ ->
out opGETGLOBAL; slot_for_literal sc
end
@@ -172,7 +174,6 @@ let emit_instr = function
if n < 4 then out(opGETFIELD0 + n) else (out opGETFIELD; out_int n)
| Ksetfield n ->
if n < 4 then out(opSETFIELD0 + n) else (out opSETFIELD; out_int n)
- | Ktagof -> out opTAGOF
| Kdummy n -> out opDUMMY; out_int n
| Kupdate -> out opUPDATE
| Kvectlength -> out opVECTLENGTH
@@ -185,10 +186,12 @@ let emit_instr = function
| Kbranchifnot lbl -> out opBRANCHIFNOT; out_label lbl
| Kstrictbranchif lbl -> out opBRANCHIF; out_label lbl
| Kstrictbranchifnot lbl -> out opBRANCHIFNOT; out_label lbl
- | Kswitch lblv ->
- out opSWITCH; out_int (Array.length lblv);
+ | Kswitch(tbl_const, tbl_block) ->
+ out opSWITCH;
+ out_int (Array.length tbl_const + (Array.length tbl_block lsl 16));
let org = !out_position in
- Array.iter (out_label_with_orig org) lblv
+ Array.iter (out_label_with_orig org) tbl_const;
+ Array.iter (out_label_with_orig org) tbl_block
| Ktranslate tbl ->
out opTRANSLATE; out_int (Array.length tbl);
Array.iter
@@ -234,11 +237,13 @@ let rec emit = function
| Kpush :: Kconst sc :: c ->
begin match sc with
Const_base(Const_int i) when i >= immed_min & i <= immed_max ->
- out opPUSHCONSTINT; out_int i
+ if i >= 0 & i <= 3
+ then out (opPUSHCONST0 + i)
+ else (out opPUSHCONSTINT; out_int i)
| Const_base(Const_char c) ->
out opPUSHCONSTINT; out_int(Char.code c)
| Const_block(t, []) ->
- if t < 4 then out (opPUSHATOM0 + t) else (out opPUSHATOM; out_int t)
+ if t = 0 then out opPUSHATOM0 else (out opPUSHATOM; out_int t)
| _ ->
out opPUSHGETGLOBAL; slot_for_literal sc
end;