Title: [283606] trunk
Revision
283606
Author
[email protected]
Date
2021-10-06 01:07:55 -0700 (Wed, 06 Oct 2021)

Log Message

[WPE][GTK] TestJSC incorrectly expects garbage collector to collect variables still on the stack
https://bugs.webkit.org/show_bug.cgi?id=222972

Reviewed by Michael Catanzaro.

Source/_javascript_Core:

Add JSCContextInternal.h header to be used by unit tests to use private JSC API and add
jscContextGarbageCollect().

* API/glib/JSCContext.cpp:
(jscContextGarbageCollect): Moved from unit tests here adding a parameter to optionally call
sanitizeStackForVM() before doing the garbage collection.
* API/glib/JSCContextInternal.h: Added.

Tools:

Include JSCContextInternal.h instead of JSCContextPrivate.h and remove the jscContextGarbageCollect() implementation.

* TestWebKitAPI/Tests/_javascript_Core/glib/TestJSC.cpp:
(testJSCWeakValue): Call sanitizeStackForVM() before the garbage collection.
(jscContextGarbageCollect): Deleted.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/_javascript_Core/API/glib/JSCContext.cpp (283605 => 283606)


--- trunk/Source/_javascript_Core/API/glib/JSCContext.cpp	2021-10-06 07:49:30 UTC (rev 283605)
+++ trunk/Source/_javascript_Core/API/glib/JSCContext.cpp	2021-10-06 08:07:55 UTC (rev 283606)
@@ -22,6 +22,7 @@
 
 #include "APICast.h"
 #include "JSCClassPrivate.h"
+#include "JSCContextInternal.h"
 #include "JSCContextPrivate.h"
 #include "JSCExceptionPrivate.h"
 #include "JSCInlines.h"
@@ -583,6 +584,19 @@
     }
 }
 
+void jscContextGarbageCollect(JSCContext* context, bool sanitizeStack)
+{
+    auto* jsContext = context->priv->jsContext.get();
+    JSC::JSGlobalObject* globalObject = toJS(jsContext);
+    JSC::VM& vm = globalObject->vm();
+    JSC::JSLockHolder locker(vm);
+
+    if (sanitizeStack)
+        sanitizeStackForVM(vm);
+
+    vm.heap.collectNow(JSC::Sync, JSC::CollectionScope::Full);
+}
+
 /**
  * jsc_context_new:
  *

Added: trunk/Source/_javascript_Core/API/glib/JSCContextInternal.h (0 => 283606)


--- trunk/Source/_javascript_Core/API/glib/JSCContextInternal.h	                        (rev 0)
+++ trunk/Source/_javascript_Core/API/glib/JSCContextInternal.h	2021-10-06 08:07:55 UTC (rev 283606)
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2021 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#pragma once
+
+#include "JSCContext.h"
+
+JS_EXPORT_PRIVATE void jscContextGarbageCollect(JSCContext*, bool sanitizeStack = false);

Modified: trunk/Source/_javascript_Core/ChangeLog (283605 => 283606)


--- trunk/Source/_javascript_Core/ChangeLog	2021-10-06 07:49:30 UTC (rev 283605)
+++ trunk/Source/_javascript_Core/ChangeLog	2021-10-06 08:07:55 UTC (rev 283606)
@@ -1,3 +1,18 @@
+2021-10-06  Carlos Garcia Campos  <[email protected]>
+
+        [WPE][GTK] TestJSC incorrectly expects garbage collector to collect variables still on the stack
+        https://bugs.webkit.org/show_bug.cgi?id=222972
+
+        Reviewed by Michael Catanzaro.
+
+        Add JSCContextInternal.h header to be used by unit tests to use private JSC API and add
+        jscContextGarbageCollect().
+
+        * API/glib/JSCContext.cpp:
+        (jscContextGarbageCollect): Moved from unit tests here adding a parameter to optionally call
+        sanitizeStackForVM() before doing the garbage collection.
+        * API/glib/JSCContextInternal.h: Added.
+
 2021-10-06  Jer Noble  <[email protected]>
 
         [Build-time perf] Forward declare JS TypedArrays

Modified: trunk/Tools/ChangeLog (283605 => 283606)


--- trunk/Tools/ChangeLog	2021-10-06 07:49:30 UTC (rev 283605)
+++ trunk/Tools/ChangeLog	2021-10-06 08:07:55 UTC (rev 283606)
@@ -1,3 +1,16 @@
+2021-10-06  Carlos Garcia Campos  <[email protected]>
+
+        [WPE][GTK] TestJSC incorrectly expects garbage collector to collect variables still on the stack
+        https://bugs.webkit.org/show_bug.cgi?id=222972
+
+        Reviewed by Michael Catanzaro.
+
+        Include JSCContextInternal.h instead of JSCContextPrivate.h and remove the jscContextGarbageCollect() implementation.
+
+        * TestWebKitAPI/Tests/_javascript_Core/glib/TestJSC.cpp:
+        (testJSCWeakValue): Call sanitizeStackForVM() before the garbage collection.
+        (jscContextGarbageCollect): Deleted.
+
 2021-10-06  Jer Noble  <[email protected]>
 
         [Build-time perf] Forward declare JS TypedArrays

Modified: trunk/Tools/TestWebKitAPI/Tests/_javascript_Core/glib/TestJSC.cpp (283605 => 283606)


--- trunk/Tools/TestWebKitAPI/Tests/_javascript_Core/glib/TestJSC.cpp	2021-10-06 07:49:30 UTC (rev 283605)
+++ trunk/Tools/TestWebKitAPI/Tests/_javascript_Core/glib/TestJSC.cpp	2021-10-06 08:07:55 UTC (rev 283606)
@@ -19,9 +19,9 @@
 
 #include "config.h"
 
-// Include JSCContextPrivate.h to be able to run garbage collector for testing.
+// Include JSCContextInternal.h to be able to run garbage collector for testing.
 #define JSC_COMPILATION 1
-#include "jsc/JSCContextPrivate.h"
+#include "jsc/JSCContextInternal.h"
 #undef JSC_COMPILATION
 
 #include <_javascript_Core/JSContextRef.h>
@@ -102,13 +102,6 @@
     g_assert_true(didThrow); \
     didThrow = false;
 
-extern "C" void JSSynchronousGarbageCollectForDebugging(JSContextRef);
-
-static void jscContextGarbageCollect(JSCContext* context)
-{
-    JSSynchronousGarbageCollectForDebugging(jscContextGetJSContext(context));
-}
-
 static void testJSCBasic()
 {
     {
@@ -3363,7 +3356,7 @@
         g_assert_true(jsc_value_is_object(weakFoo.get()));
         weakFoo = nullptr;
 
-        jscContextGarbageCollect(context.get());
+        jscContextGarbageCollect(context.get(), true);
         g_assert_true(weakValueCleared);
         g_assert_null(jsc_weak_value_get_value(weak.get()));
     }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to