Changeset 128249 in webkit
- Timestamp:
- Sep 11, 2012 5:41:06 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r128248 r128249 1 2012-09-11 Elliott Sprehn <esprehn@chromium.org> 2 3 Add new JSDependentRetained that allows keeping a JSObject alive as long as another is alive 4 https://bugs.webkit.org/show_bug.cgi?id=96034 5 6 Reviewed by Geoffrey Garen. 7 8 Add new JSDependentRetained (with the same API as V8DependentRetained) that allows keeping 9 a JSObject alive as long as another is alive. This is useful for keeping callbacks on 10 wrappers without keeping strong references into the JS heap in C++ which can result in 11 cycles that create memory leaks. 12 13 No new tests needed, this will be used to fix MutationObservers and UndoManager which will have tests. 14 15 * GNUmakefile.list.am: 16 * WebCore.vcproj/WebCore.vcproj: 17 * WebCore.xcodeproj/project.pbxproj: 18 * bindings/js/JSDependentRetained.h: Added. 19 (WebCore): 20 (JSDependentRetained): 21 (WebCore::JSDependentRetained::JSDependentRetained): 22 (WebCore::JSDependentRetained::~JSDependentRetained): 23 (WebCore::JSDependentRetained::get): Get the JSObject value. 24 (WebCore::JSDependentRetained::isEmpty): Check if the value is still alive. 25 (WebCore::JSDependentRetained::retain): Sets the owner of the object, should only be used once. 26 (WebCore::JSDependentRetained::release): 27 * bindings/v8/V8DependentRetained.h: 28 (WebCore::V8DependentRetained::V8DependentRetained): 29 (WebCore::V8DependentRetained::retain): Added this method so the API for JSC and V8 are identical. 30 1 31 2012-09-11 Alec Flett <alecflett@chromium.org> 2 32 -
trunk/Source/WebCore/GNUmakefile.list.am
r128231 r128249 2239 2239 Source/WebCore/bindings/js/JSCustomXPathNSResolver.cpp \ 2240 2240 Source/WebCore/bindings/js/JSCustomXPathNSResolver.h \ 2241 Source/WebCore/bindings/js/JSDependentRetained.h \ 2241 2242 Source/WebCore/bindings/js/JSDictionary.cpp \ 2242 2243 Source/WebCore/bindings/js/JSDictionary.h \ -
trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj
r128153 r128249 65927 65927 </File> 65928 65928 <File 65929 RelativePath="..\bindings\js\JSDependentRetained.h" 65930 > 65931 </File> 65932 <File 65929 65933 RelativePath="..\bindings\js\JSDedicatedWorkerContextCustom.cpp" 65930 65934 > -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r128165 r128249 6549 6549 FE6FD48E0F676E9300092873 /* JSCoordinates.h in Headers */ = {isa = PBXBuildFile; fileRef = FE6FD48C0F676E9300092873 /* JSCoordinates.h */; }; 6550 6550 FE700DD10F92D81A008E2BFE /* JSCoordinatesCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE700DD00F92D81A008E2BFE /* JSCoordinatesCustom.cpp */; }; 6551 FFD86E7815F9583600047233 /* JSDependentRetained.h in Headers */ = {isa = PBXBuildFile; fileRef = FFD86E7715F9583600047233 /* JSDependentRetained.h */; }; 6551 6552 FE80D7AB0E9C1ED2000D6F75 /* JSGeolocationCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE80D7A60E9C1ED2000D6F75 /* JSGeolocationCustom.cpp */; }; 6552 6553 FE80DA630E9C4703000D6F75 /* JSGeolocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE80DA5F0E9C4703000D6F75 /* JSGeolocation.cpp */; }; … … 13989 13990 FE6FD48C0F676E9300092873 /* JSCoordinates.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCoordinates.h; sourceTree = "<group>"; }; 13990 13991 FE700DD00F92D81A008E2BFE /* JSCoordinatesCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCoordinatesCustom.cpp; sourceTree = "<group>"; }; 13992 FFD86E7715F9583600047233 /* JSDependentRetained.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDependentRetained.h; sourceTree = "<group>"; }; 13991 13993 FE80D7A60E9C1ED2000D6F75 /* JSGeolocationCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSGeolocationCustom.cpp; sourceTree = "<group>"; }; 13992 13994 FE80DA5F0E9C4703000D6F75 /* JSGeolocation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSGeolocation.cpp; sourceTree = "<group>"; }; … … 20196 20198 1C81BA030E97348300266E07 /* JavaScriptCallFrame.cpp */, 20197 20199 1C81BA040E97348300266E07 /* JavaScriptCallFrame.h */, 20200 FFD86E7715F9583600047233 /* JSDependentRetained.h */, 20198 20201 BCE438A1140C0DBF005E437E /* JSDictionary.cpp */, 20199 20202 BCE4389B140B1BA7005E437E /* JSDictionary.h */, … … 23877 23880 4162A4581011464700DFF3ED /* JSDedicatedWorkerContext.h in Headers */, 23878 23881 FDA15ED212B03F94003A583A /* JSDelayNode.h in Headers */, 23882 FFD86E7815F9583600047233 /* JSDependentRetained.h in Headers */, 23879 23883 31FB1A66120A5D3F00DC02A0 /* JSDeviceMotionEvent.h in Headers */, 23880 23884 59A86008119DAFA100DEF1EF /* JSDeviceOrientationEvent.h in Headers */, -
trunk/Source/WebCore/bindings/v8/V8DependentRetained.h
r127718 r128249 1 1 /* 2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All Rights Reserved. 3 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 7 13 * 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above 11 * copyright notice, this list of conditions and the following disclaimer 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * * Neither the name of Google Inc. nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. … … 45 41 public: 46 42 V8DependentRetained(v8::Handle<v8::Object> owner, v8::Handle<v8::Object> value) 47 : m_owner(owner) 48 , m_value(value) 43 : m_value(value) 49 44 , m_propertyName(createPropertyName()) 50 45 { 51 ASSERT(!m_owner.IsEmpty()); 52 ASSERT(!m_value.IsEmpty()); 53 owner->SetHiddenValue(m_propertyName.get(), value); 54 m_owner.get().MakeWeak(this, &V8DependentRetained::ownerWeakCallback); 46 ASSERT(!m_value.isEmpty()); 55 47 m_value.get().MakeWeak(this, &V8DependentRetained::valueWeakCallback); 48 if (!owner.IsEmpty()) 49 retain(owner); 56 50 } 57 51 … … 71 65 } 72 66 73 // FIXME: We might add an explicit retain(v8::Handle<v8::Object>) method to allow 74 // creating one of these and choosing the owner later. Such behavior is required 75 // in JSC, but not in v8 right now. 67 void retain(v8::Handle<v8::Object> owner) 68 { 69 ASSERT(m_owner.isEmpty() && !owner.IsEmpty()); 70 ASSERT(!m_value.isEmpty()); 71 owner->SetHiddenValue(m_propertyName.get(), get()); 72 m_owner = owner; 73 m_owner.get().MakeWeak(this, &V8DependentRetained::ownerWeakCallback); 74 } 76 75 77 76 private:
Note: See TracChangeset
for help on using the changeset viewer.