Title: [258824] trunk/Source/_javascript_Core
Revision
258824
Author
[email protected]
Date
2020-03-22 17:40:46 -0700 (Sun, 22 Mar 2020)

Log Message

[JSC] Add JSC::keepAlive(JSValue)
https://bugs.webkit.org/show_bug.cgi?id=209398

Reviewed by Mark Lam.

Add JSC::keepAlive(JSValue). This is useful to make some JSValue variable alive from GC.

* heap/HeapCell.cpp:
* runtime/JSCJSValue.cpp:
(JSC::keepAlive):
* runtime/JSCJSValue.h:
(JSC::keepAlive):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (258823 => 258824)


--- trunk/Source/_javascript_Core/ChangeLog	2020-03-22 22:57:22 UTC (rev 258823)
+++ trunk/Source/_javascript_Core/ChangeLog	2020-03-23 00:40:46 UTC (rev 258824)
@@ -1,3 +1,18 @@
+2020-03-22  Yusuke Suzuki  <[email protected]>
+
+        [JSC] Add JSC::keepAlive(JSValue)
+        https://bugs.webkit.org/show_bug.cgi?id=209398
+
+        Reviewed by Mark Lam.
+
+        Add JSC::keepAlive(JSValue). This is useful to make some JSValue variable alive from GC.
+
+        * heap/HeapCell.cpp:
+        * runtime/JSCJSValue.cpp:
+        (JSC::keepAlive):
+        * runtime/JSCJSValue.h:
+        (JSC::keepAlive):
+
 2020-03-20  Ross Kirsling  <[email protected]>
 
         hasObservableSideEffectsForRegExpSplit doesn't check for @@match override

Modified: trunk/Source/_javascript_Core/heap/HeapCell.cpp (258823 => 258824)


--- trunk/Source/_javascript_Core/heap/HeapCell.cpp	2020-03-22 22:57:22 UTC (rev 258823)
+++ trunk/Source/_javascript_Core/heap/HeapCell.cpp	2020-03-23 00:40:46 UTC (rev 258824)
@@ -43,6 +43,7 @@
 }
 
 #if !COMPILER(GCC_COMPATIBLE)
+// This makes the argument opaque from the compiler.
 NEVER_INLINE void keepAlive(const void*)
 {
 }

Modified: trunk/Source/_javascript_Core/runtime/JSCJSValue.cpp (258823 => 258824)


--- trunk/Source/_javascript_Core/runtime/JSCJSValue.cpp	2020-03-22 22:57:22 UTC (rev 258823)
+++ trunk/Source/_javascript_Core/runtime/JSCJSValue.cpp	2020-03-23 00:40:46 UTC (rev 258824)
@@ -427,4 +427,11 @@
     RELEASE_AND_RETURN(scope, string->value(globalObject));
 }
 
+#if !COMPILER(GCC_COMPATIBLE)
+// This makes the argument opaque from the compiler.
+NEVER_INLINE void keepAlive(JSValue)
+{
+}
+#endif
+
 } // namespace JSC

Modified: trunk/Source/_javascript_Core/runtime/JSCJSValue.h (258823 => 258824)


--- trunk/Source/_javascript_Core/runtime/JSCJSValue.h	2020-03-22 22:57:22 UTC (rev 258823)
+++ trunk/Source/_javascript_Core/runtime/JSCJSValue.h	2020-03-23 00:40:46 UTC (rev 258824)
@@ -637,4 +637,17 @@
 // See section 7.2.9: https://tc39.github.io/ecma262/#sec-samevalue
 bool sameValue(JSGlobalObject*, JSValue a, JSValue b);
 
+#if COMPILER(GCC_COMPATIBLE)
+ALWAYS_INLINE void keepAlive(JSValue value)
+{
+#if USE(JSVALUE64)
+    asm volatile ("" : : "r"(bitwise_cast<uint64_t>(value)) : "memory");
+#else
+    asm volatile ("" : : "r"(value.payload()) : "memory");
+#endif
+}
+#else
+JS_EXPORT_PRIVATE void keepAlive(JSValue);
+#endif
+
 } // namespace JSC
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to