Changeset 126237 in webkit


Ignore:
Timestamp:
Aug 21, 2012 5:32:46 PM (12 years ago)
Author:
haraken@chromium.org
Message:

[V8] Remove getToStringName() and getToStringTemplate() from V8Binding
https://bugs.webkit.org/show_bug.cgi?id=94573

Reviewed by Adam Barth.

  • Remove V8Binding::getToStringName() and V8Binding::getToStringTemplate().
  • Replace getToStringName() with String::NewSymbol("toString").
  • Fix V8PerIsolateData::getToStringTemplate() so that it caches a persistent

handle of a created FunctionTemplate. Before this patch, a FunctionTemplate
had been created for each toString().

No tests. No change in behavior.

  • bindings/v8/V8Binding.cpp:

(WebCore::constructorToString):

  • bindings/v8/V8Binding.h:

(WebCore):

  • bindings/scripts/CodeGeneratorV8.pm:

(GenerateImplementation):

  • bindings/scripts/test/V8/V8Float64Array.cpp:

(WebCore::ConfigureV8Float64ArrayTemplate):

  • bindings/scripts/test/V8/V8TestActiveDOMObject.cpp:

(WebCore::ConfigureV8TestActiveDOMObjectTemplate):

  • bindings/scripts/test/V8/V8TestCustomNamedGetter.cpp:

(WebCore::ConfigureV8TestCustomNamedGetterTemplate):

  • bindings/scripts/test/V8/V8TestEventConstructor.cpp:

(WebCore::ConfigureV8TestEventConstructorTemplate):

  • bindings/scripts/test/V8/V8TestEventTarget.cpp:

(WebCore::ConfigureV8TestEventTargetTemplate):

  • bindings/scripts/test/V8/V8TestException.cpp:

(WebCore::ConfigureV8TestExceptionTemplate):

  • bindings/scripts/test/V8/V8TestInterface.cpp:

(WebCore::ConfigureV8TestInterfaceTemplate):

  • bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp:

(WebCore::ConfigureV8TestMediaQueryListListenerTemplate):

  • bindings/scripts/test/V8/V8TestNamedConstructor.cpp:

(WebCore::ConfigureV8TestNamedConstructorTemplate):

  • bindings/scripts/test/V8/V8TestNode.cpp:

(WebCore::ConfigureV8TestNodeTemplate):

  • bindings/scripts/test/V8/V8TestObj.cpp:

(WebCore::ConfigureV8TestObjTemplate):

  • bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp:

(WebCore::ConfigureV8TestSerializedScriptValueInterfaceTemplate):

  • bindings/v8/V8PerIsolateData.h:

(V8PerIsolateData):

