Ignore:
Timestamp:
Feb 10, 2018, 3:49:54 PM (8 years ago)
Author:
[email protected]
Message:

Don't waste memory for error.stack
https://bugs.webkit.org/show_bug.cgi?id=182656

Reviewed by Saam Barati.

JSTests:

Tests the policy.

  • stress/gc-error-stack.js: Added. Shows that the GC forgets frames now.
  • stress/no-gc-error-stack.js: Added. Shows that the GC won't forget things if you ask for the stack.

Source/JavaScriptCore:

This makes the StackFrames in ErrorInstance and Exception weak. We simply forget their
contents if we GC.

This isn't going to happen under normal operation since your callees and code blocks will
still be alive when you ask for .stack.

Bug 182650 tracks improving this so that it's not lossy. For now, I think it's worth it,
since it is likely to recover 3-5 MB on membuster.

  • heap/Heap.cpp:

(JSC::Heap::finalizeUnconditionalFinalizers):

  • runtime/ErrorInstance.cpp:

(JSC::ErrorInstance::visitChildren):
(JSC::ErrorInstance::finalizeUnconditionally):

  • runtime/ErrorInstance.h:

(JSC::ErrorInstance::subspaceFor):

  • runtime/Exception.cpp:

(JSC::Exception::visitChildren):
(JSC::Exception::finalizeUnconditionally):

  • runtime/Exception.h:

(JSC::Exception::valueOffset): Deleted.
(JSC::Exception::value const): Deleted.
(JSC::Exception::stack const): Deleted.
(JSC::Exception::didNotifyInspectorOfThrow const): Deleted.
(JSC::Exception::setDidNotifyInspectorOfThrow): Deleted.

  • runtime/StackFrame.cpp:

(JSC::StackFrame::isFinalizationCandidate):
(JSC::StackFrame::finalizeUnconditionally):
(JSC::StackFrame::visitChildren): Deleted.

  • runtime/StackFrame.h:
  • runtime/VM.cpp:

(JSC::VM::VM):

  • runtime/VM.h:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/VM.cpp

    r228260 r228366  
    252252#endif
    253253    , directEvalExecutableSpace ISO_SUBSPACE_INIT(heap, destructibleCellHeapCellType.get(), DirectEvalExecutable)
     254    , errorInstanceSpace ISO_SUBSPACE_INIT(heap, destructibleObjectHeapCellType.get(), ErrorInstance)
     255    , exceptionSpace ISO_SUBSPACE_INIT(heap, destructibleObjectHeapCellType.get(), Exception)
    254256    , executableToCodeBlockEdgeSpace ISO_SUBSPACE_INIT(heap, cellHeapCellType.get(), ExecutableToCodeBlockEdge)
    255257    , functionExecutableSpace ISO_SUBSPACE_INIT(heap, destructibleCellHeapCellType.get(), FunctionExecutable)
     
    265267    , weakSetSpace ISO_SUBSPACE_INIT(heap, destructibleObjectHeapCellType.get(), JSWeakSet)
    266268    , weakMapSpace ISO_SUBSPACE_INIT(heap, destructibleObjectHeapCellType.get(), JSWeakMap)
     269    , errorInstancesWithFinalizers(errorInstanceSpace)
     270    , exceptionsWithFinalizers(exceptionSpace)
    267271    , executableToCodeBlockEdgesWithConstraints(executableToCodeBlockEdgeSpace)
    268272    , executableToCodeBlockEdgesWithFinalizers(executableToCodeBlockEdgeSpace)
Note: See TracChangeset for help on using the changeset viewer.