X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/2d39b0e377c0896910ee49ae70082ba665faf986..refs/heads/master:/bytecode/GetByIdVariant.cpp diff --git a/bytecode/GetByIdVariant.cpp b/bytecode/GetByIdVariant.cpp index b8bedce..dd8e8df 100644 --- a/bytecode/GetByIdVariant.cpp +++ b/bytecode/GetByIdVariant.cpp @@ -26,10 +26,79 @@ #include "config.h" #include "GetByIdVariant.h" +#include "CallLinkStatus.h" #include "JSCInlines.h" +#include namespace JSC { +GetByIdVariant::GetByIdVariant( + const StructureSet& structureSet, PropertyOffset offset, + const IntendedStructureChain* chain, std::unique_ptr callLinkStatus) + : m_structureSet(structureSet) + , m_alternateBase(nullptr) + , m_offset(offset) + , m_callLinkStatus(WTF::move(callLinkStatus)) +{ + if (!structureSet.size()) { + ASSERT(offset == invalidOffset); + ASSERT(!chain); + } + + if (chain && chain->size()) { + m_alternateBase = chain->terminalPrototype(); + chain->gatherChecks(m_constantChecks); + } +} + +GetByIdVariant::~GetByIdVariant() { } + +GetByIdVariant::GetByIdVariant(const GetByIdVariant& other) + : GetByIdVariant() +{ + *this = other; +} + +GetByIdVariant& GetByIdVariant::operator=(const GetByIdVariant& other) +{ + m_structureSet = other.m_structureSet; + m_constantChecks = other.m_constantChecks; + m_alternateBase = other.m_alternateBase; + m_offset = other.m_offset; + if (other.m_callLinkStatus) + m_callLinkStatus = std::make_unique(*other.m_callLinkStatus); + else + m_callLinkStatus = nullptr; + return *this; +} + +StructureSet GetByIdVariant::baseStructure() const +{ + if (!m_alternateBase) + return structureSet(); + + Structure* structure = structureFor(m_constantChecks, m_alternateBase); + RELEASE_ASSERT(structure); + return structure; +} + +bool GetByIdVariant::attemptToMerge(const GetByIdVariant& other) +{ + if (m_alternateBase != other.m_alternateBase) + return false; + if (m_offset != other.m_offset) + return false; + if (m_callLinkStatus || other.m_callLinkStatus) + return false; + if (!areCompatible(m_constantChecks, other.m_constantChecks)) + return false; + + mergeInto(other.m_constantChecks, m_constantChecks); + m_structureSet.merge(other.m_structureSet); + + return true; +} + void GetByIdVariant::dump(PrintStream& out) const { dumpInContext(out, 0); @@ -44,8 +113,13 @@ void GetByIdVariant::dumpInContext(PrintStream& out, DumpContext* context) const out.print( "<", inContext(structureSet(), context), ", ", - pointerDumpInContext(chain(), context), ", ", - inContext(specificValue(), context), ", ", offset(), ">"); + "[", listDumpInContext(m_constantChecks, context), "]"); + if (m_alternateBase) + out.print(", alternateBase = ", inContext(JSValue(m_alternateBase), context)); + out.print(", offset = ", offset()); + if (m_callLinkStatus) + out.print(", call = ", *m_callLinkStatus); + out.print(">"); } } // namespace JSC