bug 361312. Fix for Math.pow plus a few other things. r: stejohns@adobe.com

This commit is contained in:
wsharp%adobe.com 2006-12-06 20:51:03 +00:00
parent 3af4185ee2
commit 4ca4131209
6 changed files with 113 additions and 10 deletions

View File

@ -248,18 +248,26 @@ namespace MMgc
GCCallback *prevCB;
};
#ifdef MMGC_64BIT
#define HIDDENPTRSHIFT 32
#define HIDDENPTRMASK 0xFFFFFFFF
#else
#define HIDDENPTRSHIFT 16
#define HIDDENPTRMASK 0x0000FFFF
#endif
template <class T>
class GCHiddenPointer
{
public:
GCHiddenPointer(T obj) { set(obj); }
operator T() const { return (T) (low16|high16<<16); }
operator T() const { return (T) (low|high<<HIDDENPTRSHIFT); }
T operator=(T tNew)
{
set(tNew);
return (T)this;
}
T operator->() const { return (T) (low16|high16<<16); }
T operator->() const { return (T) (low|high<<HIDDENPTRSHIFT); }
private:
// private to prevent its use and someone adding it, GCC creates
@ -268,12 +276,12 @@ namespace MMgc
void set(T obj)
{
uint32 p = (uint32)obj;
high16 = p >> 16;
low16 = p & 0x0000ffff;
uintptr_t p = (uintptr_t)obj;
high = p >> HIDDENPTRSHIFT;
low = p & HIDDENPTRMASK;
}
uint32 high16;
uint32 low16;
uintptr_t high;
uintptr_t low;
};
/**

View File

@ -1,3 +1,34 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version 1.1 (the
* "License"); you may not use this file except in compliance with the License. You may obtain
* a copy of the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
* 42
* The Original Code is [Open Source Virtual Machine.]
*
* The Initial Developer of the Original Code is Adobe System Incorporated. Portions created
* by the Initial Developer are Copyright (C)[ 2004-2006 ] Adobe Systems Incorporated. All Rights
* Reserved.
*
* Contributor(s): Adobe AS3 Team
*
* Alternatively, the contents of this file may be used under the terms of either the GNU
* General Public License Version 2 or later (the "GPL"), or the GNU Lesser General Public
* License Version 2.1 or later (the "LGPL"), in which case the provisions of the GPL or the
* LGPL are applicable instead of those above. If you wish to allow use of your version of this
* file only under the terms of either the GPL or the LGPL, and not to allow others to use your
* version of this file under the terms of the MPL, indicate your decision by deleting provisions
* above and replace them with the notice and other provisions required by the GPL or the
* LGPL. If you do not delete the provisions above, a recipient may use your version of this file
* under the terms of any one of the MPL, the GPL or the LGPL.
*
***** END LICENSE BLOCK ***** */
#include "MMgc.h"
using namespace std;

View File

@ -1,8 +1,40 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version 1.1 (the
* "License"); you may not use this file except in compliance with the License. You may obtain
* a copy of the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
* 42
* The Original Code is [Open Source Virtual Machine.]
*
* The Initial Developer of the Original Code is Adobe System Incorporated. Portions created
* by the Initial Developer are Copyright (C)[ 2004-2006 ] Adobe Systems Incorporated. All Rights
* Reserved.
*
* Contributor(s): Adobe AS3 Team
*
* Alternatively, the contents of this file may be used under the terms of either the GNU
* General Public License Version 2 or later (the "GPL"), or the GNU Lesser General Public
* License Version 2.1 or later (the "LGPL"), in which case the provisions of the GPL or the
* LGPL are applicable instead of those above. If you wish to allow use of your version of this
* file only under the terms of either the GPL or the LGPL, and not to allow others to use your
* version of this file under the terms of the MPL, indicate your decision by deleting provisions
* above and replace them with the notice and other provisions required by the GPL or the
* LGPL. If you do not delete the provisions above, a recipient may use your version of this file
* under the terms of any one of the MPL, the GPL or the LGPL.
*
***** END LICENSE BLOCK ***** */
#ifndef __GCGLOBALNEW__
#define __GCGLOBALNEW__
#ifdef OVERRIDE_GLOBAL_NEW
#ifdef __GNUC__
#ifndef _MAC
// Custom new and delete operators
#ifdef _DEBUG
@ -47,6 +79,7 @@ inline __attribute__((always_inline)) void operator delete[]( void *p )
#endif // _DEBUG
}
#endif // _MAC
#endif // __GNUC__
#endif // OVERRIDE_GLOBAL_NEW

