| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 950 v8::ArrayBufferView::kInternalFieldCount); | 950 v8::ArrayBufferView::kInternalFieldCount); |
| 951 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { | 951 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { |
| 952 holder->SetInternalField(i, Smi::FromInt(0)); | 952 holder->SetInternalField(i, Smi::FromInt(0)); |
| 953 } | 953 } |
| 954 | 954 |
| 955 ExternalArrayType array_type = kExternalInt8Array; // Bogus initialization. | 955 ExternalArrayType array_type = kExternalInt8Array; // Bogus initialization. |
| 956 size_t element_size = 1; // Bogus initialization. | 956 size_t element_size = 1; // Bogus initialization. |
| 957 Runtime::ArrayIdToTypeAndSize(arrayId, &array_type, &element_size); | 957 Runtime::ArrayIdToTypeAndSize(arrayId, &array_type, &element_size); |
| 958 | 958 |
| 959 Handle<JSArrayBuffer> buffer = isolate->factory()->NewJSArrayBuffer(); | 959 Handle<JSArrayBuffer> buffer = isolate->factory()->NewJSArrayBuffer(); |
| 960 if (source->IsJSTypedArray() && |
| 961 JSTypedArray::cast(*source)->type() == array_type) { |
| 962 length_obj = Handle<Object>(JSTypedArray::cast(*source)->length(), isolate); |
| 963 } |
| 960 size_t length = NumberToSize(isolate, *length_obj); | 964 size_t length = NumberToSize(isolate, *length_obj); |
| 961 | 965 |
| 962 if ((length > static_cast<unsigned>(Smi::kMaxValue)) || | 966 if ((length > static_cast<unsigned>(Smi::kMaxValue)) || |
| 963 (length > (kMaxInt / element_size))) { | 967 (length > (kMaxInt / element_size))) { |
| 964 return isolate->Throw(*isolate->factory()-> | 968 return isolate->Throw(*isolate->factory()-> |
| 965 NewRangeError("invalid_typed_array_length", | 969 NewRangeError("invalid_typed_array_length", |
| 966 HandleVector<Object>(NULL, 0))); | 970 HandleVector<Object>(NULL, 0))); |
| 967 } | 971 } |
| 968 size_t byte_length = length * element_size; | 972 size_t byte_length = length * element_size; |
| 969 | 973 |
| (...skipping 13895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14865 // Handle last resort GC and make sure to allow future allocations | 14869 // Handle last resort GC and make sure to allow future allocations |
| 14866 // to grow the heap without causing GCs (if possible). | 14870 // to grow the heap without causing GCs (if possible). |
| 14867 isolate->counters()->gc_last_resort_from_js()->Increment(); | 14871 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 14868 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 14872 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
| 14869 "Runtime::PerformGC"); | 14873 "Runtime::PerformGC"); |
| 14870 } | 14874 } |
| 14871 } | 14875 } |
| 14872 | 14876 |
| 14873 | 14877 |
| 14874 } } // namespace v8::internal | 14878 } } // namespace v8::internal |
| OLD | NEW |