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

Side by Side Diff: src/serialize.cc

Issue 9537011: Merge r10809 into 3.7 branch (Closed) Base URL: http://v8.googlecode.com/svn/branches/3.7/
Patch Set: Created 8 years, 9 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/serialize.h ('k') | src/spaces.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 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 } 1111 }
1112 1112
1113 #endif 1113 #endif
1114 1114
1115 Serializer::Serializer(SnapshotByteSink* sink) 1115 Serializer::Serializer(SnapshotByteSink* sink)
1116 : sink_(sink), 1116 : sink_(sink),
1117 current_root_index_(0), 1117 current_root_index_(0),
1118 external_reference_encoder_(new ExternalReferenceEncoder), 1118 external_reference_encoder_(new ExternalReferenceEncoder),
1119 large_object_total_(0), 1119 large_object_total_(0),
1120 root_index_wave_front_(0) { 1120 root_index_wave_front_(0) {
1121 isolate_ = Isolate::Current();
1121 // The serializer is meant to be used only to generate initial heap images 1122 // The serializer is meant to be used only to generate initial heap images
1122 // from a context in which there is only one isolate. 1123 // from a context in which there is only one isolate.
1123 ASSERT(Isolate::Current()->IsDefaultIsolate()); 1124 ASSERT(isolate_->IsDefaultIsolate());
1124 for (int i = 0; i <= LAST_SPACE; i++) { 1125 for (int i = 0; i <= LAST_SPACE; i++) {
1125 fullness_[i] = 0; 1126 fullness_[i] = 0;
1126 } 1127 }
1127 } 1128 }
1128 1129
1129 1130
1130 Serializer::~Serializer() { 1131 Serializer::~Serializer() {
1131 delete external_reference_encoder_; 1132 delete external_reference_encoder_;
1132 } 1133 }
1133 1134
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
1658 } 1659 }
1659 if (SpaceIsPaged(space)) { 1660 if (SpaceIsPaged(space)) {
1660 // Paged spaces are a little special. We encode their addresses as if the 1661 // Paged spaces are a little special. We encode their addresses as if the
1661 // pages were all contiguous and each page were filled up in the range 1662 // pages were all contiguous and each page were filled up in the range
1662 // 0 - Page::kObjectAreaSize. In practice the pages may not be contiguous 1663 // 0 - Page::kObjectAreaSize. In practice the pages may not be contiguous
1663 // and allocation does not start at offset 0 in the page, but this scheme 1664 // and allocation does not start at offset 0 in the page, but this scheme
1664 // means the deserializer can get the page number quickly by shifting the 1665 // means the deserializer can get the page number quickly by shifting the
1665 // serialized address. 1666 // serialized address.
1666 CHECK(IsPowerOf2(Page::kPageSize)); 1667 CHECK(IsPowerOf2(Page::kPageSize));
1667 int used_in_this_page = (fullness_[space] & (Page::kPageSize - 1)); 1668 int used_in_this_page = (fullness_[space] & (Page::kPageSize - 1));
1668 CHECK(size <= Page::kObjectAreaSize); 1669 CHECK(size <= SpaceAreaSize(space));
1669 if (used_in_this_page + size > Page::kObjectAreaSize) { 1670 if (used_in_this_page + size > SpaceAreaSize(space)) {
1670 *new_page = true; 1671 *new_page = true;
1671 fullness_[space] = RoundUp(fullness_[space], Page::kPageSize); 1672 fullness_[space] = RoundUp(fullness_[space], Page::kPageSize);
1672 } 1673 }
1673 } 1674 }
1674 int allocation_address = fullness_[space]; 1675 int allocation_address = fullness_[space];
1675 fullness_[space] = allocation_address + size; 1676 fullness_[space] = allocation_address + size;
1676 return allocation_address; 1677 return allocation_address;
1677 } 1678 }
1678 1679
1679 1680
1681 int Serializer::SpaceAreaSize(int space) {
1682 if (space == CODE_SPACE) {
1683 return isolate_->memory_allocator()->CodePageAreaSize();
1684 } else {
1685 return Page::kPageSize - Page::kObjectStartOffset;
1686 }
1687 }
1688
1689
1680 } } // namespace v8::internal 1690 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/serialize.h ('k') | src/spaces.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698