Show
Ignore:
Timestamp:
08/20/08 13:23:52 (5 months ago)
Author:
mbensi
Message:

merge with webkit revision 35853

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/JavaScriptCore/kjs/JSImmediate.h

    r440 r447  
    11/* 
    2  *  Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 
     2 *  Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 
    33 *  Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) 
    44 * 
     
    2323#define KJS_JS_IMMEDIATE_H 
    2424 
    25 #include "JSType.h" 
    2625#include <wtf/Assertions.h> 
    2726#include <wtf/AlwaysInline.h> 
     
    4140 
    4241    /* 
    43      * A JSValue* is either a pointer to a cell (a heap-allocated object) or an immediate (a type-tagged  
     42     * A JSValue* is either a pointer to a cell (a heap-allocated object) or an immediate (a type-tagged  
    4443     * value masquerading as a pointer). The low two bits in a JSValue* are available for type tagging 
    4544     * because allocator alignment guarantees they will be 00 in cell pointers. 
     
    8382 
    8483    class JSImmediate { 
     84    private: 
    8585        static const uintptr_t TagMask           = 0x3u; // primary tag is 2 bits long 
    86         static const uintptr_t TagBitTypeInteger = 0x1u; // bottom bit set indicates int, this dominates the following bit 
     86        static const uintptr_t TagBitTypeInteger = 0x1u; // bottom bit set indicates integer, this dominates the following bit 
    8787        static const uintptr_t TagBitTypeOther   = 0x2u; // second bit set indicates immediate other than an integer 
    8888 
     
    104104        static ALWAYS_INLINE bool isImmediate(const JSValue* v) 
    105105        { 
    106             return (reinterpret_cast<uintptr_t>(v) & TagMask)
     106            return reinterpret_cast<uintptr_t>(v) & TagMask
    107107        } 
    108108         
    109109        static ALWAYS_INLINE bool isNumber(const JSValue* v) 
    110110        { 
    111             return (reinterpret_cast<uintptr_t>(v) & TagBitTypeInteger)
     111            return reinterpret_cast<uintptr_t>(v) & TagBitTypeInteger
    112112        } 
    113113 
     
    120120        static ALWAYS_INLINE bool isBoolean(const JSValue* v) 
    121121        { 
    122             return ((reinterpret_cast<uintptr_t>(v) & FullTagTypeMask) == FullTagTypeBool)
     122            return (reinterpret_cast<uintptr_t>(v) & FullTagTypeMask) == FullTagTypeBool
    123123        } 
    124124         
     
    126126        { 
    127127            // Undefined and null share the same value, bar the 'undefined' bit in the extended tag. 
    128             return ((reinterpret_cast<uintptr_t>(v) & ~ExtendedTagBitUndefined) == FullTagTypeNull)
     128            return (reinterpret_cast<uintptr_t>(v) & ~ExtendedTagBitUndefined) == FullTagTypeNull
    129129        } 
    130130 
     
    148148        static JSValue* from(double); 
    149149 
     150        static ALWAYS_INLINE bool isEitherImmediate(const JSValue* v1, const JSValue* v2) 
     151        { 
     152            return (reinterpret_cast<uintptr_t>(v1) | reinterpret_cast<uintptr_t>(v2)) & TagMask; 
     153        } 
     154 
    150155        static ALWAYS_INLINE bool areBothImmediateNumbers(const JSValue* v1, const JSValue* v2) 
    151156        { 
    152             return (reinterpret_cast<uintptr_t>(v1) & reinterpret_cast<uintptr_t>(v2) & TagBitTypeInteger)
     157            return reinterpret_cast<uintptr_t>(v1) & reinterpret_cast<uintptr_t>(v2) & TagBitTypeInteger
    153158        } 
    154159 
     
    214219        static JSObject* toObject(const JSValue*, ExecState*); 
    215220        static UString toString(const JSValue*); 
    216         static uint32_t toTruncatedUInt32(const JSValue*); 
    217         static JSType type(const JSValue*); 
    218221 
    219222        static bool getUInt32(const JSValue*, uint32_t&); 
     
    222225 
    223226        static int32_t getTruncatedInt32(const JSValue*); 
     227        static uint32_t getTruncatedUInt32(const JSValue*); 
    224228 
    225229        static JSValue* trueImmediate(); 
     
    233237 
    234238    private: 
    235         // Immediate values are restricted to a 30 bit signed value. 
    236239        static const int minImmediateInt = ((-INT_MAX) - 1) >> IntegerPayloadShift; 
    237240        static const int maxImmediateInt = INT_MAX >> IntegerPayloadShift; 
     
    270273        static ALWAYS_INLINE bool boolValue(const JSValue* v) 
    271274        { 
    272             return (rawValue(v) & ExtendedPayloadBitBoolValue) != 0
     275            return rawValue(v) & ExtendedPayloadBitBoolValue
    273276        } 
    274277         
     
    291294        ASSERT(isImmediate(v)); 
    292295        uintptr_t bits = rawValue(v); 
    293         return 
    294             (bits & TagBitTypeInteger) ? (bits != TagBitTypeInteger) : // !0 ints 
    295             (bits == (FullTagTypeBool | ExtendedPayloadBitBoolValue)); // bool true 
    296     } 
    297  
    298     ALWAYS_INLINE uint32_t JSImmediate::toTruncatedUInt32(const JSValue* v) 
     296        return (bits & TagBitTypeInteger) 
     297            ? bits != TagBitTypeInteger // !0 ints 
     298            : bits == (FullTagTypeBool | ExtendedPayloadBitBoolValue); // bool true 
     299    } 
     300 
     301    ALWAYS_INLINE uint32_t JSImmediate::getTruncatedUInt32(const JSValue* v) 
    299302    { 
    300303        ASSERT(isNumber(v)); 
     
    377380 
    378381        // Check for data loss from conversion to int. 
    379         if ((intVal != d) || (!intVal && signbit(d))) 
     382        if (intVal != d || (!intVal && signbit(d))) 
    380383            return 0; 
    381384 
     
    418421    } 
    419422 
    420     ALWAYS_INLINE JSType JSImmediate::type(const JSValue* v) 
    421     { 
    422         ASSERT(isImmediate(v)); 
    423          
    424         if (isNumber(v)) 
    425             return NumberType; 
    426         if (isBoolean(v)) 
    427             return BooleanType; 
    428         if (v != undefinedImmediate()) 
    429             return NullType; 
    430         return UndefinedType; 
    431     } 
    432  
    433423    ALWAYS_INLINE JSValue* jsUndefined() 
    434424    {