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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 %_TypedArrayInitialize(obj, ARRAY_ID, buffer, offset, newByteLength); | 93 %_TypedArrayInitialize(obj, ARRAY_ID, buffer, offset, newByteLength); |
94 } | 94 } |
95 | 95 |
96 function NAMEConstructByLength(obj, length) { | 96 function NAMEConstructByLength(obj, length) { |
97 var l = IS_UNDEFINED(length) ? | 97 var l = IS_UNDEFINED(length) ? |
98 0 : ToPositiveInteger(length, "invalid_typed_array_length"); | 98 0 : ToPositiveInteger(length, "invalid_typed_array_length"); |
99 if (l > %_MaxSmi()) { | 99 if (l > %_MaxSmi()) { |
100 throw MakeRangeError("invalid_typed_array_length"); | 100 throw MakeRangeError("invalid_typed_array_length"); |
101 } | 101 } |
102 var byteLength = l * ELEMENT_SIZE; | 102 var byteLength = l * ELEMENT_SIZE; |
103 var buffer = new $ArrayBuffer(byteLength); | 103 if (byteLength > %_TypedArrayMaxSizeInHeap()) { |
104 %_TypedArrayInitialize(obj, ARRAY_ID, buffer, 0, byteLength); | 104 var buffer = new $ArrayBuffer(byteLength); |
| 105 %_TypedArrayInitialize(obj, ARRAY_ID, buffer, 0, byteLength); |
| 106 } else { |
| 107 %_TypedArrayInitialize(obj, ARRAY_ID, null, 0, byteLength); |
| 108 } |
105 } | 109 } |
106 | 110 |
107 function NAMEConstructByArrayLike(obj, arrayLike) { | 111 function NAMEConstructByArrayLike(obj, arrayLike) { |
108 var length = arrayLike.length; | 112 var length = arrayLike.length; |
109 var l = ToPositiveInteger(length, "invalid_typed_array_length"); | 113 var l = ToPositiveInteger(length, "invalid_typed_array_length"); |
110 | 114 |
111 if (l > %_MaxSmi()) { | 115 if (l > %_MaxSmi()) { |
112 throw MakeRangeError("invalid_typed_array_length"); | 116 throw MakeRangeError("invalid_typed_array_length"); |
113 } | 117 } |
114 if(!%TypedArrayInitializeFromArrayLike(obj, ARRAY_ID, arrayLike, l)) { | 118 if(!%TypedArrayInitializeFromArrayLike(obj, ARRAY_ID, arrayLike, l)) { |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 | 466 |
463 "getFloat32", DataViewGetFloat32, | 467 "getFloat32", DataViewGetFloat32, |
464 "setFloat32", DataViewSetFloat32, | 468 "setFloat32", DataViewSetFloat32, |
465 | 469 |
466 "getFloat64", DataViewGetFloat64, | 470 "getFloat64", DataViewGetFloat64, |
467 "setFloat64", DataViewSetFloat64 | 471 "setFloat64", DataViewSetFloat64 |
468 )); | 472 )); |
469 } | 473 } |
470 | 474 |
471 SetupDataView(); | 475 SetupDataView(); |
OLD | NEW |