Location:
trunk/Source/WebCore
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r126236 r126237  
     12012-08-20  Kentaro Hara  <haraken@chromium.org>
     2
     3        [V8] Remove getToStringName() and getToStringTemplate() from V8Binding
     4        https://bugs.webkit.org/show_bug.cgi?id=94573
     5
     6        Reviewed by Adam Barth.
     7
     8        - Remove V8Binding::getToStringName() and V8Binding::getToStringTemplate().
     9
     10        - Replace getToStringName() with String::NewSymbol("toString").
     11
     12        - Fix V8PerIsolateData::getToStringTemplate() so that it caches a persistent
     13        handle of a created FunctionTemplate. Before this patch, a FunctionTemplate
     14        had been created for each toString().
     15
     16        No tests. No change in behavior.
     17
     18        * bindings/v8/V8Binding.cpp:
     19        (WebCore::constructorToString):
     20        * bindings/v8/V8Binding.h:
     21        (WebCore):
     22        * bindings/scripts/CodeGeneratorV8.pm:
     23        (GenerateImplementation):
     24        * bindings/scripts/test/V8/V8Float64Array.cpp:
     25        (WebCore::ConfigureV8Float64ArrayTemplate):
     26        * bindings/scripts/test/V8/V8TestActiveDOMObject.cpp:
     27        (WebCore::ConfigureV8TestActiveDOMObjectTemplate):
     28        * bindings/scripts/test/V8/V8TestCustomNamedGetter.cpp:
     29        (WebCore::ConfigureV8TestCustomNamedGetterTemplate):
     30        * bindings/scripts/test/V8/V8TestEventConstructor.cpp:
     31        (WebCore::ConfigureV8TestEventConstructorTemplate):
     32        * bindings/scripts/test/V8/V8TestEventTarget.cpp:
     33        (WebCore::ConfigureV8TestEventTargetTemplate):
     34        * bindings/scripts/test/V8/V8TestException.cpp:
     35        (WebCore::ConfigureV8TestExceptionTemplate):
     36        * bindings/scripts/test/V8/V8TestInterface.cpp:
     37        (WebCore::ConfigureV8TestInterfaceTemplate):
     38        * bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp:
     39        (WebCore::ConfigureV8TestMediaQueryListListenerTemplate):
     40        * bindings/scripts/test/V8/V8TestNamedConstructor.cpp:
     41        (WebCore::ConfigureV8TestNamedConstructorTemplate):
     42        * bindings/scripts/test/V8/V8TestNode.cpp:
     43        (WebCore::ConfigureV8TestNodeTemplate):
     44        * bindings/scripts/test/V8/V8TestObj.cpp:
     45        (WebCore::ConfigureV8TestObjTemplate):
     46        * bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp:
     47        (WebCore::ConfigureV8TestSerializedScriptValueInterfaceTemplate):
     48        * bindings/v8/V8PerIsolateData.h:
     49        (V8PerIsolateData):
     50
    1512012-08-21  Arvid Nilsson  <anilsson@rim.com>
    252
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm

    r126141 r126237  
    29622962
    29632963    // Custom toString template
    2964     desc->Set(getToStringName(), getToStringTemplate());
     2964    desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->toStringTemplate());
    29652965    return desc;
    29662966}
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8Float64Array.cpp

    r126141 r126237  
    111111
    112112    // Custom toString template
    113     desc->Set(getToStringName(), getToStringTemplate());
     113    desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->toStringTemplate());
    114114    return desc;
    115115}
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestActiveDOMObject.cpp

    r126141 r126237  
    141141
    142142    // Custom toString template
    143     desc->Set(getToStringName(), getToStringTemplate());
     143    desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->toStringTemplate());
    144144    return desc;
    145145}
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCustomNamedGetter.cpp

    r125495 r126237  
    7474
    7575    // Custom toString template
    76     desc->Set(getToStringName(), getToStringTemplate());
     76    desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->toStringTemplate());
    7777    return desc;
    7878}
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestEventConstructor.cpp

    r125495 r126237  
    111111
    112112    // Custom toString template
    113     desc->Set(getToStringName(), getToStringTemplate());
     113    desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->toStringTemplate());
    114114    return desc;
    115115}
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestEventTarget.cpp

    r126141 r126237  
    135135
    136136    // Custom toString template
    137     desc->Set(getToStringName(), getToStringTemplate());
     137    desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->toStringTemplate());
    138138    return desc;
    139139}
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestException.cpp

    r125295 r126237  
    6565
    6666    // Custom toString template
    67     desc->Set(getToStringName(), getToStringTemplate());
     67    desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->toStringTemplate());
    6868    return desc;
    6969}
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp

    r126141 r126237  
    304304
    305305    // Custom toString template
    306     desc->Set(getToStringName(), getToStringTemplate());
     306    desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->toStringTemplate());
    307307    return desc;
    308308}
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp

    r125495 r126237  
    7474
    7575    // Custom toString template
    76     desc->Set(getToStringName(), getToStringTemplate());
     76    desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->toStringTemplate());
    7777    return desc;
    7878}
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestNamedConstructor.cpp

    r126141 r126237  
    115115
    116116    // Custom toString template
    117     desc->Set(getToStringName(), getToStringTemplate());
     117    desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->toStringTemplate());
    118118    return desc;
    119119}
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestNode.cpp

    r125495 r126237  
    7474
    7575    // Custom toString template
    76     desc->Set(getToStringName(), getToStringTemplate());
     76    desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->toStringTemplate());
    7777    return desc;
    7878}
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp

    r126141 r126237  
    22552255
    22562256    // Custom toString template
    2257     desc->Set(getToStringName(), getToStringTemplate());
     2257    desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->toStringTemplate());
    22582258    return desc;
    22592259}
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp

    r125495 r126237  
    257257
    258258    // Custom toString template
    259     desc->Set(getToStringName(), getToStringTemplate());
     259    desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->toStringTemplate());
    260260    return desc;
    261261}
  • trunk/Source/WebCore/bindings/v8/V8Binding.cpp

    r126218 r126237  
    326326}       
    327327
    328 v8::Persistent<v8::String> getToStringName()
    329 {
    330     v8::Persistent<v8::String>& toStringName = V8PerIsolateData::current()->toStringName();
    331     if (toStringName.IsEmpty())
    332         toStringName = v8::Persistent<v8::String>::New(v8::String::New("toString"));
    333     return *toStringName;
    334 
    335 }
    336 
    337 static v8::Handle<v8::Value> constructorToString(const v8::Arguments& args)
    338 {
    339     // The DOM constructors' toString functions grab the current toString
    340     // for Functions by taking the toString function of itself and then
    341     // calling it with the constructor as its receiver. This means that
    342     // changes to the Function prototype chain or toString function are
    343     // reflected when printing DOM constructors. The only wart is that
    344     // changes to a DOM constructor's toString's toString will cause the
    345     // toString of the DOM constructor itself to change. This is extremely
    346     // obscure and unlikely to be a problem.
    347     v8::Handle<v8::Value> value = args.Callee()->Get(getToStringName());
    348     if (!value->IsFunction())
    349         return v8::String::New("");
    350     return v8::Handle<v8::Function>::Cast(value)->Call(args.This(), 0, 0);
    351 }
    352 
    353 v8::Persistent<v8::FunctionTemplate> getToStringTemplate()
    354 {
    355     v8::Persistent<v8::FunctionTemplate>& toStringTemplate = V8PerIsolateData::current()->toStringTemplate();
    356     if (toStringTemplate.IsEmpty())
    357         toStringTemplate = v8::Persistent<v8::FunctionTemplate>::New(v8::FunctionTemplate::New(constructorToString));
    358     return toStringTemplate;
    359 }
    360 
    361328void StringCache::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
    362329{
  • trunk/Source/WebCore/bindings/v8/V8Binding.h

    r126222 r126237  
    355355    v8::Persistent<v8::FunctionTemplate> createRawTemplate();
    356356
    357     v8::Persistent<v8::String> getToStringName();
    358     v8::Persistent<v8::FunctionTemplate> getToStringTemplate();
    359 
    360357    String int32ToWebCoreString(int value);
    361358
  • trunk/Source/WebCore/bindings/v8/V8PerIsolateData.cpp

    r125494 r126237  
    107107#endif
    108108
     109v8::Handle<v8::Value> V8PerIsolateData::constructorOfToString(const v8::Arguments& args)
     110{
     111    // The DOM constructors' toString functions grab the current toString
     112    // for Functions by taking the toString function of itself and then
     113    // calling it with the constructor as its receiver. This means that
     114    // changes to the Function prototype chain or toString function are
     115    // reflected when printing DOM constructors. The only wart is that
     116    // changes to a DOM constructor's toString's toString will cause the
     117    // toString of the DOM constructor itself to change. This is extremely
     118    // obscure and unlikely to be a problem.
     119    v8::Handle<v8::Value> value = args.Callee()->Get(v8::String::NewSymbol("toString"));
     120    if (!value->IsFunction())
     121        return v8::String::New("");
     122    return v8::Handle<v8::Function>::Cast(value)->Call(args.This(), 0, 0);
     123}
     124
    109125} // namespace WebCore
  • trunk/Source/WebCore/bindings/v8/V8PerIsolateData.h

    r126066 r126237  
    7070    TemplateMap& rawTemplateMap() { return m_rawTemplates; }
    7171    TemplateMap& templateMap() { return m_templates; }
    72     v8::Persistent<v8::String>& toStringName() { return m_toStringName; }
    73     v8::Persistent<v8::FunctionTemplate>& toStringTemplate() { return m_toStringTemplate; }
     72
     73    v8::Persistent<v8::FunctionTemplate>& toStringTemplate()
     74    {
     75        if (m_toStringTemplate.IsEmpty())
     76            m_toStringTemplate = v8::Persistent<v8::FunctionTemplate>::New(v8::FunctionTemplate::New(constructorOfToString));
     77        return m_toStringTemplate;
     78    }
    7479
    7580    v8::Persistent<v8::FunctionTemplate>& lazyEventListenerToStringTemplate()
     
    131136    explicit V8PerIsolateData(v8::Isolate*);
    132137    ~V8PerIsolateData();
     138    static v8::Handle<v8::Value> constructorOfToString(const v8::Arguments&);
    133139
    134140    TemplateMap m_rawTemplates;
    135141    TemplateMap m_templates;
    136     v8::Persistent<v8::String> m_toStringName;
    137142    v8::Persistent<v8::FunctionTemplate> m_toStringTemplate;
    138143    v8::Persistent<v8::FunctionTemplate> m_lazyEventListenerToStringTemplate;
Note: See TracChangeset for help on using the changeset viewer.