Commit 9ce01c6f authored by oliver@apple.com's avatar oliver@apple.com

Move typed array implementations into wtf

https://bugs.webkit.org/show_bug.cgi?id=73248

Reviewed by Sam Weinig.

Source/JavaScriptCore:

Move typed array implementation files from WebCore to wtf.  Inline the
.cpp files for each of the array views to cut down on unnecessary exports
and function call overhead for trivial operations.

Added files to all the project files.

* GNUmakefile.list.am:
* JavaScriptCore.exp:
* JavaScriptCore.vcproj/WTF/WTF.vcproj:
* JavaScriptCore.xcodeproj/project.pbxproj:
* wtf/ArrayBuffer.cpp: Renamed from Source/WebCore/html/canvas/Float32Array.cpp.
(WTF::ArrayBuffer::transfer):
(WTF::ArrayBuffer::addView):
(WTF::ArrayBuffer::removeView):
* wtf/ArrayBuffer.h: Renamed from Source/WebCore/html/canvas/ArrayBuffer.cpp.
(WTF::ArrayBufferContents::ArrayBufferContents):
(WTF::ArrayBufferContents::data):
(WTF::ArrayBufferContents::sizeInBytes):
(WTF::ArrayBufferContents::transfer):
(WTF::ArrayBuffer::~ArrayBuffer):
(WTF::ArrayBuffer::clampValue):
(WTF::ArrayBuffer::create):
(WTF::ArrayBuffer::ArrayBuffer):
(WTF::ArrayBuffer::data):
(WTF::ArrayBuffer::byteLength):
(WTF::ArrayBuffer::slice):
(WTF::ArrayBuffer::sliceImpl):
(WTF::ArrayBuffer::clampIndex):
(WTF::ArrayBufferContents::tryAllocate):
(WTF::ArrayBufferContents::~ArrayBufferContents):
* wtf/ArrayBufferView.cpp: Copied from Source/WebCore/bindings/js/JSArrayBufferCustom.cpp.
(WTF::ArrayBufferView::ArrayBufferView):
(WTF::ArrayBufferView::~ArrayBufferView):
(WTF::ArrayBufferView::neuter):
* wtf/ArrayBufferView.h: Renamed from Source/WebCore/html/canvas/ArrayBufferView.h.
(WTF::ArrayBufferView::isByteArray):
(WTF::ArrayBufferView::isUnsignedByteArray):
(WTF::ArrayBufferView::isShortArray):
(WTF::ArrayBufferView::isUnsignedShortArray):
(WTF::ArrayBufferView::isIntArray):
(WTF::ArrayBufferView::isUnsignedIntArray):
(WTF::ArrayBufferView::isFloatArray):
(WTF::ArrayBufferView::isDoubleArray):
(WTF::ArrayBufferView::isDataView):
(WTF::ArrayBufferView::buffer):
(WTF::ArrayBufferView::baseAddress):
(WTF::ArrayBufferView::byteOffset):
(WTF::ArrayBufferView::verifySubRange):
(WTF::ArrayBufferView::clampOffsetAndNumElements):
(WTF::ArrayBufferView::setImpl):
(WTF::ArrayBufferView::setRangeImpl):
(WTF::ArrayBufferView::zeroRangeImpl):
(WTF::ArrayBufferView::calculateOffsetAndLength):
* wtf/CMakeLists.txt:
* wtf/Float32Array.h: Renamed from Source/WebCore/html/canvas/Float32Array.h.
(WTF::Float32Array::set):
(WTF::Float32Array::item):
(WTF::Float32Array::isFloatArray):
(WTF::Float32Array::create):
(WTF::Float32Array::Float32Array):
(WTF::Float32Array::subarray):
* wtf/Float64Array.h: Renamed from Source/WebCore/html/canvas/Float64Array.h.
(WTF::Float64Array::set):
(WTF::Float64Array::item):
(WTF::Float64Array::isDoubleArray):
(WTF::Float64Array::create):
(WTF::Float64Array::Float64Array):
(WTF::Float64Array::subarray):
* wtf/Int16Array.h: Renamed from Source/WebCore/html/canvas/Int16Array.cpp.
(WTF::Int16Array::set):
(WTF::Int16Array::isShortArray):
(WTF::Int16Array::create):
(WTF::Int16Array::Int16Array):
(WTF::Int16Array::subarray):
* wtf/Int32Array.h: Renamed from Source/WebCore/html/canvas/Int32Array.cpp.
(WTF::Int32Array::set):
(WTF::Int32Array::isIntArray):
(WTF::Int32Array::create):
(WTF::Int32Array::Int32Array):
(WTF::Int32Array::subarray):
* wtf/Int8Array.h: Renamed from Source/WebCore/html/canvas/Int8Array.cpp.
(WTF::Int8Array::set):
(WTF::Int8Array::isByteArray):
(WTF::Int8Array::create):
(WTF::Int8Array::Int8Array):
(WTF::Int8Array::subarray):
* wtf/IntegralTypedArrayBase.h: Renamed from Source/WebCore/html/canvas/IntegralTypedArrayBase.h.
(WTF::IntegralTypedArrayBase::set):
(WTF::IntegralTypedArrayBase::item):
(WTF::IntegralTypedArrayBase::IntegralTypedArrayBase):
* wtf/TypedArrayBase.h: Renamed from Source/WebCore/html/canvas/TypedArrayBase.h.
(WTF::TypedArrayBase::data):
(WTF::TypedArrayBase::set):
(WTF::TypedArrayBase::setRange):
(WTF::TypedArrayBase::zeroRange):
(WTF::TypedArrayBase::length):
(WTF::TypedArrayBase::byteLength):
(WTF::TypedArrayBase::TypedArrayBase):
(WTF::TypedArrayBase::create):
(WTF::TypedArrayBase::subarrayImpl):
* wtf/Uint16Array.h: Renamed from Source/WebCore/html/canvas/Uint16Array.cpp.
(WTF::Uint16Array::set):
(WTF::Uint16Array::isUnsignedShortArray):
(WTF::Uint16Array::create):
(WTF::Uint16Array::Uint16Array):
(WTF::Uint16Array::subarray):
* wtf/Uint32Array.h: Renamed from Source/WebCore/html/canvas/Uint32Array.cpp.
(WTF::Uint32Array::set):
(WTF::Uint32Array::isUnsignedIntArray):
(WTF::Uint32Array::create):
(WTF::Uint32Array::Uint32Array):
(WTF::Uint32Array::subarray):
* wtf/Uint8Array.h: Renamed from Source/WebCore/html/canvas/Uint8Array.h.
(WTF::Uint8Array::set):
(WTF::Uint8Array::isUnsignedByteArray):
(WTF::Uint8Array::create):
(WTF::Uint8Array::Uint8Array):
(WTF::Uint8Array::subarray):
* wtf/wtf.pro:

