Index: src/typedarray.js |
diff --git a/src/typedarray.js b/src/typedarray.js |
index cb68c1b8d0d2fbf405c6b6d07ada6b842d836226..65659147ee7777cf1e8bc69196d4fc09a4beee89 100644 |
--- a/src/typedarray.js |
+++ b/src/typedarray.js |
@@ -88,7 +88,7 @@ function NAMEConstructByArrayBuffer(obj, buffer, byteOffset, length) { |
|| (newLength > %_MaxSmi())) { |
throw MakeRangeError(kInvalidTypedArrayLength); |
} |
- %_TypedArrayInitialize(obj, ARRAY_ID, buffer, offset, newByteLength); |
+ %_TypedArrayInitialize(obj, ARRAY_ID, buffer, offset, newByteLength, true); |
} |
function NAMEConstructByLength(obj, length) { |
@@ -100,9 +100,9 @@ function NAMEConstructByLength(obj, length) { |
var byteLength = l * ELEMENT_SIZE; |
if (byteLength > %_TypedArrayMaxSizeInHeap()) { |
var buffer = new GlobalArrayBuffer(byteLength); |
- %_TypedArrayInitialize(obj, ARRAY_ID, buffer, 0, byteLength); |
+ %_TypedArrayInitialize(obj, ARRAY_ID, buffer, 0, byteLength, true); |
} else { |
- %_TypedArrayInitialize(obj, ARRAY_ID, null, 0, byteLength); |
+ %_TypedArrayInitialize(obj, ARRAY_ID, null, 0, byteLength, true); |
} |
} |
@@ -113,7 +113,15 @@ function NAMEConstructByArrayLike(obj, arrayLike) { |
if (l > %_MaxSmi()) { |
throw MakeRangeError(kInvalidTypedArrayLength); |
} |
- if(!%TypedArrayInitializeFromArrayLike(obj, ARRAY_ID, arrayLike, l)) { |
+ var initialized = false; |
+ var byteLength = l * ELEMENT_SIZE; |
+ if (byteLength <= %_TypedArrayMaxSizeInHeap()) { |
+ %_TypedArrayInitialize(obj, ARRAY_ID, null, 0, byteLength, false); |
+ } else { |
+ initialized = |
+ %TypedArrayInitializeFromArrayLike(obj, ARRAY_ID, arrayLike, l); |
+ } |
+ if (!initialized) { |
for (var i = 0; i < l; i++) { |
// It is crucial that we let any execptions from arrayLike[i] |
// propagate outside the function. |