isNaN optimizations

This commit is contained in:
Anton Khlynovskiy 2013-11-07 20:50:01 +04:00
parent 14b77a8aaf
commit 2a6ed9d63a
2 changed files with 43 additions and 43 deletions

View file

@ -4488,7 +4488,7 @@ function FPU(io)
{
tag_word |= 1 << (i << 1);
}
else if(isNaN(value) || value === Infinity || value === -Infinity)
else if(!isFinite(value))
{
tag_word |= 2 << (i << 1);
}
@ -5201,28 +5201,28 @@ function FPU(io)
case 2:
// fist
var st0 = get_st0();
if(isNaN(st0) || st0 > 0x7FFFFFFF || st0 < -0x80000000)
{
invalid_arithmatic();
safe_write32(addr, 0x80000000);
}
else
if(st0 <= 0x7FFFFFFF && st0 >= -0x80000000)
{
// TODO: Invalid operation
safe_write32(addr, integer_round(st0));
}
else
{
invalid_arithmatic();
safe_write32(addr, 0x80000000);
}
break;
case 3:
// fistp
var st0 = get_st0();
if(isNaN(st0) || st0 > 0x7FFFFFFF || st0 < -0x80000000)
if(st0 <= 0x7FFFFFFF && st0 >= -0x80000000)
{
invalid_arithmatic();
safe_write32(addr, 0x80000000);
safe_write32(addr, integer_round(st0));
}
else
{
safe_write32(addr, integer_round(st0));
invalid_arithmatic();
safe_write32(addr, 0x80000000);
}
pop();
break;
@ -5557,27 +5557,27 @@ function FPU(io)
case 2:
// fist
var st0 = get_st0();
if(isNaN(st0) || st0 > 0x7FFF || st0 < -0x8000)
if(st0 <= 0x7FFF || st0 >= -0x8000)
{
invalid_arithmatic();
safe_write16(addr, 0x8000);
safe_write16(addr, integer_round(st0));
}
else
{
safe_write16(addr, integer_round(st0));
invalid_arithmatic();
safe_write16(addr, 0x8000);
}
break;
case 3:
// fistp
var st0 = get_st0();
if(isNaN(st0) || st0 > 0x7FFF || st0 < -0x8000)
if(st0 <= 0x7FFF || st0 >= -0x8000)
{
invalid_arithmatic();
safe_write16(addr, 0x8000);
safe_write16(addr, integer_round(st0));
}
else
{
safe_write16(addr, integer_round(st0));
invalid_arithmatic();
safe_write16(addr, 0x8000);
}
pop();
break;
@ -5595,7 +5595,7 @@ function FPU(io)
case 7:
// fistp
var st0 = integer_round(get_st0());
if(isNaN(st0) || st0 > 0x7FFFFFFFFFFFFFFF || st0 < -0x8000000000000000)
if(!(st0 <= 0x7FFFFFFFFFFFFFFF && st0 >= -0x8000000000000000))
{
st0 = 0x8000000000000000;
invalid_arithmatic();

View file

@ -396,7 +396,7 @@ function FPU(io)
{
tag_word |= 1 << (i << 1);
}
else if(isNaN(value) || value === Infinity || value === -Infinity)
else if(!isFinite(value))
{
tag_word |= 2 << (i << 1);
}
@ -1205,29 +1205,29 @@ function FPU(io)
case 2:
// fist
var st0 = get_st0();
if(isNaN(st0) || st0 > 0x7FFFFFFF || st0 < -0x80000000)
if(st0 <= 0x7FFFFFFF && st0 >= -0x80000000)
{
// TODO: Invalid operation
safe_write32(addr, integer_round(st0));
}
else
{
invalid_arithmatic();
safe_write32(addr, 0x80000000);
}
else
{
// TODO: Invalid operation
safe_write32(addr, integer_round(st0));
}
break;
case 3:
// fistp
var st0 = get_st0();
if(isNaN(st0) || st0 > 0x7FFFFFFF || st0 < -0x80000000)
if(st0 <= 0x7FFFFFFF && st0 >= -0x80000000)
{
safe_write32(addr, integer_round(st0));
}
else
{
invalid_arithmatic();
safe_write32(addr, 0x80000000);
}
else
{
safe_write32(addr, integer_round(st0));
}
pop();
break;
case 5:
@ -1590,28 +1590,28 @@ function FPU(io)
case 2:
// fist
var st0 = get_st0();
if(isNaN(st0) || st0 > 0x7FFF || st0 < -0x8000)
if(st0 <= 0x7FFF && st0 >= -0x8000)
{
safe_write16(addr, integer_round(st0));
}
else
{
invalid_arithmatic();
safe_write16(addr, 0x8000);
}
else
{
safe_write16(addr, integer_round(st0));
}
break;
case 3:
// fistp
var st0 = get_st0();
if(isNaN(st0) || st0 > 0x7FFF || st0 < -0x8000)
if(st0 <= 0x7FFF && st0 >= -0x8000)
{
safe_write16(addr, integer_round(st0));
}
else
{
invalid_arithmatic();
safe_write16(addr, 0x8000);
}
else
{
safe_write16(addr, integer_round(st0));
}
pop();
break;
case 5:
@ -1633,7 +1633,7 @@ function FPU(io)
// fistp
var st0 = integer_round(get_st0());
if(isNaN(st0) || st0 > 0x7FFFFFFFFFFFFFFF || st0 < -0x8000000000000000)
if(!(st0 <= 0x7FFFFFFFFFFFFFFF || st0 >= -0x8000000000000000))
{
st0 = 0x8000000000000000;
invalid_arithmatic();