Title: [274817] trunk/Source/_javascript_Core
Revision
274817
Author
[email protected]
Date
2021-03-22 16:30:10 -0700 (Mon, 22 Mar 2021)

Log Message

[JSC] JSCustomGetterFunction/JSCustomSetterFunction should use Identifier for their field
https://bugs.webkit.org/show_bug.cgi?id=223588

Reviewed by Mark Lam and Saam Barati.

PropertyName is the holder for passing it as an argument, and it does not ref/deref underlying UniqueStringImpl.
We should use Identifier to keep it strongly ref-ed in JSCustomGetterFunction/JSCustomSetterFunction.
And we should make JSCustomGetterFunction/JSCustomSetterFunction destructible objects since Identifier needs to
deref underlying UniqueStringImpl when destroying these functions.

* runtime/JSCustomGetterFunction.cpp:
(JSC::JSCustomGetterFunction::JSCustomGetterFunction):
(JSC::JSCustomGetterFunction::destroy):
* runtime/JSCustomGetterFunction.h:
* runtime/JSCustomSetterFunction.cpp:
(JSC::JSCustomSetterFunction::JSCustomSetterFunction):
(JSC::JSCustomSetterFunction::destroy):
* runtime/JSCustomSetterFunction.h:
* runtime/VM.cpp:
(JSC::VM::VM):
* runtime/VM.h:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (274816 => 274817)


--- trunk/Source/_javascript_Core/ChangeLog	2021-03-22 23:26:23 UTC (rev 274816)
+++ trunk/Source/_javascript_Core/ChangeLog	2021-03-22 23:30:10 UTC (rev 274817)
@@ -1,3 +1,27 @@
+2021-03-22  Yusuke Suzuki  <[email protected]>
+
+        [JSC] JSCustomGetterFunction/JSCustomSetterFunction should use Identifier for their field
+        https://bugs.webkit.org/show_bug.cgi?id=223588
+
+        Reviewed by Mark Lam and Saam Barati.
+
+        PropertyName is the holder for passing it as an argument, and it does not ref/deref underlying UniqueStringImpl.
+        We should use Identifier to keep it strongly ref-ed in JSCustomGetterFunction/JSCustomSetterFunction.
+        And we should make JSCustomGetterFunction/JSCustomSetterFunction destructible objects since Identifier needs to
+        deref underlying UniqueStringImpl when destroying these functions.
+
+        * runtime/JSCustomGetterFunction.cpp:
+        (JSC::JSCustomGetterFunction::JSCustomGetterFunction):
+        (JSC::JSCustomGetterFunction::destroy):
+        * runtime/JSCustomGetterFunction.h:
+        * runtime/JSCustomSetterFunction.cpp:
+        (JSC::JSCustomSetterFunction::JSCustomSetterFunction):
+        (JSC::JSCustomSetterFunction::destroy):
+        * runtime/JSCustomSetterFunction.h:
+        * runtime/VM.cpp:
+        (JSC::VM::VM):
+        * runtime/VM.h:
+
 2021-03-22  Saam Barati  <[email protected]>
 
         LiteralParser shouldn't make error messages of length ~2^31

Modified: trunk/Source/_javascript_Core/runtime/JSCustomGetterFunction.cpp (274816 => 274817)


--- trunk/Source/_javascript_Core/runtime/JSCustomGetterFunction.cpp	2021-03-22 23:26:23 UTC (rev 274816)
+++ trunk/Source/_javascript_Core/runtime/JSCustomGetterFunction.cpp	2021-03-22 23:30:10 UTC (rev 274817)
@@ -52,7 +52,7 @@
 
 JSCustomGetterFunction::JSCustomGetterFunction(VM& vm, NativeExecutable* executable, JSGlobalObject* globalObject, Structure* structure, const PropertyName& propertyName, GetValueFunc getter, Optional<DOMAttributeAnnotation> domAttribute)
     : Base(vm, executable, globalObject, structure)
