2009-08-04 Jian Li <jianli@chromium.org>
authorjianli@chromium.org <jianli@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Aug 2009 22:52:07 +0000 (22:52 +0000)
committerjianli@chromium.org <jianli@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Aug 2009 22:52:07 +0000 (22:52 +0000)
        Reviewed by David Levin.

        [V8] Fix an assert in WebCoreStringResource that causes worker script
        evaluation failed.
        https://bugs.webkit.org/show_bug.cgi?id=27996

        The fix is to check for the same thread, instead of the main thread.
        This is because Chromium's workers use v8 in a single thread that is
        not the main thread.

        * bindings/v8/V8Binding.cpp:
        (WebCore::WebCoreStringResource::WebCoreStringResource):
        (WebCore::WebCoreStringResource::~WebCoreStringResource):
        (WebCore::WebCoreStringResource::atomicString):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@46782 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/bindings/v8/V8Binding.cpp

index b40616e..e5606b8 100644 (file)
@@ -1,3 +1,20 @@
+2009-08-04  Jian Li  <jianli@chromium.org>
+
+        Reviewed by David Levin.
+
+        [V8] Fix an assert in WebCoreStringResource that causes worker script
+        evaluation failed.
+        https://bugs.webkit.org/show_bug.cgi?id=27996
+
+        The fix is to check for the same thread, instead of the main thread.
+        This is because Chromium's workers use v8 in a single thread that is
+        not the main thread.
+
+        * bindings/v8/V8Binding.cpp:
+        (WebCore::WebCoreStringResource::WebCoreStringResource):
+        (WebCore::WebCoreStringResource::~WebCoreStringResource):
+        (WebCore::WebCoreStringResource::atomicString):
+
 2009-08-04  Simon Fraser  <simon.fraser@apple.com>
 
         Reviewed by Dave Hyatt.
index bc0e9d8..c5d580a 100644 (file)
@@ -51,7 +51,9 @@ public:
     explicit WebCoreStringResource(const String& string)
         : m_plainString(string)
     {
-        ASSERT(WTF::isMainThread());
+#ifndef NDEBUG
+        m_threadId = WTF::currentThread();
+#endif
         v8::V8::AdjustAmountOfExternalAllocatedMemory(2 * length());
     }
 
@@ -59,13 +61,17 @@ public:
         : m_plainString(string)
         , m_atomicString(string)
     {
-        ASSERT(WTF::isMainThread());
+#ifndef NDEBUG
+        m_threadId = WTF::currentThread();
+#endif
         v8::V8::AdjustAmountOfExternalAllocatedMemory(2 * length());
     }
 
     virtual ~WebCoreStringResource()
     {
-        ASSERT(WTF::isMainThread());
+#ifndef NDEBUG
+        ASSERT(m_threadId == WTF::currentThread());
+#endif
         int reducedExternalMemory = -2 * length();
         if (!m_plainString.impl()->inTable())
             reducedExternalMemory *= 2;
@@ -83,7 +89,9 @@ public:
 
     AtomicString atomicString()
     {
-        ASSERT(WTF::isMainThread());
+#ifndef NDEBUG
+        ASSERT(m_threadId == WTF::currentThread());
+#endif
         if (m_atomicString.isNull()) {
             m_atomicString = AtomicString(m_plainString);
             if (!m_plainString.impl()->inTable())
@@ -106,6 +114,10 @@ private:
     // the original string alive because v8 may keep derived pointers
     // into that string.
     AtomicString m_atomicString;
+
+#ifndef NDEBUG
+    WTF::ThreadIdentifier m_threadId;
+#endif
 };
 
 String v8StringToWebCoreString(v8::Handle<v8::String> v8String, ExternalMode external,