From 9605eee65cdd33a7b9bc3a1361fd5ddf93db7dce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlo=20Marcelo=20Arenas=20Bel=C3=B3n?= Date: Sun, 23 Apr 2023 07:39:44 -0700 Subject: [PATCH] arm64: refactor test92 to avoid possibly conflicting writes The specification allows up to a maximum exclusive granule of 512 words to be reserved after `ldxr`, so writes close enough to the address that was loaded could result on the reservation being invalidated and `stxr` failing. Instead of writing back the just read data, do a second read to validate the first one and compare them internally. Fixes: #160 --- test_src/sljitTest.c | 227 +++++++++++++++++++------------------------ 1 file changed, 98 insertions(+), 129 deletions(-) diff --git a/test_src/sljitTest.c b/test_src/sljitTest.c index 510df789..c38f92a0 100644 --- a/test_src/sljitTest.c +++ b/test_src/sljitTest.c @@ -11395,7 +11395,7 @@ static void test91(void) sljit_s32 i; if (verbose) - printf("Run test13\n"); + printf("Run test91\n"); if (!sljit_has_cpu_feature(SLJIT_HAS_FPU)) { if (verbose) @@ -11529,8 +11529,8 @@ static void test92(void) executable_code code; struct sljit_compiler *compiler = sljit_create_compiler(NULL, NULL); struct sljit_label *label; - struct sljit_jump *jump; - sljit_sw buf[32]; + struct sljit_jump *jump, *skip; + sljit_sw buf[12]; sljit_s32 i; if (verbose) @@ -11538,230 +11538,199 @@ static void test92(void) FAILED(!compiler, "cannot create compiler\n"); - for (i = 0; i < 32; i++) + for (i = 0; i < 12; i++) buf[i] = -1; buf[0] = -4678; - *(sljit_u8*)(buf + 2) = 178; - *(sljit_u8*)(buf + 5) = 211; - *(sljit_u16*)(buf + 9) = 17897; - *(sljit_u16*)(buf + 12) = 57812; - *(sljit_u32*)(buf + 15) = 1234567890; - *(sljit_u32*)(buf + 17) = 987609876; - *(sljit_u8*)(buf + 20) = 192; - buf[23] = 6359; - ((sljit_u8*)(buf + 26))[1] = 105; - ((sljit_u8*)(buf + 28))[2] = 13; - ((sljit_u16*)(buf + 30))[1] = 14876; + *(sljit_u8*)(buf + 1) = 178; + *(sljit_u8*)(buf + 2) = 211; + *(sljit_u16*)(buf + 3) = 17897; + *(sljit_u16*)(buf + 4) = 57812; + *(sljit_u32*)(buf + 5) = 1234567890; + *(sljit_u32*)(buf + 6) = 987609876; + *(sljit_u8*)(buf + 7) = 192; + buf[8] = 6359; + ((sljit_u8*)(buf + 9))[1] = 105; + ((sljit_u8*)(buf + 10))[2] = 13; + ((sljit_u16*)(buf + 11))[1] = 14876; sljit_emit_enter(compiler, 0, SLJIT_ARGS1(VOID, P), 5, 5, 0, 0, 2 * sizeof(sljit_sw)); label = sljit_emit_label(compiler); sljit_emit_atomic_load(compiler, SLJIT_MOV, SLJIT_R1, SLJIT_S0); - /* buf[1] */ - sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_S0), sizeof(sljit_sw), SLJIT_R1, 0); - sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_R0, 0, SLJIT_R1, 0); + jump = sljit_emit_cmp(compiler, SLJIT_NOT_EQUAL, SLJIT_R1, 0, SLJIT_MEM1(SLJIT_S0), 0); sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_R1, 0, SLJIT_IMM, -9856); /* buf[0] */ sljit_emit_atomic_store(compiler, SLJIT_MOV | SLJIT_SET_ATOMIC_STORED, SLJIT_R1, SLJIT_S0, SLJIT_R0); sljit_set_label(sljit_emit_jump(compiler, SLJIT_ATOMIC_NOT_STORED), label); + sljit_set_label(jump, sljit_emit_label(compiler)); - sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_R1, 0, SLJIT_S0, 0, SLJIT_IMM, 2 * sizeof(sljit_sw)); + sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_R1, 0, SLJIT_S0, 0, SLJIT_IMM, sizeof(sljit_sw)); label = sljit_emit_label(compiler); sljit_emit_atomic_load(compiler, SLJIT_MOV_U8, SLJIT_R2, SLJIT_R1); - /* buf[3] */ - sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_S0), 3 * sizeof(sljit_sw), SLJIT_R2, 0); + sljit_emit_op1(compiler, SLJIT_MOV_U8, SLJIT_R0, 0, SLJIT_MEM1(SLJIT_S0), sizeof(sljit_sw)); + jump = sljit_emit_cmp(compiler, SLJIT_NOT_EQUAL, SLJIT_R2, 0, SLJIT_R0, 0); sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_R0, 0, SLJIT_IMM, 203); - /* buf[2] */ + /* buf[1] */ sljit_emit_atomic_store(compiler, SLJIT_MOV_U8 | SLJIT_SET_ATOMIC_STORED, SLJIT_R0, SLJIT_R1, SLJIT_R2); - jump = sljit_emit_jump(compiler, SLJIT_ATOMIC_STORED); + skip = sljit_emit_jump(compiler, SLJIT_ATOMIC_STORED); sljit_set_label(sljit_emit_jump(compiler, SLJIT_JUMP), label); + sljit_set_label(skip, sljit_emit_label(compiler)); sljit_set_label(jump, sljit_emit_label(compiler)); - /* buf[4] */ - sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_S0), 4 * sizeof(sljit_sw), SLJIT_R0, 0); + sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_R0, 0, SLJIT_S0, 0, SLJIT_IMM, 2 * sizeof(sljit_sw)); + sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_R2, 0, SLJIT_R0, 0); label = sljit_emit_label(compiler); - sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_R0, 0, SLJIT_S0, 0, SLJIT_IMM, 5 * sizeof(sljit_sw)); sljit_emit_atomic_load(compiler, SLJIT_MOV32_U8, SLJIT_R0, SLJIT_R0); - /* buf[6] */ - sljit_emit_op1(compiler, SLJIT_MOV32, SLJIT_MEM1(SLJIT_S0), 6 * sizeof(sljit_sw), SLJIT_R0, 0); - sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_S2, 0, SLJIT_R0, 0); - sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_R0, 0, SLJIT_S0, 0, SLJIT_IMM, 5 * sizeof(sljit_sw)); + skip = sljit_emit_cmp(compiler, SLJIT_NOT_EQUAL | SLJIT_32, SLJIT_R0, 0, SLJIT_IMM, 211); + sljit_emit_op1(compiler, SLJIT_MOV32_U8, SLJIT_S2, 0, SLJIT_MEM1(SLJIT_S0), 2 * sizeof(sljit_sw)); + jump = sljit_emit_cmp(compiler, SLJIT_NOT_EQUAL | SLJIT_32, SLJIT_S2, 0, SLJIT_R0, 0); sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_S1, 0, SLJIT_IMM, 97); - /* buf[5] */ + sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_R0, 0, SLJIT_R2, 0); + /* buf[2] */ sljit_emit_atomic_store(compiler, SLJIT_MOV_U8 | SLJIT_SET_ATOMIC_STORED, SLJIT_S1, SLJIT_R0, SLJIT_S2); sljit_set_label(sljit_emit_jump(compiler, SLJIT_ATOMIC_NOT_STORED), label); - /* buf[7] */ - sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_S0), 7 * sizeof(sljit_sw), SLJIT_R0, 0); - /* buf[8] */ - sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_S0), 8 * sizeof(sljit_sw), SLJIT_S1, 0); + sljit_set_label(jump, sljit_emit_label(compiler)); + sljit_set_label(skip, sljit_emit_label(compiler)); label = sljit_emit_label(compiler); - sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_R1, 0, SLJIT_S0, 0, SLJIT_IMM, 9 * sizeof(sljit_sw)); + sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_R1, 0, SLJIT_S0, 0, SLJIT_IMM, 3 * sizeof(sljit_sw)); + sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_R0, 0, SLJIT_R1, 0); sljit_emit_atomic_load(compiler, SLJIT_MOV_U16, SLJIT_S2, SLJIT_R1); - /* buf[10] */ - sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_S0), 10 * sizeof(sljit_sw), SLJIT_S2, 0); - sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_R1, 0, SLJIT_S2, 0); - sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_R0, 0, SLJIT_S0, 0, SLJIT_IMM, 9 * sizeof(sljit_sw)); - /* buf[9] */ + sljit_emit_op1(compiler, SLJIT_MOV_U16, SLJIT_R1, 0, SLJIT_MEM1(SLJIT_S0), 3 * sizeof(sljit_sw)); + jump = sljit_emit_cmp(compiler, SLJIT_NOT_EQUAL, SLJIT_S2, 0, SLJIT_R1, 0); + /* buf[3] */ sljit_emit_atomic_store(compiler, SLJIT_MOV_U16 | SLJIT_SET_ATOMIC_STORED, SLJIT_R0, SLJIT_R0, SLJIT_R1); sljit_set_label(sljit_emit_jump(compiler, SLJIT_ATOMIC_NOT_STORED), label); - /* buf[11] */ - sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_S0), 11 * sizeof(sljit_sw), SLJIT_R0, 0); + sljit_set_label(jump, sljit_emit_label(compiler)); - sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_R1, 0, SLJIT_S0, 0, SLJIT_IMM, 12 * sizeof(sljit_sw)); + sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_R1, 0, SLJIT_S0, 0, SLJIT_IMM, 4 * sizeof(sljit_sw)); label = sljit_emit_label(compiler); sljit_emit_atomic_load(compiler, SLJIT_MOV32_U16, SLJIT_R0, SLJIT_R1); - /* buf[13] */ - sljit_emit_op1(compiler, SLJIT_MOV32, SLJIT_MEM1(SLJIT_S0), 13 * sizeof(sljit_sw), SLJIT_R0, 0); + sljit_emit_op1(compiler, SLJIT_MOV32_U16, SLJIT_S1, 0, SLJIT_MEM1(SLJIT_S0), 4 * sizeof(sljit_sw)); + jump = sljit_emit_cmp(compiler, SLJIT_NOT_EQUAL | SLJIT_32, SLJIT_R0, 0, SLJIT_S1, 0); sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_R3, 0, SLJIT_R0, 0); sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_R0, 0, SLJIT_IMM, 41306); - /* buf[12] */ + /* buf[4] */ sljit_emit_atomic_store(compiler, SLJIT_MOV32_U16 | SLJIT_SET_ATOMIC_STORED, SLJIT_R0, SLJIT_R1, SLJIT_R3); sljit_set_label(sljit_emit_jump(compiler, SLJIT_ATOMIC_NOT_STORED), label); - /* buf[14] */ - sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_S0), 14 * sizeof(sljit_sw), SLJIT_R0, 0); + sljit_set_label(jump, sljit_emit_label(compiler)); - sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_S2, 0, SLJIT_S0, 0, SLJIT_IMM, 15 * sizeof(sljit_sw)); + sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_S2, 0, SLJIT_S0, 0, SLJIT_IMM, 5 * sizeof(sljit_sw)); label = sljit_emit_label(compiler); sljit_emit_atomic_load(compiler, SLJIT_MOV_U32, SLJIT_R2, SLJIT_S2); - /* buf[16] */ - sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_S0), 16 * sizeof(sljit_sw), SLJIT_R2, 0); + sljit_emit_op1(compiler, SLJIT_MOV32, SLJIT_S1, 0, SLJIT_MEM1(SLJIT_S0), 5 * sizeof(sljit_sw)); + jump = sljit_emit_cmp(compiler, SLJIT_NOT_EQUAL, SLJIT_R2, 0, SLJIT_S1, 0); sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_S3, 0, SLJIT_R2, 0); sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_R1, 0, SLJIT_IMM, 987654321); - sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_S1, 0, SLJIT_S0, 0, SLJIT_IMM, 15 * sizeof(sljit_sw)); - /* buf[15] */ + sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_S1, 0, SLJIT_S0, 0, SLJIT_IMM, 5 * sizeof(sljit_sw)); + /* buf[5] */ sljit_emit_atomic_store(compiler, SLJIT_MOV_U32 | SLJIT_SET_ATOMIC_STORED, SLJIT_R1, SLJIT_S1, SLJIT_S3); sljit_set_label(sljit_emit_jump(compiler, SLJIT_ATOMIC_NOT_STORED), label); + sljit_set_label(jump, sljit_emit_label(compiler)); - sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_R2, 0, SLJIT_S0, 0, SLJIT_IMM, 17 * sizeof(sljit_sw)); + sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_R2, 0, SLJIT_S0, 0, SLJIT_IMM, 6 * sizeof(sljit_sw)); label = sljit_emit_label(compiler); sljit_emit_atomic_load(compiler, SLJIT_MOV32, SLJIT_R0, SLJIT_R2); - /* buf[18] */ - sljit_emit_op1(compiler, SLJIT_MOV32, SLJIT_MEM1(SLJIT_S0), 18 * sizeof(sljit_sw), SLJIT_R0, 0); + sljit_emit_op1(compiler, SLJIT_MOV32, SLJIT_S1, 0, SLJIT_MEM1(SLJIT_S0), 6 * sizeof(sljit_sw)); + jump = sljit_emit_cmp(compiler, SLJIT_NOT_EQUAL | SLJIT_32, SLJIT_R0, 0, SLJIT_S1, 0); sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_S2, 0, SLJIT_R0, 0); - sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_R0, 0, SLJIT_IMM, -573621); sljit_emit_op1(compiler, SLJIT_MOV32, SLJIT_R1, 0, SLJIT_IMM, 678906789); - /* buf[17] */ + /* buf[6] */ sljit_emit_atomic_store(compiler, SLJIT_MOV32 | SLJIT_SET_ATOMIC_STORED, SLJIT_R1, SLJIT_R2, SLJIT_S2); sljit_set_label(sljit_emit_jump(compiler, SLJIT_ATOMIC_NOT_STORED), label); - /* buf[19] */ - sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_S0), 19 * sizeof(sljit_sw), SLJIT_R0, 0); + sljit_set_label(jump, sljit_emit_label(compiler)); - sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_R1, 0, SLJIT_S0, 0, SLJIT_IMM, 20 * sizeof(sljit_sw)); + sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_R1, 0, SLJIT_S0, 0, SLJIT_IMM, 7 * sizeof(sljit_sw)); label = sljit_emit_label(compiler); sljit_emit_atomic_load(compiler, SLJIT_MOV_U8, SLJIT_R3, SLJIT_R1); - /* buf[21] */ - sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_S0), 21 * sizeof(sljit_sw), SLJIT_R3, 0); + sljit_emit_op1(compiler, SLJIT_MOV_U8, SLJIT_S1, 0, SLJIT_MEM1(SLJIT_S0), 7 * sizeof(sljit_sw)); + jump = sljit_emit_cmp(compiler, SLJIT_NOT_EQUAL, SLJIT_R3, 0, SLJIT_S1, 0); sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_R4, 0, SLJIT_R3, 0); sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_R3, 0, SLJIT_IMM, 240); sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_R0, 0, SLJIT_IMM, -5893); - /* buf[20] */ + /* buf[7] */ sljit_emit_atomic_store(compiler, SLJIT_MOV_U8 | SLJIT_SET_ATOMIC_STORED, SLJIT_R3, SLJIT_R1, SLJIT_R4); sljit_set_label(sljit_emit_jump(compiler, SLJIT_ATOMIC_NOT_STORED), label); - /* buf[22] */ - sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_S0), 22 * sizeof(sljit_sw), SLJIT_R0, 0); + sljit_set_label(jump, sljit_emit_label(compiler)); - sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_R0, 0, SLJIT_S0, 0, SLJIT_IMM, 23 * sizeof(sljit_sw)); + sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_R0, 0, SLJIT_S0, 0, SLJIT_IMM, 8 * sizeof(sljit_sw)); label = sljit_emit_label(compiler); sljit_emit_atomic_load(compiler, SLJIT_MOV, SLJIT_S3, SLJIT_R0); - /* buf[24] */ - sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_S0), 24 * sizeof(sljit_sw), SLJIT_S3, 0); + sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_S1, 0, SLJIT_MEM1(SLJIT_S0), 8 * sizeof(sljit_sw)); + jump = sljit_emit_cmp(compiler, SLJIT_NOT_EQUAL, SLJIT_S3, 0, SLJIT_S1, 0); sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_S4, 0, SLJIT_S3, 0); sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_S3, 0, SLJIT_IMM, 4059); - /* buf[23] */ + /* buf[8] */ sljit_emit_atomic_store(compiler, SLJIT_MOV | SLJIT_SET_ATOMIC_STORED, SLJIT_S3, SLJIT_R0, SLJIT_S4); sljit_set_label(sljit_emit_jump(compiler, SLJIT_ATOMIC_NOT_STORED), label); - /* buf[25] */ - sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_S0), 25 * sizeof(sljit_sw), SLJIT_R0, 0); + sljit_set_label(jump, sljit_emit_label(compiler)); - sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_R1, 0, SLJIT_S0, 0, SLJIT_IMM, 26 * sizeof(sljit_sw) + 1); + sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_R1, 0, SLJIT_S0, 0, SLJIT_IMM, 9 * sizeof(sljit_sw) + 1); label = sljit_emit_label(compiler); sljit_emit_atomic_load(compiler, SLJIT_MOV_U8, SLJIT_R0, SLJIT_R1); - /* buf[27] */ - sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_S0), 27 * sizeof(sljit_sw), SLJIT_R0, 0); + sljit_emit_op1(compiler, SLJIT_MOV_U8, SLJIT_S1, 0, SLJIT_MEM1(SLJIT_R1), 0); + skip = sljit_emit_cmp(compiler, SLJIT_NOT_EQUAL, SLJIT_R0, 0, SLJIT_S1, 0); sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_R2, 0, SLJIT_IMM, 204); - /* buf[26] */ + /* buf[9] */ sljit_emit_atomic_store(compiler, SLJIT_MOV_U8 | SLJIT_SET_ATOMIC_STORED, SLJIT_R2, SLJIT_R1, SLJIT_R0); jump = sljit_emit_jump(compiler, SLJIT_ATOMIC_STORED); sljit_set_label(sljit_emit_jump(compiler, SLJIT_JUMP), label); sljit_set_label(jump, sljit_emit_label(compiler)); + sljit_set_label(skip, sljit_emit_label(compiler)); - sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_R1, 0, SLJIT_S0, 0, SLJIT_IMM, 28 * sizeof(sljit_sw) + 2); + sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_R1, 0, SLJIT_S0, 0, SLJIT_IMM, 10 * sizeof(sljit_sw) + 2); label = sljit_emit_label(compiler); sljit_emit_atomic_load(compiler, SLJIT_MOV_U8, SLJIT_R0, SLJIT_R1); - /* buf[29] */ - sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_S0), 29 * sizeof(sljit_sw), SLJIT_R0, 0); + sljit_emit_op1(compiler, SLJIT_MOV_U8, SLJIT_S1, 0, SLJIT_MEM1(SLJIT_R1), 0); + jump = sljit_emit_cmp(compiler, SLJIT_NOT_EQUAL, SLJIT_R0, 0, SLJIT_S1, 0); sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_R2, 0, SLJIT_IMM, 240); - /* buf[28] */ + /* buf[10] */ sljit_emit_atomic_store(compiler, SLJIT_MOV_U8 | SLJIT_SET_ATOMIC_STORED, SLJIT_R2, SLJIT_R1, SLJIT_R0); sljit_set_label(sljit_emit_jump(compiler, SLJIT_ATOMIC_NOT_STORED), label); + sljit_set_label(jump, sljit_emit_label(compiler)); - sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_R1, 0, SLJIT_S0, 0, SLJIT_IMM, 30 * sizeof(sljit_sw) + 2); + sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_R1, 0, SLJIT_S0, 0, SLJIT_IMM, 11 * sizeof(sljit_sw) + 2); label = sljit_emit_label(compiler); sljit_emit_atomic_load(compiler, SLJIT_MOV_U16, SLJIT_R0, SLJIT_R1); - /* buf[31] */ - sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_S0), 31 * sizeof(sljit_sw), SLJIT_R0, 0); + sljit_emit_op1(compiler, SLJIT_MOV_U16, SLJIT_S1, 0, SLJIT_MEM1(SLJIT_R1), 0); + jump = sljit_emit_cmp(compiler, SLJIT_NOT_EQUAL, SLJIT_R0, 0, SLJIT_S1, 0); sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_R2, 0, SLJIT_IMM, 51403); - /* buf[30] */ + /* buf[11] */ sljit_emit_atomic_store(compiler, SLJIT_MOV_U16 | SLJIT_SET_ATOMIC_STORED, SLJIT_R2, SLJIT_R1, SLJIT_R0); sljit_set_label(sljit_emit_jump(compiler, SLJIT_ATOMIC_NOT_STORED), label); + sljit_set_label(jump, sljit_emit_label(compiler)); sljit_emit_return_void(compiler); - code.code = sljit_generate_code(compiler); CHECK(compiler); sljit_free_compiler(compiler); code.func1((sljit_sw)&buf); + FAILED(buf[0] != -9856, "test92 case 1 failed\n"); - FAILED(buf[1] != -4678, "test92 case 2 failed\n"); - FAILED(*(sljit_u8*)(buf + 2) != 203, "test92 case 3 failed\n"); - FAILED(((sljit_u8*)(buf + 2))[1] != 0xff, "test92 case 4 failed\n"); - FAILED(buf[3] != 178, "test92 case 5 failed\n"); - FAILED(buf[4] != 203, "test92 case 6 failed\n"); - FAILED(*(sljit_u8*)(buf + 5) != 97, "test92 case 7 failed\n"); - FAILED(((sljit_u8*)(buf + 5))[1] != 0xff, "test92 case 8 failed\n"); - FAILED(*(sljit_u32*)(buf + 6) != 211, "test92 case 9 failed\n"); - FAILED(buf[7] != (sljit_sw)(buf + 5), "test92 case 10 failed\n"); - FAILED(buf[8] != 97, "test92 case 11 failed\n"); - FAILED(*(sljit_u16*)(buf + 9) != (sljit_u16)(sljit_sw)(buf + 9), "test92 case 12 failed\n"); - FAILED(((sljit_u8*)(buf + 9))[2] != 0xff, "test92 case 13 failed\n"); - FAILED(buf[10] != 17897, "test92 case 14 failed\n"); - FAILED(buf[11] != (sljit_sw)(buf + 9), "test92 case 15 failed\n"); - FAILED(*(sljit_u16*)(buf + 12) != 41306, "test92 case 16 failed\n"); - FAILED(((sljit_u8*)(buf + 12))[2] != 0xff, "test92 case 17 failed\n"); - FAILED(*(sljit_u32*)(buf + 13) != 57812, "test92 case 18 failed\n"); - FAILED(buf[14] != 41306, "test92 case 19 failed\n"); - FAILED(*(sljit_u32*)(buf + 15) != 987654321, "test92 case 20 failed\n"); + FAILED(*(sljit_u8 *)(buf + 1) != 203 || *((sljit_u8 *)(buf + 1) + 1) != 0xff, "test92 case 2 failed\n"); + FAILED(*(sljit_u8 *)(buf + 2) != 97 || *((sljit_u8 *)(buf + 2) + 1) != 0xff, "test92 case 3 failed\n"); + FAILED(*(sljit_u16 *)(buf + 3) != (sljit_u16)(sljit_sw)(buf + 3) || *((sljit_u16 *)(buf + 3) + 1) != 0xffff, "test92 case 4 failed\n"); + FAILED(*(sljit_u16 *)(buf + 4) != 41306 || ((sljit_u8 *)(buf + 4))[2] != 0xff, "test92 case 5 failed\n"); + FAILED(*(sljit_u32 *)(buf + 5) != 987654321, "test92 case 6 failed\n"); #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE) - FAILED(((sljit_u8*)(buf + 15))[4] != 0xff, "test92 case 21 failed\n"); + FAILED(((sljit_u8 *)(buf + 5))[4] != 0xff, "test92 case 6 failed\n"); #endif /* SLJIT_64BIT_ARCHITECTURE */ - FAILED(buf[16] != 1234567890, "test92 case 22 failed\n"); - FAILED(*(sljit_u32*)(buf + 17) != 678906789, "test92 case 23 failed\n"); + FAILED(*(sljit_u32 *)(buf + 6) != 678906789, "test92 case 7 failed\n"); #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE) - FAILED(((sljit_u8*)(buf + 17))[4] != 0xff, "test92 case 24 failed\n"); + FAILED(((sljit_u8 *)(buf + 6))[4] != 0xff, "test92 case 7 failed\n"); #endif /* SLJIT_64BIT_ARCHITECTURE */ - FAILED(*(sljit_u32*)(buf + 18) != 987609876, "test92 case 25 failed\n"); - FAILED(buf[19] != -573621, "test92 case 26 failed\n"); - FAILED(*(sljit_u8*)(buf + 20) != 240, "test92 case 27 failed\n"); - FAILED(((sljit_u8*)(buf + 20))[1] != 0xff, "test92 case 28 failed\n"); - FAILED(buf[21] != 192, "test92 case 29 failed\n"); - FAILED(buf[22] != -5893, "test92 case 30 failed\n"); - FAILED(buf[23] != 4059, "test92 case 31 failed\n"); - FAILED(buf[24] != 6359, "test92 case 32 failed\n"); - FAILED(buf[25] != (sljit_sw)(buf + 23), "test92 case 33 failed\n"); - FAILED(((sljit_u8*)(buf + 26))[0] != 255, "test92 case 34 failed\n"); - FAILED(((sljit_u8*)(buf + 26))[1] != 204, "test92 case 35 failed\n"); - FAILED(((sljit_u8*)(buf + 26))[2] != 255, "test92 case 36 failed\n"); - FAILED(buf[27] != 105, "test92 case 37 failed\n"); - FAILED(((sljit_u8*)(buf + 28))[1] != 255, "test92 case 38 failed\n"); - FAILED(((sljit_u8*)(buf + 28))[2] != 240, "test92 case 39 failed\n"); - FAILED(((sljit_u8*)(buf + 28))[3] != 255, "test92 case 40 failed\n"); - FAILED(buf[29] != 13, "test92 case 41 failed\n"); - FAILED(((sljit_u16*)(buf + 30))[0] != 65535, "test92 case 42 failed\n"); - FAILED(((sljit_u16*)(buf + 30))[1] != 51403, "test92 case 43 failed\n"); - FAILED(buf[31] != 14876, "test92 case 44 failed\n"); + FAILED(*(sljit_u8*)(buf + 7) != 240 || *((sljit_u8 *)(buf + 7) + 1) != 0xff, "test92 case 8 failed\n"); + FAILED(buf[8] != 4059, "test92 case 9 failed\n"); + FAILED(((sljit_u8*)(buf + 9))[0] != 0xff, "test92 case 10 failed\n"); + FAILED(((sljit_u8*)(buf + 9))[1] != 204, "test92 case 10 failed\n"); + FAILED(((sljit_u8*)(buf + 9))[2] != 0xff, "test92 case 10 failed\n"); + FAILED(((sljit_u8*)(buf + 10))[1] != 0xff, "test92 case 11 failed\n"); + FAILED(((sljit_u8*)(buf + 10))[2] != 240, "test92 case 11 failed\n"); + FAILED(((sljit_u8*)(buf + 10))[3] != 0xff, "test92 case 11 failed\n"); + FAILED(((sljit_u16*)(buf + 11))[0] != 0xffff, "test92 case 12 failed\n"); + FAILED(((sljit_u16*)(buf + 11))[1] != 51403, "test92 case 12 failed\n"); sljit_free_code(code.code, NULL); #endif