Verified Commit 121c013c authored by Camil Staps's avatar Camil Staps 🚀

Add instruction updateAC to parallel jsr updateAC in StdString for :=

parent dd071b13
Pipeline #26110 failed with stages
in 7 minutes and 50 seconds
......@@ -514,6 +514,7 @@ const char *instruction_type (BC_WORD i) {
case CtanR: return "";
case Ctestcaf: return "C";
case Cupdate: return "";
case CupdateAC: return "";
case CupdateBOOL: return "";
case CupdateCHAR: return "";
case CupdateINT: return "";
......
......@@ -500,6 +500,7 @@ enum {
INSTRUCTION(tanR)
INSTRUCTION(testcaf)
INSTRUCTION(update)
INSTRUCTION(updateAC)
INSTRUCTION(updateBOOL)
INSTRUCTION(updateCHAR)
INSTRUCTION(updateINT)
......
......@@ -953,19 +953,20 @@ static char *specialized_jsr_labels[] = {
/* 1*/ "cmpAC",
/* 2*/ "catAC",
/* 3*/ "sliceAC",
/* 4*/ "ItoAC",
/* 5*/ "BtoAC",
/* 6*/ "RtoAC",
/* 7*/ "print__string__",
/* 8*/ "openF",
/* 9*/ "stdioF",
/*10*/ "closeF",
/*11*/ "readLineF",
/*12*/ "endF",
/*13*/ "writeFI",
/*14*/ "writeFS",
/*15*/ "writeFC",
/*16*/ "openSF"
/* 4*/ "updateAC",
/* 5*/ "ItoAC",
/* 6*/ "BtoAC",
/* 7*/ "RtoAC",
/* 8*/ "print__string__",
/* 9*/ "openF",
/*10*/ "stdioF",
/*11*/ "closeF",
/*12*/ "readLineF",
/*13*/ "endF",
/*14*/ "writeFI",
/*15*/ "writeFS",
/*16*/ "writeFC",
/*17*/ "openSF"
};
static int get_specialized_jsr_label_n(char label_name[]) {
......@@ -985,10 +986,11 @@ void add_specialized_jsr_instruction(unsigned int n) {
case 1: add_instruction(CcmpAC); return;
case 2: add_instruction(CcatAC); return;
case 3: add_instruction(CsliceAC); return;
case 4: add_instruction(CItoAC); return;
case 5: add_instruction(CBtoAC); return;
case 6: add_instruction(CRtoAC); return;
case 7: add_instruction(Cprint_string); return;
case 4: add_instruction(CupdateAC); return;
case 5: add_instruction(CItoAC); return;
case 6: add_instruction(CBtoAC); return;
case 7: add_instruction(CRtoAC); return;
case 8: add_instruction(Cprint_string); return;
default:
if (n < sizeof(specialized_jsr_labels)/sizeof(char*)) {
fprintf(stderr,"Warning: jsr %s is not supported by the interpreter\n",specialized_jsr_labels[n]);
......
......@@ -27,4 +27,4 @@ typedef int64_t CleanInt;
#define BCGEN_INSTRUCTION_TABLE_SIZE 512
#define ABC_MAGIC_NUMBER 0x2a434241
#define ABC_VERSION 10
#define ABC_VERSION 11
......@@ -2913,6 +2913,21 @@ all_instructions opts t = bootstrap $ collect_instructions opts $ map (\i -> i t
, instr "testcaf" (Just 1) $
B @ -1 .= to_word_ptr (Pc @ 1) @ 0 :.
grow_b 1
, instr "updateAC" (Just 0) $
// B[0] is index; B[1] new character; A[0] the _STRING_, which is *not* unique
new_local (TPtr TWord) (to_word_ptr (A @ 0)) \string ->
new_local TPtrOffset (to_ptr_offset (string @ 1)) \len ->
len .= lit_hword 2 + if_i64_or_i32_expr ((len + lit_hword 7) >>. lit_hword 3) ((len + lit_hword 3) >>. lit_hword 2) :.
ensure_hp len :.
A @ 0 .= to_word Hp :.
new_local TPtrOffset (len - lit_hword 1) \n ->
while_do (n >=. lit_hword 0) (
Hp @ n .= string @ n :.
n -= lit_hword 1
) :.
to_char_ptr (Hp @? 2) @ (B @ 0) .= to_char (B @ 1) :.
advance_ptr Hp len :.
shrink_b 2
, instr "update" (Just 0) $
new_local (TPtr TWord) (to_word_ptr (A @ 0)) \array ->
array @ (lit_hword 3 + to_ptr_offset (B @ 0)) .= A @ -1 :.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment