Changeset 129984 in webkit
- Timestamp:
- Sep 29, 2012, 1:29:34 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r129983 r129984 1 2012-09-29 Sheriff Bot <webkit.review.bot@gmail.com> 2 3 Unreviewed, rolling out r129965. 4 http://trac.webkit.org/changeset/129965 5 https://bugs.webkit.org/show_bug.cgi?id=97970 6 7 Causes ASSERTs in workers (Requested by abarth on #webkit). 8 9 * bindings/v8/DOMData.cpp: 10 (WebCore::DOMData::getCurrentStore): 11 * bindings/v8/ScopedPersistent.h: 12 * bindings/v8/ScriptController.cpp: 13 (WebCore::ScriptController::resetIsolatedWorlds): 14 (WebCore::ScriptController::evaluateInIsolatedWorld): 15 (WebCore::ScriptController::currentWorldContext): 16 * bindings/v8/V8Binding.cpp: 17 (WebCore::perContextDataForCurrentWorld): 18 * bindings/v8/V8DOMWindowShell.cpp: 19 (WebCore::setIsolatedWorldField): 20 (WebCore::V8DOMWindowShell::enteredIsolatedWorldContext): 21 (WebCore::V8DOMWindowShell::destroyIsolatedShell): 22 (WebCore): 23 (WebCore::isolatedContextWeakCallback): 24 (WebCore::V8DOMWindowShell::disposeContext): 25 (WebCore::V8DOMWindowShell::initializeIfNeeded): 26 (WebCore::V8DOMWindowShell::setIsolatedWorldSecurityOrigin): 27 * bindings/v8/V8DOMWindowShell.h: 28 (V8DOMWindowShell): 29 (WebCore::V8DOMWindowShell::getEntered): 30 * bindings/v8/V8DOMWrapper.h: 31 (WebCore::V8DOMWrapper::getCachedWrapper): 32 * bindings/v8/WorldContextHandle.cpp: 33 (WebCore::WorldContextHandle::WorldContextHandle): 34 * bindings/v8/custom/V8DocumentCustom.cpp: 35 (WebCore::toV8): 36 * bindings/v8/custom/V8HTMLDocumentCustom.cpp: 37 (WebCore::toV8): 38 * bindings/v8/custom/V8SVGDocumentCustom.cpp: 39 (WebCore::toV8): 40 * bindings/v8/custom/V8XMLHttpRequestConstructor.cpp: 41 (WebCore::V8XMLHttpRequest::constructorCallback): 42 1 43 2012-09-29 Emil A Eklund <eae@chromium.org> 2 44 -
trunk/Source/WebCore/bindings/v8/DOMData.cpp
r129965 r129984 44 44 if (UNLIKELY(data->domDataStore() != 0)) 45 45 return *data->domDataStore(); 46 V8DOMWindowShell ::IsolatedContextData* isolatedData = V8DOMWindowShell::enteredIsolatedContextData();47 if (UNLIKELY( !!isolatedData))48 return * isolatedData->world()->domDataStore();46 V8DOMWindowShell* context = V8DOMWindowShell::getEntered(); 47 if (UNLIKELY(context != 0)) 48 return *context->world()->domDataStore(); 49 49 return defaultStore; 50 50 } -
trunk/Source/WebCore/bindings/v8/ScopedPersistent.h
r129965 r129984 79 79 } 80 80 81 v8::Persistent<T> leakHandle()82 {83 v8::Persistent<T> handle = m_handle;84 m_handle.Clear();85 return handle;86 }87 88 81 private: 89 82 v8::Persistent<T> m_handle; -
trunk/Source/WebCore/bindings/v8/ScriptController.cpp
r129965 r129984 147 147 for (IsolatedWorldMap::iterator iter = m_isolatedWorlds.begin(); 148 148 iter != m_isolatedWorlds.end(); ++iter) { 149 iter->second->clearIsolatedShell(); 150 delete iter->second; 149 iter->second->destroyIsolatedShell(); 151 150 } 152 151 m_isolatedWorlds.clear(); … … 392 391 } 393 392 394 // Destroy temporary world.393 // Mark temporary shell for weak destruction. 395 394 if (worldID == DOMWrapperWorld::uninitializedWorldId) { 396 395 int actualWorldId = isolatedWorldShell->world()->worldId(); 397 396 m_isolatedWorlds.remove(actualWorldId); 398 isolatedWorldShell->clearIsolatedShell(); 399 delete isolatedWorldShell; 397 isolatedWorldShell->destroyIsolatedShell(); 400 398 } 401 399 … … 432 430 v8::Local<v8::Context> ScriptController::currentWorldContext() 433 431 { 434 V8DOMWindowShell::IsolatedContextData* isolatedContextData = V8DOMWindowShell::enteredIsolatedContextData(); 435 if (UNLIKELY(!!isolatedContextData)) { 436 V8DOMWindowShell* isolatedShell = existingWindowShellInternal(isolatedContextData->world()); 437 // A temporary isolated world has been deleted, so use the current context. 438 if (UNLIKELY(!isolatedShell)) { 439 v8::Handle<v8::Context> context = v8::Context::GetEntered(); 440 if (m_frame != toFrameIfNotDetached(context)) 441 return v8::Local<v8::Context>(); 442 return v8::Local<v8::Context>::New(context); 443 } 444 // The shell exists, but potentially it has a new context, so use it. 445 if (isolatedShell->context().IsEmpty() || m_frame != toFrameIfNotDetached(isolatedShell->context())) 432 if (V8DOMWindowShell* isolatedShell = V8DOMWindowShell::getEntered()) { 433 v8::Persistent<v8::Context> context = isolatedShell->context(); 434 if (context.IsEmpty() || m_frame != toFrameIfNotDetached(context)) 446 435 return v8::Local<v8::Context>(); 447 return v8::Local<v8::Context>::New( isolatedShell->context());436 return v8::Local<v8::Context>::New(context); 448 437 } 449 438 windowShell()->initializeIfNeeded(); -
trunk/Source/WebCore/bindings/v8/V8Binding.cpp
r129965 r129984 312 312 V8PerContextData* perContextDataForCurrentWorld(Frame* frame) 313 313 { 314 V8DOMWindowShell ::IsolatedContextData* isolatedShellData = 0;315 if (UNLIKELY(!!(isolatedShell Data = V8DOMWindowShell::enteredIsolatedContextData())))316 return isolatedShell Data->perContextData();314 V8DOMWindowShell* isolatedShell; 315 if (UNLIKELY(!!(isolatedShell = V8DOMWindowShell::getEntered()))) 316 return isolatedShell->perContextData(); 317 317 return frame->script()->windowShell()->perContextData(); 318 318 } -
trunk/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp
r129965 r129984 171 171 } 172 172 173 static void setIsolatedWorldField(V8DOMWindowShell::IsolatedContextData* data, v8::Handle<v8::Context> context) 174 { 175 toInnerGlobalObject(context)->SetPointerInInternalField(V8DOMWindow::enteredIsolatedWorldIndex, data); 176 } 177 178 V8DOMWindowShell::IsolatedContextData* V8DOMWindowShell::toIsolatedContextData(v8::Handle<v8::Object> innerGlobal) 179 { 180 ASSERT(innerGlobal->InternalFieldCount() >= V8DOMWindow::enteredIsolatedWorldIndex); 181 return static_cast<IsolatedContextData*>(innerGlobal->GetPointerFromInternalField(V8DOMWindow::enteredIsolatedWorldIndex)); 173 static void setIsolatedWorldField(V8DOMWindowShell* shell, v8::Local<v8::Context> context) 174 { 175 toInnerGlobalObject(context)->SetPointerInInternalField(V8DOMWindow::enteredIsolatedWorldIndex, shell); 176 } 177 178 V8DOMWindowShell* V8DOMWindowShell::enteredIsolatedWorldContext() 179 { 180 return static_cast<V8DOMWindowShell*>(toInnerGlobalObject(v8::Context::GetEntered())->GetPointerFromInternalField(V8DOMWindow::enteredIsolatedWorldIndex)); 182 181 } 183 182 … … 209 208 } 210 209 210 void V8DOMWindowShell::destroyIsolatedShell() 211 { 212 disposeContext(true); 213 } 214 211 215 static void isolatedContextWeakCallback(v8::Persistent<v8::Value> object, void* parameter) 212 216 { 213 object.Dispose(); 214 delete static_cast<V8DOMWindowShell::IsolatedContextData*>(parameter); 215 } 216 217 void V8DOMWindowShell::disposeContext() 218 { 217 // Handle will be disposed in delete. 218 delete static_cast<V8DOMWindowShell*>(parameter); 219 } 220 221 void V8DOMWindowShell::disposeContext(bool weak) 222 { 223 ASSERT(!m_context.get().IsWeak()); 219 224 m_perContextData.clear(); 220 225 … … 224 229 m_frame->loader()->client()->willReleaseScriptContext(m_context.get(), m_world->worldId()); 225 230 226 if (m_isolatedContextData) { 231 if (!weak) 232 m_context.clear(); 233 else { 227 234 ASSERT(!m_world->isMainWorld()); 228 // Here we must intentionally leak the per context data pointer as it gets deleted in isolatedContextWeakCallback. 229 m_context.leakHandle().MakeWeak(m_isolatedContextData.leakPtr(), isolatedContextWeakCallback); 230 // The global handle keeps a reference to the context, so it must be removed. 231 m_global.clear(); 232 } else 233 m_context.clear(); 235 destroyGlobal(); 236 m_frame = 0; 237 m_context.get().MakeWeak(this, isolatedContextWeakCallback); 238 } 234 239 235 240 // It's likely that disposing the context has created a lot of … … 245 250 { 246 251 m_global.clear(); 247 }248 249 void V8DOMWindowShell::clearIsolatedShell()250 {251 disposeContext();252 252 } 253 253 … … 346 346 } 347 347 348 m_perContextData = V8PerContextData::create(m_context.get());349 if (!m_perContextData->init()) {350 disposeContext();351 return false;352 }353 354 348 // Flag context as isolated. 355 349 if (!isMainWorld) { … … 358 352 if (!mainWindow->context().IsEmpty()) 359 353 setInjectedScriptContextDebugId(m_context.get(), m_frame->script()->contextDebugId(mainWindow->context())); 360 m_isolatedContextData = IsolatedContextData::create(m_world, m_perContextData.release(), m_isolatedWorldShellSecurityOrigin); 361 setIsolatedWorldField(m_isolatedContextData.get(), context); 354 setIsolatedWorldField(this, context); 355 } 356 357 m_perContextData = V8PerContextData::create(m_context.get()); 358 if (!m_perContextData->init()) { 359 disposeContext(); 360 return false; 362 361 } 363 362 … … 619 618 } 620 619 m_isolatedWorldShellSecurityOrigin = securityOrigin; 621 if (m_isolatedContextData)622 m_isolatedContextData->setSecurityOrigin(m_isolatedWorldShellSecurityOrigin);623 620 } 624 621 -
trunk/Source/WebCore/bindings/v8/V8DOMWindowShell.h
r129965 r129984 54 54 class V8DOMWindowShell { 55 55 public: 56 57 // This class holds all the data that is accessible from a context for an isolated shell.58 // It survives until the context is deleted.59 class IsolatedContextData {60 WTF_MAKE_NONCOPYABLE(IsolatedContextData);61 public:62 static PassOwnPtr<IsolatedContextData> create(PassRefPtr<DOMWrapperWorld> world, PassOwnPtr<V8PerContextData> perContextData, PassRefPtr<SecurityOrigin> securityOrigin)63 {64 return adoptPtr(new IsolatedContextData(world, perContextData, securityOrigin));65 }66 DOMWrapperWorld* world() { return m_world.get(); }67 V8PerContextData* perContextData() { return m_perContextData.get(); }68 void setSecurityOrigin(PassRefPtr<SecurityOrigin> origin) { m_securityOrigin = origin; }69 SecurityOrigin* securityOrigin() { return m_securityOrigin.get(); }70 71 private:72 IsolatedContextData(PassRefPtr<DOMWrapperWorld> world, PassOwnPtr<V8PerContextData> perContextData, PassRefPtr<SecurityOrigin> securityOrigin)73 : m_world(world)74 , m_perContextData(perContextData)75 , m_securityOrigin(securityOrigin)76 {77 }78 79 RefPtr<DOMWrapperWorld> m_world;80 OwnPtr<V8PerContextData> m_perContextData;81 RefPtr<SecurityOrigin> m_securityOrigin;82 };83 84 56 static PassOwnPtr<V8DOMWindowShell> create(Frame*, PassRefPtr<DOMWrapperWorld>); 85 57 … … 105 77 void clearForNavigation(); 106 78 void clearForClose(); 107 void clearIsolatedShell();108 79 109 80 void destroyGlobal(); … … 120 91 }; 121 92 122 inline static IsolatedContextData* enteredIsolatedContextData() 93 // Returns the isolated world associated with 94 // v8::Context::GetEntered(). Because worlds are isolated, the entire 95 // JavaScript call stack should be from the same isolated world. 96 // Returns 0 if the entered context is from the main world. 97 // 98 // FIXME: Consider edge cases with DOM mutation events that might 99 // violate this invariant. 100 // 101 // FIXME: This is poorly named after the deletion of isolated contexts. 102 static V8DOMWindowShell* getEntered() 123 103 { 124 if ( LIKELY(!DOMWrapperWorld::isolatedWorldsExist()))104 if (!DOMWrapperWorld::isolatedWorldsExist()) 125 105 return 0; 126 106 if (!v8::Context::InContext()) 127 107 return 0; 128 v8::Handle<v8::Object> innerGlobal = v8::Handle<v8::Object>::Cast(v8::Context::GetEntered()->Global()->GetPrototype()); 129 IsolatedContextData* isolatedContextData = toIsolatedContextData(innerGlobal); 130 if (LIKELY(!isolatedContextData)) 131 return 0; 132 return isolatedContextData; 108 return enteredIsolatedWorldContext(); 133 109 } 134 110 135 static IsolatedContextData* toIsolatedContextData(v8::Handle<v8::Object> innerGlobal); 136 111 void destroyIsolatedShell(); 137 112 private: 138 113 V8DOMWindowShell(Frame*, PassRefPtr<DOMWrapperWorld>); 139 114 140 void disposeContext( );115 void disposeContext(bool weak = false); 141 116 142 117 void setSecurityToken(); … … 152 127 bool installDOMWindow(); 153 128 129 static V8DOMWindowShell* enteredIsolatedWorldContext(); 130 154 131 Frame* m_frame; 155 132 RefPtr<DOMWrapperWorld> m_world; 156 133 157 134 OwnPtr<V8PerContextData> m_perContextData; 158 OwnPtr<IsolatedContextData> m_isolatedContextData;159 135 160 136 ScopedPersistent<v8::Context> m_context; -
trunk/Source/WebCore/bindings/v8/V8DOMWrapper.h
r129965 r129984 119 119 } 120 120 121 V8DOMWindowShell ::IsolatedContextData* isolatedData = V8DOMWindowShell::enteredIsolatedContextData();122 if (LIKELY(! isolatedData)) {121 V8DOMWindowShell* context = V8DOMWindowShell::getEntered(); 122 if (LIKELY(!context)) { 123 123 v8::Persistent<v8::Object>* wrapper = node->wrapper(); 124 124 if (!wrapper) … … 126 126 return *wrapper; 127 127 } 128 DOMDataStore* store = isolatedData->world()->domDataStore();128 DOMDataStore* store = context->world()->domDataStore(); 129 129 DOMNodeMapping& domNodeMap = node->isActiveNode() ? store->activeDomNodeMap() : store->domNodeMap(); 130 130 return domNodeMap.get(node); -
trunk/Source/WebCore/bindings/v8/WorldContextHandle.cpp
r129965 r129984 45 45 return; 46 46 47 if (!v8::Context::InContext()) { 47 #if ENABLE(WORKERS) 48 // FIXME We are duplicating a lot of effort here checking the context for the worker and for the isolated world. 49 if (v8::Context::InContext()) { 50 v8::Handle<v8::Context> context = v8::Context::GetCurrent(); 51 if (!context.IsEmpty()) { 52 if (UNLIKELY(!V8DOMWrapper::isWrapperOfType(toInnerGlobalObject(context), &V8DOMWindow::info))) { 53 m_worldToUse = UseWorkerWorld; 54 return; 55 } 56 } 57 } 58 #endif 59 60 V8DOMWindowShell* shell = V8DOMWindowShell::getEntered(); 61 if (LIKELY(!shell)) { 48 62 m_worldToUse = UseMainWorld; 49 63 return; 50 64 } 51 65 52 v8::Handle<v8::Context> context = v8::Context::GetCurrent(); 53 ASSERT(!context.IsEmpty()); 54 v8::Handle<v8::Object> innerGlobal = toInnerGlobalObject(context); 55 #if ENABLE(WORKERS) 56 if (UNLIKELY(!V8DOMWrapper::isWrapperOfType(innerGlobal, &V8DOMWindow::info))) { 57 m_worldToUse = UseWorkerWorld; 58 return; 59 } 60 #endif 61 62 V8DOMWindowShell::IsolatedContextData* data = V8DOMWindowShell::toIsolatedContextData(innerGlobal); 63 if (LIKELY(!data)) { 64 m_worldToUse = UseMainWorld; 65 return; 66 } 67 68 m_context = SharedPersistent<v8::Context>::create(context); 66 ASSERT(!shell->context().IsEmpty()); 67 m_context = SharedPersistent<v8::Context>::create(shell->context()); 69 68 } 70 69 -
trunk/Source/WebCore/bindings/v8/custom/V8DocumentCustom.cpp
r129971 r129984 109 109 if (wrapper.IsEmpty()) 110 110 return wrapper; 111 if (!V8DOMWindowShell:: enteredIsolatedContextData()) {111 if (!V8DOMWindowShell::getEntered()) { 112 112 if (Frame* frame = impl->frame()) 113 113 frame->script()->windowShell()->updateDocumentWrapper(wrapper); -
trunk/Source/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp
r129971 r129984 184 184 if (wrapper.IsEmpty()) 185 185 return wrapper; 186 if (!V8DOMWindowShell:: enteredIsolatedContextData()) {186 if (!V8DOMWindowShell::getEntered()) { 187 187 if (Frame* frame = impl->frame()) 188 188 frame->script()->windowShell()->updateDocumentWrapper(wrapper); -
trunk/Source/WebCore/bindings/v8/custom/V8SVGDocumentCustom.cpp
r129971 r129984 46 46 if (wrapper.IsEmpty()) 47 47 return wrapper; 48 if (!V8DOMWindowShell:: enteredIsolatedContextData()) {48 if (!V8DOMWindowShell::getEntered()) { 49 49 if (Frame* frame = impl->frame()) 50 50 frame->script()->windowShell()->updateDocumentWrapper(wrapper); -
trunk/Source/WebCore/bindings/v8/custom/V8XMLHttpRequestConstructor.cpp
r129965 r129984 56 56 57 57 RefPtr<SecurityOrigin> securityOrigin; 58 if (V8DOMWindowShell ::IsolatedContextData* isolatedContextData = V8DOMWindowShell::enteredIsolatedContextData())59 securityOrigin = isolated ContextData->securityOrigin();58 if (V8DOMWindowShell* isolatedWorldShell = V8DOMWindowShell::getEntered()) 59 securityOrigin = isolatedWorldShell->isolatedWorldSecurityOrigin(); 60 60 61 61 RefPtr<XMLHttpRequest> xmlHttpRequest = XMLHttpRequest::create(context, securityOrigin);
Note:
See TracChangeset
for help on using the changeset viewer.