Diff
Modified: trunk/Source/WebCore/ChangeLog (126236 => 126237)
--- trunk/Source/WebCore/ChangeLog 2012-08-22 00:25:52 UTC (rev 126236)
+++ trunk/Source/WebCore/ChangeLog 2012-08-22 00:32:46 UTC (rev 126237)
@@ -1,3 +1,53 @@
+2012-08-20 Kentaro Hara <[email protected]>
+
+ [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):
+
2012-08-21 Arvid Nilsson <[email protected]>
[BlackBerry] WebGL Aquarium fails to render
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (126236 => 126237)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm 2012-08-22 00:25:52 UTC (rev 126236)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm 2012-08-22 00:32:46 UTC (rev 126237)
@@ -2961,7 +2961,7 @@
push(@implContent, <<END);
// Custom toString template
- desc->Set(getToStringName(), getToStringTemplate());
+ desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->toStringTemplate());
return desc;
}
Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8Float64Array.cpp (126236 => 126237)
--- trunk/Source/WebCore/bindings/scripts/test/V8/V8Float64Array.cpp 2012-08-22 00:25:52 UTC (rev 126236)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8Float64Array.cpp 2012-08-22 00:32:46 UTC (rev 126237)
@@ -110,7 +110,7 @@
proto->Set(v8::String::NewSymbol("foo"), v8::FunctionTemplate::New(Float64ArrayV8Internal::fooCallback, v8Undefined(), fooSignature));
// Custom toString template
- desc->Set(getToStringName(), getToStringTemplate());
+ desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->toStringTemplate());
return desc;
}
Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestActiveDOMObject.cpp (126236 => 126237)
--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestActiveDOMObject.cpp 2012-08-22 00:25:52 UTC (rev 126236)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestActiveDOMObject.cpp 2012-08-22 00:32:46 UTC (rev 126237)
@@ -140,7 +140,7 @@
proto->SetAccessor(v8::String::NewSymbol("postMessage"), TestActiveDOMObjectV8Internal::postMessageAttrGetter, TestActiveDOMObjectV8Internal::TestActiveDOMObjectDomainSafeFunctionSetter, v8Undefined(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>(v8::DontDelete));
// Custom toString template
- desc->Set(getToStringName(), getToStringTemplate());
+ desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->toStringTemplate());
return desc;
}
Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCustomNamedGetter.cpp (126236 => 126237)
--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCustomNamedGetter.cpp 2012-08-22 00:25:52 UTC (rev 126236)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCustomNamedGetter.cpp 2012-08-22 00:32:46 UTC (rev 126237)
@@ -73,7 +73,7 @@
desc->InstanceTemplate()->SetNamedPropertyHandler(V8TestCustomNamedGetter::namedPropertyGetter, 0, 0, 0, 0);
// Custom toString template
- desc->Set(getToStringName(), getToStringTemplate());
+ desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->toStringTemplate());
return desc;
}
Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestEventConstructor.cpp (126236 => 126237)
--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestEventConstructor.cpp 2012-08-22 00:25:52 UTC (rev 126236)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestEventConstructor.cpp 2012-08-22 00:32:46 UTC (rev 126237)
@@ -110,7 +110,7 @@
// Custom toString template
- desc->Set(getToStringName(), getToStringTemplate());
+ desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->toStringTemplate());
return desc;
}
Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestEventTarget.cpp (126236 => 126237)
--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestEventTarget.cpp 2012-08-22 00:25:52 UTC (rev 126236)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestEventTarget.cpp 2012-08-22 00:32:46 UTC (rev 126237)
@@ -134,7 +134,7 @@
proto->Set(v8::String::NewSymbol("dispatchEvent"), v8::FunctionTemplate::New(TestEventTargetV8Internal::dispatchEventCallback, v8Undefined(), dispatchEventSignature));
// Custom toString template
- desc->Set(getToStringName(), getToStringTemplate());
+ desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->toStringTemplate());
return desc;
}
Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestException.cpp (126236 => 126237)
--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestException.cpp 2012-08-22 00:25:52 UTC (rev 126236)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestException.cpp 2012-08-22 00:32:46 UTC (rev 126237)
@@ -64,7 +64,7 @@
// Custom toString template
- desc->Set(getToStringName(), getToStringTemplate());
+ desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->toStringTemplate());
return desc;
}
Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp (126236 => 126237)
--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp 2012-08-22 00:25:52 UTC (rev 126236)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp 2012-08-22 00:32:46 UTC (rev 126237)
@@ -303,7 +303,7 @@
V8DOMConfiguration::batchConfigureConstants(desc, proto, TestInterfaceConsts, WTF_ARRAY_LENGTH(TestInterfaceConsts));
// Custom toString template
- desc->Set(getToStringName(), getToStringTemplate());
+ desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->toStringTemplate());
return desc;
}
Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp (126236 => 126237)
--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp 2012-08-22 00:25:52 UTC (rev 126236)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp 2012-08-22 00:32:46 UTC (rev 126237)
@@ -73,7 +73,7 @@
// Custom toString template
- desc->Set(getToStringName(), getToStringTemplate());
+ desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->toStringTemplate());
return desc;
}
Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestNamedConstructor.cpp (126236 => 126237)
--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestNamedConstructor.cpp 2012-08-22 00:25:52 UTC (rev 126236)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestNamedConstructor.cpp 2012-08-22 00:32:46 UTC (rev 126237)
@@ -114,7 +114,7 @@
// Custom toString template
- desc->Set(getToStringName(), getToStringTemplate());
+ desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->toStringTemplate());
return desc;
}
Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestNode.cpp (126236 => 126237)
--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestNode.cpp 2012-08-22 00:25:52 UTC (rev 126236)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestNode.cpp 2012-08-22 00:32:46 UTC (rev 126237)
@@ -73,7 +73,7 @@
// Custom toString template
- desc->Set(getToStringName(), getToStringTemplate());
+ desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->toStringTemplate());
return desc;
}
Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp (126236 => 126237)
--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp 2012-08-22 00:25:52 UTC (rev 126236)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp 2012-08-22 00:32:46 UTC (rev 126237)
@@ -2254,7 +2254,7 @@
V8DOMConfiguration::batchConfigureConstants(desc, proto, TestObjConsts, WTF_ARRAY_LENGTH(TestObjConsts));
// Custom toString template
- desc->Set(getToStringName(), getToStringTemplate());
+ desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->toStringTemplate());
return desc;
}
Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp (126236 => 126237)
--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp 2012-08-22 00:25:52 UTC (rev 126236)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp 2012-08-22 00:32:46 UTC (rev 126237)
@@ -256,7 +256,7 @@
// Custom toString template
- desc->Set(getToStringName(), getToStringTemplate());
+ desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->toStringTemplate());
return desc;
}
Modified: trunk/Source/WebCore/bindings/v8/V8Binding.cpp (126236 => 126237)
--- trunk/Source/WebCore/bindings/v8/V8Binding.cpp 2012-08-22 00:25:52 UTC (rev 126236)
+++ trunk/Source/WebCore/bindings/v8/V8Binding.cpp 2012-08-22 00:32:46 UTC (rev 126237)
@@ -325,39 +325,6 @@
return v8::Persistent<v8::FunctionTemplate>::New(result);
}
-v8::Persistent<v8::String> getToStringName()
-{
- v8::Persistent<v8::String>& toStringName = V8PerIsolateData::current()->toStringName();
- if (toStringName.IsEmpty())
- toStringName = v8::Persistent<v8::String>::New(v8::String::New("toString"));
- return *toStringName;
-
-}
-
-static v8::Handle<v8::Value> constructorToString(const v8::Arguments& args)
-{
- // The DOM constructors' toString functions grab the current toString
- // for Functions by taking the toString function of itself and then
- // calling it with the constructor as its receiver. This means that
- // changes to the Function prototype chain or toString function are
- // reflected when printing DOM constructors. The only wart is that
- // changes to a DOM constructor's toString's toString will cause the
- // toString of the DOM constructor itself to change. This is extremely
- // obscure and unlikely to be a problem.
- v8::Handle<v8::Value> value = args.Callee()->Get(getToStringName());
- if (!value->IsFunction())
- return v8::String::New("");
- return v8::Handle<v8::Function>::Cast(value)->Call(args.This(), 0, 0);
-}
-
-v8::Persistent<v8::FunctionTemplate> getToStringTemplate()
-{
- v8::Persistent<v8::FunctionTemplate>& toStringTemplate = V8PerIsolateData::current()->toStringTemplate();
- if (toStringTemplate.IsEmpty())
- toStringTemplate = v8::Persistent<v8::FunctionTemplate>::New(v8::FunctionTemplate::New(constructorToString));
- return toStringTemplate;
-}
-
void StringCache::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::Binding);
Modified: trunk/Source/WebCore/bindings/v8/V8Binding.h (126236 => 126237)
--- trunk/Source/WebCore/bindings/v8/V8Binding.h 2012-08-22 00:25:52 UTC (rev 126236)
+++ trunk/Source/WebCore/bindings/v8/V8Binding.h 2012-08-22 00:32:46 UTC (rev 126237)
@@ -354,9 +354,6 @@
v8::Persistent<v8::FunctionTemplate> createRawTemplate();
- v8::Persistent<v8::String> getToStringName();
- v8::Persistent<v8::FunctionTemplate> getToStringTemplate();
-
String int32ToWebCoreString(int value);
PassRefPtr<DOMStringList> toDOMStringList(v8::Handle<v8::Value>);
Modified: trunk/Source/WebCore/bindings/v8/V8PerIsolateData.cpp (126236 => 126237)
--- trunk/Source/WebCore/bindings/v8/V8PerIsolateData.cpp 2012-08-22 00:25:52 UTC (rev 126236)
+++ trunk/Source/WebCore/bindings/v8/V8PerIsolateData.cpp 2012-08-22 00:32:46 UTC (rev 126237)
@@ -106,4 +106,20 @@
}
#endif
+v8::Handle<v8::Value> V8PerIsolateData::constructorOfToString(const v8::Arguments& args)
+{
+ // The DOM constructors' toString functions grab the current toString
+ // for Functions by taking the toString function of itself and then
+ // calling it with the constructor as its receiver. This means that
+ // changes to the Function prototype chain or toString function are
+ // reflected when printing DOM constructors. The only wart is that
+ // changes to a DOM constructor's toString's toString will cause the
+ // toString of the DOM constructor itself to change. This is extremely
+ // obscure and unlikely to be a problem.
+ v8::Handle<v8::Value> value = args.Callee()->Get(v8::String::NewSymbol("toString"));
+ if (!value->IsFunction())
+ return v8::String::New("");
+ return v8::Handle<v8::Function>::Cast(value)->Call(args.This(), 0, 0);
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/bindings/v8/V8PerIsolateData.h (126236 => 126237)
--- trunk/Source/WebCore/bindings/v8/V8PerIsolateData.h 2012-08-22 00:25:52 UTC (rev 126236)
+++ trunk/Source/WebCore/bindings/v8/V8PerIsolateData.h 2012-08-22 00:32:46 UTC (rev 126237)
@@ -69,9 +69,14 @@
TemplateMap& rawTemplateMap() { return m_rawTemplates; }
TemplateMap& templateMap() { return m_templates; }
- v8::Persistent<v8::String>& toStringName() { return m_toStringName; }
- v8::Persistent<v8::FunctionTemplate>& toStringTemplate() { return m_toStringTemplate; }
+ v8::Persistent<v8::FunctionTemplate>& toStringTemplate()
+ {
+ if (m_toStringTemplate.IsEmpty())
+ m_toStringTemplate = v8::Persistent<v8::FunctionTemplate>::New(v8::FunctionTemplate::New(constructorOfToString));
+ return m_toStringTemplate;
+ }
+
v8::Persistent<v8::FunctionTemplate>& lazyEventListenerToStringTemplate()
{
return m_lazyEventListenerToStringTemplate;
@@ -130,10 +135,10 @@
private:
explicit V8PerIsolateData(v8::Isolate*);
~V8PerIsolateData();
+ static v8::Handle<v8::Value> constructorOfToString(const v8::Arguments&);
TemplateMap m_rawTemplates;
TemplateMap m_templates;
- v8::Persistent<v8::String> m_toStringName;
v8::Persistent<v8::FunctionTemplate> m_toStringTemplate;
v8::Persistent<v8::FunctionTemplate> m_lazyEventListenerToStringTemplate;
OwnPtr<StringCache> m_stringCache;