Skip to content

Commit

Permalink
Merge r271544 - [JSC] Clean up DFGPreciseLocalClobberize to avoid dup…
Browse files Browse the repository at this point in the history
…licate code

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

Reviewed by Filip Pizlo.

This patch cleans up DFGPreciseLocalClobberize by extracting code to lambda to remove duplicate code.

* dfg/DFGPreciseLocalClobberize.h:
(JSC::DFG::PreciseLocalClobberizeAdaptor::readTop):
  • Loading branch information
Constellation authored and carlosgcampos committed Mar 18, 2021
1 parent 70661b7 commit 27cb7bb
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 22 deletions.
12 changes: 12 additions & 0 deletions Source/JavaScriptCore/ChangeLog
@@ -1,3 +1,15 @@
2021-01-15 Yusuke Suzuki <ysuzuki@apple.com>

[JSC] Clean up DFGPreciseLocalClobberize to avoid duplicate code
https://bugs.webkit.org/show_bug.cgi?id=220670

Reviewed by Filip Pizlo.

This patch cleans up DFGPreciseLocalClobberize by extracting code to lambda to remove duplicate code.

* dfg/DFGPreciseLocalClobberize.h:
(JSC::DFG::PreciseLocalClobberizeAdaptor::readTop):

2020-12-16 Tadeu Zagallo <tzagallo@apple.com>

propertyNameEnumerator must check it can still take the fast path after getGenericPropertyNames
Expand Down
50 changes: 28 additions & 22 deletions Source/JavaScriptCore/dfg/DFGPreciseLocalClobberize.h
Expand Up @@ -105,6 +105,30 @@ class PreciseLocalClobberizeAdaptor {

void readTop()
{
auto readWorld = [&] (Node* node) {
// All of the outermost arguments, except this, are read in sloppy mode.
if (!m_graph.m_codeBlock->ownerExecutable()->isInStrictContext()) {
for (unsigned i = m_graph.m_codeBlock->numParameters(); i--;)
m_read(virtualRegisterForArgumentIncludingThis(i));
}

// The stack header is read.
for (unsigned i = 0; i < CallFrameSlot::thisArgument; ++i)
m_read(VirtualRegister(i));

// Read all of the inline arguments and call frame headers that we didn't already capture.
for (InlineCallFrame* inlineCallFrame = node->origin.semantic.inlineCallFrame(); inlineCallFrame; inlineCallFrame = inlineCallFrame->getCallerInlineFrameSkippingTailCalls()) {
if (!inlineCallFrame->isInStrictContext()) {
for (unsigned i = inlineCallFrame->argumentsWithFixup.size(); i--;)
m_read(VirtualRegister(inlineCallFrame->stackOffset + virtualRegisterForArgumentIncludingThis(i).offset()));
}
if (inlineCallFrame->isClosureCall)
m_read(VirtualRegister(inlineCallFrame->stackOffset + CallFrameSlot::callee));
if (inlineCallFrame->isVarargs())
m_read(VirtualRegister(inlineCallFrame->stackOffset + CallFrameSlot::argumentCountIncludingThis));
}
};

auto readFrame = [&] (InlineCallFrame* inlineCallFrame, unsigned numberOfArgumentsToSkip) {
if (!inlineCallFrame) {
// Read the outermost arguments and argument count.
Expand All @@ -122,8 +146,10 @@ class PreciseLocalClobberizeAdaptor {

auto readSpread = [&] (Node* spread) {
ASSERT(spread->op() == Spread || spread->op() == PhantomSpread);
if (!spread->child1()->isPhantomAllocation())
if (!spread->child1()->isPhantomAllocation()) {
readWorld(spread);
return;
}

ASSERT(spread->child1()->op() == PhantomCreateRest || spread->child1()->op() == PhantomNewArrayBuffer);
if (spread->child1()->op() == PhantomNewArrayBuffer) {
Expand Down Expand Up @@ -238,27 +264,7 @@ class PreciseLocalClobberizeAdaptor {
}

default: {
// All of the outermost arguments, except this, are read in sloppy mode.
if (!m_graph.m_codeBlock->ownerExecutable()->isInStrictContext()) {
for (unsigned i = m_graph.m_codeBlock->numParameters(); i--;)
m_read(virtualRegisterForArgumentIncludingThis(i));
}

// The stack header is read.
for (unsigned i = 0; i < CallFrameSlot::thisArgument; ++i)
m_read(VirtualRegister(i));

// Read all of the inline arguments and call frame headers that we didn't already capture.
for (InlineCallFrame* inlineCallFrame = m_node->origin.semantic.inlineCallFrame(); inlineCallFrame; inlineCallFrame = inlineCallFrame->getCallerInlineFrameSkippingTailCalls()) {
if (!inlineCallFrame->isInStrictContext()) {
for (unsigned i = inlineCallFrame->argumentsWithFixup.size(); i--;)
m_read(VirtualRegister(inlineCallFrame->stackOffset + virtualRegisterForArgumentIncludingThis(i).offset()));
}
if (inlineCallFrame->isClosureCall)
m_read(VirtualRegister(inlineCallFrame->stackOffset + CallFrameSlot::callee));
if (inlineCallFrame->isVarargs())
m_read(VirtualRegister(inlineCallFrame->stackOffset + CallFrameSlot::argumentCountIncludingThis));
}
readWorld(m_node);
break;
} }
}
Expand Down

0 comments on commit 27cb7bb

Please sign in to comment.