Title: [144122] trunk/Source/_javascript_Core
Revision
144122
Author
[email protected]
Date
2013-02-26 16:38:14 -0800 (Tue, 26 Feb 2013)

Log Message

Web Inspector: REGRESSION: [JSC] SourceProvider reuses IDs
https://bugs.webkit.org/show_bug.cgi?id=99674

Reviewed by Gavin Barraclough.

Simple incrementing counter for SourceProvider IDs.  Uses a
lock to incrementing the counter so we don't increment reuse
counter values or reassign the ID for a given SourceProvider.

* parser/SourceProvider.cpp:
(JSC::SourceProvider::SourceProvider):
(JSC):
(JSC::SourceProvider::getID):
* parser/SourceProvider.h:
(JSC::SourceProvider::asID):
(SourceProvider):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (144121 => 144122)


--- trunk/Source/_javascript_Core/ChangeLog	2013-02-27 00:34:33 UTC (rev 144121)
+++ trunk/Source/_javascript_Core/ChangeLog	2013-02-27 00:38:14 UTC (rev 144122)
@@ -1,3 +1,22 @@
+2013-02-26  Oliver Hunt  <[email protected]>
+
+        Web Inspector: REGRESSION: [JSC] SourceProvider reuses IDs
+        https://bugs.webkit.org/show_bug.cgi?id=99674
+
+        Reviewed by Gavin Barraclough.
+
+        Simple incrementing counter for SourceProvider IDs.  Uses a
+        lock to incrementing the counter so we don't increment reuse
+        counter values or reassign the ID for a given SourceProvider.
+
+        * parser/SourceProvider.cpp:
+        (JSC::SourceProvider::SourceProvider):
+        (JSC):
+        (JSC::SourceProvider::getID):
+        * parser/SourceProvider.h:
+        (JSC::SourceProvider::asID):
+        (SourceProvider):
+
 2013-02-26  Sheriff Bot  <[email protected]>
 
         Unreviewed, rolling out r144074.

Modified: trunk/Source/_javascript_Core/parser/SourceProvider.cpp (144121 => 144122)


--- trunk/Source/_javascript_Core/parser/SourceProvider.cpp	2013-02-27 00:34:33 UTC (rev 144121)
+++ trunk/Source/_javascript_Core/parser/SourceProvider.cpp	2013-02-27 00:38:14 UTC (rev 144122)
@@ -25,6 +25,7 @@
 
 #include "config.h"
 #include "SourceProvider.h"
+#include <wtf/TCSpinLock.h>
 
 namespace JSC {
 
@@ -32,6 +33,7 @@
     : m_url(url)
     , m_startPosition(startPosition)
     , m_validated(false)
+    , m_id(0)
 {
 }
 
@@ -39,5 +41,16 @@
 {
 }
 
+static TCMalloc_SpinLock providerIdLock = SPINLOCK_INITIALIZER;
+
+void SourceProvider::getID()
+{
+    SpinLockHolder lock(&providerIdLock);
+    if (!m_id) {
+        static intptr_t nextProviderID = 0;
+        m_id = ++nextProviderID;
+    }
+}
+
 } // namespace JSC
 

Modified: trunk/Source/_javascript_Core/parser/SourceProvider.h (144121 => 144122)


--- trunk/Source/_javascript_Core/parser/SourceProvider.h	2013-02-27 00:34:33 UTC (rev 144121)
+++ trunk/Source/_javascript_Core/parser/SourceProvider.h	2013-02-27 00:38:14 UTC (rev 144122)
@@ -58,7 +58,9 @@
             ASSERT(this);
             if (!this) // Be defensive in release mode.
                 return nullID;
-            return reinterpret_cast<intptr_t>(this);
+            if (!m_id)
+                getID();
+            return m_id;
         }
 
         bool isValid() const { return m_validated; }
@@ -66,9 +68,12 @@
 
     private:
 
+        JS_EXPORT_PRIVATE void getID();
+
         String m_url;
         TextPosition m_startPosition;
-        bool m_validated;
+        bool m_validated : 1;
+        uintptr_t m_id : sizeof(uintptr_t) * 8 - 1;
     };
 
     class StringSourceProvider : public SourceProvider {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to