diff options
Diffstat (limited to 'src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSNumberCell.h')
-rw-r--r-- | src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSNumberCell.h | 163 |
1 files changed, 20 insertions, 143 deletions
diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSNumberCell.h b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSNumberCell.h index a35e2106d0..6a48081632 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSNumberCell.h +++ b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSNumberCell.h @@ -35,10 +35,8 @@ namespace JSC { extern const double NaN; extern const double Inf; +#if USE(JSVALUE32) JSValue jsNumberCell(ExecState*, double); - JSValue jsAPIMangledNumber(ExecState*, double); - -#if !USE(ALTERNATE_JSIMMEDIATE) class Identifier; class JSCell; @@ -53,7 +51,7 @@ namespace JSC { friend class JIT; friend JSValue jsNumberCell(JSGlobalData*, double); friend JSValue jsNumberCell(ExecState*, double); - friend JSValue jsAPIMangledNumber(ExecState*, double); + public: double value() const { return m_value; } @@ -68,9 +66,6 @@ namespace JSC { virtual JSObject* toThisObject(ExecState*) const; virtual JSValue getJSNumber(); - static const uintptr_t JSAPIMangledMagicNumber = 0xbbadbeef; - bool isAPIMangledNumber() const { return m_structure == reinterpret_cast<Structure*>(JSAPIMangledMagicNumber); } - void* operator new(size_t size, ExecState* exec) { #ifdef JAVASCRIPTCORE_BUILDING_ALL_IN_ONE_FILE @@ -89,7 +84,7 @@ namespace JSC { #endif } - static PassRefPtr<Structure> createStructure(JSValue proto) { return Structure::create(proto, TypeInfo(NumberType, NeedsThisConversion)); } + static PassRefPtr<Structure> createStructure(JSValue proto) { return Structure::create(proto, TypeInfo(NumberType, NeedsThisConversion | HasDefaultMark)); } private: JSNumberCell(JSGlobalData* globalData, double value) @@ -104,16 +99,7 @@ namespace JSC { { } - enum APIMangledTag { APIMangled }; - JSNumberCell(APIMangledTag, double value) - : JSCell(reinterpret_cast<Structure*>(JSAPIMangledMagicNumber)) - , m_value(value) - { - } - virtual bool getUInt32(uint32_t&) const; - virtual bool getTruncatedInt32(int32_t&) const; - virtual bool getTruncatedUInt32(uint32_t&) const; double m_value; }; @@ -131,7 +117,6 @@ namespace JSC { return static_cast<JSNumberCell*>(v.asCell()); } - inline JSValue::JSValue(ExecState* exec, double d) { JSValue v = JSImmediate::from(d); @@ -192,59 +177,30 @@ namespace JSC { *this = v ? v : jsNumberCell(globalData, i); } - inline JSValue::JSValue(JSGlobalData* globalData, long i) - { - JSValue v = JSImmediate::from(i); - *this = v ? v : jsNumberCell(globalData, i); - } - - inline JSValue::JSValue(JSGlobalData* globalData, unsigned long i) - { - JSValue v = JSImmediate::from(i); - *this = v ? v : jsNumberCell(globalData, i); - } - - inline JSValue::JSValue(JSGlobalData* globalData, long long i) - { - JSValue v = JSImmediate::from(i); - *this = v ? v : jsNumberCell(globalData, static_cast<double>(i)); - } - - inline JSValue::JSValue(JSGlobalData* globalData, unsigned long long i) - { - JSValue v = JSImmediate::from(i); - *this = v ? v : jsNumberCell(globalData, static_cast<double>(i)); - } - - inline bool JSValue::isDoubleNumber() const + inline bool JSValue::isDouble() const { return isNumberCell(asValue()); } - inline double JSValue::getDoubleNumber() const + inline double JSValue::asDouble() const { return asNumberCell(asValue())->value(); } inline bool JSValue::isNumber() const { - return JSImmediate::isNumber(asValue()) || isDoubleNumber(); + return JSImmediate::isNumber(asValue()) || isDouble(); } inline double JSValue::uncheckedGetNumber() const { ASSERT(isNumber()); - return JSImmediate::isImmediate(asValue()) ? JSImmediate::toDouble(asValue()) : getDoubleNumber(); + return JSImmediate::isImmediate(asValue()) ? JSImmediate::toDouble(asValue()) : asDouble(); } - inline bool JSValue::isAPIMangledNumber() - { - ASSERT(isNumber()); - return JSImmediate::isImmediate(asValue()) ? false : asNumberCell(asValue())->isAPIMangledNumber(); - } - -#else +#endif // USE(JSVALUE32) +#if USE(JSVALUE64) inline JSValue::JSValue(ExecState*, double d) { JSValue v = JSImmediate::from(d); @@ -315,40 +271,12 @@ namespace JSC { *this = v; } - inline JSValue::JSValue(JSGlobalData*, long i) - { - JSValue v = JSImmediate::from(i); - ASSERT(v); - *this = v; - } - - inline JSValue::JSValue(JSGlobalData*, unsigned long i) + inline bool JSValue::isDouble() const { - JSValue v = JSImmediate::from(i); - ASSERT(v); - *this = v; - } - - inline JSValue::JSValue(JSGlobalData*, long long i) - { - JSValue v = JSImmediate::from(static_cast<double>(i)); - ASSERT(v); - *this = v; + return JSImmediate::isDouble(asValue()); } - inline JSValue::JSValue(JSGlobalData*, unsigned long long i) - { - JSValue v = JSImmediate::from(static_cast<double>(i)); - ASSERT(v); - *this = v; - } - - inline bool JSValue::isDoubleNumber() const - { - return JSImmediate::isDoubleNumber(asValue()); - } - - inline double JSValue::getDoubleNumber() const + inline double JSValue::asDouble() const { return JSImmediate::doubleValue(asValue()); } @@ -364,7 +292,9 @@ namespace JSC { return JSImmediate::toDouble(asValue()); } -#endif +#endif // USE(JSVALUE64) + +#if USE(JSVALUE32) || USE(JSVALUE64) inline JSValue::JSValue(ExecState*, char i) { @@ -390,30 +320,6 @@ namespace JSC { *this = JSImmediate::from(i); } - inline JSValue::JSValue(JSGlobalData*, char i) - { - ASSERT(JSImmediate::from(i)); - *this = JSImmediate::from(i); - } - - inline JSValue::JSValue(JSGlobalData*, unsigned char i) - { - ASSERT(JSImmediate::from(i)); - *this = JSImmediate::from(i); - } - - inline JSValue::JSValue(JSGlobalData*, short i) - { - ASSERT(JSImmediate::from(i)); - *this = JSImmediate::from(i); - } - - inline JSValue::JSValue(JSGlobalData*, unsigned short i) - { - ASSERT(JSImmediate::from(i)); - *this = JSImmediate::from(i); - } - inline JSValue jsNaN(ExecState* exec) { return jsNumber(exec, NaN); @@ -433,23 +339,10 @@ namespace JSC { inline bool JSValue::getNumber(double &result) const { - if (isInt32Fast()) - result = getInt32Fast(); - else if (LIKELY(isDoubleNumber())) - result = getDoubleNumber(); - else { - ASSERT(!isNumber()); - return false; - } - return true; - } - - inline bool JSValue::numberToInt32(int32_t& arg) - { - if (isInt32Fast()) - arg = getInt32Fast(); - else if (LIKELY(isDoubleNumber())) - arg = JSC::toInt32(getDoubleNumber()); + if (isInt32()) + result = asInt32(); + else if (LIKELY(isDouble())) + result = asDouble(); else { ASSERT(!isNumber()); return false; @@ -457,23 +350,7 @@ namespace JSC { return true; } - inline bool JSValue::numberToUInt32(uint32_t& arg) - { - if (isUInt32Fast()) - arg = getUInt32Fast(); - else if (LIKELY(isDoubleNumber())) - arg = JSC::toUInt32(getDoubleNumber()); - else if (isInt32Fast()) { - // FIXME: I think this case can be merged with the uint case; toUInt32SlowCase - // on a negative value is equivalent to simple static_casting. - bool ignored; - arg = toUInt32SlowCase(getInt32Fast(), ignored); - } else { - ASSERT(!isNumber()); - return false; - } - return true; - } +#endif // USE(JSVALUE32) || USE(JSVALUE64) } // namespace JSC |