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

Side by Side Diff: src/typedarray.js

Issue 258243004: Harden some INLINE_OPTIMIZED runtime bultins. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 | « src/runtime.cc ('k') | 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 ["NAME.buffer", this]); 145 ["NAME.buffer", this]);
146 } 146 }
147 return %TypedArrayGetBuffer(this); 147 return %TypedArrayGetBuffer(this);
148 } 148 }
149 149
150 function NAME_GetByteLength() { 150 function NAME_GetByteLength() {
151 if (!(%_ClassOf(this) === 'NAME')) { 151 if (!(%_ClassOf(this) === 'NAME')) {
152 throw MakeTypeError('incompatible_method_receiver', 152 throw MakeTypeError('incompatible_method_receiver',
153 ["NAME.byteLength", this]); 153 ["NAME.byteLength", this]);
154 } 154 }
155 return %_ArrayBufferViewGetByteLength(this); 155 return %_TypedArrayGetByteLength(this);
156 } 156 }
157 157
158 function NAME_GetByteOffset() { 158 function NAME_GetByteOffset() {
159 if (!(%_ClassOf(this) === 'NAME')) { 159 if (!(%_ClassOf(this) === 'NAME')) {
160 throw MakeTypeError('incompatible_method_receiver', 160 throw MakeTypeError('incompatible_method_receiver',
161 ["NAME.byteOffset", this]); 161 ["NAME.byteOffset", this]);
162 } 162 }
163 return %_ArrayBufferViewGetByteOffset(this); 163 return %_TypedArrayGetByteOffset(this);
164 } 164 }
165 165
166 function NAME_GetLength() { 166 function NAME_GetLength() {
167 if (!(%_ClassOf(this) === 'NAME')) { 167 if (!(%_ClassOf(this) === 'NAME')) {
168 throw MakeTypeError('incompatible_method_receiver', 168 throw MakeTypeError('incompatible_method_receiver',
169 ["NAME.length", this]); 169 ["NAME.length", this]);
170 } 170 }
171 return %_TypedArrayGetLength(this); 171 return %_TypedArrayGetLength(this);
172 } 172 }
173 173
(...skipping 20 matching lines...) Expand all
194 if (endInt < 0) { 194 if (endInt < 0) {
195 endInt = MathMax(0, srcLength + endInt); 195 endInt = MathMax(0, srcLength + endInt);
196 } else { 196 } else {
197 endInt = MathMin(endInt, srcLength); 197 endInt = MathMin(endInt, srcLength);
198 } 198 }
199 if (endInt < beginInt) { 199 if (endInt < beginInt) {
200 endInt = beginInt; 200 endInt = beginInt;
201 } 201 }
202 var newLength = endInt - beginInt; 202 var newLength = endInt - beginInt;
203 var beginByteOffset = 203 var beginByteOffset =
204 %_ArrayBufferViewGetByteOffset(this) + beginInt * ELEMENT_SIZE; 204 %_TypedArrayGetByteOffset(this) + beginInt * ELEMENT_SIZE;
205 return new $NAME(%TypedArrayGetBuffer(this), 205 return new $NAME(%TypedArrayGetBuffer(this),
206 beginByteOffset, newLength); 206 beginByteOffset, newLength);
207 } 207 }
208 endmacro 208 endmacro
209 209
210 TYPED_ARRAYS(TYPED_ARRAY_CONSTRUCTOR) 210 TYPED_ARRAYS(TYPED_ARRAY_CONSTRUCTOR)
211 211
212 212
213 function TypedArraySetFromArrayLike(target, source, sourceLength, offset) { 213 function TypedArraySetFromArrayLike(target, source, sourceLength, offset) {
214 if (offset > 0) { 214 if (offset > 0) {
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 ['DataView.buffer', this]); 386 ['DataView.buffer', this]);
387 } 387 }
388 return %DataViewGetBuffer(this); 388 return %DataViewGetBuffer(this);
389 } 389 }
390 390
391 function DataViewGetByteOffset() { 391 function DataViewGetByteOffset() {
392 if (!IS_DATAVIEW(this)) { 392 if (!IS_DATAVIEW(this)) {
393 throw MakeTypeError('incompatible_method_receiver', 393 throw MakeTypeError('incompatible_method_receiver',
394 ['DataView.byteOffset', this]); 394 ['DataView.byteOffset', this]);
395 } 395 }
396 return %_ArrayBufferViewGetByteOffset(this); 396 return %_DataViewGetByteOffset(this);
397 } 397 }
398 398
399 function DataViewGetByteLength() { 399 function DataViewGetByteLength() {
400 if (!IS_DATAVIEW(this)) { 400 if (!IS_DATAVIEW(this)) {
401 throw MakeTypeError('incompatible_method_receiver', 401 throw MakeTypeError('incompatible_method_receiver',
402 ['DataView.byteLength', this]); 402 ['DataView.byteLength', this]);
403 } 403 }
404 return %_ArrayBufferViewGetByteLength(this); 404 return %_DataViewGetByteLength(this);
405 } 405 }
406 406
407 macro DATA_VIEW_TYPES(FUNCTION) 407 macro DATA_VIEW_TYPES(FUNCTION)
408 FUNCTION(Int8) 408 FUNCTION(Int8)
409 FUNCTION(Uint8) 409 FUNCTION(Uint8)
410 FUNCTION(Int16) 410 FUNCTION(Int16)
411 FUNCTION(Uint16) 411 FUNCTION(Uint16)
412 FUNCTION(Int32) 412 FUNCTION(Int32)
413 FUNCTION(Uint32) 413 FUNCTION(Uint32)
414 FUNCTION(Float32) 414 FUNCTION(Float32)
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 486
487 "getFloat32", DataViewGetFloat32, 487 "getFloat32", DataViewGetFloat32,
488 "setFloat32", DataViewSetFloat32, 488 "setFloat32", DataViewSetFloat32,
489 489
490 "getFloat64", DataViewGetFloat64, 490 "getFloat64", DataViewGetFloat64,
491 "setFloat64", DataViewSetFloat64 491 "setFloat64", DataViewSetFloat64
492 )); 492 ));
493 } 493 }
494 494
495 SetupDataView(); 495 SetupDataView();
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698