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 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 // Fast paths. Note that FAST_ELEMENTS in particular can bail due to the | 547 // Fast paths. Note that FAST_ELEMENTS in particular can bail due to the |
548 // structure of the elements changing. | 548 // structure of the elements changing. |
549 switch (array->GetElementsKind()) { | 549 switch (array->GetElementsKind()) { |
550 case FAST_SMI_ELEMENTS: { | 550 case FAST_SMI_ELEMENTS: { |
551 Handle<FixedArray> elements(FixedArray::cast(array->elements()), | 551 Handle<FixedArray> elements(FixedArray::cast(array->elements()), |
552 isolate_); | 552 isolate_); |
553 for (; i < length; i++) WriteSmi(Smi::cast(elements->get(i))); | 553 for (; i < length; i++) WriteSmi(Smi::cast(elements->get(i))); |
554 break; | 554 break; |
555 } | 555 } |
556 case FAST_DOUBLE_ELEMENTS: { | 556 case FAST_DOUBLE_ELEMENTS: { |
| 557 // Elements are empty_fixed_array, not a FixedDoubleArray, if the array |
| 558 // is empty. No elements to encode in this case anyhow. |
| 559 if (length == 0) break; |
557 Handle<FixedDoubleArray> elements( | 560 Handle<FixedDoubleArray> elements( |
558 FixedDoubleArray::cast(array->elements()), isolate_); | 561 FixedDoubleArray::cast(array->elements()), isolate_); |
559 for (; i < length; i++) { | 562 for (; i < length; i++) { |
560 WriteTag(SerializationTag::kDouble); | 563 WriteTag(SerializationTag::kDouble); |
561 WriteDouble(elements->get_scalar(i)); | 564 WriteDouble(elements->get_scalar(i)); |
562 } | 565 } |
563 break; | 566 break; |
564 } | 567 } |
565 case FAST_ELEMENTS: { | 568 case FAST_ELEMENTS: { |
566 Handle<Object> old_length(array->length(), isolate_); | 569 Handle<Object> old_length(array->length(), isolate_); |
(...skipping 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1934 if (stack.size() != 1) { | 1937 if (stack.size() != 1) { |
1935 isolate_->Throw(*isolate_->factory()->NewError( | 1938 isolate_->Throw(*isolate_->factory()->NewError( |
1936 MessageTemplate::kDataCloneDeserializationError)); | 1939 MessageTemplate::kDataCloneDeserializationError)); |
1937 return MaybeHandle<Object>(); | 1940 return MaybeHandle<Object>(); |
1938 } | 1941 } |
1939 return scope.CloseAndEscape(stack[0]); | 1942 return scope.CloseAndEscape(stack[0]); |
1940 } | 1943 } |
1941 | 1944 |
1942 } // namespace internal | 1945 } // namespace internal |
1943 } // namespace v8 | 1946 } // namespace v8 |
OLD | NEW |