haikuwebkit/LayoutTests/js/error-should-not-strong-ref...

55 lines
1.3 KiB
HTML
Raw Permalink Normal View History

Error instances should not strongly hold onto StackFrames https://bugs.webkit.org/show_bug.cgi?id=185996 Reviewed by Mark Lam. Source/JavaScriptCore: Previously, we would hold onto all the StackFrames until the the user looked at one of the properties on the Error object. This patch makes us only weakly retain the StackFrames and collect all the information if we are about to collect any frame. This patch also adds a method to $vm that returns the heaps count of live global objects. * heap/Heap.cpp: (JSC::Heap::finalizeUnconditionalFinalizers): * interpreter/Interpreter.cpp: (JSC::Interpreter::stackTraceAsString): * interpreter/Interpreter.h: * runtime/Error.cpp: (JSC::addErrorInfo): * runtime/ErrorInstance.cpp: (JSC::ErrorInstance::finalizeUnconditionally): (JSC::ErrorInstance::computeErrorInfo): (JSC::ErrorInstance::materializeErrorInfoIfNeeded): (JSC::ErrorInstance::visitChildren): Deleted. * runtime/ErrorInstance.h: (JSC::ErrorInstance::subspaceFor): * runtime/JSFunction.cpp: (JSC::getCalculatedDisplayName): * runtime/StackFrame.h: (JSC::StackFrame::isMarked const): * runtime/VM.cpp: (JSC::VM::VM): * runtime/VM.h: * tools/JSDollarVM.cpp: (JSC::functionGlobalObjectCount): (JSC::JSDollarVM::finishCreation): LayoutTests: * js/error-should-not-strong-reference-global-object-expected.txt: Added. * js/error-should-not-strong-reference-global-object.html: Added. Canonical link: https://commits.webkit.org/201537@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@232314 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-05-30 23:19:51 +00:00
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../resources/js-test-pre.js"></script>
</head>
<body>
<script>
function foo(frames) {
frames = document.getElementsByTagName("iframe");
for (let i = 1; i < frames.length; i++) {
document.body.removeChild(frames[i]);
}
throw new Error(0);
}
const iframeCount = 10;
function setup() {
for (let i = 0; i < iframeCount; ++i) {
let iframe = document.createElement("iframe");
document.body.appendChild(iframe);
iframe.contentWindow.foo = new iframe.contentWindow.Function("frames", "i", "frames[i].foo(frames, i - 1);");
}
}
let errors = [];
function run() {
setup();
let frames = window.frames;
frames = [window].concat(Array.from(frames));
let last = frames.length - 1;
try {
frames[last].foo(frames, last);
} catch (e) {
errors.push(e);
}
}
for (let i = 0; i < 50; i++)
run();
setTimeout(() => {
$vm.gc();
// We shouldn't have more than 10% of the global objects we allocated.
var globalObjectCount = $vm.globalObjectCount();
if (globalObjectCount >= 51)
throw new Error("There are more global objects than there should be: actual count = " + globalObjectCount);
}, 1);
Error instances should not strongly hold onto StackFrames https://bugs.webkit.org/show_bug.cgi?id=185996 Reviewed by Mark Lam. Source/JavaScriptCore: Previously, we would hold onto all the StackFrames until the the user looked at one of the properties on the Error object. This patch makes us only weakly retain the StackFrames and collect all the information if we are about to collect any frame. This patch also adds a method to $vm that returns the heaps count of live global objects. * heap/Heap.cpp: (JSC::Heap::finalizeUnconditionalFinalizers): * interpreter/Interpreter.cpp: (JSC::Interpreter::stackTraceAsString): * interpreter/Interpreter.h: * runtime/Error.cpp: (JSC::addErrorInfo): * runtime/ErrorInstance.cpp: (JSC::ErrorInstance::finalizeUnconditionally): (JSC::ErrorInstance::computeErrorInfo): (JSC::ErrorInstance::materializeErrorInfoIfNeeded): (JSC::ErrorInstance::visitChildren): Deleted. * runtime/ErrorInstance.h: (JSC::ErrorInstance::subspaceFor): * runtime/JSFunction.cpp: (JSC::getCalculatedDisplayName): * runtime/StackFrame.h: (JSC::StackFrame::isMarked const): * runtime/VM.cpp: (JSC::VM::VM): * runtime/VM.h: * tools/JSDollarVM.cpp: (JSC::functionGlobalObjectCount): (JSC::JSDollarVM::finishCreation): LayoutTests: * js/error-should-not-strong-reference-global-object-expected.txt: Added. * js/error-should-not-strong-reference-global-object.html: Added. Canonical link: https://commits.webkit.org/201537@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@232314 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-05-30 23:19:51 +00:00
</script>
<script src="../resources/js-test-post.js"></script>
</body>
</html>