Changeset 145494 in webkit
- Timestamp:
- Mar 12, 2013 12:52:32 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r145493 r145494 1 2013-03-12 Marja Hölttä <marja@chromium.org> 2 3 [V8] Get rid of function-level static FunctionTemplates in generated bindings code 4 https://bugs.webkit.org/show_bug.cgi?id=111971 5 6 Reviewed by Kentaro Hara. 7 8 In the future we'll create and store function templates for main world 9 and non-main worlds separately (see bug 111724), having function 10 templates as static variables inside functions will break the 11 functionality. 12 13 No new tests (updated the bindings test expectations). 14 15 * bindings/scripts/CodeGeneratorV8.pm: 16 (GenerateDomainSafeFunctionGetter): 17 * bindings/scripts/test/V8/V8TestActiveDOMObject.cpp: 18 (WebCore::TestActiveDOMObjectV8Internal::postMessageAttrGetter): 19 * bindings/v8/V8PerIsolateData.cpp: 20 (WebCore::V8PerIsolateData::V8PerIsolateData): 21 (WebCore::V8PerIsolateData::privateTemplate): 22 (WebCore): 23 * bindings/v8/V8PerIsolateData.h: 24 (V8PerIsolateData): 25 * bindings/v8/custom/V8LocationCustom.cpp: 26 (WebCore::V8Location::reloadAttrGetterCustom): 27 (WebCore::V8Location::replaceAttrGetterCustom): 28 (WebCore::V8Location::assignAttrGetterCustom): 29 1 30 2013-03-12 Tien-Ren Chen <trchen@chromium.org> 2 31 -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm
r145043 r145494 787 787 } 788 788 789 my $newTemplate String = "v8::FunctionTemplate::New(${interfaceName}V8Internal::${funcName}MethodCallback, v8Undefined(), $signature)";789 my $newTemplateParams = "${interfaceName}V8Internal::${funcName}MethodCallback, v8Undefined(), $signature"; 790 790 791 791 AddToImplIncludes("Frame.h"); … … 793 793 static v8::Handle<v8::Value> ${funcName}AttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) 794 794 { 795 static v8::Persistent<v8::FunctionTemplate> privateTemplate = v8::Persistent<v8::FunctionTemplate>::New(info.GetIsolate(), $newTemplateString); 796 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(${v8InterfaceName}::GetTemplate(info.GetIsolate(), worldType(info.GetIsolate()))); 795 // This is only for getting a unique pointer which we can pass to privateTemplate. 796 static String privateTemplateUniqueKey = "${funcName}PrivateTemplate"; 797 WrapperWorldType currentWorldType = worldType(info.GetIsolate()); 798 v8::Persistent<v8::FunctionTemplate> privateTemplate = V8PerIsolateData::from(info.GetIsolate())->privateTemplate(currentWorldType, &privateTemplateUniqueKey, $newTemplateParams); 799 800 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(${v8InterfaceName}::GetTemplate(info.GetIsolate(), currentWorldType)); 797 801 if (holder.IsEmpty()) { 798 802 // can only reach here by 'object.__proto__.func', and it should passed … … 802 806 ${interfaceName}* imp = ${v8InterfaceName}::toNative(holder); 803 807 if (!BindingSecurity::shouldAllowAccessToFrame(BindingState::instance(), imp->frame(), DoNotReportSecurityError)) { 804 static v8::Persistent<v8::FunctionTemplate> sharedTemplate = v8::Persistent<v8::FunctionTemplate>::New(info.GetIsolate(), $newTemplateString); 808 static String sharedTemplateUniqueKey = "${funcName}SharedTemplate"; 809 v8::Persistent<v8::FunctionTemplate> sharedTemplate = V8PerIsolateData::from(info.GetIsolate())->privateTemplate(currentWorldType, &sharedTemplateUniqueKey, $newTemplateParams); 805 810 return sharedTemplate->GetFunction(); 806 811 } -
trunk/Source/WebCore/bindings/scripts/test/V8/V8TestActiveDOMObject.cpp
r144651 r145494 129 129 static v8::Handle<v8::Value> postMessageAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) 130 130 { 131 static v8::Persistent<v8::FunctionTemplate> privateTemplate = v8::Persistent<v8::FunctionTemplate>::New(info.GetIsolate(), v8::FunctionTemplate::New(TestActiveDOMObjectV8Internal::postMessageMethodCallback, v8Undefined(), v8::Signature::New(V8TestActiveDOMObject::GetRawTemplate(info.GetIsolate())))); 132 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8TestActiveDOMObject::GetTemplate(info.GetIsolate(), worldType(info.GetIsolate()))); 131 // This is only for getting a unique pointer which we can pass to privateTemplate. 132 static String privateTemplateUniqueKey = "postMessagePrivateTemplate"; 133 WrapperWorldType currentWorldType = worldType(info.GetIsolate()); 134 v8::Persistent<v8::FunctionTemplate> privateTemplate = V8PerIsolateData::from(info.GetIsolate())->privateTemplate(currentWorldType, &privateTemplateUniqueKey, TestActiveDOMObjectV8Internal::postMessageMethodCallback, v8Undefined(), v8::Signature::New(V8TestActiveDOMObject::GetRawTemplate(info.GetIsolate()))); 135 136 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8TestActiveDOMObject::GetTemplate(info.GetIsolate(), currentWorldType)); 133 137 if (holder.IsEmpty()) { 134 138 // can only reach here by 'object.__proto__.func', and it should passed … … 138 142 TestActiveDOMObject* imp = V8TestActiveDOMObject::toNative(holder); 139 143 if (!BindingSecurity::shouldAllowAccessToFrame(BindingState::instance(), imp->frame(), DoNotReportSecurityError)) { 140 static v8::Persistent<v8::FunctionTemplate> sharedTemplate = v8::Persistent<v8::FunctionTemplate>::New(info.GetIsolate(), v8::FunctionTemplate::New(TestActiveDOMObjectV8Internal::postMessageMethodCallback, v8Undefined(), v8::Signature::New(V8TestActiveDOMObject::GetRawTemplate(info.GetIsolate())))); 144 static String sharedTemplateUniqueKey = "postMessageSharedTemplate"; 145 v8::Persistent<v8::FunctionTemplate> sharedTemplate = V8PerIsolateData::from(info.GetIsolate())->privateTemplate(currentWorldType, &sharedTemplateUniqueKey, TestActiveDOMObjectV8Internal::postMessageMethodCallback, v8Undefined(), v8::Signature::New(V8TestActiveDOMObject::GetRawTemplate(info.GetIsolate()))); 141 146 return sharedTemplate->GetFunction(); 142 147 } -
trunk/Source/WebCore/bindings/v8/V8PerIsolateData.cpp
r141570 r145494 45 45 46 46 V8PerIsolateData::V8PerIsolateData(v8::Isolate* isolate) 47 : m_stringCache(adoptPtr(new StringCache())) 47 : m_isolate(isolate) 48 , m_stringCache(adoptPtr(new StringCache())) 48 49 , m_integerCache(adoptPtr(new IntegerCache())) 49 50 , m_domDataStore(0) … … 122 123 } 123 124 125 v8::Persistent<v8::FunctionTemplate> V8PerIsolateData::privateTemplate(WrapperWorldType, void* privatePointer, v8::InvocationCallback callback, v8::Handle<v8::Value> data, v8::Handle<v8::Signature> signature, int length) 126 { 127 v8::Persistent<v8::FunctionTemplate> privateTemplate; 128 V8PerIsolateData::TemplateMap::iterator result = m_templates.find(privatePointer); 129 if (result != m_templates.end()) 130 return result->value; 131 v8::Persistent<v8::FunctionTemplate> newPrivateTemplate = v8::Persistent<v8::FunctionTemplate>::New(m_isolate, v8::FunctionTemplate::New(callback, data, signature, length)); 132 m_templates.add(privatePointer, newPrivateTemplate); 133 return newPrivateTemplate; 134 } 135 124 136 #if ENABLE(INSPECTOR) 125 137 void V8PerIsolateData::visitExternalStrings(ExternalStringVisitor* visitor) -
trunk/Source/WebCore/bindings/v8/V8PerIsolateData.h
r136815 r145494 28 28 29 29 #include "ScopedPersistent.h" 30 #include "WrapperTypeInfo.h" 30 31 #include <v8.h> 31 32 #include <wtf/Forward.h> … … 65 66 static void dispose(v8::Isolate*); 66 67 67 typedef HashMap< WrapperTypeInfo*, v8::Persistent<v8::FunctionTemplate> > TemplateMap;68 typedef HashMap<void*, v8::Persistent<v8::FunctionTemplate> > TemplateMap; 68 69 69 70 TemplateMap& rawTemplateMap() { return m_rawTemplates; } … … 128 129 bool shouldCollectGarbageSoon() const { return m_shouldCollectGarbageSoon; } 129 130 131 v8::Persistent<v8::FunctionTemplate> privateTemplate(WrapperWorldType, void* privatePointer, v8::InvocationCallback, v8::Handle<v8::Value> data, v8::Handle<v8::Signature>, int length = 0); 132 130 133 private: 131 134 explicit V8PerIsolateData(v8::Isolate*); … … 133 136 static v8::Handle<v8::Value> constructorOfToString(const v8::Arguments&); 134 137 138 v8::Isolate* m_isolate; 135 139 TemplateMap m_rawTemplates; 136 140 TemplateMap m_templates; -
trunk/Source/WebCore/bindings/v8/custom/V8LocationCustom.cpp
r144617 r145494 140 140 { 141 141 v8::Isolate* isolate = info.GetIsolate(); 142 static v8::Persistent<v8::FunctionTemplate> privateTemplate = v8::Persistent<v8::FunctionTemplate>::New(isolate, v8::FunctionTemplate::New(V8Location::reloadMethodCustom, v8Undefined(), v8::Signature::New(V8Location::GetRawTemplate(isolate)))); 143 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8Location::GetTemplate(isolate, worldType(isolate))); 142 // This is only for getting a unique pointer which we can pass to privateTemplate. 143 static String privateTemplateUniqueKey = "reloadPrivateTemplate"; 144 WrapperWorldType currentWorldType = worldType(isolate); 145 v8::Persistent<v8::FunctionTemplate> privateTemplate = V8PerIsolateData::from(isolate)->privateTemplate(currentWorldType, &privateTemplateUniqueKey, V8Location::reloadMethodCustom, v8Undefined(), v8::Signature::New(V8Location::GetRawTemplate(isolate))); 146 147 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8Location::GetTemplate(isolate, currentWorldType)); 144 148 if (holder.IsEmpty()) { 145 149 // can only reach here by 'object.__proto__.func', and it should passed … … 149 153 Location* imp = V8Location::toNative(holder); 150 154 if (!BindingSecurity::shouldAllowAccessToFrame(BindingState::instance(), imp->frame(), DoNotReportSecurityError)) { 151 static v8::Persistent<v8::FunctionTemplate> sharedTemplate = v8::Persistent<v8::FunctionTemplate>::New(isolate, v8::FunctionTemplate::New(V8Location::reloadMethodCustom, v8Undefined(), v8::Signature::New(V8Location::GetRawTemplate(isolate)))); 155 static String sharedTemplateUniqueKey = "reloadSharedTemplate"; 156 v8::Persistent<v8::FunctionTemplate> sharedTemplate = V8PerIsolateData::from(info.GetIsolate())->privateTemplate(currentWorldType, &sharedTemplateUniqueKey, V8Location::reloadMethodCustom, v8Undefined(), v8::Signature::New(V8Location::GetRawTemplate(isolate))); 152 157 return sharedTemplate->GetFunction(); 153 158 } … … 158 163 { 159 164 v8::Isolate* isolate = info.GetIsolate(); 160 static v8::Persistent<v8::FunctionTemplate> privateTemplate = v8::Persistent<v8::FunctionTemplate>::New(isolate, v8::FunctionTemplate::New(V8Location::replaceMethodCustom, v8Undefined(), v8::Signature::New(V8Location::GetRawTemplate(isolate)))); 161 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8Location::GetTemplate(isolate, worldType(isolate))); 165 // This is only for getting a unique pointer which we can pass to privateTemplateMap. 166 static String privateTemplateUniqueKey = "replacePrivateTemplate"; 167 WrapperWorldType currentWorldType = worldType(info.GetIsolate()); 168 v8::Persistent<v8::FunctionTemplate> privateTemplate = V8PerIsolateData::from(isolate)->privateTemplate(currentWorldType, &privateTemplateUniqueKey, V8Location::replaceMethodCustom, v8Undefined(), v8::Signature::New(V8Location::GetRawTemplate(isolate))); 169 170 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8Location::GetTemplate(isolate, currentWorldType)); 162 171 if (holder.IsEmpty()) { 163 172 // can only reach here by 'object.__proto__.func', and it should passed … … 167 176 Location* imp = V8Location::toNative(holder); 168 177 if (!BindingSecurity::shouldAllowAccessToFrame(BindingState::instance(), imp->frame(), DoNotReportSecurityError)) { 169 static v8::Persistent<v8::FunctionTemplate> sharedTemplate = v8::Persistent<v8::FunctionTemplate>::New(isolate, v8::FunctionTemplate::New(V8Location::replaceMethodCustom, v8Undefined(), v8::Signature::New(V8Location::GetRawTemplate(isolate)))); 178 static String sharedTemplateUniqueKey = "replaceSharedTemplate"; 179 v8::Persistent<v8::FunctionTemplate> sharedTemplate = V8PerIsolateData::from(info.GetIsolate())->privateTemplate(currentWorldType, &sharedTemplateUniqueKey, V8Location::replaceMethodCustom, v8Undefined(), v8::Signature::New(V8Location::GetRawTemplate(isolate))); 170 180 return sharedTemplate->GetFunction(); 171 181 } … … 176 186 { 177 187 v8::Isolate* isolate = info.GetIsolate(); 178 static v8::Persistent<v8::FunctionTemplate> privateTemplate = 179 v8::Persistent<v8::FunctionTemplate>::New(isolate, v8::FunctionTemplate::New(V8Location::assignMethodCustom, v8Undefined(), v8::Signature::New(V8Location::GetRawTemplate(isolate)))); 180 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8Location::GetTemplate(isolate, worldType(isolate))); 188 // This is only for getting a unique pointer which we can pass to privateTemplateMap. 189 static String privateTemplateUniqueKey = "assignPrivateTemplate"; 190 WrapperWorldType currentWorldType = worldType(info.GetIsolate()); 191 v8::Persistent<v8::FunctionTemplate> privateTemplate = V8PerIsolateData::from(isolate)->privateTemplate(currentWorldType, &privateTemplateUniqueKey, V8Location::assignMethodCustom, v8Undefined(), v8::Signature::New(V8Location::GetRawTemplate(isolate))); 192 193 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8Location::GetTemplate(isolate, currentWorldType)); 181 194 if (holder.IsEmpty()) { 182 195 // can only reach here by 'object.__proto__.func', and it should passed … … 186 199 Location* imp = V8Location::toNative(holder); 187 200 if (!BindingSecurity::shouldAllowAccessToFrame(BindingState::instance(), imp->frame(), DoNotReportSecurityError)) { 188 static v8::Persistent<v8::FunctionTemplate> sharedTemplate = v8::Persistent<v8::FunctionTemplate>::New(isolate, v8::FunctionTemplate::New(V8Location::assignMethodCustom, v8Undefined(), v8::Signature::New(V8Location::GetRawTemplate(isolate)))); 201 static String sharedTemplateUniqueKey = "assignSharedTemplate"; 202 v8::Persistent<v8::FunctionTemplate> sharedTemplate = V8PerIsolateData::from(info.GetIsolate())->privateTemplate(currentWorldType, &sharedTemplateUniqueKey, V8Location::assignMethodCustom, v8Undefined(), v8::Signature::New(V8Location::GetRawTemplate(isolate))); 189 203 return sharedTemplate->GetFunction(); 190 204 }
Note: See TracChangeset
for help on using the changeset viewer.