View File

@ -2500,13 +2500,21 @@ namespace avmplus
markDead(orig);
}
else if (ins != NULL && ins->code == MIR_fsub &&
ins->oprnd1->code == MIR_i2d &&
ins->oprnd2->code == MIR_i2d)
(ins->oprnd1->code == MIR_u2d || ins->oprnd1->code == MIR_i2d) &&
(ins->oprnd2->code == MIR_u2d || ins->oprnd2->code == MIR_i2d))
{
OP* orig = value.ins;
localSet(loc, binaryIns(MIR_sub, ins->oprnd1->oprnd1, ins->oprnd2->oprnd1));
markDead(orig);
}
else if (ins != NULL && ins->code == MIR_fmul &&
(ins->oprnd1->code == MIR_u2d || ins->oprnd1->code == MIR_i2d) &&
(ins->oprnd2->code == MIR_u2d || ins->oprnd2->code == MIR_i2d))
{
OP* orig = value.ins;
localSet(loc, binaryIns(MIR_imul, ins->oprnd1->oprnd1, ins->oprnd2->oprnd1));
markDead(orig);
}
else if (ins != NULL && ((ins->code == MIR_i2d) || (ins->code == MIR_u2d)))
{
OP* orig = value.ins;
@ -2550,6 +2558,22 @@ namespace avmplus
localSet(loc, binaryIns(MIR_add, ins->oprnd1->oprnd1, ins->oprnd2->oprnd1));
markDead(orig);
}
else if (ins != NULL && ins->code == MIR_fsub &&
(ins->oprnd1->code == MIR_u2d || ins->oprnd1->code == MIR_i2d) &&
(ins->oprnd2->code == MIR_u2d || ins->oprnd2->code == MIR_i2d))
{
OP* orig = value.ins;
localSet(loc, binaryIns(MIR_sub, ins->oprnd1->oprnd1, ins->oprnd2->oprnd1));
markDead(orig);
}
else if (ins != NULL && ins->code == MIR_fmul &&
(ins->oprnd1->code == MIR_u2d || ins->oprnd1->code == MIR_i2d) &&
(ins->oprnd2->code == MIR_u2d || ins->oprnd2->code == MIR_i2d))
{
OP* orig = value.ins;
localSet(loc, binaryIns(MIR_imul, ins->oprnd1->oprnd1, ins->oprnd2->oprnd1));
markDead(orig);
}
else if (ins != NULL && ((ins->code == MIR_i2d) || (ins->code == MIR_u2d)))
{
OP* orig = value.ins;

View File

@ -792,6 +792,13 @@ return the result of the comparison ToPrimitive(x) == y.
return atomToDouble(lhs) == atomToDouble(rhs) ? trueAtom : falseAtom;
}
}
// Sometimes ints can hide in double atoms (neg zero for one)
else if ((ltype == kIntegerType) && (rtype == kDoubleType) ||
(rtype == kIntegerType) && (ltype == kDoubleType))
{
return number(lhs) == number(rhs) ? trueAtom : falseAtom;
}
return falseAtom;
}

View File

@ -531,7 +531,7 @@ namespace avmplus
// That means we can't invert the exponent when the base ten value exponent is < 307.
// We could first check if powerOfTwo(base)*exp > 1074, but that would
// slow down all powInts calls. This limits the xtra work to just very small numbers.
if (value == 0 && base != 0) // double check by calling the real thing
if (value == 0 && base != 0 && !MathUtils::isInfinite(base)) // double check by calling the real thing
return MathUtils::powInternal(original_base,(double)original_exponent);
}
exponent >>= 1;