Commit 5a49442f authored by darin@apple.com's avatar darin@apple.com

JavaScriptCore:

2008-10-18  Darin Adler  <darin@apple.com>

        Reviewed by Oliver Hunt.

        - first step of https://bugs.webkit.org/show_bug.cgi?id=21732
          improve performance by eliminating JSValue as a base class for JSCell

        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.exp: Updated.

        * 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@apple.com>

        Reviewed by Oliver Hunt.

        - first step of https://bugs.webkit.org/show_bug.cgi?id=21732
          improve performance by eliminating JSValue as a base class for JSCell

        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.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@37681 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 9c9096fd
......@@ -29,13 +29,6 @@
#include "ustring.h"
#include "ExecState.h"
namespace JSC {
class ExecState;
class JSValue;
class JSObject;
class PropertyNameArray;
}
typedef const struct OpaqueJSContextGroup* JSContextGroupRef;
typedef const struct OpaqueJSContext* JSContextRef;
typedef struct OpaqueJSContext* JSGlobalContextRef;
......
......@@ -77,6 +77,8 @@ private:
void init(ExecState*);
static JSCallbackObject* asCallbackObject(JSValue*);
static JSValue* call(ExecState*, JSObject* functionObject, JSValue* thisValue, const ArgList&);
static JSObject* construct(ExecState*, JSObject* constructor, const ArgList&);
......
......@@ -39,6 +39,13 @@
namespace JSC {
template <class Base>
inline JSCallbackObject<Base>* JSCallbackObject<Base>::asCallbackObject(JSValue* value)
{
ASSERT(asObject(value)->inherits(&info));
return static_cast<JSCallbackObject*>(asObject(value));
}
template <class Base>
JSCallbackObject<Base>::JSCallbackObject(ExecState* exec, PassRefPtr<StructureID> structure, JSClassRef jsClass, void* data)
: Base(structure)
......@@ -123,7 +130,7 @@ bool JSCallbackObject<Base>::getOwnPropertySlot(ExecState* exec, const Identifie
// cache the value so we don't have to compute it again
// FIXME: This violates the PropertySlot design a little bit.
// We should either use this optimization everywhere, or nowhere.
slot.setCustom(reinterpret_cast<JSObject*>(toJS(value)), cachedValueGetter);
slot.setCustom(asObject(toJS(value)), cachedValueGetter);
return true;
}
}
......@@ -318,7 +325,7 @@ JSValue* JSCallbackObject<Base>::call(ExecState* exec, JSObject* functionObject,
}
ASSERT_NOT_REACHED(); // getCallData should prevent us from reaching here
return 0;
return noValue();
}
template <class Base>
......@@ -433,8 +440,7 @@ JSValue* JSCallbackObject<Base>::cachedValueGetter(ExecState*, const Identifier&
template <class Base>
JSValue* JSCallbackObject<Base>::staticValueGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
{
ASSERT(slot.slotBase()->isObject(&JSCallbackObject::info));
JSCallbackObject* thisObj = static_cast<JSCallbackObject*>(slot.slotBase());
JSCallbackObject* thisObj = asCallbackObject(slot.slotBase());
JSObjectRef thisRef = toRef(thisObj);
RefPtr<OpaqueJSString> propertyNameRef;
......@@ -456,8 +462,7 @@ JSValue* JSCallbackObject<Base>::staticValueGetter(ExecState* exec, const Identi
template <class Base>
JSValue* JSCallbackObject<Base>::staticFunctionGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
{
ASSERT(slot.slotBase()->isObject(&JSCallbackObject::info));
JSCallbackObject* thisObj = static_cast<JSCallbackObject*>(slot.slotBase());
JSCallbackObject* thisObj = asCallbackObject(slot.slotBase());
// Check for cached or override property.
PropertySlot slot2(thisObj);
......@@ -482,8 +487,7 @@ JSValue* JSCallbackObject<Base>::staticFunctionGetter(ExecState* exec, const Ide
template <class Base>
JSValue* JSCallbackObject<Base>::callbackGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
{
ASSERT(slot.slotBase()->isObject(&JSCallbackObject::info));
JSCallbackObject* thisObj = static_cast<JSCallbackObject*>(slot.slotBase());
JSCallbackObject* thisObj = asCallbackObject(slot.slotBase());
JSObjectRef thisRef = toRef(thisObj);
RefPtr<OpaqueJSString> propertyNameRef;
......
This diff is collapsed.
......@@ -337,7 +337,7 @@ __ZNK3JSC7UString8toUInt32EPb
__ZNK3JSC7UString8toUInt32EPbb
__ZNK3JSC8JSObject11hasPropertyEPNS_9ExecStateERKNS_10IdentifierE
__ZNK3JSC8JSObject11hasPropertyEPNS_9ExecStateEj
__ZNK3JSC8JSObject12defaultValueEPNS_9ExecStateENS_7JSValue22PreferredPrimitiveTypeE
__ZNK3JSC8JSObject12defaultValueEPNS_9ExecStateENS_22PreferredPrimitiveTypeE
__ZNK3JSC8JSObject12toThisObjectEPNS_9ExecStateE
__ZNK3JSC8JSObject14toGlobalObjectEPNS_9ExecStateE
__ZNK3JSC8JSObject21getPropertyAttributesEPNS_9ExecStateERKNS_10IdentifierERj
......
......@@ -554,6 +554,7 @@
93AA4F770957251F0084B3A7 /* AlwaysInline.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = AlwaysInline.h; sourceTree = "<group>"; tabWidth = 8; };
93ADFCE60CCBD7AC00D30B08 /* JSArray.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSArray.cpp; sourceTree = "<group>"; };
93B6A0DE0AA64DA40076DE27 /* GetPtr.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = GetPtr.h; sourceTree = "<group>"; };
93CEDDFB0EA91EE600258EBE /* RegExpMatchesArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegExpMatchesArray.h; sourceTree = "<group>"; };
93E26BD308B1514100F85226 /* pcre_xclass.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; name = pcre_xclass.cpp; path = pcre/pcre_xclass.cpp; sourceTree = "<group>"; tabWidth = 8; };
93E26BE508B1517100F85226 /* pcre_internal.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; name = pcre_internal.h; path = pcre/pcre_internal.h; sourceTree = "<group>"; tabWidth = 8; };
93E26BFC08B151D400F85226 /* ucpinternal.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; name = ucpinternal.h; path = pcre/ucpinternal.h; sourceTree = "<group>"; tabWidth = 8; };
......@@ -1203,6 +1204,7 @@
F692A87E0255597D01FF60F7 /* regexp.h */,
BCD202BD0E1706A7002C7E82 /* RegExpConstructor.cpp */,
BCD202BE0E1706A7002C7E82 /* RegExpConstructor.h */,
93CEDDFB0EA91EE600258EBE /* RegExpMatchesArray.h */,
F692A87B0255597D01FF60F7 /* RegExpObject.cpp */,
F692A87C0255597D01FF60F7 /* RegExpObject.h */,
BCD202BF0E1706A7002C7E82 /* RegExpPrototype.cpp */,
......
This diff is collapsed.
......@@ -44,42 +44,43 @@
#define CTI_ARGS_exception 0x0F
#define CTI_ARGS_profilerReference 0x10
#define CTI_ARGS_globalData 0x11
#define ARG_callFrame ((CallFrame*)(ARGS)[CTI_ARGS_callFrame])
#define ARG_registerFile ((RegisterFile*)(ARGS)[CTI_ARGS_registerFile])
#define ARG_exception ((JSValue**)(ARGS)[CTI_ARGS_exception])
#define ARG_profilerReference ((Profiler**)(ARGS)[CTI_ARGS_profilerReference])
#define ARG_globalData ((JSGlobalData*)(ARGS)[CTI_ARGS_globalData])
#define ARG_setCallFrame(newCallFrame) (*(CallFrame**)&(ARGS)[CTI_ARGS_callFrame] = (newCallFrame))
#define ARG_src1 ((JSValue*)((ARGS)[1]))
#define ARG_src2 ((JSValue*)((ARGS)[2]))
#define ARG_src3 ((JSValue*)((ARGS)[3]))
#define ARG_src4 ((JSValue*)((ARGS)[4]))
#define ARG_src5 ((JSValue*)((ARGS)[5]))
#define ARG_id1 ((Identifier*)((ARGS)[1]))
#define ARG_id2 ((Identifier*)((ARGS)[2]))
#define ARG_id3 ((Identifier*)((ARGS)[3]))
#define ARG_id4 ((Identifier*)((ARGS)[4]))
#define ARG_int1 ((int)((ARGS)[1]))
#define ARG_int2 ((int)((ARGS)[2]))
#define ARG_int3 ((int)((ARGS)[3]))
#define ARG_int4 ((int)((ARGS)[4]))
#define ARG_int5 ((int)((ARGS)[5]))
#define ARG_int6 ((int)((ARGS)[6]))
#define ARG_func1 ((FuncDeclNode*)((ARGS)[1]))
#define ARG_funcexp1 ((FuncExprNode*)((ARGS)[1]))
#define ARG_registers1 ((Register*)((ARGS)[1]))
#define ARG_regexp1 ((RegExp*)((ARGS)[1]))
#define ARG_pni1 ((JSPropertyNameIterator*)((ARGS)[1]))
#define ARG_instr1 ((Instruction*)((ARGS)[1]))
#define ARG_instr2 ((Instruction*)((ARGS)[2]))
#define ARG_instr3 ((Instruction*)((ARGS)[3]))
#define ARG_instr4 ((Instruction*)((ARGS)[4]))
#define ARG_instr5 ((Instruction*)((ARGS)[5]))
#define ARG_instr6 ((Instruction*)((ARGS)[6]))
#define CTI_RETURN_ADDRESS_SLOT ((ARGS)[-1])
#define ARG_callFrame static_cast<CallFrame*>(ARGS[CTI_ARGS_callFrame])
#define ARG_registerFile static_cast<RegisterFile*>(ARGS[CTI_ARGS_registerFile])
#define ARG_exception static_cast<JSValue**>(ARGS[CTI_ARGS_exception])
#define ARG_profilerReference static_cast<Profiler**>(ARGS[CTI_ARGS_profilerReference])
#define ARG_globalData static_cast<JSGlobalData*>(ARGS[CTI_ARGS_globalData])
#define ARG_setCallFrame(newCallFrame) (ARGS[CTI_ARGS_callFrame] = (newCallFrame))
#define ARG_src1 static_cast<JSValue*>(ARGS[1])
#define ARG_src2 static_cast<JSValue*>(ARGS[2])
#define ARG_src3 static_cast<JSValue*>(ARGS[3])
#define ARG_src4 static_cast<JSValue*>(ARGS[4])
#define ARG_src5 static_cast<JSValue*>(ARGS[5])
#define ARG_id1 static_cast<Identifier*>(ARGS[1])
#define ARG_id2 static_cast<Identifier*>(ARGS[2])
#define ARG_id3 static_cast<Identifier*>(ARGS[3])
#define ARG_id4 static_cast<Identifier*>(ARGS[4])
#define ARG_int1 reinterpret_cast<intptr_t>(ARGS[1])
#define ARG_int2 reinterpret_cast<intptr_t>(ARGS[2])
#define ARG_int3 reinterpret_cast<intptr_t>(ARGS[3])
#define ARG_int4 reinterpret_cast<intptr_t>(ARGS[4])
#define ARG_int5 reinterpret_cast<intptr_t>(ARGS[5])
#define ARG_int6 reinterpret_cast<intptr_t>(ARGS[6])
#define ARG_func1 static_cast<FuncDeclNode*>(ARGS[1])
#define ARG_funcexp1 static_cast<FuncExprNode*>(ARGS[1])
#define ARG_registers1 static_cast<Register*>(ARGS[1])
#define ARG_regexp1 static_cast<RegExp*>(ARGS[1])
#define ARG_pni1 static_cast<JSPropertyNameIterator*>(ARGS[1])
#define ARG_instr1 static_cast<Instruction*>(ARGS[1])
#define ARG_instr2 static_cast<Instruction*>(ARGS[2])
#define ARG_instr3 static_cast<Instruction*>(ARGS[3])
#define ARG_instr4 static_cast<Instruction*>(ARGS[4])
#define ARG_instr5 static_cast<Instruction*>(ARGS[5])
#define ARG_instr6 static_cast<Instruction*>(ARGS[6])
#define CTI_RETURN_ADDRESS_SLOT (ARGS[-1])
namespace JSC {
......@@ -93,6 +94,7 @@ namespace JSC {
class SimpleJumpTable;
class StringJumpTable;
class StructureIDChain;
struct Instruction;
struct OperandTypes;
struct StructureStubInfo;
......@@ -335,7 +337,9 @@ namespace JSC {
private:
CTI(Machine*, CallFrame*, CodeBlock*);
static uintptr_t asInteger(JSValue*);
bool isConstant(int src);
JSValue* getConstant(CallFrame*, int src);
......
......@@ -719,7 +719,7 @@ RegisterID* CodeGenerator::emitEqualityOp(OpcodeID opcode, RegisterID* dst, Regi
&& src1->isTemporary()
&& static_cast<unsigned>(src2->index()) < m_codeBlock->constantRegisters.size()
&& m_codeBlock->constantRegisters[src2->index()].jsValue(m_scopeChain->globalObject()->globalExec())->isString()) {
const UString& value = static_cast<JSString*>(m_codeBlock->constantRegisters[src2->index()].jsValue(m_scopeChain->globalObject()->globalExec()))->value();
const UString& value = asString(m_codeBlock->constantRegisters[src2->index()].jsValue(m_scopeChain->globalObject()->globalExec()))->value();
if (value == "undefined") {
rewindUnaryOp();
emitOpcode(op_is_undefined);
......@@ -783,7 +783,7 @@ RegisterID* CodeGenerator::emitLoad(RegisterID* dst, double number)
// Later we can do the extra work to handle that like the other cases.
if (number == HashTraits<double>::emptyValue() || HashTraits<double>::isDeletedValue(number))
return emitLoad(dst, jsNumber(globalData(), number));
JSValue*& valueInMap = m_numberMap.add(number, 0).first->second;
JSValue*& valueInMap = m_numberMap.add(number, noValue()).first->second;
if (!valueInMap)
valueInMap = jsNumber(globalData(), number);
return emitLoad(dst, valueInMap);
......@@ -821,9 +821,9 @@ RegisterID* CodeGenerator::emitUnexpectedLoad(RegisterID* dst, double d)
return dst;
}
bool CodeGenerator::findScopedProperty(const Identifier& property, int& index, size_t& stackDepth, bool forWriting, JSValue*& globalObject)
bool CodeGenerator::findScopedProperty(const Identifier& property, int& index, size_t& stackDepth, bool forWriting, JSObject*& globalObject)
{
// Cases where we cannot statically optimise the lookup
// Cases where we cannot statically optimize the lookup.
if (property == propertyNames().arguments || !canOptimizeNonLocals()) {
stackDepth = 0;
index = missingSymbolMarker();
......@@ -866,7 +866,7 @@ bool CodeGenerator::findScopedProperty(const Identifier& property, int& index, s
break;
}
// Can't locate the property but we're able to avoid a few lookups
// Can't locate the property but we're able to avoid a few lookups.
stackDepth = depth;
index = missingSymbolMarker();
JSObject* scope = *iter;
......@@ -889,7 +889,7 @@ RegisterID* CodeGenerator::emitResolve(RegisterID* dst, const Identifier& proper
{
size_t depth = 0;
int index = 0;
JSValue* globalObject = 0;
JSObject* globalObject = 0;
if (!findScopedProperty(property, index, depth, false, globalObject) && !globalObject) {
// We can't optimise at all :-(
emitOpcode(op_resolve);
......@@ -907,7 +907,7 @@ RegisterID* CodeGenerator::emitResolve(RegisterID* dst, const Identifier& proper
m_codeBlock->structureIDInstructions.append(instructions().size());
emitOpcode(op_resolve_global);
instructions().append(dst->index());
instructions().append(static_cast<JSCell*>(globalObject));
instructions().append(globalObject);
instructions().append(addConstant(property));
instructions().append(0);
instructions().append(0);
......@@ -928,7 +928,7 @@ RegisterID* CodeGenerator::emitGetScopedVar(RegisterID* dst, size_t depth, int i
if (globalObject) {
emitOpcode(op_get_global_var);
instructions().append(dst->index());
instructions().append(static_cast<JSCell*>(globalObject));
instructions().append(asCell(globalObject));
instructions().append(index);
return dst;
}
......@@ -944,7 +944,7 @@ RegisterID* CodeGenerator::emitPutScopedVar(size_t depth, int index, RegisterID*
{
if (globalObject) {
emitOpcode(op_put_global_var);
instructions().append(static_cast<JSCell*>(globalObject));
instructions().append(asCell(globalObject));
instructions().append(index);
instructions().append(value->index());
return value;
......
......@@ -102,7 +102,7 @@ namespace JSC {
//
// NB: depth does _not_ include the local scope. eg. a depth of 0 refers
// to the scope containing this codeblock.
bool findScopedProperty(const Identifier&, int& index, size_t& depth, bool forWriting, JSValue*& globalObject);
bool findScopedProperty(const Identifier&, int& index, size_t& depth, bool forWriting, JSObject*& globalObject);
// Returns the register storing "this"
RegisterID* thisRegister() { return &m_thisRegister; }
......@@ -328,12 +328,13 @@ namespace JSC {
void rewindUnaryOp();
PassRefPtr<LabelID> emitComplexJumpScopes(LabelID* target, ControlFlowContext* topScope, ControlFlowContext* bottomScope);
struct JSValueHashTraits : HashTraits<JSValue*> {
static void constructDeletedValue(JSValue*& slot) { slot = JSImmediate::impossibleValue(); }
static bool isDeletedValue(JSValue* value) { return value == JSImmediate::impossibleValue(); }
};
typedef HashMap<JSValue*, unsigned, DefaultHash<JSValue*>::Hash, JSValueHashTraits> JSValueMap;
typedef HashMap<JSValue*, unsigned, PtrHash<JSValue*>, JSValueHashTraits> JSValueMap;
struct IdentifierMapIndexHashTraits {
typedef int TraitType;
......
......@@ -40,7 +40,7 @@ JSPropertyNameIterator::~JSPropertyNameIterator()
JSValue* JSPropertyNameIterator::toPrimitive(ExecState*, PreferredPrimitiveType) const
{
ASSERT_NOT_REACHED();
return 0;
return noValue();
}
bool JSPropertyNameIterator::getPrimitiveNumber(ExecState*, double&, JSValue*&)
......
......@@ -97,7 +97,7 @@ inline JSPropertyNameIterator* JSPropertyNameIterator::create(ExecState* exec, J
inline JSValue* JSPropertyNameIterator::next(ExecState* exec)
{
if (m_position == m_end)
return 0;
return noValue();
if (m_data->cachedStructureID() == m_object->structureID() && structureIDChainsAreEqual(m_data->cachedPrototypeChain(), m_object->structureID()->cachedPrototypeChain()))
return jsOwnedString(exec, (*m_position++).ustring());
......@@ -108,7 +108,7 @@ inline JSValue* JSPropertyNameIterator::next(ExecState* exec)
m_position++;
} while (m_position != m_end);
return 0;
return noValue();
}
} // namespace JSC
......
This diff is collapsed.
......@@ -228,7 +228,7 @@ namespace JSC {
static JSValue* SFX_CALL cti_op_new_regexp(CTI_ARGS);
static JSValue* SFX_CALL cti_op_bitor(CTI_ARGS);
static JSValue* SFX_CALL cti_op_call_eval(CTI_ARGS);
static void* SFX_CALL cti_op_throw(CTI_ARGS);
static JSValue* SFX_CALL cti_op_throw(CTI_ARGS);
static JSPropertyNameIterator* SFX_CALL cti_op_get_pnames(CTI_ARGS);
static JSValue* SFX_CALL cti_op_next_pname(CTI_ARGS);
static void SFX_CALL cti_op_push_scope(CTI_ARGS);
......@@ -259,7 +259,7 @@ namespace JSC {
static void SFX_CALL cti_op_call_profiler(CTI_ARGS);
static void SFX_CALL cti_op_ret_profiler(CTI_ARGS);
static void* SFX_CALL cti_vm_throw(CTI_ARGS);
static JSValue* SFX_CALL cti_vm_throw(CTI_ARGS);
static void* SFX_CALL cti_vm_compile(CTI_ARGS);
static void* SFX_CALL cti_vm_lazyLinkCall(CTI_ARGS);
static JSValue* SFX_CALL cti_op_push_activation(CTI_ARGS);
......@@ -309,6 +309,8 @@ namespace JSC {
void uncachePutByID(CodeBlock*, Instruction* vPC);
#if ENABLE(CTI)
static void throwStackOverflowPreviousFrame(CallFrame*, JSGlobalData*, void*& returnAddress);
void tryCTICacheGetByID(CallFrame*, CodeBlock*, void* returnAddress, JSValue* baseValue, const Identifier& propertyName, const PropertySlot&);
void tryCTICachePutByID(CallFrame*, CodeBlock*, void* returnAddress, JSValue* baseValue, const PutPropertySlot&);
......
......@@ -40,15 +40,12 @@ namespace JSC {
class JSActivation;
class JSFunction;
class JSPropertyNameIterator;
class JSValue;
class ScopeChainNode;
struct Instruction;
typedef ExecState CallFrame;
static JSValue* const nullJSValue = 0;
class Register {
public:
Register();
......@@ -138,7 +135,7 @@ namespace JSC {
{
#ifndef NDEBUG
SET_TYPE(EmptyType);
*this = nullJSValue;
*this = noValue();
#endif
}
......@@ -147,7 +144,7 @@ namespace JSC {
SET_TYPE(ValueType);
u.value = v;
}
// This function is scaffolding for legacy clients. It will eventually go away.
ALWAYS_INLINE JSValue* Register::jsValue(CallFrame*) const
{
......
......@@ -30,8 +30,6 @@
#include <wtf/Vector.h>
namespace JSC {
class JSValue;
class ArgList : Noncopyable {
private:
......
......@@ -91,6 +91,14 @@ namespace JSC {
OwnPtr<ArgumentsData> d;
};
Arguments* asArguments(JSValue*);
inline Arguments* asArguments(JSValue* value)
{
ASSERT(asObject(value)->inherits(&Arguments::info));
return static_cast<Arguments*>(asObject(value));
}
ALWAYS_INLINE void Arguments::getArgumentsData(CallFrame* callFrame, JSFunction*& function, ptrdiff_t& firstParameterIndex, Register*& argv, int& argc)
{
function = callFrame->callee();
......
......@@ -101,7 +101,6 @@ bool ArrayPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& prope
return getStaticFunctionSlot<JSArray>(exec, ExecState::arrayTable(exec), this, propertyName, slot);
}
// ------------------------------ Array Functions ----------------------------
// Helper function
......@@ -109,7 +108,7 @@ static JSValue* getProperty(ExecState* exec, JSObject* obj, unsigned index)
{
PropertySlot slot(obj);
if (!obj->getPropertySlot(exec, index, slot))
return 0;
return noValue();
return slot.getValue(exec, index);
}
......@@ -123,7 +122,7 @@ JSValue* arrayProtoFuncToString(ExecState* exec, JSObject*, JSValue* thisValue,
{
if (!thisValue->isObject(&JSArray::info))
return throwError(exec, TypeError);
JSObject* thisObj = static_cast<JSArray*>(thisValue);
JSObject* thisObj = asArray(thisValue);
HashSet<JSObject*>& arrayVisitedElements = exec->globalData().arrayVisitedElements;
if (arrayVisitedElements.size() > MaxReentryDepth)
......@@ -167,7 +166,7 @@ JSValue* arrayProtoFuncToLocaleString(ExecState* exec, JSObject*, JSValue* thisV
{
if (!thisValue->isObject(&JSArray::info))
return throwError(exec, TypeError);
JSObject* thisObj = static_cast<JSArray*>(thisValue);
JSObject* thisObj = asArray(thisValue);
HashSet<JSObject*>& arrayVisitedElements = exec->globalData().arrayVisitedElements;
if (arrayVisitedElements.size() > MaxReentryDepth)
......@@ -270,7 +269,7 @@ JSValue* arrayProtoFuncConcat(ExecState* exec, JSObject*, JSValue* thisValue, co
ArgList::const_iterator end = args.end();
while (1) {
if (curArg->isObject(&JSArray::info)) {
JSArray* curArray = static_cast<JSArray*>(curArg);
JSArray* curArray = asArray(curArg);
unsigned length = curArray->length();
for (unsigned k = 0; k < length; ++k) {
if (JSValue* v = getProperty(exec, curArray, k))
......@@ -293,10 +292,10 @@ JSValue* arrayProtoFuncConcat(ExecState* exec, JSObject*, JSValue* thisValue, co
JSValue* arrayProtoFuncPop(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
if (exec->machine()->isJSArray(thisValue))
return static_cast<JSArray*>(thisValue)->pop();
return asArray(thisValue)->pop();
JSObject* thisObj = thisValue->toThisObject(exec);
JSValue* result = 0;
JSValue* result;
unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
if (length == 0) {
putProperty(exec, thisObj, exec->propertyNames().length, jsNumber(exec, length));
......@@ -312,7 +311,7 @@ JSValue* arrayProtoFuncPop(ExecState* exec, JSObject*, JSValue* thisValue, const
JSValue* arrayProtoFuncPush(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
if (exec->machine()->isJSArray(thisValue) && args.size() == 1) {
JSArray* array = static_cast<JSArray*>(thisValue);
JSArray* array = asArray(thisValue);
array->push(exec, args.begin()->jsValue(exec));
return jsNumber(exec, array->length());
}
......@@ -353,7 +352,7 @@ JSValue* arrayProtoFuncReverse(ExecState* exec, JSObject*, JSValue* thisValue, c
JSValue* arrayProtoFuncShift(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
JSObject* thisObj = thisValue->toThisObject(exec);
JSValue* result = 0;
JSValue* result;
unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
if (length == 0) {
......@@ -428,9 +427,9 @@ JSValue* arrayProtoFuncSort(ExecState* exec, JSObject*, JSValue* thisValue, cons
if (thisObj->classInfo() == &JSArray::info) {
if (callType != CallTypeNone)
static_cast<JSArray*>(thisObj)->sort(exec, function, callType, callData);
asArray(thisObj)->sort(exec, function, callType, callData);
else
static_cast<JSArray*>(thisObj)->sort(exec);
asArray(thisObj)->sort(exec);
return thisObj;
}
......
......@@ -33,6 +33,14 @@ namespace JSC {
static const ClassInfo info;
};
BooleanObject* asBooleanObject(JSValue*);
inline BooleanObject* asBooleanObject(JSValue* value)
{
ASSERT(asObject(value)->inherits(&BooleanObject::info));
return static_cast<BooleanObject*>(asObject(value));
}
} // namespace JSC
#endif // BooleanObject_h
......@@ -61,10 +61,10 @@ JSValue* booleanProtoFuncToString(ExecState* exec, JSObject*, JSValue* thisValue
if (!thisValue->isObject(&BooleanObject::info))
return throwError(exec, TypeError);
if (static_cast<BooleanObject*>(thisValue)->internalValue() == jsBoolean(false))
if (asBooleanObject(thisValue)->internalValue() == jsBoolean(false))
return jsNontrivialString(exec, "false");
ASSERT(static_cast<BooleanObject*>(thisValue)->internalValue() == jsBoolean(true));
ASSERT(asBooleanObject(thisValue)->internalValue() == jsBoolean(true));
return jsNontrivialString(exec, "true");
}
......@@ -76,7 +76,7 @@ JSValue* booleanProtoFuncValueOf(ExecState* exec, JSObject*, JSValue* thisValue,
if (!thisValue->isObject(&BooleanObject::info))
return throwError(exec, TypeError);
return static_cast<BooleanObject*>(thisValue)->internalValue();
return asBooleanObject(thisValue)->internalValue();
}
} // namespace JSC
......@@ -33,10 +33,10 @@ namespace JSC {
JSValue* call(ExecState* exec, JSValue* functionObject, CallType callType, const CallData& callData, JSValue* thisValue, const ArgList& args)
{
if (callType == CallTypeHost)
return callData.native.function(exec, static_cast<JSObject*>(functionObject), thisValue, args);
return callData.native.function(exec, asObject(functionObject), thisValue, args);
ASSERT(callType == CallTypeJS);
// FIXME: Can this be done more efficiently using the callData?
return static_cast<JSFunction*>(functionObject)->call(exec, thisValue, args);
return asFunction(functionObject)->call(exec, thisValue, args);
}
} // namespace JSC
......@@ -33,10 +33,10 @@ namespace JSC {
JSObject* construct(ExecState* exec, JSValue* object, ConstructType constructType, const ConstructData& constructData, const ArgList& args)
{
if (constructType == ConstructTypeHost)
return constructData.native.function(exec, static_cast<JSObject*>(object), args);
return constructData.native.function(exec, asObject(object), args);
ASSERT(constructType == ConstructTypeJS);
// FIXME: Can this be done more efficiently using the constructData?
return static_cast<JSFunction*>(object)->construct(exec, args);
return asFunction(object)->construct(exec, args);
}
} // namespace JSC
......@@ -74,7 +74,7 @@ JSObject* constructDate(ExecState* exec, const ArgList& args)
value = getCurrentUTCTime();
else if (numArgs == 1) {
if (args.at(exec, 0)->isObject(&DateInstance::info))
value = static_cast<DateInstance*>(args.at(exec, 0))->internalNumber();
value = asDateInstance(args.at(exec, 0))->internalNumber();
else {
JSValue* primitive = args.at(exec, 0)->toPrimitive(exec);
if (primitive->isString())
......
......@@ -52,6 +52,14 @@ namespace JSC {
mutable Cache* m_cache;
};
DateInstance* asDateInstance(JSValue*);
inline DateInstance* asDateInstance(JSValue* value)
{
ASSERT(asObject(value)->inherits(&DateInstance::info));
return static_cast<DateInstance*>(asObject(value));
}
} // namespace JSC
#endif // DateInstance_h
This diff is collapsed.
......@@ -60,14 +60,14 @@ JSObject* DebuggerCallFrame::thisObject() const
if (!m_callFrame->codeBlock())
return 0;
// FIXME: Why is it safe to cast this to JSObject?
return static_cast<JSObject*>(m_callFrame->thisValue());
// FIXME: Why is it safe to assume this is an object?
return asObject(m_callFrame->thisValue());
}
JSValue* DebuggerCallFrame::evaluate(const UString& script, JSValue*& exception) const
{
if (!m_callFrame->codeBlock())
return 0;
return noValue();
int errLine;
UString errMsg;
......
......@@ -37,6 +37,12 @@ namespace JSC {
public:
enum Type { ProgramType, FunctionType };