summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Pall <mike>2012-02-04 00:32:45 +0100
committerMike Pall <mike>2012-02-04 00:32:45 +0100
commit8e524d437e2e5e3a1d27351c0e18e97181c56328 (patch)
tree34382bc3802c5a8a926fcb4c7e5edf0a4b30529d
parentd72d758a112cd4a83402f4debfe5173ba170c6c2 (diff)
downloadluajit2-8e524d437e2e5e3a1d27351c0e18e97181c56328.tar.gz
Fix bytecode dump for certain number constants.
-rw-r--r--src/lj_bcwrite.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/lj_bcwrite.c b/src/lj_bcwrite.c
index 3c15f6f0..ae90727e 100644
--- a/src/lj_bcwrite.c
+++ b/src/lj_bcwrite.c
@@ -219,13 +219,19 @@ static void bcwrite_knum(BCWriteCtx *ctx, GCproto *pt)
k = lj_num2int(num);
if (num == (lua_Number)k) { /* -0 is never a constant. */
save_int:
- bcwrite_uleb128(ctx, 2*(uint32_t)k);
- if (k < 0) ctx->sb.buf[ctx->sb.n-1] |= 0x10;
+ bcwrite_uleb128(ctx, 2*(uint32_t)k | ((uint32_t)k & 0x80000000u));
+ if (k < 0) {
+ char *p = &ctx->sb.buf[ctx->sb.n-1];
+ *p = (*p & 7) | ((k>>27) & 0x18);
+ }
continue;
}
}
- bcwrite_uleb128(ctx, 1+2*o->u32.lo);
- if (o->u32.lo >= 0x80000000u) ctx->sb.buf[ctx->sb.n-1] |= 0x10;
+ bcwrite_uleb128(ctx, 1+(2*o->u32.lo | (o->u32.lo & 0x80000000u)));
+ if (o->u32.lo >= 0x80000000u) {
+ char *p = &ctx->sb.buf[ctx->sb.n-1];
+ *p = (*p & 7) | ((o->u32.lo>>27) & 0x18);
+ }
bcwrite_uleb128(ctx, o->u32.hi);
}
}