RESOLVED FIXED 153245
[ES6] Fix various issues with TypedArrays.
https://bugs.webkit.org/show_bug.cgi?id=153245
Summary [ES6] Fix various issues with TypedArrays.
Keith Miller
Reported 2016-01-19 12:03:11 PST
[ES6] Fix various issues with TypedArrays.
Attachments
Patch (16.93 KB, patch)
2016-01-19 13:39 PST, Keith Miller
no flags
Patch (16.36 KB, patch)
2016-01-19 16:29 PST, Keith Miller
ggaren: review+
Keith Miller
Comment 1 2016-01-19 13:39:02 PST
Keith Miller
Comment 2 2016-01-19 16:29:56 PST
Geoffrey Garen
Comment 3 2016-01-19 17:04:00 PST
Comment on attachment 269307 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=269307&action=review r=me Can you add a test for .byteOffset and .buffer? > Source/JavaScriptCore/runtime/JSArrayBufferView.h:162 > + bool isNeutered() { return hasArrayBuffer() && !vector(); } What prevents FastTypedArray and OversizeTypedArray from being neutered?
Keith Miller
Comment 4 2016-01-19 17:07:35 PST
(In reply to comment #3) > Comment on attachment 269307 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=269307&action=review > > r=me > > Can you add a test for .byteOffset and .buffer? .byteOffset is covered by the test I added and I'll add a test for .buffer. > > > Source/JavaScriptCore/runtime/JSArrayBufferView.h:162 > > + bool isNeutered() { return hasArrayBuffer() && !vector(); } > > What prevents FastTypedArray and OversizeTypedArray from being neutered? JSArrayBufferViews can only be neutered from their underlying ArrayBuffer. Since those modes don't have ArrayBuffers they cannot be neutered.
Keith Miller
Comment 5 2016-01-20 11:28:25 PST
I think .buffer still has some minor issues. I'll put the changes in a different patch: https://bugs.webkit.org/show_bug.cgi?id=153281
Keith Miller
Comment 6 2016-01-20 11:32:43 PST
Darin Adler
Comment 7 2016-01-20 17:24:44 PST
Comment on attachment 269307 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=269307&action=review > Source/JavaScriptCore/runtime/JSGenericTypedArrayViewPrototypeFunctions.h:78 > - offset = exec->uncheckedArgument(1).toUInt32(exec); > + double offsetNumber = exec->uncheckedArgument(1).toInteger(exec); > if (exec->hadException()) > return JSValue::encode(jsUndefined()); > + if (offsetNumber < 0) > + return throwVMRangeError(exec, "Offset should not be negative"); > + offset = offsetNumber; This seems like a change in behavior. Will this do the right thing for numbers larger than 2^31? Do we have test cases covering that?
Keith Miller
Comment 8 2016-01-20 20:34:22 PST
Comment on attachment 269307 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=269307&action=review >> Source/JavaScriptCore/runtime/JSGenericTypedArrayViewPrototypeFunctions.h:78 >> + offset = offsetNumber; > > This seems like a change in behavior. Will this do the right thing for numbers larger than 2^31? Do we have test cases covering that? It does change behavior but that's intentional as the spec requires the change see: http://www.ecma-international.org/ecma-262/6.0/#sec-%typedarray%.prototype.set-array-offset. I'm not sure if we have a test for numbers >= 2^31, I will add one. Although, looking at this again, offset = offsetNumber will produce undefined behavior if offsetNumber >= 2^32. I thought the assignment would just round down to the nearest unsigned number, which is not the case. It should be: offset = static_cast<unsigned>(std::min(offsetNumber, static_cast<double>(std::numeric_limits<unsigned>::max())));
Keith Miller
Comment 9 2016-01-21 10:35:16 PST
(In reply to comment #8) > Comment on attachment 269307 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=269307&action=review > > >> Source/JavaScriptCore/runtime/JSGenericTypedArrayViewPrototypeFunctions.h:78 > >> + offset = offsetNumber; > > > > This seems like a change in behavior. Will this do the right thing for numbers larger than 2^31? Do we have test cases covering that? > > It does change behavior but that's intentional as the spec requires the > change see: > http://www.ecma-international.org/ecma-262/6.0/#sec-%typedarray%.prototype. > set-array-offset. I'm not sure if we have a test for numbers >= 2^31, I will > add one. Although, looking at this again, offset = offsetNumber will produce > undefined behavior if offsetNumber >= 2^32. I thought the assignment would > just round down to the nearest unsigned number, which is not the case. It > should be: > > offset = static_cast<unsigned>(std::min(offsetNumber, > static_cast<double>(std::numeric_limits<unsigned>::max()))); This should be fixed when https://bugs.webkit.org/show_bug.cgi?id=153309 lands.
Note You need to log in before you can comment on or make changes to this bug.