[Webkit-unassigned] [Bug 120112] Typed Arrays have no public facing API

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Oct 15 13:35:53 PDT 2015


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

--- Comment #30 from Dominic Szablewski <dominic.szablewski at gmail.com> ---
Thanks for the in-depth explanation, Filip!

So it seems an additional JSObjectReleaseTypedArrayDataPtr(ctx, object, ptr) function would be absolutely necessary.

Unfortunately I understand way to little about the innards of JSC to implement the pining/retaining of the backing store myself. I'm not sure what steps exactly JSObjectGetTypedArrayDataPtr() would need to take.

On the other handJSObjectReleaseTypedArrayDataPtr() would only need to ensure that the pointer really belongs to object and then "unpin"/release the object's backing store, right?


Again, I don't see myself fit to actually implement this in JSC, but I believe the API we now arrived at is pretty solid. Namely:


Create a TypedArray:
JSObjectRef JSObjectMakeTypedArray(JSContextRef ctx, JSTypedArrayType arrayType, size_t numElements);

Query type:
JSTypedArrayType JSObjectGetTypedArrayType(JSContextRef ctx, JSObjectRef object);

Query byte length and element count:
size_t JSObjectGetTypedArrayByteLength(JSContextRef ctx, JSObjectRef object);
size_t JSObjectGetTypedArrayNumElements(JSContextRef ctx, JSObjectRef object);

Obtain a pointer to the array's data (retains the pointer):
void * JSObjectGetTypedArrayDataPtr(JSContextRef ctx, JSObjectRef object);
or
void * JSObjectGetTypedArrayDataPtr(JSContextRef ctx, JSObjectRef object, size_t &byteLength);

Release pointer to the array's data:
JSObjectReleaseTypedArrayDataPtr(ctx, JSObjectRef object, void * dataPtr);


Is there anything else the API needs to cover?

Let me also state again that I don't think a method to create a Typed Array with a pointer (that was allocated elsewhere and would not be copied) is necessary. Current users of Typed Arrays within Webkit (XMLHttpRequest, WebSockets, WebGL) seem to get along without it. I.e. always letting JSC take care of the allocation doesn't seem to be a problem.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-unassigned/attachments/20151015/ad92c520/attachment-0001.html>


More information about the webkit-unassigned mailing list