Skip to content

Commit

Permalink
Merge remote-tracking branch 'raptorjit/master' into auditlog
Browse files Browse the repository at this point in the history
  • Loading branch information
lukego committed Jan 31, 2018
2 parents e74afb9 + 7484d99 commit 389cc39
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion doc/ext_ffi_semantics.html
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ <h2 id="param">Parameterized Types</h2>
<p>
The main use for parameterized types are libraries implementing abstract
data types
(<a href="http://www.freelists.org/post/luajit/ffi-type-of-pointer-to,8"><span class="ext">&raquo;</span>&nbsp;example</a>),
(<a href="https://www.freelists.org/post/luajit/ffi-type-of-pointer-to,8">example</a>),
similar to what can be achieved with C++ template metaprogramming.
Another use case are derived types of anonymous structs, which avoids
pollution of the global struct namespace.
Expand Down
3 changes: 2 additions & 1 deletion dynasm/dasm_x86.h
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,8 @@ int dasm_encode(Dst_DECL, void *buffer)
}
case DASM_REL_LG: p++; if (n >= 0) goto rel_pc;
b++; n = (int)(ptrdiff_t)D->globals[-n];
case DASM_REL_A: rel_a: n -= (int)(ptrdiff_t)(cp+4); goto wd; /* !x64 */
case DASM_REL_A: rel_a:
n -= (unsigned int)(ptrdiff_t)(cp+4); goto wd; /* !x64 */
case DASM_REL_PC: rel_pc: {
int shrink = *b++;
int *pb = DASM_POS2PTR(D, n); if (*pb < 0) { n = pb[1]; goto rel_a; }
Expand Down
2 changes: 1 addition & 1 deletion src/jit/bcsave.lua
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ typedef struct {
o.sect[2].size = fofs(ofs)
o.sect[3].type = f32(3) -- .strtab
o.sect[3].ofs = fofs(sofs + ofs)
o.sect[3].size = fofs(#symname+1)
o.sect[3].size = fofs(#symname+2)
ffi.copy(o.space+ofs+1, symname)
ofs = ofs + #symname + 2
o.sect[4].type = f32(1) -- .rodata
Expand Down
9 changes: 5 additions & 4 deletions src/lj_asm.c
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ static uint32_t ir_khash(IRIns *ir)
} else {
lua_assert(irt_isgcv(ir->t));
lo = u32ptr(ir_kgc(ir));
hi = lo + HASH_BIAS;
hi = (uint32_t)(u64ptr(ir_kgc(ir)) >> 32) | (irt_toitype(ir->t) << 15);
}
return hashrot(lo, hi);
}
Expand Down Expand Up @@ -989,15 +989,15 @@ static void asm_bufput(ASMState *as, IRIns *ir)
const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_buf_putstr];
IRRef args[3];
IRIns *irs;
int kchar = -1;
int kchar = -129;
args[0] = ir->op1; /* SBuf * */
args[1] = ir->op2; /* GCstr * */
irs = IR(ir->op2);
lua_assert(irt_isstr(irs->t));
if (irs->o == IR_KGC) {
GCstr *s = ir_kstr(irs);
if (s->len == 1) { /* Optimize put of single-char string constant. */
kchar = strdata(s)[0];
kchar = (int8_t)strdata(s)[0]; /* Signed! */
args[1] = ASMREF_TMP1; /* int, truncated to char */
ci = &lj_ir_callinfo[IRCALL_lj_buf_putchar];
}
Expand All @@ -1024,7 +1024,7 @@ static void asm_bufput(ASMState *as, IRIns *ir)
asm_gencall(as, ci, args);
if (args[1] == ASMREF_TMP1) {
Reg tmp = ra_releasetmp(as, ASMREF_TMP1);
if (kchar == -1)
if (kchar == -129)
asm_tvptr(as, tmp, irs->op1);
else
ra_allockreg(as, kchar, tmp);
Expand Down Expand Up @@ -1798,6 +1798,7 @@ static void asm_setup_regsp(ASMState *as)
for (ir = IR(T->nk), lastir = IR(REF_BASE); ir < lastir; ir++) {
ir->prev = REGSP_INIT;
if (irt_is64(ir->t) && ir->o != IR_KNULL) {
/* The false-positive of irt_is64() for ASMREF_L (REF_NIL) is OK here. */
ir->i = 0; /* Will become non-zero only for RIP-relative addresses. */
ir++;
}
Expand Down
2 changes: 1 addition & 1 deletion src/lj_asm_x86.h
Original file line number Diff line number Diff line change
Expand Up @@ -1348,7 +1348,7 @@ static void asm_sload(ASMState *as, IRIns *ir)
emit_i8(as, irt_toitype(t));
emit_rr(as, XO_ARITHi8, XOg_CMP, tmp);
emit_shifti(as, XOg_SAR|REX_64, tmp, 47);
emit_rmro(as, XO_MOV, tmp|REX_64, base, ofs+4);
emit_rmro(as, XO_MOV, tmp|REX_64, base, ofs);
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/lj_ir.h
Original file line number Diff line number Diff line change
Expand Up @@ -375,10 +375,12 @@ typedef struct IRType1 { uint8_t irt; } IRType1;
#define irt_isaddr(t) (irt_typerange((t), IRT_LIGHTUD, IRT_UDATA))
#define irt_isint64(t) (irt_typerange((t), IRT_I64, IRT_U64))

/* Include IRT_NIL, so IR(ASMREF_L) (aka REF_NIL) is considered 64 bit. */
#define IRT_IS64 \
((1u<<IRT_NUM)|(1u<<IRT_I64)|(1u<<IRT_U64)|(1u<<IRT_P64)|\
(1u<<IRT_LIGHTUD)|(1u<<IRT_STR)|(1u<<IRT_THREAD)|(1u<<IRT_PROTO)|\
(1u<<IRT_FUNC)|(1u<<IRT_CDATA)|(1u<<IRT_TAB)|(1u<<IRT_UDATA))
(1u<<IRT_FUNC)|(1u<<IRT_CDATA)|(1u<<IRT_TAB)|(1u<<IRT_UDATA)|\
(1u<<IRT_NIL))

#define irt_is64(t) ((IRT_IS64 >> irt_type(t)) & 1)
#define irt_is64orfp(t) (((IRT_IS64|(1u<<IRT_FLOAT))>>irt_type(t)) & 1)
Expand Down
2 changes: 1 addition & 1 deletion src/lj_opt_fold.c
Original file line number Diff line number Diff line change
Expand Up @@ -1168,7 +1168,7 @@ LJFOLDF(simplify_conv_sext)
if (ref == J->scev.idx) {
IRRef lo = J->scev.dir ? J->scev.start : J->scev.stop;
lua_assert(irt_isint(J->scev.t));
if (lo && IR(lo)->i + ofs >= 0) {
if (lo && IR(lo)->o == IR_KINT && IR(lo)->i + ofs >= 0) {
ok_reduce:
/* Eliminate widening. All 32 bit ops do an implicit zero-extension. */
return LEFTFOLD;
Expand Down
1 change: 1 addition & 0 deletions src/lj_opt_sink.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ static void sink_sweep_ins(jit_State *J)
for (ir = IR(J->cur.nk); ir < irbase; ir++) {
irt_clearmark(ir->t);
ir->prev = REGSP_INIT;
/* The false-positive of irt_is64() for ASMREF_L (REF_NIL) is OK here. */
if (irt_is64(ir->t) && ir->o != IR_KNULL)
ir++;
}
Expand Down

0 comments on commit 389cc39

Please sign in to comment.