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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 return; | 88 return; |
89 } | 89 } |
90 Add(address, type, id, name); | 90 Add(address, type, id, name); |
91 } | 91 } |
92 | 92 |
93 | 93 |
94 void ExternalReferenceTable::Add(Address address, | 94 void ExternalReferenceTable::Add(Address address, |
95 TypeCode type, | 95 TypeCode type, |
96 uint16_t id, | 96 uint16_t id, |
97 const char* name) { | 97 const char* name) { |
98 DCHECK_NE(NULL, address); | 98 DCHECK_NOT_NULL(address); |
99 ExternalReferenceEntry entry; | 99 ExternalReferenceEntry entry; |
100 entry.address = address; | 100 entry.address = address; |
101 entry.code = EncodeExternal(type, id); | 101 entry.code = EncodeExternal(type, id); |
102 entry.name = name; | 102 entry.name = name; |
103 DCHECK_NE(0, entry.code); | 103 DCHECK_NE(0u, entry.code); |
104 // Assert that the code is added in ascending order to rule out duplicates. | 104 // Assert that the code is added in ascending order to rule out duplicates. |
105 DCHECK((size() == 0) || (code(size() - 1) < entry.code)); | 105 DCHECK((size() == 0) || (code(size() - 1) < entry.code)); |
106 refs_.Add(entry); | 106 refs_.Add(entry); |
107 if (id > max_id_[type]) max_id_[type] = id; | 107 if (id > max_id_[type]) max_id_[type] = id; |
108 } | 108 } |
109 | 109 |
110 | 110 |
111 void ExternalReferenceTable::PopulateTable(Isolate* isolate) { | 111 void ExternalReferenceTable::PopulateTable(Isolate* isolate) { |
112 for (int type_code = 0; type_code < kTypeCodeCount; type_code++) { | 112 for (int type_code = 0; type_code < kTypeCodeCount; type_code++) { |
113 max_id_[type_code] = 0; | 113 max_id_[type_code] = 0; |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 #endif // DEBUG | 640 #endif // DEBUG |
641 if (!isolate_->heap()->ReserveSpace(reservations_)) return false; | 641 if (!isolate_->heap()->ReserveSpace(reservations_)) return false; |
642 for (int i = 0; i < kNumberOfPreallocatedSpaces; i++) { | 642 for (int i = 0; i < kNumberOfPreallocatedSpaces; i++) { |
643 high_water_[i] = reservations_[i][0].start; | 643 high_water_[i] = reservations_[i][0].start; |
644 } | 644 } |
645 return true; | 645 return true; |
646 } | 646 } |
647 | 647 |
648 | 648 |
649 void Deserializer::Initialize(Isolate* isolate) { | 649 void Deserializer::Initialize(Isolate* isolate) { |
650 DCHECK_EQ(NULL, isolate_); | 650 DCHECK_NULL(isolate_); |
651 DCHECK_NE(NULL, isolate); | 651 DCHECK_NOT_NULL(isolate); |
652 isolate_ = isolate; | 652 isolate_ = isolate; |
653 DCHECK_EQ(NULL, external_reference_decoder_); | 653 DCHECK_NULL(external_reference_decoder_); |
654 external_reference_decoder_ = new ExternalReferenceDecoder(isolate); | 654 external_reference_decoder_ = new ExternalReferenceDecoder(isolate); |
655 } | 655 } |
656 | 656 |
657 | 657 |
658 void Deserializer::Deserialize(Isolate* isolate) { | 658 void Deserializer::Deserialize(Isolate* isolate) { |
659 Initialize(isolate); | 659 Initialize(isolate); |
660 if (!ReserveSpace()) FatalProcessOutOfMemory("deserializing context"); | 660 if (!ReserveSpace()) FatalProcessOutOfMemory("deserializing context"); |
661 // No active threads. | 661 // No active threads. |
662 DCHECK_EQ(NULL, isolate_->thread_manager()->FirstThreadStateInUse()); | 662 DCHECK_NULL(isolate_->thread_manager()->FirstThreadStateInUse()); |
663 // No active handles. | 663 // No active handles. |
664 DCHECK(isolate_->handle_scope_implementer()->blocks()->is_empty()); | 664 DCHECK(isolate_->handle_scope_implementer()->blocks()->is_empty()); |
665 isolate_->heap()->IterateSmiRoots(this); | 665 isolate_->heap()->IterateSmiRoots(this); |
666 isolate_->heap()->IterateStrongRoots(this, VISIT_ONLY_STRONG); | 666 isolate_->heap()->IterateStrongRoots(this, VISIT_ONLY_STRONG); |
667 isolate_->heap()->RepairFreeListsAfterDeserialization(); | 667 isolate_->heap()->RepairFreeListsAfterDeserialization(); |
668 isolate_->heap()->IterateWeakRoots(this, VISIT_ALL); | 668 isolate_->heap()->IterateWeakRoots(this, VISIT_ALL); |
669 | 669 |
670 isolate_->heap()->set_native_contexts_list( | 670 isolate_->heap()->set_native_contexts_list( |
671 isolate_->heap()->undefined_value()); | 671 isolate_->heap()->undefined_value()); |
672 isolate_->heap()->set_array_buffers_list( | 672 isolate_->heap()->set_array_buffers_list( |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
935 AlwaysAllocateScope scope(isolate_); | 935 AlwaysAllocateScope scope(isolate_); |
936 LargeObjectSpace* lo_space = isolate_->heap()->lo_space(); | 936 LargeObjectSpace* lo_space = isolate_->heap()->lo_space(); |
937 Executability exec = static_cast<Executability>(source_.Get()); | 937 Executability exec = static_cast<Executability>(source_.Get()); |
938 AllocationResult result = lo_space->AllocateRaw(size, exec); | 938 AllocationResult result = lo_space->AllocateRaw(size, exec); |
939 HeapObject* obj = HeapObject::cast(result.ToObjectChecked()); | 939 HeapObject* obj = HeapObject::cast(result.ToObjectChecked()); |
940 deserialized_large_objects_.Add(obj); | 940 deserialized_large_objects_.Add(obj); |
941 return obj->address(); | 941 return obj->address(); |
942 } else { | 942 } else { |
943 DCHECK(space_index < kNumberOfPreallocatedSpaces); | 943 DCHECK(space_index < kNumberOfPreallocatedSpaces); |
944 Address address = high_water_[space_index]; | 944 Address address = high_water_[space_index]; |
945 DCHECK_NE(NULL, address); | 945 DCHECK_NOT_NULL(address); |
946 high_water_[space_index] += size; | 946 high_water_[space_index] += size; |
947 #ifdef DEBUG | 947 #ifdef DEBUG |
948 // Assert that the current reserved chunk is still big enough. | 948 // Assert that the current reserved chunk is still big enough. |
949 const Heap::Reservation& reservation = reservations_[space_index]; | 949 const Heap::Reservation& reservation = reservations_[space_index]; |
950 int chunk_index = current_chunk_[space_index]; | 950 int chunk_index = current_chunk_[space_index]; |
951 CHECK_LE(high_water_[space_index], reservation[chunk_index].end); | 951 CHECK_LE(high_water_[space_index], reservation[chunk_index].end); |
952 #endif | 952 #endif |
953 return address; | 953 return address; |
954 } | 954 } |
955 } | 955 } |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1376 | 1376 |
1377 Serializer::~Serializer() { | 1377 Serializer::~Serializer() { |
1378 delete external_reference_encoder_; | 1378 delete external_reference_encoder_; |
1379 if (code_address_map_ != NULL) delete code_address_map_; | 1379 if (code_address_map_ != NULL) delete code_address_map_; |
1380 } | 1380 } |
1381 | 1381 |
1382 | 1382 |
1383 void StartupSerializer::SerializeStrongReferences() { | 1383 void StartupSerializer::SerializeStrongReferences() { |
1384 Isolate* isolate = this->isolate(); | 1384 Isolate* isolate = this->isolate(); |
1385 // No active threads. | 1385 // No active threads. |
1386 CHECK_EQ(NULL, isolate->thread_manager()->FirstThreadStateInUse()); | 1386 CHECK_NULL(isolate->thread_manager()->FirstThreadStateInUse()); |
1387 // No active or weak handles. | 1387 // No active or weak handles. |
1388 CHECK(isolate->handle_scope_implementer()->blocks()->is_empty()); | 1388 CHECK(isolate->handle_scope_implementer()->blocks()->is_empty()); |
1389 CHECK_EQ(0, isolate->global_handles()->NumberOfWeakHandles()); | 1389 CHECK_EQ(0, isolate->global_handles()->NumberOfWeakHandles()); |
1390 CHECK_EQ(0, isolate->eternal_handles()->NumberOfHandles()); | 1390 CHECK_EQ(0, isolate->eternal_handles()->NumberOfHandles()); |
1391 // We don't support serializing installed extensions. | 1391 // We don't support serializing installed extensions. |
1392 CHECK(!isolate->has_installed_extensions()); | 1392 CHECK(!isolate->has_installed_extensions()); |
1393 isolate->heap()->IterateSmiRoots(this); | 1393 isolate->heap()->IterateSmiRoots(this); |
1394 isolate->heap()->IterateStrongRoots(this, VISIT_ONLY_STRONG); | 1394 isolate->heap()->IterateStrongRoots(this, VISIT_ONLY_STRONG); |
1395 } | 1395 } |
1396 | 1396 |
(...skipping 1168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2565 return GetHeaderValue(kNumInternalizedStringsOffset); | 2565 return GetHeaderValue(kNumInternalizedStringsOffset); |
2566 } | 2566 } |
2567 | 2567 |
2568 Vector<const uint32_t> SerializedCodeData::CodeStubKeys() const { | 2568 Vector<const uint32_t> SerializedCodeData::CodeStubKeys() const { |
2569 int reservations_size = GetHeaderValue(kReservationsOffset) * kInt32Size; | 2569 int reservations_size = GetHeaderValue(kReservationsOffset) * kInt32Size; |
2570 const byte* start = data_ + kHeaderSize + reservations_size; | 2570 const byte* start = data_ + kHeaderSize + reservations_size; |
2571 return Vector<const uint32_t>(reinterpret_cast<const uint32_t*>(start), | 2571 return Vector<const uint32_t>(reinterpret_cast<const uint32_t*>(start), |
2572 GetHeaderValue(kNumCodeStubKeysOffset)); | 2572 GetHeaderValue(kNumCodeStubKeysOffset)); |
2573 } | 2573 } |
2574 } } // namespace v8::internal | 2574 } } // namespace v8::internal |
OLD | NEW |