Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: src/typedarray.js

Issue 14857002: Allow pathological zero-length typed arrays. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | test/mjsunit/harmony/typedarrays.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 86
87 function CreateTypedArrayConstructor(name, elementSize, arrayId, constructor) { 87 function CreateTypedArrayConstructor(name, elementSize, arrayId, constructor) {
88 function ConstructByArrayBuffer(obj, buffer, byteOffset, length) { 88 function ConstructByArrayBuffer(obj, buffer, byteOffset, length) {
89 var offset = IS_UNDEFINED(byteOffset) ? 0 : TO_POSITIVE_INTEGER(byteOffset); 89 var offset = IS_UNDEFINED(byteOffset) ? 0 : TO_POSITIVE_INTEGER(byteOffset);
90 90
91 if (offset % elementSize !== 0) { 91 if (offset % elementSize !== 0) {
92 throw MakeRangeError("invalid_typed_array_alignment", 92 throw MakeRangeError("invalid_typed_array_alignment",
93 "start offset", name, elementSize); 93 "start offset", name, elementSize);
94 } 94 }
95 var bufferByteLength = %ArrayBufferGetByteLength(buffer); 95 var bufferByteLength = %ArrayBufferGetByteLength(buffer);
96 if (offset >= bufferByteLength) { 96 if (offset > bufferByteLength) {
97 throw MakeRangeError("invalid_typed_array_offset"); 97 throw MakeRangeError("invalid_typed_array_offset");
98 } 98 }
99 99
100 var newByteLength; 100 var newByteLength;
101 var newLength; 101 var newLength;
102 if (IS_UNDEFINED(length)) { 102 if (IS_UNDEFINED(length)) {
103 if (bufferByteLength % elementSize !== 0) { 103 if (bufferByteLength % elementSize !== 0) {
104 throw MakeRangeError("invalid_typed_array_alignment", 104 throw MakeRangeError("invalid_typed_array_alignment",
105 "byte length", name, elementSize); 105 "byte length", name, elementSize);
106 } 106 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 // arrayIds below should be synchronized with Runtime_TypedArrayInitialize. 210 // arrayIds below should be synchronized with Runtime_TypedArrayInitialize.
211 SetupTypedArray(1, "Uint8Array", global.Uint8Array, 1); 211 SetupTypedArray(1, "Uint8Array", global.Uint8Array, 1);
212 SetupTypedArray(2, "Int8Array", global.Int8Array, 1); 212 SetupTypedArray(2, "Int8Array", global.Int8Array, 1);
213 SetupTypedArray(3, "Uint16Array", global.Uint16Array, 2); 213 SetupTypedArray(3, "Uint16Array", global.Uint16Array, 2);
214 SetupTypedArray(4, "Int16Array", global.Int16Array, 2); 214 SetupTypedArray(4, "Int16Array", global.Int16Array, 2);
215 SetupTypedArray(5, "Uint32Array", global.Uint32Array, 4); 215 SetupTypedArray(5, "Uint32Array", global.Uint32Array, 4);
216 SetupTypedArray(6, "Int32Array", global.Int32Array, 4); 216 SetupTypedArray(6, "Int32Array", global.Int32Array, 4);
217 SetupTypedArray(7, "Float32Array", global.Float32Array, 4); 217 SetupTypedArray(7, "Float32Array", global.Float32Array, 4);
218 SetupTypedArray(8, "Float64Array", global.Float64Array, 8); 218 SetupTypedArray(8, "Float64Array", global.Float64Array, 8);
219 SetupTypedArray(9, "Uint8ClampedArray", global.Uint8ClampedArray, 1); 219 SetupTypedArray(9, "Uint8ClampedArray", global.Uint8ClampedArray, 1);
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/harmony/typedarrays.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698