Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Improve access case printing and show inline capacity for structures
https://bugs.webkit.org/show_bug.cgi?id=230357

Reviewed by Saam Barati.

This just makes the printing of access cases slightly more readable.

* bytecode/AccessCase.cpp:
(JSC::AccessCase::dump const):
* bytecode/AccessCase.h:
(JSC::AccessCase::dumpImpl const):
* bytecode/GetterSetterAccessCase.cpp:
(JSC::GetterSetterAccessCase::dumpImpl const):
* bytecode/GetterSetterAccessCase.h:
* bytecode/InstanceOfAccessCase.cpp:
(JSC::InstanceOfAccessCase::dumpImpl const):
* bytecode/InstanceOfAccessCase.h:
* bytecode/ProxyableAccessCase.cpp:
(JSC::ProxyableAccessCase::dumpImpl const):
* bytecode/ProxyableAccessCase.h:
* heap/Heap.cpp:
(JSC::Heap::runEndPhase):
* runtime/JSCJSValue.cpp:
(JSC::JSValue::dumpInContextAssumingStructure const):
* runtime/Structure.cpp:
(JSC::Structure::dump const):


Canonical link: https://commits.webkit.org/241805@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@282664 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
justinmichaud committed Sep 17, 2021
1 parent f6e0158 commit eb8b4f9
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 20 deletions.
29 changes: 29 additions & 0 deletions Source/JavaScriptCore/ChangeLog
@@ -1,3 +1,32 @@
2021-09-17 Justin Michaud <justin_michaud@apple.com>

Improve access case printing and show inline capacity for structures
https://bugs.webkit.org/show_bug.cgi?id=230357

Reviewed by Saam Barati.

This just makes the printing of access cases slightly more readable.

* bytecode/AccessCase.cpp:
(JSC::AccessCase::dump const):
* bytecode/AccessCase.h:
(JSC::AccessCase::dumpImpl const):
* bytecode/GetterSetterAccessCase.cpp:
(JSC::GetterSetterAccessCase::dumpImpl const):
* bytecode/GetterSetterAccessCase.h:
* bytecode/InstanceOfAccessCase.cpp:
(JSC::InstanceOfAccessCase::dumpImpl const):
* bytecode/InstanceOfAccessCase.h:
* bytecode/ProxyableAccessCase.cpp:
(JSC::ProxyableAccessCase::dumpImpl const):
* bytecode/ProxyableAccessCase.h:
* heap/Heap.cpp:
(JSC::Heap::runEndPhase):
* runtime/JSCJSValue.cpp:
(JSC::JSValue::dumpInContextAssumingStructure const):
* runtime/Structure.cpp:
(JSC::Structure::dump const):

2021-09-17 Justin Michaud <justin_michaud@apple.com>

PutByVal and PutPrivateName ICs should emit a write barrier if a butterfly might be allocated
Expand Down
19 changes: 12 additions & 7 deletions Source/JavaScriptCore/bytecode/AccessCase.cpp
Expand Up @@ -853,8 +853,9 @@ bool AccessCase::canReplace(const AccessCase& other) const

void AccessCase::dump(PrintStream& out) const
{
out.print("\n", m_type, ":(");
out.print("\n", m_type, ": {");

Indenter indent;
CommaPrinter comma;

out.print(comma, m_state);
Expand All @@ -863,21 +864,25 @@ void AccessCase::dump(PrintStream& out) const
if (isValidOffset(m_offset))
out.print(comma, "offset = ", m_offset);

++indent;

if (m_polyProtoAccessChain) {
out.print(comma, "prototype access chain = ");
out.print("\n", indent, "prototype access chain = ");
m_polyProtoAccessChain->dump(structure(), out);
} else {
if (m_type == Transition || m_type == Delete || m_type == SetPrivateBrand)
out.print(comma, "structure = ", pointerDump(structure()), " -> ", pointerDump(newStructure()));
out.print("\n", indent, "from structure = ", pointerDump(structure()),
"\n", indent, "to structure = ", pointerDump(newStructure()));
else if (m_structure)
out.print(comma, "structure = ", pointerDump(m_structure.get()));
out.print("\n", indent, "structure = ", pointerDump(m_structure.get()));
}

if (!m_conditionSet.isEmpty())
out.print(comma, "conditions = ", m_conditionSet);
out.print("\n", indent, "conditions = ", m_conditionSet);

dumpImpl(out, comma, indent);

dumpImpl(out, comma);
out.print(")");
out.print("}");
}

bool AccessCase::visitWeak(VM& vm) const
Expand Down
2 changes: 1 addition & 1 deletion Source/JavaScriptCore/bytecode/AccessCase.h
Expand Up @@ -246,7 +246,7 @@ class AccessCase : public ThreadSafeRefCounted<AccessCase> {
bool canReplace(const AccessCase& other) const;

void dump(PrintStream& out) const;
virtual void dumpImpl(PrintStream&, CommaPrinter&) const { }
virtual void dumpImpl(PrintStream&, CommaPrinter&, Indenter&) const { }

virtual ~AccessCase();

Expand Down
4 changes: 2 additions & 2 deletions Source/JavaScriptCore/bytecode/GetterSetterAccessCase.cpp
Expand Up @@ -112,9 +112,9 @@ JSObject* GetterSetterAccessCase::alternateBase() const
return Base::alternateBase();
}

