OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/api.h" | 8 #include "src/api.h" |
9 #include "src/base/platform/platform.h" | 9 #include "src/base/platform/platform.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 1647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1658 | 1658 |
1659 | 1659 |
1660 void PartialSerializer::SerializeObject(HeapObject* obj, HowToCode how_to_code, | 1660 void PartialSerializer::SerializeObject(HeapObject* obj, HowToCode how_to_code, |
1661 WhereToPoint where_to_point, int skip) { | 1661 WhereToPoint where_to_point, int skip) { |
1662 if (obj->IsMap()) { | 1662 if (obj->IsMap()) { |
1663 // The code-caches link to context-specific code objects, which | 1663 // The code-caches link to context-specific code objects, which |
1664 // the startup and context serializes cannot currently handle. | 1664 // the startup and context serializes cannot currently handle. |
1665 DCHECK(Map::cast(obj)->code_cache() == obj->GetHeap()->empty_fixed_array()); | 1665 DCHECK(Map::cast(obj)->code_cache() == obj->GetHeap()->empty_fixed_array()); |
1666 } | 1666 } |
1667 | 1667 |
| 1668 // Replace typed arrays by undefined. |
| 1669 if (obj->IsJSTypedArray()) obj = isolate_->heap()->undefined_value(); |
| 1670 |
1668 int root_index = root_index_map_.Lookup(obj); | 1671 int root_index = root_index_map_.Lookup(obj); |
1669 if (root_index != RootIndexMap::kInvalidRootIndex) { | 1672 if (root_index != RootIndexMap::kInvalidRootIndex) { |
1670 PutRoot(root_index, obj, how_to_code, where_to_point, skip); | 1673 PutRoot(root_index, obj, how_to_code, where_to_point, skip); |
1671 return; | 1674 return; |
1672 } | 1675 } |
1673 | 1676 |
1674 if (ShouldBeInThePartialSnapshotCache(obj)) { | 1677 if (ShouldBeInThePartialSnapshotCache(obj)) { |
1675 FlushSkip(skip); | 1678 FlushSkip(skip); |
1676 | 1679 |
1677 int cache_index = PartialSnapshotCacheIndex(obj); | 1680 int cache_index = PartialSnapshotCacheIndex(obj); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1825 } | 1828 } |
1826 | 1829 |
1827 | 1830 |
1828 void Serializer::ObjectSerializer::Serialize() { | 1831 void Serializer::ObjectSerializer::Serialize() { |
1829 if (FLAG_trace_serializer) { | 1832 if (FLAG_trace_serializer) { |
1830 PrintF(" Encoding heap object: "); | 1833 PrintF(" Encoding heap object: "); |
1831 object_->ShortPrint(); | 1834 object_->ShortPrint(); |
1832 PrintF("\n"); | 1835 PrintF("\n"); |
1833 } | 1836 } |
1834 | 1837 |
| 1838 // We cannot serialize typed array objects correctly. |
| 1839 DCHECK(!object_->IsJSTypedArray()); |
| 1840 |
1835 if (object_->IsScript()) { | 1841 if (object_->IsScript()) { |
1836 // Clear cached line ends. | 1842 // Clear cached line ends. |
1837 Object* undefined = serializer_->isolate()->heap()->undefined_value(); | 1843 Object* undefined = serializer_->isolate()->heap()->undefined_value(); |
1838 Script::cast(object_)->set_line_ends(undefined); | 1844 Script::cast(object_)->set_line_ends(undefined); |
1839 } | 1845 } |
1840 | 1846 |
1841 if (object_->IsExternalString()) { | 1847 if (object_->IsExternalString()) { |
1842 Heap* heap = serializer_->isolate()->heap(); | 1848 Heap* heap = serializer_->isolate()->heap(); |
1843 if (object_->map() != heap->native_source_string_map()) { | 1849 if (object_->map() != heap->native_source_string_map()) { |
1844 // Usually we cannot recreate resources for external strings. To work | 1850 // Usually we cannot recreate resources for external strings. To work |
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2546 return GetHeaderValue(kNumInternalizedStringsOffset); | 2552 return GetHeaderValue(kNumInternalizedStringsOffset); |
2547 } | 2553 } |
2548 | 2554 |
2549 Vector<const uint32_t> SerializedCodeData::CodeStubKeys() const { | 2555 Vector<const uint32_t> SerializedCodeData::CodeStubKeys() const { |
2550 int reservations_size = GetHeaderValue(kReservationsOffset) * kInt32Size; | 2556 int reservations_size = GetHeaderValue(kReservationsOffset) * kInt32Size; |
2551 const byte* start = data_ + kHeaderSize + reservations_size; | 2557 const byte* start = data_ + kHeaderSize + reservations_size; |
2552 return Vector<const uint32_t>(reinterpret_cast<const uint32_t*>(start), | 2558 return Vector<const uint32_t>(reinterpret_cast<const uint32_t*>(start), |
2553 GetHeaderValue(kNumCodeStubKeysOffset)); | 2559 GetHeaderValue(kNumCodeStubKeysOffset)); |
2554 } | 2560 } |
2555 } } // namespace v8::internal | 2561 } } // namespace v8::internal |
OLD | NEW |