| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
| 8 #include "src/runtime/runtime.h" | 8 #include "src/runtime/runtime.h" |
| 9 #include "src/runtime/runtime-utils.h" | 9 #include "src/runtime/runtime-utils.h" |
| 10 | 10 |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 holder->set_buffer(*buffer); | 234 holder->set_buffer(*buffer); |
| 235 | 235 |
| 236 Handle<ExternalArray> elements = isolate->factory()->NewExternalArray( | 236 Handle<ExternalArray> elements = isolate->factory()->NewExternalArray( |
| 237 static_cast<int>(length), array_type, | 237 static_cast<int>(length), array_type, |
| 238 static_cast<uint8_t*>(buffer->backing_store()) + byte_offset); | 238 static_cast<uint8_t*>(buffer->backing_store()) + byte_offset); |
| 239 Handle<Map> map = | 239 Handle<Map> map = |
| 240 JSObject::GetElementsTransitionMap(holder, external_elements_kind); | 240 JSObject::GetElementsTransitionMap(holder, external_elements_kind); |
| 241 JSObject::SetMapAndElements(holder, map, elements); | 241 JSObject::SetMapAndElements(holder, map, elements); |
| 242 DCHECK(IsExternalArrayElementsKind(holder->map()->elements_kind())); | 242 DCHECK(IsExternalArrayElementsKind(holder->map()->elements_kind())); |
| 243 } else { | 243 } else { |
| 244 holder->set_buffer(Smi::FromInt(0)); | 244 Handle<JSArrayBuffer> buffer = isolate->factory()->NewJSArrayBuffer(); |
| 245 Runtime::SetupArrayBuffer(isolate, buffer, true, NULL, byte_length); |
| 246 holder->set_buffer(*buffer); |
| 245 Handle<FixedTypedArrayBase> elements = | 247 Handle<FixedTypedArrayBase> elements = |
| 246 isolate->factory()->NewFixedTypedArray(static_cast<int>(length), | 248 isolate->factory()->NewFixedTypedArray(static_cast<int>(length), |
| 247 array_type); | 249 array_type); |
| 248 holder->set_elements(*elements); | 250 holder->set_elements(*elements); |
| 249 } | 251 } |
| 250 return isolate->heap()->undefined_value(); | 252 return isolate->heap()->undefined_value(); |
| 251 } | 253 } |
| 252 | 254 |
| 253 | 255 |
| 254 // Initializes a typed array from an array-like object. | 256 // Initializes a typed array from an array-like object. |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 DATA_VIEW_SETTER(Uint16, uint16_t) | 719 DATA_VIEW_SETTER(Uint16, uint16_t) |
| 718 DATA_VIEW_SETTER(Int16, int16_t) | 720 DATA_VIEW_SETTER(Int16, int16_t) |
| 719 DATA_VIEW_SETTER(Uint32, uint32_t) | 721 DATA_VIEW_SETTER(Uint32, uint32_t) |
| 720 DATA_VIEW_SETTER(Int32, int32_t) | 722 DATA_VIEW_SETTER(Int32, int32_t) |
| 721 DATA_VIEW_SETTER(Float32, float) | 723 DATA_VIEW_SETTER(Float32, float) |
| 722 DATA_VIEW_SETTER(Float64, double) | 724 DATA_VIEW_SETTER(Float64, double) |
| 723 | 725 |
| 724 #undef DATA_VIEW_SETTER | 726 #undef DATA_VIEW_SETTER |
| 725 } | 727 } |
| 726 } // namespace v8::internal | 728 } // namespace v8::internal |
| OLD | NEW |