Commit 0b31aa52 authored by xan@webkit.org's avatar xan@webkit.org

2010-10-28 Xan Lopez <xlopez@igalia.com>

        Reviewed by Oliver Hunt.

        Do not have two different asCell APIs in JSValue
        https://bugs.webkit.org/show_bug.cgi?id=47979

        Remove JSCell* asCell(JSValue) in favor of only using
        JSValue::asCell().

        * API/APICast.h:
        (toRef):
        * jit/JITPropertyAccess32_64.cpp:
        (JSC::JIT::testPrototype):
        * jit/JITStubs.cpp:
        (JSC::JITThunks::tryCachePutByID):
        (JSC::JITThunks::tryCacheGetByID):
        (JSC::DEFINE_STUB_FUNCTION):
        * runtime/GetterSetter.h:
        (JSC::asGetterSetter):
        * runtime/JSByteArray.h:
        (JSC::asByteArray):
        * runtime/JSCell.h:
        (JSC::JSCell::getCallData):
        (JSC::JSCell::getConstructData):
        * runtime/JSString.h:
        (JSC::RopeBuilder::appendValueInConstructAndIncrementLength):
        (JSC::asString):
        * runtime/JSValue.h:
        * runtime/Operations.cpp:
        (JSC::jsIsObjectType):
        * runtime/Operations.h:
        (JSC::normalizePrototypeChain):
        * runtime/Protect.h:
        (JSC::gcProtect):
        (JSC::gcUnprotect):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@70749 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1177849d
......@@ -111,8 +111,8 @@ inline JSValueRef toRef(JSC::ExecState* exec, JSC::JSValue v)
if (!v)
return 0;
if (!v.isCell())
return reinterpret_cast<JSValueRef>(asCell(JSC::jsAPIValueWrapper(exec, v)));
return reinterpret_cast<JSValueRef>(asCell(v));
return reinterpret_cast<JSValueRef>(JSC::jsAPIValueWrapper(exec, v).asCell());
return reinterpret_cast<JSValueRef>(v.asCell());
#else
UNUSED_PARAM(exec);
return reinterpret_cast<JSValueRef>(JSC::JSValue::encode(v));
......
2010-10-28 Xan Lopez <xlopez@igalia.com>
Reviewed by Oliver Hunt.
Do not have two different asCell APIs in JSValue
https://bugs.webkit.org/show_bug.cgi?id=47979
Remove JSCell* asCell(JSValue) in favor of only using
JSValue::asCell().
* API/APICast.h:
(toRef):
* jit/JITPropertyAccess32_64.cpp:
(JSC::JIT::testPrototype):
* jit/JITStubs.cpp:
(JSC::JITThunks::tryCachePutByID):
(JSC::JITThunks::tryCacheGetByID):
(JSC::DEFINE_STUB_FUNCTION):
* runtime/GetterSetter.h:
(JSC::asGetterSetter):
* runtime/JSByteArray.h:
(JSC::asByteArray):
* runtime/JSCell.h:
(JSC::JSCell::getCallData):
(JSC::JSCell::getConstructData):
* runtime/JSString.h:
(JSC::RopeBuilder::appendValueInConstructAndIncrementLength):
(JSC::asString):
* runtime/JSValue.h:
* runtime/Operations.cpp:
(JSC::jsIsObjectType):
* runtime/Operations.h:
(JSC::normalizePrototypeChain):
* runtime/Protect.h:
(JSC::gcProtect):
(JSC::gcUnprotect):
2010-10-27 Chao-ying Fu <fu@mips.com>
Reviewed by Oliver Hunt.
......
......@@ -1205,7 +1205,7 @@ NEVER_INLINE void Interpreter::tryCachePutByID(CallFrame* callFrame, CodeBlock*
return;
}
JSCell* baseCell = asCell(baseValue);
JSCell* baseCell = baseValue.asCell();
Structure* structure = baseCell->structure();
if (structure->isUncacheableDictionary()) {
......@@ -1295,7 +1295,7 @@ NEVER_INLINE void Interpreter::tryCacheGetByID(CallFrame* callFrame, CodeBlock*
return;
}
Structure* structure = asCell(baseValue)->structure();
Structure* structure = baseValue.asCell()->structure();
if (structure->isUncacheableDictionary()) {
vPC[0] = getOpcode(op_get_by_id_generic);
......@@ -1633,7 +1633,7 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
NEXT_INSTRUCTION();
}
callFrame->r(dst) = jsBoolean(!src.isCell() || !asCell(src)->structure()->typeInfo().masqueradesAsUndefined());
callFrame->r(dst) = jsBoolean(!src.isCell() || !src.asCell()->structure()->typeInfo().masqueradesAsUndefined());
vPC += OPCODE_LENGTH(op_neq_null);
NEXT_INSTRUCTION();
}
......@@ -2492,7 +2492,7 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
JSValue baseValue = callFrame->r(base).jsValue();
if (LIKELY(baseValue.isCell())) {
JSCell* baseCell = asCell(baseValue);
JSCell* baseCell = baseValue.asCell();
Structure* structure = vPC[4].u.structure;
if (LIKELY(baseCell->structure() == structure)) {
......@@ -2523,7 +2523,7 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
JSValue baseValue = callFrame->r(base).jsValue();
if (LIKELY(baseValue.isCell())) {
JSCell* baseCell = asCell(baseValue);
JSCell* baseCell = baseValue.asCell();
Structure* structure = vPC[4].u.structure;
if (LIKELY(baseCell->structure() == structure)) {
......@@ -2562,7 +2562,7 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
JSValue baseValue = callFrame->r(base).jsValue();
if (LIKELY(baseValue.isCell())) {
JSCell* baseCell = asCell(baseValue);
JSCell* baseCell = baseValue.asCell();
Structure* structure = vPC[4].u.structure;
if (LIKELY(baseCell->structure() == structure)) {
......@@ -2607,7 +2607,7 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
JSValue baseValue = callFrame->r(base).jsValue();
if (LIKELY(baseValue.isCell())) {
JSCell* baseCell = asCell(baseValue);
JSCell* baseCell = baseValue.asCell();
Structure* structure = vPC[4].u.structure;
if (LIKELY(baseCell->structure() == structure)) {
......@@ -2688,7 +2688,7 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
JSValue baseValue = callFrame->r(base).jsValue();
if (LIKELY(baseValue.isCell())) {
JSCell* baseCell = asCell(baseValue);
JSCell* baseCell = baseValue.asCell();
Structure* structure = vPC[4].u.structure;
if (LIKELY(baseCell->structure() == structure)) {
......@@ -2737,7 +2737,7 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
JSValue baseValue = callFrame->r(base).jsValue();
if (LIKELY(baseValue.isCell())) {
JSCell* baseCell = asCell(baseValue);
JSCell* baseCell = baseValue.asCell();
Structure* structure = vPC[4].u.structure;
if (LIKELY(baseCell->structure() == structure)) {
......@@ -2780,7 +2780,7 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
JSValue baseValue = callFrame->r(base).jsValue();
if (LIKELY(baseValue.isCell())) {
JSCell* baseCell = asCell(baseValue);
JSCell* baseCell = baseValue.asCell();
Structure* structure = vPC[4].u.structure;
if (LIKELY(baseCell->structure() == structure)) {
......@@ -2837,7 +2837,7 @@ skip_id_custom_self:
JSValue baseValue = callFrame->r(base).jsValue();
if (LIKELY(baseValue.isCell())) {
JSCell* baseCell = asCell(baseValue);
JSCell* baseCell = baseValue.asCell();
Structure* structure = vPC[4].u.structure;
if (LIKELY(baseCell->structure() == structure)) {
......@@ -2892,7 +2892,7 @@ skip_id_custom_self:
JSValue baseValue = callFrame->r(base).jsValue();
if (LIKELY(baseValue.isCell())) {
JSCell* baseCell = asCell(baseValue);
JSCell* baseCell = baseValue.asCell();
Structure* structure = vPC[4].u.structure;
if (LIKELY(baseCell->structure() == structure)) {
......@@ -3018,7 +3018,7 @@ skip_id_custom_self:
JSValue baseValue = callFrame->r(base).jsValue();
if (LIKELY(baseValue.isCell())) {
JSCell* baseCell = asCell(baseValue);
JSCell* baseCell = baseValue.asCell();
Structure* oldStructure = vPC[4].u.structure;
Structure* newStructure = vPC[5].u.structure;
......@@ -3070,7 +3070,7 @@ skip_id_custom_self:
JSValue baseValue = callFrame->r(base).jsValue();
if (LIKELY(baseValue.isCell())) {
JSCell* baseCell = asCell(baseValue);
JSCell* baseCell = baseValue.asCell();
Structure* structure = vPC[4].u.structure;
if (LIKELY(baseCell->structure() == structure)) {
......
......@@ -595,10 +595,10 @@ void JIT::testPrototype(JSValue prototype, JumpList& failureCases)
// values. In the non X86_64 case, the generated code is slightly more efficient because it uses
// two less instructions and doesn't require any scratch registers.
#if CPU(X86_64)
move(ImmPtr(asCell(prototype)->structure()), regT3);
failureCases.append(branchPtr(NotEqual, AbsoluteAddress(&asCell(prototype)->m_structure), regT3));
move(ImmPtr(prototype.asCell()->structure()), regT3);
failureCases.append(branchPtr(NotEqual, AbsoluteAddress(&prototype.asCell()->m_structure), regT3));
#else
failureCases.append(branchPtr(NotEqual, AbsoluteAddress(&asCell(prototype)->m_structure), ImmPtr(asCell(prototype)->structure())));
failureCases.append(branchPtr(NotEqual, AbsoluteAddress(&prototype.asCell()->m_structure), ImmPtr(prototype.asCell()->structure())));
#endif
}
......
......@@ -848,7 +848,7 @@ NEVER_INLINE void JITThunks::tryCachePutByID(CallFrame* callFrame, CodeBlock* co
return;
}
JSCell* baseCell = asCell(baseValue);
JSCell* baseCell = baseValue.asCell();
Structure* structure = baseCell->structure();
if (structure->isUncacheableDictionary()) {
......@@ -916,7 +916,7 @@ NEVER_INLINE void JITThunks::tryCacheGetByID(CallFrame* callFrame, CodeBlock* co
return;
}
JSCell* baseCell = asCell(baseValue);
JSCell* baseCell = baseValue.asCell();
Structure* structure = baseCell->structure();
if (structure->isUncacheableDictionary()) {
......@@ -1561,7 +1561,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_id_method_check)
JSObject* slotBaseObject;
if (baseValue.isCell()
&& slot.isCacheableValue()
&& !(structure = asCell(baseValue)->structure())->isUncacheableDictionary()
&& !(structure = baseValue.asCell()->structure())->isUncacheableDictionary()
&& (slotBaseObject = asObject(slot.slotBase()))->getPropertySpecificValue(callFrame, ident, specific)
&& specific
) {
......@@ -1635,7 +1635,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_id_self_fail)
if (baseValue.isCell()
&& slot.isCacheable()
&& !asCell(baseValue)->structure()->isUncacheableDictionary()
&& !baseValue.asCell()->structure()->isUncacheableDictionary()
&& slot.slotBase() == baseValue) {
CodeBlock* codeBlock = callFrame->codeBlock();
......@@ -1656,7 +1656,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_id_self_fail)
}
if (listIndex < POLYMORPHIC_LIST_CACHE_SIZE) {
stubInfo->u.getByIdSelfList.listSize++;
JIT::compileGetByIdSelfList(callFrame->scopeChain()->globalData, codeBlock, stubInfo, polymorphicStructureList, listIndex, asCell(baseValue)->structure(), ident, slot, slot.cachedOffset());
JIT::compileGetByIdSelfList(callFrame->scopeChain()->globalData, codeBlock, stubInfo, polymorphicStructureList, listIndex, baseValue.asCell()->structure(), ident, slot, slot.cachedOffset());
if (listIndex == (POLYMORPHIC_LIST_CACHE_SIZE - 1))
ctiPatchCallByReturnAddress(codeBlock, STUB_RETURN_ADDRESS, FunctionPtr(cti_op_get_by_id_generic));
......@@ -1740,12 +1740,12 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_id_proto_list)
CHECK_FOR_EXCEPTION();
if (!baseValue.isCell() || !slot.isCacheable() || asCell(baseValue)->structure()->isDictionary()) {
if (!baseValue.isCell() || !slot.isCacheable() || baseValue.asCell()->structure()->isDictionary()) {
ctiPatchCallByReturnAddress(callFrame->codeBlock(), STUB_RETURN_ADDRESS, FunctionPtr(cti_op_get_by_id_proto_fail));
return JSValue::encode(result);
}
Structure* structure = asCell(baseValue)->structure();
Structure* structure = baseValue.asCell()->structure();
CodeBlock* codeBlock = callFrame->codeBlock();
StructureStubInfo* stubInfo = &codeBlock->getStubInfo(STUB_RETURN_ADDRESS);
......@@ -1756,8 +1756,8 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_id_proto_list)
if (slot.slotBase() == baseValue)
ctiPatchCallByReturnAddress(codeBlock, STUB_RETURN_ADDRESS, FunctionPtr(cti_op_get_by_id_proto_fail));
else if (slot.slotBase() == asCell(baseValue)->structure()->prototypeForLookup(callFrame)) {
ASSERT(!asCell(baseValue)->structure()->isDictionary());
else if (slot.slotBase() == baseValue.asCell()->structure()->prototypeForLookup(callFrame)) {
ASSERT(!baseValue.asCell()->structure()->isDictionary());
// Since we're accessing a prototype in a loop, it's a good bet that it
// should not be treated as a dictionary.
if (slotBaseObject->structure()->isDictionary()) {
......@@ -1774,7 +1774,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_id_proto_list)
ctiPatchCallByReturnAddress(codeBlock, STUB_RETURN_ADDRESS, FunctionPtr(cti_op_get_by_id_proto_list_full));
}
} else if (size_t count = normalizePrototypeChain(callFrame, baseValue, slot.slotBase(), propertyName, offset)) {
ASSERT(!asCell(baseValue)->structure()->isDictionary());
ASSERT(!baseValue.asCell()->structure()->isDictionary());
int listIndex;
PolymorphicAccessStructureList* prototypeStructureList = getPolymorphicAccessStructureListSlot(stubInfo, listIndex);
......@@ -2365,10 +2365,10 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_val)
if (LIKELY(baseValue.isCell() && subscript.isString())) {
Identifier propertyName(callFrame, asString(subscript)->value(callFrame));
PropertySlot slot(asCell(baseValue));
PropertySlot slot(baseValue.asCell());
// JSString::value may have thrown, but we shouldn't find a property with a null identifier,
// so we should miss this case and wind up in the CHECK_FOR_EXCEPTION_AT_END, below.
if (asCell(baseValue)->fastGetOwnPropertySlot(callFrame, propertyName, slot)) {
if (baseValue.asCell()->fastGetOwnPropertySlot(callFrame, propertyName, slot)) {
JSValue result = slot.getValue(callFrame, propertyName);
CHECK_FOR_EXCEPTION();
return JSValue::encode(result);
......@@ -2901,14 +2901,14 @@ DEFINE_STUB_FUNCTION(int, op_eq)
start:
if (src2.isUndefined()) {
return src1.isNull() ||
(src1.isCell() && asCell(src1)->structure()->typeInfo().masqueradesAsUndefined()) ||
src1.isUndefined();
(src1.isCell() && src1.asCell()->structure()->typeInfo().masqueradesAsUndefined())
|| src1.isUndefined();
}
if (src2.isNull()) {
return src1.isUndefined() ||
(src1.isCell() && asCell(src1)->structure()->typeInfo().masqueradesAsUndefined()) ||
src1.isNull();
(src1.isCell() && src1.asCell()->structure()->typeInfo().masqueradesAsUndefined())
|| src1.isNull();
}
if (src1.isInt32()) {
......@@ -2944,12 +2944,12 @@ DEFINE_STUB_FUNCTION(int, op_eq)
}
if (src1.isUndefined())
return src2.isCell() && asCell(src2)->structure()->typeInfo().masqueradesAsUndefined();
return src2.isCell() && src2.asCell()->structure()->typeInfo().masqueradesAsUndefined();
if (src1.isNull())
return src2.isCell() && asCell(src2)->structure()->typeInfo().masqueradesAsUndefined();
return src2.isCell() && src2.asCell()->structure()->typeInfo().masqueradesAsUndefined();
JSCell* cell1 = asCell(src1);
JSCell* cell1 = src1.asCell();
if (cell1->isString()) {
if (src2.isInt32())
......@@ -2964,7 +2964,7 @@ DEFINE_STUB_FUNCTION(int, op_eq)
if (src2.isFalse())
return jsToNumber(static_cast<JSString*>(cell1)->value(stackFrame.callFrame)) == 0.0;
JSCell* cell2 = asCell(src2);
JSCell* cell2 = src2.asCell();
if (cell2->isString())
return static_cast<JSString*>(cell1)->value(stackFrame.callFrame) == static_cast<JSString*>(cell2)->value(stackFrame.callFrame);
......
......@@ -64,8 +64,8 @@ namespace JSC {
inline GetterSetter* asGetterSetter(JSValue value)
{
ASSERT(asCell(value)->isGetterSetter());
return static_cast<GetterSetter*>(asCell(value));
ASSERT(value.asCell()->isGetterSetter());
return static_cast<GetterSetter*>(value.asCell());
}
......
......@@ -106,7 +106,7 @@ namespace JSC {
JSByteArray* asByteArray(JSValue value);
inline JSByteArray* asByteArray(JSValue value)
{
return static_cast<JSByteArray*>(asCell(value));
return static_cast<JSByteArray*>(value.asCell());
}
inline bool isJSByteArray(JSGlobalData* globalData, JSValue v) { return v.isCell() && v.asCell()->vptr() == globalData->jsByteArrayVPtr; }
......
......@@ -216,14 +216,14 @@ namespace JSC {
inline CallType getCallData(JSValue value, CallData& callData)
{
CallType result = value.isCell() ? asCell(value)->getCallData(callData) : CallTypeNone;
CallType result = value.isCell() ? value.asCell()->getCallData(callData) : CallTypeNone;
ASSERT(result == CallTypeNone || value.isValidCallee());
return result;
}
inline ConstructType getConstructData(JSValue value, ConstructData& constructData)
{
ConstructType result = value.isCell() ? asCell(value)->getConstructData(constructData) : ConstructTypeNone;
ConstructType result = value.isCell() ? value.asCell()->getConstructData(constructData) : ConstructTypeNone;
ASSERT(result == ConstructTypeNone || value.isValidCallee());
return result;
}
......
......@@ -379,8 +379,8 @@ namespace JSC {
void appendValueInConstructAndIncrementLength(ExecState* exec, unsigned& index, JSValue v)
{
if (v.isString()) {
ASSERT(asCell(v)->isString());
JSString* s = static_cast<JSString*>(asCell(v));
ASSERT(v.asCell()->isString());
JSString* s = static_cast<JSString*>(v.asCell());
ASSERT(s->fiberCount() == 1);
appendStringInConstruct(index, s);
m_length += s->length();
......@@ -451,8 +451,8 @@ namespace JSC {
inline JSString* asString(JSValue value)
{
ASSERT(asCell(value)->isString());
return static_cast<JSString*>(asCell(value));
ASSERT(value.asCell()->isString());
return static_cast<JSString*>(value.asCell());
}
inline JSString* jsEmptyString(JSGlobalData* globalData)
......
......@@ -357,14 +357,6 @@ namespace JSC {
inline bool operator!=(const JSValue a, const JSCell* b) { return a != JSValue(b); }
inline bool operator!=(const JSCell* a, const JSValue b) { return JSValue(a) != b; }
// FIXME: We should deprecate this and just use JSValue::asCell() instead.
JSCell* asCell(JSValue);
inline JSCell* asCell(JSValue value)
{
return value.asCell();
}
ALWAYS_INLINE int32_t JSValue::toInt32(ExecState* exec) const
{
if (isInt32())
......
......@@ -85,7 +85,7 @@ bool jsIsObjectType(JSValue v)
if (!v.isCell())
return v.isNull();
JSType type = asCell(v)->structure()->typeInfo().type();
JSType type = v.asCell()->structure()->typeInfo().type();
if (type == NumberType || type == StringType)
return false;
if (type == ObjectType) {
......
......@@ -412,7 +412,7 @@ namespace JSC {
inline size_t normalizePrototypeChain(CallFrame* callFrame, JSValue base, JSValue slotBase, const Identifier& propertyName, size_t& slotOffset)
{
JSCell* cell = asCell(base);
JSCell* cell = base.asCell();
size_t count = 0;
while (slotBase != cell) {
......@@ -424,7 +424,7 @@ namespace JSC {
if (v.isNull())
return 0;
cell = asCell(v);
cell = v.asCell();
// Since we're accessing a prototype in a loop, it's a good bet that it
// should not be treated as a dictionary.
......@@ -449,7 +449,7 @@ namespace JSC {
if (v.isNull())
return count;
base = asCell(v);
base = v.asCell();
// Since we're accessing a prototype in a loop, it's a good bet that it
// should not be treated as a dictionary.
......
......@@ -52,13 +52,13 @@ namespace JSC {
inline void gcProtect(JSValue value)
{
if (value && value.isCell())
gcProtect(asCell(value));
gcProtect(value.asCell());
}
inline void gcUnprotect(JSValue value)
{
if (value && value.isCell())
gcUnprotect(asCell(value));
gcUnprotect(value.asCell());
}
// FIXME: Share more code with RefPtr template? The only differences are the ref/deref operation
......
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