Changeset 128125 in webkit
- Timestamp:
- Sep 10, 2012 4:22:10 PM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r128124 r128125 1 2012-09-10 Adam Barth <abarth@chromium.org> 2 3 [V8] V8AuxiliaryContext used by IDB leaks memory 4 https://bugs.webkit.org/show_bug.cgi?id=96317 5 6 Reviewed by Tony Chang. 7 8 Before this patch, we leaked m_auxiliaryContext on V8PerIsolateData 9 because no one ever called Dispose to balance the call to 10 V8::Context::New. This patch uses ScopedPersistent to call Dispose 11 automatically. 12 13 Also, I've deleted the V8AuxiliaryContext because it just reinvents 14 V8::Context::Scope. 15 16 * bindings/v8/IDBBindingUtilities.cpp: 17 (WebCore::createIDBKeyFromSerializedValueAndKeyPath): 18 (WebCore::injectIDBKeyIntoSerializedValue): 19 * bindings/v8/V8PerIsolateData.cpp: 20 (WebCore::V8PerIsolateData::ensureAuxiliaryContext): 21 (WebCore): 22 * bindings/v8/V8PerIsolateData.h: 23 (V8PerIsolateData): 24 * bindings/v8/V8Utilities.cpp: 25 * bindings/v8/V8Utilities.h: 26 1 27 2012-09-10 Adam Barth <abarth@chromium.org> 2 28 -
trunk/Source/WebCore/bindings/v8/IDBBindingUtilities.cpp
r125481 r128125 163 163 RefPtr<SerializedScriptValue> value = prpValue; 164 164 165 V8AuxiliaryContext context; 165 v8::HandleScope handleScope; 166 v8::Context::Scope scope(V8PerIsolateData::current()->ensureAuxiliaryContext()); 167 166 168 v8::Handle<v8::Value> v8Value(value->deserialize()); 167 169 v8::Handle<v8::Value> v8Key(getNthValueOnKeyPath(v8Value, keyPathElements, keyPathElements.size())); … … 208 210 return 0; 209 211 210 V8AuxiliaryContext context; 212 v8::HandleScope handleScope; 213 v8::Context::Scope scope(V8PerIsolateData::current()->ensureAuxiliaryContext()); 214 211 215 v8::Handle<v8::Value> v8Value(value->deserialize()); 212 216 v8::Handle<v8::Value> parent(ensureNthValueOnKeyPath(v8Value, keyPathElements, keyPathElements.size() - 1)); -
trunk/Source/WebCore/bindings/v8/V8PerIsolateData.cpp
r127718 r128125 108 108 #endif 109 109 110 v8::Handle<v8::Context> V8PerIsolateData::ensureAuxiliaryContext() 111 { 112 if (m_auxiliaryContext.isEmpty()) 113 m_auxiliaryContext.adopt(v8::Context::New()); 114 return m_auxiliaryContext.get(); 115 } 116 110 117 v8::Handle<v8::Value> V8PerIsolateData::constructorOfToString(const v8::Arguments& args) 111 118 { -
trunk/Source/WebCore/bindings/v8/V8PerIsolateData.h
r127718 r128125 27 27 #define V8PerIsolateData_h 28 28 29 #include "ScopedPersistent.h" 29 30 #include <v8.h> 30 31 #include <wtf/HashMap.h> … … 92 93 93 94 V8HiddenPropertyName* hiddenPropertyName() { return m_hiddenPropertyName.get(); } 94 v8:: Persistent<v8::Context>& auxiliaryContext() { return m_auxiliaryContext; }95 v8::Handle<v8::Context> ensureAuxiliaryContext(); 95 96 96 97 void registerDOMDataStore(DOMDataStore* domDataStore) … … 152 153 153 154 OwnPtr<V8HiddenPropertyName> m_hiddenPropertyName; 154 v8::Persistent<v8::Context> m_auxiliaryContext;155 ScopedPersistent<v8::Context> m_auxiliaryContext; 155 156 156 157 bool m_constructorMode; -
trunk/Source/WebCore/bindings/v8/V8Utilities.cpp
r126506 r128125 48 48 49 49 namespace WebCore { 50 51 V8AuxiliaryContext::V8AuxiliaryContext()52 {53 auxiliaryContext()->Enter();54 }55 56 V8AuxiliaryContext::~V8AuxiliaryContext()57 {58 auxiliaryContext()->Exit();59 }60 61 v8::Persistent<v8::Context>& V8AuxiliaryContext::auxiliaryContext()62 {63 v8::Persistent<v8::Context>& context = V8PerIsolateData::current()->auxiliaryContext();64 if (context.IsEmpty())65 context = v8::Context::New();66 return context;67 }68 50 69 51 // Use an array to hold dependents. It works like a ref-counted scheme. -
trunk/Source/WebCore/bindings/v8/V8Utilities.h
r125478 r128125 63 63 typedef unsigned CallbackAllowedValueFlags; 64 64 65 class V8AuxiliaryContext {66 public:67 V8AuxiliaryContext();68 virtual ~V8AuxiliaryContext();69 private:70 v8::HandleScope m_handleScope;71 static v8::Persistent<v8::Context>& auxiliaryContext();72 };73 74 65 typedef WTF::Vector<RefPtr<MessagePort>, 1> MessagePortArray; 75 66 typedef WTF::Vector<RefPtr<ArrayBuffer>, 1> ArrayBufferArray; -
trunk/Source/WebKit/chromium/ChangeLog
r128123 r128125 1 2012-09-10 Adam Barth <abarth@chromium.org> 2 3 [V8] V8AuxiliaryContext used by IDB leaks memory 4 https://bugs.webkit.org/show_bug.cgi?id=96317 5 6 Reviewed by Tony Chang. 7 8 Call the V8 APIs directly instead of using a helper class. 9 10 * tests/IDBBindingUtilitiesTest.cpp: 11 (WebCore::TEST): 12 1 13 2012-09-10 Adam Barth <abarth@chromium.org> 2 14 -
trunk/Source/WebKit/chromium/tests/IDBBindingUtilitiesTest.cpp
r117817 r128125 29 29 #include "IDBKeyPath.h" 30 30 #include "SerializedScriptValue.h" 31 #include "V8PerIsolateData.h" 31 32 #include "V8Utilities.h" 32 33 … … 92 93 TEST(IDBKeyFromValueAndKeyPathTest, TopLevelPropertyStringValue) 93 94 { 94 V8AuxiliaryContext v8context; 95 v8::HandleScope handleScope; 96 v8::Context::Scope scope(V8PerIsolateData::current()->ensureAuxiliaryContext()); 97 95 98 v8::Local<v8::Object> object = v8::Object::New(); 96 99 object->Set(v8::String::New("foo"), v8::String::New("zoo")); … … 104 107 TEST(IDBKeyFromValueAndKeyPathTest, TopLevelPropertyNumberValue) 105 108 { 106 V8AuxiliaryContext v8context; 109 v8::HandleScope handleScope; 110 v8::Context::Scope scope(V8PerIsolateData::current()->ensureAuxiliaryContext()); 111 107 112 v8::Local<v8::Object> object = v8::Object::New(); 108 113 object->Set(v8::String::New("foo"), v8::Number::New(456)); … … 116 121 TEST(IDBKeyFromValueAndKeyPathTest, SubProperty) 117 122 { 118 V8AuxiliaryContext v8context; 123 v8::HandleScope handleScope; 124 v8::Context::Scope scope(V8PerIsolateData::current()->ensureAuxiliaryContext()); 125 119 126 v8::Local<v8::Object> object = v8::Object::New(); 120 127 v8::Local<v8::Object> subProperty = v8::Object::New(); … … 130 137 TEST(InjectIDBKeyTest, TopLevelPropertyStringValue) 131 138 { 132 V8AuxiliaryContext v8context; 139 v8::HandleScope handleScope; 140 v8::Context::Scope scope(V8PerIsolateData::current()->ensureAuxiliaryContext()); 141 133 142 v8::Local<v8::Object> object = v8::Object::New(); 134 143 object->Set(v8::String::New("foo"), v8::String::New("zoo")); … … 142 151 TEST(InjectIDBKeyTest, SubProperty) 143 152 { 144 V8AuxiliaryContext v8context; 153 v8::HandleScope handleScope; 154 v8::Context::Scope scope(V8PerIsolateData::current()->ensureAuxiliaryContext()); 155 145 156 v8::Local<v8::Object> object = v8::Object::New(); 146 157 v8::Local<v8::Object> subProperty = v8::Object::New();
Note: See TracChangeset
for help on using the changeset viewer.