| 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 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 } | 516 } |
| 517 | 517 |
| 518 WriteTag(SerializationTag::kEndJSObject); | 518 WriteTag(SerializationTag::kEndJSObject); |
| 519 WriteVarint<uint32_t>(properties_written); | 519 WriteVarint<uint32_t>(properties_written); |
| 520 return ThrowIfOutOfMemory(); | 520 return ThrowIfOutOfMemory(); |
| 521 } | 521 } |
| 522 | 522 |
| 523 Maybe<bool> ValueSerializer::WriteJSObjectSlow(Handle<JSObject> object) { | 523 Maybe<bool> ValueSerializer::WriteJSObjectSlow(Handle<JSObject> object) { |
| 524 WriteTag(SerializationTag::kBeginJSObject); | 524 WriteTag(SerializationTag::kBeginJSObject); |
| 525 Handle<FixedArray> keys; | 525 Handle<FixedArray> keys; |
| 526 uint32_t properties_written; | 526 uint32_t properties_written = 0; |
| 527 if (!KeyAccumulator::GetKeys(object, KeyCollectionMode::kOwnOnly, | 527 if (!KeyAccumulator::GetKeys(object, KeyCollectionMode::kOwnOnly, |
| 528 ENUMERABLE_STRINGS) | 528 ENUMERABLE_STRINGS) |
| 529 .ToHandle(&keys) || | 529 .ToHandle(&keys) || |
| 530 !WriteJSObjectPropertiesSlow(object, keys).To(&properties_written)) { | 530 !WriteJSObjectPropertiesSlow(object, keys).To(&properties_written)) { |
| 531 return Nothing<bool>(); | 531 return Nothing<bool>(); |
| 532 } | 532 } |
| 533 WriteTag(SerializationTag::kEndJSObject); | 533 WriteTag(SerializationTag::kEndJSObject); |
| 534 WriteVarint<uint32_t>(properties_written); | 534 WriteVarint<uint32_t>(properties_written); |
| 535 return ThrowIfOutOfMemory(); | 535 return ThrowIfOutOfMemory(); |
| 536 } | 536 } |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 if (!WriteJSObjectPropertiesSlow(array, keys).To(&properties_written)) { | 625 if (!WriteJSObjectPropertiesSlow(array, keys).To(&properties_written)) { |
| 626 return Nothing<bool>(); | 626 return Nothing<bool>(); |
| 627 } | 627 } |
| 628 WriteTag(SerializationTag::kEndDenseJSArray); | 628 WriteTag(SerializationTag::kEndDenseJSArray); |
| 629 WriteVarint<uint32_t>(properties_written); | 629 WriteVarint<uint32_t>(properties_written); |
| 630 WriteVarint<uint32_t>(length); | 630 WriteVarint<uint32_t>(length); |
| 631 } else { | 631 } else { |
| 632 WriteTag(SerializationTag::kBeginSparseJSArray); | 632 WriteTag(SerializationTag::kBeginSparseJSArray); |
| 633 WriteVarint<uint32_t>(length); | 633 WriteVarint<uint32_t>(length); |
| 634 Handle<FixedArray> keys; | 634 Handle<FixedArray> keys; |
| 635 uint32_t properties_written; | 635 uint32_t properties_written = 0; |
| 636 if (!KeyAccumulator::GetKeys(array, KeyCollectionMode::kOwnOnly, | 636 if (!KeyAccumulator::GetKeys(array, KeyCollectionMode::kOwnOnly, |
| 637 ENUMERABLE_STRINGS) | 637 ENUMERABLE_STRINGS) |
| 638 .ToHandle(&keys) || | 638 .ToHandle(&keys) || |
| 639 !WriteJSObjectPropertiesSlow(array, keys).To(&properties_written)) { | 639 !WriteJSObjectPropertiesSlow(array, keys).To(&properties_written)) { |
| 640 return Nothing<bool>(); | 640 return Nothing<bool>(); |
| 641 } | 641 } |
| 642 WriteTag(SerializationTag::kEndSparseJSArray); | 642 WriteTag(SerializationTag::kEndSparseJSArray); |
| 643 WriteVarint<uint32_t>(properties_written); | 643 WriteVarint<uint32_t>(properties_written); |
| 644 WriteVarint<uint32_t>(length); | 644 WriteVarint<uint32_t>(length); |
| 645 } | 645 } |
| (...skipping 1323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1969 if (stack.size() != 1) { | 1969 if (stack.size() != 1) { |
| 1970 isolate_->Throw(*isolate_->factory()->NewError( | 1970 isolate_->Throw(*isolate_->factory()->NewError( |
| 1971 MessageTemplate::kDataCloneDeserializationError)); | 1971 MessageTemplate::kDataCloneDeserializationError)); |
| 1972 return MaybeHandle<Object>(); | 1972 return MaybeHandle<Object>(); |
| 1973 } | 1973 } |
| 1974 return scope.CloseAndEscape(stack[0]); | 1974 return scope.CloseAndEscape(stack[0]); |
| 1975 } | 1975 } |
| 1976 | 1976 |
| 1977 } // namespace internal | 1977 } // namespace internal |
| 1978 } // namespace v8 | 1978 } // namespace v8 |
| OLD | NEW |