Error instances should not strongly hold onto StackFrames
authorkeith_miller@apple.com <keith_miller@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 May 2018 23:19:51 +0000 (23:19 +0000)
committerkeith_miller@apple.com <keith_miller@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 May 2018 23:19:51 +0000 (23:19 +0000)
commitc311fcafe3aa7c2a84480d769ef6d1645ef2fc21
tree4cdbfd21aee03f19b3148b6426a8e2397ae2a579
parentd87aaef3886c8881e8102a694e30dbc75da18c3c
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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@232314 268f45cc-cd09-0410-ab3c-d52691b4dbfc
17 files changed:
JSTests/stress/error-stack-trace-limit.js
JSTests/stress/tail-call-recognize.js
LayoutTests/ChangeLog
LayoutTests/js/error-should-not-strong-reference-global-object-expected.txt [new file with mode: 0644]
LayoutTests/js/error-should-not-strong-reference-global-object.html [new file with mode: 0644]
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/heap/Heap.cpp
Source/JavaScriptCore/interpreter/Interpreter.cpp
Source/JavaScriptCore/interpreter/Interpreter.h
Source/JavaScriptCore/runtime/Error.cpp
Source/JavaScriptCore/runtime/ErrorInstance.cpp
Source/JavaScriptCore/runtime/ErrorInstance.h
Source/JavaScriptCore/runtime/JSFunction.cpp
Source/JavaScriptCore/runtime/StackFrame.h
Source/JavaScriptCore/runtime/VM.cpp
Source/JavaScriptCore/runtime/VM.h
Source/JavaScriptCore/tools/JSDollarVM.cpp