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

Side by Side Diff: src/spaces.cc

Issue 7870003: Guard against rare case of allocation failure during evacuation. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/gc
Patch Set: Created 9 years, 3 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') | no next file » | 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 703 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) { 714 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) {
715 Address cur = obj->address(); 715 Address cur = obj->address();
716 Address next = cur + obj->Size(); 716 Address next = cur + obj->Size();
717 if ((cur <= addr) && (addr < next)) return obj; 717 if ((cur <= addr) && (addr < next)) return obj;
718 } 718 }
719 719
720 UNREACHABLE(); 720 UNREACHABLE();
721 return Failure::Exception(); 721 return Failure::Exception();
722 } 722 }
723 723
724 724 bool PagedSpace::CanExpand() {
725 bool PagedSpace::Expand() {
726 ASSERT(max_capacity_ % Page::kObjectAreaSize == 0); 725 ASSERT(max_capacity_ % Page::kObjectAreaSize == 0);
727 ASSERT(Capacity() % Page::kObjectAreaSize == 0); 726 ASSERT(Capacity() % Page::kObjectAreaSize == 0);
728 727
729 if (Capacity() == max_capacity_) return false; 728 if (Capacity() == max_capacity_) return false;
730 729
731 ASSERT(Capacity() < max_capacity_); 730 ASSERT(Capacity() < max_capacity_);
732 731
733 // Are we going to exceed capacity for this space? 732 // Are we going to exceed capacity for this space?
734 if ((Capacity() + Page::kPageSize) > max_capacity_) return false; 733 if ((Capacity() + Page::kPageSize) > max_capacity_) return false;
735 734
735 return true;
736 }
737
738 bool PagedSpace::Expand() {
739 if (!CanExpand()) return false;
740
736 Page* p = heap()->isolate()->memory_allocator()-> 741 Page* p = heap()->isolate()->memory_allocator()->
737 AllocatePage(this, executable()); 742 AllocatePage(this, executable());
738 if (p == NULL) return false; 743 if (p == NULL) return false;
739 744
740 ASSERT(Capacity() <= max_capacity_); 745 ASSERT(Capacity() <= max_capacity_);
741 746
742 p->InsertAfter(anchor_.prev_page()); 747 p->InsertAfter(anchor_.prev_page());
743 748
744 return true; 749 return true;
745 } 750 }
(...skipping 1759 matching lines...) Expand 10 before | Expand all | Expand 10 after
2505 for (HeapObject* obj = obj_it.Next(); obj != NULL; obj = obj_it.Next()) { 2510 for (HeapObject* obj = obj_it.Next(); obj != NULL; obj = obj_it.Next()) {
2506 if (obj->IsCode()) { 2511 if (obj->IsCode()) {
2507 Code* code = Code::cast(obj); 2512 Code* code = Code::cast(obj);
2508 isolate->code_kind_statistics()[code->kind()] += code->Size(); 2513 isolate->code_kind_statistics()[code->kind()] += code->Size();
2509 } 2514 }
2510 } 2515 }
2511 } 2516 }
2512 #endif // DEBUG 2517 #endif // DEBUG
2513 2518
2514 } } // namespace v8::internal 2519 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/spaces.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698