Move TypedArray implementation into JSC
https://bugs.webkit.org/show_bug.cgi?id=119489

Reviewed by Filip Pizlo.

Source/JavaScriptCore:

Move TypedArray implementation into JSC in advance of re-implementation

* GNUmakefile.list.am:
* JSCTypedArrayStubs.h:
* JavaScriptCore.xcodeproj/project.pbxproj:
* runtime/ArrayBuffer.cpp: Renamed from Source/WTF/wtf/ArrayBuffer.cpp.
(JSC::ArrayBuffer::transfer):
(JSC::ArrayBuffer::addView):
(JSC::ArrayBuffer::removeView):
* runtime/ArrayBuffer.h: Renamed from Source/WTF/wtf/ArrayBuffer.h.
(JSC::ArrayBufferContents::ArrayBufferContents):
(JSC::ArrayBufferContents::data):
(JSC::ArrayBufferContents::sizeInBytes):
(JSC::ArrayBufferContents::transfer):
(JSC::ArrayBufferContents::copyTo):
(JSC::ArrayBuffer::isNeutered):
(JSC::ArrayBuffer::~ArrayBuffer):
(JSC::ArrayBuffer::clampValue):
(JSC::ArrayBuffer::create):
(JSC::ArrayBuffer::createUninitialized):
(JSC::ArrayBuffer::ArrayBuffer):
(JSC::ArrayBuffer::data):
(JSC::ArrayBuffer::byteLength):
(JSC::ArrayBuffer::slice):
(JSC::ArrayBuffer::sliceImpl):
(JSC::ArrayBuffer::clampIndex):
(JSC::ArrayBufferContents::tryAllocate):
(JSC::ArrayBufferContents::~ArrayBufferContents):
* runtime/ArrayBufferView.cpp: Renamed from Source/WTF/wtf/ArrayBufferView.cpp.
(JSC::ArrayBufferView::ArrayBufferView):
(JSC::ArrayBufferView::~ArrayBufferView):
(JSC::ArrayBufferView::neuter):
* runtime/ArrayBufferView.h: Renamed from Source/WTF/wtf/ArrayBufferView.h.
(JSC::ArrayBufferView::buffer):
(JSC::ArrayBufferView::baseAddress):
(JSC::ArrayBufferView::byteOffset):
(JSC::ArrayBufferView::setNeuterable):
(JSC::ArrayBufferView::isNeuterable):
(JSC::ArrayBufferView::verifySubRange):
(JSC::ArrayBufferView::clampOffsetAndNumElements):
(JSC::ArrayBufferView::setImpl):
(JSC::ArrayBufferView::setRangeImpl):
(JSC::ArrayBufferView::zeroRangeImpl):
(JSC::ArrayBufferView::calculateOffsetAndLength):
* runtime/Float32Array.h: Renamed from Source/WTF/wtf/Float32Array.h.
(JSC::Float32Array::set):
(JSC::Float32Array::getType):
(JSC::Float32Array::create):
(JSC::Float32Array::createUninitialized):
(JSC::Float32Array::Float32Array):
(JSC::Float32Array::subarray):
* runtime/Float64Array.h: Renamed from Source/WTF/wtf/Float64Array.h.
(JSC::Float64Array::set):
(JSC::Float64Array::getType):
(JSC::Float64Array::create):
(JSC::Float64Array::createUninitialized):
(JSC::Float64Array::Float64Array):
(JSC::Float64Array::subarray):
* runtime/Int16Array.h: Renamed from Source/WTF/wtf/Int16Array.h.
(JSC::Int16Array::getType):
(JSC::Int16Array::create):
(JSC::Int16Array::createUninitialized):
(JSC::Int16Array::Int16Array):
(JSC::Int16Array::subarray):
* runtime/Int32Array.h: Renamed from Source/WTF/wtf/Int32Array.h.
(JSC::Int32Array::getType):
(JSC::Int32Array::create):
(JSC::Int32Array::createUninitialized):
(JSC::Int32Array::Int32Array):
(JSC::Int32Array::subarray):
* runtime/Int8Array.h: Renamed from Source/WTF/wtf/Int8Array.h.
(JSC::Int8Array::getType):
(JSC::Int8Array::create):
(JSC::Int8Array::createUninitialized):
(JSC::Int8Array::Int8Array):
(JSC::Int8Array::subarray):
* runtime/IntegralTypedArrayBase.h: Renamed from Source/WTF/wtf/IntegralTypedArrayBase.h.
(JSC::IntegralTypedArrayBase::set):
(JSC::IntegralTypedArrayBase::IntegralTypedArrayBase):
* runtime/TypedArrayBase.h: Renamed from Source/WTF/wtf/TypedArrayBase.h.
(JSC::TypedArrayBase::data):
(JSC::TypedArrayBase::set):
(JSC::TypedArrayBase::setRange):
(JSC::TypedArrayBase::zeroRange):
(JSC::TypedArrayBase::length):
(JSC::TypedArrayBase::byteLength):
(JSC::TypedArrayBase::item):
(JSC::TypedArrayBase::checkInboundData):
(JSC::TypedArrayBase::TypedArrayBase):
(JSC::TypedArrayBase::create):
(JSC::TypedArrayBase::createUninitialized):
(JSC::TypedArrayBase::subarrayImpl):
(JSC::TypedArrayBase::neuter):
* runtime/Uint16Array.h: Renamed from Source/WTF/wtf/Uint16Array.h.
(JSC::Uint16Array::getType):
(JSC::Uint16Array::create):
(JSC::Uint16Array::createUninitialized):
(JSC::Uint16Array::Uint16Array):
(JSC::Uint16Array::subarray):
* runtime/Uint32Array.h: Renamed from Source/WTF/wtf/Uint32Array.h.
(JSC::Uint32Array::getType):
(JSC::Uint32Array::create):
(JSC::Uint32Array::createUninitialized):
(JSC::Uint32Array::Uint32Array):
(JSC::Uint32Array::subarray):
* runtime/Uint8Array.h: Renamed from Source/WTF/wtf/Uint8Array.h.
(JSC::Uint8Array::getType):
(JSC::Uint8Array::create):
(JSC::Uint8Array::createUninitialized):
(JSC::Uint8Array::Uint8Array):
(JSC::Uint8Array::subarray):
* runtime/Uint8ClampedArray.h: Renamed from Source/WTF/wtf/Uint8ClampedArray.h.
(JSC::Uint8ClampedArray::getType):
(JSC::Uint8ClampedArray::create):
(JSC::Uint8ClampedArray::createUninitialized):
(JSC::Uint8ClampedArray::zeroFill):
(JSC::Uint8ClampedArray::set):
(JSC::Uint8ClampedArray::Uint8ClampedArray):
(JSC::Uint8ClampedArray::subarray):
* runtime/VM.h:

