| OLD | NEW | 
|    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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   85     %TypedArrayInitialize(obj, ARRAY_ID, buffer, offset, newByteLength); |   85     %TypedArrayInitialize(obj, ARRAY_ID, buffer, offset, newByteLength); | 
|   86   } |   86   } | 
|   87  |   87  | 
|   88   function NAMEConstructByLength(obj, length) { |   88   function NAMEConstructByLength(obj, length) { | 
|   89     var l = IS_UNDEFINED(length) ? |   89     var l = IS_UNDEFINED(length) ? | 
|   90       0 : ToPositiveInteger(length, "invalid_typed_array_length"); |   90       0 : ToPositiveInteger(length, "invalid_typed_array_length"); | 
|   91     if (l > %MaxSmi()) { |   91     if (l > %MaxSmi()) { | 
|   92       throw MakeRangeError("invalid_typed_array_length"); |   92       throw MakeRangeError("invalid_typed_array_length"); | 
|   93     } |   93     } | 
|   94     var byteLength = l * ELEMENT_SIZE; |   94     var byteLength = l * ELEMENT_SIZE; | 
|   95     var buffer = new $ArrayBuffer(byteLength); |   95     if (byteLength > %TypedArrayMaxSizeInHeap()) { | 
|   96     %TypedArrayInitialize(obj, ARRAY_ID, buffer, 0, byteLength); |   96       var buffer = new $ArrayBuffer(byteLength); | 
 |   97       %TypedArrayInitialize(obj, ARRAY_ID, buffer, 0, byteLength); | 
 |   98     } else { | 
 |   99       %TypedArrayInitialize(obj, ARRAY_ID, null, 0, byteLength); | 
 |  100     } | 
|   97   } |  101   } | 
|   98  |  102  | 
|   99   function NAMEConstructByArrayLike(obj, arrayLike) { |  103   function NAMEConstructByArrayLike(obj, arrayLike) { | 
|  100     var length = arrayLike.length; |  104     var length = arrayLike.length; | 
|  101     var l = ToPositiveInteger(length, "invalid_typed_array_length"); |  105     var l = ToPositiveInteger(length, "invalid_typed_array_length"); | 
|  102     if (l > %MaxSmi()) { |  106     if (l > %MaxSmi()) { | 
|  103       throw MakeRangeError("invalid_typed_array_length"); |  107       throw MakeRangeError("invalid_typed_array_length"); | 
|  104     } |  108     } | 
|  105     if(!%TypedArrayInitializeFromArrayLike(obj, ARRAY_ID, arrayLike, l)) { |  109     if(!%TypedArrayInitializeFromArrayLike(obj, ARRAY_ID, arrayLike, l)) { | 
|  106       for (var i = 0; i < l; i++) { |  110       for (var i = 0; i < l; i++) { | 
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  160     if (endInt < 0) { |  164     if (endInt < 0) { | 
|  161       endInt = MathMax(0, srcLength + endInt); |  165       endInt = MathMax(0, srcLength + endInt); | 
|  162     } else { |  166     } else { | 
|  163       endInt = MathMin(endInt, srcLength); |  167       endInt = MathMin(endInt, srcLength); | 
|  164     } |  168     } | 
|  165     if (endInt < beginInt) { |  169     if (endInt < beginInt) { | 
|  166       endInt = beginInt; |  170       endInt = beginInt; | 
|  167     } |  171     } | 
|  168     var newLength = endInt - beginInt; |  172     var newLength = endInt - beginInt; | 
|  169     var beginByteOffset = |  173     var beginByteOffset = | 
|  170         %TypedArrayGetByteOffset(this) + beginInt * elementSize; |  174         this.byteOffset + beginInt * elementSize; | 
|  171     return new constructor(%TypedArrayGetBuffer(this), |  175     return new constructor(this.buffer, | 
|  172                            beginByteOffset, newLength); |  176                            beginByteOffset, newLength); | 
|  173   } |  177   } | 
|  174 } |  178 } | 
|  175  |  179  | 
|  176 function TypedArraySetFromArrayLike(target, source, sourceLength, offset) { |  180 function TypedArraySetFromArrayLike(target, source, sourceLength, offset) { | 
|  177   if (offset > 0) { |  181   if (offset > 0) { | 
|  178     for (var i = 0; i < sourceLength; i++) { |  182     for (var i = 0; i < sourceLength; i++) { | 
|  179       target[offset + i] = source[i]; |  183       target[offset + i] = source[i]; | 
|  180     } |  184     } | 
|  181   } |  185   } | 
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  440  |  444  | 
|  441       "getFloat32", DataViewGetFloat32, |  445       "getFloat32", DataViewGetFloat32, | 
|  442       "setFloat32", DataViewSetFloat32, |  446       "setFloat32", DataViewSetFloat32, | 
|  443  |  447  | 
|  444       "getFloat64", DataViewGetFloat64, |  448       "getFloat64", DataViewGetFloat64, | 
|  445       "setFloat64", DataViewSetFloat64 |  449       "setFloat64", DataViewSetFloat64 | 
|  446   )); |  450   )); | 
|  447 } |  451 } | 
|  448  |  452  | 
|  449 SetupDataView(); |  453 SetupDataView(); | 
| OLD | NEW |