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

Side by Side Diff: src/typedarray.js

Issue 94473002: Ensure that length is Smi in TypedArrayFromArrayLike constructor. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
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 | « no previous file | test/mjsunit/regress/regress-324028.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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 throw MakeRangeError("invalid_typed_array_length"); 91 throw MakeRangeError("invalid_typed_array_length");
92 } 92 }
93 var byteLength = l * ELEMENT_SIZE; 93 var byteLength = l * ELEMENT_SIZE;
94 var buffer = new $ArrayBuffer(byteLength); 94 var buffer = new $ArrayBuffer(byteLength);
95 %TypedArrayInitialize(obj, ARRAY_ID, buffer, 0, byteLength); 95 %TypedArrayInitialize(obj, ARRAY_ID, buffer, 0, byteLength);
96 } 96 }
97 97
98 function NAMEConstructByArrayLike(obj, arrayLike) { 98 function NAMEConstructByArrayLike(obj, arrayLike) {
99 var length = arrayLike.length; 99 var length = arrayLike.length;
100 var l = ToPositiveInteger(length, "invalid_typed_array_length"); 100 var l = ToPositiveInteger(length, "invalid_typed_array_length");
101 if (l > %MaxSmi()) {
102 throw MakeRangeError("invalid_typed_array_length");
103 }
101 if(!%TypedArrayInitializeFromArrayLike(obj, ARRAY_ID, arrayLike, l)) { 104 if(!%TypedArrayInitializeFromArrayLike(obj, ARRAY_ID, arrayLike, l)) {
102 for (var i = 0; i < l; i++) { 105 for (var i = 0; i < l; i++) {
103 // It is crucial that we let any execptions from arrayLike[i] 106 // It is crucial that we let any execptions from arrayLike[i]
104 // propagate outside the function. 107 // propagate outside the function.
105 obj[i] = arrayLike[i]; 108 obj[i] = arrayLike[i];
106 } 109 }
107 } 110 }
108 } 111 }
109 112
110 function NAMEConstructor(arg1, arg2, arg3) { 113 function NAMEConstructor(arg1, arg2, arg3) {
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 435
433 "getFloat32", DataViewGetFloat32, 436 "getFloat32", DataViewGetFloat32,
434 "setFloat32", DataViewSetFloat32, 437 "setFloat32", DataViewSetFloat32,
435 438
436 "getFloat64", DataViewGetFloat64, 439 "getFloat64", DataViewGetFloat64,
437 "setFloat64", DataViewSetFloat64 440 "setFloat64", DataViewSetFloat64
438 )); 441 ));
439 } 442 }
440 443
441 SetupDataView(); 444 SetupDataView();
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-324028.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698