Add bytecode instruction to access string, different from the bytes one.

master
Hugo Heuzard 2018-02-17 07:59:49 +00:00 committed by Nicolás Ojeda Bär
parent 8c51cd996a
commit 1c233b6b69
8 changed files with 16 additions and 9 deletions

View File

@ -360,8 +360,9 @@ let comp_primitive p args =
| Pstringrefs -> Kccall("caml_string_get", 2)
| Pbytesrefs -> Kccall("caml_bytes_get", 2)
| Pbytessets -> Kccall("caml_bytes_set", 3)
| Pstringrefu | Pbytesrefu -> Kgetstringchar
| Pbytessetu -> Ksetstringchar
| Pstringrefu -> Kgetstringchar
| Pbytesrefu -> Kgetbyteschar
| Pbytessetu -> Ksetbyteschar
| Pstring_load_16(_) -> Kccall("caml_string_get16", 2)
| Pstring_load_32(_) -> Kccall("caml_string_get32", 2)
| Pstring_load_64(_) -> Kccall("caml_string_get64", 2)

View File

@ -258,8 +258,9 @@ let emit_instr = function
| Kvectlength -> out opVECTLENGTH
| Kgetvectitem -> out opGETVECTITEM
| Ksetvectitem -> out opSETVECTITEM
| Kgetstringchar -> out opGETSTRINGCHAR
| Ksetstringchar -> out opSETSTRINGCHAR
| Kgetstringchar -> out opGETISTRINGCHAR
| Kgetbyteschar -> out opGETSTRINGCHAR
| Ksetbyteschar -> out opSETSTRINGCHAR
| Kbranch lbl -> out opBRANCH; out_label lbl
| Kbranchif lbl -> out opBRANCHIF; out_label lbl
| Kbranchifnot lbl -> out opBRANCHIFNOT; out_label lbl

View File

@ -78,7 +78,8 @@ type instruction =
| Kgetvectitem
| Ksetvectitem
| Kgetstringchar
| Ksetstringchar
| Kgetbyteschar
| Ksetbyteschar
| Kbranch of label
| Kbranchif of label
| Kbranchifnot of label

View File

@ -98,7 +98,8 @@ type instruction =
| Kgetvectitem
| Ksetvectitem
| Kgetstringchar
| Ksetstringchar
| Kgetbyteschar
| Ksetbyteschar
| Kbranch of label
| Kbranchif of label
| Kbranchifnot of label

View File

@ -56,7 +56,8 @@ let instruction ppf = function
| Kgetvectitem -> fprintf ppf "\tgetvectitem"
| Ksetvectitem -> fprintf ppf "\tsetvectitem"
| Kgetstringchar -> fprintf ppf "\tgetstringchar"
| Ksetstringchar -> fprintf ppf "\tsetstringchar"
| Kgetbyteschar -> fprintf ppf "\tgetbyteschar"
| Ksetbyteschar -> fprintf ppf "\tsetbyteschar"
| Kbranch lbl -> fprintf ppf "\tbranch L%i" lbl
| Kbranchif lbl -> fprintf ppf "\tbranchif L%i" lbl
| Kbranchifnot lbl -> fprintf ppf "\tbranchifnot L%i" lbl

View File

@ -60,6 +60,7 @@ enum instructions {
STOP,
EVENT, BREAK,
RERAISE, RAISE_NOTRACE,
GETISTRINGCHAR,
FIRST_UNIMPLEMENTED_OP};
#endif /* CAML_INTERNALS */

View File

@ -778,8 +778,8 @@ value caml_interprete(code_t prog, asize_t prog_size)
sp += 2;
Next;
/* String operations */
/* Bytes/String operations */
Instruct(GETISTRINGCHAR):
Instruct(GETSTRINGCHAR):
accu = Val_int(Byte_u(accu, Long_val(sp[0])));
sp += 1;

View File

@ -333,6 +333,7 @@ let op_shapes = [
opVECTLENGTH, Nothing;
opGETVECTITEM, Nothing;
opSETVECTITEM, Nothing;
opGETISTRINGCHAR, Nothing;
opGETSTRINGCHAR, Nothing;
opSETSTRINGCHAR, Nothing;
opBRANCH, Disp;