aboutsummaryrefslogtreecommitdiff
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)
downloadluajit-8e524d437e2e5e3a1d27351c0e18e97181c56328.tar.gz
luajit-8e524d437e2e5e3a1d27351c0e18e97181c56328.tar.bz2
luajit-8e524d437e2e5e3a1d27351c0e18e97181c56328.zip
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)
219 k = lj_num2int(num); 219 k = lj_num2int(num);
220 if (num == (lua_Number)k) { /* -0 is never a constant. */ 220 if (num == (lua_Number)k) { /* -0 is never a constant. */
221 save_int: 221 save_int:
222 bcwrite_uleb128(ctx, 2*(uint32_t)k); 222 bcwrite_uleb128(ctx, 2*(uint32_t)k | ((uint32_t)k & 0x80000000u));
223 if (k < 0) ctx->sb.buf[ctx->sb.n-1] |= 0x10; 223 if (k < 0) {
224 char *p = &ctx->sb.buf[ctx->sb.n-1];
225 *p = (*p & 7) | ((k>>27) & 0x18);
226 }
224 continue; 227 continue;
225 } 228 }
226 } 229 }
227 bcwrite_uleb128(ctx, 1+2*o->u32.lo); 230 bcwrite_uleb128(ctx, 1+(2*o->u32.lo | (o->u32.lo & 0x80000000u)));
228 if (o->u32.lo >= 0x80000000u) ctx->sb.buf[ctx->sb.n-1] |= 0x10; 231 if (o->u32.lo >= 0x80000000u) {
232 char *p = &ctx->sb.buf[ctx->sb.n-1];
233 *p = (*p & 7) | ((o->u32.lo>>27) & 0x18);
234 }
229 bcwrite_uleb128(ctx, o->u32.hi); 235 bcwrite_uleb128(ctx, o->u32.hi);
230 } 236 }
231 } 237 }