Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: src/spaces.cc

Issue 7744023: Two tiny refactorings: Removed a bit of copy-n-paste. Moved LargeObjectChunk::Free from header to... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/spaces.h ('k') | src/spaces-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2704 matching lines...) Expand 10 before | Expand all | Expand 10 after
2715 } 2715 }
2716 2716
2717 ObjectSpace space = (executable == EXECUTABLE) 2717 ObjectSpace space = (executable == EXECUTABLE)
2718 ? kObjectSpaceCodeSpace 2718 ? kObjectSpaceCodeSpace
2719 : kObjectSpaceLoSpace; 2719 : kObjectSpaceLoSpace;
2720 isolate->memory_allocator()->PerformAllocationCallback( 2720 isolate->memory_allocator()->PerformAllocationCallback(
2721 space, kAllocationActionAllocate, size); 2721 space, kAllocationActionAllocate, size);
2722 2722
2723 LargeObjectChunk* chunk = reinterpret_cast<LargeObjectChunk*>(mem); 2723 LargeObjectChunk* chunk = reinterpret_cast<LargeObjectChunk*>(mem);
2724 chunk->size_ = size; 2724 chunk->size_ = size;
2725 Page* page = Page::FromAddress(RoundUp(chunk->address(), Page::kPageSize)); 2725 chunk->GetPage()->heap_ = isolate->heap();
2726 page->heap_ = isolate->heap();
2727 return chunk; 2726 return chunk;
2728 } 2727 }
2729 2728
2730 2729
2730 void LargeObjectChunk::Free(Executability executable) {
2731 Isolate* isolate = GetPage()->heap_->isolate();
2732 isolate->memory_allocator()->FreeRawMemory(address(), size(), executable);
2733 }
2734
2735
2731 int LargeObjectChunk::ChunkSizeFor(int size_in_bytes) { 2736 int LargeObjectChunk::ChunkSizeFor(int size_in_bytes) {
2732 int os_alignment = static_cast<int>(OS::AllocateAlignment()); 2737 int os_alignment = static_cast<int>(OS::AllocateAlignment());
2733 if (os_alignment < Page::kPageSize) { 2738 if (os_alignment < Page::kPageSize) {
2734 size_in_bytes += (Page::kPageSize - os_alignment); 2739 size_in_bytes += (Page::kPageSize - os_alignment);
2735 } 2740 }
2736 return size_in_bytes + Page::kObjectStartOffset; 2741 return size_in_bytes + Page::kObjectStartOffset;
2737 } 2742 }
2738 2743
2739 // ----------------------------------------------------------------------------- 2744 // -----------------------------------------------------------------------------
2740 // LargeObjectSpace 2745 // LargeObjectSpace
(...skipping 13 matching lines...) Expand all
2754 objects_size_ = 0; 2759 objects_size_ = 0;
2755 return true; 2760 return true;
2756 } 2761 }
2757 2762
2758 2763
2759 void LargeObjectSpace::TearDown() { 2764 void LargeObjectSpace::TearDown() {
2760 while (first_chunk_ != NULL) { 2765 while (first_chunk_ != NULL) {
2761 LargeObjectChunk* chunk = first_chunk_; 2766 LargeObjectChunk* chunk = first_chunk_;
2762 first_chunk_ = first_chunk_->next(); 2767 first_chunk_ = first_chunk_->next();
2763 LOG(heap()->isolate(), DeleteEvent("LargeObjectChunk", chunk->address())); 2768 LOG(heap()->isolate(), DeleteEvent("LargeObjectChunk", chunk->address()));
2764 Page* page = Page::FromAddress(RoundUp(chunk->address(), Page::kPageSize)); 2769 Executability executable = chunk->GetPage()->PageExecutability();
2765 Executability executable = page->PageExecutability();
2766 ObjectSpace space = kObjectSpaceLoSpace; 2770 ObjectSpace space = kObjectSpaceLoSpace;
2767 if (executable == EXECUTABLE) space = kObjectSpaceCodeSpace; 2771 if (executable == EXECUTABLE) space = kObjectSpaceCodeSpace;
2768 size_t size = chunk->size(); 2772 size_t size = chunk->size();
2769 size_t guard_size = (executable == EXECUTABLE) ? Page::kPageSize : 0; 2773 size_t guard_size = (executable == EXECUTABLE) ? Page::kPageSize : 0;
2770 heap()->isolate()->memory_allocator()->FreeRawMemory( 2774 heap()->isolate()->memory_allocator()->FreeRawMemory(
2771 chunk->address() - guard_size, 2775 chunk->address() - guard_size,
2772 size + guard_size, 2776 size + guard_size,
2773 executable); 2777 executable);
2774 heap()->isolate()->memory_allocator()->PerformAllocationCallback( 2778 heap()->isolate()->memory_allocator()->PerformAllocationCallback(
2775 space, kAllocationActionFree, size); 2779 space, kAllocationActionFree, size);
(...skipping 22 matching lines...) Expand all
2798 return Failure::RetryAfterGC(identity()); 2802 return Failure::RetryAfterGC(identity());
2799 } 2803 }
2800 2804
2801 size_ += static_cast<int>(chunk->size()); 2805 size_ += static_cast<int>(chunk->size());
2802 objects_size_ += requested_size; 2806 objects_size_ += requested_size;
2803 page_count_++; 2807 page_count_++;
2804 chunk->set_next(first_chunk_); 2808 chunk->set_next(first_chunk_);
2805 first_chunk_ = chunk; 2809 first_chunk_ = chunk;
2806 2810
2807 // Initialize page header. 2811 // Initialize page header.
2808 Page* page = Page::FromAddress(RoundUp(chunk->address(), Page::kPageSize)); 2812 Page* page = chunk->GetPage();
2809 Address object_address = page->ObjectAreaStart(); 2813 Address object_address = page->ObjectAreaStart();
2810 2814
2811 // Clear the low order bit of the second word in the page to flag it as a 2815 // Clear the low order bit of the second word in the page to flag it as a
2812 // large object page. If the chunk_size happened to be written there, its 2816 // large object page. If the chunk_size happened to be written there, its
2813 // low order bit should already be clear. 2817 // low order bit should already be clear.
2814 page->SetIsLargeObjectPage(true); 2818 page->SetIsLargeObjectPage(true);
2815 page->SetPageExecutability(executable); 2819 page->SetPageExecutability(executable);
2816 page->SetRegionMarks(Page::kAllRegionsCleanMarks); 2820 page->SetRegionMarks(Page::kAllRegionsCleanMarks);
2817 return HeapObject::FromAddress(object_address); 2821 return HeapObject::FromAddress(object_address);
2818 } 2822 }
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
2936 LargeObjectChunk* previous = NULL; 2940 LargeObjectChunk* previous = NULL;
2937 LargeObjectChunk* current = first_chunk_; 2941 LargeObjectChunk* current = first_chunk_;
2938 while (current != NULL) { 2942 while (current != NULL) {
2939 HeapObject* object = current->GetObject(); 2943 HeapObject* object = current->GetObject();
2940 if (object->IsMarked()) { 2944 if (object->IsMarked()) {
2941 object->ClearMark(); 2945 object->ClearMark();
2942 heap()->mark_compact_collector()->tracer()->decrement_marked_count(); 2946 heap()->mark_compact_collector()->tracer()->decrement_marked_count();
2943 previous = current; 2947 previous = current;
2944 current = current->next(); 2948 current = current->next();
2945 } else { 2949 } else {
2946 Page* page = Page::FromAddress(RoundUp(current->address(), 2950 Executability executable = current->GetPage()->PageExecutability();
2947 Page::kPageSize));
2948 Executability executable = page->PageExecutability();
2949 Address chunk_address = current->address(); 2951 Address chunk_address = current->address();
2950 size_t chunk_size = current->size(); 2952 size_t chunk_size = current->size();
2951 2953
2952 // Cut the chunk out from the chunk list. 2954 // Cut the chunk out from the chunk list.
2953 current = current->next(); 2955 current = current->next();
2954 if (previous == NULL) { 2956 if (previous == NULL) {
2955 first_chunk_ = current; 2957 first_chunk_ = current;
2956 } else { 2958 } else {
2957 previous->set_next(current); 2959 previous->set_next(current);
2958 } 2960 }
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
3087 for (HeapObject* obj = obj_it.next(); obj != NULL; obj = obj_it.next()) { 3089 for (HeapObject* obj = obj_it.next(); obj != NULL; obj = obj_it.next()) {
3088 if (obj->IsCode()) { 3090 if (obj->IsCode()) {
3089 Code* code = Code::cast(obj); 3091 Code* code = Code::cast(obj);
3090 isolate->code_kind_statistics()[code->kind()] += code->Size(); 3092 isolate->code_kind_statistics()[code->kind()] += code->Size();
3091 } 3093 }
3092 } 3094 }
3093 } 3095 }
3094 #endif // DEBUG 3096 #endif // DEBUG
3095 3097
3096 } } // namespace v8::internal 3098 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/spaces.h ('k') | src/spaces-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698