From 851efc8d1011b6745d4e663dae67ce0e019bfa6d Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Tue, 2 Dec 2008 19:39:09 -0700 Subject: [PATCH] handle case of unresolved promise in compareCR and compareCM --- src/x86.cpp | 49 ++++++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/src/x86.cpp b/src/x86.cpp index 1722c2553d..baa9b23ba5 100644 --- a/src/x86.cpp +++ b/src/x86.cpp @@ -1746,9 +1746,9 @@ compareCR(Context* c, unsigned size, Assembler::Constant* a, { assert(c, BytesPerWord == 8 or size == 4); - int64_t v = a->value->value(); + if (a->value->resolved() and isInt32(a->value->value())) { + int64_t v = a->value->value(); - if (isInt32(v)) { if (size == 8) rex(c); if (isInt8(v)) { c->code.append(0x83); @@ -1767,25 +1767,6 @@ compareCR(Context* c, unsigned size, Assembler::Constant* a, } } -void -compareCM(Context* c, unsigned size UNUSED, Assembler::Constant* a, - Assembler::Memory* b) -{ - assert(c, BytesPerWord == 8 or size == 4); - - int64_t v = a->value->value(); - - encode(c, isInt8(v) ? 0x83 : 0x81, 7, b, true); - - if (isInt8(v)) { - c->code.append(v); - } else if (isInt32(v)) { - c->code.append4(v); - } else { - abort(c); - } -} - void compareRM(Context* c, unsigned size, Assembler::Register* a, Assembler::Memory* b) @@ -1798,6 +1779,32 @@ compareRM(Context* c, unsigned size, Assembler::Register* a, encode(c, 0x39, a->low, b, true); } +void +compareCM(Context* c, unsigned size, Assembler::Constant* a, + Assembler::Memory* b) +{ + assert(c, BytesPerWord == 8 or size == 4); + + if (a->value->resolved()) { + int64_t v = a->value->value(); + + encode(c, isInt8(v) ? 0x83 : 0x81, 7, b, true); + + if (isInt8(v)) { + c->code.append(v); + } else if (isInt32(v)) { + c->code.append4(v); + } else { + abort(c); + } + } else { + Assembler::Register tmp(c->client->acquireTemporary()); + moveCR(c, size, a, &tmp); + compareRM(c, size, &tmp, b); + c->client->releaseTemporary(tmp.low); + } +} + void compareAM(Context* c, unsigned size, Assembler::Address* a, Assembler::Memory* b)