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

Side by Side Diff: src/typedarray.js

Issue 79263005: Revert "Use %_IsSmi instead of %MaxSmi." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 1 month 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 | no next file » | 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 newByteLength = newLength * ELEMENT_SIZE; 79 newByteLength = newLength * ELEMENT_SIZE;
80 } 80 }
81 if (offset + newByteLength > bufferByteLength) { 81 if (offset + newByteLength > bufferByteLength) {
82 throw MakeRangeError("invalid_typed_array_length"); 82 throw MakeRangeError("invalid_typed_array_length");
83 } 83 }
84 %TypedArrayInitialize(obj, ARRAY_ID, buffer, offset, newByteLength); 84 %TypedArrayInitialize(obj, ARRAY_ID, buffer, offset, newByteLength);
85 } 85 }
86 86
87 function NAMEConstructByLength(obj, length) { 87 function NAMEConstructByLength(obj, length) {
88 var l = IS_UNDEFINED(length) ? 88 var l = IS_UNDEFINED(length) ?
89 0 : ToPositiveInteger(length, "invalid_typed_array_length"); 89 0 : ToPositiveInteger(length, "invalid_typed_array_length");
90 if (!%_IsSmi(l)) { 90 if (l > %MaxSmi()) {
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 (!%TypedArrayInitializeFromArrayLike(obj, ARRAY_ID, arrayLike, l)) { 101 if(!%TypedArrayInitializeFromArrayLike(obj, ARRAY_ID, arrayLike, l)) {
102 for (var i = 0; i < l; i++) { 102 for (var i = 0; i < l; i++) {
103 // It is crucial that we let any execptions from arrayLike[i] 103 // It is crucial that we let any execptions from arrayLike[i]
104 // propagate outside the function. 104 // propagate outside the function.
105 obj[i] = arrayLike[i]; 105 obj[i] = arrayLike[i];
106 } 106 }
107 } 107 }
108 } 108 }
109 109
110 function NAMEConstructor(arg1, arg2, arg3) { 110 function NAMEConstructor(arg1, arg2, arg3) {
111
111 if (%_IsConstructCall()) { 112 if (%_IsConstructCall()) {
112 if (IS_ARRAYBUFFER(arg1)) { 113 if (IS_ARRAYBUFFER(arg1)) {
113 NAMEConstructByArrayBuffer(this, arg1, arg2, arg3); 114 NAMEConstructByArrayBuffer(this, arg1, arg2, arg3);
114 } else if (IS_NUMBER(arg1) || IS_STRING(arg1) || 115 } else if (IS_NUMBER(arg1) || IS_STRING(arg1) ||
115 IS_BOOLEAN(arg1) || IS_UNDEFINED(arg1)) { 116 IS_BOOLEAN(arg1) || IS_UNDEFINED(arg1)) {
116 NAMEConstructByLength(this, arg1); 117 NAMEConstructByLength(this, arg1);
117 } else { 118 } else {
118 NAMEConstructByArrayLike(this, arg1); 119 NAMEConstructByArrayLike(this, arg1);
119 } 120 }
120 } else { 121 } else {
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 432
432 "getFloat32", DataViewGetFloat32, 433 "getFloat32", DataViewGetFloat32,
433 "setFloat32", DataViewSetFloat32, 434 "setFloat32", DataViewSetFloat32,
434 435
435 "getFloat64", DataViewGetFloat64, 436 "getFloat64", DataViewGetFloat64,
436 "setFloat64", DataViewSetFloat64 437 "setFloat64", DataViewSetFloat64
437 )); 438 ));
438 } 439 }
439 440
440 SetupDataView(); 441 SetupDataView();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698