Changeset 228366 in webkit
- Timestamp:
- Feb 10, 2018 3:49:54 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r228311 r228366 1 2018-02-09 Filip Pizlo <fpizlo@apple.com> 2 3 Don't waste memory for error.stack 4 https://bugs.webkit.org/show_bug.cgi?id=182656 5 6 Reviewed by Saam Barati. 7 8 Tests the policy. 9 10 * stress/gc-error-stack.js: Added. Shows that the GC forgets frames now. 11 * stress/no-gc-error-stack.js: Added. Shows that the GC won't forget things if you ask for the stack. 12 1 13 2018-02-08 Yusuke Suzuki <utatane.tea@gmail.com> 2 14 -
trunk/Source/JavaScriptCore/ChangeLog
r228318 r228366 1 2018-02-09 Filip Pizlo <fpizlo@apple.com> 2 3 Don't waste memory for error.stack 4 https://bugs.webkit.org/show_bug.cgi?id=182656 5 6 Reviewed by Saam Barati. 7 8 This makes the StackFrames in ErrorInstance and Exception weak. We simply forget their 9 contents if we GC. 10 11 This isn't going to happen under normal operation since your callees and code blocks will 12 still be alive when you ask for .stack. 13 14 Bug 182650 tracks improving this so that it's not lossy. For now, I think it's worth it, 15 since it is likely to recover 3-5 MB on membuster. 16 17 * heap/Heap.cpp: 18 (JSC::Heap::finalizeUnconditionalFinalizers): 19 * runtime/ErrorInstance.cpp: 20 (JSC::ErrorInstance::visitChildren): 21 (JSC::ErrorInstance::finalizeUnconditionally): 22 * runtime/ErrorInstance.h: 23 (JSC::ErrorInstance::subspaceFor): 24 * runtime/Exception.cpp: 25 (JSC::Exception::visitChildren): 26 (JSC::Exception::finalizeUnconditionally): 27 * runtime/Exception.h: 28 (JSC::Exception::valueOffset): Deleted. 29 (JSC::Exception::value const): Deleted. 30 (JSC::Exception::stack const): Deleted. 31 (JSC::Exception::didNotifyInspectorOfThrow const): Deleted. 32 (JSC::Exception::setDidNotifyInspectorOfThrow): Deleted. 33 * runtime/StackFrame.cpp: 34 (JSC::StackFrame::isFinalizationCandidate): 35 (JSC::StackFrame::finalizeUnconditionally): 36 (JSC::StackFrame::visitChildren): Deleted. 37 * runtime/StackFrame.h: 38 * runtime/VM.cpp: 39 (JSC::VM::VM): 40 * runtime/VM.h: 41 1 42 2018-02-09 Carlos Alberto Lopez Perez <clopez@igalia.com> 2 43 -
trunk/Source/JavaScriptCore/heap/Heap.cpp
r227738 r228366 580 580 void Heap::finalizeUnconditionalFinalizers() 581 581 { 582 finalizeMarkedUnconditionalFinalizers<ErrorInstance>(vm()->errorInstancesWithFinalizers); 583 finalizeMarkedUnconditionalFinalizers<Exception>(vm()->exceptionsWithFinalizers); 582 584 finalizeMarkedUnconditionalFinalizers<InferredType>(vm()->inferredTypesWithFinalizers); 583 585 finalizeMarkedUnconditionalFinalizers<InferredValue>(vm()->inferredValuesWithFinalizers); -
trunk/Source/JavaScriptCore/runtime/ErrorInstance.cpp
r227906 r228366 1 1 /* 2 2 * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) 3 * Copyright (C) 2003-201 7Apple Inc. All rights reserved.3 * Copyright (C) 2003-2018 Apple Inc. All rights reserved. 4 4 * 5 5 * This library is free software; you can redistribute it and/or … … 24 24 #include "CodeBlock.h" 25 25 #include "InlineCallFrame.h" 26 #include "IsoCellSetInlines.h" 26 27 #include "JSScope.h" 27 28 #include "JSCInlines.h" … … 234 235 Base::visitChildren(thisObject, visitor); 235 236 237 bool isFinalizationCandidate = false; 236 238 { 237 239 auto locker = holdLock(thisObject->cellLock()); 238 240 if (thisObject->m_stackTrace) { 239 for (StackFrame& frame : *thisObject->m_stackTrace) 240 frame.visitChildren(visitor); 241 for (StackFrame& frame : *thisObject->m_stackTrace) { 242 if (frame.isFinalizationCandidate()) { 243 isFinalizationCandidate = true; 244 break; 245 } 246 } 241 247 } 242 248 } 249 if (isFinalizationCandidate) 250 visitor.vm().errorInstancesWithFinalizers.add(thisObject); 251 } 252 253 void ErrorInstance::finalizeUnconditionally(VM& vm) 254 { 255 { 256 auto locker = holdLock(cellLock()); 257 if (m_stackTrace) { 258 for (StackFrame& frame : *m_stackTrace) 259 frame.finalizeUnconditionally(vm); 260 } 261 } 262 263 vm.errorInstancesWithFinalizers.remove(this); 243 264 } 244 265 -
trunk/Source/JavaScriptCore/runtime/ErrorInstance.h
r225768 r228366 1 1 /* 2 2 * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) 3 * Copyright (C) 2008-201 7Apple Inc. All rights reserved.3 * Copyright (C) 2008-2018 Apple Inc. All rights reserved. 4 4 * 5 5 * This library is free software; you can redistribute it and/or … … 27 27 namespace JSC { 28 28 29 // FIXME: This should be final, but isn't because of bizarre (and mostly wrong) things done in 30 // WebAssembly. 31 // https://bugs.webkit.org/show_bug.cgi?id=182649 29 32 class ErrorInstance : public JSDestructibleObject { 30 33 public: 34 template<typename CellType> 35 static IsoSubspace* subspaceFor(VM& vm) 36 { 37 return &vm.errorInstanceSpace; 38 } 39 31 40 typedef JSDestructibleObject Base; 32 41 const static unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesGetPropertyNames; … … 69 78 70 79 Vector<StackFrame>* stackTrace() { return m_stackTrace.get(); } 80 81 void finalizeUnconditionally(VM&); 71 82 72 83 bool materializeErrorInfoIfNeeded(VM&); -
trunk/Source/JavaScriptCore/runtime/Exception.cpp
r221836 r228366 1 1 /* 2 * Copyright (C) 2015-201 7Apple Inc. All rights reserved.2 * Copyright (C) 2015-2018 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 28 28 29 29 #include "Interpreter.h" 30 #include "IsoCellSetInlines.h" 30 31 #include "JSCInlines.h" 31 32 … … 58 59 Base::visitChildren(thisObject, visitor); 59 60 61 bool isFinalizationCandidate = false; 60 62 visitor.append(thisObject->m_value); 61 for (StackFrame& frame : thisObject->m_stack) 62 frame.visitChildren(visitor); 63 for (StackFrame& frame : thisObject->m_stack) { 64 if (frame.isFinalizationCandidate()) { 65 isFinalizationCandidate = true; 66 break; 67 } 68 } 69 if (isFinalizationCandidate) 70 visitor.vm().exceptionsWithFinalizers.add(thisObject); 71 } 72 73 void Exception::finalizeUnconditionally(VM& vm) 74 { 75 for (StackFrame& frame : m_stack) 76 frame.finalizeUnconditionally(vm); 77 78 vm.exceptionsWithFinalizers.remove(this); 63 79 } 64 80 -
trunk/Source/JavaScriptCore/runtime/Exception.h
r222186 r228366 1 1 /* 2 * Copyright (C) 2015-201 7Apple Inc. All rights reserved.2 * Copyright (C) 2015-2018 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 32 32 namespace JSC { 33 33 34 class Exception : public JSDestructibleObject {34 class Exception final : public JSDestructibleObject { 35 35 public: 36 template<typename CellType> 37 static IsoSubspace* subspaceFor(VM& vm) 38 { 39 return &vm.exceptionSpace; 40 } 41 36 42 typedef JSDestructibleObject Base; 37 43 static const unsigned StructureFlags = StructureIsImmortal | Base::StructureFlags; … … 61 67 62 68 ~Exception(); 69 70 void finalizeUnconditionally(VM&); 63 71 64 72 private: -
trunk/Source/JavaScriptCore/runtime/StackFrame.cpp
r225378 r228366 1 1 /* 2 * Copyright (C) 2016-201 7Apple Inc. All rights reserved.2 * Copyright (C) 2016-2018 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 143 143 } 144 144 145 void StackFrame::visitChildren(SlotVisitor& visitor)145 bool StackFrame::isFinalizationCandidate() 146 146 { 147 if (m_callee) 148 visitor.append(m_callee); 149 if (m_codeBlock) 150 visitor.append(m_codeBlock); 147 if (m_callee && !Heap::isMarked(m_callee.get())) 148 return true; 149 if (m_codeBlock && !Heap::isMarked(m_codeBlock.get())) 150 return true; 151 return false; 152 } 153 154 void StackFrame::finalizeUnconditionally(VM&) 155 { 156 // FIXME: We should do something smarter. For example, if this happens, we could stringify the 157 // whole stack trace. The main shortcoming is that that requires doing operations that are not 158 // currently legal during finalization. We could make this work by giving JSC a proper "second 159 // chance" finalizer infrastructure. Or maybe there's an even easier way. 160 // https://bugs.webkit.org/show_bug.cgi?id=182650 161 162 if (m_callee && !Heap::isMarked(m_callee.get())) 163 m_callee.clear(); 164 if (m_codeBlock && !Heap::isMarked(m_codeBlock.get())) 165 m_codeBlock.clear(); 151 166 } 152 167 -
trunk/Source/JavaScriptCore/runtime/StackFrame.h
r224272 r228366 1 1 /* 2 * Copyright (C) 2016-201 7Apple Inc. All rights reserved.2 * Copyright (C) 2016-2018 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 57 57 } 58 58 59 void visitChildren(SlotVisitor&); 59 bool isFinalizationCandidate(); 60 void finalizeUnconditionally(VM&); 60 61 61 62 private: -
trunk/Source/JavaScriptCore/runtime/VM.cpp
r228260 r228366 252 252 #endif 253 253 , 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) 254 256 , executableToCodeBlockEdgeSpace ISO_SUBSPACE_INIT(heap, cellHeapCellType.get(), ExecutableToCodeBlockEdge) 255 257 , functionExecutableSpace ISO_SUBSPACE_INIT(heap, destructibleCellHeapCellType.get(), FunctionExecutable) … … 265 267 , weakSetSpace ISO_SUBSPACE_INIT(heap, destructibleObjectHeapCellType.get(), JSWeakSet) 266 268 , weakMapSpace ISO_SUBSPACE_INIT(heap, destructibleObjectHeapCellType.get(), JSWeakMap) 269 , errorInstancesWithFinalizers(errorInstanceSpace) 270 , exceptionsWithFinalizers(exceptionSpace) 267 271 , executableToCodeBlockEdgesWithConstraints(executableToCodeBlockEdgeSpace) 268 272 , executableToCodeBlockEdgesWithFinalizers(executableToCodeBlockEdgeSpace) -
trunk/Source/JavaScriptCore/runtime/VM.h
r228260 r228366 340 340 341 341 IsoSubspace directEvalExecutableSpace; 342 IsoSubspace errorInstanceSpace; 343 IsoSubspace exceptionSpace; 342 344 IsoSubspace executableToCodeBlockEdgeSpace; 343 345 IsoSubspace functionExecutableSpace; … … 354 356 IsoSubspace weakMapSpace; 355 357 358 IsoCellSet errorInstancesWithFinalizers; 359 IsoCellSet exceptionsWithFinalizers; 356 360 IsoCellSet executableToCodeBlockEdgesWithConstraints; 357 361 IsoCellSet executableToCodeBlockEdgesWithFinalizers;
Note: See TracChangeset
for help on using the changeset viewer.