RESOLVED FIXED 150216
Fix some issues with TypedArrays
https://bugs.webkit.org/show_bug.cgi?id=150216
Summary Fix some issues with TypedArrays
Keith Miller
Reported 2015-10-15 17:37:20 PDT
Fix some issues with TypedArrays
Attachments
Patch (20.77 KB, patch)
2015-10-16 10:24 PDT, Keith Miller
no flags
Patch (23.61 KB, patch)
2015-10-16 10:51 PDT, Keith Miller
no flags
Benchmark Results (62.92 KB, text/plain)
2015-10-16 11:35 PDT, Keith Miller
no flags
Patch (23.72 KB, patch)
2015-10-16 13:54 PDT, Keith Miller
ggaren: review+
Keith Miller
Comment 1 2015-10-16 10:24:37 PDT
Keith Miller
Comment 2 2015-10-16 10:51:39 PDT
Michael Saboff
Comment 3 2015-10-16 11:21:13 PDT
Comment on attachment 263291 [details] Patch r=me
Keith Miller
Comment 4 2015-10-16 11:35:15 PDT
Created attachment 263300 [details] Benchmark Results Benchmark results since adding iterators during construction in the DFG may have slowed things down (they didn't). Note: "string-unpack-code" does not use TypedArrays and subsequent reruns showed no performance difference.
Keith Miller
Comment 5 2015-10-16 11:37:50 PDT
Geoffrey Garen
Comment 6 2015-10-16 12:12:10 PDT
Comment on attachment 263291 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=263291&action=review > Source/JavaScriptCore/dfg/DFGOperations.cpp:609 > + return bitwise_cast<char*>(constructGenericTypedArrayViewWithFirstArgument<JSInt8Array>(exec, structure, encodedValue)); reinterpret_cast<char*> is better here because it is slightly more type-safe. Cast to char* is allowed despite strict aliasing rules because char* is considered to alias everything, so cast to char* is, from the aliasing point of view, just a case to a more generic type. > Source/JavaScriptCore/runtime/JSGenericTypedArrayViewConstructorInlines.h:118 > +template<typename ViewClass, bool checkForOtherArguments = false> > +static JSObject* constructGenericTypedArrayViewWithFirstArgument(ExecState* exec, Structure* structure, EncodedJSValue firstArgument) Boolean parameters read poorly at the call site. Nobody knows what "create(true, false, true)" means. For future reference, WebKit style suggests limiting or eliminating boolean parameters. In this case, I think it is better to eliminate the checkForOtherArguments parameter. It tightly couples this function to a single caller (the constructor callback), which is usually a programming anti-pattern. How about this: template<typename ViewClass> static JSObject* constructGenericTypedArrayView(ExecState* exec, EncodedJSValue argument, unsigned offset, const WTF::Optional<unsigned>& length) { ... } All of our callers know their offset (usually it's zero, while the constructor needs to check its arguments). Most of our caller don't supply a length while the constructor sometimes does, so we have Optional for that. This pushes the calculation and conversion of constructor input arguments back up into the constructor function, which is where it belongs. Technically, this adds one branch to some DFG typed array allocations. I don't think that will matter.
Keith Miller
Comment 7 2015-10-16 12:47:41 PDT
Reverted r191190 for reason: Patch needs some design changes. Committed r191193: <http://trac.webkit.org/changeset/191193>
Keith Miller
Comment 8 2015-10-16 13:54:00 PDT
Geoffrey Garen
Comment 9 2015-10-16 14:35:09 PDT
Comment on attachment 263324 [details] Patch r=me
Keith Miller
Comment 10 2015-10-16 14:40:56 PDT
Note You need to log in before you can comment on or make changes to this bug.