OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1300 Isolate* isolate = this->isolate(); | 1300 Isolate* isolate = this->isolate(); |
1301 // No active threads. | 1301 // No active threads. |
1302 CHECK_EQ(NULL, isolate->thread_manager()->FirstThreadStateInUse()); | 1302 CHECK_EQ(NULL, isolate->thread_manager()->FirstThreadStateInUse()); |
1303 // No active or weak handles. | 1303 // No active or weak handles. |
1304 CHECK(isolate->handle_scope_implementer()->blocks()->is_empty()); | 1304 CHECK(isolate->handle_scope_implementer()->blocks()->is_empty()); |
1305 CHECK_EQ(0, isolate->global_handles()->NumberOfWeakHandles()); | 1305 CHECK_EQ(0, isolate->global_handles()->NumberOfWeakHandles()); |
1306 CHECK_EQ(0, isolate->eternal_handles()->NumberOfHandles()); | 1306 CHECK_EQ(0, isolate->eternal_handles()->NumberOfHandles()); |
1307 // We don't support serializing installed extensions. | 1307 // We don't support serializing installed extensions. |
1308 CHECK(!isolate->has_installed_extensions()); | 1308 CHECK(!isolate->has_installed_extensions()); |
1309 | 1309 |
1310 HEAP->IterateStrongRoots(this, VISIT_ONLY_STRONG); | 1310 isolate->heap()->IterateStrongRoots(this, VISIT_ONLY_STRONG); |
1311 } | 1311 } |
1312 | 1312 |
1313 | 1313 |
1314 void PartialSerializer::Serialize(Object** object) { | 1314 void PartialSerializer::Serialize(Object** object) { |
1315 this->VisitPointer(object); | 1315 this->VisitPointer(object); |
1316 Pad(); | 1316 Pad(); |
1317 } | 1317 } |
1318 | 1318 |
1319 | 1319 |
1320 void Serializer::VisitPointers(Object** start, Object** end) { | 1320 void Serializer::VisitPointers(Object** start, Object** end) { |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1478 | 1478 |
1479 | 1479 |
1480 void StartupSerializer::SerializeWeakReferences() { | 1480 void StartupSerializer::SerializeWeakReferences() { |
1481 // This phase comes right after the partial serialization (of the snapshot). | 1481 // This phase comes right after the partial serialization (of the snapshot). |
1482 // After we have done the partial serialization the partial snapshot cache | 1482 // After we have done the partial serialization the partial snapshot cache |
1483 // will contain some references needed to decode the partial snapshot. We | 1483 // will contain some references needed to decode the partial snapshot. We |
1484 // add one entry with 'undefined' which is the sentinel that the deserializer | 1484 // add one entry with 'undefined' which is the sentinel that the deserializer |
1485 // uses to know it is done deserializing the array. | 1485 // uses to know it is done deserializing the array. |
1486 Object* undefined = isolate()->heap()->undefined_value(); | 1486 Object* undefined = isolate()->heap()->undefined_value(); |
1487 VisitPointer(&undefined); | 1487 VisitPointer(&undefined); |
1488 HEAP->IterateWeakRoots(this, VISIT_ALL); | 1488 isolate()->heap()->IterateWeakRoots(this, VISIT_ALL); |
1489 Pad(); | 1489 Pad(); |
1490 } | 1490 } |
1491 | 1491 |
1492 | 1492 |
1493 void Serializer::PutRoot(int root_index, | 1493 void Serializer::PutRoot(int root_index, |
1494 HeapObject* object, | 1494 HeapObject* object, |
1495 SerializerDeserializer::HowToCode how_to_code, | 1495 SerializerDeserializer::HowToCode how_to_code, |
1496 SerializerDeserializer::WhereToPoint where_to_point, | 1496 SerializerDeserializer::WhereToPoint where_to_point, |
1497 int skip) { | 1497 int skip) { |
1498 if (how_to_code == kPlain && | 1498 if (how_to_code == kPlain && |
1499 where_to_point == kStartOfObject && | 1499 where_to_point == kStartOfObject && |
1500 root_index < kRootArrayNumberOfConstantEncodings && | 1500 root_index < kRootArrayNumberOfConstantEncodings && |
1501 !HEAP->InNewSpace(object)) { | 1501 !isolate()->heap()->InNewSpace(object)) { |
1502 if (skip == 0) { | 1502 if (skip == 0) { |
1503 sink_->Put(kRootArrayConstants + kNoSkipDistance + root_index, | 1503 sink_->Put(kRootArrayConstants + kNoSkipDistance + root_index, |
1504 "RootConstant"); | 1504 "RootConstant"); |
1505 } else { | 1505 } else { |
1506 sink_->Put(kRootArrayConstants + kHasSkipDistance + root_index, | 1506 sink_->Put(kRootArrayConstants + kHasSkipDistance + root_index, |
1507 "RootConstant"); | 1507 "RootConstant"); |
1508 sink_->PutInt(skip, "SkipInPutRoot"); | 1508 sink_->PutInt(skip, "SkipInPutRoot"); |
1509 } | 1509 } |
1510 } else { | 1510 } else { |
1511 if (skip != 0) { | 1511 if (skip != 0) { |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1624 while (current < end && !(*current)->IsSmi()) { | 1624 while (current < end && !(*current)->IsSmi()) { |
1625 HeapObject* current_contents = HeapObject::cast(*current); | 1625 HeapObject* current_contents = HeapObject::cast(*current); |
1626 int root_index = serializer_->RootIndex(current_contents, kPlain); | 1626 int root_index = serializer_->RootIndex(current_contents, kPlain); |
1627 // Repeats are not subject to the write barrier so there are only some | 1627 // Repeats are not subject to the write barrier so there are only some |
1628 // objects that can be used in a repeat encoding. These are the early | 1628 // objects that can be used in a repeat encoding. These are the early |
1629 // ones in the root array that are never in new space. | 1629 // ones in the root array that are never in new space. |
1630 if (current != start && | 1630 if (current != start && |
1631 root_index != kInvalidRootIndex && | 1631 root_index != kInvalidRootIndex && |
1632 root_index < kRootArrayNumberOfConstantEncodings && | 1632 root_index < kRootArrayNumberOfConstantEncodings && |
1633 current_contents == current[-1]) { | 1633 current_contents == current[-1]) { |
1634 ASSERT(!HEAP->InNewSpace(current_contents)); | 1634 ASSERT(!serializer_->isolate()->heap()->InNewSpace(current_contents)); |
1635 int repeat_count = 1; | 1635 int repeat_count = 1; |
1636 while (current < end - 1 && current[repeat_count] == current_contents) { | 1636 while (current < end - 1 && current[repeat_count] == current_contents) { |
1637 repeat_count++; | 1637 repeat_count++; |
1638 } | 1638 } |
1639 current += repeat_count; | 1639 current += repeat_count; |
1640 bytes_processed_so_far_ += repeat_count * kPointerSize; | 1640 bytes_processed_so_far_ += repeat_count * kPointerSize; |
1641 if (repeat_count > kMaxRepeats) { | 1641 if (repeat_count > kMaxRepeats) { |
1642 sink_->Put(kRepeat, "SerializeRepeats"); | 1642 sink_->Put(kRepeat, "SerializeRepeats"); |
1643 sink_->PutInt(repeat_count, "SerializeRepeats"); | 1643 sink_->PutInt(repeat_count, "SerializeRepeats"); |
1644 } else { | 1644 } else { |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1741 int skip = OutputRawData(rinfo->pc(), kCanReturnSkipInsteadOfSkipping); | 1741 int skip = OutputRawData(rinfo->pc(), kCanReturnSkipInsteadOfSkipping); |
1742 serializer_->SerializeObject(cell, kPlain, kInnerPointer, skip); | 1742 serializer_->SerializeObject(cell, kPlain, kInnerPointer, skip); |
1743 } | 1743 } |
1744 | 1744 |
1745 | 1745 |
1746 void Serializer::ObjectSerializer::VisitExternalAsciiString( | 1746 void Serializer::ObjectSerializer::VisitExternalAsciiString( |
1747 v8::String::ExternalAsciiStringResource** resource_pointer) { | 1747 v8::String::ExternalAsciiStringResource** resource_pointer) { |
1748 Address references_start = reinterpret_cast<Address>(resource_pointer); | 1748 Address references_start = reinterpret_cast<Address>(resource_pointer); |
1749 OutputRawData(references_start); | 1749 OutputRawData(references_start); |
1750 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) { | 1750 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) { |
1751 Object* source = HEAP->natives_source_cache()->get(i); | 1751 Object* source = |
| 1752 serializer_->isolate()->heap()->natives_source_cache()->get(i); |
1752 if (!source->IsUndefined()) { | 1753 if (!source->IsUndefined()) { |
1753 ExternalAsciiString* string = ExternalAsciiString::cast(source); | 1754 ExternalAsciiString* string = ExternalAsciiString::cast(source); |
1754 typedef v8::String::ExternalAsciiStringResource Resource; | 1755 typedef v8::String::ExternalAsciiStringResource Resource; |
1755 const Resource* resource = string->resource(); | 1756 const Resource* resource = string->resource(); |
1756 if (resource == *resource_pointer) { | 1757 if (resource == *resource_pointer) { |
1757 sink_->Put(kNativesStringResource, "NativesStringResource"); | 1758 sink_->Put(kNativesStringResource, "NativesStringResource"); |
1758 sink_->PutSection(i, "NativesStringResourceEnd"); | 1759 sink_->PutSection(i, "NativesStringResourceEnd"); |
1759 bytes_processed_so_far_ += sizeof(resource); | 1760 bytes_processed_so_far_ += sizeof(resource); |
1760 return; | 1761 return; |
1761 } | 1762 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1810 sink_->PutInt(to_skip, "SkipDistance"); | 1811 sink_->PutInt(to_skip, "SkipDistance"); |
1811 to_skip = 0; | 1812 to_skip = 0; |
1812 } | 1813 } |
1813 return to_skip; | 1814 return to_skip; |
1814 } | 1815 } |
1815 | 1816 |
1816 | 1817 |
1817 int Serializer::SpaceOfObject(HeapObject* object) { | 1818 int Serializer::SpaceOfObject(HeapObject* object) { |
1818 for (int i = FIRST_SPACE; i <= LAST_SPACE; i++) { | 1819 for (int i = FIRST_SPACE; i <= LAST_SPACE; i++) { |
1819 AllocationSpace s = static_cast<AllocationSpace>(i); | 1820 AllocationSpace s = static_cast<AllocationSpace>(i); |
1820 if (HEAP->InSpace(object, s)) { | 1821 if (object->GetHeap()->InSpace(object, s)) { |
1821 ASSERT(i < kNumberOfSpaces); | 1822 ASSERT(i < kNumberOfSpaces); |
1822 return i; | 1823 return i; |
1823 } | 1824 } |
1824 } | 1825 } |
1825 UNREACHABLE(); | 1826 UNREACHABLE(); |
1826 return 0; | 1827 return 0; |
1827 } | 1828 } |
1828 | 1829 |
1829 | 1830 |
1830 int Serializer::Allocate(int space, int size) { | 1831 int Serializer::Allocate(int space, int size) { |
(...skipping 24 matching lines...) Expand all Loading... |
1855 | 1856 |
1856 bool SnapshotByteSource::AtEOF() { | 1857 bool SnapshotByteSource::AtEOF() { |
1857 if (0u + length_ - position_ > 2 * sizeof(uint32_t)) return false; | 1858 if (0u + length_ - position_ > 2 * sizeof(uint32_t)) return false; |
1858 for (int x = position_; x < length_; x++) { | 1859 for (int x = position_; x < length_; x++) { |
1859 if (data_[x] != SerializerDeserializer::nop()) return false; | 1860 if (data_[x] != SerializerDeserializer::nop()) return false; |
1860 } | 1861 } |
1861 return true; | 1862 return true; |
1862 } | 1863 } |
1863 | 1864 |
1864 } } // namespace v8::internal | 1865 } } // namespace v8::internal |
OLD | NEW |