Skip to content

Commit 130d1c0

Browse files
committed
reapply 5dd8842 change
1 parent 0ddf6f4 commit 130d1c0

File tree

3 files changed

+35
-10
lines changed

3 files changed

+35
-10
lines changed

Source/JavaScriptCore/interpreter/Interpreter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,9 +505,9 @@ void Interpreter::getAsyncStackTrace(JSCell* owner, Vector<StackFrame>& results,
505505
// If a CodeBlock doesn't already exist, the stack trace will only show the filename and won't show line column
506506
if (CodeBlock* codeBlock = executable->codeBlockForCall()) {
507507
BytecodeIndex bytecodeIndex = computeBytecodeIndex(codeBlock, currentGenerator);
508-
results.append(StackFrame(vm, owner, asyncFunction, codeBlock, bytecodeIndex));
508+
results.append(StackFrame(vm, owner, asyncFunction, codeBlock, bytecodeIndex, /* isAsyncFrame */ true));
509509
} else
510-
results.append(StackFrame(vm, owner, asyncFunction, /* isAsyncFrameWithoutCodeBlock */ true));
510+
results.append(StackFrame(vm, owner, asyncFunction, /* isAsyncFrame */ true));
511511
}
512512
}
513513
currentGenerator = getParentGenerator(currentGenerator);

Source/JavaScriptCore/runtime/StackFrame.cpp

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,16 @@ StackFrame::StackFrame(VM& vm, JSCell* owner, JSCell* callee, CodeBlock* codeBlo
5252
{
5353
}
5454

55+
StackFrame::StackFrame(VM& vm, JSCell* owner, JSCell* callee, CodeBlock* codeBlock, BytecodeIndex bytecodeIndex, bool isAsyncFrame)
56+
: m_frameData(JSFrameData {
57+
WriteBarrier<JSCell>(vm, owner, callee),
58+
WriteBarrier<CodeBlock>(vm, owner, codeBlock),
59+
bytecodeIndex,
60+
isAsyncFrame
61+
})
62+
{
63+
}
64+
5565
StackFrame::StackFrame(VM& vm, JSCell* owner, CodeBlock* codeBlock, BytecodeIndex bytecodeIndex)
5666
: m_frameData(JSFrameData {
5767
WriteBarrier<JSCell>(),
@@ -71,12 +81,12 @@ StackFrame::StackFrame(Wasm::IndexOrName indexOrName, size_t functionIndex)
7181
{
7282
}
7383

74-
StackFrame::StackFrame(VM& vm, JSCell* owner, JSCell* callee, bool isAsyncFrameWithoutCodeBlock)
84+
StackFrame::StackFrame(VM& vm, JSCell* owner, JSCell* callee, bool isAsyncFrame)
7585
: m_frameData(JSFrameData {
7686
WriteBarrier<JSCell>(vm, owner, callee),
7787
WriteBarrier<CodeBlock>(),
7888
BytecodeIndex(),
79-
isAsyncFrameWithoutCodeBlock
89+
isAsyncFrame
8090
})
8191
{
8292
}
@@ -147,7 +157,7 @@ String StackFrame::sourceURL(VM& vm) const
147157
{
148158
return WTF::switchOn(m_frameData,
149159
[&vm, this](const JSFrameData& jsFrame) -> String {
150-
if (jsFrame.m_isAsyncFrameWithoutCodeBlock) {
160+
if (isAsyncFrameWithoutCodeBlock()) {
151161
ASSERT(jsFrame.callee);
152162
ASSERT(!jsFrame.codeBlock);
153163
JSFunction* calleeFn = jsDynamicCast<JSFunction*>(jsFrame.callee.get());
@@ -171,7 +181,7 @@ String StackFrame::sourceURLStripped(VM& vm) const
171181
{
172182
return WTF::switchOn(m_frameData,
173183
[&vm, this](const JSFrameData& jsFrame) -> String {
174-
if (jsFrame.m_isAsyncFrameWithoutCodeBlock) {
184+
if (isAsyncFrameWithoutCodeBlock()) {
175185
ASSERT(jsFrame.callee);
176186
ASSERT(!jsFrame.codeBlock);
177187
JSFunction* calleeFn = jsDynamicCast<JSFunction*>(jsFrame.callee.get());
@@ -214,7 +224,14 @@ String StackFrame::functionName(VM& vm) const
214224
if (auto* executable = jsDynamicCast<FunctionExecutable*>(jsFrame.codeBlock->ownerExecutable()))
215225
name = executable->ecmaName().impl();
216226
}
217-
return name.isNull() ? emptyString() : name;
227+
228+
if (name.isNull())
229+
return emptyString();
230+
231+
if (jsFrame.m_isAsyncFrame)
232+
return makeString("async "_s, name);
233+
234+
return name;
218235
},
219236
[](const WasmFrameData& wasmFrame) -> String {
220237
if (wasmFrame.functionIndexOrName.isEmpty() || !wasmFrame.functionIndexOrName.nameSection())

Source/JavaScriptCore/runtime/StackFrame.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ struct JSFrameData {
4444
WriteBarrier<JSCell> callee;
4545
WriteBarrier<CodeBlock> codeBlock;
4646
BytecodeIndex bytecodeIndex;
47-
bool m_isAsyncFrameWithoutCodeBlock { false };
47+
bool m_isAsyncFrame { false };
4848
};
4949

5050
struct WasmFrameData {
@@ -58,8 +58,9 @@ class StackFrame {
5858

5959
StackFrame(VM&, JSCell* owner, JSCell* callee);
6060
StackFrame(VM&, JSCell* owner, JSCell* callee, CodeBlock*, BytecodeIndex);
61+
StackFrame(VM&, JSCell* owner, JSCell* callee, CodeBlock*, BytecodeIndex, bool isAsyncFrame);
6162
StackFrame(VM&, JSCell* owner, CodeBlock*, BytecodeIndex);
62-
StackFrame(VM&, JSCell* owner, JSCell* callee, bool isAsyncFrameWithoutCodeBlock);
63+
StackFrame(VM&, JSCell* owner, JSCell* callee, bool isAsyncFrame);
6364
StackFrame(Wasm::IndexOrName);
6465
StackFrame(Wasm::IndexOrName, size_t functionIndex);
6566
StackFrame() = default;
@@ -97,6 +98,13 @@ class StackFrame {
9798
return false;
9899
}
99100

101+
bool isAsyncFrameWithoutCodeBlock() const
102+
{
103+
if (auto* jsFrame = std::get_if<JSFrameData>(&m_frameData))
104+
return jsFrame->m_isAsyncFrame && !codeBlock();
105+
return false;
106+
}
107+
100108
LineColumn computeLineAndColumn() const;
101109
String functionName(VM&) const;
102110
SourceID sourceID() const;
@@ -116,4 +124,4 @@ class StackFrame {
116124
FrameData m_frameData { JSFrameData { } };
117125
};
118126

119-
} // namespace JSC
127+
} // namespace JSC

0 commit comments

Comments
 (0)