[JSC] Use finalizer in JSGlobalLexicalEnvironment and JSGlobalObject
authorysuzuki@apple.com <ysuzuki@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Mar 2019 07:00:24 +0000 (07:00 +0000)
committerysuzuki@apple.com <ysuzuki@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Mar 2019 07:00:24 +0000 (07:00 +0000)
commit0d4c98b56375ac7923f3914091766a85caba437f
treef95804a5949a9421f7b46713c784a0eaa730e822
parent2cb49200d1c8217537de1c6bd50b7ecdecf581b4
[JSC] Use finalizer in JSGlobalLexicalEnvironment and JSGlobalObject
https://bugs.webkit.org/show_bug.cgi?id=195992

Reviewed by Keith Miller and Mark Lam.

Source/JavaScriptCore:

JSGlobalLexicalEnvironment and JSGlobalObject have their own CompleteSubspace to call destructors while they are not inheriting JSDestructibleObject.
But it is too costly since (1) it requires CompleteSubspace in VM, (2) both objects allocate MarkedBlocks while # of them are really small.

Instead of using CompleteSubspace, we just set finalizers for them. Since these objects are rarely allocated, setting finalizers does not show
memory / performance problems (actually, previously we used finalizer for ArrayPrototype due to the same reason, and it does not show any problems).

And we also add following two changes to JSSegmentedVariableObject.

1. Remove one boolean used for debugging in Release build. It enlarges sizeof(JSSegmentedVariableObject) and allocates one more MarkedBlock.
2. Use cellLock() instead.

* CMakeLists.txt:
* JavaScriptCore.xcodeproj/project.pbxproj:
* Sources.txt:
* runtime/JSSegmentedVariableObject.cpp:
(JSC::JSSegmentedVariableObject::findVariableIndex):
(JSC::JSSegmentedVariableObject::addVariables):
(JSC::JSSegmentedVariableObject::visitChildren):
(JSC::JSSegmentedVariableObject::~JSSegmentedVariableObject):
(JSC::JSSegmentedVariableObject::finishCreation):
* runtime/JSSegmentedVariableObject.h:
(JSC::JSSegmentedVariableObject::subspaceFor): Deleted.
* runtime/JSSegmentedVariableObjectHeapCellType.cpp: Removed.
* runtime/JSSegmentedVariableObjectHeapCellType.h: Removed.
* runtime/StringIteratorPrototype.cpp:
* runtime/VM.cpp:
(JSC::VM::VM):
* runtime/VM.h:

Source/WebCore:

Use cellHeapCellType since JSSegmentedVariableObject already set finalizer.

* bindings/js/WebCoreJSClientData.cpp:
(WebCore::JSVMClientData::JSVMClientData):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243279 268f45cc-cd09-0410-ab3c-d52691b4dbfc
13 files changed:
Source/JavaScriptCore/CMakeLists.txt
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
Source/JavaScriptCore/Sources.txt
Source/JavaScriptCore/runtime/JSSegmentedVariableObject.cpp
Source/JavaScriptCore/runtime/JSSegmentedVariableObject.h
Source/JavaScriptCore/runtime/JSSegmentedVariableObjectHeapCellType.cpp [deleted file]
Source/JavaScriptCore/runtime/JSSegmentedVariableObjectHeapCellType.h [deleted file]
Source/JavaScriptCore/runtime/StringIteratorPrototype.cpp
Source/JavaScriptCore/runtime/VM.cpp
Source/JavaScriptCore/runtime/VM.h
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/WebCoreJSClientData.cpp