-    , m_propertyName(propertyName)
+    , m_propertyName(Identifier::fromUid(vm, propertyName.uid()))
     , m_getter(getter)
     , m_domAttribute(domAttribute)
 {
@@ -71,4 +71,9 @@
     return function;
 }
 
+void JSCustomGetterFunction::destroy(JSCell* cell)
+{
+    static_cast<JSCustomGetterFunction*>(cell)->~JSCustomGetterFunction();
+}
+
 } // namespace JSC

Modified: trunk/Source/_javascript_Core/runtime/JSCustomGetterFunction.h (274816 => 274817)


--- trunk/Source/_javascript_Core/runtime/JSCustomGetterFunction.h	2021-03-22 23:26:23 UTC (rev 274816)
+++ trunk/Source/_javascript_Core/runtime/JSCustomGetterFunction.h	2021-03-22 23:30:10 UTC (rev 274817)
@@ -34,6 +34,9 @@
     typedef JSFunction Base;
     static constexpr unsigned StructureFlags = Base::StructureFlags;
 
+    static constexpr bool needsDestruction = true;
+    static void destroy(JSCell*);
+
     template<typename CellType, SubspaceAccess mode>
     static IsoSubspace* subspaceFor(VM& vm)
     {
@@ -50,7 +53,7 @@
 
     DECLARE_EXPORT_INFO;
 
-    const PropertyName& propertyName() const { return m_propertyName; }
+    const Identifier& propertyName() const { return m_propertyName; }
     GetValueFunc getter() const { return m_getter; };
     Optional<DOMAttributeAnnotation> domAttribute() const { return m_domAttribute; };
 
@@ -57,7 +60,7 @@
 private:
     JSCustomGetterFunction(VM&, NativeExecutable*, JSGlobalObject*, Structure*, const PropertyName&, GetValueFunc, Optional<DOMAttributeAnnotation>);
 
-    PropertyName m_propertyName;
+    Identifier m_propertyName;
     GetValueFunc m_getter;
     Optional<DOMAttributeAnnotation> m_domAttribute;
 };

Modified: trunk/Source/_javascript_Core/runtime/JSCustomSetterFunction.cpp (274816 => 274817)


--- trunk/Source/_javascript_Core/runtime/JSCustomSetterFunction.cpp	2021-03-22 23:26:23 UTC (rev 274816)
+++ trunk/Source/_javascript_Core/runtime/JSCustomSetterFunction.cpp	2021-03-22 23:30:10 UTC (rev 274817)
@@ -43,7 +43,7 @@
 
 JSCustomSetterFunction::JSCustomSetterFunction(VM& vm, NativeExecutable* executable, JSGlobalObject* globalObject, Structure* structure, const PropertyName& propertyName, PutValueFunc setter)
     : Base(vm, executable, globalObject, structure)
-    , m_propertyName(propertyName)
+    , m_propertyName(Identifier::fromUid(vm, propertyName.uid()))
     , m_setter(setter)
 {
 }
@@ -61,4 +61,9 @@
     return function;
 }
 
+void JSCustomSetterFunction::destroy(JSCell* cell)
+{
+    static_cast<JSCustomSetterFunction*>(cell)->~JSCustomSetterFunction();
+}
+
 } // namespace JSC

Modified: trunk/Source/_javascript_Core/runtime/JSCustomSetterFunction.h (274816 => 274817)


--- trunk/Source/_javascript_Core/runtime/JSCustomSetterFunction.h	2021-03-22 23:26:23 UTC (rev 274816)
+++ trunk/Source/_javascript_Core/runtime/JSCustomSetterFunction.h	2021-03-22 23:30:10 UTC (rev 274817)
@@ -34,6 +34,9 @@
     typedef JSFunction Base;
     static constexpr unsigned StructureFlags = Base::StructureFlags;
 
