| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 998 MemoryChunk::UpdateHighWaterMark(allocation_info_.top()); | 998 MemoryChunk::UpdateHighWaterMark(allocation_info_.top()); |
| 999 size_t size = 0; | 999 size_t size = 0; |
| 1000 PageIterator it(this); | 1000 PageIterator it(this); |
| 1001 while (it.has_next()) { | 1001 while (it.has_next()) { |
| 1002 size += it.next()->CommittedPhysicalMemory(); | 1002 size += it.next()->CommittedPhysicalMemory(); |
| 1003 } | 1003 } |
| 1004 return size; | 1004 return size; |
| 1005 } | 1005 } |
| 1006 | 1006 |
| 1007 | 1007 |
| 1008 MaybeObject* PagedSpace::FindObject(Address addr) { | 1008 Object* PagedSpace::FindObject(Address addr) { |
| 1009 // Note: this function can only be called on precisely swept spaces. | 1009 // Note: this function can only be called on precisely swept spaces. |
| 1010 ASSERT(!heap()->mark_compact_collector()->in_use()); | 1010 ASSERT(!heap()->mark_compact_collector()->in_use()); |
| 1011 | 1011 |
| 1012 if (!Contains(addr)) return Failure::Exception(); | 1012 if (!Contains(addr)) return Smi::FromInt(0); // Signaling not found. |
| 1013 | 1013 |
| 1014 Page* p = Page::FromAddress(addr); | 1014 Page* p = Page::FromAddress(addr); |
| 1015 HeapObjectIterator it(p, NULL); | 1015 HeapObjectIterator it(p, NULL); |
| 1016 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) { | 1016 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) { |
| 1017 Address cur = obj->address(); | 1017 Address cur = obj->address(); |
| 1018 Address next = cur + obj->Size(); | 1018 Address next = cur + obj->Size(); |
| 1019 if ((cur <= addr) && (addr < next)) return obj; | 1019 if ((cur <= addr) && (addr < next)) return obj; |
| 1020 } | 1020 } |
| 1021 | 1021 |
| 1022 UNREACHABLE(); | 1022 UNREACHABLE(); |
| 1023 return Failure::Exception(); | 1023 return Smi::FromInt(0); |
| 1024 } | 1024 } |
| 1025 | 1025 |
| 1026 | 1026 |
| 1027 bool PagedSpace::CanExpand() { | 1027 bool PagedSpace::CanExpand() { |
| 1028 ASSERT(max_capacity_ % AreaSize() == 0); | 1028 ASSERT(max_capacity_ % AreaSize() == 0); |
| 1029 | 1029 |
| 1030 if (Capacity() == max_capacity_) return false; | 1030 if (Capacity() == max_capacity_) return false; |
| 1031 | 1031 |
| 1032 ASSERT(Capacity() < max_capacity_); | 1032 ASSERT(Capacity() < max_capacity_); |
| 1033 | 1033 |
| (...skipping 1974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3008 LargePage* current = first_page_; | 3008 LargePage* current = first_page_; |
| 3009 while (current != NULL) { | 3009 while (current != NULL) { |
| 3010 size += current->CommittedPhysicalMemory(); | 3010 size += current->CommittedPhysicalMemory(); |
| 3011 current = current->next_page(); | 3011 current = current->next_page(); |
| 3012 } | 3012 } |
| 3013 return size; | 3013 return size; |
| 3014 } | 3014 } |
| 3015 | 3015 |
| 3016 | 3016 |
| 3017 // GC support | 3017 // GC support |
| 3018 MaybeObject* LargeObjectSpace::FindObject(Address a) { | 3018 Object* LargeObjectSpace::FindObject(Address a) { |
| 3019 LargePage* page = FindPage(a); | 3019 LargePage* page = FindPage(a); |
| 3020 if (page != NULL) { | 3020 if (page != NULL) { |
| 3021 return page->GetObject(); | 3021 return page->GetObject(); |
| 3022 } | 3022 } |
| 3023 return Failure::Exception(); | 3023 return Smi::FromInt(0); // Signaling not found. |
| 3024 } | 3024 } |
| 3025 | 3025 |
| 3026 | 3026 |
| 3027 LargePage* LargeObjectSpace::FindPage(Address a) { | 3027 LargePage* LargeObjectSpace::FindPage(Address a) { |
| 3028 uintptr_t key = reinterpret_cast<uintptr_t>(a) / MemoryChunk::kAlignment; | 3028 uintptr_t key = reinterpret_cast<uintptr_t>(a) / MemoryChunk::kAlignment; |
| 3029 HashMap::Entry* e = chunk_map_.Lookup(reinterpret_cast<void*>(key), | 3029 HashMap::Entry* e = chunk_map_.Lookup(reinterpret_cast<void*>(key), |
| 3030 static_cast<uint32_t>(key), | 3030 static_cast<uint32_t>(key), |
| 3031 false); | 3031 false); |
| 3032 if (e != NULL) { | 3032 if (e != NULL) { |
| 3033 ASSERT(e->value != NULL); | 3033 ASSERT(e->value != NULL); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3094 heap()->FreeQueuedChunks(); | 3094 heap()->FreeQueuedChunks(); |
| 3095 } | 3095 } |
| 3096 | 3096 |
| 3097 | 3097 |
| 3098 bool LargeObjectSpace::Contains(HeapObject* object) { | 3098 bool LargeObjectSpace::Contains(HeapObject* object) { |
| 3099 Address address = object->address(); | 3099 Address address = object->address(); |
| 3100 MemoryChunk* chunk = MemoryChunk::FromAddress(address); | 3100 MemoryChunk* chunk = MemoryChunk::FromAddress(address); |
| 3101 | 3101 |
| 3102 bool owned = (chunk->owner() == this); | 3102 bool owned = (chunk->owner() == this); |
| 3103 | 3103 |
| 3104 SLOW_ASSERT(!owned || !FindObject(address)->IsFailure()); | 3104 SLOW_ASSERT(!owned || FindObject(address)->IsHeapObject()); |
| 3105 | 3105 |
| 3106 return owned; | 3106 return owned; |
| 3107 } | 3107 } |
| 3108 | 3108 |
| 3109 | 3109 |
| 3110 #ifdef VERIFY_HEAP | 3110 #ifdef VERIFY_HEAP |
| 3111 // We do not assume that the large object iterator works, because it depends | 3111 // We do not assume that the large object iterator works, because it depends |
| 3112 // on the invariants we are checking during verification. | 3112 // on the invariants we are checking during verification. |
| 3113 void LargeObjectSpace::Verify() { | 3113 void LargeObjectSpace::Verify() { |
| 3114 for (LargePage* chunk = first_page_; | 3114 for (LargePage* chunk = first_page_; |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3214 object->ShortPrint(); | 3214 object->ShortPrint(); |
| 3215 PrintF("\n"); | 3215 PrintF("\n"); |
| 3216 } | 3216 } |
| 3217 printf(" --------------------------------------\n"); | 3217 printf(" --------------------------------------\n"); |
| 3218 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3218 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
| 3219 } | 3219 } |
| 3220 | 3220 |
| 3221 #endif // DEBUG | 3221 #endif // DEBUG |
| 3222 | 3222 |
| 3223 } } // namespace v8::internal | 3223 } } // namespace v8::internal |
| OLD | NEW |