update webkit (#19238)

This commit is contained in:
Dylan Conway
2025-04-23 23:21:22 -07:00
committed by GitHub
parent 98c66605e5
commit 41388204b9
14 changed files with 48 additions and 138 deletions

View File

@@ -122,11 +122,10 @@ void JSCStackTrace::getFramesForCaller(JSC::VM& vm, JSC::CallFrame* callFrame, J
WTF::String callerName {};
if (JSC::JSFunction* callerFunction = JSC::jsDynamicCast<JSC::JSFunction*>(caller)) {
callerName = callerFunction->name(vm);
if (callerName.isEmpty() && callerFunction->jsExecutable()) {
if (callerName.isEmpty() && !callerFunction->isHostFunction() && callerFunction->jsExecutable()) {
callerName = callerFunction->jsExecutable()->name().string();
}
}
if (JSC::InternalFunction* callerFunctionInternal = JSC::jsDynamicCast<JSC::InternalFunction*>(caller)) {
} else if (JSC::InternalFunction* callerFunctionInternal = JSC::jsDynamicCast<JSC::InternalFunction*>(caller)) {
callerName = callerFunctionInternal->name();
}
@@ -255,116 +254,6 @@ void JSCStackTrace::getFramesForCaller(JSC::VM& vm, JSC::CallFrame* callFrame, J
});
}
JSCStackTrace JSCStackTrace::captureCurrentJSStackTrace(Zig::GlobalObject* globalObject, JSC::CallFrame* callFrame, size_t frameLimit, JSC::JSValue caller)
{
auto& vm = JSC::getVM(globalObject);
if (!callFrame) {
return JSCStackTrace();
}
WTF::Vector<JSCStackFrame> stackFrames;
size_t framesCount = 0;
bool belowCaller = false;
int32_t skipFrames = 0;
WTF::String callerName {};
if (JSC::JSFunction* callerFunction = JSC::jsDynamicCast<JSC::JSFunction*>(caller)) {
callerName = callerFunction->name(vm);
if (!callerFunction->name(vm).isEmpty() || callerFunction->isHostOrBuiltinFunction()) {
callerName = callerFunction->name(vm);
} else {
callerName = callerFunction->jsExecutable()->name().string();
}
}
if (JSC::InternalFunction* callerFunctionInternal = JSC::jsDynamicCast<JSC::InternalFunction*>(caller)) {
callerName = callerFunctionInternal->name();
}
if (!callerName.isEmpty()) {
JSC::StackVisitor::visit(callFrame, vm, [&](JSC::StackVisitor& visitor) -> WTF::IterationStatus {
if (isImplementationVisibilityPrivate(visitor)) {
return WTF::IterationStatus::Continue;
}
framesCount += 1;
// skip caller frame and all frames above it
if (!belowCaller) {
skipFrames += 1;
if (visitor->functionName() == callerName) {
belowCaller = true;
return WTF::IterationStatus::Continue;
}
}
return WTF::IterationStatus::Continue;
});
} else if (caller && caller.isCell()) {
JSC::StackVisitor::visit(callFrame, vm, [&](JSC::StackVisitor& visitor) -> WTF::IterationStatus {
if (isImplementationVisibilityPrivate(visitor)) {
return WTF::IterationStatus::Continue;
}
framesCount += 1;
// skip caller frame and all frames above it
if (!belowCaller) {
auto callee = visitor->callee();
skipFrames += 1;
if (callee.isCell() && callee.asCell() == caller) {
belowCaller = true;
return WTF::IterationStatus::Continue;
}
}
return WTF::IterationStatus::Continue;
});
} else if (caller.isEmpty() || caller.isUndefined()) {
// Skip the first frame.
JSC::StackVisitor::visit(callFrame, vm, [&](JSC::StackVisitor& visitor) -> WTF::IterationStatus {
if (isImplementationVisibilityPrivate(visitor)) {
return WTF::IterationStatus::Continue;
}
framesCount += 1;
if (!belowCaller) {
skipFrames += 1;
belowCaller = true;
}
return WTF::IterationStatus::Continue;
});
}
framesCount = std::min(frameLimit, framesCount);
// Create the actual stack frames
size_t i = 0;
stackFrames.reserveInitialCapacity(framesCount);
JSC::StackVisitor::visit(callFrame, vm, [&](JSC::StackVisitor& visitor) -> WTF::IterationStatus {
// Skip native frames
if (isImplementationVisibilityPrivate(visitor)) {
return WTF::IterationStatus::Continue;
}
// Skip frames if needed
if (skipFrames > 0) {
skipFrames--;
return WTF::IterationStatus::Continue;
}
stackFrames.constructAndAppend(vm, visitor);
i++;
return (i == framesCount) ? WTF::IterationStatus::Done : WTF::IterationStatus::Continue;
});
return JSCStackTrace(stackFrames);
}
JSCStackTrace JSCStackTrace::getStackTraceForThrownValue(JSC::VM& vm, JSC::JSValue thrownValue)
{
const WTF::Vector<JSC::StackFrame>* jscStackTrace = nullptr;
@@ -752,6 +641,25 @@ String functionName(JSC::VM& vm, JSC::JSGlobalObject* lexicalGlobalObject, JSC::
}
}
{
if (functionName.isEmpty()) {
if (jstype == JSC::JSFunctionType) {
auto* function = jsCast<JSC::JSFunction*>(object);
if (function) {
functionName = function->nameWithoutGC(vm);
if (functionName.isEmpty() && !function->isHostFunction()) {
functionName = function->jsExecutable()->ecmaName().string();
}
}
} else if (jstype == JSC::InternalFunctionType) {
auto* function = jsCast<JSC::InternalFunction*>(object);
if (function) {
functionName = function->name();
}
}
}
}
return functionName;
}
@@ -813,14 +721,17 @@ String functionName(JSC::VM& vm, JSC::JSGlobalObject* lexicalGlobalObject, const
// Lastly, try type-specific properties.
if (jstype == JSC::JSFunctionType) {
auto* function = jsDynamicCast<JSC::JSFunction*>(object);
auto* function = jsCast<JSC::JSFunction*>(object);
if (function) {
functionName = function->nameWithoutGC(vm);
if (functionName.isEmpty() && !function->isHostFunction()) {
functionName = function->jsExecutable()->ecmaName().string();
}
setTypeFlagsIfNecessary();
return functionName;
}
} else if (jstype == JSC::InternalFunctionType) {
auto* function = jsDynamicCast<JSC::InternalFunction*>(object);
auto* function = jsCast<JSC::InternalFunction*>(object);
if (function) {
functionName = function->name();
setTypeFlagsIfNecessary();