| 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 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 uint32_t properties_written = 0; | 468 uint32_t properties_written = 0; |
| 469 bool map_changed = false; | 469 bool map_changed = false; |
| 470 for (int i = 0; i < map->NumberOfOwnDescriptors(); i++) { | 470 for (int i = 0; i < map->NumberOfOwnDescriptors(); i++) { |
| 471 Handle<Name> key(map->instance_descriptors()->GetKey(i), isolate_); | 471 Handle<Name> key(map->instance_descriptors()->GetKey(i), isolate_); |
| 472 if (!key->IsString()) continue; | 472 if (!key->IsString()) continue; |
| 473 PropertyDetails details = map->instance_descriptors()->GetDetails(i); | 473 PropertyDetails details = map->instance_descriptors()->GetDetails(i); |
| 474 if (details.IsDontEnum()) continue; | 474 if (details.IsDontEnum()) continue; |
| 475 | 475 |
| 476 Handle<Object> value; | 476 Handle<Object> value; |
| 477 if (V8_LIKELY(!map_changed)) map_changed = *map == object->map(); | 477 if (V8_LIKELY(!map_changed)) map_changed = *map == object->map(); |
| 478 if (V8_LIKELY(!map_changed && details.type() == DATA)) { | 478 if (V8_LIKELY(!map_changed && details.location() == kField)) { |
| 479 DCHECK_EQ(kData, details.kind()); |
| 479 FieldIndex field_index = FieldIndex::ForDescriptor(*map, i); | 480 FieldIndex field_index = FieldIndex::ForDescriptor(*map, i); |
| 480 value = JSObject::FastPropertyAt(object, details.representation(), | 481 value = JSObject::FastPropertyAt(object, details.representation(), |
| 481 field_index); | 482 field_index); |
| 482 } else { | 483 } else { |
| 483 // This logic should essentially match WriteJSObjectPropertiesSlow. | 484 // This logic should essentially match WriteJSObjectPropertiesSlow. |
| 484 // If the property is no longer found, do not serialize it. | 485 // If the property is no longer found, do not serialize it. |
| 485 // This could happen if a getter deleted the property. | 486 // This could happen if a getter deleted the property. |
| 486 LookupIterator it(isolate_, object, key, LookupIterator::OWN); | 487 LookupIterator it(isolate_, object, key, LookupIterator::OWN); |
| 487 if (!it.IsFound()) continue; | 488 if (!it.IsFound()) continue; |
| 488 if (!Object::GetProperty(&it).ToHandle(&value)) return Nothing<bool>(); | 489 if (!Object::GetProperty(&it).ToHandle(&value)) return Nothing<bool>(); |
| (...skipping 1386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1875 if (stack.size() != 1) { | 1876 if (stack.size() != 1) { |
| 1876 isolate_->Throw(*isolate_->factory()->NewError( | 1877 isolate_->Throw(*isolate_->factory()->NewError( |
| 1877 MessageTemplate::kDataCloneDeserializationError)); | 1878 MessageTemplate::kDataCloneDeserializationError)); |
| 1878 return MaybeHandle<Object>(); | 1879 return MaybeHandle<Object>(); |
| 1879 } | 1880 } |
| 1880 return scope.CloseAndEscape(stack[0]); | 1881 return scope.CloseAndEscape(stack[0]); |
| 1881 } | 1882 } |
| 1882 | 1883 |
| 1883 } // namespace internal | 1884 } // namespace internal |
| 1884 } // namespace v8 | 1885 } // namespace v8 |
| OLD | NEW |