| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 #endif | 871 #endif |
| 872 | 872 |
| 873 | 873 |
| 874 void Serializer::InitializeAllocators() { | 874 void Serializer::InitializeAllocators() { |
| 875 for (int i = 0; i <= LAST_SPACE; i++) { | 875 for (int i = 0; i <= LAST_SPACE; i++) { |
| 876 allocator_[i]->InitEmptyHeap(static_cast<AllocationSpace>(i)); | 876 allocator_[i]->InitEmptyHeap(static_cast<AllocationSpace>(i)); |
| 877 } | 877 } |
| 878 } | 878 } |
| 879 | 879 |
| 880 | 880 |
| 881 bool Serializer::IsVisited(HeapObject *obj) { | 881 bool Serializer::IsVisited(HeapObject* obj) { |
| 882 HashMap::Entry* entry = | 882 HashMap::Entry* entry = |
| 883 saved_addresses_.Lookup(obj, HeapObjectHash(obj), false); | 883 saved_addresses_.Lookup(obj, HeapObjectHash(obj), false); |
| 884 return entry != NULL; | 884 return entry != NULL; |
| 885 } | 885 } |
| 886 | 886 |
| 887 | 887 |
| 888 Address Serializer::GetSavedAddress(HeapObject *obj) { | 888 Address Serializer::GetSavedAddress(HeapObject* obj) { |
| 889 HashMap::Entry* entry | 889 HashMap::Entry* entry |
| 890 = saved_addresses_.Lookup(obj, HeapObjectHash(obj), false); | 890 = saved_addresses_.Lookup(obj, HeapObjectHash(obj), false); |
| 891 ASSERT(entry != NULL); | 891 ASSERT(entry != NULL); |
| 892 return reinterpret_cast<Address>(entry->value); | 892 return reinterpret_cast<Address>(entry->value); |
| 893 } | 893 } |
| 894 | 894 |
| 895 | 895 |
| 896 void Serializer::SaveAddress(HeapObject* obj, Address addr) { | 896 void Serializer::SaveAddress(HeapObject* obj, Address addr) { |
| 897 HashMap::Entry* entry = | 897 HashMap::Entry* entry = |
| 898 saved_addresses_.Lookup(obj, HeapObjectHash(obj), true); | 898 saved_addresses_.Lookup(obj, HeapObjectHash(obj), true); |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1388 | 1388 |
| 1389 | 1389 |
| 1390 Object* Deserializer::GetObject() { | 1390 Object* Deserializer::GetObject() { |
| 1391 // Read the prologue: type, size and encoded address. | 1391 // Read the prologue: type, size and encoded address. |
| 1392 InstanceType type = static_cast<InstanceType>(reader_.GetInt()); | 1392 InstanceType type = static_cast<InstanceType>(reader_.GetInt()); |
| 1393 int size = reader_.GetInt() << kObjectAlignmentBits; | 1393 int size = reader_.GetInt() << kObjectAlignmentBits; |
| 1394 Address a = GetEncodedAddress(); | 1394 Address a = GetEncodedAddress(); |
| 1395 | 1395 |
| 1396 // Get a raw object of the right size in the right space. | 1396 // Get a raw object of the right size in the right space. |
| 1397 AllocationSpace space = GetSpace(a); | 1397 AllocationSpace space = GetSpace(a); |
| 1398 Object *o; | 1398 Object* o; |
| 1399 if (IsLargeExecutableObject(a)) { | 1399 if (IsLargeExecutableObject(a)) { |
| 1400 o = Heap::lo_space()->AllocateRawCode(size); | 1400 o = Heap::lo_space()->AllocateRawCode(size); |
| 1401 } else if (IsLargeFixedArray(a)) { | 1401 } else if (IsLargeFixedArray(a)) { |
| 1402 o = Heap::lo_space()->AllocateRawFixedArray(size); | 1402 o = Heap::lo_space()->AllocateRawFixedArray(size); |
| 1403 } else { | 1403 } else { |
| 1404 o = Heap::AllocateRaw(size, space); | 1404 o = Heap::AllocateRaw(size, space); |
| 1405 } | 1405 } |
| 1406 ASSERT(!o->IsFailure()); | 1406 ASSERT(!o->IsFailure()); |
| 1407 // Check that the simulation of heap allocation was correct. | 1407 // Check that the simulation of heap allocation was correct. |
| 1408 ASSERT(o == Resolve(a)); | 1408 ASSERT(o == Resolve(a)); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1446 int page_offset, | 1446 int page_offset, |
| 1447 PagedSpace* space, | 1447 PagedSpace* space, |
| 1448 List<Page*>* page_list) { | 1448 List<Page*>* page_list) { |
| 1449 ASSERT(page_index < page_list->length()); | 1449 ASSERT(page_index < page_list->length()); |
| 1450 Address address = (*page_list)[page_index]->OffsetToAddress(page_offset); | 1450 Address address = (*page_list)[page_index]->OffsetToAddress(page_offset); |
| 1451 return HeapObject::FromAddress(address); | 1451 return HeapObject::FromAddress(address); |
| 1452 } | 1452 } |
| 1453 | 1453 |
| 1454 | 1454 |
| 1455 template<typename T> | 1455 template<typename T> |
| 1456 void ConcatReversed(List<T> * target, const List<T> & source) { | 1456 void ConcatReversed(List<T>* target, const List<T>& source) { |
| 1457 for (int i = source.length() - 1; i >= 0; i--) { | 1457 for (int i = source.length() - 1; i >= 0; i--) { |
| 1458 target->Add(source[i]); | 1458 target->Add(source[i]); |
| 1459 } | 1459 } |
| 1460 } | 1460 } |
| 1461 | 1461 |
| 1462 | 1462 |
| 1463 Object* Deserializer::Resolve(Address encoded) { | 1463 Object* Deserializer::Resolve(Address encoded) { |
| 1464 Object* o = reinterpret_cast<Object*>(encoded); | 1464 Object* o = reinterpret_cast<Object*>(encoded); |
| 1465 if (o->IsSmi()) return o; | 1465 if (o->IsSmi()) return o; |
| 1466 | 1466 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1507 ASSERT(index < large_objects_.length()); | 1507 ASSERT(index < large_objects_.length()); |
| 1508 } | 1508 } |
| 1509 return large_objects_[index]; // s.page_offset() is ignored. | 1509 return large_objects_[index]; // s.page_offset() is ignored. |
| 1510 } | 1510 } |
| 1511 UNREACHABLE(); | 1511 UNREACHABLE(); |
| 1512 return NULL; | 1512 return NULL; |
| 1513 } | 1513 } |
| 1514 | 1514 |
| 1515 | 1515 |
| 1516 } } // namespace v8::internal | 1516 } } // namespace v8::internal |
| OLD | NEW |