void GetterSetterAccessCase::dumpImpl(PrintStream& out, CommaPrinter& comma) const
void GetterSetterAccessCase::dumpImpl(PrintStream& out, CommaPrinter& comma, Indenter& indent) const
{
Base::dumpImpl(out, comma);
Base::dumpImpl(out, comma, indent);
out.print(comma, "customSlotBase = ", RawPointer(customSlotBase()));
if (callLinkInfo())
out.print(comma, "callLinkInfo = ", RawPointer(callLinkInfo()));
Expand Down
2 changes: 1 addition & 1 deletion Source/JavaScriptCore/bytecode/GetterSetterAccessCase.h
Expand Up @@ -62,7 +62,7 @@ class GetterSetterAccessCase final : public ProxyableAccessCase {
const ObjectPropertyConditionSet&, RefPtr<PolyProtoAccessChain>&&, bool viaProxy = false,
FunctionPtr<CustomAccessorPtrTag> customSetter = nullptr, JSObject* customSlotBase = nullptr);

void dumpImpl(PrintStream&, CommaPrinter&) const final;
void dumpImpl(PrintStream&, CommaPrinter&, Indenter&) const final;
Ref<AccessCase> clone() const final;

~GetterSetterAccessCase() final;
Expand Down
4 changes: 2 additions & 2 deletions Source/JavaScriptCore/bytecode/InstanceOfAccessCase.cpp
Expand Up @@ -39,9 +39,9 @@ Ref<AccessCase> InstanceOfAccessCase::create(
return adoptRef(*new InstanceOfAccessCase(vm, owner, accessType, structure, conditionSet, prototype));
}

void InstanceOfAccessCase::dumpImpl(PrintStream& out, CommaPrinter& comma) const
void InstanceOfAccessCase::dumpImpl(PrintStream& out, CommaPrinter& comma, Indenter& indent) const
{
Base::dumpImpl(out, comma);
Base::dumpImpl(out, comma, indent);
out.print(comma, "prototype = ", JSValue(prototype()));
}

Expand Down
2 changes: 1 addition & 1 deletion Source/JavaScriptCore/bytecode/InstanceOfAccessCase.h
Expand Up @@ -42,7 +42,7 @@ class InstanceOfAccessCase final : public AccessCase {

JSObject* prototype() const { return m_prototype.get(); }

void dumpImpl(PrintStream&, CommaPrinter&) const final;
void dumpImpl(PrintStream&, CommaPrinter&, Indenter&) const final;
Ref<AccessCase> clone() const final;

~InstanceOfAccessCase() final;
Expand Down
4 changes: 2 additions & 2 deletions Source/JavaScriptCore/bytecode/ProxyableAccessCase.cpp
Expand Up @@ -55,9 +55,9 @@ Ref<AccessCase> ProxyableAccessCase::clone() const
return result;
}

void ProxyableAccessCase::dumpImpl(PrintStream& out, CommaPrinter& comma) const
void ProxyableAccessCase::dumpImpl(PrintStream& out, CommaPrinter& comma, Indenter& indent) const
{
Base::dumpImpl(out, comma);
Base::dumpImpl(out, comma, indent);
out.print(comma, "viaProxy = ", viaProxy());
out.print(comma, "additionalSet = ", RawPointer(additionalSet()));
}
Expand Down
2 changes: 1 addition & 1 deletion Source/JavaScriptCore/bytecode/ProxyableAccessCase.h
Expand Up @@ -40,7 +40,7 @@ class ProxyableAccessCase : public AccessCase {
static Ref<AccessCase> create(VM&, JSCell*, AccessType, CacheableIdentifier, PropertyOffset, Structure*, const ObjectPropertyConditionSet& = ObjectPropertyConditionSet(),
bool viaProxy = false, WatchpointSet* additionalSet = nullptr, RefPtr<PolyProtoAccessChain>&& = nullptr);

void dumpImpl(PrintStream&, CommaPrinter&) const override;
void dumpImpl(PrintStream&, CommaPrinter&, Indenter&) const override;
Ref<AccessCase> clone() const override;

~ProxyableAccessCase() override;
Expand Down
2 changes: 1 addition & 1 deletion Source/JavaScriptCore/runtime/JSCJSValue.cpp
Expand Up @@ -313,7 +313,7 @@ void JSValue::dumpInContextAssumingStructure(
out.print("BigInt[heap-allocated]: addr=", RawPointer(asCell()), ", length=", jsCast<JSBigInt*>(asCell())->length(), ", sign=", jsCast<JSBigInt*>(asCell())->sign());
else if (structure->classInfo()->isSubClassOf(JSObject::info())) {
out.print("Object: ", RawPointer(asCell()));
out.print(" with butterfly ", RawPointer(asObject(asCell())->butterfly()));
out.print(" with butterfly ", RawPointer(asObject(asCell())->butterfly()), "(base=", RawPointer(asObject(asCell())->butterfly()->base(structure)), ")");
out.print(" (Structure ", inContext(*structure, context), ")");
} else {
out.print("Cell: ", RawPointer(asCell()));
Expand Down
8 changes: 6 additions & 2 deletions Source/JavaScriptCore/runtime/Structure.cpp
Expand Up @@ -1322,8 +1322,12 @@ Ref<StructureShape> Structure::toStructureShape(JSValue value, bool& sawPolyProt

void Structure::dump(PrintStream& out) const
{
out.print(RawPointer(this), ":[", RawPointer(reinterpret_cast<void*>(id())), ", ", classInfo()->className, ", {");

auto* structureID = reinterpret_cast<void*>(id());
out.print(RawPointer(this), ":[", RawPointer(structureID),
"/", (uint32_t)(reinterpret_cast<uintptr_t>(structureID)), ", ",
classInfo()->className, ", (", inlineSize(), "/", inlineCapacity(), ", ",
outOfLineSize(), "/", outOfLineCapacity(), "){");

CommaPrinter comma;

const_cast<Structure*>(this)->forEachPropertyConcurrently(
Expand Down

0 comments on commit eb8b4f9

Please sign in to comment.