Changeset 145765 in webkit
- Timestamp:
- Mar 13, 2013 3:50:09 PM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r145762 r145765 1 2013-03-13 Marja Hölttä <marja@chromium.org> 2 3 [V8] Get rid of more function-level static FunctionTemplates and ObjectTemplates in bindings 4 https://bugs.webkit.org/show_bug.cgi?id=112262 5 6 Reviewed by Jochen Eisinger. 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 and object templates as static variables inside functions will 11 break the functionality. 12 13 No new tests (no changes in functionality yet; existing bindings 14 tests still pass). 15 16 * bindings/scripts/CodeGeneratorV8.pm: 17 (GenerateHeader): 18 (GenerateImplementation): 19 * bindings/v8/V8DOMWindowShell.cpp: 20 (WebCore::V8DOMWindowShell::createContext): 21 * bindings/v8/V8PerIsolateData.cpp: 22 (WebCore::V8PerIsolateData::hasPrivateTemplate): 23 (WebCore): 24 * bindings/v8/V8PerIsolateData.h: 25 (V8PerIsolateData): 26 * bindings/v8/custom/V8HTMLDocumentCustom.cpp: 27 (WebCore::V8HTMLDocument::wrapInShadowObject): 28 1 29 2013-03-13 Julien Chaffraix <jchaffraix@webkit.org> 2 30 -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm
r145745 r145765 385 385 if ($interfaceName eq "DOMWindow") { 386 386 push(@headerContent, <<END); 387 static v8::Persistent<v8::ObjectTemplate> GetShadowObjectTemplate(v8::Isolate* );387 static v8::Persistent<v8::ObjectTemplate> GetShadowObjectTemplate(v8::Isolate*, WrapperWorldType); 388 388 END 389 389 } … … 3261 3261 if ($interfaceName eq "DOMWindow") { 3262 3262 push(@implContent, <<END); 3263 v8::Persistent<v8::ObjectTemplate> V8DOMWindow::GetShadowObjectTemplate(v8::Isolate* isolate) 3264 { 3265 static v8::Persistent<v8::ObjectTemplate> V8DOMWindowShadowObjectCache; 3266 if (V8DOMWindowShadowObjectCache.IsEmpty()) { 3267 V8DOMWindowShadowObjectCache = v8::Persistent<v8::ObjectTemplate>::New(isolate, v8::ObjectTemplate::New()); 3268 ConfigureShadowObjectTemplate(V8DOMWindowShadowObjectCache, isolate); 3269 } 3270 return V8DOMWindowShadowObjectCache; 3263 v8::Persistent<v8::ObjectTemplate> V8DOMWindow::GetShadowObjectTemplate(v8::Isolate* isolate, WrapperWorldType currentWorldType) 3264 { 3265 if (currentWorldType == MainWorld) { 3266 static v8::Persistent<v8::ObjectTemplate> V8DOMWindowShadowObjectCacheForMainWorld; 3267 if (V8DOMWindowShadowObjectCacheForMainWorld.IsEmpty()) { 3268 V8DOMWindowShadowObjectCacheForMainWorld = v8::Persistent<v8::ObjectTemplate>::New(isolate, v8::ObjectTemplate::New()); 3269 ConfigureShadowObjectTemplate(V8DOMWindowShadowObjectCacheForMainWorld, isolate); 3270 } 3271 return V8DOMWindowShadowObjectCacheForMainWorld; 3272 } else { 3273 static v8::Persistent<v8::ObjectTemplate> V8DOMWindowShadowObjectCacheForNonMainWorld; 3274 if (V8DOMWindowShadowObjectCacheForNonMainWorld.IsEmpty()) { 3275 V8DOMWindowShadowObjectCacheForNonMainWorld = v8::Persistent<v8::ObjectTemplate>::New(isolate, v8::ObjectTemplate::New()); 3276 ConfigureShadowObjectTemplate(V8DOMWindowShadowObjectCacheForNonMainWorld, isolate); 3277 } 3278 return V8DOMWindowShadowObjectCacheForNonMainWorld; 3279 } 3271 3280 } 3272 3281 -
trunk/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp
r144805 r145765 282 282 // Create a new environment using an empty template for the shadow 283 283 // object. Reuse the global object if one has been created earlier. 284 v8::Persistent<v8::ObjectTemplate> globalTemplate = V8DOMWindow::GetShadowObjectTemplate(m_isolate );284 v8::Persistent<v8::ObjectTemplate> globalTemplate = V8DOMWindow::GetShadowObjectTemplate(m_isolate, m_world->isMainWorld() ? MainWorld : IsolatedWorld); 285 285 if (globalTemplate.IsEmpty()) 286 286 return; -
trunk/Source/WebCore/bindings/v8/V8PerIsolateData.cpp
r145575 r145765 123 123 } 124 124 125 bool V8PerIsolateData::hasPrivateTemplate(WrapperWorldType, void* privatePointer) 126 { 127 return m_templates.find(privatePointer) != m_templates.end(); 128 } 129 125 130 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 131 { -
trunk/Source/WebCore/bindings/v8/V8PerIsolateData.h
r145575 r145765 129 129 bool shouldCollectGarbageSoon() const { return m_shouldCollectGarbageSoon; } 130 130 131 bool hasPrivateTemplate(WrapperWorldType, void* privatePointer); 131 132 v8::Persistent<v8::FunctionTemplate> privateTemplate(WrapperWorldType, void* privatePointer, v8::InvocationCallback, v8::Handle<v8::Value> data, v8::Handle<v8::Signature>, int length = 0); 132 133 -
trunk/Source/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp
r144617 r145765 55 55 v8::Local<v8::Object> V8HTMLDocument::wrapInShadowObject(v8::Local<v8::Object> wrapper, Node* impl, v8::Isolate* isolate) 56 56 { 57 DEFINE_STATIC_LOCAL(v8::Persistent<v8::FunctionTemplate>, shadowTemplate, ()); 58 if (shadowTemplate.IsEmpty()) { 57 // This is only for getting a unique pointer which we can pass to privateTemplate. 58 static const char* shadowTemplateUniqueKey = "wrapInShadowObjectShadowTemplate"; 59 WrapperWorldType currentWorldType = worldType(isolate); 60 v8::Persistent<v8::FunctionTemplate> shadowTemplate; 61 if (!V8PerIsolateData::from(isolate)->hasPrivateTemplate(currentWorldType, &shadowTemplateUniqueKey)) { 59 62 shadowTemplate = v8::Persistent<v8::FunctionTemplate>::New(isolate, v8::FunctionTemplate::New()); 60 63 if (shadowTemplate.IsEmpty()) 61 64 return v8::Local<v8::Object>(); 62 65 shadowTemplate->SetClassName(v8::String::NewSymbol("HTMLDocument")); 63 shadowTemplate->Inherit(V8HTMLDocument::GetTemplate(isolate, worldTypeInMainThread(isolate)));66 shadowTemplate->Inherit(V8HTMLDocument::GetTemplate(isolate, currentWorldType)); 64 67 shadowTemplate->InstanceTemplate()->SetInternalFieldCount(V8HTMLDocument::internalFieldCount); 68 } else { 69 shadowTemplate = V8PerIsolateData::from(isolate)->privateTemplate(currentWorldType, &shadowTemplateUniqueKey, 0, v8::Handle<v8::Value>(), v8::Handle<v8::Signature>()); 65 70 } 66 67 71 v8::Local<v8::Function> shadowConstructor = shadowTemplate->GetFunction(); 68 72 if (shadowConstructor.IsEmpty())
Note: See TracChangeset
for help on using the changeset viewer.