Ignore:
Timestamp:
Oct 18, 2008, 4:08:12 PM (17 years ago)
Author:
Darin Adler
Message:

JavaScriptCore:

2008-10-18 Darin Adler <Darin Adler>

Reviewed by Oliver Hunt.

Remove casts from JSValue* to derived classes, replacing them with
calls to inline casting functions. These functions are also a bit
better than aidrect cast because they also do a runtime assertion.

Removed use of 0 as for JSValue*, changing call sites to use a
noValue() function instead.

Move things needed by classes derived from JSValue out of the class,
since the classes won't be deriving from JSValue any more soon.

I did most of these changes by changing JSValue to not be JSValue* any
more, then fixing a lot of the compilation problems, then rolling out
the JSValue change.

1.011x as fast on SunSpider (presumably due to some of the Machine.cpp changes)

  • API/APICast.h: Removed unneeded forward declarations.
  • API/JSCallbackObject.h: Added an asCallbackObject function for casting.
  • API/JSCallbackObjectFunctions.h: (JSC::JSCallbackObject::asCallbackObject): Added. (JSC::JSCallbackObject::getOwnPropertySlot): Use asObject. (JSC::JSCallbackObject::call): Use noValue. (JSC::JSCallbackObject::staticValueGetter): Use asCallbackObject. (JSC::JSCallbackObject::staticFunctionGetter): Ditto. (JSC::JSCallbackObject::callbackGetter): Ditto.
  • JavaScriptCore.xcodeproj/project.pbxproj: Added RegExpMatchesArray.h.
  • VM/CTI.cpp: (JSC::CTI::asInteger): Added. For use casting a JSValue to an integer. (JSC::CTI::emitGetArg): Use asInteger. (JSC::CTI::emitGetPutArg): Ditto. (JSC::CTI::getConstantImmediateNumericArg): Ditto. Also use noValue. (JSC::CTI::emitInitRegister): Use asInteger. (JSC::CTI::getDeTaggedConstantImmediate): Ditto. (JSC::CTI::compileOpCallInitializeCallFrame): Ditto. (JSC::CTI::compileOpCall): Ditto. (JSC::CTI::compileOpStrictEq): Ditto. (JSC::CTI::privateCompileMainPass): Ditto. (JSC::CTI::privateCompileGetByIdProto): Ditto. (JSC::CTI::privateCompileGetByIdChain): Ditto. (JSC::CTI::privateCompilePutByIdTransition): Ditto.
  • VM/CTI.h: Rewrite the ARG-related macros to use C++ casts instead of C casts and get rid of some extra parentheses. Addd declaration of asInteger.
  • VM/CodeGenerator.cpp: (JSC::CodeGenerator::emitEqualityOp): Use asString. (JSC::CodeGenerator::emitLoad): Use noValue. (JSC::CodeGenerator::findScopedProperty): Change globalObject argument to JSObject* instead of JSValue*. (JSC::CodeGenerator::emitResolve): Remove unneeded cast. (JSC::CodeGenerator::emitGetScopedVar): Use asCell. (JSC::CodeGenerator::emitPutScopedVar): Ditto.
  • VM/CodeGenerator.h: Changed out argument of findScopedProperty. Also change the JSValueMap to use PtrHash explicitly instead of getting it from DefaultHash.
  • VM/JSPropertyNameIterator.cpp: (JSC::JSPropertyNameIterator::toPrimitive): Use noValue.
  • VM/JSPropertyNameIterator.h: (JSC::JSPropertyNameIterator::next): Ditto.
  • VM/Machine.cpp: (JSC::fastIsNumber): Moved isImmediate check here instead of checking for 0 inside Heap::isNumber. Use asCell and asNumberCell. (JSC::fastToInt32): Ditto. (JSC::fastToUInt32): Ditto. (JSC::jsLess): Use asString. (JSC::jsLessEq): Ditto. (JSC::jsAdd): Ditto. (JSC::jsTypeStringForValue): Use asObject. (JSC::jsIsObjectType): Ditto. (JSC::jsIsFunctionType): Ditto. (JSC::inlineResolveBase): Use noValue. (JSC::Machine::callEval): Use asString. Initialize result to undefined, not 0. (JSC::Machine::Machine): Remove unneeded casts to JSCell*. (JSC::Machine::throwException): Use asObject. (JSC::Machine::debug): Remove explicit calls to the DebuggerCallFrame constructor. (JSC::Machine::checkTimeout): Use noValue. (JSC::cachePrototypeChain): Use asObject. (JSC::Machine::tryCachePutByID): Use asCell. (JSC::Machine::tryCacheGetByID): Use aCell and asObject. (JSC::Machine::privateExecute): Use noValue, asCell, asObject, asString, asArray, asActivation, asFunction. Changed code that creates call frames for host functions to pass 0 for the function pointer -- the call frame needs a JSFunction* and a host function object is not one. This was caught by the assertions in the casting functions. Also remove some unneeded casts in cases where two values are compared. (JSC::Machine::retrieveLastCaller): Use noValue. (JSC::Machine::tryCTICachePutByID): Use asCell. (JSC::Machine::tryCTICacheGetByID): Use aCell and asObject. (JSC::setUpThrowTrampolineReturnAddress): Added this function to restore the PIC-branch-avoidance that was recently lost. (JSC::Machine::cti_op_add): Use asString. (JSC::Machine::cti_op_instanceof): Use asCell and asObject. (JSC::Machine::cti_op_call_JSFunction): Use asFunction. (JSC::Machine::cti_op_call_NotJSFunction): Changed code to pass 0 for the function pointer, since we don't have a JSFunction. Use asObject. (JSC::Machine::cti_op_tear_off_activation): Use asActivation. (JSC::Machine::cti_op_construct_JSConstruct): Use asFunction and asObject. (JSC::Machine::cti_op_construct_NotJSConstruct): use asObject. (JSC::Machine::cti_op_get_by_val): Use asArray and asString. (JSC::Machine::cti_op_resolve_func): Use asPointer; this helps prepare us for a situation where JSValue is not a pointer. (JSC::Machine::cti_op_put_by_val): Use asArray. (JSC::Machine::cti_op_put_by_val_array): Ditto. (JSC::Machine::cti_op_resolve_global): Use asGlobalObject. (JSC::Machine::cti_op_post_inc): Change VM_CHECK_EXCEPTION_2 to VM_CHECK_EXCEPTION_AT_END, since there's no observable work done after that point. Also use asPointer. (JSC::Machine::cti_op_resolve_with_base): Use asPointer. (JSC::Machine::cti_op_post_dec): Change VM_CHECK_EXCEPTION_2 to VM_CHECK_EXCEPTION_AT_END, since there's no observable work done after that point. Also use asPointer. (JSC::Machine::cti_op_call_eval): Use asObject, noValue, and change VM_CHECK_EXCEPTION_ARG to VM_THROW_EXCEPTION_AT_END. (JSC::Machine::cti_op_throw): Change return value to a JSValue*. (JSC::Machine::cti_op_in): Use asObject. (JSC::Machine::cti_op_switch_char): Use asString. (JSC::Machine::cti_op_switch_string): Ditto. (JSC::Machine::cti_op_put_getter): Use asObject. (JSC::Machine::cti_op_put_setter): Ditto. (JSC::Machine::cti_vm_throw): Change return value to a JSValue*. Use noValue.
  • VM/Machine.h: Change return values of both cti_op_throw and cti_vm_throw to JSValue*.
  • VM/Register.h: Remove nullJSValue, which is the same thing as noValue(). Also removed unneeded definition of JSValue.
  • kjs/ArgList.h: Removed unneeded definition of JSValue.
  • kjs/Arguments.h: (JSC::asArguments): Added.
  • kjs/ArrayPrototype.cpp: (JSC::getProperty): Use noValue. (JSC::arrayProtoFuncToString): Use asArray. (JSC::arrayProtoFuncToLocaleString): Ditto. (JSC::arrayProtoFuncConcat): Ditto. (JSC::arrayProtoFuncPop): Ditto. Also removed unneeded initialization of the result, which is set in both sides of the branch. (JSC::arrayProtoFuncPush): Ditto. (JSC::arrayProtoFuncShift): Removed unneeded initialization of the result, which is set in both sides of the branch. (JSC::arrayProtoFuncSort): Use asArray.
  • kjs/BooleanObject.h: (JSC::asBooleanObject): Added.
  • kjs/BooleanPrototype.cpp: (JSC::booleanProtoFuncToString): Use asBooleanObject. (JSC::booleanProtoFuncValueOf): Ditto.
  • kjs/CallData.cpp: (JSC::call): Use asObject and asFunction.
  • kjs/ConstructData.cpp: (JSC::construct): Ditto.
  • kjs/DateConstructor.cpp: (JSC::constructDate): Use asDateInstance.
  • kjs/DateInstance.h: (JSC::asDateInstance): Added.
  • kjs/DatePrototype.cpp: (JSC::dateProtoFuncToString): Use asDateInstance. (JSC::dateProtoFuncToUTCString): Ditto. (JSC::dateProtoFuncToDateString): Ditto. (JSC::dateProtoFuncToTimeString): Ditto. (JSC::dateProtoFuncToLocaleString): Ditto. (JSC::dateProtoFuncToLocaleDateString): Ditto. (JSC::dateProtoFuncToLocaleTimeString): Ditto. (JSC::dateProtoFuncValueOf): Ditto. (JSC::dateProtoFuncGetTime): Ditto. (JSC::dateProtoFuncGetFullYear): Ditto. (JSC::dateProtoFuncGetUTCFullYear): Ditto. (JSC::dateProtoFuncToGMTString): Ditto. (JSC::dateProtoFuncGetMonth): Ditto. (JSC::dateProtoFuncGetUTCMonth): Ditto. (JSC::dateProtoFuncGetDate): Ditto. (JSC::dateProtoFuncGetUTCDate): Ditto. (JSC::dateProtoFuncGetDay): Ditto. (JSC::dateProtoFuncGetUTCDay): Ditto. (JSC::dateProtoFuncGetHours): Ditto. (JSC::dateProtoFuncGetUTCHours): Ditto. (JSC::dateProtoFuncGetMinutes): Ditto. (JSC::dateProtoFuncGetUTCMinutes): Ditto. (JSC::dateProtoFuncGetSeconds): Ditto. (JSC::dateProtoFuncGetUTCSeconds): Ditto. (JSC::dateProtoFuncGetMilliSeconds): Ditto. (JSC::dateProtoFuncGetUTCMilliseconds): Ditto. (JSC::dateProtoFuncGetTimezoneOffset): Ditto. (JSC::dateProtoFuncSetTime): Ditto. (JSC::setNewValueFromTimeArgs): Ditto. (JSC::setNewValueFromDateArgs): Ditto. (JSC::dateProtoFuncSetYear): Ditto. (JSC::dateProtoFuncGetYear): Ditto.
  • kjs/DebuggerCallFrame.cpp: (JSC::DebuggerCallFrame::thisObject): Use asObject. (JSC::DebuggerCallFrame::evaluate): Use noValue.
  • kjs/DebuggerCallFrame.h: Added a constructor that takes only a callFrame.
  • kjs/ExecState.h: (JSC::ExecState::clearException): Use noValue.
  • kjs/FunctionPrototype.cpp: (JSC::functionProtoFuncToString): Use asFunction. (JSC::functionProtoFuncApply): Use asArguments and asArray.
  • kjs/GetterSetter.cpp: (JSC::GetterSetter::getPrimitiveNumber): Use noValue.
  • kjs/GetterSetter.h: (JSC::asGetterSetter): Added.
  • kjs/InternalFunction.cpp: (JSC::InternalFunction::name): Use asString.
  • kjs/InternalFunction.h: (JSC::asInternalFunction): Added.
  • kjs/JSActivation.cpp: (JSC::JSActivation::argumentsGetter): Use asActivation.
  • kjs/JSActivation.h: (JSC::asActivation): Added.
  • kjs/JSArray.cpp: (JSC::JSArray::putSlowCase): Use noValue. (JSC::JSArray::deleteProperty): Ditto. (JSC::JSArray::increaseVectorLength): Ditto. (JSC::JSArray::setLength): Ditto. (JSC::JSArray::pop): Ditto. (JSC::JSArray::sort): Ditto. (JSC::JSArray::compactForSorting): Ditto.
  • kjs/JSArray.h: (JSC::asArray): Added.
  • kjs/JSCell.cpp: (JSC::JSCell::getJSNumber): Use noValue.
  • kjs/JSCell.h: (JSC::asCell): Added. (JSC::JSValue::asCell): Changed to not preserve const. Given the wide use of JSValue* and JSCell*, it's not really useful to use const. (JSC::JSValue::isNumber): Use asValue. (JSC::JSValue::isString): Ditto. (JSC::JSValue::isGetterSetter): Ditto. (JSC::JSValue::isObject): Ditto. (JSC::JSValue::getNumber): Ditto. (JSC::JSValue::getString): Ditto. (JSC::JSValue::getObject): Ditto. (JSC::JSValue::getCallData): Ditto. (JSC::JSValue::getConstructData): Ditto. (JSC::JSValue::getUInt32): Ditto. (JSC::JSValue::getTruncatedInt32): Ditto. (JSC::JSValue::getTruncatedUInt32): Ditto. (JSC::JSValue::mark): Ditto. (JSC::JSValue::marked): Ditto. (JSC::JSValue::toPrimitive): Ditto. (JSC::JSValue::getPrimitiveNumber): Ditto. (JSC::JSValue::toBoolean): Ditto. (JSC::JSValue::toNumber): Ditto. (JSC::JSValue::toString): Ditto. (JSC::JSValue::toObject): Ditto. (JSC::JSValue::toThisObject): Ditto. (JSC::JSValue::needsThisConversion): Ditto. (JSC::JSValue::toThisString): Ditto. (JSC::JSValue::getJSNumber): Ditto.
  • kjs/JSFunction.cpp: (JSC::JSFunction::argumentsGetter): Use asFunction. (JSC::JSFunction::callerGetter): Ditto. (JSC::JSFunction::lengthGetter): Ditto. (JSC::JSFunction::construct): Use asObject.
  • kjs/JSFunction.h: (JSC::asFunction): Added.
  • kjs/JSGlobalObject.cpp: (JSC::lastInPrototypeChain): Use asObject.
  • kjs/JSGlobalObject.h: (JSC::asGlobalObject): Added. (JSC::ScopeChainNode::globalObject): Use asGlobalObject.
  • kjs/JSImmediate.h: Added noValue, asPointer, and makeValue functions. Use rawValue, makeValue, and noValue consistently instead of doing reinterpret_cast in various functions.
  • kjs/JSNumberCell.h: (JSC::asNumberCell): Added. (JSC::JSValue::uncheckedGetNumber): Use asValue and asNumberCell. (JSC::JSValue::toJSNumber): Use asValue.
  • kjs/JSObject.cpp: (JSC::JSObject::put): Use asObject and asGetterSetter. (JSC::callDefaultValueFunction): Use noValue. (JSC::JSObject::defineGetter): Use asGetterSetter. (JSC::JSObject::defineSetter): Ditto. (JSC::JSObject::lookupGetter): Ditto. Also use asObject. (JSC::JSObject::lookupSetter): Ditto. (JSC::JSObject::hasInstance): Use asObject. (JSC::JSObject::fillGetterPropertySlot): Use asGetterSetter.
  • kjs/JSObject.h: (JSC::JSObject::getDirect): Use noValue. (JSC::asObject): Added. (JSC::JSValue::isObject): Use asValue. (JSC::JSObject::get): Removed unneeded const_cast. (JSC::JSObject::getPropertySlot): Use asObject. (JSC::JSValue::get): Removed unneeded const_cast. Use asValue, asCell, and asObject. (JSC::JSValue::put): Ditto. (JSC::JSObject::allocatePropertyStorageInline): Fixed spelling of "oldPropertStorage".
  • kjs/JSString.cpp: (JSC::JSString::getOwnPropertySlot): Use asObject.
  • kjs/JSString.h: (JSC::asString): Added. (JSC::JSValue::toThisJSString): Use asValue.
  • kjs/JSValue.h: Make PreferredPrimitiveType a top level enum instead of a member of JSValue. Added an asValue function that returns this. Removed overload of asCell for const. Use asValue instead of getting right at this.
  • kjs/ObjectPrototype.cpp: (JSC::objectProtoFuncIsPrototypeOf): Use asObject. (JSC::objectProtoFuncDefineGetter): Ditto. (JSC::objectProtoFuncDefineSetter): Ditto.
  • kjs/PropertySlot.h: (JSC::PropertySlot::PropertySlot): Take a const JSValue* so the callers don't have to worry about const. (JSC::PropertySlot::clearBase): Use noValue. (JSC::PropertySlot::clearValue): Ditto.
  • kjs/RegExpConstructor.cpp: (JSC::regExpConstructorDollar1): Use asRegExpConstructor. (JSC::regExpConstructorDollar2): Ditto. (JSC::regExpConstructorDollar3): Ditto. (JSC::regExpConstructorDollar4): Ditto. (JSC::regExpConstructorDollar5): Ditto. (JSC::regExpConstructorDollar6): Ditto. (JSC::regExpConstructorDollar7): Ditto. (JSC::regExpConstructorDollar8): Ditto. (JSC::regExpConstructorDollar9): Ditto. (JSC::regExpConstructorInput): Ditto. (JSC::regExpConstructorMultiline): Ditto. (JSC::regExpConstructorLastMatch): Ditto. (JSC::regExpConstructorLastParen): Ditto. (JSC::regExpConstructorLeftContext): Ditto. (JSC::regExpConstructorRightContext): Ditto. (JSC::setRegExpConstructorInput): Ditto. (JSC::setRegExpConstructorMultiline): Ditto. (JSC::constructRegExp): Use asObject.
  • kjs/RegExpConstructor.h: (JSC::asRegExpConstructor): Added.
  • kjs/RegExpObject.cpp: (JSC::regExpObjectGlobal): Use asRegExpObject. (JSC::regExpObjectIgnoreCase): Ditto. (JSC::regExpObjectMultiline): Ditto. (JSC::regExpObjectSource): Ditto. (JSC::regExpObjectLastIndex): Ditto. (JSC::setRegExpObjectLastIndex): Ditto. (JSC::callRegExpObject): Ditto.
  • kjs/RegExpObject.h: (JSC::asRegExpObject): Added.
  • kjs/RegExpPrototype.cpp: (JSC::regExpProtoFuncTest): Use asRegExpObject. (JSC::regExpProtoFuncExec): Ditto. (JSC::regExpProtoFuncCompile): Ditto. (JSC::regExpProtoFuncToString): Ditto.
  • kjs/StringObject.h: (JSC::StringObject::internalValue): Use asString. (JSC::asStringObject): Added.
  • kjs/StringPrototype.cpp: (JSC::stringProtoFuncReplace): Use asRegExpObject. (JSC::stringProtoFuncToString): Ue asStringObject. (JSC::stringProtoFuncMatch): Use asRegExpObject. (JSC::stringProtoFuncSearch): Ditto. (JSC::stringProtoFuncSplit): Ditto.
  • kjs/StructureID.cpp: (JSC::StructureID::getEnumerablePropertyNames): Use asObject. (JSC::StructureID::createCachedPrototypeChain): Ditto. (JSC::StructureIDChain::StructureIDChain): Use asCell and asObject.
  • kjs/collector.h: (JSC::Heap::isNumber): Removed null handling. This can only be called on valid cells. (JSC::Heap::cellBlock): Removed overload for const and non-const. Whether the JSCell* is const or not really should have no effect on whether you can modify the collector block it's in.
  • kjs/interpreter.cpp: (JSC::Interpreter::evaluate): Use noValue and noObject.
  • kjs/nodes.cpp: (JSC::FunctionCallResolveNode::emitCode): Use JSObject for the global object rather than JSValue. (JSC::PostfixResolveNode::emitCode): Ditto. (JSC::PrefixResolveNode::emitCode): Ditto. (JSC::ReadModifyResolveNode::emitCode): Ditto. (JSC::AssignResolveNode::emitCode): Ditto.
  • kjs/operations.h: (JSC::equalSlowCaseInline): Use asString, asCell, asNumberCell, (JSC::strictEqualSlowCaseInline): Ditto.