Source/WebCore:

Update WebCore for new location of TypedArray implementation.

* ForwardingHeaders/runtime/ArrayBuffer.h: Added.
* ForwardingHeaders/runtime/ArrayBufferView.h: Added.
* ForwardingHeaders/runtime/Float32Array.h: Added.
* ForwardingHeaders/runtime/Float64Array.h: Added.
* ForwardingHeaders/runtime/Int16Array.h: Added.
* ForwardingHeaders/runtime/Int32Array.h: Added.
* ForwardingHeaders/runtime/Int8Array.h: Added.
* ForwardingHeaders/runtime/IntegralTypedArrayBase.h: Added.
* ForwardingHeaders/runtime/TypedArrayBase.h: Added.
* ForwardingHeaders/runtime/Uint16Array.h: Added.
* ForwardingHeaders/runtime/Uint32Array.h: Added.
* ForwardingHeaders/runtime/Uint8Array.h: Added.
* ForwardingHeaders/runtime/Uint8ClampedArray.h: Added.
* Modules/webaudio/AnalyserNode.h:
(WebCore::AnalyserNode::getFloatFrequencyData):
(WebCore::AnalyserNode::getByteFrequencyData):
(WebCore::AnalyserNode::getByteTimeDomainData):
* Modules/webaudio/AsyncAudioDecoder.cpp:
* Modules/webaudio/AsyncAudioDecoder.h:
(WebCore::AsyncAudioDecoder::DecodingTask::audioData):
* Modules/webaudio/AudioBuffer.h:
* Modules/webaudio/AudioContext.cpp:
* Modules/webaudio/AudioParam.h:
* Modules/webaudio/AudioParamTimeline.h:
* Modules/webaudio/PeriodicWave.h:
* Modules/webaudio/RealtimeAnalyser.cpp:
* Modules/webaudio/RealtimeAnalyser.h:
* Modules/webaudio/ScriptProcessorNode.cpp:
* Modules/webaudio/WaveShaperProcessor.h:
* Modules/websockets/ThreadableWebSocketChannel.h:
* Modules/websockets/WebSocket.cpp:
* Modules/websockets/WebSocket.h:
* Modules/websockets/WebSocketChannel.cpp:
* Modules/websockets/WebSocketChannel.h:
* Modules/websockets/WorkerThreadableWebSocketChannel.cpp:
* Modules/websockets/WorkerThreadableWebSocketChannel.h:
* WebCore.exp.in:
* bindings/js/JSArrayBufferCustom.cpp:
* bindings/js/JSArrayBufferViewHelper.h:
* bindings/js/JSAudioContextCustom.cpp:
* bindings/js/JSCryptoCustom.cpp:
* bindings/js/JSDictionary.h:
* bindings/js/JSFileReaderCustom.cpp:
* bindings/js/JSWebGLRenderingContextCustom.cpp:
* bindings/js/JSXMLHttpRequestCustom.cpp:
* bindings/js/SerializedScriptValue.cpp:
(WebCore::SerializedScriptValue::transferArrayBuffers):
* bindings/js/SerializedScriptValue.h:
* bindings/scripts/CodeGeneratorJS.pm:
(AddIncludesForType):
(GenerateHeader):
(NativeToJSValue):
* dom/MessageEvent.h:
* fileapi/FileReader.cpp:
* fileapi/FileReader.h:
* fileapi/FileReaderLoader.cpp:
* fileapi/FileReaderLoader.h:
* fileapi/FileReaderSync.cpp:
* fileapi/FileReaderSync.h:
* fileapi/WebKitBlobBuilder.cpp:
* fileapi/WebKitBlobBuilder.h:
* html/HTMLMediaElement.cpp:
* html/ImageData.h:
* html/canvas/ArrayBuffer.idl:
* html/canvas/ArrayBufferView.idl:
* html/canvas/CanvasRenderingContext2D.cpp:
* html/canvas/DataView.h:
* html/canvas/Float32Array.idl:
* html/canvas/Float64Array.idl:
* html/canvas/Int16Array.idl:
* html/canvas/Int32Array.idl:
* html/canvas/Int8Array.idl:
* html/canvas/Uint16Array.idl:
* html/canvas/Uint32Array.idl:
* html/canvas/Uint8Array.idl:
* html/canvas/Uint8ClampedArray.idl:
* html/canvas/WebGLBuffer.h:
(WebCore::WebGLBuffer::elementArrayBuffer):
* html/canvas/WebGLGetInfo.cpp:
* html/canvas/WebGLGetInfo.h:
* html/canvas/WebGLRenderingContext.cpp:
* html/canvas/WebGLRenderingContext.h:
* inspector/InspectorMemoryAgent.cpp:
* page/Crypto.cpp:
* page/Crypto.h:
* platform/graphics/GraphicsContext3D.cpp:
* platform/graphics/ImageBuffer.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
* platform/graphics/cg/ImageBufferDataCG.h:
* platform/graphics/filters/FEBlend.cpp:
* platform/graphics/filters/FEColorMatrix.cpp:
* platform/graphics/filters/FEComponentTransfer.cpp:
* platform/graphics/filters/FEComposite.cpp:
* platform/graphics/filters/FEConvolveMatrix.cpp:
* platform/graphics/filters/FECustomFilter.cpp:
* platform/graphics/filters/FEDisplacementMap.cpp:
* platform/graphics/filters/FEDropShadow.cpp:
* platform/graphics/filters/FEGaussianBlur.cpp:
* platform/graphics/filters/FELighting.h:
* platform/graphics/filters/FEMorphology.cpp:
* platform/graphics/filters/FETurbulence.cpp:
* platform/graphics/filters/FilterEffect.cpp:
* platform/graphics/filters/FilterEffect.h:
* platform/graphics/mac/GraphicsContext3DMac.mm:
* platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
* testing/Internals.h:
* xml/XMLHttpRequest.cpp:
* xml/XMLHttpRequest.h:
(WebCore::XMLHttpRequest::optionalResponseArrayBuffer):

