Changeset 117377 in webkit


Ignore:
Timestamp:
May 16, 2012 6:36:11 PM (12 years ago)
Author:
jsbell@chromium.org
Message:

SerializedScriptValue: lazy initialization of static nullValue not threadsafe
https://bugs.webkit.org/show_bug.cgi?id=70833

Reviewed by Kentaro Hara.

Remove unsafe lazy initialization of static |null| SSV. None of the callers
appeared to be in performance-critical areas - most were preparing an event to
be dispatched to script - so no per-call-site caching was added.

No new tests - no functional changes.

  • bindings/js/SerializedScriptValue.cpp: Mint a new one each time.

(WebCore::SerializedScriptValue::nullValue):

  • bindings/js/SerializedScriptValue.h: Return via PassRefPtr.
  • bindings/v8/SerializedScriptValue.cpp: Mint a new one each time.

(WebCore::SerializedScriptValue::nullValue):

  • bindings/v8/SerializedScriptValue.h: Return via PassRefPtr.

(SerializedScriptValue):

  • dom/Document.cpp:

(WebCore::Document::statePopped): Change to PassRefPtr to maintain refcount.

  • dom/Document.h:

(Document):

Location:
trunk/Source/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r117376 r117377  
     12012-05-16  Joshua Bell  <jsbell@chromium.org>
     2
     3        SerializedScriptValue: lazy initialization of static nullValue not threadsafe
     4        https://bugs.webkit.org/show_bug.cgi?id=70833
     5
     6        Reviewed by Kentaro Hara.
     7
     8        Remove unsafe lazy initialization of static |null| SSV. None of the callers
     9        appeared to be in performance-critical areas - most were preparing an event to
     10        be dispatched to script - so no per-call-site caching was added.
     11
     12        No new tests - no functional changes.
     13
     14        * bindings/js/SerializedScriptValue.cpp: Mint a new one each time.
     15        (WebCore::SerializedScriptValue::nullValue):
     16        * bindings/js/SerializedScriptValue.h: Return via PassRefPtr.
     17        * bindings/v8/SerializedScriptValue.cpp: Mint a new one each time.
     18        (WebCore::SerializedScriptValue::nullValue):
     19        * bindings/v8/SerializedScriptValue.h: Return via PassRefPtr.
     20        (SerializedScriptValue):
     21        * dom/Document.cpp:
     22        (WebCore::Document::statePopped): Change to PassRefPtr to maintain refcount.
     23        * dom/Document.h:
     24        (Document):
     25
    1262012-05-16  James Robinson  <jamesr@chromium.org>
    227
  • trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp

    r114992 r117377  
    18601860}
    18611861
    1862 SerializedScriptValue* SerializedScriptValue::nullValue()
    1863 {
    1864     DEFINE_STATIC_LOCAL(RefPtr<SerializedScriptValue>, emptyValue, (SerializedScriptValue::create()));
    1865     return emptyValue.get();
     1862PassRefPtr<SerializedScriptValue> SerializedScriptValue::nullValue()
     1863{
     1864    return SerializedScriptValue::create();
    18661865}
    18671866
  • trunk/Source/WebCore/bindings/js/SerializedScriptValue.h

    r111044 r117377  
    7979
    8080    static PassRefPtr<SerializedScriptValue> create();
    81     static SerializedScriptValue* nullValue();
     81    static PassRefPtr<SerializedScriptValue> nullValue();
    8282    static PassRefPtr<SerializedScriptValue> undefinedValue();
    8383    static PassRefPtr<SerializedScriptValue> booleanValue(bool value);
  • trunk/Source/WebCore/bindings/v8/SerializedScriptValue.cpp

    r115374 r117377  
    20992099}
    21002100
    2101 SerializedScriptValue* SerializedScriptValue::nullValue(v8::Isolate* isolate)
     2101PassRefPtr<SerializedScriptValue> SerializedScriptValue::nullValue(v8::Isolate* isolate)
    21022102{
    2103     // FIXME: This is not thread-safe. Move caching to callers.
    2104     // https://bugs.webkit.org/show_bug.cgi?id=70833
    2105     DEFINE_STATIC_LOCAL(RefPtr<SerializedScriptValue>, nullValue, (0));
    2106     if (!nullValue) {
    2107         Writer writer(isolate);
    2108         writer.writeNull();
    2109         String wireData = StringImpl::adopt(writer.data());
    2110         nullValue = adoptRef(new SerializedScriptValue(wireData));
    2111     }
    2112     return nullValue.get();
     2103    Writer writer(isolate);
     2104    writer.writeNull();
     2105    String wireData = StringImpl::adopt(writer.data());
     2106    return adoptRef(new SerializedScriptValue(wireData));
    21132107}
    21142108
  • trunk/Source/WebCore/bindings/v8/SerializedScriptValue.h

    r115229 r117377  
    5959    static PassRefPtr<SerializedScriptValue> create();
    6060
    61     static SerializedScriptValue* nullValue(v8::Isolate* = 0);
     61    static PassRefPtr<SerializedScriptValue> nullValue(v8::Isolate* = 0);
    6262    static PassRefPtr<SerializedScriptValue> undefinedValue(v8::Isolate* = 0);
    6363    static PassRefPtr<SerializedScriptValue> booleanValue(bool value, v8::Isolate* = 0);
  • trunk/Source/WebCore/dom/Document.cpp

    r117323 r117377  
    50615061}
    50625062
    5063 void Document::statePopped(SerializedScriptValue* stateObject)
     5063void Document::statePopped(PassRefPtr<SerializedScriptValue> stateObject)
    50645064{
    50655065    if (!frame())
  • trunk/Source/WebCore/dom/Document.h

    r117029 r117377  
    10511051
    10521052    void updateURLForPushOrReplaceState(const KURL&);
    1053     void statePopped(SerializedScriptValue*);
     1053    void statePopped(PassRefPtr<SerializedScriptValue>);
    10541054
    10551055    bool processingLoadEvent() const { return m_processingLoadEvent; }
Note: See TracChangeset for help on using the changeset viewer.