[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 313/437: Implement the jit_align interface
From: |
Andy Wingo |
Subject: |
[Guile-commits] 313/437: Implement the jit_align interface |
Date: |
Mon, 2 Jul 2018 05:14:43 -0400 (EDT) |
wingo pushed a commit to branch lightning
in repository guile.
commit afae5407f67646254c868a9fde6da97609d5f69d
Author: pcpa <address@hidden>
Date: Tue Oct 14 17:05:25 2014 -0300
Implement the jit_align interface
* lib/jit_aarch64-cpu.c, lib/jit_alpha-cpu.c, lib/jit_arm-cpu.c,
lib/jit_hppa-cpu.c, lib/jit_mips-cpu.c, lib/jit_ppc-cpu.c,
lib/jit_sparc-cpu.c: Implement or correct the internal
nop(count) call that receives an argument that tells the
modulo bytes to align the code for the next instruction.
* include/lightning.h, lib/lightning.c, lib/jit_aarch64.c,
lib/jit_alpha.c, lib/jit_arm.c, lib/jit_hppa.c, lib/jit_ia64.c,
lib/jit_mips.c, lib/jit_ppc.c, lib/jit_s390x.c, lib/jit_sparc.c,
lib/jit_x86.c: Implement the new jit_align() call that receive
an argument, that tells the modulo, in bytes, to align the
next instruction. In most backends the only value that makes
a difference is a value that matches sizeof(void*), as all
other values usually are already automatically aligned in
labels, but not guaranteed to be aligned at word size bytes.
* check/align.ok, check/align.tst: New files, implementing
a simple test for the new jit_align() interface.
* check/Makefile.am, check/lightning.c, lib/jit_aarch64-sz.c,
lib/jit_alpha-sz.c, lib/jit_arm-sz.c, lib/jit_hppa-sz.c,
lib/jit_ia64-sz.c, lib/jit_mips-sz.c, lib/jit_ppc-sz.c,
lib/jit_print.c, lib/jit_s390x-sz.c, lib/jit_sparc-sz.c,
lib/jit_x86-sz.c: Update for the new jit_code_align code and
the jit_align() interface.
---
ChangeLog | 28 ++++++++++++++++++++++++++++
check/Makefile.am | 5 +++--
check/lightning.c | 5 +++--
include/lightning.h | 3 ++-
lib/jit_aarch64-cpu.c | 11 +++++++++++
lib/jit_aarch64-sz.c | 1 +
lib/jit_aarch64.c | 7 +++++++
lib/jit_alpha-cpu.c | 10 ++++++++++
lib/jit_alpha-sz.c | 1 +
lib/jit_alpha.c | 7 +++++++
lib/jit_arm-cpu.c | 6 +++---
lib/jit_arm-sz.c | 2 ++
lib/jit_arm.c | 7 +++++++
lib/jit_hppa-cpu.c | 10 ++++++++++
lib/jit_hppa-sz.c | 1 +
lib/jit_hppa.c | 7 +++++++
lib/jit_ia64-sz.c | 1 +
lib/jit_ia64.c | 5 +++++
lib/jit_mips-cpu.c | 8 +++++---
lib/jit_mips-sz.c | 3 +++
lib/jit_mips.c | 7 +++++++
lib/jit_ppc-cpu.c | 10 ++++++++++
lib/jit_ppc-sz.c | 3 +++
lib/jit_ppc.c | 7 +++++++
lib/jit_print.c | 2 +-
lib/jit_s390x-sz.c | 1 +
lib/jit_s390x.c | 10 +++++++++-
lib/jit_sparc-cpu.c | 3 ++-
lib/jit_sparc-sz.c | 1 +
lib/jit_sparc.c | 9 ++++++++-
lib/jit_x86-sz.c | 2 ++
lib/jit_x86.c | 8 +++++++-
lib/lightning.c | 9 +++++----
33 files changed, 180 insertions(+), 20 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 35e26a1..cba8922 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,31 @@
+2014-10-14 Paulo Andrade <address@hidden>
+
+ * lib/jit_aarch64-cpu.c, lib/jit_alpha-cpu.c, lib/jit_arm-cpu.c,
+ lib/jit_hppa-cpu.c, lib/jit_mips-cpu.c, lib/jit_ppc-cpu.c,
+ lib/jit_sparc-cpu.c: Implement or correct the internal
+ nop(count) call that receives an argument that tells the
+ modulo bytes to align the code for the next instruction.
+
+ * include/lightning.h, lib/lightning.c, lib/jit_aarch64.c,
+ lib/jit_alpha.c, lib/jit_arm.c, lib/jit_hppa.c, lib/jit_ia64.c,
+ lib/jit_mips.c, lib/jit_ppc.c, lib/jit_s390x.c, lib/jit_sparc.c,
+ lib/jit_x86.c: Implement the new jit_align() call that receive
+ an argument, that tells the modulo, in bytes, to align the
+ next instruction. In most backends the only value that makes
+ a difference is a value that matches sizeof(void*), as all
+ other values usually are already automatically aligned in
+ labels, but not guaranteed to be aligned at word size bytes.
+
+ * check/align.ok, check/align.tst: New files, implementing
+ a simple test for the new jit_align() interface.
+
+ * check/Makefile.am, check/lightning.c, lib/jit_aarch64-sz.c,
+ lib/jit_alpha-sz.c, lib/jit_arm-sz.c, lib/jit_hppa-sz.c,
+ lib/jit_ia64-sz.c, lib/jit_mips-sz.c, lib/jit_ppc-sz.c,
+ lib/jit_print.c, lib/jit_s390x-sz.c, lib/jit_sparc-sz.c,
+ lib/jit_x86-sz.c: Update for the new jit_code_align code and
+ the jit_align() interface.
+
2014-10-13 Paulo Andrade <address@hidden>
* include/lightning.h, lib/jit_size.c, size.c: Use a
diff --git a/check/Makefile.am b/check/Makefile.am
index c65622b..5e0b21b 100644
--- a/check/Makefile.am
+++ b/check/Makefile.am
@@ -39,6 +39,7 @@ $(top_builddir)/lib/liblightning.la:
EXTRA_DIST = \
3to2.tst 3to2.ok \
add.tst add.ok \
+ align.tst align.ok \
allocai.tst allocai.ok \
bp.tst bp.ok \
divi.tst divi.ok \
@@ -91,7 +92,7 @@ EXTRA_DIST = \
run-test all.tst
base_TESTS = \
- 3to2 add allocai \
+ 3to2 add align allocai \
bp divi fib rpn \
ldstr ldsti \
ldstxr ldstxi \
@@ -164,7 +165,7 @@ endif
if test_arm_arm
#arm_TESTS = $(addsuffix .arm, $(base_TESTS))
arm_TESTS = \
- 3to2.arm add.arm allocai.arm \
+ 3to2.arm add.arm align.arm allocai.arm \
bp.arm divi.arm fib.arm rpn.arm \
ldstr.arm ldsti.arm \
ldstxr.arm ldstxi.arm \
diff --git a/check/lightning.c b/check/lightning.c
index 60b75bc..cf08dea 100644
--- a/check/lightning.c
+++ b/check/lightning.c
@@ -267,7 +267,7 @@ static void call_forward(void *value, label_t *label);
static void make_arg(void *value);
static jit_pointer_t get_arg(void);
static long get_imm(void);
-static void name(void);
+static void align(void); static void name(void);
static void prolog(void);
static void frame(void); static void tramp(void);
static void ellipsis(void);
@@ -567,7 +567,7 @@ static char *data;
static size_t data_offset, data_length;
static instr_t instr_vector[] = {
#define entry(value) { NULL, #value, value }
- entry(name),
+ entry(align), entry(name),
entry(prolog),
entry(frame), entry(tramp),
entry(ellipsis),
@@ -1324,6 +1324,7 @@ name(void) {
(void)identifier(ch);
jit_name(parser.string);
}
+entry_im(align)
entry(prolog)
entry_im(frame) entry_im(tramp)
entry(ellipsis)
diff --git a/include/lightning.h b/include/lightning.h
index 0179919..2e87905 100644
--- a/include/lightning.h
+++ b/include/lightning.h
@@ -177,7 +177,8 @@ typedef enum {
#define jit_data(u,v,w) _jit_data(_jit,u,v,w)
jit_code_data,
#define jit_live(u) jit_new_node_w(jit_code_live, u)
- jit_code_live,
+#define jit_align(u) jit_new_node_w(jit_code_align, u)
+ jit_code_live, jit_code_align,
jit_code_save, jit_code_load,
#define jit_name(u) _jit_name(_jit,u)
jit_code_name,
diff --git a/lib/jit_aarch64-cpu.c b/lib/jit_aarch64-cpu.c
index a2d2ce0..fd25f7f 100644
--- a/lib/jit_aarch64-cpu.c
+++ b/lib/jit_aarch64-cpu.c
@@ -467,6 +467,7 @@ typedef union {
# define B_C(Cc,Simm19) oc19(A64_B_C,Cc,Simm19)
# define CBZ(Rd,Simm19) ox19(A64_CBZ|XS,Rd,Simm19)
# define CBNZ(Rd,Simm19) ox19(A64_CBNZ|XS,Rd,Simm19)
+# define NOP() ii(0xd503201f)
static jit_int32_t logical_immediate(jit_word_t);
# define oxxx(Op,Rd,Rn,Rm) _oxxx(_jit,Op,Rd,Rn,Rm)
static void
_oxxx(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t,jit_int32_t);
@@ -499,6 +500,8 @@ static void _oxxxc(jit_state_t*,jit_int32_t,jit_int32_t,
# define oxxx7(Op,Rt,Rt2,Rn,Simm7) _oxxx7(_jit,Op,Rt,Rt2,Rn,Simm7)
static void _oxxx7(jit_state_t*,jit_int32_t,
jit_int32_t,jit_int32_t,jit_int32_t,jit_int32_t);
+# define nop(i0) _nop(_jit,i0)
+static void _nop(jit_state_t*,jit_int32_t);
# define addr(r0,r1,r2) ADD(r0,r1,r2)
# define addi(r0,r1,i0) _addi(_jit,r0,r1,i0)
static void _addi(jit_state_t*,jit_int32_t,jit_int32_t,jit_word_t);
@@ -1011,6 +1014,14 @@ _oxxx7(jit_state_t *_jit, jit_int32_t Op,
}
static void
+_nop(jit_state_t *_jit, jit_int32_t i0)
+{
+ for (; i0 > 0; i0 -= 4)
+ NOP();
+ assert(i0 == 0);
+}
+
+static void
_addi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
{
jit_int32_t reg;
diff --git a/lib/jit_aarch64-sz.c b/lib/jit_aarch64-sz.c
index 58efa4e..01b18f2 100644
--- a/lib/jit_aarch64-sz.c
+++ b/lib/jit_aarch64-sz.c
@@ -8,6 +8,7 @@
0,
0,
0,
+ 0,
64,
0,
4,
diff --git a/lib/jit_aarch64.c b/lib/jit_aarch64.c
index 94c52b7..6de141c 100644
--- a/lib/jit_aarch64.c
+++ b/lib/jit_aarch64.c
@@ -717,6 +717,13 @@ _emit_code(jit_state_t *_jit)
value = jit_classify(node->code);
jit_regarg_set(node, value);
switch (node->code) {
+ case jit_code_align:
+ assert(!(node->u.w & (node->u.w - 1)) &&
+ node->u.w <= sizeof(jit_word_t));
+ if (node->u.w == sizeof(jit_word_t) &&
+ (word = _jit->pc.w & (sizeof(jit_word_t) - 1)))
+ nop(sizeof(jit_word_t) - word);
+ break;
case jit_code_note: case jit_code_name:
node->u.w = _jit->pc.w;
break;
diff --git a/lib/jit_alpha-cpu.c b/lib/jit_alpha-cpu.c
index 8fe4338..8787b0f 100644
--- a/lib/jit_alpha-cpu.c
+++ b/lib/jit_alpha-cpu.c
@@ -303,6 +303,8 @@ static void _Opi(jit_state_t*,int,int,unsigned int,unsigned
int,int);
# define NEGL(ra,rc) SUBL(_R31_REGNO,ra,rc)
# define NEGQ(ra,rc) SUBQ(_R31_REGNO,ra,rc)
# define NOT(ra,rc) ORNOT(_R31_REGNO,ra,rc)
+# define nop(i0) _nop(_jit,i0)
+static void _nop(jit_state_t*,jit_int32_t);
# define movr(r0,r1) _movr(_jit,r0,r1)
static void _movr(jit_state_t*,jit_int32_t,jit_int32_t);
# define movi(r0,i0) _movi(_jit,r0,i0)
@@ -704,6 +706,14 @@ _Opi(jit_state_t *_jit, int o, int ra, unsigned int i,
unsigned int f, int rc)
}
static void
+_nop(jit_state_t *_jit, jit_int32_t i0)
+{
+ for (; i0 > 0; i0 -= 4)
+ NOP();
+ assert(i0 == 0);
+}
+
+static void
_movr(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
{
if (r0 != r1)
diff --git a/lib/jit_alpha-sz.c b/lib/jit_alpha-sz.c
index b2544fe..bf914d0 100644
--- a/lib/jit_alpha-sz.c
+++ b/lib/jit_alpha-sz.c
@@ -8,6 +8,7 @@
0,
0,
0,
+ 0,
76,
0,
4,
diff --git a/lib/jit_alpha.c b/lib/jit_alpha.c
index 84b055c..6d78c70 100644
--- a/lib/jit_alpha.c
+++ b/lib/jit_alpha.c
@@ -744,6 +744,13 @@ _emit_code(jit_state_t *_jit)
value = jit_classify(node->code);
jit_regarg_set(node, value);
switch (node->code) {
+ case jit_code_align:
+ assert(!(node->u.w & (node->u.w - 1)) &&
+ node->u.w <= sizeof(jit_word_t));
+ if (node->u.w == sizeof(jit_word_t) &&
+ (word = _jit->pc.w & (sizeof(jit_word_t) - 1)))
+ nop(sizeof(jit_word_t) - word);
+ break;
case jit_code_note: case jit_code_name:
node->u.w = _jit->pc.w;
break;
diff --git a/lib/jit_arm-cpu.c b/lib/jit_arm-cpu.c
index 02edeed..3f7db05 100644
--- a/lib/jit_arm-cpu.c
+++ b/lib/jit_arm-cpu.c
@@ -833,7 +833,7 @@ static void _torl(jit_state_t*,int,int,int) maybe_unused;
jit_unget_reg(_R0); \
} while (0)
# define nop(i0) _nop(_jit,i0)
-static void _nop(jit_state_t*,jit_word_t) maybe_unused;
+static void _nop(jit_state_t*,jit_int32_t);
# define movr(r0,r1) _movr(_jit,r0,r1)
static void _movr(jit_state_t*,jit_int32_t,jit_int32_t);
# define movi(r0,i0) _movi(_jit,r0,i0)
@@ -1498,9 +1498,8 @@ _torl(jit_state_t *_jit, int o, int rn, int im)
}
static void
-_nop(jit_state_t *_jit, jit_word_t i0)
+_nop(jit_state_t *_jit, jit_int32_t i0)
{
- assert(i0 >= 0);
if (jit_thumb_p()) {
for (; i0 > 0; i0 -= 2)
T1_NOP();
@@ -1509,6 +1508,7 @@ _nop(jit_state_t *_jit, jit_word_t i0)
for (; i0 > 0; i0 -= 4)
NOP();
}
+ assert(i0 == 0);
}
static void
diff --git a/lib/jit_arm-sz.c b/lib/jit_arm-sz.c
index db7751e..a9f217b 100644
--- a/lib/jit_arm-sz.c
+++ b/lib/jit_arm-sz.c
@@ -9,6 +9,7 @@
0,
0,
0,
+ 0,
26,
0,
4,
@@ -361,6 +362,7 @@
0,
0,
0,
+ 0,
18,
0,
4,
diff --git a/lib/jit_arm.c b/lib/jit_arm.c
index 7dbf78a..179bf68 100644
--- a/lib/jit_arm.c
+++ b/lib/jit_arm.c
@@ -1043,6 +1043,13 @@ _emit_code(jit_state_t *_jit)
value = jit_classify(node->code);
jit_regarg_set(node, value);
switch (node->code) {
+ case jit_code_align:
+ assert(!(node->u.w & (node->u.w - 1)) &&
+ node->u.w <= sizeof(jit_word_t));
+ if (node->u.w == sizeof(jit_word_t) &&
+ (word = _jit->pc.w & (sizeof(jit_word_t) - 1)))
+ nop(sizeof(jit_word_t) - word);
+ break;
case jit_code_note: case jit_code_name:
if (must_align_p(node->next))
nop(2);
diff --git a/lib/jit_hppa-cpu.c b/lib/jit_hppa-cpu.c
index 479d6cf..3fec623 100644
--- a/lib/jit_hppa-cpu.c
+++ b/lib/jit_hppa-cpu.c
@@ -640,6 +640,8 @@ static void _f38(jit_state_t*,jit_int32_t,
#define UADDCM(r1,r2,t) f8(0x2,r2,r1,ADD_CF_NV,2,0,1,2,0,t)
#define UXOR(r1,r2,t) f8(0x2,r2,r1,LOG_CC_NV,0,1,1,2,0,t)
#define XOR(r1,r2,t) f8(0x2,r2,r1,LOG_CC_NV,0,1,0,2,0,t)
+# define nop(c) _nop(_jit,c)
+static void _nop(jit_state_t*,jit_int32_t);
#define movr(r0,r1) _movr(_jit,r0,r1)
static void _movr(jit_state_t*,jit_int32_t,jit_int32_t);
#define movi(r0,i0) _movi(_jit,r0,i0)
@@ -1586,6 +1588,14 @@ _f38(jit_state_t *_jit, jit_int32_t o,
}
static void
+_nop(jit_state_t *_jit, jit_int32_t i0)
+{
+ for (; i0 > 0; i0 -= 4)
+ NOP();
+ assert(i0 == 0);
+}
+
+static void
_movr(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
{
if (r0 != r1)
diff --git a/lib/jit_hppa-sz.c b/lib/jit_hppa-sz.c
index ab8c77d..f2b1918 100644
--- a/lib/jit_hppa-sz.c
+++ b/lib/jit_hppa-sz.c
@@ -8,6 +8,7 @@
0,
0,
0,
+ 0,
64,
0,
4,
diff --git a/lib/jit_hppa.c b/lib/jit_hppa.c
index 289542f..636f364 100644
--- a/lib/jit_hppa.c
+++ b/lib/jit_hppa.c
@@ -722,6 +722,13 @@ _emit_code(jit_state_t *_jit)
value = jit_classify(node->code);
jit_regarg_set(node, value);
switch (node->code) {
+ case jit_code_align:
+ assert(!(node->u.w & (node->u.w - 1)) &&
+ node->u.w <= sizeof(jit_word_t));
+ if (node->u.w == sizeof(jit_word_t) &&
+ (word = _jit->pc.w & (sizeof(jit_word_t) - 1)))
+ nop(sizeof(jit_word_t) - word);
+ break;
case jit_code_note: case jit_code_name:
node->u.w = _jit->pc.w;
break;
diff --git a/lib/jit_ia64-sz.c b/lib/jit_ia64-sz.c
index 1185ada..5d88500 100644
--- a/lib/jit_ia64-sz.c
+++ b/lib/jit_ia64-sz.c
@@ -5,6 +5,7 @@
0,
0,
0,
+ 0,
16,
16,
48,
diff --git a/lib/jit_ia64.c b/lib/jit_ia64.c
index 0a9eccd..e8eee8a 100644
--- a/lib/jit_ia64.c
+++ b/lib/jit_ia64.c
@@ -859,6 +859,11 @@ _emit_code(jit_state_t *_jit)
#endif
jit_regarg_set(node, value);
switch (node->code) {
+ case jit_code_align:
+ assert(!(node->u.w & (node->u.w - 1)) &&
+ node->u.w <= sizeof(jit_word_t));
+ /* nothing done */
+ break;
case jit_code_note: case jit_code_name:
sync();
node->u.w = _jit->pc.w;
diff --git a/lib/jit_mips-cpu.c b/lib/jit_mips-cpu.c
index 8976b31..9e9778f 100644
--- a/lib/jit_mips-cpu.c
+++ b/lib/jit_mips-cpu.c
@@ -303,7 +303,8 @@
_hrrrit(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t,jit_int32_t,
static void
_hrri(jit_state_t*,jit_int32_t,jit_int32_t,jit_int32_t,jit_int32_t);
# define hi(hc,im) _hi(_jit,hc,im)
static void _hi(jit_state_t*,jit_int32_t,jit_int32_t);
-# define NOP(i0) _nop(_jit,i0)
+# define NOP(i0) ii(0)
+# define nop(i0) _nop(_jit,i0)
static void _nop(jit_state_t*,jit_int32_t);
# define h_ri(hc,rt,im) _hrri(_jit,hc,0,rt,im)
# define rrit(rt,rd,im,tc) _hrrrit(_jit,0,0,rt,rd,im,tc)
@@ -769,8 +770,9 @@ _hi(jit_state_t *_jit, jit_int32_t hc, jit_int32_t im)
static void
_nop(jit_state_t *_jit, jit_int32_t i0)
{
- while (i0--)
- ii(0);
+ for (; i0 > 0; i0 -= 4)
+ NOP();
+ assert(i0 == 0);
}
static void
diff --git a/lib/jit_mips-sz.c b/lib/jit_mips-sz.c
index 69f6dcf..9b5b57b 100644
--- a/lib/jit_mips-sz.c
+++ b/lib/jit_mips-sz.c
@@ -9,6 +9,7 @@
0,
0,
0,
+ 0,
44,
0,
4,
@@ -361,6 +362,7 @@
0,
0,
0,
+ 0,
96,
0,
4,
@@ -712,6 +714,7 @@
0,
0,
0,
+ 0,
44,
0,
4,
diff --git a/lib/jit_mips.c b/lib/jit_mips.c
index 3eec489..c31d43b 100644
--- a/lib/jit_mips.c
+++ b/lib/jit_mips.c
@@ -978,6 +978,13 @@ _emit_code(jit_state_t *_jit)
value = jit_classify(node->code);
jit_regarg_set(node, value);
switch (node->code) {
+ case jit_code_align:
+ assert(!(node->u.w & (node->u.w - 1)) &&
+ node->u.w <= sizeof(jit_word_t));
+ if (node->u.w == sizeof(jit_word_t) &&
+ (word = _jit->pc.w & (sizeof(jit_word_t) - 1)))
+ nop(sizeof(jit_word_t) - word);
+ break;
case jit_code_note: case jit_code_name:
node->u.w = _jit->pc.w;
break;
diff --git a/lib/jit_ppc-cpu.c b/lib/jit_ppc-cpu.c
index ed93065..844c8b1 100644
--- a/lib/jit_ppc-cpu.c
+++ b/lib/jit_ppc-cpu.c
@@ -451,6 +451,8 @@ static void _FXS(jit_state_t*,int,int,int,int,int,int,int);
# define XOR_(d,a,b) FXO_(31,a,d,b,0,316)
# define XORI(s,a,u) FDu(26,s,a,u)
# define XORIS(s,a,u) FDu(27,s,a,u)
+# define nop(c) _nop(_jit,c)
+static void _nop(jit_state_t*,jit_int32_t);
# define movr(r0,r1) _movr(_jit,r0,r1)
static void _movr(jit_state_t*,jit_int32_t,jit_int32_t);
# define movi(r0,i0) _movi(_jit,r0,i0)
@@ -977,6 +979,14 @@ _FXS(jit_state_t *_jit, int o, int s, int a, int h, int x,
int i, int r)
#endif
static void
+_nop(jit_state_t *_jit, jit_int32_t i0)
+{
+ for (; i0 > 0; i0 -= 4)
+ NOP();
+ assert(i0 == 0);
+}
+
+static void
_movr(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
{
if (r0 != r1)
diff --git a/lib/jit_ppc-sz.c b/lib/jit_ppc-sz.c
index e0c53b9..6025ffc 100644
--- a/lib/jit_ppc-sz.c
+++ b/lib/jit_ppc-sz.c
@@ -9,6 +9,7 @@
0,
0,
0,
+ 0,
44,
0,
4,
@@ -361,6 +362,7 @@
0,
0,
0,
+ 0,
72,
0,
4,
@@ -713,6 +715,7 @@
0,
0,
0,
+ 0,
72,
0,
4,
diff --git a/lib/jit_ppc.c b/lib/jit_ppc.c
index 08da19f..88488f0 100644
--- a/lib/jit_ppc.c
+++ b/lib/jit_ppc.c
@@ -875,6 +875,13 @@ _emit_code(jit_state_t *_jit)
value = jit_classify(node->code);
jit_regarg_set(node, value);
switch (node->code) {
+ case jit_code_align:
+ assert(!(node->u.w & (node->u.w - 1)) &&
+ node->u.w <= sizeof(jit_word_t));
+ if (node->u.w == sizeof(jit_word_t) &&
+ (word = _jit->pc.w & (sizeof(jit_word_t) - 1)))
+ nop(sizeof(jit_word_t) - word);
+ break;
case jit_code_note: case jit_code_name:
node->u.w = _jit->pc.w;
break;
diff --git a/lib/jit_print.c b/lib/jit_print.c
index 17d2559..49a5536 100644
--- a/lib/jit_print.c
+++ b/lib/jit_print.c
@@ -38,7 +38,7 @@
*/
static char *code_name[] = {
"data",
- "live",
+ "live", "align",
"save", "load",
"#name", "#note",
"label",
diff --git a/lib/jit_s390x-sz.c b/lib/jit_s390x-sz.c
index e7b8ea2..d3df0c6 100644
--- a/lib/jit_s390x-sz.c
+++ b/lib/jit_s390x-sz.c
@@ -7,6 +7,7 @@
0,
0,
0,
+ 0,
2,
38,
0,
diff --git a/lib/jit_s390x.c b/lib/jit_s390x.c
index 99802a5..4c45db0 100644
--- a/lib/jit_s390x.c
+++ b/lib/jit_s390x.c
@@ -697,11 +697,19 @@ _emit_code(jit_state_t *_jit)
value = jit_classify(node->code);
jit_regarg_set(node, value);
switch (node->code) {
+ case jit_code_align:
+ assert(!(node->u.w & (node->u.w - 1)) &&
+ node->u.w <= sizeof(jit_word_t));
+ if (node->u.w == sizeof(jit_word_t) &&
+ (word = _jit->pc.w & (sizeof(jit_word_t) - 1)))
+ nop(sizeof(jit_word_t) - word);
+ break;
case jit_code_note: case jit_code_name:
node->u.w = _jit->pc.w;
break;
case jit_code_label:
- if (node->link && (word = _jit->pc.w & 3))
+ if ((node->link || (node->flag & jit_flag_use)) &&
+ (word = _jit->pc.w & 3))
nop(4 - word);
/* remember label is defined */
node->flag |= jit_flag_patch;
diff --git a/lib/jit_sparc-cpu.c b/lib/jit_sparc-cpu.c
index ba56c61..095c364 100644
--- a/lib/jit_sparc-cpu.c
+++ b/lib/jit_sparc-cpu.c
@@ -809,8 +809,9 @@ _f1(jit_state_t *_jit, jit_int32_t op, jit_int32_t disp30)
static void
_nop(jit_state_t *_jit, jit_int32_t i0)
{
- while (i0--)
+ for (; i0 > 0; i0 -= 4)
NOP();
+ assert(i0 == 0);
}
static void
diff --git a/lib/jit_sparc-sz.c b/lib/jit_sparc-sz.c
index 6056af2..730a16a 100644
--- a/lib/jit_sparc-sz.c
+++ b/lib/jit_sparc-sz.c
@@ -8,6 +8,7 @@
0,
0,
0,
+ 0,
16,
0,
4,
diff --git a/lib/jit_sparc.c b/lib/jit_sparc.c
index 81a9f5c..a8488e2 100644
--- a/lib/jit_sparc.c
+++ b/lib/jit_sparc.c
@@ -715,11 +715,18 @@ _emit_code(jit_state_t *_jit)
value = jit_classify(node->code);
jit_regarg_set(node, value);
switch (node->code) {
+ case jit_code_align:
+ assert(!(node->u.w & (node->u.w - 1)) &&
+ node->u.w <= sizeof(jit_word_t));
+ if (node->u.w == sizeof(jit_word_t) &&
+ (word = _jit->pc.w & (sizeof(jit_word_t) - 1)))
+ nop(sizeof(jit_word_t) - word);
+ break;
case jit_code_note: case jit_code_name:
node->u.w = _jit->pc.w;
break;
case jit_code_label:
- if (node->link &&
+ if ((node->link || (node->flag & jit_flag_use)) &&
(word = _jit->pc.w & (sizeof(jit_word_t) - 1)))
nop(sizeof(jit_word_t) - word);
/* remember label is defined */
diff --git a/lib/jit_x86-sz.c b/lib/jit_x86-sz.c
index b8c9af3..52101e4 100644
--- a/lib/jit_x86-sz.c
+++ b/lib/jit_x86-sz.c
@@ -7,6 +7,7 @@
0,
0,
0,
+ 0,
3,
26,
0,
@@ -707,6 +708,7 @@
0,
0,
0,
+ 0,
7,
43,
0,
diff --git a/lib/jit_x86.c b/lib/jit_x86.c
index 747741d..20dcc21 100644
--- a/lib/jit_x86.c
+++ b/lib/jit_x86.c
@@ -1268,11 +1268,17 @@ _emit_code(jit_state_t *_jit)
value = jit_classify(node->code);
jit_regarg_set(node, value);
switch (node->code) {
+ case jit_code_align:
+ assert(!(node->u.w & (node->u.w - 1)) &&
+ node->u.w <= sizeof(jit_word_t));
+ if ((word = _jit->pc.w & (node->u.w - 1)))
+ nop(node->u.w - word);
+ break;
case jit_code_note: case jit_code_name:
node->u.w = _jit->pc.w;
break;
case jit_code_label:
- if (node->link &&
+ if ((node->link || (node->flag & jit_flag_use)) &&
(word = _jit->pc.w & (sizeof(jit_word_t) - 1)))
nop(sizeof(jit_word_t) - word);
/* remember label is defined */
diff --git a/lib/lightning.c b/lib/lightning.c
index 42c3a45..9ee261d 100644
--- a/lib/lightning.c
+++ b/lib/lightning.c
@@ -1177,9 +1177,9 @@ _jit_classify(jit_state_t *_jit, jit_code_t code)
jit_int32_t mask;
switch (code) {
- case jit_code_data: case jit_code_save: case jit_code_load:
- case jit_code_name: case jit_code_label: case jit_code_note:
- case jit_code_prolog: case jit_code_epilog:
+ case jit_code_data: case jit_code_align: case jit_code_save:
+ case jit_code_load: case jit_code_name: case jit_code_label:
+ case jit_code_note: case jit_code_prolog: case jit_code_epilog:
mask = 0;
break;
case jit_code_live:
@@ -2395,7 +2395,8 @@ _redundant_jump(jit_state_t *_jit, jit_node_t *prev,
jit_node_t *node)
return (1);
}
break;
- case jit_code_note:
+ case jit_code_name: case jit_code_note:
+ case jit_code_align:
break;
default:
return (0);
- [Guile-commits] 266/437: Add assertion to detect double patching., (continued)
- [Guile-commits] 266/437: Add assertion to detect double patching., Andy Wingo, 2018/07/02
- [Guile-commits] 199/437: Correct wrong shift value for 32 bit, Andy Wingo, 2018/07/02
- [Guile-commits] 294/437: Correct change of possibly wrong bitmask in jit_update, Andy Wingo, 2018/07/02
- [Guile-commits] 291/437: MIPS: Correct use of wrong test register, Andy Wingo, 2018/07/02
- [Guile-commits] 303/437: Only mark callee save regs as live on jumps that cannot be tracked., Andy Wingo, 2018/07/02
- [Guile-commits] 218/437: Build and pass all test cases on a multiprocessor HP-UX., Andy Wingo, 2018/07/02
- [Guile-commits] 285/437: GNU lightning 2.0.4 release, Andy Wingo, 2018/07/02
- [Guile-commits] 193/437: Make code and data buffer readonly., Andy Wingo, 2018/07/02
- [Guile-commits] 145/437: Add new test case for int/float to/from conversion., Andy Wingo, 2018/07/02
- [Guile-commits] 308/437: x86: Update instruction size information for Windows x64, Andy Wingo, 2018/07/02
- [Guile-commits] 313/437: Implement the jit_align interface,
Andy Wingo <=
- [Guile-commits] 250/437: Add the new jit_pointer_p predicate interface., Andy Wingo, 2018/07/02
- [Guile-commits] 286/437: Do not export private definitions and types., Andy Wingo, 2018/07/02
- [Guile-commits] 147/437: Correct test cases in the mips backend., Andy Wingo, 2018/07/02
- [Guile-commits] 292/437: AARCH64: Correct assertion test, Andy Wingo, 2018/07/02
- [Guile-commits] 305/437: Consider all callee_save_p regs as live on non trackable jumps, Andy Wingo, 2018/07/02
- [Guile-commits] 40/437: checkin rewrite of i386 assembler, Andy Wingo, 2018/07/02
- [Guile-commits] 295/437: Always mark return registers as live in epilog, Andy Wingo, 2018/07/02
- [Guile-commits] 326/437: Actually install the pkgconfig file., Andy Wingo, 2018/07/02
- [Guile-commits] 325/437: misc: Create a pkg-config file, Andy Wingo, 2018/07/02
- [Guile-commits] 335/437: PPC: Add initial powerpc le support., Andy Wingo, 2018/07/02