OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/value-serializer.h" | 5 #include "src/value-serializer.h" |
6 | 6 |
7 #include <type_traits> | 7 #include <type_traits> |
8 | 8 |
9 #include "src/base/logging.h" | 9 #include "src/base/logging.h" |
10 #include "src/conversions.h" | 10 #include "src/conversions.h" |
(...skipping 1436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1447 uint32_t id = next_id_++; | 1447 uint32_t id = next_id_++; |
1448 uint32_t byte_length; | 1448 uint32_t byte_length; |
1449 Vector<const uint8_t> bytes; | 1449 Vector<const uint8_t> bytes; |
1450 if (!ReadVarint<uint32_t>().To(&byte_length) || | 1450 if (!ReadVarint<uint32_t>().To(&byte_length) || |
1451 byte_length > static_cast<size_t>(end_ - position_)) { | 1451 byte_length > static_cast<size_t>(end_ - position_)) { |
1452 return MaybeHandle<JSArrayBuffer>(); | 1452 return MaybeHandle<JSArrayBuffer>(); |
1453 } | 1453 } |
1454 const bool should_initialize = false; | 1454 const bool should_initialize = false; |
1455 Handle<JSArrayBuffer> array_buffer = | 1455 Handle<JSArrayBuffer> array_buffer = |
1456 isolate_->factory()->NewJSArrayBuffer(SharedFlag::kNotShared, pretenure_); | 1456 isolate_->factory()->NewJSArrayBuffer(SharedFlag::kNotShared, pretenure_); |
1457 JSArrayBuffer::SetupAllocatingData(array_buffer, isolate_, byte_length, | 1457 if (!JSArrayBuffer::SetupAllocatingData(array_buffer, isolate_, byte_length, |
1458 should_initialize); | 1458 should_initialize)) { |
| 1459 return MaybeHandle<JSArrayBuffer>(); |
| 1460 } |
1459 memcpy(array_buffer->backing_store(), position_, byte_length); | 1461 memcpy(array_buffer->backing_store(), position_, byte_length); |
1460 position_ += byte_length; | 1462 position_ += byte_length; |
1461 AddObjectWithID(id, array_buffer); | 1463 AddObjectWithID(id, array_buffer); |
1462 return array_buffer; | 1464 return array_buffer; |
1463 } | 1465 } |
1464 | 1466 |
1465 MaybeHandle<JSArrayBuffer> ValueDeserializer::ReadTransferredJSArrayBuffer( | 1467 MaybeHandle<JSArrayBuffer> ValueDeserializer::ReadTransferredJSArrayBuffer( |
1466 bool is_shared) { | 1468 bool is_shared) { |
1467 uint32_t id = next_id_++; | 1469 uint32_t id = next_id_++; |
1468 uint32_t transfer_id; | 1470 uint32_t transfer_id; |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1872 if (stack.size() != 1) { | 1874 if (stack.size() != 1) { |
1873 isolate_->Throw(*isolate_->factory()->NewError( | 1875 isolate_->Throw(*isolate_->factory()->NewError( |
1874 MessageTemplate::kDataCloneDeserializationError)); | 1876 MessageTemplate::kDataCloneDeserializationError)); |
1875 return MaybeHandle<Object>(); | 1877 return MaybeHandle<Object>(); |
1876 } | 1878 } |
1877 return scope.CloseAndEscape(stack[0]); | 1879 return scope.CloseAndEscape(stack[0]); |
1878 } | 1880 } |
1879 | 1881 |
1880 } // namespace internal | 1882 } // namespace internal |
1881 } // namespace v8 | 1883 } // namespace v8 |
OLD | NEW |