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

Side by Side Diff: src/typedarray.js

Issue 197713004: Merged r19862 into 3.23 branch. (Closed) Base URL: https://v8.googlecode.com/svn/branches/3.23
Patch Set: Created 6 years, 9 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 | « src/runtime.cc ('k') | src/version.cc » ('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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 FUNCTION(4, Int16Array, 2) 42 FUNCTION(4, Int16Array, 2)
43 FUNCTION(5, Uint32Array, 4) 43 FUNCTION(5, Uint32Array, 4)
44 FUNCTION(6, Int32Array, 4) 44 FUNCTION(6, Int32Array, 4)
45 FUNCTION(7, Float32Array, 4) 45 FUNCTION(7, Float32Array, 4)
46 FUNCTION(8, Float64Array, 8) 46 FUNCTION(8, Float64Array, 8)
47 FUNCTION(9, Uint8ClampedArray, 1) 47 FUNCTION(9, Uint8ClampedArray, 1)
48 endmacro 48 endmacro
49 49
50 macro TYPED_ARRAY_CONSTRUCTOR(ARRAY_ID, NAME, ELEMENT_SIZE) 50 macro TYPED_ARRAY_CONSTRUCTOR(ARRAY_ID, NAME, ELEMENT_SIZE)
51 function NAMEConstructByArrayBuffer(obj, buffer, byteOffset, length) { 51 function NAMEConstructByArrayBuffer(obj, buffer, byteOffset, length) {
52 var bufferByteLength = buffer.byteLength; 52 var bufferByteLength = %ArrayBufferGetByteLength(buffer);
53 var offset; 53 var offset;
54 if (IS_UNDEFINED(byteOffset)) { 54 if (IS_UNDEFINED(byteOffset)) {
55 offset = 0; 55 offset = 0;
56 } else { 56 } else {
57 offset = ToPositiveInteger(byteOffset, "invalid_typed_array_length"); 57 offset = ToPositiveInteger(byteOffset, "invalid_typed_array_length");
58 58
59 if (offset % ELEMENT_SIZE !== 0) { 59 if (offset % ELEMENT_SIZE !== 0) {
60 throw MakeRangeError("invalid_typed_array_alignment", 60 throw MakeRangeError("invalid_typed_array_alignment",
61 "start offset", "NAME", ELEMENT_SIZE); 61 "start offset", "NAME", ELEMENT_SIZE);
62 } 62 }
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 306
307 // --------------------------- DataView ----------------------------- 307 // --------------------------- DataView -----------------------------
308 308
309 var $DataView = global.DataView; 309 var $DataView = global.DataView;
310 310
311 function DataViewConstructor(buffer, byteOffset, byteLength) { // length = 3 311 function DataViewConstructor(buffer, byteOffset, byteLength) { // length = 3
312 if (%_IsConstructCall()) { 312 if (%_IsConstructCall()) {
313 if (!IS_ARRAYBUFFER(buffer)) { 313 if (!IS_ARRAYBUFFER(buffer)) {
314 throw MakeTypeError('data_view_not_array_buffer', []); 314 throw MakeTypeError('data_view_not_array_buffer', []);
315 } 315 }
316 var bufferByteLength = buffer.byteLength; 316 var bufferByteLength = %ArrayBufferGetByteLength(buffer);
317 var offset = IS_UNDEFINED(byteOffset) ? 317 var offset = IS_UNDEFINED(byteOffset) ?
318 0 : ToPositiveInteger(byteOffset, 'invalid_data_view_offset'); 318 0 : ToPositiveInteger(byteOffset, 'invalid_data_view_offset');
319 if (offset > bufferByteLength) { 319 if (offset > bufferByteLength) {
320 throw MakeRangeError('invalid_data_view_offset'); 320 throw MakeRangeError('invalid_data_view_offset');
321 } 321 }
322 var length = IS_UNDEFINED(byteLength) ? 322 var length = IS_UNDEFINED(byteLength) ?
323 bufferByteLength - offset : TO_INTEGER(byteLength); 323 bufferByteLength - offset : TO_INTEGER(byteLength);
324 if (length < 0 || offset + length > bufferByteLength) { 324 if (length < 0 || offset + length > bufferByteLength) {
325 throw new MakeRangeError('invalid_data_view_length'); 325 throw new MakeRangeError('invalid_data_view_length');
326 } 326 }
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 436
437 "getFloat32", DataViewGetFloat32, 437 "getFloat32", DataViewGetFloat32,
438 "setFloat32", DataViewSetFloat32, 438 "setFloat32", DataViewSetFloat32,
439 439
440 "getFloat64", DataViewGetFloat64, 440 "getFloat64", DataViewGetFloat64,
441 "setFloat64", DataViewSetFloat64 441 "setFloat64", DataViewSetFloat64
442 )); 442 ));
443 } 443 }
444 444
445 SetupDataView(); 445 SetupDataView();
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | src/version.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698