Commit 0c59caf6 authored by oliver@apple.com's avatar oliver@apple.com

Replace static_cast with jsCast when casting JSCell subclasses in JSC

https://bugs.webkit.org/show_bug.cgi?id=83307

Reviewed by Gavin Barraclough.

Replace all usage of static_cast<JSCell subtype*> with jsCast<> in JavaScriptCore.
This results in assertions when unsafe casts are performed, but simply leaves
a static_cast<> in release builds.

* API/APICast.h:
(toJS):
* API/JSCallbackConstructor.cpp:
(JSC::constructJSCallback):
* API/JSCallbackFunction.cpp:
(JSC::JSCallbackFunction::call):
* API/JSCallbackObjectFunctions.h:
(JSC::::asCallbackObject):
(JSC::::finishCreation):
(JSC::::construct):
(JSC::::call):
* API/JSObjectRef.cpp:
(JSObjectGetPrivate):
(JSObjectSetPrivate):
(JSObjectGetPrivateProperty):
(JSObjectSetPrivateProperty):
(JSObjectDeletePrivateProperty):
* API/JSValueRef.cpp:
(JSValueIsObjectOfClass):
* API/JSWeakObjectMapRefPrivate.cpp:
* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::resolve):
(JSC::BytecodeGenerator::resolveConstDecl):
* debugger/DebuggerActivation.cpp:
(JSC::DebuggerActivation::finishCreation):
* dfg/DFGOperations.cpp:
* interpreter/Interpreter.cpp:
(JSC::Interpreter::execute):
(JSC::Interpreter::privateExecute):
* jit/JITStubs.cpp:
(JSC::DEFINE_STUB_FUNCTION):
* runtime/Executable.h:
(JSC::isHostFunction):
* runtime/JSActivation.h:
(JSC::asActivation):
* runtime/JSArray.cpp:
(JSC::JSArray::defineOwnProperty):
* runtime/JSArray.h:
(JSC::asArray):
* runtime/JSBoundFunction.cpp:
(JSC::boundFunctionCall):
(JSC::boundFunctionConstruct):
* runtime/JSByteArray.h:
(JSC::asByteArray):
* runtime/JSCell.cpp:
(JSC::JSCell::toObject):
* runtime/JSCell.h:
(JSC::jsCast):
* runtime/JSGlobalObject.h:
(JSC::asGlobalObject):
* runtime/JSGlobalObjectFunctions.cpp:
(JSC::globalFuncEval):
* runtime/JSObject.cpp:
(JSC::JSObject::setPrototypeWithCycleCheck):
(JSC::JSObject::allowsAccessFrom):
(JSC::JSObject::toThisObject):
(JSC::JSObject::unwrappedObject):
* runtime/JSObject.h:
(JSC::asObject):
* runtime/JSPropertyNameIterator.h:
(JSC::Register::propertyNameIterator):
* runtime/JSString.h:
(JSC::asString):
(JSC::JSValue::toString):
* runtime/StringPrototype.cpp:
(JSC::stringProtoFuncSubstr):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@113363 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent f133627c
......@@ -69,7 +69,7 @@ inline JSC::JSValue toJS(JSC::ExecState* exec, JSValueRef v)
if (!jsCell)
return JSC::JSValue();
if (jsCell->isAPIValueWrapper())
return static_cast<JSC::JSAPIValueWrapper*>(jsCell)->value();
return jsCast<JSC::JSAPIValueWrapper*>(jsCell)->value();
return jsCell;
#else
return JSC::JSValue::decode(reinterpret_cast<JSC::EncodedJSValue>(const_cast<OpaqueJSValue*>(v)));
......
......@@ -70,7 +70,7 @@ static EncodedJSValue JSC_HOST_CALL constructJSCallback(ExecState* exec)
JSContextRef ctx = toRef(exec);
JSObjectRef constructorRef = toRef(constructor);
JSObjectCallAsConstructorCallback callback = static_cast<JSCallbackConstructor*>(constructor)->callback();
JSObjectCallAsConstructorCallback callback = jsCast<JSCallbackConstructor*>(constructor)->callback();
if (callback) {
int argumentCount = static_cast<int>(exec->argumentCount());
Vector<JSValueRef, 16> arguments(argumentCount);
......@@ -88,7 +88,7 @@ static EncodedJSValue JSC_HOST_CALL constructJSCallback(ExecState* exec)
return JSValue::encode(toJS(result));
}
return JSValue::encode(toJS(JSObjectMake(ctx, static_cast<JSCallbackConstructor*>(constructor)->classRef(), 0)));
return JSValue::encode(toJS(JSObjectMake(ctx, jsCast<JSCallbackConstructor*>(constructor)->classRef(), 0)));
}
ConstructType JSCallbackConstructor::getConstructData(JSCell*, ConstructData& constructData)
......
......@@ -70,7 +70,7 @@ EncodedJSValue JSCallbackFunction::call(ExecState* exec)
JSValueRef result;
{
APICallbackShim callbackShim(exec);
result = static_cast<JSCallbackFunction*>(toJS(functionRef))->m_callback(execRef, functionRef, thisObjRef, argumentCount, arguments.data(), &exception);
result = jsCast<JSCallbackFunction*>(toJS(functionRef))->m_callback(execRef, functionRef, thisObjRef, argumentCount, arguments.data(), &exception);
}
if (exception)
throwError(exec, toJS(exec, exception));
......
......@@ -46,7 +46,7 @@ template <class Parent>
inline JSCallbackObject<Parent>* JSCallbackObject<Parent>::asCallbackObject(JSValue value)
{
ASSERT(asObject(value)->inherits(&s_info));
return static_cast<JSCallbackObject*>(asObject(value));
return jsCast<JSCallbackObject*>(asObject(value));
}
template <class Parent>
......@@ -80,7 +80,7 @@ void JSCallbackObject<Parent>::finishCreation(JSGlobalData& globalData)
ASSERT(Parent::inherits(&s_info));
ASSERT(Parent::isGlobalObject());
Base::finishCreation(globalData);
init(static_cast<JSGlobalObject*>(this)->globalExec());
init(jsCast<JSGlobalObject*>(this)->globalExec());
}
template <class Parent>
......@@ -354,7 +354,7 @@ EncodedJSValue JSCallbackObject<Parent>::construct(ExecState* exec)
JSContextRef execRef = toRef(exec);
JSObjectRef constructorRef = toRef(constructor);
for (JSClassRef jsClass = static_cast<JSCallbackObject<Parent>*>(constructor)->classRef(); jsClass; jsClass = jsClass->parentClass) {
for (JSClassRef jsClass = jsCast<JSCallbackObject<Parent>*>(constructor)->classRef(); jsClass; jsClass = jsClass->parentClass) {
if (JSObjectCallAsConstructorCallback callAsConstructor = jsClass->callAsConstructor) {
int argumentCount = static_cast<int>(exec->argumentCount());
Vector<JSValueRef, 16> arguments(argumentCount);
......@@ -420,7 +420,7 @@ EncodedJSValue JSCallbackObject<Parent>::call(ExecState* exec)
JSObjectRef functionRef = toRef(exec->callee());
JSObjectRef thisObjRef = toRef(exec->hostThisValue().toThisObject(exec));
for (JSClassRef jsClass = static_cast<JSCallbackObject<Parent>*>(toJS(functionRef))->classRef(); jsClass; jsClass = jsClass->parentClass) {
for (JSClassRef jsClass = jsCast<JSCallbackObject<Parent>*>(toJS(functionRef))->classRef(); jsClass; jsClass = jsClass->parentClass) {
if (JSObjectCallAsFunctionCallback callAsFunction = jsClass->callAsFunction) {
int argumentCount = static_cast<int>(exec->argumentCount());
Vector<JSValueRef, 16> arguments(argumentCount);
......
......@@ -341,9 +341,9 @@ void* JSObjectGetPrivate(JSObjectRef object)
JSObject* jsObject = toJS(object);
if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::s_info))
return static_cast<JSCallbackObject<JSGlobalObject>*>(jsObject)->getPrivate();
return jsCast<JSCallbackObject<JSGlobalObject>*>(jsObject)->getPrivate();
if (jsObject->inherits(&JSCallbackObject<JSNonFinalObject>::s_info))
return static_cast<JSCallbackObject<JSNonFinalObject>*>(jsObject)->getPrivate();
return jsCast<JSCallbackObject<JSNonFinalObject>*>(jsObject)->getPrivate();
return 0;
}
......@@ -353,11 +353,11 @@ bool JSObjectSetPrivate(JSObjectRef object, void* data)
JSObject* jsObject = toJS(object);
if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::s_info)) {
static_cast<JSCallbackObject<JSGlobalObject>*>(jsObject)->setPrivate(data);
jsCast<JSCallbackObject<JSGlobalObject>*>(jsObject)->setPrivate(data);
return true;
}
if (jsObject->inherits(&JSCallbackObject<JSNonFinalObject>::s_info)) {
static_cast<JSCallbackObject<JSNonFinalObject>*>(jsObject)->setPrivate(data);
jsCast<JSCallbackObject<JSNonFinalObject>*>(jsObject)->setPrivate(data);
return true;
}
......@@ -372,9 +372,9 @@ JSValueRef JSObjectGetPrivateProperty(JSContextRef ctx, JSObjectRef object, JSSt
JSValue result;
Identifier name(propertyName->identifier(&exec->globalData()));
if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::s_info))
result = static_cast<JSCallbackObject<JSGlobalObject>*>(jsObject)->getPrivateProperty(name);
result = jsCast<JSCallbackObject<JSGlobalObject>*>(jsObject)->getPrivateProperty(name);
else if (jsObject->inherits(&JSCallbackObject<JSNonFinalObject>::s_info))
result = static_cast<JSCallbackObject<JSNonFinalObject>*>(jsObject)->getPrivateProperty(name);
result = jsCast<JSCallbackObject<JSNonFinalObject>*>(jsObject)->getPrivateProperty(name);
return toRef(exec, result);
}
......@@ -386,11 +386,11 @@ bool JSObjectSetPrivateProperty(JSContextRef ctx, JSObjectRef object, JSStringRe
JSValue jsValue = value ? toJS(exec, value) : JSValue();
Identifier name(propertyName->identifier(&exec->globalData()));
if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::s_info)) {
static_cast<JSCallbackObject<JSGlobalObject>*>(jsObject)->setPrivateProperty(exec->globalData(), name, jsValue);
jsCast<JSCallbackObject<JSGlobalObject>*>(jsObject)->setPrivateProperty(exec->globalData(), name, jsValue);
return true;
}
if (jsObject->inherits(&JSCallbackObject<JSNonFinalObject>::s_info)) {
static_cast<JSCallbackObject<JSNonFinalObject>*>(jsObject)->setPrivateProperty(exec->globalData(), name, jsValue);
jsCast<JSCallbackObject<JSNonFinalObject>*>(jsObject)->setPrivateProperty(exec->globalData(), name, jsValue);
return true;
}
return false;
......@@ -403,11 +403,11 @@ bool JSObjectDeletePrivateProperty(JSContextRef ctx, JSObjectRef object, JSStrin
JSObject* jsObject = toJS(object);
Identifier name(propertyName->identifier(&exec->globalData()));
if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::s_info)) {
static_cast<JSCallbackObject<JSGlobalObject>*>(jsObject)->deletePrivateProperty(name);
jsCast<JSCallbackObject<JSGlobalObject>*>(jsObject)->deletePrivateProperty(name);
return true;
}
if (jsObject->inherits(&JSCallbackObject<JSNonFinalObject>::s_info)) {
static_cast<JSCallbackObject<JSNonFinalObject>*>(jsObject)->deletePrivateProperty(name);
jsCast<JSCallbackObject<JSNonFinalObject>*>(jsObject)->deletePrivateProperty(name);
return true;
}
return false;
......
......@@ -130,9 +130,9 @@ bool JSValueIsObjectOfClass(JSContextRef ctx, JSValueRef value, JSClassRef jsCla
if (JSObject* o = jsValue.getObject()) {
if (o->inherits(&JSCallbackObject<JSGlobalObject>::s_info))
return static_cast<JSCallbackObject<JSGlobalObject>*>(o)->inherits(jsClass);
return jsCast<JSCallbackObject<JSGlobalObject>*>(o)->inherits(jsClass);
if (o->inherits(&JSCallbackObject<JSNonFinalObject>::s_info))
return static_cast<JSCallbackObject<JSNonFinalObject>*>(o)->inherits(jsClass);
return jsCast<JSCallbackObject<JSNonFinalObject>*>(o)->inherits(jsClass);
}
return false;
}
......
......@@ -65,7 +65,7 @@ JSObjectRef JSWeakObjectMapGet(JSContextRef ctx, JSWeakObjectMapRef map, void* k
{
ExecState* exec = toJS(ctx);
APIEntryShim entryShim(exec);
return toRef(static_cast<JSObject*>(map->map().get(key)));
return toRef(jsCast<JSObject*>(map->map().get(key)));
}
void JSWeakObjectMapRemove(JSContextRef ctx, JSWeakObjectMapRef map, void* key)
......
2012-04-05 Oliver Hunt <oliver@apple.com>
Replace static_cast with jsCast when casting JSCell subclasses in JSC
https://bugs.webkit.org/show_bug.cgi?id=83307
Reviewed by Gavin Barraclough.
Replace all usage of static_cast<JSCell subtype*> with jsCast<> in JavaScriptCore.
This results in assertions when unsafe casts are performed, but simply leaves
a static_cast<> in release builds.
* API/APICast.h:
(toJS):
* API/JSCallbackConstructor.cpp:
(JSC::constructJSCallback):
* API/JSCallbackFunction.cpp:
(JSC::JSCallbackFunction::call):
* API/JSCallbackObjectFunctions.h:
(JSC::::asCallbackObject):
(JSC::::finishCreation):
(JSC::::construct):
(JSC::::call):
* API/JSObjectRef.cpp:
(JSObjectGetPrivate):
(JSObjectSetPrivate):
(JSObjectGetPrivateProperty):
(JSObjectSetPrivateProperty):
(JSObjectDeletePrivateProperty):
* API/JSValueRef.cpp:
(JSValueIsObjectOfClass):
* API/JSWeakObjectMapRefPrivate.cpp:
* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::resolve):
(JSC::BytecodeGenerator::resolveConstDecl):
* debugger/DebuggerActivation.cpp:
(JSC::DebuggerActivation::finishCreation):
* dfg/DFGOperations.cpp:
* interpreter/Interpreter.cpp:
(JSC::Interpreter::execute):
(JSC::Interpreter::privateExecute):
* jit/JITStubs.cpp:
(JSC::DEFINE_STUB_FUNCTION):
* runtime/Executable.h:
(JSC::isHostFunction):
* runtime/JSActivation.h:
(JSC::asActivation):
* runtime/JSArray.cpp:
(JSC::JSArray::defineOwnProperty):
* runtime/JSArray.h:
(JSC::asArray):
* runtime/JSBoundFunction.cpp:
(JSC::boundFunctionCall):
(JSC::boundFunctionConstruct):
* runtime/JSByteArray.h:
(JSC::asByteArray):
* runtime/JSCell.cpp:
(JSC::JSCell::toObject):
* runtime/JSCell.h:
(JSC::jsCast):
* runtime/JSGlobalObject.h:
(JSC::asGlobalObject):
* runtime/JSGlobalObjectFunctions.cpp:
(JSC::globalFuncEval):
* runtime/JSObject.cpp:
(JSC::JSObject::setPrototypeWithCycleCheck):
(JSC::JSObject::allowsAccessFrom):
(JSC::JSObject::toThisObject):
(JSC::JSObject::unwrappedObject):
* runtime/JSObject.h:
(JSC::asObject):
* runtime/JSPropertyNameIterator.h:
(JSC::Register::propertyNameIterator):
* runtime/JSString.h:
(JSC::asString):
(JSC::JSValue::toString):
* runtime/StringPrototype.cpp:
(JSC::stringProtoFuncSubstr):
2012-04-05 Benjamin Poulain <bpoulain@apple.com>
Make something faster than JSStringBuilder for joining an array of JSValue
......@@ -1185,7 +1185,7 @@ ResolveResult BytecodeGenerator::resolve(const Identifier& property)
flags |= ResolveResult::DynamicFlag;
break;
}
JSVariableObject* currentVariableObject = static_cast<JSVariableObject*>(currentScope);
JSVariableObject* currentVariableObject = jsCast<JSVariableObject*>(currentScope);
SymbolTableEntry entry = currentVariableObject->symbolTable().get(property.impl());
// Found the property
......@@ -1242,7 +1242,7 @@ ResolveResult BytecodeGenerator::resolveConstDecl(const Identifier& property)
JSObject* currentScope = iter->get();
if (!currentScope->isVariableObject())
continue;
JSVariableObject* currentVariableObject = static_cast<JSVariableObject*>(currentScope);
JSVariableObject* currentVariableObject = jsCast<JSVariableObject*>(currentScope);
SymbolTableEntry entry = currentVariableObject->symbolTable().get(property.impl());
if (entry.isNull())
continue;
......
......@@ -44,7 +44,7 @@ void DebuggerActivation::finishCreation(JSGlobalData& globalData, JSObject* acti
Base::finishCreation(globalData);
ASSERT(activation);
ASSERT(activation->isActivationObject());
m_activation.set(globalData, this, static_cast<JSActivation*>(activation));
m_activation.set(globalData, this, jsCast<JSActivation*>(activation));
}
void DebuggerActivation::visitChildren(JSCell* cell, SlotVisitor& visitor)
......
......@@ -253,7 +253,7 @@ JSCell* DFG_OPERATION operationCreateThisInlined(ExecState* exec, JSCell* protot
JSGlobalData* globalData = &exec->globalData();
NativeCallFrameTracer tracer(globalData, exec);
return createThis(exec, prototype, static_cast<JSFunction*>(constructor));
return createThis(exec, prototype, jsCast<JSFunction*>(constructor));
}
JSCell* DFG_OPERATION operationNewObject(ExecState* exec)
......@@ -1025,7 +1025,7 @@ void DFG_OPERATION operationTearOffActivation(ExecState* exec, JSCell* activatio
{
ASSERT(activation);
ASSERT(activation->inherits(&JSActivation::s_info));
static_cast<JSActivation*>(activation)->tearOff(exec->globalData());
jsCast<JSActivation*>(activation)->tearOff(exec->globalData());
}
JSCell* DFG_OPERATION operationNewFunction(ExecState* exec, JSCell* functionExecutable)
......
......@@ -1514,7 +1514,7 @@ JSValue Interpreter::execute(EvalExecutable* eval, CallFrame* callFrame, JSValue
for (ScopeChainNode* node = scopeChain; ; node = node->next.get()) {
ASSERT(node);
if (node->object->isVariableObject() && !node->object->isStaticScopeObject()) {
variableObject = static_cast<JSVariableObject*>(node->object.get());
variableObject = jsCast<JSVariableObject*>(node->object.get());
break;
}
}
......@@ -2883,7 +2883,7 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
ASSERT_UNUSED(end, iter != end);
}
ASSERT((*iter)->isVariableObject());
JSVariableObject* scope = static_cast<JSVariableObject*>(iter->get());
JSVariableObject* scope = jsCast<JSVariableObject*>(iter->get());
callFrame->uncheckedR(dst) = scope->registerAt(index).get();
ASSERT(callFrame->r(dst).jsValue());
vPC += OPCODE_LENGTH(op_get_scoped_var);
......@@ -2914,7 +2914,7 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
}
ASSERT((*iter)->isVariableObject());
JSVariableObject* scope = static_cast<JSVariableObject*>(iter->get());
JSVariableObject* scope = jsCast<JSVariableObject*>(iter->get());
ASSERT(callFrame->r(value).jsValue());
scope->registerAt(index).set(*globalData, scope, callFrame->r(value).jsValue());
vPC += OPCODE_LENGTH(op_put_scoped_var);
......
......@@ -2949,20 +2949,20 @@ DEFINE_STUB_FUNCTION(int, op_eq)
if (cell1->isString()) {
if (src2.isInt32())
return jsToNumber(static_cast<JSString*>(cell1)->value(stackFrame.callFrame)) == src2.asInt32();
return jsToNumber(jsCast<JSString*>(cell1)->value(stackFrame.callFrame)) == src2.asInt32();
if (src2.isDouble())
return jsToNumber(static_cast<JSString*>(cell1)->value(stackFrame.callFrame)) == src2.asDouble();
return jsToNumber(jsCast<JSString*>(cell1)->value(stackFrame.callFrame)) == src2.asDouble();
if (src2.isTrue())
return jsToNumber(static_cast<JSString*>(cell1)->value(stackFrame.callFrame)) == 1.0;
return jsToNumber(jsCast<JSString*>(cell1)->value(stackFrame.callFrame)) == 1.0;
if (src2.isFalse())
return jsToNumber(static_cast<JSString*>(cell1)->value(stackFrame.callFrame)) == 0.0;
return jsToNumber(jsCast<JSString*>(cell1)->value(stackFrame.callFrame)) == 0.0;
JSCell* cell2 = src2.asCell();
if (cell2->isString())
return static_cast<JSString*>(cell1)->value(stackFrame.callFrame) == static_cast<JSString*>(cell2)->value(stackFrame.callFrame);
return jsCast<JSString*>(cell1)->value(stackFrame.callFrame) == jsCast<JSString*>(cell2)->value(stackFrame.callFrame);
src2 = asObject(cell2)->toPrimitive(stackFrame.callFrame);
CHECK_FOR_EXCEPTION();
......
......@@ -721,7 +721,7 @@ namespace JSC {
inline bool isHostFunction(JSValue value, NativeFunction nativeFunction)
{
JSFunction* function = static_cast<JSFunction*>(getJSFunction(value));
JSFunction* function = jsCast<JSFunction*>(getJSFunction(value));
if (!function || !function->isHostFunction())
return false;
return function->nativeFunction() == nativeFunction;
......
......@@ -102,7 +102,7 @@ namespace JSC {
inline JSActivation* asActivation(JSValue value)
{
ASSERT(asObject(value)->inherits(&JSActivation::s_info));
return static_cast<JSActivation*>(asObject(value));
return jsCast<JSActivation*>(asObject(value));
}
ALWAYS_INLINE JSActivation* Register::activation() const
......
......@@ -545,7 +545,7 @@ void JSArray::setLengthWritable(ExecState* exec, bool writable)
// Defined in ES5.1 15.4.5.1
bool JSArray::defineOwnProperty(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor, bool throwException)
{
JSArray* array = static_cast<JSArray*>(object);
JSArray* array = jsCast<JSArray*>(object);
// 3. If P is "length", then
if (propertyName == exec->propertyNames().length) {
......
......@@ -339,7 +339,7 @@ namespace JSC {
inline JSArray* asArray(JSCell* cell)
{
ASSERT(cell->inherits(&JSArray::s_info));
return static_cast<JSArray*>(cell);
return jsCast<JSArray*>(cell);
}
inline JSArray* asArray(JSValue value)
......
......@@ -38,7 +38,7 @@ const ClassInfo JSBoundFunction::s_info = { "Function", &Base::s_info, 0, 0, CRE
EncodedJSValue JSC_HOST_CALL boundFunctionCall(ExecState* exec)
{
JSBoundFunction* boundFunction = static_cast<JSBoundFunction*>(exec->callee());
JSBoundFunction* boundFunction = jsCast<JSBoundFunction*>(exec->callee());
ASSERT(isJSArray(boundFunction->boundArgs())); // Currently this is true!
JSArray* boundArgs = asArray(boundFunction->boundArgs());
......@@ -58,7 +58,7 @@ EncodedJSValue JSC_HOST_CALL boundFunctionCall(ExecState* exec)
EncodedJSValue JSC_HOST_CALL boundFunctionConstruct(ExecState* exec)
{
JSBoundFunction* boundFunction = static_cast<JSBoundFunction*>(exec->callee());
JSBoundFunction* boundFunction = jsCast<JSBoundFunction*>(exec->callee());
ASSERT(isJSArray(boundFunction->boundArgs())); // Currently this is true!
JSArray* boundArgs = asArray(boundFunction->boundArgs());
......
......@@ -123,7 +123,7 @@ namespace JSC {
JSByteArray* asByteArray(JSValue value);
inline JSByteArray* asByteArray(JSValue value)
{
return static_cast<JSByteArray*>(value.asCell());
return jsCast<JSByteArray*>(value.asCell());
}
inline bool isJSByteArray(JSValue v) { return v.isCell() && v.asCell()->classInfo() == &JSByteArray::s_info; }
......
......@@ -159,7 +159,7 @@ JSObject* JSCell::toObject(ExecState* exec, JSGlobalObject* globalObject) const
if (isString())
return static_cast<const JSString*>(this)->toObject(exec, globalObject);
ASSERT(isObject());
return static_cast<JSObject*>(const_cast<JSCell*>(this));
return jsCast<JSObject*>(const_cast<JSCell*>(this));
}
void slowValidateCell(JSCell* cell)
......
......@@ -351,14 +351,14 @@ namespace JSC {
template<typename To, typename From>
inline To jsCast(From* from)
{
ASSERT(!from || from->inherits(&WTF::RemovePointer<To>::Type::s_info));
ASSERT(!from || from->JSCell::inherits(&WTF::RemovePointer<To>::Type::s_info));
return static_cast<To>(from);
}
template<typename To>
inline To jsCast(JSValue from)
{
ASSERT(from.isCell() && from.asCell()->inherits(&WTF::RemovePointer<To>::Type::s_info));
ASSERT(from.isCell() && from.asCell()->JSCell::inherits(&WTF::RemovePointer<To>::Type::s_info));
return static_cast<To>(from.asCell());
}
......
......@@ -358,7 +358,7 @@ namespace JSC {
inline JSGlobalObject* asGlobalObject(JSValue value)
{
ASSERT(asObject(value)->isGlobalObject());
return static_cast<JSGlobalObject*>(asObject(value));
return jsCast<JSGlobalObject*>(asObject(value));
}
inline void JSGlobalObject::setRegisters(WriteBarrier<Unknown>* registers, PassOwnArrayPtr<WriteBarrier<Unknown> > registerArray, size_t count)
......
......@@ -505,7 +505,7 @@ EncodedJSValue JSC_HOST_CALL globalFuncEval(ExecState* exec)
{
JSObject* thisObject = exec->hostThisValue().toThisObject(exec);
JSObject* unwrappedObject = thisObject->unwrappedObject();
if (!unwrappedObject->isGlobalObject() || static_cast<JSGlobalObject*>(unwrappedObject)->evalFunction() != exec->callee())
if (!unwrappedObject->isGlobalObject() || jsCast<JSGlobalObject*>(unwrappedObject)->evalFunction() != exec->callee())
return throwVMError(exec, createEvalError(exec, "The \"this\" value passed to eval must be the global object from which eval originated"));
JSValue x = exec->argument(0);
......@@ -525,11 +525,11 @@ EncodedJSValue JSC_HOST_CALL globalFuncEval(ExecState* exec)
}
EvalExecutable* eval = EvalExecutable::create(exec, makeSource(s), false);
JSObject* error = eval->compile(exec, static_cast<JSGlobalObject*>(unwrappedObject)->globalScopeChain());
JSObject* error = eval->compile(exec, jsCast<JSGlobalObject*>(unwrappedObject)->globalScopeChain());
if (error)
return throwVMError(exec, error);
return JSValue::encode(exec->interpreter()->execute(eval, exec, thisObject, static_cast<JSGlobalObject*>(unwrappedObject)->globalScopeChain()));
return JSValue::encode(exec->interpreter()->execute(eval, exec, thisObject, jsCast<JSGlobalObject*>(unwrappedObject)->globalScopeChain()));
}
EncodedJSValue JSC_HOST_CALL globalFuncParseInt(ExecState* exec)
......
......@@ -203,7 +203,7 @@ bool JSObject::setPrototypeWithCycleCheck(JSGlobalData& globalData, JSValue prot
{
JSValue checkFor = this;
if (this->isGlobalObject())
checkFor = static_cast<JSGlobalObject*>(this)->globalExec()->thisValue();
checkFor = jsCast<JSGlobalObject*>(this)->globalExec()->thisValue();
JSValue nextPrototype = prototype;
while (nextPrototype && nextPrototype.isObject()) {
......@@ -217,7 +217,7 @@ bool JSObject::setPrototypeWithCycleCheck(JSGlobalData& globalData, JSValue prot
bool JSObject::allowsAccessFrom(ExecState* exec)
{
JSGlobalObject* globalObject = isGlobalThis() ? static_cast<JSGlobalThis*>(this)->unwrappedObject() : this->globalObject();
JSGlobalObject* globalObject = isGlobalThis() ? jsCast<JSGlobalThis*>(this)->unwrappedObject() : this->globalObject();
return globalObject->globalObjectMethodTable()->allowsAccessFrom(globalObject, exec);
}
......@@ -445,13 +445,13 @@ JSString* JSObject::toString(ExecState* exec) const
JSObject* JSObject::toThisObject(JSCell* cell, ExecState*)
{
return static_cast<JSObject*>(cell);
return jsCast<JSObject*>(cell);
}
JSObject* JSObject::unwrappedObject()
{
if (isGlobalThis())
return static_cast<JSGlobalThis*>(this)->unwrappedObject();
return jsCast<JSGlobalThis*>(this)->unwrappedObject();
return this;
}
......
......@@ -474,7 +474,7 @@ inline Structure* createEmptyObjectStructure(JSGlobalData& globalData, JSGlobalO
inline JSObject* asObject(JSCell* cell)
{
ASSERT(cell->isObject());
return static_cast<JSObject*>(cell);
return jsCast<JSObject*>(cell);
}
inline JSObject* asObject(JSValue value)
......
......@@ -121,7 +121,7 @@ namespace JSC {
ALWAYS_INLINE JSPropertyNameIterator* Register::propertyNameIterator() const
{
return static_cast<JSPropertyNameIterator*>(jsValue().asCell());
return jsCast<JSPropertyNameIterator*>(jsValue().asCell());
}
} // namespace JSC
......
......@@ -277,7 +277,7 @@ namespace JSC {
inline JSString* asString(JSValue value)
{
ASSERT(value.asCell()->isString());
return static_cast<JSString*>(value.asCell());
return jsCast<JSString*>(value.asCell());
}
inline JSString* jsEmptyString(JSGlobalData* globalData)
......@@ -458,7 +458,7 @@ namespace JSC {
inline JSString* JSValue::toString(ExecState* exec) const
{
if (isString())
return static_cast<JSString*>(asCell());
return jsCast<JSString*>(asCell());
return toStringSlowCase(exec);
}
......
......@@ -1103,7 +1103,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncSubstr(ExecState* exec)
JSString* jsString = 0;
UString uString;
if (thisValue.isString()) {
jsString = static_cast<JSString*>(thisValue.asCell());
jsString = jsCast<JSString*>(thisValue.asCell());
len = jsString->length();
} else if (thisValue.isUndefinedOrNull()) {
// CheckObjectCoercible
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment