Commit 59144210 authored by oliver@apple.com's avatar oliver@apple.com

2011-04-01 Oliver Hunt <oliver@apple.com>

        Reviewed by Geoffrey Garen.

        Make StructureChain GC allocated
        https://bugs.webkit.org/show_bug.cgi?id=56695

        Make StructureChain GC allocated, and make the various owners
        mark it correctly.

        * JavaScriptCore.exp:
        * bytecode/CodeBlock.cpp:
        (JSC::CodeBlock::dump):
        (JSC::CodeBlock::derefStructures):
        (JSC::CodeBlock::refStructures):
        (JSC::CodeBlock::markAggregate):
        * bytecode/Instruction.h:
        (JSC::PolymorphicAccessStructureList::PolymorphicStubInfo::set):
        (JSC::PolymorphicAccessStructureList::PolymorphicAccessStructureList):
        (JSC::PolymorphicAccessStructureList::derefStructures):
        (JSC::PolymorphicAccessStructureList::markAggregate):
        (JSC::Instruction::Instruction):
        * bytecode/StructureStubInfo.cpp:
        (JSC::StructureStubInfo::deref):
        (JSC::StructureStubInfo::markAggregate):
        * bytecode/StructureStubInfo.h:
        (JSC::StructureStubInfo::initGetByIdChain):
        (JSC::StructureStubInfo::initPutByIdTransition):
        * bytecompiler/BytecodeGenerator.cpp:
        (JSC::BytecodeGenerator::emitJumpIfNotFunctionCall):
        (JSC::BytecodeGenerator::emitJumpIfNotFunctionApply):
        * collector/handles/Handle.h:
        (JSC::HandleConverter::operator->):
        (JSC::HandleConverter::operator*):
        * interpreter/Interpreter.cpp:
        (JSC::Interpreter::privateExecute):
        * jit/JITOpcodes.cpp:
        (JSC::JIT::emit_op_jneq_ptr):
        * jit/JITOpcodes32_64.cpp:
        (JSC::JIT::emit_op_jneq_ptr):
        * jit/JITPropertyAccess.cpp:
        (JSC::JIT::privateCompileGetByIdChainList):
        * jit/JITPropertyAccess32_64.cpp:
        (JSC::JIT::privateCompileGetByIdChainList):
        * jit/JITStubs.cpp:
        (JSC::JITThunks::tryCachePutByID):
        (JSC::JITThunks::tryCacheGetByID):
        (JSC::getPolymorphicAccessStructureListSlot):
        (JSC::DEFINE_STUB_FUNCTION):
        * runtime/JSCell.h:
        * runtime/JSGlobalData.cpp:
        (JSC::JSGlobalData::JSGlobalData):
        * runtime/JSGlobalData.h:
        * runtime/JSGlobalObject.cpp:
        (JSC::markIfNeeded):
        * runtime/JSGlobalObject.h:
        (JSC::Structure::prototypeChain):
        * runtime/JSObject.h:
        (JSC::JSObject::putDirectInternal):
        (JSC::JSObject::markChildrenDirect):
        * runtime/JSPropertyNameIterator.cpp:
        (JSC::JSPropertyNameIterator::create):
        (JSC::JSPropertyNameIterator::get):
        (JSC::JSPropertyNameIterator::markChildren):
        * runtime/JSPropertyNameIterator.h:
        (JSC::JSPropertyNameIterator::setCachedPrototypeChain):
        * runtime/JSZombie.cpp:
        (JSC::JSZombie::leakedZombieStructure):
        * runtime/JSZombie.h:
        * runtime/MarkStack.h:
        (JSC::MarkStack::append):
        * runtime/MarkedBlock.cpp:
        (JSC::MarkedBlock::sweep):
        * runtime/Structure.cpp:
        (JSC::Structure::addPropertyTransition):
        * runtime/Structure.h:
        (JSC::Structure::markAggregate):
        * runtime/StructureChain.cpp:
        (JSC::StructureChain::StructureChain):
        (JSC::StructureChain::~StructureChain):
        (JSC::StructureChain::markChildren):
        * runtime/StructureChain.h:
        (JSC::StructureChain::create):
        (JSC::StructureChain::createStructure):
        * runtime/WriteBarrier.h:
        (JSC::WriteBarrierBase::get):
        (JSC::WriteBarrierBase::operator*):
        (JSC::WriteBarrierBase::operator->):
2011-04-01  Oliver Hunt  <oliver@apple.com>

        Reviewed by Geoffrey Garen.

        Make StructureChain GC allocated
        https://bugs.webkit.org/show_bug.cgi?id=56695

        Update for new Structure marking function

        * bindings/js/JSDOMGlobalObject.cpp:
        (WebCore::JSDOMGlobalObject::markChildren):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@82849 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent cb7a066b
2011-04-01 Oliver Hunt <oliver@apple.com>
Reviewed by Geoffrey Garen.
Make StructureChain GC allocated
https://bugs.webkit.org/show_bug.cgi?id=56695
Make StructureChain GC allocated, and make the various owners
mark it correctly.
* JavaScriptCore.exp:
* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::dump):
(JSC::CodeBlock::derefStructures):
(JSC::CodeBlock::refStructures):
(JSC::CodeBlock::markAggregate):
* bytecode/Instruction.h:
(JSC::PolymorphicAccessStructureList::PolymorphicStubInfo::set):
(JSC::PolymorphicAccessStructureList::PolymorphicAccessStructureList):
(JSC::PolymorphicAccessStructureList::derefStructures):
(JSC::PolymorphicAccessStructureList::markAggregate):
(JSC::Instruction::Instruction):
* bytecode/StructureStubInfo.cpp:
(JSC::StructureStubInfo::deref):
(JSC::StructureStubInfo::markAggregate):
* bytecode/StructureStubInfo.h:
(JSC::StructureStubInfo::initGetByIdChain):
(JSC::StructureStubInfo::initPutByIdTransition):
* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::emitJumpIfNotFunctionCall):
(JSC::BytecodeGenerator::emitJumpIfNotFunctionApply):
* collector/handles/Handle.h:
(JSC::HandleConverter::operator->):
(JSC::HandleConverter::operator*):
* interpreter/Interpreter.cpp:
(JSC::Interpreter::privateExecute):
* jit/JITOpcodes.cpp:
(JSC::JIT::emit_op_jneq_ptr):
* jit/JITOpcodes32_64.cpp:
(JSC::JIT::emit_op_jneq_ptr):
* jit/JITPropertyAccess.cpp:
(JSC::JIT::privateCompileGetByIdChainList):
* jit/JITPropertyAccess32_64.cpp:
(JSC::JIT::privateCompileGetByIdChainList):
* jit/JITStubs.cpp:
(JSC::JITThunks::tryCachePutByID):
(JSC::JITThunks::tryCacheGetByID):
(JSC::getPolymorphicAccessStructureListSlot):
(JSC::DEFINE_STUB_FUNCTION):
* runtime/JSCell.h:
* runtime/JSGlobalData.cpp:
(JSC::JSGlobalData::JSGlobalData):
* runtime/JSGlobalData.h:
* runtime/JSGlobalObject.cpp:
(JSC::markIfNeeded):
* runtime/JSGlobalObject.h:
(JSC::Structure::prototypeChain):
* runtime/JSObject.h:
(JSC::JSObject::putDirectInternal):
(JSC::JSObject::markChildrenDirect):
* runtime/JSPropertyNameIterator.cpp:
(JSC::JSPropertyNameIterator::create):
(JSC::JSPropertyNameIterator::get):
(JSC::JSPropertyNameIterator::markChildren):
* runtime/JSPropertyNameIterator.h:
(JSC::JSPropertyNameIterator::setCachedPrototypeChain):
* runtime/JSZombie.cpp:
(JSC::JSZombie::leakedZombieStructure):
* runtime/JSZombie.h:
* runtime/MarkStack.h:
(JSC::MarkStack::append):
* runtime/MarkedBlock.cpp:
(JSC::MarkedBlock::sweep):
* runtime/Structure.cpp:
(JSC::Structure::addPropertyTransition):
* runtime/Structure.h:
(JSC::Structure::markAggregate):
* runtime/StructureChain.cpp:
(JSC::StructureChain::StructureChain):
(JSC::StructureChain::~StructureChain):
(JSC::StructureChain::markChildren):
* runtime/StructureChain.h:
(JSC::StructureChain::create):
(JSC::StructureChain::createStructure):
* runtime/WriteBarrier.h:
(JSC::WriteBarrierBase::get):
(JSC::WriteBarrierBase::operator*):
(JSC::WriteBarrierBase::operator->):
2011-04-01 Geoffrey Garen <ggaren@apple.com>
Reviewed by Oliver Hunt.
......
......@@ -314,7 +314,7 @@ __ZN3JSC9MarkStack10s_pageSizeE
__ZN3JSC9MarkStack18initializePagesizeEv
__ZN3JSC9Structure17stopIgnoringLeaksEv
__ZN3JSC9Structure18startIgnoringLeaksEv
__ZN3JSC9Structure21addPropertyTransitionEPS0_RKNS_10IdentifierEjPNS_6JSCellERm
__ZN3JSC9Structure21addPropertyTransitionERNS_12JSGlobalDataEPS0_RKNS_10IdentifierEjPNS_6JSCellERm
__ZN3JSC9Structure22materializePropertyMapEv
__ZN3JSC9Structure25changePrototypeTransitionEPS0_NS_7JSValueE
__ZN3JSC9Structure27despecifyDictionaryFunctionERKNS_10IdentifierE
......
......@@ -51,7 +51,7 @@ EXPORTS
?addBytes@MD5@WTF@@QAEXPBEI@Z
?addBytes@SHA1@WTF@@QAEXPBEI@Z
?addCurrentThread@MachineThreads@JSC@@QAEXXZ
?addPropertyTransition@Structure@JSC@@SA?AV?$PassRefPtr@VStructure@JSC@@@WTF@@PAV12@ABVIdentifier@2@IPAVJSCell@2@AAI@Z
?addPropertyTransition@Structure@JSC@@SA?AV?$PassRefPtr@VStructure@JSC@@@WTF@@AAVJSGlobalData@2@PAV12@ABVIdentifier@2@IPAVJSCell@2@AAI@Z
?addPropertyTransitionToExistingStructure@Structure@JSC@@SA?AV?$PassRefPtr@VStructure@JSC@@@WTF@@PAV12@ABVIdentifier@2@IPAVJSCell@2@AAI@Z
?addPropertyWithoutTransition@Structure@JSC@@QAEIABVIdentifier@2@IPAVJSCell@2@@Z
?addSlowCase@Identifier@JSC@@CA?AV?$PassRefPtr@VStringImpl@WTF@@@WTF@@PAVExecState@2@PAVStringImpl@4@@Z
......
......@@ -731,7 +731,7 @@ void CodeBlock::dump(ExecState* exec, const Vector<Instruction>::const_iterator&
case op_resolve_global_dynamic: {
int r0 = (++it)->u.operand;
int id0 = (++it)->u.operand;
JSValue scope = JSValue((++it)->u.jsCell);
JSValue scope = JSValue((++it)->u.jsCell.get());
++it;
int depth = (++it)->u.operand;
printf("[%4d] resolve_global_dynamic\t %s, %s, %s, %d\n", location, registerName(exec, r0).data(), valueToSourceString(exec, scope).utf8().data(), idName(id0, m_identifiers[id0]).data(), depth);
......@@ -1437,13 +1437,11 @@ void CodeBlock::derefStructures(Instruction* vPC) const
}
if (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_chain) || vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_getter_chain) || vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_custom_chain)) {
vPC[4].u.structure->deref();
vPC[5].u.structureChain->deref();
return;
}
if (vPC[0].u.opcode == interpreter->getOpcode(op_put_by_id_transition)) {
vPC[4].u.structure->deref();
vPC[5].u.structure->deref();
vPC[6].u.structureChain->deref();
return;
}
if (vPC[0].u.opcode == interpreter->getOpcode(op_put_by_id_replace)) {
......@@ -1486,13 +1484,11 @@ void CodeBlock::refStructures(Instruction* vPC) const
}
if (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_chain) || vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_getter_chain) || vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_custom_chain)) {
vPC[4].u.structure->ref();
vPC[5].u.structureChain->ref();
return;
}
if (vPC[0].u.opcode == interpreter->getOpcode(op_put_by_id_transition)) {
vPC[4].u.structure->ref();
vPC[5].u.structure->ref();
vPC[6].u.structureChain->ref();
return;
}
if (vPC[0].u.opcode == interpreter->getOpcode(op_put_by_id_replace)) {
......@@ -1527,6 +1523,34 @@ void CodeBlock::markAggregate(MarkStack& markStack)
if (callLinkInfo(i).isLinked())
markStack.append(&callLinkInfo(i).callee);
#endif
#if ENABLE(INTERPRETER)
Interpreter* interpreter = m_globalData->interpreter;
for (size_t size = m_propertyAccessInstructions.size(), i = 0; i < size; ++i) {
Instruction* vPC = &m_instructions[m_propertyAccessInstructions[i]];
if (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_chain) || vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_getter_chain) || vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_custom_chain))
markStack.append(&vPC[5].u.structureChain);
else if (vPC[0].u.opcode == interpreter->getOpcode(op_put_by_id_transition))
markStack.append(&vPC[6].u.structureChain);
}
#endif
#if ENABLE(JIT)
for (size_t size = m_globalResolveInfos.size(), i = 0; i < size; ++i) {
if (Structure* structure = m_globalResolveInfos[i].structure)
structure->markAggregate(markStack);
}
for (size_t size = m_structureStubInfos.size(), i = 0; i < size; ++i)
m_structureStubInfos[i].markAggregate(markStack);
for (size_t size = m_methodCallLinkInfos.size(), i = 0; i < size; ++i) {
if (Structure* structure = m_methodCallLinkInfos[i].cachedStructure) {
// Both members must be filled at the same time
structure->markAggregate(markStack);
ASSERT(!!m_methodCallLinkInfos[i].cachedPrototypeStructure);
m_methodCallLinkInfos[i].cachedPrototypeStructure->markAggregate(markStack);
}
}
#endif
}
HandlerInfo* CodeBlock::handlerForBytecodeOffset(unsigned bytecodeOffset)
......
......@@ -33,6 +33,7 @@
#include "Opcode.h"
#include "PropertySlot.h"
#include "Structure.h"
#include "StructureChain.h"
#include <wtf/VectorTraits.h>
#define POLYMORPHIC_LIST_CACHE_SIZE 8
......@@ -63,7 +64,7 @@ namespace JSC {
Structure* base;
union {
Structure* proto;
StructureChain* chain;
WriteBarrierBase<StructureChain> chain;
} u;
void set(PolymorphicAccessStructureListStubRoutineType _stubRoutine, Structure* _base)
......@@ -82,11 +83,11 @@ namespace JSC {
isChain = false;
}
void set(PolymorphicAccessStructureListStubRoutineType _stubRoutine, Structure* _base, StructureChain* _chain)
void set(JSGlobalData& globalData, JSCell* owner, PolymorphicAccessStructureListStubRoutineType _stubRoutine, Structure* _base, StructureChain* _chain)
{
stubRoutine = _stubRoutine;
base = _base;
u.chain = _chain;
u.chain.set(globalData, owner, _chain);
isChain = true;
}
} list[POLYMORPHIC_LIST_CACHE_SIZE];
......@@ -101,9 +102,9 @@ namespace JSC {
list[0].set(stubRoutine, firstBase, firstProto);
}
PolymorphicAccessStructureList(PolymorphicAccessStructureListStubRoutineType stubRoutine, Structure* firstBase, StructureChain* firstChain)
PolymorphicAccessStructureList(JSGlobalData& globalData, JSCell* owner, PolymorphicAccessStructureListStubRoutineType stubRoutine, Structure* firstBase, StructureChain* firstChain)
{
list[0].set(stubRoutine, firstBase, firstChain);
list[0].set(globalData, owner, stubRoutine, firstBase, firstChain);
}
void derefStructures(int count)
......@@ -115,13 +116,22 @@ namespace JSC {
info.base->deref();
if (info.u.proto) {
if (info.isChain)
info.u.chain->deref();
else
if (!info.isChain)
info.u.proto->deref();
}
}
}
void markAggregate(MarkStack& markStack, int count)
{
for (int i = 0; i < count; ++i) {
PolymorphicStubInfo& info = list[i];
ASSERT(info.base);
if (info.u.chain && info.isChain)
markStack.append(&info.u.chain);
}
}
};
struct Instruction {
......@@ -130,7 +140,7 @@ namespace JSC {
#if !ENABLE(COMPUTED_GOTO_INTERPRETER)
// We have to initialize one of the pointer members to ensure that
// the entire struct is initialized, when opcode is not a pointer.
u.jsCell = 0;
u.jsCell.clear();
#endif
u.opcode = opcode;
}
......@@ -139,13 +149,21 @@ namespace JSC {
{
// We have to initialize one of the pointer members to ensure that
// the entire struct is initialized in 64-bit.
u.jsCell = 0;
u.jsCell.clear();
u.operand = operand;
}
Instruction(Structure* structure) { u.structure = structure; }
Instruction(StructureChain* structureChain) { u.structureChain = structureChain; }
Instruction(JSCell* jsCell) { u.jsCell = jsCell; }
Instruction(JSGlobalData& globalData, JSCell* owner, StructureChain* structureChain)
{
u.structureChain.clear();
u.structureChain.set(globalData, owner, structureChain);
}
Instruction(JSGlobalData& globalData, JSCell* owner, JSCell* jsCell)
{
u.jsCell.clear();
u.jsCell.set(globalData, owner, jsCell);
}
Instruction(PolymorphicAccessStructureList* polymorphicStructures) { u.polymorphicStructures = polymorphicStructures; }
Instruction(PropertySlot::GetValueFunc getterFunc) { u.getterFunc = getterFunc; }
......@@ -153,8 +171,8 @@ namespace JSC {
Opcode opcode;
int operand;
Structure* structure;
StructureChain* structureChain;
JSCell* jsCell;
WriteBarrierBase<StructureChain> structureChain;
WriteBarrierBase<JSCell> jsCell;
PolymorphicAccessStructureList* polymorphicStructures;
PropertySlot::GetValueFunc getterFunc;
} u;
......
......@@ -44,7 +44,6 @@ void StructureStubInfo::deref()
return;
case access_get_by_id_chain:
u.getByIdChain.baseObjectStructure->deref();
u.getByIdChain.chain->deref();
return;
case access_get_by_id_self_list: {
PolymorphicAccessStructureList* polymorphicStructures = u.getByIdSelfList.structureList;
......@@ -60,8 +59,6 @@ void StructureStubInfo::deref()
}
case access_put_by_id_transition:
u.putByIdTransition.previousStructure->deref();
u.putByIdTransition.structure->deref();
u.putByIdTransition.chain->deref();
return;
case access_put_by_id_replace:
u.putByIdReplace.baseObjectStructure->deref();
......@@ -78,6 +75,51 @@ void StructureStubInfo::deref()
ASSERT_NOT_REACHED();
}
}
void StructureStubInfo::markAggregate(MarkStack& markStack)
{
switch (accessType) {
case access_get_by_id_self:
u.getByIdSelf.baseObjectStructure->markAggregate(markStack);
return;
case access_get_by_id_proto:
u.getByIdProto.baseObjectStructure->markAggregate(markStack);
u.getByIdProto.prototypeStructure->markAggregate(markStack);
return;
case access_get_by_id_chain:
u.getByIdChain.baseObjectStructure->markAggregate(markStack);
markStack.append(&u.getByIdChain.chain);
return;
case access_get_by_id_self_list: {
PolymorphicAccessStructureList* polymorphicStructures = u.getByIdSelfList.structureList;
polymorphicStructures->markAggregate(markStack, u.getByIdSelfList.listSize);
return;
}
case access_get_by_id_proto_list: {
PolymorphicAccessStructureList* polymorphicStructures = u.getByIdProtoList.structureList;
polymorphicStructures->markAggregate(markStack, u.getByIdProtoList.listSize);
return;
}
case access_put_by_id_transition:
u.putByIdTransition.previousStructure->markAggregate(markStack);
u.putByIdTransition.structure->markAggregate(markStack);
markStack.append(&u.putByIdTransition.chain);
return;
case access_put_by_id_replace:
u.putByIdReplace.baseObjectStructure->markAggregate(markStack);
return;
case access_get_by_id:
case access_put_by_id:
case access_get_by_id_generic:
case access_put_by_id_generic:
case access_get_array_length:
case access_get_string_length:
// These instructions don't ref their Structures.
return;
default:
ASSERT_NOT_REACHED();
}
}
#endif
} // namespace JSC
......@@ -77,15 +77,14 @@ namespace JSC {
prototypeStructure->ref();
}
void initGetByIdChain(Structure* baseObjectStructure, StructureChain* chain)
void initGetByIdChain(JSGlobalData& globalData, JSCell* owner, Structure* baseObjectStructure, StructureChain* chain)
{
accessType = access_get_by_id_chain;
u.getByIdChain.baseObjectStructure = baseObjectStructure;
baseObjectStructure->ref();
u.getByIdChain.chain = chain;
chain->ref();
u.getByIdChain.chain.set(globalData, owner, chain);
}
void initGetByIdSelfList(PolymorphicAccessStructureList* structureList, int listSize)
......@@ -106,7 +105,7 @@ namespace JSC {
// PutById*
void initPutByIdTransition(Structure* previousStructure, Structure* structure, StructureChain* chain)
void initPutByIdTransition(JSGlobalData& globalData, JSCell* owner, Structure* previousStructure, Structure* structure, StructureChain* chain)
{
accessType = access_put_by_id_transition;
......@@ -116,8 +115,7 @@ namespace JSC {
u.putByIdTransition.structure = structure;
structure->ref();
u.putByIdTransition.chain = chain;
chain->ref();
u.putByIdTransition.chain.set(globalData, owner, chain);
}
void initPutByIdReplace(Structure* baseObjectStructure)
......@@ -129,6 +127,7 @@ namespace JSC {
}
void deref();
void markAggregate(MarkStack&);
bool seenOnce()
{
......@@ -153,7 +152,7 @@ namespace JSC {
} getByIdProto;
struct {
Structure* baseObjectStructure;
StructureChain* chain;
WriteBarrierBase<StructureChain> chain;
} getByIdChain;
struct {
PolymorphicAccessStructureList* structureList;
......@@ -166,7 +165,7 @@ namespace JSC {
struct {
Structure* previousStructure;
Structure* structure;
StructureChain* chain;
WriteBarrierBase<StructureChain> chain;
} putByIdTransition;
struct {
Structure* baseObjectStructure;
......
......@@ -925,7 +925,7 @@ PassRefPtr<Label> BytecodeGenerator::emitJumpIfNotFunctionCall(RegisterID* cond,
emitOpcode(op_jneq_ptr);
instructions().append(cond->index());
instructions().append(m_scopeChain->globalObject->callFunction());
instructions().append(Instruction(*m_globalData, m_codeBlock->ownerExecutable(), m_scopeChain->globalObject->callFunction()));
instructions().append(target->bind(begin, instructions().size()));
return target;
}
......@@ -936,7 +936,7 @@ PassRefPtr<Label> BytecodeGenerator::emitJumpIfNotFunctionApply(RegisterID* cond
emitOpcode(op_jneq_ptr);
instructions().append(cond->index());
instructions().append(m_scopeChain->globalObject->applyFunction());
instructions().append(Instruction(*m_globalData, m_codeBlock->ownerExecutable(), m_scopeChain->globalObject->applyFunction()));
instructions().append(target->bind(begin, instructions().size()));
return target;
}
......
......@@ -104,10 +104,35 @@ template <> struct HandleTypes<Unknown> {
};
template <typename Base, typename T> struct HandleConverter {
T* operator->() { return static_cast<Base*>(this)->get(); }
const T* operator->() const { return static_cast<const Base*>(this)->get(); }
T* operator*() { return static_cast<Base*>(this)->get(); }
const T* operator*() const { return static_cast<const Base*>(this)->get(); }
T* operator->()
{
#if ENABLE(JSC_ZOMBIES)
ASSERT(!static_cast<const Base*>(this)->get() || !static_cast<const Base*>(this)->get()->isZombie());
#endif
return static_cast<Base*>(this)->get();
}
const T* operator->() const
{
#if ENABLE(JSC_ZOMBIES)
ASSERT(!static_cast<const Base*>(this)->get() || !static_cast<const Base*>(this)->get()->isZombie());
#endif
return static_cast<const Base*>(this)->get();
}
T* operator*()
{
#if ENABLE(JSC_ZOMBIES)
ASSERT(!static_cast<const Base*>(this)->get() || !static_cast<const Base*>(this)->get()->isZombie());
#endif
return static_cast<Base*>(this)->get();
}
const T* operator*() const
{
#if ENABLE(JSC_ZOMBIES)
ASSERT(!static_cast<const Base*>(this)->get() || !static_cast<const Base*>(this)->get()->isZombie());
#endif
return static_cast<const Base*>(this)->get();
}
};
template <typename Base> struct HandleConverter<Base, Unknown> {
......@@ -118,7 +143,13 @@ template <typename Base> struct HandleConverter<Base, Unknown> {
bool isUndefinedOrNull() const { return jsValue().isUndefinedOrNull(); }
private:
JSValue jsValue() const { return static_cast<const Base*>(this)->get(); }
JSValue jsValue() const
{
#if ENABLE(JSC_ZOMBIES)
ASSERT(!static_cast<const Base*>(this)->get() || !static_cast<const Base*>(this)->get().isZombie());
#endif
return static_cast<const Base*>(this)->get();
}
};
template <typename T> class Handle : public HandleBase, public HandleConverter<Handle<T>, T> {
......
......@@ -3537,10 +3537,9 @@ skip_id_custom_self:
to ptr, using pointer equality.
*/
int src = vPC[1].u.operand;
JSValue ptr = JSValue(vPC[2].u.jsCell);
int target = vPC[3].u.operand;
JSValue srcValue = callFrame->r(src).jsValue();
if (srcValue != ptr) {
if (srcValue != vPC[2].u.jsCell.get()) {
vPC += target;
NEXT_INSTRUCTION();
}
......
......@@ -762,7 +762,7 @@ void JIT::emit_op_jneq_null(Instruction* currentInstruction)
void JIT::emit_op_jneq_ptr(Instruction* currentInstruction)
{
unsigned src = currentInstruction[1].u.operand;
JSCell* ptr = currentInstruction[2].u.jsCell;
JSCell* ptr = currentInstruction[2].u.jsCell.get();
unsigned target = currentInstruction[3].u.operand;
emitGetVirtualRegister(src, regT0);
......
......@@ -979,7 +979,7 @@ void JIT::emit_op_jneq_null(Instruction* currentInstruction)
void JIT::emit_op_jneq_ptr(Instruction* currentInstruction)
{
unsigned src = currentInstruction[1].u.operand;
JSCell* ptr = currentInstruction[2].u.jsCell;
JSCell* ptr = currentInstruction[2].u.jsCell.get();
unsigned target = currentInstruction[3].u.operand;
emitLoad(src, regT1, regT0);
......
......@@ -979,8 +979,7 @@ void JIT::privateCompileGetByIdChainList(StructureStubInfo* stubInfo, Polymorphi
// Track the stub we have created so that it will be deleted later.
structure->ref();
chain->ref();
prototypeStructures->list[currentIndex].set(entryLabel, structure, chain);
prototypeStructures->list[currentIndex].set(callFrame->globalData(), m_codeBlock->ownerExecutable(), entryLabel, structure, chain);
// Finally patch the jump to slow case back in the hot path to jump here instead.
CodeLocationJump jumpLocation = stubInfo->hotPathBegin.jumpAtOffset(patchOffsetGetByIdBranchToSlowCase);
......
......@@ -1007,8 +1007,7 @@ void JIT::privateCompileGetByIdChainList(StructureStubInfo* stubInfo, Polymorphi
// Track the stub we have created so that it will be deleted later.
structure->ref();
chain->ref();
prototypeStructures->list[currentIndex].set(entryLabel, structure, chain);
prototypeStructures->list[currentIndex].set(callFrame->globalData(), m_codeBlock->ownerExecutable(), entryLabel, structure, chain);
// Finally patch the jump to slow case back in the hot path to jump here instead.
CodeLocationJump jumpLocation = stubInfo->hotPathBegin.jumpAtOffset(patchOffsetGetByIdBranchToSlowCase);
......
......@@ -771,7 +771,7 @@ NEVER_INLINE void JITThunks::tryCachePutByID(CallFrame* callFrame, CodeBlock* co
normalizePrototypeChain(callFrame, baseCell);
StructureChain* prototypeChain = structure->prototypeChain(callFrame);
stubInfo->initPutByIdTransition(structure->previousID(), structure, prototypeChain);
stubInfo->initPutByIdTransition(callFrame->globalData(), codeBlock->ownerExecutable(), structure->previousID(), structure, prototypeChain);
JIT::compilePutByIdTransition(callFrame->scopeChain()->globalData, codeBlock, stubInfo, structure->previousID(), structure, slot.cachedOffset(), prototypeChain, returnAddress, direct);
return;
}
......@@ -866,7 +866,7 @@ NEVER_INLINE void JITThunks::tryCacheGetByID(CallFrame* callFrame, CodeBlock* co
}
StructureChain* prototypeChain = structure->prototypeChain(callFrame);
stubInfo->initGetByIdChain(structure, prototypeChain);
stubInfo->initGetByIdChain(callFrame->globalData(), codeBlock->ownerExecutable(), structure, prototypeChain);
JIT::compileGetByIdChain(callFrame->scopeChain()->globalData, callFrame, codeBlock, stubInfo, structure, prototypeChain, count, propertyName, slot, offset, returnAddress);
}
......@@ -1553,7 +1553,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_id_self_fail)
return JSValue::encode(result);
}
static PolymorphicAccessStructureList* getPolymorphicAccessStructureListSlot(StructureStubInfo* stubInfo, int& listIndex)
static PolymorphicAccessStructureList* getPolymorphicAccessStructureListSlot(JSGlobalData& globalData, ScriptExecutable* owner, StructureStubInfo* stubInfo, int& listIndex)
{
PolymorphicAccessStructureList* prototypeStructureList = 0;
listIndex = 1;
......@@ -1565,7 +1565,7 @@ static PolymorphicAccessStructureList* getPolymorphicAccessStructureListSlot(Str
stubInfo->initGetByIdProtoList(prototypeStructureList, 2);
break;
case access_get_by_id_chain:
prototypeStructureList = new PolymorphicAccessStructureList(stubInfo->stubRoutine, stubInfo->u.getByIdChain.baseObjectStructure, stubInfo->u.getByIdChain.chain);
prototypeStructureList = new PolymorphicAccessStructureList(globalData, owner, stubInfo->stubRoutine, stubInfo->u.getByIdChain.baseObjectStructure, stubInfo->u.getByIdChain.chain.get());
stubInfo->stubRoutine = CodeLocationLabel();
stubInfo->initGetByIdProtoList(prototypeStructureList, 2);
break;
......@@ -1653,7 +1653,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_id_proto_list)
}
int listIndex;
PolymorphicAccessStructureList* prototypeStructureList = getPolymorphicAccessStructureListSlot(stubInfo, listIndex);
PolymorphicAccessStructureList* prototypeStructureList = getPolymorphicAccessStructureListSlot(callFrame->globalData(), codeBlock->ownerExecutable(), stubInfo, listIndex);
if (listIndex < POLYMORPHIC_LIST_CACHE_SIZE) {
JIT::compileGetByIdProtoList(callFrame->scopeChain()->globalData, callFrame, codeBlock, stubInfo, prototypeStructureList, listIndex, structure, slotBaseObject->structure(), propertyName, slot, offset);
......@@ -1663,7 +1663,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_id_proto_list)
} else if (size_t count = normalizePrototypeChain(callFrame, baseValue, slot.slotBase(), propertyName, offset)) {
ASSERT(!baseValue.asCell()->structure()->isDictionary());
int listIndex;
PolymorphicAccessStructureList* prototypeStructureList = getPolymorphicAccessStructureListSlot(stubInfo, listIndex);
PolymorphicAccessStructureList* prototypeStructureList = getPolymorphicAccessStructureListSlot(callFrame->globalData(), codeBlock->ownerExecutable(), stubInfo, listIndex);
if (listIndex < POLYMORPHIC_LIST_CACHE_SIZE) {
StructureChain* protoChain = structure->prototypeChain(callFrame);
......
......@@ -68,6 +68,7 @@ namespace JSC {
friend class MarkedSpace;
friend class MarkedBlock;
friend class ScopeChainNode;
friend class StructureChain;
private:
explicit JSCell(Structure*);
......
......@@ -184,6 +184,7 @@ JSGlobalData::JSGlobalData(GlobalDataType globalDataType, ThreadStackType thread
programExecutableStructure = ProgramExecutable::createStructure(*this, jsNull());
functionExecutableStructure = FunctionExecutable::createStructure(*this, jsNull());
dummyMarkableCellStructure = JSCell::createDummyStructure(*this);
structureChainStructure = StructureChain::createStructure(*this, jsNull());
interpreter = new Interpreter(*this);
if (globalDataType == Default)
......
......@@ -161,6 +161,7 @@ namespace JSC {
RefPtr<Structure> programExecutableStructure;
RefPtr<Structure> functionExecutableStructure;
RefPtr<Structure> dummyMarkableCellStructure;
RefPtr<Structure> structureChainStructure;