Changeset 135862 in webkit


Ignore:
Timestamp:
Nov 27, 2012 7:50:07 AM (11 years ago)
Author:
haraken@chromium.org
Message:

[V8] Remove V8StringResource::m_string
https://bugs.webkit.org/show_bug.cgi?id=103367

Reviewed by Adam Barth.

This patch cleans up V8StringResource and removes V8StringResource::m_string.
This patch won't change performance. (This patch just adds one redundant IsString()
check and one IsInt32() check.) I confirmed no performance regression in micro benchmarks
(https://bugs.webkit.org/attachment.cgi?id=176178).

No tests. No change in behavior.

  • bindings/v8/V8Binding.cpp:

(WebCore::v8NonStringValueToWebCoreString):

  • bindings/v8/V8StringResource.cpp:

(WebCore::int32ToWebCoreStringFast):
(WebCore::String):
(WebCore::AtomicString):
(WebCore):

  • bindings/v8/V8StringResource.h:

(WebCore::V8StringResource::V8StringResource):
(WebCore::V8StringResource::prepareBase):
(WebCore::V8StringResource::toString):
(V8StringResource):
(WebCore::::prepare):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r135856 r135862  
     12012-11-27  Kentaro Hara  <haraken@chromium.org>
     2
     3        [V8] Remove V8StringResource::m_string
     4        https://bugs.webkit.org/show_bug.cgi?id=103367
     5
     6        Reviewed by Adam Barth.
     7
     8        This patch cleans up V8StringResource and removes V8StringResource::m_string.
     9        This patch won't change performance. (This patch just adds one redundant IsString()
     10        check and one IsInt32() check.) I confirmed no performance regression in micro benchmarks
     11        (https://bugs.webkit.org/attachment.cgi?id=176178).
     12
     13        No tests. No change in behavior.
     14
     15        * bindings/v8/V8Binding.cpp:
     16        (WebCore::v8NonStringValueToWebCoreString):
     17        * bindings/v8/V8StringResource.cpp:
     18        (WebCore::int32ToWebCoreStringFast):
     19        (WebCore::String):
     20        (WebCore::AtomicString):
     21        (WebCore):
     22        * bindings/v8/V8StringResource.h:
     23        (WebCore::V8StringResource::V8StringResource):
     24        (WebCore::V8StringResource::prepareBase):
     25        (WebCore::V8StringResource::toString):
     26        (V8StringResource):
     27        (WebCore::::prepare):
     28
    1292012-11-27  Alec Flett  <alecflett@chromium.org>
    230
  • trunk/Source/WebCore/bindings/v8/V8Binding.cpp

    r135703 r135862  
    101101    ASSERT(!object->IsString());
    102102    if (object->IsInt32())
    103         return int32ToWebCoreString(object->Int32Value());
     103        return int32ToWebCoreString<String>(object->Int32Value());
    104104
    105105    v8::TryCatch block;
  • trunk/Source/WebCore/bindings/v8/V8StringResource.cpp

    r135494 r135862  
    191191    // Most numbers used are <= 100. Even if they aren't used there's very little cost in using the space.
    192192    const int kLowNumbers = 100;
     193
     194    // FIXME: Store lowNumbers in V8PerIsolateData so that workers can also use them.
    193195    DEFINE_STATIC_LOCAL(Vector<AtomicString>, lowNumbers, (kLowNumbers + 1));
    194196    String webCoreString;
     
    205207}
    206208
    207 String int32ToWebCoreString(int value)
     209template<> String int32ToWebCoreString<String>(int value)
    208210{
    209211    // If we are on the main thread (this should always true for non-workers), call the faster one.
     
    213215}
    214216
     217template<> AtomicString int32ToWebCoreString<AtomicString>(int value)
     218{
     219    return AtomicString(int32ToWebCoreString<String>(value));
     220}
     221
    215222} // namespace WebCore
  • trunk/Source/WebCore/bindings/v8/V8StringResource.h

    r135812 r135862  
    143143template <typename StringType>
    144144StringType v8StringToWebCoreString(v8::Handle<v8::String>, ExternalMode);
    145 String int32ToWebCoreString(int value);
     145template <typename StringType>
     146StringType int32ToWebCoreString(int value);
    146147
    147148// V8StringResource is an adapter class that converts V8 values to Strings
     
    159160        : m_v8Object(object)
    160161        , m_mode(Externalize)
    161         , m_string()
    162162    {
    163163    }
     
    170170    bool prepareBase()
    171171    {
    172         if (m_v8Object.IsEmpty())
     172        ASSERT(!m_v8Object.IsEmpty());
     173        if (LIKELY(m_v8Object->IsString() || m_v8Object->IsInt32()))
    173174            return true;
    174 
    175         if (LIKELY(m_v8Object->IsString()))
    176             return true;
    177 
    178         if (LIKELY(m_v8Object->IsInt32())) {
    179             setString(int32ToWebCoreString(m_v8Object->Int32Value()));
    180             return true;
    181         }
    182175
    183176        m_mode = DoNotExternalize;
     
    192185    }
    193186
    194     void setString(const String& string)
    195     {
    196         m_string = string;
    197         m_v8Object.Clear(); // To signal that String is ready.
    198     }
    199 
    200187    template <class StringType>
    201188    StringType toString()
    202189    {
    203         if (LIKELY(!m_v8Object.IsEmpty()))
    204             return v8StringToWebCoreString<StringType>(m_v8Object.As<v8::String>(), m_mode);
    205 
    206         return StringType(m_string);
     190        if (m_v8Object.IsEmpty())
     191            return StringType();
     192        if (m_v8Object->IsInt32())
     193            return int32ToWebCoreString<StringType>(m_v8Object->Int32Value());
     194        ASSERT(m_v8Object->IsString());
     195        return v8StringToWebCoreString<StringType>(m_v8Object.As<v8::String>(), m_mode);
    207196    }
    208197
    209198    v8::Local<v8::Value> m_v8Object;
    210199    ExternalMode m_mode;
    211     String m_string;
    212200};
    213201
    214202template<> inline bool V8StringResource<DefaultMode>::prepare()
    215203{
     204    if (m_v8Object.IsEmpty())
     205        return true;
    216206    return prepareBase();
    217207}
     
    220210{
    221211    if (m_v8Object.IsEmpty() || m_v8Object->IsNull()) {
    222         setString(String());
     212        m_v8Object.Clear();
    223213        return true;
    224214    }
     
    229219{
    230220    if (m_v8Object.IsEmpty() || m_v8Object->IsNull() || m_v8Object->IsUndefined()) {
    231         setString(String());
     221        m_v8Object.Clear();
    232222        return true;
    233223    }
Note: See TracChangeset for help on using the changeset viewer.