| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 "use strict"; | 5 "use strict"; |
| 6 | 6 |
| 7 // This file relies on the fact that the following declaration has been made | 7 // This file relies on the fact that the following declaration has been made |
| 8 // in runtime.js: | 8 // in runtime.js: |
| 9 // var $Array = global.Array; | 9 // var $Array = global.Array; |
| 10 var $ArrayBuffer = global.ArrayBuffer; | 10 var $ArrayBuffer = global.ArrayBuffer; |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 throw MakeTypeError('incompatible_method_receiver', | 155 throw MakeTypeError('incompatible_method_receiver', |
| 156 ["NAME.subarray", this]); | 156 ["NAME.subarray", this]); |
| 157 } | 157 } |
| 158 var beginInt = TO_INTEGER(begin); | 158 var beginInt = TO_INTEGER(begin); |
| 159 if (!IS_UNDEFINED(end)) { | 159 if (!IS_UNDEFINED(end)) { |
| 160 end = TO_INTEGER(end); | 160 end = TO_INTEGER(end); |
| 161 } | 161 } |
| 162 | 162 |
| 163 var srcLength = %_TypedArrayGetLength(this); | 163 var srcLength = %_TypedArrayGetLength(this); |
| 164 if (beginInt < 0) { | 164 if (beginInt < 0) { |
| 165 beginInt = MathMax(0, srcLength + beginInt); | 165 beginInt = $max(0, srcLength + beginInt); |
| 166 } else { | 166 } else { |
| 167 beginInt = MathMin(srcLength, beginInt); | 167 beginInt = $min(srcLength, beginInt); |
| 168 } | 168 } |
| 169 | 169 |
| 170 var endInt = IS_UNDEFINED(end) ? srcLength : end; | 170 var endInt = IS_UNDEFINED(end) ? srcLength : end; |
| 171 if (endInt < 0) { | 171 if (endInt < 0) { |
| 172 endInt = MathMax(0, srcLength + endInt); | 172 endInt = $max(0, srcLength + endInt); |
| 173 } else { | 173 } else { |
| 174 endInt = MathMin(endInt, srcLength); | 174 endInt = $min(endInt, srcLength); |
| 175 } | 175 } |
| 176 if (endInt < beginInt) { | 176 if (endInt < beginInt) { |
| 177 endInt = beginInt; | 177 endInt = beginInt; |
| 178 } | 178 } |
| 179 var newLength = endInt - beginInt; | 179 var newLength = endInt - beginInt; |
| 180 var beginByteOffset = | 180 var beginByteOffset = |
| 181 %_ArrayBufferViewGetByteOffset(this) + beginInt * ELEMENT_SIZE; | 181 %_ArrayBufferViewGetByteOffset(this) + beginInt * ELEMENT_SIZE; |
| 182 return new $NAME(%TypedArrayGetBuffer(this), | 182 return new $NAME(%TypedArrayGetBuffer(this), |
| 183 beginByteOffset, newLength); | 183 beginByteOffset, newLength); |
| 184 } | 184 } |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 | 473 |
| 474 "getFloat32", DataViewGetFloat32JS, | 474 "getFloat32", DataViewGetFloat32JS, |
| 475 "setFloat32", DataViewSetFloat32JS, | 475 "setFloat32", DataViewSetFloat32JS, |
| 476 | 476 |
| 477 "getFloat64", DataViewGetFloat64JS, | 477 "getFloat64", DataViewGetFloat64JS, |
| 478 "setFloat64", DataViewSetFloat64JS | 478 "setFloat64", DataViewSetFloat64JS |
| 479 )); | 479 )); |
| 480 } | 480 } |
| 481 | 481 |
| 482 SetupDataView(); | 482 SetupDataView(); |
| OLD | NEW |