Index: src/typedarray.js |
diff --git a/src/typedarray.js b/src/typedarray.js |
index 0c0cb71b2a3bf883972384a8cb1d86be23baa299..d54db3433c1aa0911c3b3675adaf40c77364b5eb 100644 |
--- a/src/typedarray.js |
+++ b/src/typedarray.js |
@@ -92,8 +92,12 @@ macro TYPED_ARRAY_CONSTRUCTOR(ARRAY_ID, NAME, ELEMENT_SIZE) |
throw MakeRangeError("invalid_typed_array_length"); |
} |
var byteLength = l * ELEMENT_SIZE; |
- var buffer = new $ArrayBuffer(byteLength); |
- %TypedArrayInitialize(obj, ARRAY_ID, buffer, 0, byteLength); |
+ if (byteLength > %TypedArrayInHeapThreshold()) { |
+ var buffer = new $ArrayBuffer(byteLength); |
+ %TypedArrayInitialize(obj, ARRAY_ID, buffer, 0, byteLength); |
+ } else { |
+ %TypedArrayInitialize(obj, ARRAY_ID, null, 0, byteLength); |
+ } |
} |
function NAMEConstructByArrayLike(obj, arrayLike) { |
@@ -167,8 +171,8 @@ function CreateSubArray(elementSize, constructor) { |
} |
var newLength = endInt - beginInt; |
var beginByteOffset = |
- %TypedArrayGetByteOffset(this) + beginInt * elementSize; |
- return new constructor(%TypedArrayGetBuffer(this), |
+ this.byteOffset + beginInt * elementSize; |
+ return new constructor(this.buffer, |
beginByteOffset, newLength); |
} |
} |