+    static constexpr bool needsDestruction = true;
+    static void destroy(JSCell*);
+
     template<typename CellType, SubspaceAccess mode>
     static IsoSubspace* subspaceFor(VM& vm)
     {
@@ -50,13 +53,13 @@
 
     DECLARE_EXPORT_INFO;
 
-    const PropertyName& propertyName() const { return m_propertyName; }
+    const Identifier& propertyName() const { return m_propertyName; }
     PutValueFunc setter() const { return m_setter; };
 
 private:
     JSCustomSetterFunction(VM&, NativeExecutable*, JSGlobalObject*, Structure*, const PropertyName&, PutValueFunc);
 
-    PropertyName m_propertyName;
+    Identifier m_propertyName;
     PutValueFunc m_setter;
 };
 

Modified: trunk/Source/_javascript_Core/runtime/VM.cpp (274816 => 274817)


--- trunk/Source/_javascript_Core/runtime/VM.cpp	2021-03-22 23:26:23 UTC (rev 274816)
+++ trunk/Source/_javascript_Core/runtime/VM.cpp	2021-03-22 23:30:10 UTC (rev 274817)
@@ -291,6 +291,8 @@
     , callbackConstructorHeapCellType(IsoHeapCellType::create<JSCallbackConstructor>())
     , callbackGlobalObjectHeapCellType(IsoHeapCellType::create<JSCallbackObject<JSGlobalObject>>())
     , callbackObjectHeapCellType(IsoHeapCellType::create<JSCallbackObject<JSNonFinalObject>>())
+    , customGetterFunctionHeapCellType(IsoHeapCellType::create<JSCustomGetterFunction>())
+    , customSetterFunctionHeapCellType(IsoHeapCellType::create<JSCustomSetterFunction>())
     , dateInstanceHeapCellType(IsoHeapCellType::create<DateInstance>())
     , errorInstanceHeapCellType(IsoHeapCellType::create<ErrorInstance>())
     , finalizationRegistryCellType(IsoHeapCellType::create<JSFinalizationRegistry>())
@@ -1482,8 +1484,8 @@
 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(callbackGlobalObjectSpace, callbackGlobalObjectHeapCellType.get(), JSCallbackObject<JSGlobalObject>)
 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(callbackFunctionSpace, cellHeapCellType.get(), JSCallbackFunction) // Hash:0xe7648ebc
 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(callbackObjectSpace, callbackObjectHeapCellType.get(), JSCallbackObject<JSNonFinalObject>)
-DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(customGetterFunctionSpace, cellHeapCellType.get(), JSCustomGetterFunction)
-DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(customSetterFunctionSpace, cellHeapCellType.get(), JSCustomSetterFunction)
+DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(customGetterFunctionSpace, customGetterFunctionHeapCellType.get(), JSCustomGetterFunction)
+DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(customSetterFunctionSpace, customSetterFunctionHeapCellType.get(), JSCustomSetterFunction)
 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(dataViewSpace, cellHeapCellType.get(), JSDataView)
 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(debuggerScopeSpace, cellHeapCellType.get(), DebuggerScope)
 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(errorInstanceSpace, errorInstanceHeapCellType.get(), ErrorInstance) // Hash:0x3f40d4a

Modified: trunk/Source/_javascript_Core/runtime/VM.h (274816 => 274817)


--- trunk/Source/_javascript_Core/runtime/VM.h	2021-03-22 23:26:23 UTC (rev 274816)
+++ trunk/Source/_javascript_Core/runtime/VM.h	2021-03-22 23:30:10 UTC (rev 274817)
@@ -365,6 +365,8 @@
     std::unique_ptr<IsoHeapCellType> callbackConstructorHeapCellType;
     std::unique_ptr<IsoHeapCellType> callbackGlobalObjectHeapCellType;
     std::unique_ptr<IsoHeapCellType> callbackObjectHeapCellType;
+    std::unique_ptr<IsoHeapCellType> customGetterFunctionHeapCellType;
+    std::unique_ptr<IsoHeapCellType> customSetterFunctionHeapCellType;
     std::unique_ptr<IsoHeapCellType> dateInstanceHeapCellType;
     std::unique_ptr<IsoHeapCellType> errorInstanceHeapCellType;
     std::unique_ptr<IsoHeapCellType> finalizationRegistryCellType;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to