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

Side by Side Diff: src/typedarray.js

Issue 112863002: Merge bleeding_edge 18021:18297 (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 7 years 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/type-info.cc ('k') | src/typing.h » ('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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 if (bufferByteLength % ELEMENT_SIZE !== 0) { 71 if (bufferByteLength % ELEMENT_SIZE !== 0) {
72 throw MakeRangeError("invalid_typed_array_alignment", 72 throw MakeRangeError("invalid_typed_array_alignment",
73 "byte length", "NAME", ELEMENT_SIZE); 73 "byte length", "NAME", ELEMENT_SIZE);
74 } 74 }
75 newByteLength = bufferByteLength - offset; 75 newByteLength = bufferByteLength - offset;
76 newLength = newByteLength / ELEMENT_SIZE; 76 newLength = newByteLength / ELEMENT_SIZE;
77 } else { 77 } else {
78 var newLength = ToPositiveInteger(length, "invalid_typed_array_length"); 78 var newLength = ToPositiveInteger(length, "invalid_typed_array_length");
79 newByteLength = newLength * ELEMENT_SIZE; 79 newByteLength = newLength * ELEMENT_SIZE;
80 } 80 }
81 if (offset + newByteLength > bufferByteLength) { 81 if ((offset + newByteLength > bufferByteLength)
82 || (newLength > %MaxSmi())) {
82 throw MakeRangeError("invalid_typed_array_length"); 83 throw MakeRangeError("invalid_typed_array_length");
83 } 84 }
84 %TypedArrayInitialize(obj, ARRAY_ID, buffer, offset, newByteLength); 85 %TypedArrayInitialize(obj, ARRAY_ID, buffer, offset, newByteLength);
85 } 86 }
86 87
87 function NAMEConstructByLength(obj, length) { 88 function NAMEConstructByLength(obj, length) {
88 var l = IS_UNDEFINED(length) ? 89 var l = IS_UNDEFINED(length) ?
89 0 : ToPositiveInteger(length, "invalid_typed_array_length"); 90 0 : ToPositiveInteger(length, "invalid_typed_array_length");
90 if (l > %MaxSmi()) { 91 if (l > %MaxSmi()) {
91 throw MakeRangeError("invalid_typed_array_length"); 92 throw MakeRangeError("invalid_typed_array_length");
92 } 93 }
93 var byteLength = l * ELEMENT_SIZE; 94 var byteLength = l * ELEMENT_SIZE;
94 var buffer = new $ArrayBuffer(byteLength); 95 var buffer = new $ArrayBuffer(byteLength);
95 %TypedArrayInitialize(obj, ARRAY_ID, buffer, 0, byteLength); 96 %TypedArrayInitialize(obj, ARRAY_ID, buffer, 0, byteLength);
96 } 97 }
97 98
98 function NAMEConstructByArrayLike(obj, arrayLike) { 99 function NAMEConstructByArrayLike(obj, arrayLike) {
99 var length = arrayLike.length; 100 var length = arrayLike.length;
100 var l = ToPositiveInteger(length, "invalid_typed_array_length"); 101 var l = ToPositiveInteger(length, "invalid_typed_array_length");
102 if (l > %MaxSmi()) {
103 throw MakeRangeError("invalid_typed_array_length");
104 }
101 if(!%TypedArrayInitializeFromArrayLike(obj, ARRAY_ID, arrayLike, l)) { 105 if(!%TypedArrayInitializeFromArrayLike(obj, ARRAY_ID, arrayLike, l)) {
102 for (var i = 0; i < l; i++) { 106 for (var i = 0; i < l; i++) {
103 // It is crucial that we let any execptions from arrayLike[i] 107 // It is crucial that we let any execptions from arrayLike[i]
104 // propagate outside the function. 108 // propagate outside the function.
105 obj[i] = arrayLike[i]; 109 obj[i] = arrayLike[i];
106 } 110 }
107 } 111 }
108 } 112 }
109 113
110 function NAMEConstructor(arg1, arg2, arg3) { 114 function NAMEConstructor(arg1, arg2, arg3) {
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 436
433 "getFloat32", DataViewGetFloat32, 437 "getFloat32", DataViewGetFloat32,
434 "setFloat32", DataViewSetFloat32, 438 "setFloat32", DataViewSetFloat32,
435 439
436 "getFloat64", DataViewGetFloat64, 440 "getFloat64", DataViewGetFloat64,
437 "setFloat64", DataViewSetFloat64 441 "setFloat64", DataViewSetFloat64
438 )); 442 ));
439 } 443 }
440 444
441 SetupDataView(); 445 SetupDataView();
OLDNEW
« no previous file with comments | « src/type-info.cc ('k') | src/typing.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698