Title: [251812] trunk
Revision
251812
Author
[email protected]
Date
2019-10-30 15:19:33 -0700 (Wed, 30 Oct 2019)

Log Message

tryCachePutToScopeGlobal should hold the lock to update metadata.m_getPutInfo
https://bugs.webkit.org/show_bug.cgi?id=203628
<rdar://problem/56705353>

Reviewed by Yusuke Suzuki.

JSTests:

* stress/property-move-from-global-object-to-global-lexical-environment.js: Added.
(foo):

Source/_javascript_Core:

We hold the lock to update m_watchpointSet and m_operand, but at that point we have already
updated m_getPutInfo. This can lead to inconsistent state observable from the compiler thread
where the getPutInfo does not match the watchpointSet.

* runtime/CommonSlowPaths.h:
(JSC::CommonSlowPaths::tryCachePutToScopeGlobal):

Modified Paths

Added Paths

Diff

Modified: trunk/JSTests/ChangeLog (251811 => 251812)


--- trunk/JSTests/ChangeLog	2019-10-30 22:17:03 UTC (rev 251811)
+++ trunk/JSTests/ChangeLog	2019-10-30 22:19:33 UTC (rev 251812)
@@ -1,3 +1,14 @@
+2019-10-30  Tadeu Zagallo  <[email protected]>
+
+        tryCachePutToScopeGlobal should hold the lock to update metadata.m_getPutInfo
+        https://bugs.webkit.org/show_bug.cgi?id=203628
+        <rdar://problem/56705353>
+
+        Reviewed by Yusuke Suzuki.
+
+        * stress/property-move-from-global-object-to-global-lexical-environment.js: Added.
+        (foo):
+
 2019-10-29  Yusuke Suzuki  <[email protected]>
 
         [JSC] Add fast path for String#localeCompare

Added: trunk/JSTests/stress/property-move-from-global-object-to-global-lexical-environment.js (0 => 251812)


--- trunk/JSTests/stress/property-move-from-global-object-to-global-lexical-environment.js	                        (rev 0)
+++ trunk/JSTests/stress/property-move-from-global-object-to-global-lexical-environment.js	2019-10-30 22:19:33 UTC (rev 251812)
@@ -0,0 +1,15 @@
+function foo() {
+      bar = 4;
+}
+function get() {
+      return bar;
+}
+for (var i = 0; i < 1000000; ++i)
+      foo();
+for (var i = 0; i < 1000000; ++i)
+      get();
+$.evalScript('let bar = 3;');
+for (var i = 0; i < 1000000; ++i)
+      get();
+for (var i = 0; i < 1000000; ++i)
+      foo();

Modified: trunk/Source/_javascript_Core/ChangeLog (251811 => 251812)


--- trunk/Source/_javascript_Core/ChangeLog	2019-10-30 22:17:03 UTC (rev 251811)
+++ trunk/Source/_javascript_Core/ChangeLog	2019-10-30 22:19:33 UTC (rev 251812)
@@ -1,3 +1,18 @@
+2019-10-30  Tadeu Zagallo  <[email protected]>
+
+        tryCachePutToScopeGlobal should hold the lock to update metadata.m_getPutInfo
+        https://bugs.webkit.org/show_bug.cgi?id=203628
+        <rdar://problem/56705353>
+
+        Reviewed by Yusuke Suzuki.
+
+        We hold the lock to update m_watchpointSet and m_operand, but at that point we have already
+        updated m_getPutInfo. This can lead to inconsistent state observable from the compiler thread
+        where the getPutInfo does not match the watchpointSet.
+
+        * runtime/CommonSlowPaths.h:
+        (JSC::CommonSlowPaths::tryCachePutToScopeGlobal):
+
 2019-10-07  Jer Noble  <[email protected]>
 
         Implement the Remote Playback API.

Modified: trunk/Source/_javascript_Core/runtime/CommonSlowPaths.h (251811 => 251812)


--- trunk/Source/_javascript_Core/runtime/CommonSlowPaths.h	2019-10-30 22:17:03 UTC (rev 251811)
+++ trunk/Source/_javascript_Core/runtime/CommonSlowPaths.h	2019-10-30 22:19:33 UTC (rev 251812)
@@ -143,10 +143,10 @@
         if (scope->isGlobalLexicalEnvironment()) {
             JSGlobalLexicalEnvironment* globalLexicalEnvironment = jsCast<JSGlobalLexicalEnvironment*>(scope);
             ResolveType newResolveType = needsVarInjectionChecks(resolveType) ? GlobalLexicalVarWithVarInjectionChecks : GlobalLexicalVar;
-            metadata.m_getPutInfo = GetPutInfo(metadata.m_getPutInfo.resolveMode(), newResolveType, metadata.m_getPutInfo.initializationMode());
             SymbolTableEntry entry = globalLexicalEnvironment->symbolTable()->get(ident.impl());
             ASSERT(!entry.isNull());
             ConcurrentJSLocker locker(codeBlock->m_lock);
+            metadata.m_getPutInfo = GetPutInfo(metadata.m_getPutInfo.resolveMode(), newResolveType, metadata.m_getPutInfo.initializationMode());
             metadata.m_watchpointSet = entry.watchpointSet();
             metadata.m_operand = reinterpret_cast<uintptr_t>(globalLexicalEnvironment->variableAt(entry.scopeOffset()).slot());
             return;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to