Source/WTF:

Remove TypedArray implementation from WTF

* GNUmakefile.list.am:
* WTF.xcodeproj/project.pbxproj:
* wtf/Forward.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@153728 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/JavaScriptCore/runtime/Int16Array.h b/Source/JavaScriptCore/runtime/Int16Array.h
new file mode 100644
index 0000000..c466ae4
--- /dev/null
+++ b/Source/JavaScriptCore/runtime/Int16Array.h
@@ -0,0 +1,102 @@
+/*
+ * 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. 
+ */
+
+#ifndef Int16Array_h
+#define Int16Array_h
+
+#include "IntegralTypedArrayBase.h"
+
+namespace JSC {
+
+class ArrayBuffer;
+
+class Int16Array : public IntegralTypedArrayBase<int16_t> {
+public:
+    static inline PassRefPtr<Int16Array> create(unsigned length);
+    static inline PassRefPtr<Int16Array> create(const int16_t* array, unsigned length);
+    static inline PassRefPtr<Int16Array> create(PassRefPtr<ArrayBuffer>, unsigned byteOffset, unsigned length);
+
+    // Should only be used when it is known the entire array will be filled. Do
+    // not return these results directly to JavaScript without filling first.
+    static inline PassRefPtr<Int16Array> createUninitialized(unsigned length);
+
+    using TypedArrayBase<int16_t>::set;
+    using IntegralTypedArrayBase<int16_t>::set;
+
+    inline PassRefPtr<Int16Array> subarray(int start) const;
+    inline PassRefPtr<Int16Array> subarray(int start, int end) const;
+
+    virtual ViewType getType() const
+    {
+        return TypeInt16;
+    }
+
+private:
+    inline Int16Array(PassRefPtr<ArrayBuffer>, unsigned byteOffset, unsigned length);
+
+    // Make constructor visible to superclass.
+    friend class TypedArrayBase<int16_t>;
+};
+
+PassRefPtr<Int16Array> Int16Array::create(unsigned length)
+{
+    return TypedArrayBase<int16_t>::create<Int16Array>(length);
+}
+
+PassRefPtr<Int16Array> Int16Array::create(const int16_t* array, unsigned length)
+{
+    return TypedArrayBase<int16_t>::create<Int16Array>(array, length);
+}
+
+PassRefPtr<Int16Array> Int16Array::create(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length)
+{
+    return TypedArrayBase<int16_t>::create<Int16Array>(buffer, byteOffset, length);
+}
+
+PassRefPtr<Int16Array> Int16Array::createUninitialized(unsigned length)
+{
+    return TypedArrayBase<int16_t>::createUninitialized<Int16Array>(length);
+}
+
+Int16Array::Int16Array(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length)
+    : IntegralTypedArrayBase<int16_t>(buffer, byteOffset, length)
+{
+}
+
+PassRefPtr<Int16Array> Int16Array::subarray(int start) const
+{
+    return subarray(start, length());
+}
+
+PassRefPtr<Int16Array> Int16Array::subarray(int start, int end) const
+{
+    return subarrayImpl<Int16Array>(start, end);
+}
+
+} // namespace JSC
+
+using JSC::Int16Array;
+
+#endif // Int16Array_h