Source/WebCore:

Removed the typed array implementation files from WebCore and
added forwarding headers.

* CMakeLists.txt:
* ForwardingHeaders/wtf/ArrayBuffer.h: Added.
* ForwardingHeaders/wtf/ArrayBufferView.h: Added.
* ForwardingHeaders/wtf/Float32Array.h: Added.
* ForwardingHeaders/wtf/Float64Array.h: Added.
* ForwardingHeaders/wtf/Int16Array.h: Added.
* ForwardingHeaders/wtf/Int32Array.h: Added.
* ForwardingHeaders/wtf/Int8Array.h: Added.
* ForwardingHeaders/wtf/Uint16Array.h: Added.
* ForwardingHeaders/wtf/Uint32Array.h: Added.
* ForwardingHeaders/wtf/Uint8Array.h: Added.
* GNUmakefile.list.am:
* Target.pri:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSArrayBufferCustom.cpp:
* bindings/js/JSArrayBufferViewHelper.h:
* bindings/js/JSAudioContextCustom.cpp:
* bindings/js/JSFileReaderCustom.cpp:
* bindings/js/JSFloat32ArrayCustom.cpp:
* bindings/js/JSFloat64ArrayCustom.cpp:
* bindings/js/JSInt16ArrayCustom.cpp:
* bindings/js/JSInt32ArrayCustom.cpp:
* bindings/js/JSInt8ArrayCustom.cpp:
* bindings/js/JSUint16ArrayCustom.cpp:
* bindings/js/JSUint32ArrayCustom.cpp:
* bindings/js/JSUint8ArrayCustom.cpp:
* bindings/js/JSWaveShaperNodeCustom.cpp:
* bindings/js/JSWebGLRenderingContextCustom.cpp:
* bindings/js/JSXMLHttpRequestCustom.cpp:
* bindings/scripts/CodeGeneratorJS.pm:
(AddIncludesForType):
(GenerateHeader):
(NativeToJSValue):
* bindings/scripts/test/JS/JSFloat64Array.cpp:
* bindings/scripts/test/JS/JSFloat64Array.h:
* dom/MessageEvent.h:
* fileapi/FileReader.cpp:
* fileapi/FileReaderLoader.cpp:
* fileapi/FileReaderSync.cpp:
* fileapi/WebKitBlobBuilder.cpp:
* html/HTMLMediaElement.cpp:
* html/canvas/ArrayBuffer.h: Removed.
* html/canvas/ArrayBufferView.cpp: Removed.
* html/canvas/DataView.h:
* html/canvas/Float64Array.cpp: Removed.
* html/canvas/Int16Array.h: Removed.
* html/canvas/Int32Array.h: Removed.
* html/canvas/Int8Array.h: Removed.
* html/canvas/Uint16Array.h: Removed.
* html/canvas/Uint32Array.h: Removed.
* html/canvas/Uint8Array.cpp: Removed.
* html/canvas/WebGLBuffer.cpp:
* html/canvas/WebGLBuffer.h:
* html/canvas/WebGLGetInfo.cpp:
* html/canvas/WebGLGetInfo.h:
* html/canvas/WebGLRenderingContext.cpp:
* html/canvas/WebGLRenderingContext.h:
* page/Crypto.cpp:
* platform/graphics/GraphicsContext3D.cpp:
* platform/graphics/mac/GraphicsContext3DMac.mm:
* platform/graphics/opengl/GraphicsContext3DOpenGL.cpp:
* webaudio/AsyncAudioDecoder.cpp:
* webaudio/AudioBuffer.h:
* webaudio/AudioContext.cpp:
* webaudio/AudioParam.h:
* webaudio/AudioParamTimeline.h:
* webaudio/JavaScriptAudioNode.cpp:
* webaudio/RealtimeAnalyser.cpp:
* webaudio/WaveShaperProcessor.h:
* websockets/WebSocketChannel.cpp:
* websockets/WorkerThreadableWebSocketChannel.cpp:
* xml/XMLHttpRequest.cpp:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@101295 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent b694b65e
2011-11-28 Oliver Hunt <oliver@apple.com>
Move typed array implementations into wtf
https://bugs.webkit.org/show_bug.cgi?id=73248
Reviewed by Sam Weinig.
Move typed array implementation files from WebCore to wtf. Inline the
.cpp files for each of the array views to cut down on unnecessary exports
and function call overhead for trivial operations.
Added files to all the project files.
* GNUmakefile.list.am:
* JavaScriptCore.exp:
* JavaScriptCore.vcproj/WTF/WTF.vcproj:
* JavaScriptCore.xcodeproj/project.pbxproj:
* wtf/ArrayBuffer.cpp: Renamed from Source/WebCore/html/canvas/Float32Array.cpp.
(WTF::ArrayBuffer::transfer):
(WTF::ArrayBuffer::addView):
(WTF::ArrayBuffer::removeView):
* wtf/ArrayBuffer.h: Renamed from Source/WebCore/html/canvas/ArrayBuffer.cpp.
(WTF::ArrayBufferContents::ArrayBufferContents):
(WTF::ArrayBufferContents::data):
(WTF::ArrayBufferContents::sizeInBytes):
(WTF::ArrayBufferContents::transfer):
(WTF::ArrayBuffer::~ArrayBuffer):
(WTF::ArrayBuffer::clampValue):
(WTF::ArrayBuffer::create):
(WTF::ArrayBuffer::ArrayBuffer):
(WTF::ArrayBuffer::data):
(WTF::ArrayBuffer::byteLength):
(WTF::ArrayBuffer::slice):
(WTF::ArrayBuffer::sliceImpl):
(WTF::ArrayBuffer::clampIndex):
(WTF::ArrayBufferContents::tryAllocate):
(WTF::ArrayBufferContents::~ArrayBufferContents):
* wtf/ArrayBufferView.cpp: Copied from Source/WebCore/bindings/js/JSArrayBufferCustom.cpp.
(WTF::ArrayBufferView::ArrayBufferView):
(WTF::ArrayBufferView::~ArrayBufferView):
(WTF::ArrayBufferView::neuter):
* wtf/ArrayBufferView.h: Renamed from Source/WebCore/html/canvas/ArrayBufferView.h.
(WTF::ArrayBufferView::isByteArray):
(WTF::ArrayBufferView::isUnsignedByteArray):
(WTF::ArrayBufferView::isShortArray):
(WTF::ArrayBufferView::isUnsignedShortArray):
(WTF::ArrayBufferView::isIntArray):
(WTF::ArrayBufferView::isUnsignedIntArray):
(WTF::ArrayBufferView::isFloatArray):
(WTF::ArrayBufferView::isDoubleArray):
(WTF::ArrayBufferView::isDataView):
(WTF::ArrayBufferView::buffer):
(WTF::ArrayBufferView::baseAddress):
(WTF::ArrayBufferView::byteOffset):
(WTF::ArrayBufferView::verifySubRange):
(WTF::ArrayBufferView::clampOffsetAndNumElements):
(WTF::ArrayBufferView::setImpl):
(WTF::ArrayBufferView::setRangeImpl):
(WTF::ArrayBufferView::zeroRangeImpl):
(WTF::ArrayBufferView::calculateOffsetAndLength):
* wtf/CMakeLists.txt:
* wtf/Float32Array.h: Renamed from Source/WebCore/html/canvas/Float32Array.h.
(WTF::Float32Array::set):
(WTF::Float32Array::item):
(WTF::Float32Array::isFloatArray):
(WTF::Float32Array::create):
(WTF::Float32Array::Float32Array):
(WTF::Float32Array::subarray):
* wtf/Float64Array.h: Renamed from Source/WebCore/html/canvas/Float64Array.h.
(WTF::Float64Array::set):
(WTF::Float64Array::item):
(WTF::Float64Array::isDoubleArray):
(WTF::Float64Array::create):
(WTF::Float64Array::Float64Array):
(WTF::Float64Array::subarray):
* wtf/Int16Array.h: Renamed from Source/WebCore/html/canvas/Int16Array.cpp.
(WTF::Int16Array::set):
(WTF::Int16Array::isShortArray):
(WTF::Int16Array::create):
(WTF::Int16Array::Int16Array):
(WTF::Int16Array::subarray):
* wtf/Int32Array.h: Renamed from Source/WebCore/html/canvas/Int32Array.cpp.
(WTF::Int32Array::set):
(WTF::Int32Array::isIntArray):
(WTF::Int32Array::create):
(WTF::Int32Array::Int32Array):
(WTF::Int32Array::subarray):
* wtf/Int8Array.h: Renamed from Source/WebCore/html/canvas/Int8Array.cpp.
(WTF::Int8Array::set):
(WTF::Int8Array::isByteArray):
(WTF::Int8Array::create):
(WTF::Int8Array::Int8Array):
(WTF::Int8Array::subarray):
* wtf/IntegralTypedArrayBase.h: Renamed from Source/WebCore/html/canvas/IntegralTypedArrayBase.h.
(WTF::IntegralTypedArrayBase::set):
(WTF::IntegralTypedArrayBase::item):
(WTF::IntegralTypedArrayBase::IntegralTypedArrayBase):
* wtf/TypedArrayBase.h: Renamed from Source/WebCore/html/canvas/TypedArrayBase.h.
(WTF::TypedArrayBase::data):
(WTF::TypedArrayBase::set):
(WTF::TypedArrayBase::setRange):
(WTF::TypedArrayBase::zeroRange):
(WTF::TypedArrayBase::length):
(WTF::TypedArrayBase::byteLength):
(WTF::TypedArrayBase::TypedArrayBase):
(WTF::TypedArrayBase::create):
(WTF::TypedArrayBase::subarrayImpl):
* wtf/Uint16Array.h: Renamed from Source/WebCore/html/canvas/Uint16Array.cpp.
(WTF::Uint16Array::set):
(WTF::Uint16Array::isUnsignedShortArray):
(WTF::Uint16Array::create):
(WTF::Uint16Array::Uint16Array):
(WTF::Uint16Array::subarray):
* wtf/Uint32Array.h: Renamed from Source/WebCore/html/canvas/Uint32Array.cpp.
(WTF::Uint32Array::set):
(WTF::Uint32Array::isUnsignedIntArray):
(WTF::Uint32Array::create):
(WTF::Uint32Array::Uint32Array):
(WTF::Uint32Array::subarray):
* wtf/Uint8Array.h: Renamed from Source/WebCore/html/canvas/Uint8Array.h.
(WTF::Uint8Array::set):
(WTF::Uint8Array::isUnsignedByteArray):
(WTF::Uint8Array::create):
(WTF::Uint8Array::Uint8Array):
(WTF::Uint8Array::subarray):
* wtf/wtf.pro:
2011-11-27 Filip Pizlo <fpizlo@apple.com>
Don't try to optimize huge code blocks
......@@ -496,14 +496,18 @@ javascriptcore_sources += \
Source/JavaScriptCore/runtime/WriteBarrier.h \
Source/JavaScriptCore/wtf/Alignment.h \
Source/JavaScriptCore/wtf/AlwaysInline.h \
Source/JavaScriptCore/wtf/ArrayBuffer.cpp \
Source/JavaScriptCore/wtf/ArrayBuffer.h \
Source/JavaScriptCore/wtf/ArrayBufferView.cpp \
Source/JavaScriptCore/wtf/ArrayBufferView.h \
Source/JavaScriptCore/wtf/ASCIICType.h \
Source/JavaScriptCore/wtf/Assertions.cpp \
Source/JavaScriptCore/wtf/Assertions.h \
Source/JavaScriptCore/wtf/Atomics.h \
Source/JavaScriptCore/wtf/AVLTree.h \
Source/JavaScriptCore/wtf/Bitmap.h \
Source/JavaScriptCore/wtf/BitVector.cpp \
Source/JavaScriptCore/wtf/BitVector.h \
Source/JavaScriptCore/wtf/Bitmap.h \
Source/JavaScriptCore/wtf/BlockStack.h \
Source/JavaScriptCore/wtf/BloomFilter.h \
Source/JavaScriptCore/wtf/BoundsCheckedPointer.h \
......@@ -520,30 +524,30 @@ javascriptcore_sources += \
Source/JavaScriptCore/wtf/DateMath.h \
Source/JavaScriptCore/wtf/DecimalNumber.cpp \
Source/JavaScriptCore/wtf/DecimalNumber.h \
Source/JavaScriptCore/wtf/Decoder.h \
Source/JavaScriptCore/wtf/Deque.h \
Source/JavaScriptCore/wtf/DisallowCType.h \
Source/JavaScriptCore/wtf/DoublyLinkedList.h \
Source/JavaScriptCore/wtf/dtoa.cpp \
Source/JavaScriptCore/wtf/dtoa.h \
Source/JavaScriptCore/wtf/dtoa/bignum-dtoa.cc \
Source/JavaScriptCore/wtf/dtoa/bignum.cc \
Source/JavaScriptCore/wtf/dtoa/cached-powers.cc \
Source/JavaScriptCore/wtf/dtoa/diy-fp.cc \
Source/JavaScriptCore/wtf/dtoa/double-conversion.cc \
Source/JavaScriptCore/wtf/dtoa/fast-dtoa.cc \
Source/JavaScriptCore/wtf/dtoa/fixed-dtoa.cc \
Source/JavaScriptCore/wtf/dtoa/strtod.cc \
Source/JavaScriptCore/wtf/dtoa/bignum-dtoa.h \
Source/JavaScriptCore/wtf/dtoa/bignum.cc \
Source/JavaScriptCore/wtf/dtoa/bignum.h \
Source/JavaScriptCore/wtf/dtoa/cached-powers.cc \
Source/JavaScriptCore/wtf/dtoa/cached-powers.h \
Source/JavaScriptCore/wtf/dtoa/diy-fp.cc \
Source/JavaScriptCore/wtf/dtoa/diy-fp.h \
Source/JavaScriptCore/wtf/dtoa/double-conversion.cc \
Source/JavaScriptCore/wtf/dtoa/double-conversion.h \
Source/JavaScriptCore/wtf/dtoa/double.h \
Source/JavaScriptCore/wtf/dtoa/fast-dtoa.cc \
Source/JavaScriptCore/wtf/dtoa/fast-dtoa.h \
Source/JavaScriptCore/wtf/dtoa/fixed-dtoa.cc \
Source/JavaScriptCore/wtf/dtoa/fixed-dtoa.h \
Source/JavaScriptCore/wtf/dtoa/strtod.cc \
Source/JavaScriptCore/wtf/dtoa/strtod.h \
Source/JavaScriptCore/wtf/dtoa/utils.h \
Source/JavaScriptCore/wtf/Decoder.h \
Source/JavaScriptCore/wtf/Deque.h \
Source/JavaScriptCore/wtf/DisallowCType.h \
Source/JavaScriptCore/wtf/DoublyLinkedList.h \
Source/JavaScriptCore/wtf/dtoa.cpp \
Source/JavaScriptCore/wtf/dtoa.h \
Source/JavaScriptCore/wtf/DynamicAnnotations.cpp \
Source/JavaScriptCore/wtf/DynamicAnnotations.h \
Source/JavaScriptCore/wtf/Encoder.h \
......@@ -551,6 +555,8 @@ javascriptcore_sources += \
Source/JavaScriptCore/wtf/FastMalloc.cpp \
Source/JavaScriptCore/wtf/FastMalloc.h \
Source/JavaScriptCore/wtf/FixedArray.h \
Source/JavaScriptCore/wtf/Float32Array.h \
Source/JavaScriptCore/wtf/Float64Array.h \
Source/JavaScriptCore/wtf/Forward.h \
Source/JavaScriptCore/wtf/GetPtr.h \
Source/JavaScriptCore/wtf/gobject/GOwnPtr.cpp \
......@@ -569,6 +575,10 @@ javascriptcore_sources += \
Source/JavaScriptCore/wtf/HashTraits.h \
Source/JavaScriptCore/wtf/HexNumber.h \
Source/JavaScriptCore/wtf/InlineASM.h \
Source/JavaScriptCore/wtf/Int16Array.h \
Source/JavaScriptCore/wtf/Int32Array.h \
Source/JavaScriptCore/wtf/Int8Array.h \
Source/JavaScriptCore/wtf/IntegralTypedArrayBase.h \
Source/JavaScriptCore/wtf/ListHashSet.h \
Source/JavaScriptCore/wtf/ListRefPtr.h \
Source/JavaScriptCore/wtf/Locker.h \
......@@ -578,12 +588,12 @@ javascriptcore_sources += \
Source/JavaScriptCore/wtf/MathExtras.h \
Source/JavaScriptCore/wtf/MD5.cpp \
Source/JavaScriptCore/wtf/MD5.h \
Source/JavaScriptCore/wtf/MessageQueue.h \
Source/JavaScriptCore/wtf/MetaAllocator.cpp \
Source/JavaScriptCore/wtf/MetaAllocator.h \
Source/JavaScriptCore/wtf/MetaAllocatorHandle.h \
Source/JavaScriptCore/wtf/MessageQueue.h \
Source/JavaScriptCore/wtf/NonCopyingSort.h \
Source/JavaScriptCore/wtf/Noncopyable.h \
Source/JavaScriptCore/wtf/NonCopyingSort.h \
Source/JavaScriptCore/wtf/NotFound.h \
Source/JavaScriptCore/wtf/NullPtr.h \
Source/JavaScriptCore/wtf/OSAllocator.h \
......@@ -591,24 +601,24 @@ javascriptcore_sources += \
Source/JavaScriptCore/wtf/OSRandomSource.h \
Source/JavaScriptCore/wtf/OwnArrayPtr.h \
Source/JavaScriptCore/wtf/OwnFastMallocPtr.h \
Source/JavaScriptCore/wtf/OwnPtrCommon.h \
Source/JavaScriptCore/wtf/OwnPtr.h \
Source/JavaScriptCore/wtf/OwnPtrCommon.h \
Source/JavaScriptCore/wtf/PackedIntVector.h \
Source/JavaScriptCore/wtf/PageAllocation.h \
Source/JavaScriptCore/wtf/PageAllocationAligned.cpp \
Source/JavaScriptCore/wtf/PageAllocationAligned.h \
Source/JavaScriptCore/wtf/PageReservation.h \
Source/JavaScriptCore/wtf/PageBlock.cpp \
Source/JavaScriptCore/wtf/PageBlock.h \
Source/JavaScriptCore/wtf/PassOwnArrayPtr.h \
Source/JavaScriptCore/wtf/PassOwnPtr.h \
Source/JavaScriptCore/wtf/PassRefPtr.h \
Source/JavaScriptCore/wtf/PassTraits.h \
Source/JavaScriptCore/wtf/PageReservation.h \
Source/JavaScriptCore/wtf/ParallelJobs.h \
Source/JavaScriptCore/wtf/ParallelJobsGeneric.cpp \
Source/JavaScriptCore/wtf/ParallelJobsGeneric.h \
Source/JavaScriptCore/wtf/ParallelJobsLibdispatch.h \
Source/JavaScriptCore/wtf/ParallelJobsOpenMP.h \
Source/JavaScriptCore/wtf/PassOwnArrayPtr.h \
Source/JavaScriptCore/wtf/PassOwnPtr.h \
Source/JavaScriptCore/wtf/PassRefPtr.h \
Source/JavaScriptCore/wtf/PassTraits.h \
Source/JavaScriptCore/wtf/Platform.h \
Source/JavaScriptCore/wtf/PossiblyNull.h \
Source/JavaScriptCore/wtf/RandomNumber.cpp \
......@@ -656,26 +666,30 @@ javascriptcore_sources += \
Source/JavaScriptCore/wtf/text/TextPosition.h \
Source/JavaScriptCore/wtf/text/WTFString.cpp \
Source/JavaScriptCore/wtf/text/WTFString.h \
Source/JavaScriptCore/wtf/threads/BinarySemaphore.cpp \
Source/JavaScriptCore/wtf/threads/BinarySemaphore.h \
Source/JavaScriptCore/wtf/ThreadIdentifierDataPthreads.cpp \
Source/JavaScriptCore/wtf/ThreadIdentifierDataPthreads.h \
Source/JavaScriptCore/wtf/ThreadRestrictionVerifier.h \
Source/JavaScriptCore/wtf/Threading.cpp \
Source/JavaScriptCore/wtf/Threading.h \
Source/JavaScriptCore/wtf/ThreadingPrimitives.h \
Source/JavaScriptCore/wtf/ThreadingPthreads.cpp \
Source/JavaScriptCore/wtf/ThreadRestrictionVerifier.h \
Source/JavaScriptCore/wtf/threads/BinarySemaphore.cpp \
Source/JavaScriptCore/wtf/threads/BinarySemaphore.h \
Source/JavaScriptCore/wtf/ThreadSafeRefCounted.h \
Source/JavaScriptCore/wtf/ThreadSpecific.h \
Source/JavaScriptCore/wtf/TypedArrayBase.h \
Source/JavaScriptCore/wtf/TypeTraits.cpp \
Source/JavaScriptCore/wtf/TypeTraits.h \
Source/JavaScriptCore/wtf/UnionFind.h \
Source/JavaScriptCore/wtf/Uint16Array.h \
Source/JavaScriptCore/wtf/Uint32Array.h \
Source/JavaScriptCore/wtf/Uint8Array.h \
Source/JavaScriptCore/wtf/unicode/CharacterNames.h \
Source/JavaScriptCore/wtf/unicode/CollatorDefault.cpp \
Source/JavaScriptCore/wtf/unicode/Collator.h \
Source/JavaScriptCore/wtf/unicode/CollatorDefault.cpp \
Source/JavaScriptCore/wtf/unicode/Unicode.h \
Source/JavaScriptCore/wtf/unicode/UTF8.cpp \
Source/JavaScriptCore/wtf/unicode/UTF8.h \
Source/JavaScriptCore/wtf/UnionFind.h \
Source/JavaScriptCore/wtf/UnusedParam.h \
Source/JavaScriptCore/wtf/ValueCheck.h \
Source/JavaScriptCore/wtf/Vector.h \
......
......@@ -423,6 +423,9 @@ __ZN3WTF13tryFastMallocEm
__ZN3WTF14fastMallocSizeEPKv
__ZN3WTF14numberToStringEdPc
__ZN3WTF14tryFastReallocEPvm
__ZN3WTF15ArrayBufferView6neuterEv
__ZN3WTF15ArrayBufferViewC2ENS_10PassRefPtrINS_11ArrayBufferEEEj
__ZN3WTF15ArrayBufferViewD2Ev
__ZN3WTF15ThreadCondition4waitERNS_5MutexE
__ZN3WTF15ThreadCondition6signalEv
__ZN3WTF15ThreadCondition9broadcastEv
......
......@@ -545,6 +545,10 @@
'runtime/Tracing.h',
'runtime/UString.cpp',
'runtime/UStringConcatenate.h',
'wtf/ArrayBuffer.cpp',
'wtf/ArrayBuffer.h',
'wtf/ArrayBufferView.cpp',
'wtf/ArrayBufferView.h',
'wtf/Assertions.cpp',
'wtf/ByteArray.cpp',
'wtf/CryptographicallyRandomNumber.cpp',
......@@ -554,7 +558,13 @@
'wtf/DynamicAnnotations.cpp',
'wtf/DynamicAnnotations.h',
'wtf/FastMalloc.cpp',
'wtf/Float32Array.h',
'wtf/Float64Array.h',
'wtf/HashTable.cpp',
'wtf/Int16Array.h',
'wtf/Int32Array.h',
'wtf/Int8Array.h',
'wtf/IntegralTypedArrayBase.h',
'wtf/MD5.cpp',
'wtf/MainThread.cpp',
'wtf/MallocZoneSupport.h',
......@@ -587,7 +597,11 @@
'wtf/ThreadingPthreads.cpp',
'wtf/ThreadingWin.cpp',
'wtf/TypeTraits.cpp',
'wtf/WTFThreadData.cpp',
'wtf/TypedArrayBase.h',
'wtf/WTFThreadData.cpp'
'wtf/Uint16Array.h',
'wtf/Uint32Array.h',
'wtf/Uint8Array.h',
'wtf/chromium/ChromiumThreading.h',
'wtf/chromium/MainThreadChromium.cpp',
'wtf/dtoa.cpp',
......
......@@ -612,6 +612,22 @@
RelativePath="..\..\wtf\AlwaysInline.h"
>
</File>
<File
RelativePath="..\..\wtf\ArrayBuffer.cpp"
>
</File>
<File
RelativePath="..\..\wtf\ArrayBuffer.h"
>
</File>
<File
RelativePath="..\..\wtf\ArrayBufferView.cpp"
>
</File>
<File
RelativePath="..\..\wtf\ArrayBufferView.h"
>
</File>
<File
RelativePath="..\..\wtf\ASCIICType.h"
>
......@@ -728,6 +744,14 @@
RelativePath="..\..\wtf\DynamicAnnotations.h"
>
</File>
<File
RelativePath="..\..\wtf\Float32Array.h"
>
</File>
<File
RelativePath="..\..\wtf\Float64Array.h"
>
</File>
<File
RelativePath="..\..\wtf\dtoa.cpp"
>
......@@ -832,6 +856,18 @@
RelativePath="..\..\wtf\HexNumber.h"
>
</File>
<File
RelativePath="..\..\wtf\Int16Array.h"
>
</File>
<File
RelativePath="..\..\wtf\Int32Array.h"
>
</File>
<File
RelativePath="..\..\wtf\Int8Array.h"
>
</File>
<File
RelativePath="..\..\wtf\ListHashSet.h"
>
......@@ -1156,6 +1192,18 @@
RelativePath="..\..\wtf\TypeTraits.h"
>
</File>
<File
RelativePath="..\..\wtf\UInt16Array.h"
>
</File>
<File
RelativePath="..\..\wtf\UInt32Array.h"
>
</File>
<File
RelativePath="..\..\wtf\UInt8Array.h"
>
</File>
<File
RelativePath="..\..\wtf\UnusedParam.h"
>
......
/*
* Copyright (C) 2009 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "ArrayBuffer.h"
#include "ArrayBufferView.h"
#include <wtf/RefPtr.h>
#include <wtf/Vector.h>
namespace WTF {
bool ArrayBuffer::transfer(ArrayBufferContents& result, Vector<ArrayBufferView*>& neuteredViews)
{
RefPtr<ArrayBuffer> keepAlive(this);
if (!m_contents.m_data) {
result.m_data = 0;
return false;
}
m_contents.transfer(result);
while (m_firstView) {
ArrayBufferView* current = m_firstView;
removeView(current);
current->neuter();
neuteredViews.append(current);
}
return true;
}
void ArrayBuffer::addView(ArrayBufferView* view)
{
view->m_buffer = this;
view->m_prevView = 0;
view->m_nextView = m_firstView;
if (m_firstView)
m_firstView->m_prevView = view;
m_firstView = view;
}
void ArrayBuffer::removeView(ArrayBufferView* view)
{
ASSERT(this == view->m_buffer);
if (view->m_nextView)
view->m_nextView->m_prevView = view->m_prevView;
if (view->m_prevView)
view->m_prevView->m_nextView = view->m_nextView;
if (m_firstView == view)
m_firstView = view->m_nextView;
view->m_prevView = view->m_nextView = 0;
}
}
......@@ -23,16 +23,86 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "ArrayBuffer.h"
#include "ArrayBufferView.h"
#ifndef ArrayBuffer_h
#define ArrayBuffer_h
#include <wtf/RefPtr.h>
#include <wtf/HashSet.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/Vector.h>
namespace WTF {
static int clampValue(int x, int left, int right)
class ArrayBuffer;
class ArrayBufferView;
class ArrayBufferContents {
WTF_MAKE_NONCOPYABLE(ArrayBufferContents);
public:
ArrayBufferContents()
: m_data(0)
, m_sizeInBytes(0)
{ }
inline ~ArrayBufferContents();
void* data() { return m_data; }
unsigned sizeInBytes() { return m_sizeInBytes; }
private:
ArrayBufferContents(void* data, unsigned sizeInBytes)
: m_data(data)
, m_sizeInBytes(sizeInBytes)
{ }
friend class ArrayBuffer;
static inline void tryAllocate(unsigned numElements, unsigned elementByteSize, ArrayBufferContents&);
void transfer(ArrayBufferContents& other)
{
ASSERT(!other.m_data);
other.m_data = m_data;
other.m_sizeInBytes = m_sizeInBytes;
m_data = 0;
m_sizeInBytes = 0;
}
void* m_data;
unsigned m_sizeInBytes;
};
class ArrayBuffer : public RefCounted<ArrayBuffer> {
public:
static inline PassRefPtr<ArrayBuffer> create(unsigned numElements, unsigned elementByteSize);
static inline PassRefPtr<ArrayBuffer> create(ArrayBuffer*);
static inline PassRefPtr<ArrayBuffer> create(const void* source, unsigned byteLength);
static inline PassRefPtr<ArrayBuffer> create(ArrayBufferContents&);
inline void* data();
inline const void* data() const;
inline unsigned byteLength() const;
inline PassRefPtr<ArrayBuffer> slice(int begin, int end) const;
inline PassRefPtr<ArrayBuffer> slice(int begin) const;
void addView(ArrayBufferView*);
void removeView(ArrayBufferView*);
bool transfer(ArrayBufferContents&, Vector<ArrayBufferView*>& neuteredViews);
~ArrayBuffer() { }
private:
inline ArrayBuffer(ArrayBufferContents&);
inline PassRefPtr<ArrayBuffer> sliceImpl(unsigned begin, unsigned end) const;
inline unsigned clampIndex(int index) const;
static inline int clampValue(int x, int left, int right);
ArrayBufferContents m_contents;
ArrayBufferView* m_firstView;
};
int ArrayBuffer::clampValue(int x, int left, int right)
{
ASSERT(left <= right);
if (x < left)
......@@ -117,31 +187,6 @@ unsigned ArrayBuffer::clampIndex(int index) const
return clampValue(index, 0, currentLength);
}
bool ArrayBuffer::transfer(ArrayBufferContents& result, Vector<ArrayBufferView*>& neuteredViews)
{
RefPtr<ArrayBuffer> keepAlive(this);
if (!m_contents.m_data) {
result.m_data = 0;
return false;
}
m_contents.transfer(result);
while (m_firstView) {
ArrayBufferView* current = m_firstView;
removeView(current);
current->neuter();
neuteredViews.append(current);
}
return true;
}
ArrayBufferContents::~ArrayBufferContents()
{
WTF::fastFree(m_data);
}
void ArrayBufferContents::tryAllocate(unsigned numElements, unsigned elementByteSize, ArrayBufferContents& result)
{
// Do not allow 32-bit overflow of the total size.
......@@ -162,26 +207,13 @@ void ArrayBufferContents::tryAllocate(unsigned numElements, unsigned elementByte
result.m_data = 0;
}
void ArrayBuffer::addView(ArrayBufferView* view)
ArrayBufferContents::~ArrayBufferContents()
{
view->m_buffer = this;
view->m_prevView = 0;
view->m_nextView = m_firstView;
if (m_firstView)
m_firstView->m_prevView = view;
m_firstView = view;
WTF::fastFree(m_data);
}
void ArrayBuffer::removeView(ArrayBufferView* view)
{
ASSERT(this == view->m_buffer);
if (view->m_nextView)
view->m_nextView->m_prevView = view->m_prevView;
if (view->m_prevView)
view->m_prevView->m_nextView = view->m_nextView;
if (m_firstView == view)