Changeset 126196 in webkit
- Timestamp:
- Aug 21, 2012 3:32:32 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ChangeLog
r126182 r126196 1 2012-08-21 Ulan Degenbaev <ulan@chromium.org> 2 3 Call AdjustAmountOfExternalAllocatedMemory when V8ArrayBuffer constructed and destructed 4 https://bugs.webkit.org/show_bug.cgi?id=92993 5 6 Reviewed by Kenneth Russell. 7 8 Call AdjustAmountOfExternalAllocatedMemory when V8ArrayBuffer 9 is constructed and destructed so that V8's garbage collection 10 heuristics can account for the memory held by these objects. 11 12 * ManualTests/typed-array-memory.html: Added. 13 1 14 2012-08-21 Martin Robinson <mrobinson@igalia.com> 2 15 -
trunk/Source/WTF/ChangeLog
r126191 r126196 1 2012-08-21 Ulan Degenbaev <ulan@chromium.org> 2 3 Call AdjustAmountOfExternalAllocatedMemory when V8ArrayBuffer constructed and destructed 4 https://bugs.webkit.org/show_bug.cgi?id=92993 5 6 Reviewed by Kenneth Russell. 7 8 Call AdjustAmountOfExternalAllocatedMemory when V8ArrayBuffer 9 is constructed and destructed so that V8's garbage collection 10 heuristics can account for the memory held by these objects. 11 12 * wtf/ArrayBuffer.h: 13 (WTF): 14 (ArrayBufferDeallocationObserver): 15 (WTF::ArrayBufferContents::ArrayBufferContents): 16 (WTF::ArrayBufferContents::transfer): 17 (ArrayBufferContents): 18 (ArrayBuffer): 19 (WTF::ArrayBuffer::setDeallocationObserver): 20 (WTF::ArrayBufferContents::~ArrayBufferContents): 21 1 22 2012-08-21 Benjamin Poulain <bpoulain@apple.com> 2 23 -
trunk/Source/WTF/wtf/ArrayBuffer.h
r114992 r126196 37 37 class ArrayBufferView; 38 38 39 #if defined(WTF_USE_V8) 40 // The current implementation assumes that the instance of this class is a 41 // singleton living for the entire process's lifetime. 42 class ArrayBufferDeallocationObserver { 43 public: 44 virtual void ArrayBufferDeallocated(unsigned sizeInBytes) = 0; 45 }; 46 #endif 47 48 39 49 class ArrayBufferContents { 40 50 WTF_MAKE_NONCOPYABLE(ArrayBufferContents); … … 43 53 : m_data(0) 44 54 , m_sizeInBytes(0) 55 #if defined(WTF_USE_V8) 56 , m_deallocationObserver(0) 57 #endif 45 58 { } 46 59 … … 54 67 : m_data(data) 55 68 , m_sizeInBytes(sizeInBytes) 69 #if defined(WTF_USE_V8) 70 , m_deallocationObserver(0) 71 #endif 56 72 { } 57 73 … … 71 87 m_data = 0; 72 88 m_sizeInBytes = 0; 89 #if defined(WTF_USE_V8) 90 // Notify the current V8 isolate that the buffer is gone. 91 if (m_deallocationObserver) 92 m_deallocationObserver->ArrayBufferDeallocated(other.m_sizeInBytes); 93 ASSERT(!other.m_deallocationObserver); 94 m_deallocationObserver = 0; 95 #endif 73 96 } 74 97 75 98 void* m_data; 76 99 unsigned m_sizeInBytes; 100 101 #if defined(WTF_USE_V8) 102 ArrayBufferDeallocationObserver* m_deallocationObserver; 103 #endif 77 104 }; 78 105 … … 99 126 WTF_EXPORT_PRIVATE bool transfer(ArrayBufferContents&, Vector<RefPtr<ArrayBufferView> >& neuteredViews); 100 127 bool isNeutered() { return !m_contents.m_data; } 128 129 #if defined(WTF_USE_V8) 130 void setDeallocationObserver(ArrayBufferDeallocationObserver* deallocationObserver) 131 { 132 m_contents.m_deallocationObserver = deallocationObserver; 133 } 134 #endif 101 135 102 136 ~ArrayBuffer() { } … … 239 273 ArrayBufferContents::~ArrayBufferContents() 240 274 { 275 #if defined (WTF_USE_V8) 276 if (m_deallocationObserver) 277 m_deallocationObserver->ArrayBufferDeallocated(m_sizeInBytes); 278 #endif 241 279 WTF::fastFree(m_data); 242 280 } -
trunk/Source/WebCore/ChangeLog
r126195 r126196 1 2012-08-21 Ulan Degenbaev <ulan@chromium.org> 2 3 Call AdjustAmountOfExternalAllocatedMemory when V8ArrayBuffer constructed and destructed 4 https://bugs.webkit.org/show_bug.cgi?id=92993 5 6 Reviewed by Kenneth Russell. 7 8 Call AdjustAmountOfExternalAllocatedMemory when V8ArrayBuffer 9 is constructed and destructed so that V8's garbage collection 10 heuristics can account for the memory held by these objects. 11 12 * WebCore.gypi: 13 * bindings/v8/SerializedScriptValue.cpp: 14 * bindings/v8/custom/V8ArrayBufferCustom.cpp: 15 (WebCore::V8ArrayBufferDeallocationObserver::instance): 16 (WebCore): 17 (WebCore::V8ArrayBuffer::constructorCallback): 18 * bindings/v8/custom/V8ArrayBufferCustom.h: Added. 19 (WebCore): 20 * bindings/v8/custom/V8ArrayBufferViewCustom.cpp: 21 * bindings/v8/custom/V8ArrayBufferViewCustom.h: 22 (WebCore::constructWebGLArray): 23 * dom/MessageEvent.cpp: 24 (WebCore::MessageEvent::MessageEvent): 25 (WebCore::MessageEvent::initMessageEvent): 26 1 27 2012-08-21 Taiju Tsuiki <tzik@chromium.org> 2 28 -
trunk/Source/WebCore/WebCore.gypi
r126193 r126196 2311 2311 'bindings/v8/WrapperTypeInfo.h', 2312 2312 'bindings/v8/custom/V8ArrayBufferCustom.cpp', 2313 'bindings/v8/custom/V8ArrayBufferCustom.h', 2313 2314 'bindings/v8/custom/V8ArrayBufferViewCustom.cpp', 2314 2315 'bindings/v8/custom/V8ArrayBufferViewCustom.h', -
trunk/Source/WebCore/bindings/v8/custom/V8ArrayBufferCustom.cpp
r125495 r126196 30 30 31 31 #include "config.h" 32 #include "V8ArrayBufferCustom.h" 33 32 34 #include <wtf/ArrayBuffer.h> 35 #include <wtf/StdLibExtras.h> 33 36 34 37 #include "ExceptionCode.h" 38 #include "V8ArrayBuffer.h" 35 39 #include "V8Binding.h" 36 #include "V8ArrayBuffer.h"37 40 #include "V8Proxy.h" 38 41 39 42 namespace WebCore { 43 44 V8ArrayBufferDeallocationObserver* V8ArrayBufferDeallocationObserver::instance() 45 { 46 DEFINE_STATIC_LOCAL(V8ArrayBufferDeallocationObserver, deallocationObserver, ()); 47 return &deallocationObserver; 48 } 49 40 50 41 51 v8::Handle<v8::Value> V8ArrayBuffer::constructorCallback(const v8::Arguments& args) … … 72 82 if (!buffer.get()) 73 83 return throwError(RangeError, "ArrayBuffer size is not a small enough positive integer.", args.GetIsolate()); 84 buffer->setDeallocationObserver(V8ArrayBufferDeallocationObserver::instance()); 85 v8::V8::AdjustAmountOfExternalAllocatedMemory(buffer->byteLength()); 74 86 // Transform the holder into a wrapper object for the array. 75 87 v8::Handle<v8::Object> wrapper = args.Holder(); -
trunk/Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.cpp
r119070 r126196 1 2 1 /* 3 2 * Copyright (C) 2011 Google Inc. All rights reserved. -
trunk/Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h
r125947 r126196 36 36 37 37 #include "V8ArrayBuffer.h" 38 #include "V8ArrayBufferCustom.h" 38 39 #include "V8Binding.h" 39 40 #include "V8Proxy.h" … … 148 149 return throwError(RangeError, tooLargeSize, args.GetIsolate()); 149 150 151 array->buffer()->setDeallocationObserver(V8ArrayBufferDeallocationObserver::instance()); 152 v8::V8::AdjustAmountOfExternalAllocatedMemory(array->byteLength()); 153 150 154 memcpy(array->baseAddress(), source->baseAddress(), length * sizeof(ElementType)); 151 155 … … 182 186 if (!array.get()) 183 187 return throwError(RangeError, tooLargeSize, args.GetIsolate()); 188 189 if (doInstantiation) { 190 array->buffer()->setDeallocationObserver(V8ArrayBufferDeallocationObserver::instance()); 191 v8::V8::AdjustAmountOfExternalAllocatedMemory(array->byteLength()); 192 } 184 193 185 194
Note: See TracChangeset
for help on using the changeset viewer.