Changeset 142159 in webkit
- Timestamp:
- Feb 7, 2013 11:48:39 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 35 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r142158 r142159 1 2013-02-07 Dan Carney <dcarney@google.com> 2 3 [v8] move persistent::new and ::dispose into same class 4 https://bugs.webkit.org/show_bug.cgi?id=109065 5 6 Reviewed by Adam Barth. 7 8 No new tests. No change in functionality. 9 10 * bindings/scripts/CodeGeneratorV8.pm: 11 (GenerateSingleConstructorCallback): 12 (GenerateEventConstructorCallback): 13 (GenerateNamedConstructorCallback): 14 (GenerateToV8Converters): 15 * bindings/scripts/test/V8/V8Float64Array.cpp: 16 (WebCore::V8Float64Array::createWrapper): 17 * bindings/scripts/test/V8/V8TestActiveDOMObject.cpp: 18 (WebCore::V8TestActiveDOMObject::createWrapper): 19 * bindings/scripts/test/V8/V8TestCustomNamedGetter.cpp: 20 (WebCore::V8TestCustomNamedGetter::createWrapper): 21 * bindings/scripts/test/V8/V8TestEventConstructor.cpp: 22 (WebCore::V8TestEventConstructor::constructorCallback): 23 (WebCore::V8TestEventConstructor::createWrapper): 24 * bindings/scripts/test/V8/V8TestEventTarget.cpp: 25 (WebCore::V8TestEventTarget::createWrapper): 26 * bindings/scripts/test/V8/V8TestException.cpp: 27 (WebCore::V8TestException::createWrapper): 28 * bindings/scripts/test/V8/V8TestInterface.cpp: 29 (WebCore::V8TestInterface::constructorCallback): 30 (WebCore::V8TestInterface::createWrapper): 31 * bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp: 32 (WebCore::V8TestMediaQueryListListener::createWrapper): 33 * bindings/scripts/test/V8/V8TestNamedConstructor.cpp: 34 (WebCore::V8TestNamedConstructorConstructorCallback): 35 (WebCore::V8TestNamedConstructor::createWrapper): 36 * bindings/scripts/test/V8/V8TestNode.cpp: 37 (WebCore::V8TestNode::constructorCallback): 38 (WebCore::V8TestNode::createWrapper): 39 * bindings/scripts/test/V8/V8TestObj.cpp: 40 (WebCore::V8TestObj::constructorCallback): 41 (WebCore::V8TestObj::createWrapper): 42 * bindings/scripts/test/V8/V8TestOverloadedConstructors.cpp: 43 (WebCore::V8TestOverloadedConstructors::constructor1Callback): 44 (WebCore::V8TestOverloadedConstructors::constructor2Callback): 45 (WebCore::V8TestOverloadedConstructors::constructor3Callback): 46 (WebCore::V8TestOverloadedConstructors::constructor4Callback): 47 (WebCore::V8TestOverloadedConstructors::createWrapper): 48 * bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp: 49 (WebCore::V8TestSerializedScriptValueInterface::constructorCallback): 50 (WebCore::V8TestSerializedScriptValueInterface::createWrapper): 51 * bindings/v8/DOMDataStore.cpp: 52 * bindings/v8/DOMDataStore.h: 53 (WebCore::DOMDataStore::setWrapper): 54 (DOMDataStore): 55 (WebCore::DOMDataStore::set): 56 (WebCore::DOMDataStore::setWrapperInObject): 57 * bindings/v8/DOMWrapperMap.h: 58 (WebCore::DOMWrapperMap::get): 59 (WebCore::DOMWrapperMap::set): 60 (WebCore::DOMWrapperMap::removeAndDispose): 61 (WebCore::DOMWrapperMap::defaultWeakCallback): 62 * bindings/v8/ScriptWrappable.h: 63 (WebCore::ScriptWrappable::wrapper): 64 (WebCore::ScriptWrappable::setWrapper): 65 (WebCore::ScriptWrappable::reportMemoryUsage): 66 (ScriptWrappable): 67 (WebCore::ScriptWrappable::disposeWrapper): 68 (WebCore::ScriptWrappable::weakCallback): 69 * bindings/v8/V8DOMWindowShell.cpp: 70 (WebCore::V8DOMWindowShell::installDOMWindow): 71 * bindings/v8/V8DOMWrapper.h: 72 (V8DOMWrapper): 73 (WebCore::V8DOMWrapper::associateObjectWithWrapper): 74 * bindings/v8/V8NPObject.cpp: 75 (WebCore::weakNPObjectCallback): 76 (WebCore::createV8ObjectForNPObject): 77 (WebCore::forgetV8ObjectForNPObject): 78 * bindings/v8/WorkerScriptController.cpp: 79 (WebCore::WorkerScriptController::initializeContextIfNeeded): 80 * bindings/v8/WrapperTypeInfo.h: 81 (WebCore): 82 (WrapperConfiguration): 83 (WebCore::WrapperConfiguration::configureWrapper): 84 (WebCore::buildWrapperConfiguration): 85 * bindings/v8/custom/V8ArrayBufferCustom.cpp: 86 (WebCore::V8ArrayBuffer::constructorCallbackCustom): 87 * bindings/v8/custom/V8ArrayBufferViewCustom.h: 88 (WebCore::wrapArrayBufferView): 89 (WebCore::constructWebGLArray): 90 * bindings/v8/custom/V8AudioContextCustom.cpp: 91 (WebCore::V8AudioContext::constructorCallbackCustom): 92 * bindings/v8/custom/V8DOMFormDataCustom.cpp: 93 (WebCore::V8DOMFormData::constructorCallbackCustom): 94 * bindings/v8/custom/V8DataViewCustom.cpp: 95 (WebCore::V8DataView::constructorCallbackCustom): 96 * bindings/v8/custom/V8HTMLImageElementConstructor.cpp: 97 (WebCore::v8HTMLImageElementConstructorCallback): 98 * bindings/v8/custom/V8IntentCustom.cpp: 99 (WebCore::V8Intent::constructorCallbackCustom): 100 * bindings/v8/custom/V8MessageChannelCustom.cpp: 101 (WebCore::V8MessageChannel::constructorCallbackCustom): 102 * bindings/v8/custom/V8MutationObserverCustom.cpp: 103 (WebCore::V8MutationObserver::constructorCallbackCustom): 104 * bindings/v8/custom/V8WebKitPointCustom.cpp: 105 (WebCore::V8WebKitPoint::constructorCallbackCustom): 106 * bindings/v8/custom/V8XMLHttpRequestCustom.cpp: 107 (WebCore::V8XMLHttpRequest::constructorCallbackCustom): 108 1 109 2013-02-07 Zan Dobersek <zdobersek@igalia.com> 2 110 -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm
r142061 r142159 1965 1965 push(@implContent, <<END); 1966 1966 1967 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &info, wrapper, args.GetIsolate() );1967 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); 1968 1968 return wrapper; 1969 1969 END … … 2040 2040 2041 2041 v8::Handle<v8::Object> wrapper = args.Holder(); 2042 V8DOMWrapper::associateObjectWithWrapper(event.release(), &info, wrapper, args.GetIsolate() );2042 V8DOMWrapper::associateObjectWithWrapper(event.release(), &info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); 2043 2043 return wrapper; 2044 2044 } … … 2181 2181 push(@implContent, <<END); 2182 2182 2183 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &${v8InterfaceName}Constructor::info, wrapper, args.GetIsolate() );2183 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &${v8InterfaceName}Constructor::info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); 2184 2184 return wrapper; 2185 2185 END … … 3537 3537 3538 3538 installPerContextProperties(wrapper, impl.get(), isolate); 3539 v8::Persistent<v8::Object> wrapperHandle = V8DOMWrapper::associateObjectWithWrapper(impl, &info, wrapper, isolate); 3540 if (!hasDependentLifetime) 3541 wrapperHandle.MarkIndependent(); 3539 V8DOMWrapper::associateObjectWithWrapper(impl, &info, wrapper, isolate, hasDependentLifetime ? WrapperConfiguration::Dependent : WrapperConfiguration::Independent); 3542 3540 return wrapper; 3543 3541 } -
trunk/Source/WebCore/bindings/scripts/test/V8/V8Float64Array.cpp
r142061 r142159 181 181 182 182 installPerContextProperties(wrapper, impl.get(), isolate); 183 v8::Persistent<v8::Object> wrapperHandle = V8DOMWrapper::associateObjectWithWrapper(impl, &info, wrapper, isolate); 184 if (!hasDependentLifetime) 185 wrapperHandle.MarkIndependent(); 183 V8DOMWrapper::associateObjectWithWrapper(impl, &info, wrapper, isolate, hasDependentLifetime ? WrapperConfiguration::Dependent : WrapperConfiguration::Independent); 186 184 return wrapper; 187 185 } -
trunk/Source/WebCore/bindings/scripts/test/V8/V8TestActiveDOMObject.cpp
r142061 r142159 208 208 209 209 installPerContextProperties(wrapper, impl.get(), isolate); 210 v8::Persistent<v8::Object> wrapperHandle = V8DOMWrapper::associateObjectWithWrapper(impl, &info, wrapper, isolate); 211 if (!hasDependentLifetime) 212 wrapperHandle.MarkIndependent(); 210 V8DOMWrapper::associateObjectWithWrapper(impl, &info, wrapper, isolate, hasDependentLifetime ? WrapperConfiguration::Dependent : WrapperConfiguration::Independent); 213 211 return wrapper; 214 212 } -
trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCustomNamedGetter.cpp
r142061 r142159 146 146 147 147 installPerContextProperties(wrapper, impl.get(), isolate); 148 v8::Persistent<v8::Object> wrapperHandle = V8DOMWrapper::associateObjectWithWrapper(impl, &info, wrapper, isolate); 149 if (!hasDependentLifetime) 150 wrapperHandle.MarkIndependent(); 148 V8DOMWrapper::associateObjectWithWrapper(impl, &info, wrapper, isolate, hasDependentLifetime ? WrapperConfiguration::Dependent : WrapperConfiguration::Independent); 151 149 return wrapper; 152 150 } -
trunk/Source/WebCore/bindings/scripts/test/V8/V8TestEventConstructor.cpp
r142061 r142159 104 104 105 105 v8::Handle<v8::Object> wrapper = args.Holder(); 106 V8DOMWrapper::associateObjectWithWrapper(event.release(), &info, wrapper, args.GetIsolate() );106 V8DOMWrapper::associateObjectWithWrapper(event.release(), &info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); 107 107 return wrapper; 108 108 } … … 178 178 179 179 installPerContextProperties(wrapper, impl.get(), isolate); 180 v8::Persistent<v8::Object> wrapperHandle = V8DOMWrapper::associateObjectWithWrapper(impl, &info, wrapper, isolate); 181 if (!hasDependentLifetime) 182 wrapperHandle.MarkIndependent(); 180 V8DOMWrapper::associateObjectWithWrapper(impl, &info, wrapper, isolate, hasDependentLifetime ? WrapperConfiguration::Dependent : WrapperConfiguration::Independent); 183 181 return wrapper; 184 182 } -
trunk/Source/WebCore/bindings/scripts/test/V8/V8TestEventTarget.cpp
r142061 r142159 212 212 213 213 installPerContextProperties(wrapper, impl.get(), isolate); 214 v8::Persistent<v8::Object> wrapperHandle = V8DOMWrapper::associateObjectWithWrapper(impl, &info, wrapper, isolate); 215 if (!hasDependentLifetime) 216 wrapperHandle.MarkIndependent(); 214 V8DOMWrapper::associateObjectWithWrapper(impl, &info, wrapper, isolate, hasDependentLifetime ? WrapperConfiguration::Dependent : WrapperConfiguration::Independent); 217 215 return wrapper; 218 216 } -
trunk/Source/WebCore/bindings/scripts/test/V8/V8TestException.cpp
r142061 r142159 137 137 138 138 installPerContextProperties(wrapper, impl.get(), isolate); 139 v8::Persistent<v8::Object> wrapperHandle = V8DOMWrapper::associateObjectWithWrapper(impl, &info, wrapper, isolate); 140 if (!hasDependentLifetime) 141 wrapperHandle.MarkIndependent(); 139 V8DOMWrapper::associateObjectWithWrapper(impl, &info, wrapper, isolate, hasDependentLifetime ? WrapperConfiguration::Dependent : WrapperConfiguration::Independent); 142 140 return wrapper; 143 141 } -
trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp
r142061 r142159 274 274 goto fail; 275 275 276 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &info, wrapper, args.GetIsolate() );276 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); 277 277 return wrapper; 278 278 fail: … … 367 367 368 368 installPerContextProperties(wrapper, impl.get(), isolate); 369 v8::Persistent<v8::Object> wrapperHandle = V8DOMWrapper::associateObjectWithWrapper(impl, &info, wrapper, isolate); 370 if (!hasDependentLifetime) 371 wrapperHandle.MarkIndependent(); 369 V8DOMWrapper::associateObjectWithWrapper(impl, &info, wrapper, isolate, hasDependentLifetime ? WrapperConfiguration::Dependent : WrapperConfiguration::Independent); 372 370 return wrapper; 373 371 } -
trunk/Source/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp
r142061 r142159 146 146 147 147 installPerContextProperties(wrapper, impl.get(), isolate); 148 v8::Persistent<v8::Object> wrapperHandle = V8DOMWrapper::associateObjectWithWrapper(impl, &info, wrapper, isolate); 149 if (!hasDependentLifetime) 150 wrapperHandle.MarkIndependent(); 148 V8DOMWrapper::associateObjectWithWrapper(impl, &info, wrapper, isolate, hasDependentLifetime ? WrapperConfiguration::Dependent : WrapperConfiguration::Independent); 151 149 return wrapper; 152 150 } -
trunk/Source/WebCore/bindings/scripts/test/V8/V8TestNamedConstructor.cpp
r142061 r142159 93 93 goto fail; 94 94 95 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &V8TestNamedConstructorConstructor::info, wrapper, args.GetIsolate() );95 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &V8TestNamedConstructorConstructor::info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); 96 96 return wrapper; 97 97 fail: … … 185 185 186 186 installPerContextProperties(wrapper, impl.get(), isolate); 187 v8::Persistent<v8::Object> wrapperHandle = V8DOMWrapper::associateObjectWithWrapper(impl, &info, wrapper, isolate); 188 if (!hasDependentLifetime) 189 wrapperHandle.MarkIndependent(); 187 V8DOMWrapper::associateObjectWithWrapper(impl, &info, wrapper, isolate, hasDependentLifetime ? WrapperConfiguration::Dependent : WrapperConfiguration::Independent); 190 188 return wrapper; 191 189 } -
trunk/Source/WebCore/bindings/scripts/test/V8/V8TestNode.cpp
r142061 r142159 76 76 v8::Handle<v8::Object> wrapper = args.Holder(); 77 77 78 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &info, wrapper, args.GetIsolate() );78 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); 79 79 return wrapper; 80 80 } … … 150 150 151 151 installPerContextProperties(wrapper, impl.get(), isolate); 152 v8::Persistent<v8::Object> wrapperHandle = V8DOMWrapper::associateObjectWithWrapper(impl, &info, wrapper, isolate); 153 if (!hasDependentLifetime) 154 wrapperHandle.MarkIndependent(); 152 V8DOMWrapper::associateObjectWithWrapper(impl, &info, wrapper, isolate, hasDependentLifetime ? WrapperConfiguration::Dependent : WrapperConfiguration::Independent); 155 153 return wrapper; 156 154 } -
trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp
r142061 r142159 2091 2091 v8::Handle<v8::Object> wrapper = args.Holder(); 2092 2092 2093 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &info, wrapper, args.GetIsolate() );2093 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); 2094 2094 return wrapper; 2095 2095 } … … 2292 2292 2293 2293 installPerContextProperties(wrapper, impl.get(), isolate); 2294 v8::Persistent<v8::Object> wrapperHandle = V8DOMWrapper::associateObjectWithWrapper(impl, &info, wrapper, isolate); 2295 if (!hasDependentLifetime) 2296 wrapperHandle.MarkIndependent(); 2294 V8DOMWrapper::associateObjectWithWrapper(impl, &info, wrapper, isolate, hasDependentLifetime ? WrapperConfiguration::Dependent : WrapperConfiguration::Independent); 2297 2295 return wrapper; 2298 2296 } -
trunk/Source/WebCore/bindings/scripts/test/V8/V8TestOverloadedConstructors.cpp
r142061 r142159 77 77 v8::Handle<v8::Object> wrapper = args.Holder(); 78 78 79 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &info, wrapper, args.GetIsolate() );79 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); 80 80 return wrapper; 81 81 } … … 89 89 v8::Handle<v8::Object> wrapper = args.Holder(); 90 90 91 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &info, wrapper, args.GetIsolate() );91 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); 92 92 return wrapper; 93 93 } … … 101 101 v8::Handle<v8::Object> wrapper = args.Holder(); 102 102 103 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &info, wrapper, args.GetIsolate() );103 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); 104 104 return wrapper; 105 105 } … … 113 113 v8::Handle<v8::Object> wrapper = args.Holder(); 114 114 115 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &info, wrapper, args.GetIsolate() );115 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); 116 116 return wrapper; 117 117 } … … 201 201 202 202 installPerContextProperties(wrapper, impl.get(), isolate); 203 v8::Persistent<v8::Object> wrapperHandle = V8DOMWrapper::associateObjectWithWrapper(impl, &info, wrapper, isolate); 204 if (!hasDependentLifetime) 205 wrapperHandle.MarkIndependent(); 203 V8DOMWrapper::associateObjectWithWrapper(impl, &info, wrapper, isolate, hasDependentLifetime ? WrapperConfiguration::Dependent : WrapperConfiguration::Independent); 206 204 return wrapper; 207 205 } -
trunk/Source/WebCore/bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp
r142061 r142159 247 247 v8::Handle<v8::Object> wrapper = args.Holder(); 248 248 249 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &info, wrapper, args.GetIsolate() );249 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); 250 250 return wrapper; 251 251 } … … 319 319 320 320 installPerContextProperties(wrapper, impl.get(), isolate); 321 v8::Persistent<v8::Object> wrapperHandle = V8DOMWrapper::associateObjectWithWrapper(impl, &info, wrapper, isolate); 322 if (!hasDependentLifetime) 323 wrapperHandle.MarkIndependent(); 321 V8DOMWrapper::associateObjectWithWrapper(impl, &info, wrapper, isolate, hasDependentLifetime ? WrapperConfiguration::Dependent : WrapperConfiguration::Independent); 324 322 return wrapper; 325 323 } -
trunk/Source/WebCore/bindings/v8/DOMDataStore.cpp
r141771 r142159 81 81 } 82 82 83 void DOMDataStore::weakCallback(v8::Isolate* isolate, v8::Persistent<v8::Value> value, void* context)84 {85 ScriptWrappable* key = static_cast<ScriptWrappable*>(context);86 ASSERT(value->IsObject());87 v8::Persistent<v8::Object> wrapper = v8::Persistent<v8::Object>::Cast(value);88 ASSERT(key->wrapper() == wrapper);89 // Note: |object| might not be equal to |key|, e.g., if ScriptWrappable isn't a left-most base class.90 void* object = toNative(wrapper);91 WrapperTypeInfo* info = toWrapperTypeInfo(wrapper);92 ASSERT(info->derefObjectFunction);93 94 key->clearWrapper();95 value.Dispose();96 value.Clear();97 // FIXME: I noticed that 50%~ of minor GC cycle times can be consumed98 // inside key->deref(), which causes Node destructions. We should99 // make Node destructions incremental.100 info->derefObject(object);101 }102 103 83 } // namespace WebCore -
trunk/Source/WebCore/bindings/v8/DOMDataStore.h
r142103 r142159 90 90 91 91 template<typename T> 92 static void setWrapper(T* object, v8:: Persistent<v8::Object> wrapper, v8::Isolate* isolate)92 static void setWrapper(T* object, v8::Handle<v8::Object> wrapper, v8::Isolate* isolate, const WrapperConfiguration& configuration) 93 93 { 94 94 if (mainWorldWrapperIsStoredInObject(object) && isMainWorldObject(object)) { 95 95 if (LIKELY(!DOMWrapperWorld::isolatedWorldsExist())) { 96 setWrapperInObject(object, wrapper, isolate );96 setWrapperInObject(object, wrapper, isolate, configuration); 97 97 return; 98 98 } 99 99 } 100 return current(isolate)->set(object, wrapper, isolate );100 return current(isolate)->set(object, wrapper, isolate, configuration); 101 101 } 102 102 … … 109 109 } 110 110 111 void reportMemoryUsage(MemoryObjectInfo*) const; 112 113 private: 111 114 template<typename T> 112 inline void set(T* object, v8:: Persistent<v8::Object> wrapper, v8::Isolate* isolate)115 inline void set(T* object, v8::Handle<v8::Object> wrapper, v8::Isolate* isolate, const WrapperConfiguration& configuration) 113 116 { 114 117 ASSERT(!!object); 115 118 ASSERT(!wrapper.IsEmpty()); 116 119 if (mainWorldWrapperIsStoredInObject(object) && m_type == MainWorld) { 117 setWrapperInObject(object, wrapper, isolate );120 setWrapperInObject(object, wrapper, isolate, configuration); 118 121 return; 119 122 } 120 m_wrapperMap.set(object, wrapper );123 m_wrapperMap.set(object, wrapper, configuration); 121 124 } 122 125 123 void reportMemoryUsage(MemoryObjectInfo*) const;124 125 private:126 126 static DOMDataStore* mainWorldStore(); 127 127 … … 155 155 } 156 156 157 static void setWrapperInObject(void*, v8:: Persistent<v8::Object>, v8::Isolate*)157 static void setWrapperInObject(void*, v8::Handle<v8::Object>, v8::Isolate*, const WrapperConfiguration&) 158 158 { 159 159 ASSERT_NOT_REACHED(); 160 160 } 161 static void setWrapperInObject(ScriptWrappable* object, v8:: Persistent<v8::Object> wrapper, v8::Isolate* isolate)161 static void setWrapperInObject(ScriptWrappable* object, v8::Handle<v8::Object> wrapper, v8::Isolate* isolate, const WrapperConfiguration& configuration) 162 162 { 163 ASSERT(object->wrapper().IsEmpty()); 164 object->setWrapper(wrapper); 165 wrapper.MakeWeak(isolate, object, weakCallback); 163 object->setWrapper(wrapper, isolate, configuration); 166 164 } 167 static void setWrapperInObject(Node* object, v8::Persistent<v8::Object> wrapper, v8::Isolate* isolate )165 static void setWrapperInObject(Node* object, v8::Persistent<v8::Object> wrapper, v8::Isolate* isolate, const WrapperConfiguration& configuration) 168 166 { 169 ASSERT(object->wrapper().IsEmpty()); 170 object->setWrapper(wrapper); 167 object->setWrapper(wrapper, isolate, configuration); 171 168 V8GCController::didCreateWrapperForNode(object); 172 wrapper.MakeWeak(isolate, static_cast<ScriptWrappable*>(object), weakCallback);173 169 } 174 175 static void weakCallback(v8::Isolate*, v8::Persistent<v8::Value>, void* context);176 170 177 171 Type m_type; -
trunk/Source/WebCore/bindings/v8/DOMWrapperMap.h
r141771 r142159 51 51 } 52 52 53 v8:: Persistent<v8::Object> get(KeyType* key)53 v8::Handle<v8::Object> get(KeyType* key) 54 54 { 55 55 return m_map.get(key); 56 56 } 57 57 58 void set(KeyType* key, v8:: Persistent<v8::Object> wrapper)58 void set(KeyType* key, v8::Handle<v8::Object> wrapper, const WrapperConfiguration& configuration) 59 59 { 60 60 ASSERT(!m_map.contains(key)); 61 61 ASSERT(static_cast<KeyType*>(toNative(wrapper)) == key); 62 wrapper.MakeWeak(m_isolate, this, m_callback); 63 m_map.set(key, wrapper); 62 v8::Persistent<v8::Object> persistent = v8::Persistent<v8::Object>::New(m_isolate, wrapper); 63 configuration.configureWrapper(persistent, m_isolate); 64 persistent.MakeWeak(m_isolate, this, m_callback); 65 m_map.set(key, persistent); 64 66 } 65 67 … … 82 84 } 83 85 84 void remove (KeyType* key, v8::Persistent<v8::Object> wrapper)86 void removeAndDispose(KeyType* key, v8::Handle<v8::Object> value, v8::Isolate* isolate) 85 87 { 88 v8::Persistent<v8::Object> wrapper(*value); 86 89 typename MapType::iterator it = m_map.find(key); 87 90 ASSERT(it != m_map.end()); 88 91 ASSERT(it->value == wrapper); 89 92 m_map.remove(it); 93 wrapper.Dispose(isolate); 94 value.Clear(); 90 95 } 91 96 … … 99 104 ASSERT(type->derefObjectFunction); 100 105 KeyType* key = static_cast<KeyType*>(toNative(wrapper)); 101 102 map->remove(key, wrapper); 103 wrapper.Dispose(); 104 wrapper.Clear(); 106 map->removeAndDispose(key, wrapper, isolate); 105 107 type->derefObject(key); 106 108 } -
trunk/Source/WebCore/bindings/v8/ScriptWrappable.h
r140575 r142159 33 33 34 34 #include "WebCoreMemoryInstrumentation.h" 35 #include "WrapperTypeInfo.h" 35 36 #include <v8.h> 36 37 … … 41 42 ScriptWrappable() { } 42 43 43 v8:: Persistent<v8::Object> wrapper() const44 v8::Handle<v8::Object> wrapper() const 44 45 { 45 return v8:: Persistent<v8::Object>(maskOrUnmaskPointer(*m_maskedWrapper));46 return v8::Handle<v8::Object>(maskOrUnmaskPointer(*m_maskedWrapper)); 46 47 } 47 48 48 void setWrapper(v8:: Persistent<v8::Object> wrapper)49 void setWrapper(v8::Handle<v8::Object> wrapper, v8::Isolate* isolate, const WrapperConfiguration& configuration) 49 50 { 50 m_maskedWrapper = maskOrUnmaskPointer(*wrapper); 51 } 52 53 void clearWrapper() 54 { 55 ASSERT(!m_maskedWrapper.IsEmpty()); 56 m_maskedWrapper.Clear(); 57 } 58 59 void disposeWrapper() 60 { 61 ASSERT(!m_maskedWrapper.IsEmpty()); 62 m_maskedWrapper = wrapper(); 63 m_maskedWrapper.Dispose(); 64 m_maskedWrapper.Clear(); 51 ASSERT(m_maskedWrapper.IsEmpty()); 52 v8::Persistent<v8::Object> persistent = v8::Persistent<v8::Object>::New(wrapper); 53 configuration.configureWrapper(persistent, isolate); 54 persistent.MakeWeak(isolate, this, weakCallback); 55 m_maskedWrapper = maskOrUnmaskPointer(*persistent); 65 56 } 66 57 … … 72 63 73 64 private: 65 inline void disposeWrapper(v8::Persistent<v8::Value> value) 66 { 67 ASSERT(!m_maskedWrapper.IsEmpty()); 68 ASSERT(*value == maskOrUnmaskPointer(*m_maskedWrapper)); 69 value.Dispose(); 70 m_maskedWrapper.Clear(); 71 } 72 74 73 v8::Persistent<v8::Object> m_maskedWrapper; 75 74 … … 80 79 return reinterpret_cast<v8::Object*>((objectPointer ^ randomMask) & (!objectPointer - 1)); // Preserve null without branching. 81 80 } 81 82 static void weakCallback(v8::Isolate* isolate, v8::Persistent<v8::Value> value, void* context) 83 { 84 ScriptWrappable* key = static_cast<ScriptWrappable*>(context); 85 ASSERT(value->IsObject()); 86 v8::Persistent<v8::Object> wrapper = v8::Persistent<v8::Object>::Cast(value); 87 ASSERT(key->wrapper() == wrapper); 88 key->disposeWrapper(value); 89 90 // Note: |object| might not be equal to |key|, e.g., if ScriptWrappable isn't a left-most base class. 91 void* object = toNative(wrapper); 92 WrapperTypeInfo* info = toWrapperTypeInfo(wrapper); 93 ASSERT(info->derefObjectFunction); 94 95 // FIXME: I noticed that 50%~ of minor GC cycle times can be consumed 96 // inside key->deref(), which causes Node destructions. We should 97 // make Node destructions incremental. 98 info->derefObject(object); 99 } 82 100 }; 83 101 -
trunk/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp
r142103 r142159 336 336 V8DOMWrapper::setNativeInfo(innerGlobalObject, &V8DOMWindow::info, window); 337 337 innerGlobalObject->SetPrototype(windowWrapper); 338 V8DOMWrapper::associateObjectWithWrapper(PassRefPtr<DOMWindow>(window), &V8DOMWindow::info, windowWrapper, m_isolate );338 V8DOMWrapper::associateObjectWithWrapper(PassRefPtr<DOMWindow>(window), &V8DOMWindow::info, windowWrapper, m_isolate, WrapperConfiguration::Dependent); 339 339 return true; 340 340 } -
trunk/Source/WebCore/bindings/v8/V8DOMWrapper.h
r141977 r142159 57 57 58 58 template<typename T> 59 static inline v8:: Persistent<v8::Object> associateObjectWithWrapper(PassRefPtr<T>, WrapperTypeInfo*, v8::Handle<v8::Object>, v8::Isolate*);59 static inline v8::Handle<v8::Object> associateObjectWithWrapper(PassRefPtr<T>, WrapperTypeInfo*, v8::Handle<v8::Object>, v8::Isolate*, WrapperConfiguration::Lifetime); 60 60 static inline void setNativeInfo(v8::Handle<v8::Object>, WrapperTypeInfo*, void*); 61 61 static inline void clearNativeInfo(v8::Handle<v8::Object>, WrapperTypeInfo*); 62 static inline void setWrapperClass(void*, v8::Persistent<v8::Object>);63 static inline void setWrapperClass(Node*, v8::Persistent<v8::Object>);64 62 65 63 static bool isDOMWrapper(v8::Handle<v8::Value>); … … 69 67 static void setNamedHiddenReference(v8::Handle<v8::Object> parent, const char* name, v8::Handle<v8::Value> child); 70 68 }; 71 72 inline void V8DOMWrapper::setWrapperClass(void*, v8::Persistent<v8::Object> wrapper)73 {74 wrapper.SetWrapperClassId(v8DOMObjectClassId);75 }76 77 inline void V8DOMWrapper::setWrapperClass(Node*, v8::Persistent<v8::Object> wrapper)78 {79 wrapper.SetWrapperClassId(v8DOMNodeClassId);80 }81 69 82 70 inline void V8DOMWrapper::setNativeInfo(v8::Handle<v8::Object> wrapper, WrapperTypeInfo* type, void* object) … … 98 86 99 87 template<typename T> 100 inline v8:: Persistent<v8::Object> V8DOMWrapper::associateObjectWithWrapper(PassRefPtr<T> object, WrapperTypeInfo* type, v8::Handle<v8::Object> wrapper, v8::Isolate* isolate)88 inline v8::Handle<v8::Object> V8DOMWrapper::associateObjectWithWrapper(PassRefPtr<T> object, WrapperTypeInfo* type, v8::Handle<v8::Object> wrapper, v8::Isolate* isolate, WrapperConfiguration::Lifetime lifetime) 101 89 { 102 90 setNativeInfo(wrapper, type, object.get()); 103 v8::Persistent<v8::Object> wrapperHandle = v8::Persistent<v8::Object>::New(wrapper); 104 ASSERT(maybeDOMWrapper(wrapperHandle)); 105 setWrapperClass(object.get(), wrapperHandle); 106 DOMDataStore::setWrapper(object.leakRef(), wrapperHandle, isolate); 107 return wrapperHandle; 91 ASSERT(maybeDOMWrapper(wrapper)); 92 WrapperConfiguration configuration = buildWrapperConfiguration(object.get(), lifetime); 93 DOMDataStore::setWrapper(object.leakRef(), wrapper, isolate, configuration); 94 return wrapper; 108 95 } 109 96 -
trunk/Source/WebCore/bindings/v8/V8NPObject.cpp
r141946 r142159 403 403 // Must remove from our map before calling _NPN_ReleaseObject(). _NPN_ReleaseObject can 404 404 // call forgetV8ObjectForNPObject, which uses the table as well. 405 staticNPObjectMap().remove(npObject, wrapper); 406 wrapper.Dispose(); 407 wrapper.Clear(); 405 staticNPObjectMap().removeAndDispose(npObject, wrapper, isolate); 408 406 409 407 if (_NPN_IsAlive(npObject)) … … 449 447 450 448 V8DOMWrapper::setNativeInfo(value, npObjectTypeInfo(), object); 451 v8::Persistent<v8::Object> wrapperHandle = v8::Persistent<v8::Object>::New(value);452 V8DOMWrapper::setWrapperClass(object, wrapperHandle);453 449 454 450 // KJS retains the object as part of its wrapper (see Bindings::CInstance). … … 456 452 _NPN_RegisterObject(object, root); 457 453 458 staticNPObjectMap().set(object, wrapperHandle); 459 ASSERT(V8DOMWrapper::maybeDOMWrapper(wrapperHandle)); 454 WrapperConfiguration configuration = buildWrapperConfiguration(object, WrapperConfiguration::Dependent); 455 staticNPObjectMap().set(object, value, configuration); 456 ASSERT(V8DOMWrapper::maybeDOMWrapper(value)); 460 457 return value; 461 458 } … … 463 460 void forgetV8ObjectForNPObject(NPObject* object) 464 461 { 465 v8:: Persistent<v8::Object> wrapper = staticNPObjectMap().get(object);462 v8::Handle<v8::Object> wrapper = staticNPObjectMap().get(object); 466 463 if (!wrapper.IsEmpty()) { 467 464 v8::HandleScope scope; 468 465 V8DOMWrapper::clearNativeInfo(wrapper, npObjectTypeInfo()); 469 staticNPObjectMap().remove(object, wrapper); 470 wrapper.Dispose(); 471 wrapper.Clear(); 466 staticNPObjectMap().removeAndDispose(object, wrapper, v8::Isolate::GetCurrent()); 472 467 _NPN_ReleaseObject(object); 473 468 } -
trunk/Source/WebCore/bindings/v8/WorkerScriptController.cpp
r141946 r142159 128 128 } 129 129 130 V8DOMWrapper::associateObjectWithWrapper(PassRefPtr<WorkerContext>(m_workerContext), contextType, jsWorkerContext, m_isolate );130 V8DOMWrapper::associateObjectWithWrapper(PassRefPtr<WorkerContext>(m_workerContext), contextType, jsWorkerContext, m_isolate, WrapperConfiguration::Dependent); 131 131 132 132 // Insert the object instance as the prototype of the shadow object. -
trunk/Source/WebCore/bindings/v8/WrapperTypeInfo.h
r142061 r142159 39 39 class DOMDataStore; 40 40 class EventTarget; 41 class Node; 41 42 42 43 static const int v8DOMWrapperTypeIndex = 0; … … 142 143 } 143 144 145 struct WrapperConfiguration { 146 147 enum Lifetime { 148 Dependent, Independent 149 }; 150 151 void configureWrapper(v8::Persistent<v8::Object> wrapper, v8::Isolate* isolate) const 152 { 153 wrapper.SetWrapperClassId(classId); 154 if (lifetime == Independent) 155 wrapper.MarkIndependent(isolate); 156 } 157 158 const uint16_t classId; 159 const Lifetime lifetime; 160 }; 161 162 inline WrapperConfiguration buildWrapperConfiguration(void*, WrapperConfiguration::Lifetime lifetime) 163 { 164 WrapperConfiguration configuration = {v8DOMObjectClassId, lifetime}; 165 return configuration; 166 } 167 168 inline WrapperConfiguration buildWrapperConfiguration(Node*, WrapperConfiguration::Lifetime lifetime) 169 { 170 WrapperConfiguration configuration = {v8DOMNodeClassId, lifetime}; 171 return configuration; 172 } 144 173 } 145 174 -
trunk/Source/WebCore/bindings/v8/custom/V8ArrayBufferCustom.cpp
r139601 r142159 77 77 // Transform the holder into a wrapper object for the array. 78 78 v8::Handle<v8::Object> wrapper = args.Holder(); 79 V8DOMWrapper::associateObjectWithWrapper(buffer.release(), &info, wrapper, args.GetIsolate() );79 V8DOMWrapper::associateObjectWithWrapper(buffer.release(), &info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); 80 80 return wrapper; 81 81 } -
trunk/Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h
r141718 r142159 56 56 args.Holder()->SetIndexedPropertiesToExternalArrayData(array.get()->baseAddress(), arrayType, array.get()->length()); 57 57 v8::Handle<v8::Object> wrapper = args.Holder(); 58 v8::Persistent<v8::Object> wrapperHandle = V8DOMWrapper::associateObjectWithWrapper(array.release(), type, wrapper, args.GetIsolate()); 59 wrapperHandle.MarkIndependent(); 58 V8DOMWrapper::associateObjectWithWrapper(array.release(), type, wrapper, args.GetIsolate(), WrapperConfiguration::Independent); 60 59 return wrapper; 61 60 } … … 226 225 227 226 v8::Handle<v8::Object> wrapper = args.Holder(); 228 v8::Persistent<v8::Object> wrapperHandle = V8DOMWrapper::associateObjectWithWrapper(array.release(), type, wrapper, args.GetIsolate()); 229 wrapperHandle.MarkIndependent(); 227 V8DOMWrapper::associateObjectWithWrapper(array.release(), type, wrapper, args.GetIsolate(), WrapperConfiguration::Independent); 230 228 return wrapper; 231 229 } -
trunk/Source/WebCore/bindings/v8/custom/V8AudioContextCustom.cpp
r139601 r142159 74 74 // Transform the holder into a wrapper object for the audio context. 75 75 v8::Handle<v8::Object> wrapper = args.Holder(); 76 V8DOMWrapper::associateObjectWithWrapper(audioContext.release(), &info, wrapper, args.GetIsolate() );76 V8DOMWrapper::associateObjectWithWrapper(audioContext.release(), &info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); 77 77 78 78 return wrapper; -
trunk/Source/WebCore/bindings/v8/custom/V8DOMFormDataCustom.cpp
r141718 r142159 48 48 49 49 v8::Handle<v8::Object> wrapper = args.Holder(); 50 V8DOMWrapper::associateObjectWithWrapper(domFormData.release(), &info, wrapper, args.GetIsolate() );50 V8DOMWrapper::associateObjectWithWrapper(domFormData.release(), &info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); 51 51 return wrapper; 52 52 } -
trunk/Source/WebCore/bindings/v8/custom/V8DataViewCustom.cpp
r141718 r142159 40 40 RefPtr<DataView> dataView = DataView::create(0); 41 41 v8::Handle<v8::Object> wrapper = args.Holder(); 42 V8DOMWrapper::associateObjectWithWrapper(dataView.release(), &info, wrapper, args.GetIsolate() );42 V8DOMWrapper::associateObjectWithWrapper(dataView.release(), &info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); 43 43 return wrapper; 44 44 } -
trunk/Source/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp
r140729 r142159 78 78 RefPtr<HTMLImageElement> image = HTMLImageElement::createForJSConstructor(document, optionalWidth, optionalHeight); 79 79 v8::Handle<v8::Object> wrapper = args.Holder(); 80 V8DOMWrapper::associateObjectWithWrapper(image.release(), &V8HTMLImageElementConstructor::info, wrapper, args.GetIsolate() );80 V8DOMWrapper::associateObjectWithWrapper(image.release(), &V8HTMLImageElementConstructor::info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); 81 81 return wrapper; 82 82 } -
trunk/Source/WebCore/bindings/v8/custom/V8IntentCustom.cpp
r141614 r142159 58 58 59 59 v8::Handle<v8::Object> wrapper = args.Holder(); 60 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &info, wrapper, args.GetIsolate() );60 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); 61 61 return wrapper; 62 62 } … … 81 81 82 82 v8::Handle<v8::Object> wrapper = args.Holder(); 83 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &info, wrapper, args.GetIsolate() );83 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); 84 84 return wrapper; 85 85 } -
trunk/Source/WebCore/bindings/v8/custom/V8MessageChannelCustom.cpp
r139601 r142159 58 58 V8DOMWrapper::setNamedHiddenReference(wrapper, "port2", toV8(obj->port2(), args.Holder(), args.GetIsolate())); 59 59 60 V8DOMWrapper::associateObjectWithWrapper(obj.release(), &info, wrapper, args.GetIsolate() );60 V8DOMWrapper::associateObjectWithWrapper(obj.release(), &info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); 61 61 return wrapper; 62 62 } -
trunk/Source/WebCore/bindings/v8/custom/V8MutationObserverCustom.cpp
r141771 r142159 57 57 RefPtr<MutationObserver> observer = MutationObserver::create(callback.release()); 58 58 59 V8DOMWrapper::associateObjectWithWrapper(observer.release(), &info, wrapper, args.GetIsolate() );59 V8DOMWrapper::associateObjectWithWrapper(observer.release(), &info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); 60 60 return wrapper; 61 61 } -
trunk/Source/WebCore/bindings/v8/custom/V8WebKitPointCustom.cpp
r139601 r142159 58 58 RefPtr<WebKitPoint> point = WebKitPoint::create(x, y); 59 59 v8::Handle<v8::Object> wrapper = args.Holder(); 60 V8DOMWrapper::associateObjectWithWrapper(point.release(), &info, wrapper, args.GetIsolate() );60 V8DOMWrapper::associateObjectWithWrapper(point.release(), &info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); 61 61 return wrapper; 62 62 } -
trunk/Source/WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp
r141763 r142159 62 62 63 63 v8::Handle<v8::Object> wrapper = args.Holder(); 64 V8DOMWrapper::associateObjectWithWrapper(xmlHttpRequest.release(), &info, wrapper, args.GetIsolate() );64 V8DOMWrapper::associateObjectWithWrapper(xmlHttpRequest.release(), &info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); 65 65 return wrapper; 66 66 }
Note: See TracChangeset
for help on using the changeset viewer.