Index: src/factory.cc |
diff --git a/src/factory.cc b/src/factory.cc |
index 25d8cd80e50c75f4b2eb3a4d72bf6b831058c575..60ea691d916ff071dfec04459bdccd7c34c7b0fd 100644 |
--- a/src/factory.cc |
+++ b/src/factory.cc |
@@ -1731,6 +1731,19 @@ ElementsKind GetExternalArrayElementsKind(ExternalArrayType type) { |
} |
+size_t GetExternalArrayElementSize(ExternalArrayType type) { |
+ switch (type) { |
+#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ |
+ case kExternal##Type##Array: \ |
+ return size; |
+ TYPED_ARRAYS(TYPED_ARRAY_CASE) |
+ } |
+ UNREACHABLE(); |
+ return 0; |
+#undef TYPED_ARRAY_CASE |
+} |
+ |
+ |
JSFunction* GetTypedArrayFun(ExternalArrayType type, Isolate* isolate) { |
Context* native_context = isolate->context()->native_context(); |
switch (type) { |
@@ -1769,7 +1782,9 @@ Handle<JSTypedArray> Factory::NewJSTypedArray(ExternalArrayType type, |
array->set_weak_next(buffer->weak_first_view()); |
buffer->set_weak_first_view(*array); |
array->set_byte_offset(Smi::FromInt(0)); |
- array->set_byte_length(buffer->byte_length()); |
+ Handle<Object> byte_length_handle = |
Dmitry Lomov (no reviews)
2014/10/10 08:43:02
DBC: why we have this Factory::NewJSTypedArray?
W
|
+ NewNumberFromSize(length * GetExternalArrayElementSize(type)); |
+ array->set_byte_length(*byte_length_handle); |
Handle<Object> length_handle = NewNumberFromSize(length); |
array->set_length(*length_handle); |
Handle<ExternalArray> elements = |