WebCore:

2008-10-18 Darin Adler <Darin Adler>

Reviewed by Oliver Hunt.

Update for change to make PreferredPrimitiveType no longer
a member of JSValue.

  • bridge/c/c_instance.cpp: (JSC::Bindings::CInstance::defaultValue): Removed JSValue:: prefix.
  • bridge/jni/jni_instance.cpp: (JavaInstance::defaultValue): Ditto.
  • bridge/objc/objc_instance.mm: (ObjcInstance::defaultValue): Ditto.
  • bridge/qt/qt_instance.cpp: (JSC::Bindings::QtInstance::defaultValue): Ditto.
  • bridge/runtime.h: Ditto. Also removed typedef.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/JSImmediate.h

    r36802 r37681  
    3939    class UString;
    4040
     41    inline JSValue* noValue() { return 0; }
     42    inline void* asPointer(JSValue* value) { return value; }
     43
    4144    /*
    4245     * A JSValue* is either a pointer to a cell (a heap-allocated object) or an immediate (a type-tagged
     
    106109        static ALWAYS_INLINE bool isImmediate(const JSValue* v)
    107110        {
    108             return reinterpret_cast<uintptr_t>(v) & TagMask;
     111            return rawValue(v) & TagMask;
    109112        }
    110113       
    111114        static ALWAYS_INLINE bool isNumber(const JSValue* v)
    112115        {
    113             return reinterpret_cast<uintptr_t>(v) & TagBitTypeInteger;
     116            return rawValue(v) & TagBitTypeInteger;
    114117        }
    115118
     
    117120        {
    118121            // A single mask to check for the sign bit and the number tag all at once.
    119             return (reinterpret_cast<uintptr_t>(v) & (0x80000000 | TagBitTypeInteger)) == TagBitTypeInteger;
     122            return (rawValue(v) & (0x80000000 | TagBitTypeInteger)) == TagBitTypeInteger;
    120123        }
    121124       
    122125        static ALWAYS_INLINE bool isBoolean(const JSValue* v)
    123126        {
    124             return (reinterpret_cast<uintptr_t>(v) & FullTagTypeMask) == FullTagTypeBool;
     127            return (rawValue(v) & FullTagTypeMask) == FullTagTypeBool;
    125128        }
    126129       
     
    128131        {
    129132            // Undefined and null share the same value, bar the 'undefined' bit in the extended tag.
    130             return (reinterpret_cast<uintptr_t>(v) & ~ExtendedTagBitUndefined) == FullTagTypeNull;
     133            return (rawValue(v) & ~ExtendedTagBitUndefined) == FullTagTypeNull;
    131134        }
    132135
     
    134137        {
    135138            ASSERT(isNumber(v));
    136             return reinterpret_cast<uintptr_t>(v) & 0x80000000;
     139            return rawValue(v) & 0x80000000;
    137140        }
    138141
     
    152155        static ALWAYS_INLINE bool isEitherImmediate(const JSValue* v1, const JSValue* v2)
    153156        {
    154             return (reinterpret_cast<uintptr_t>(v1) | reinterpret_cast<uintptr_t>(v2)) & TagMask;
     157            return (rawValue(v1) | rawValue(v2)) & TagMask;
    155158        }
    156159
    157160        static ALWAYS_INLINE bool isAnyImmediate(const JSValue* v1, const JSValue* v2, JSValue* v3)
    158161        {
    159             return (reinterpret_cast<uintptr_t>(v1) | reinterpret_cast<uintptr_t>(v2) | reinterpret_cast<uintptr_t>(v3)) & TagMask;
     162            return (rawValue(v1) | rawValue(v2) | rawValue(v3)) & TagMask;
    160163        }
    161164
     
    167170        static ALWAYS_INLINE bool areBothImmediateNumbers(const JSValue* v1, const JSValue* v2)
    168171        {
    169             return reinterpret_cast<uintptr_t>(v1) & reinterpret_cast<uintptr_t>(v2) & TagBitTypeInteger;
     172            return rawValue(v1) & rawValue(v2) & TagBitTypeInteger;
    170173        }
    171174
     
    173176        {
    174177            ASSERT(areBothImmediateNumbers(v1, v2));
    175             return reinterpret_cast<JSValue*>(reinterpret_cast<uintptr_t>(v1) & reinterpret_cast<uintptr_t>(v2));
     178            return makeValue(rawValue(v1) & rawValue(v2));
    176179        }
    177180
     
    179182        {
    180183            ASSERT(areBothImmediateNumbers(v1, v2));
    181             return reinterpret_cast<JSValue*>((reinterpret_cast<uintptr_t>(v1) ^ reinterpret_cast<uintptr_t>(v2)) | TagBitTypeInteger);
     184            return makeValue((rawValue(v1) ^ rawValue(v2)) | TagBitTypeInteger);
    182185        }
    183186
     
    185188        {
    186189            ASSERT(areBothImmediateNumbers(v1, v2));
    187             return reinterpret_cast<JSValue*>(reinterpret_cast<uintptr_t>(v1) | reinterpret_cast<uintptr_t>(v2));
     190            return makeValue(rawValue(v1) | rawValue(v2));
    188191        }
    189192
     
    191194        {
    192195            ASSERT(areBothImmediateNumbers(val, shift));
    193             return reinterpret_cast<JSValue*>((reinterpret_cast<intptr_t>(val) >> ((reinterpret_cast<uintptr_t>(shift) >> IntegerPayloadShift) & 0x1f)) | TagBitTypeInteger);
     196            return makeValue((static_cast<intptr_t>(rawValue(val)) >> ((rawValue(shift) >> IntegerPayloadShift) & 0x1f)) | TagBitTypeInteger);
    194197        }
    195198
     
    198201            // Number is non-negative and an operation involving two of these can't overflow.
    199202            // Checking for allowed negative numbers takes more time than it's worth on SunSpider.
    200             return (reinterpret_cast<uintptr_t>(v) & (TagBitTypeInteger + (3u << 30))) == TagBitTypeInteger;
     203            return (rawValue(v) & (TagBitTypeInteger + (3u << 30))) == TagBitTypeInteger;
    201204        }
    202205
     
    205208            ASSERT(canDoFastAdditiveOperations(v1));
    206209            ASSERT(canDoFastAdditiveOperations(v2));
    207             return reinterpret_cast<JSValue*>(reinterpret_cast<uintptr_t>(v1) + reinterpret_cast<uintptr_t>(v2) - TagBitTypeInteger);
     210            return makeValue(rawValue(v1) + rawValue(v2) - TagBitTypeInteger);
    208211        }
    209212
     
    212215            ASSERT(canDoFastAdditiveOperations(v1));
    213216            ASSERT(canDoFastAdditiveOperations(v2));
    214             return reinterpret_cast<JSValue*>(reinterpret_cast<uintptr_t>(v1) - reinterpret_cast<uintptr_t>(v2) + TagBitTypeInteger);
     217            return makeValue(rawValue(v1) - rawValue(v2) + TagBitTypeInteger);
    215218        }
    216219
     
    218221        {
    219222            ASSERT(canDoFastAdditiveOperations(v));
    220             return reinterpret_cast<JSValue*>(reinterpret_cast<uintptr_t>(v) + (1 << IntegerPayloadShift));
     223            return makeValue(rawValue(v) + (1 << IntegerPayloadShift));
    221224        }
    222225
     
    224227        {
    225228            ASSERT(canDoFastAdditiveOperations(v));
    226             return reinterpret_cast<JSValue*>(reinterpret_cast<uintptr_t>(v) - (1 << IntegerPayloadShift));
     229            return makeValue(rawValue(v) - (1 << IntegerPayloadShift));
    227230        }
    228231
     
    254257        static const int maxImmediateInt = INT_MAX >> IntegerPayloadShift;
    255258        static const unsigned maxImmediateUInt = maxImmediateInt;
    256        
     259
     260        static ALWAYS_INLINE JSValue* makeValue(uintptr_t integer)
     261        {
     262            return reinterpret_cast<JSValue*>(integer);
     263        }
     264
    257265        static ALWAYS_INLINE JSValue* makeInt(int32_t value)
    258266        {
    259             return reinterpret_cast<JSValue*>((value << IntegerPayloadShift) | TagBitTypeInteger);
     267            return makeValue((value << IntegerPayloadShift) | TagBitTypeInteger);
    260268        }
    261269       
    262270        static ALWAYS_INLINE JSValue* makeBool(bool b)
    263271        {
    264             return reinterpret_cast<JSValue*>((static_cast<uintptr_t>(b) << ExtendedPayloadShift) | FullTagTypeBool);
     272            return makeValue((static_cast<uintptr_t>(b) << ExtendedPayloadShift) | FullTagTypeBool);
    265273        }
    266274       
    267275        static ALWAYS_INLINE JSValue* makeUndefined()
    268276        {
    269             return reinterpret_cast<JSValue*>(FullTagTypeUndefined);
     277            return makeValue(FullTagTypeUndefined);
    270278        }
    271279       
    272280        static ALWAYS_INLINE JSValue* makeNull()
    273281        {
    274             return reinterpret_cast<JSValue*>(FullTagTypeNull);
     282            return makeValue(FullTagTypeNull);
    275283        }
    276284       
    277285        static ALWAYS_INLINE int32_t intValue(const JSValue* v)
    278286        {
    279             return static_cast<int32_t>(reinterpret_cast<intptr_t>(v) >> IntegerPayloadShift);
     287            return static_cast<int32_t>(static_cast<intptr_t>(rawValue(v)) >> IntegerPayloadShift);
    280288        }
    281289       
     
    306314
    307315    // This value is impossible because 0x4 is not a valid pointer but a tag of 0 would indicate non-immediate
    308     ALWAYS_INLINE JSValue* JSImmediate::impossibleValue() { return reinterpret_cast<JSValue*>(0x4); }
     316    ALWAYS_INLINE JSValue* JSImmediate::impossibleValue() { return makeValue(0x4); }
    309317
    310318    ALWAYS_INLINE bool JSImmediate::toBoolean(const JSValue* v)
     
    351359    {
    352360        if ((i < minImmediateInt) | (i > maxImmediateInt))
    353             return 0;
     361            return noValue();
    354362        return makeInt(i);
    355363    }
     
    358366    {
    359367        if (i > maxImmediateUInt)
    360             return 0;
     368            return noValue();
    361369        return makeInt(i);
    362370    }
     
    365373    {
    366374        if ((i < minImmediateInt) | (i > maxImmediateInt))
    367             return 0;
     375            return noValue();
    368376        return makeInt(i);
    369377    }
     
    372380    {
    373381        if (i > maxImmediateUInt)
    374             return 0;
     382            return noValue();
    375383        return makeInt(i);
    376384    }
     
    379387    {
    380388        if ((i < minImmediateInt) | (i > maxImmediateInt))
    381             return 0;
     389            return noValue();
    382390        return makeInt(static_cast<uintptr_t>(i));
    383391    }
     
    386394    {
    387395        if (i > maxImmediateUInt)
    388             return 0;
     396            return noValue();
    389397        return makeInt(static_cast<uintptr_t>(i));
    390398    }
     
    395403
    396404        if ((intVal < minImmediateInt) | (intVal > maxImmediateInt))
    397             return 0;
     405            return noValue();
    398406
    399407        // Check for data loss from conversion to int.
    400408        if (intVal != d || (!intVal && signbit(d)))
    401             return 0;
     409            return noValue();
    402410
    403411        return makeInt(intVal);
Note: See TracChangeset for help on using the changeset viewer.