Changeset 197983 in webkit
- Timestamp:
- Mar 10, 2016 6:46:03 PM (8 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 5 added
- 15 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/API/APIUtils.h
r197982 r197983 1 1 /* 2 * Copyright (C) 20 09, 2013Apple Inc. All rights reserved.2 * Copyright (C) 2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 21 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 24 */ 25 25 26 #i nclude "config.h"27 # include "ArrayBuffer.h"26 #ifndef APIUtils_h 27 #define APIUtils_h 28 28 29 #include " ArrayBufferNeuteringWatchpoint.h"30 #include "JS ArrayBufferView.h"31 #include "JS CInlines.h"32 #include <wtf/RefPtr.h>29 #include "Exception.h" 30 #include "JSCJSValue.h" 31 #include "JSGlobalObjectInspectorController.h" 32 #include "JSValueRef.h" 33 33 34 namespace JSC { 34 enum class ExceptionStatus { 35 DidThrow, 36 DidNotThrow 37 }; 35 38 36 bool ArrayBuffer::transfer(ArrayBufferContents& result)39 inline ExceptionStatus handleExceptionIfNeeded(JSC::ExecState* exec, JSValueRef* returnedExceptionRef) 37 40 { 38 Ref<ArrayBuffer> protect(*this); 39 40 if (!m_contents.m_data) { 41 result.m_data = 0; 42 return false; 41 if (exec->hadException()) { 42 JSC::Exception* exception = exec->exception(); 43 if (returnedExceptionRef) 44 *returnedExceptionRef = toRef(exec, exception->value()); 45 exec->clearException(); 46 #if ENABLE(REMOTE_INSPECTOR) 47 exec->vmEntryGlobalObject()->inspectorController().reportAPIException(exec, exception); 48 #endif 49 return ExceptionStatus::DidThrow; 43 50 } 44 45 bool isNeuterable = !m_pinCount; 46 47 if (!isNeuterable) { 48 m_contents.copyTo(result); 49 if (!result.m_data) 50 return false; 51 return true; 52 } 53 54 m_contents.transfer(result); 55 for (size_t i = numberOfIncomingReferences(); i--;) { 56 JSCell* cell = incomingReferenceAt(i); 57 if (JSArrayBufferView* view = jsDynamicCast<JSArrayBufferView*>(cell)) 58 view->neuter(); 59 else if (ArrayBufferNeuteringWatchpoint* watchpoint = jsDynamicCast<ArrayBufferNeuteringWatchpoint*>(cell)) 60 watchpoint->fireAll(); 61 } 62 return true; 51 return ExceptionStatus::DidNotThrow; 63 52 } 64 53 65 } // namespace JSC 54 inline void setException(JSC::ExecState* exec, JSValueRef* returnedExceptionRef, JSC::JSValue exception) 55 { 56 if (returnedExceptionRef) 57 *returnedExceptionRef = toRef(exec, exception); 58 #if ENABLE(REMOTE_INSPECTOR) 59 exec->vmEntryGlobalObject()->inspectorController().reportAPIException(exec, JSC::Exception::create(exec->vm(), exception)); 60 #endif 61 } 66 62 63 #endif /* APIUtils_h */ -
trunk/Source/JavaScriptCore/API/JSBase.h
r194318 r197983 58 58 typedef struct OpaqueJSPropertyNameAccumulator* JSPropertyNameAccumulatorRef; 59 59 60 /*! @typedef JSTypedArrayBytesDeallocator A function used to deallocate bytes passed to a Typed Array constructor. The function should take two arguments. The first is a pointer to the bytes that were originally passed to the Typed Array constructor. The second is a pointer to additional information desired at the time the bytes are to be freed. */ 61 typedef void (*JSTypedArrayBytesDeallocator)(void* bytes, void* deallocatorContext); 60 62 61 63 /* JavaScript data types */ -
trunk/Source/JavaScriptCore/API/JSObjectRef.cpp
r197648 r197983 30 30 31 31 #include "APICast.h" 32 #include "APIUtils.h" 32 33 #include "ButterflyInlines.h" 33 34 #include "CodeBlock.h" … … 63 64 using namespace JSC; 64 65 65 enum class ExceptionStatus {66 DidThrow,67 DidNotThrow68 };69 70 static ExceptionStatus handleExceptionIfNeeded(ExecState* exec, JSValueRef* returnedExceptionRef)71 {72 if (exec->hadException()) {73 Exception* exception = exec->exception();74 if (returnedExceptionRef)75 *returnedExceptionRef = toRef(exec, exception->value());76 exec->clearException();77 #if ENABLE(REMOTE_INSPECTOR)78 exec->vmEntryGlobalObject()->inspectorController().reportAPIException(exec, exception);79 #endif80 return ExceptionStatus::DidThrow;81 }82 return ExceptionStatus::DidNotThrow;83 }84 85 66 JSClassRef JSClassCreate(const JSClassDefinition* definition) 86 67 { -
trunk/Source/JavaScriptCore/API/JSValueRef.cpp
r186279 r197983 1 1 /* 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.2 * Copyright (C) 2006, 2007, 2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 28 28 29 29 #include "APICast.h" 30 #include "APIUtils.h" 30 31 #include "DateInstance.h" 31 32 #include "Exception.h" … … 54 55 using namespace JSC; 55 56 56 enum class ExceptionStatus {57 DidThrow,58 DidNotThrow59 };60 61 static ExceptionStatus handleExceptionIfNeeded(ExecState* exec, JSValueRef* returnedExceptionRef)62 {63 if (exec->hadException()) {64 Exception* exception = exec->exception();65 if (returnedExceptionRef)66 *returnedExceptionRef = toRef(exec, exception->value());67 exec->clearException();68 #if ENABLE(REMOTE_INSPECTOR)69 exec->vmEntryGlobalObject()->inspectorController().reportAPIException(exec, exception);70 #endif71 return ExceptionStatus::DidThrow;72 }73 return ExceptionStatus::DidNotThrow;74 }75 76 57 #if PLATFORM(MAC) 77 58 static bool evernoteHackNeeded() -
trunk/Source/JavaScriptCore/API/JSValueRef.h
r182297 r197983 53 53 } JSType; 54 54 55 /*! 56 @enum JSTypedArrayType 57 @abstract A constant identifying the Typed Array type of a JSObjectRef. 58 @constant kJSTypedArrayTypeInt8Array Int8Array 59 @constant kJSTypedArrayTypeInt16Array Int16Array 60 @constant kJSTypedArrayTypeInt32Array Int32Array 61 @constant kJSTypedArrayTypeUint8Array Uint8Array 62 @constant kJSTypedArrayTypeUint8ClampedArray Uint8ClampedArray 63 @constant kJSTypedArrayTypeUint16Array Uint16Array 64 @constant kJSTypedArrayTypeUint32Array Uint32Array 65 @constant kJSTypedArrayTypeFloat32Array Float32Array 66 @constant kJSTypedArrayTypeFloat64Array Float64Array 67 @constant kJSTypedArrayTypeArrayBuffer ArrayBuffer 68 @constant kJSTypedArrayTypeNone Not a Typed Array 69 70 */ 71 typedef enum { 72 kJSTypedArrayTypeInt8Array, 73 kJSTypedArrayTypeInt16Array, 74 kJSTypedArrayTypeInt32Array, 75 kJSTypedArrayTypeUint8Array, 76 kJSTypedArrayTypeUint8ClampedArray, 77 kJSTypedArrayTypeUint16Array, 78 kJSTypedArrayTypeUint32Array, 79 kJSTypedArrayTypeFloat32Array, 80 kJSTypedArrayTypeFloat64Array, 81 kJSTypedArrayTypeArrayBuffer, 82 kJSTypedArrayTypeNone, 83 } JSTypedArrayType CF_ENUM_AVAILABLE(10_12, 10_0); 84 55 85 #ifdef __cplusplus 56 86 extern "C" { … … 147 177 */ 148 178 JS_EXPORT bool JSValueIsDate(JSContextRef ctx, JSValueRef value) CF_AVAILABLE(10_11, 9_0); 179 180 /*! 181 @function 182 @abstract Returns a JavaScript value's Typed Array type. 183 @param ctx The execution context to use. 184 @param value The JSValue whose Typed Array type to return. 185 @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. 186 @result A value of type JSTypedArrayType that identifies value's Typed Array type, or kJSTypedArrayTypeNone if the value is not a Typed Array object. 187 */ 188 JS_EXPORT JSTypedArrayType JSValueGetTypedArrayType(JSContextRef ctx, JSValueRef value, JSValueRef* exception) CF_AVAILABLE(10_12, 10_0); 149 189 150 190 /* Comparing values */ -
trunk/Source/JavaScriptCore/API/JavaScript.h
r165676 r197983 32 32 #include <JavaScriptCore/JSStringRef.h> 33 33 #include <JavaScriptCore/JSObjectRef.h> 34 #include <JavaScriptCore/JSTypedArray.h> 34 35 #include <JavaScriptCore/JSValueRef.h> 35 36 -
trunk/Source/JavaScriptCore/API/WebKitAvailability.h
r195184 r197983 68 68 #undef CF_AVAILABLE 69 69 #define CF_AVAILABLE(_mac, _ios) 70 #undef CF_ENUM_AVAILABLE 71 #define CF_ENUM_AVAILABLE(_mac, _ios) 70 72 #endif 71 73 72 74 #else 73 75 #define CF_AVAILABLE(_mac, _ios) 76 #define CF_ENUM_AVAILABLE(_mac, _ios) 74 77 #endif 75 78 -
trunk/Source/JavaScriptCore/API/tests/testapi.c
r189454 r197983 1 1 /* 2 * Copyright (C) 2006, 2015 Apple Inc. All rights reserved.2 * Copyright (C) 2006, 2015-2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 45 45 #include "GlobalContextWithFinalizerTest.h" 46 46 #include "PingPongStackOverflowTest.h" 47 #include "TypedArrayCTest.h" 47 48 48 49 #if JSC_OBJC_API_ENABLED … … 51 52 52 53 bool assertTrue(bool value, const char* message); 53 extern void JSSynchronousGarbageCollectForDebugging(JSContextRef);54 54 55 55 static JSGlobalContextRef context; … … 1114 1114 } 1115 1115 1116 1117 1116 int main(int argc, char* argv[]) 1118 1117 { … … 1138 1137 testObjectiveCAPI(); 1139 1138 #endif 1139 1140 1140 1141 1141 1142 const char *scriptPath = "testapi.js"; … … 1892 1893 } 1893 1894 1895 failed = testTypedArrayCAPI() || failed; 1894 1896 failed = testExecutionTimeLimit() || failed; 1895 1897 failed = testGlobalContextWithFinalizer() || failed; -
trunk/Source/JavaScriptCore/CMakeLists.txt
r197794 r197983 55 55 API/JSObjectRef.cpp 56 56 API/JSProfilerPrivate.cpp 57 API/JSTypedArray.cpp 57 58 API/JSScriptRef.cpp 58 59 API/JSStringRef.cpp -
trunk/Source/JavaScriptCore/ChangeLog
r197970 r197983 1 2016-03-10 Keith Miller <keith_miller@apple.com> 2 3 Typed Arrays have no public facing API 4 https://bugs.webkit.org/show_bug.cgi?id=120112 5 6 Reviewed by Geoffrey Garen. 7 8 This patch adds a new C-API (an Obj-C API will follow in the future) for Typed Arrays. The API has two sets of 9 functions. One for Typed Arrays and another for Array Buffers. This API is intended to reflect the use of Typed 10 Array objects in JS code. There is a method for each of the core TypedArray and Array Buffer methods. 11 Originally, we were planning on using a separate non-JS object as the backing store instead of a JS Array Buffer 12 but we decide to defer that idea since there was no good CF/NS API that met all the constraints we needed 13 (Discussed further below). We also wanted to want until Shared Array Buffers had reached a more finished state 14 to see what impact they might have on an API. 15 16 The API has the following Typed Array construction methods: 17 1) Create with length (the backing buffer is zero initialized). -- JSObjectMakeTypedArray 18 2) Create with an existing pointer and a destructor. -- JSObjectMakeTypedArrayFromBytesNoCopy 19 3) Create with an Array Buffer object. -- JSObjectMakeTypedArrayFromArrayBuffer 20 4) Create with an Array Buffer object with a given offset and length. -- JSObjectMakeTypedArrayFromArrayBufferWithOffset 21 22 The API has the following functions on Typed Array JSObjectRefs: 23 5) Get access to a temporary void* of the backing store's data. -- JSObjectGetTypedArrayBytesPtr 24 6) Get the length of a Typed Array object (returns 0 if it is not a Typed Array object). -- JSObjectGetTypedArrayLength 25 7) Get the byte length of a Typed Array object (returns 0 if it is not a Typed Array object). -- JSObjectGetTypedArrayByteLength 26 8) Get the byte offset of a Typed Array object (returns 0 if it is not a Typed Array object). -- JSObjectGetTypedArrayByteOffset 27 9) Get a Typed Array object's Array Buffer backing store. -- JSObjectGetTypedArrayBuffer 28 29 The API has the following Array Buffer construction method: 30 10) Create with an existing pointer and a destructor. -- JSObjectMakeArrayBufferWithBytesNoCopy 31 32 The API has the following functions on Array Buffer JSObjectRefs: 33 11) Get access to a temporary void* of the backing store's data. -- JSObjectGetArrayBufferBytesPtr 34 12) Get the byte length of an Array Buffer object (returns 0 if it is not an Array Buffer object). -- JSObjectGetArrayBufferByteLength 35 36 The API adds the following new typedefs and enumerations: 37 13) A typedef representing the function pointer type used to deallocate byte pointers provided to constructors. -- JSTypedArrayByesDeallocator 38 14) An enumeration indicating the Typed Array API type of a JSValueRef. -- JSTypedArrayType 39 40 Finally, The API has the following function to get Typed Array Types: 41 15) Get the Typed Array type of a JS value. -- JSValueGetTypedArrayType 42 43 There are a couple of things to note about these functions. Calling JSObjectGetTypedArrayBytesPtr (5) or 44 JSObjectGetArrayBufferBytesPtr (12) will pin and lock the ArrayBuffer's data for the remaining lifetime of that 45 ArrayBuffer. This is because, currently, we do not have finalizers for our Array Buffers or Typed Arrays with a 46 backing ArrayBuffer and adding one would likely incur a non-trivial cost to GC. Also, we do not have a direct 47 way to make a Typed Array from a pointer with an offset as we do not expect using offsets to be a common use 48 case of the API. 49 50 While it would have been nice to integrate our backing store with CFData or one of its subclasses, it is not 51 possible to force a CFData/CFMutableData to be both writable and have a fixed size/backing store pointer. 52 NSData is not writable and CFMutableData can have a fixed pointer if it is allocated with a non-zero capacity 53 but there is no way for us to force an existing CFMutableData into this state. 54 55 * API/APIUtils.h: Copied from Source/JavaScriptCore/runtime/ArrayBuffer.cpp. 56 (handleExceptionIfNeeded): 57 (setException): 58 * API/JSBase.h: 59 * API/JSObjectRef.cpp: 60 (handleExceptionIfNeeded): Deleted. 61 * API/JSTypedArray.cpp: Added. 62 (toJSTypedArrayType): 63 (toTypedArrayType): 64 (createTypedArray): 65 (JSValueGetTypedArrayType): 66 (JSObjectMakeTypedArray): 67 (JSObjectMakeTypedArrayWithBytesNoCopy): 68 (JSObjectMakeTypedArrayWithArrayBuffer): 69 (JSObjectMakeTypedArrayWithArrayBufferAndOffset): 70 (JSObjectGetTypedArrayBytesPtr): 71 (JSObjectGetTypedArrayLength): 72 (JSObjectGetTypedArrayByteLength): 73 (JSObjectGetTypedArrayByteOffset): 74 (JSObjectGetTypedArrayBuffer): 75 (JSObjectMakeArrayBufferWithBytesNoCopy): 76 (JSObjectGetArrayBufferBytesPtr): 77 (JSObjectGetArrayBufferByteLength): 78 * API/JSTypedArray.h: Added. 79 * API/JSValueRef.cpp: 80 (handleExceptionIfNeeded): Deleted. 81 * API/JSValueRef.h: 82 * API/JavaScript.h: 83 * API/WebKitAvailability.h: 84 * API/tests/TypedArrayCTest.cpp: Added. 85 (id): 86 (freePtr): 87 (assertEqualsAsNumber): 88 (testAccess): 89 (testConstructors): 90 (forEachTypedArrayType): 91 (testTypedArrayCAPI): 92 * API/tests/TypedArrayCTest.h: Added. 93 * API/tests/testapi.c: 94 (main): 95 * CMakeLists.txt: 96 * ForwardingHeaders/JavaScriptCore/JSTypedArray.h: Added. 97 * JavaScriptCore.xcodeproj/project.pbxproj: 98 * PlatformEfl.cmake: 99 * PlatformGTK.cmake: 100 * runtime/ArrayBuffer.cpp: 101 (JSC::ArrayBuffer::transfer): 102 * runtime/ArrayBuffer.h: 103 (JSC::arrayBufferDestructorNull): 104 (JSC::arrayBufferDestructorDefault): 105 (JSC::ArrayBufferContents::ArrayBufferContents): 106 (JSC::ArrayBufferContents::transfer): 107 (JSC::ArrayBuffer::createAdopted): 108 (JSC::ArrayBuffer::createFromBytes): 109 (JSC::ArrayBuffer::ArrayBuffer): 110 (JSC::ArrayBuffer::pinAndLock): 111 (JSC::ArrayBufferContents::tryAllocate): 112 (JSC::ArrayBufferContents::~ArrayBufferContents): 113 * shell/PlatformWin.cmake: 114 1 115 2016-03-10 Saam barati <sbarati@apple.com> 2 116 -
trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r197796 r197983 1178 1178 52C952B719A289850069B386 /* TypeProfiler.h in Headers */ = {isa = PBXBuildFile; fileRef = 52C952B619A289850069B386 /* TypeProfiler.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1179 1179 52C952B919A28A1C0069B386 /* TypeProfiler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 52C952B819A28A1C0069B386 /* TypeProfiler.cpp */; }; 1180 53486BB71C1795C300F6F3AF /* JSTypedArray.h in Headers */ = {isa = PBXBuildFile; fileRef = 53486BB61C1795C300F6F3AF /* JSTypedArray.h */; settings = {ATTRIBUTES = (Public, ); }; }; 1181 53486BBB1C18E84500F6F3AF /* JSTypedArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53486BBA1C18E84500F6F3AF /* JSTypedArray.cpp */; }; 1182 534902851C7276B70012BCB8 /* TypedArrayCTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 534902821C7242C80012BCB8 /* TypedArrayCTest.cpp */; }; 1180 1183 534C457C1BC72411007476A7 /* JSTypedArrayViewConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = 534C457B1BC72411007476A7 /* JSTypedArrayViewConstructor.h */; }; 1181 1184 534C457E1BC72549007476A7 /* JSTypedArrayViewConstructor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 534C457D1BC72549007476A7 /* JSTypedArrayViewConstructor.cpp */; }; 1185 53529A4C1C457B75000B49C6 /* APIUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 53529A4B1C457B75000B49C6 /* APIUtils.h */; }; 1182 1186 5370B4F51BF26202005C40FC /* AdaptiveInferredPropertyValueWatchpointBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5370B4F31BF25EA2005C40FC /* AdaptiveInferredPropertyValueWatchpointBase.cpp */; }; 1183 1187 5370B4F61BF26205005C40FC /* AdaptiveInferredPropertyValueWatchpointBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 5370B4F41BF25EA2005C40FC /* AdaptiveInferredPropertyValueWatchpointBase.h */; }; … … 3301 3305 52C952B619A289850069B386 /* TypeProfiler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TypeProfiler.h; sourceTree = "<group>"; }; 3302 3306 52C952B819A28A1C0069B386 /* TypeProfiler.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TypeProfiler.cpp; sourceTree = "<group>"; }; 3307 53486BB61C1795C300F6F3AF /* JSTypedArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSTypedArray.h; sourceTree = "<group>"; }; 3308 53486BBA1C18E84500F6F3AF /* JSTypedArray.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSTypedArray.cpp; sourceTree = "<group>"; }; 3309 534902821C7242C80012BCB8 /* TypedArrayCTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TypedArrayCTest.cpp; path = API/tests/TypedArrayCTest.cpp; sourceTree = "<group>"; }; 3310 534902831C7242C80012BCB8 /* TypedArrayCTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TypedArrayCTest.h; path = API/tests/TypedArrayCTest.h; sourceTree = "<group>"; }; 3303 3311 534C457A1BC703DC007476A7 /* TypedArrayConstructor.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = TypedArrayConstructor.js; sourceTree = "<group>"; }; 3304 3312 534C457B1BC72411007476A7 /* JSTypedArrayViewConstructor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSTypedArrayViewConstructor.h; sourceTree = "<group>"; }; 3305 3313 534C457D1BC72549007476A7 /* JSTypedArrayViewConstructor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSTypedArrayViewConstructor.cpp; sourceTree = "<group>"; }; 3314 53529A4B1C457B75000B49C6 /* APIUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIUtils.h; sourceTree = "<group>"; }; 3306 3315 5370B4F31BF25EA2005C40FC /* AdaptiveInferredPropertyValueWatchpointBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AdaptiveInferredPropertyValueWatchpointBase.cpp; sourceTree = "<group>"; }; 3307 3316 5370B4F41BF25EA2005C40FC /* AdaptiveInferredPropertyValueWatchpointBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AdaptiveInferredPropertyValueWatchpointBase.h; sourceTree = "<group>"; }; … … 4897 4906 FEF040521AAEC4ED00BD28B0 /* CompareAndSwapTest.h */, 4898 4907 C29ECB021804D0ED00D2CBB4 /* CurrentThisInsideBlockGetterTest.h */, 4908 534902821C7242C80012BCB8 /* TypedArrayCTest.cpp */, 4909 534902831C7242C80012BCB8 /* TypedArrayCTest.h */, 4899 4910 C29ECB011804D0ED00D2CBB4 /* CurrentThisInsideBlockGetterTest.mm */, 4900 4911 C203281E1981979D0088B499 /* CustomGlobalObjectClassTest.c */, … … 5184 5195 C211B574176A224D000E2A23 /* APICallbackFunction.h */, 5185 5196 1482B78A0A4305AB00517CFC /* APICast.h */, 5197 53529A4B1C457B75000B49C6 /* APIUtils.h */, 5186 5198 1CAA8B4A0D32C39A0041BCFF /* JavaScript.h */, 5187 5199 1CAA8B4B0D32C39A0041BCFF /* JavaScriptCore.h */, … … 5232 5244 146AAB2A0B66A84900E55F16 /* JSStringRefCF.h */, 5233 5245 1A28D4A7177B71C80007FA3C /* JSStringRefPrivate.h */, 5246 53486BBA1C18E84500F6F3AF /* JSTypedArray.cpp */, 5247 53486BB61C1795C300F6F3AF /* JSTypedArray.h */, 5234 5248 86E3C606167BAB87006D760A /* JSValue.h */, 5235 5249 86E3C60D167BAB87006D760A /* JSValue.mm */, … … 7111 7125 0F5A52D017ADD717008ECB2D /* CopyToken.h in Headers */, 7112 7126 C2239D1816262BDD005AC5FD /* CopyVisitor.h in Headers */, 7127 53486BB71C1795C300F6F3AF /* JSTypedArray.h in Headers */, 7113 7128 C2239D1916262BDD005AC5FD /* CopyVisitorInlines.h in Headers */, 7114 7129 C218D1401655CFD50062BB81 /* CopyWorkList.h in Headers */, … … 7184 7199 0F04396E1B03DC0B009598B7 /* DFGCombinedLiveness.h in Headers */, 7185 7200 0F7B294D14C3CD4C007C3DB1 /* DFGCommon.h in Headers */, 7201 53529A4C1C457B75000B49C6 /* APIUtils.h in Headers */, 7186 7202 0FEA0A32170D40BF00BB722C /* DFGCommonData.h in Headers */, 7187 7203 0F725CB01C506D3B00AD943A /* B3FoldPathConstants.h in Headers */, … … 8559 8575 65570F5A1AA4C3EA009B3C23 /* Regress141275.mm in Sources */, 8560 8576 FEB51F6C1A97B688001F921C /* Regress141809.mm in Sources */, 8577 534902851C7276B70012BCB8 /* TypedArrayCTest.cpp in Sources */, 8561 8578 1440F6100A4F85670005F061 /* testapi.c in Sources */, 8562 8579 86D2221A167EF9440024C804 /* testapi.mm in Sources */, … … 8589 8606 0FEC85781BDACDC70080FF74 /* AirGenerate.cpp in Sources */, 8590 8607 0FEC85931BDB1E100080FF74 /* AirGenerated.cpp in Sources */, 8608 53486BBB1C18E84500F6F3AF /* JSTypedArray.cpp in Sources */, 8591 8609 0FEC857B1BDACDC70080FF74 /* AirHandleCalleeSaves.cpp in Sources */, 8592 8610 0FEC857D1BDACDC70080FF74 /* AirInsertionSet.cpp in Sources */, -
trunk/Source/JavaScriptCore/PlatformEfl.cmake
r191165 r197983 16 16 API/JSStringRef.h 17 17 API/JSValueRef.h 18 API/JSTypedArray.h 18 19 API/WebKitAvailability.h 19 20 DESTINATION "${HEADER_INSTALL_DIR}/JavaScriptCore" -
trunk/Source/JavaScriptCore/PlatformGTK.cmake
r196796 r197983 25 25 API/JSObjectRef.h 26 26 API/JSStringRef.h 27 API/JSTypedArray.h 27 28 API/JSValueRef.h 28 29 API/WebKitAvailability.h -
trunk/Source/JavaScriptCore/runtime/ArrayBuffer.cpp
r195360 r197983 43 43 } 44 44 45 bool isNeuterable = !m_pinCount ;45 bool isNeuterable = !m_pinCount && !m_locked; 46 46 47 47 if (!isNeuterable) { -
trunk/Source/JavaScriptCore/runtime/ArrayBuffer.h
r163444 r197983 1 1 /* 2 * Copyright (C) 2009, 2013 Apple Inc. All rights reserved.2 * Copyright (C) 2009, 2013, 2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 29 29 #include "GCIncomingRefCounted.h" 30 30 #include "Weak.h" 31 #include <functional> 31 32 #include <wtf/PassRefPtr.h> 32 33 #include <wtf/StdLibExtras.h> … … 38 39 class ArrayBufferView; 39 40 class JSArrayBuffer; 41 42 typedef std::function<void(void*)> ArrayBufferDestructorFunction; 43 static void arrayBufferDestructorNull(void*) { } 44 static void arrayBufferDestructorDefault(void* p) { fastFree(p); } 40 45 41 46 class ArrayBufferContents { … … 43 48 public: 44 49 ArrayBufferContents() 45 : m_data(0) 50 : m_destructor(arrayBufferDestructorNull) 51 , m_data(nullptr) 46 52 , m_sizeInBytes(0) 47 53 { } … … 53 59 54 60 private: 55 ArrayBufferContents(void* data, unsigned sizeInBytes )61 ArrayBufferContents(void* data, unsigned sizeInBytes, ArrayBufferDestructorFunction&& destructor) 56 62 : m_data(data) 57 63 , m_sizeInBytes(sizeInBytes) 58 { } 64 { 65 m_destructor = WTFMove(destructor); 66 } 59 67 60 68 friend class ArrayBuffer; … … 69 77 { 70 78 ASSERT(!other.m_data); 71 other.m_data = m_data; 72 other.m_sizeInBytes = m_sizeInBytes; 73 m_data = 0; 74 m_sizeInBytes = 0; 79 std::swap(m_data, other.m_data); 80 std::swap(m_sizeInBytes, other.m_sizeInBytes); 81 std::swap(m_destructor, other.m_destructor); 75 82 } 76 83 … … 85 92 } 86 93 94 ArrayBufferDestructorFunction m_destructor; 87 95 void* m_data; 88 96 unsigned m_sizeInBytes; … … 96 104 static inline PassRefPtr<ArrayBuffer> create(ArrayBufferContents&); 97 105 static inline PassRefPtr<ArrayBuffer> createAdopted(const void* data, unsigned byteLength); 106 static inline PassRefPtr<ArrayBuffer> createFromBytes(const void* data, unsigned byteLength, ArrayBufferDestructorFunction&&); 98 107 99 108 // Only for use by Uint8ClampedArray::createUninitialized and SharedBuffer::createArrayBuffer. … … 111 120 inline void pin(); 112 121 inline void unpin(); 122 inline void pinAndLock(); 113 123 114 124 JS_EXPORT_PRIVATE bool transfer(ArrayBufferContents&); … … 127 137 static inline int clampValue(int x, int left, int right); 128 138 129 unsigned m_pinCount;130 139 ArrayBufferContents m_contents; 140 unsigned m_pinCount : 31; 141 bool m_locked : 1; // m_locked == true means that some API user fetched m_contents directly from a TypedArray object. 131 142 132 143 public: … … 173 184 PassRefPtr<ArrayBuffer> ArrayBuffer::createAdopted(const void* data, unsigned byteLength) 174 185 { 175 ArrayBufferContents contents(const_cast<void*>(data), byteLength); 186 return createFromBytes(data, byteLength, WTFMove(arrayBufferDestructorDefault)); 187 } 188 189 PassRefPtr<ArrayBuffer> ArrayBuffer::createFromBytes(const void* data, unsigned byteLength, ArrayBufferDestructorFunction&& destructor) 190 { 191 ArrayBufferContents contents(const_cast<void*>(data), byteLength, WTFMove(destructor)); 176 192 return create(contents); 177 193 } … … 193 209 ArrayBuffer::ArrayBuffer(ArrayBufferContents& contents) 194 210 : m_pinCount(0) 211 , m_locked(false) 195 212 { 196 213 contents.transfer(m_contents); … … 249 266 { 250 267 m_pinCount--; 268 } 269 270 void ArrayBuffer::pinAndLock() 271 { 272 m_locked = true; 251 273 } 252 274 … … 272 294 if (allocationSucceeded) { 273 295 result.m_sizeInBytes = numElements * elementByteSize; 296 result.m_destructor = arrayBufferDestructorDefault; 274 297 return; 275 298 } … … 279 302 ArrayBufferContents::~ArrayBufferContents() 280 303 { 281 WTF::fastFree(m_data);304 m_destructor(m_data); 282 305 } 283 306 -
trunk/Source/JavaScriptCore/shell/PlatformWin.cmake
r194705 r197983 35 35 ../API/tests/PingPongStackOverflowTest.cpp 36 36 ../API/tests/testapi.c 37 ../API/tests/TypedArrayCTest.cpp 37 38 ) 38 39 set_source_files_properties(../API/tests/CustomGlobalObjectClassTest.c PROPERTIES COMPILE_FLAGS "/TP /MT")
Note: See TracChangeset
for help on using the changeset viewer.