From 4ca4131209153a57df6008bf1de020b1d93ce9ed Mon Sep 17 00:00:00 2001 From: "wsharp%adobe.com" Date: Wed, 6 Dec 2006 20:51:03 +0000 Subject: [PATCH] bug 361312. Fix for Math.pow plus a few other things. r: stejohns@adobe.com --- js/tamarin/MMgc/GC.h | 22 ++++++++++++++------- js/tamarin/MMgc/GCGlobalNew.cpp | 31 +++++++++++++++++++++++++++++ js/tamarin/MMgc/GCGlobalNew.h | 33 +++++++++++++++++++++++++++++++ js/tamarin/codegen/CodegenMIR.cpp | 28 ++++++++++++++++++++++++-- js/tamarin/core/AvmCore.cpp | 7 +++++++ js/tamarin/core/MathUtils.cpp | 2 +- 6 files changed, 113 insertions(+), 10 deletions(-) diff --git a/js/tamarin/MMgc/GC.h b/js/tamarin/MMgc/GC.h index 6a963b5c30a6..1291eaaed752 100644 --- a/js/tamarin/MMgc/GC.h +++ b/js/tamarin/MMgc/GC.h @@ -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 GCHiddenPointer { public: GCHiddenPointer(T obj) { set(obj); } - operator T() const { return (T) (low16|high16<<16); } + operator T() const { return (T) (low|high<() const { return (T) (low16|high16<<16); } + T operator->() const { return (T) (low|high<> 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; }; /** diff --git a/js/tamarin/MMgc/GCGlobalNew.cpp b/js/tamarin/MMgc/GCGlobalNew.cpp index 5f6497a4aac8..1681e6596d6c 100755 --- a/js/tamarin/MMgc/GCGlobalNew.cpp +++ b/js/tamarin/MMgc/GCGlobalNew.cpp @@ -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; diff --git a/js/tamarin/MMgc/GCGlobalNew.h b/js/tamarin/MMgc/GCGlobalNew.h index 6919fa994c08..8210c4f8b9a7 100755 --- a/js/tamarin/MMgc/GCGlobalNew.h +++ b/js/tamarin/MMgc/GCGlobalNew.h @@ -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 diff --git a/js/tamarin/codegen/CodegenMIR.cpp b/js/tamarin/codegen/CodegenMIR.cpp index d01a4832602e..11ef4ef15273 100644 --- a/js/tamarin/codegen/CodegenMIR.cpp +++ b/js/tamarin/codegen/CodegenMIR.cpp @@ -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; diff --git a/js/tamarin/core/AvmCore.cpp b/js/tamarin/core/AvmCore.cpp index b834f1484be5..79f02907b7f2 100644 --- a/js/tamarin/core/AvmCore.cpp +++ b/js/tamarin/core/AvmCore.cpp @@ -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; } diff --git a/js/tamarin/core/MathUtils.cpp b/js/tamarin/core/MathUtils.cpp index c2f5dc0a1b79..e3d9b04b6dd4 100644 --- a/js/tamarin/core/MathUtils.cpp +++ b/js/tamarin/core/MathUtils.cpp @@ -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;