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

Side by Side Diff: src/serialize.cc

Issue 355041: Made iteration of global handles more efficient on scavenges. (Closed)
Patch Set: Created 11 years, 1 month 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
« src/global-handles.cc ('K') | « src/mark-compact.cc ('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 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 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 // No active or weak handles. 1090 // No active or weak handles.
1091 CHECK(HandleScopeImplementer::instance()->blocks()->is_empty()); 1091 CHECK(HandleScopeImplementer::instance()->blocks()->is_empty());
1092 CHECK_EQ(0, GlobalHandles::NumberOfWeakHandles()); 1092 CHECK_EQ(0, GlobalHandles::NumberOfWeakHandles());
1093 // We need a counter function during serialization to resolve the 1093 // We need a counter function during serialization to resolve the
1094 // references to counters in the code on the heap. 1094 // references to counters in the code on the heap.
1095 CHECK(StatsTable::HasCounterFunction()); 1095 CHECK(StatsTable::HasCounterFunction());
1096 CHECK(enabled()); 1096 CHECK(enabled());
1097 InitializeAllocators(); 1097 InitializeAllocators();
1098 reference_encoder_ = new ExternalReferenceEncoder(); 1098 reference_encoder_ = new ExternalReferenceEncoder();
1099 PutHeader(); 1099 PutHeader();
1100 Heap::IterateRoots(this); 1100 Heap::IterateRoots(this, VISIT_ONLY_STRONG);
1101 PutLog(); 1101 PutLog();
1102 PutContextStack(); 1102 PutContextStack();
1103 Disable(); 1103 Disable();
1104 } 1104 }
1105 1105
1106 1106
1107 void Serializer::Finalize(byte** str, int* len) { 1107 void Serializer::Finalize(byte** str, int* len) {
1108 writer_->GetBytes(str, len); 1108 writer_->GetBytes(str, len);
1109 } 1109 }
1110 1110
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1193 writer_->PutInt(Heap::code_space()->Size() + Heap::new_space()->Size()); 1193 writer_->PutInt(Heap::code_space()->Size() + Heap::new_space()->Size());
1194 writer_->PutC('|'); 1194 writer_->PutC('|');
1195 writer_->PutInt(Heap::map_space()->Size()); 1195 writer_->PutInt(Heap::map_space()->Size());
1196 writer_->PutC('|'); 1196 writer_->PutC('|');
1197 writer_->PutInt(Heap::cell_space()->Size()); 1197 writer_->PutInt(Heap::cell_space()->Size());
1198 writer_->PutC(']'); 1198 writer_->PutC(']');
1199 // Write global handles. 1199 // Write global handles.
1200 writer_->PutC('G'); 1200 writer_->PutC('G');
1201 writer_->PutC('['); 1201 writer_->PutC('[');
1202 GlobalHandlesRetriever ghr(&global_handles_); 1202 GlobalHandlesRetriever ghr(&global_handles_);
1203 GlobalHandles::IterateRoots(&ghr); 1203 GlobalHandles::IterateStrongRoots(&ghr);
1204 for (int i = 0; i < global_handles_.length(); i++) { 1204 for (int i = 0; i < global_handles_.length(); i++) {
1205 writer_->PutC('N'); 1205 writer_->PutC('N');
1206 } 1206 }
1207 writer_->PutC(']'); 1207 writer_->PutC(']');
1208 } 1208 }
1209 1209
1210 1210
1211 void Serializer::PutLog() { 1211 void Serializer::PutLog() {
1212 #ifdef ENABLE_LOGGING_AND_PROFILING 1212 #ifdef ENABLE_LOGGING_AND_PROFILING
1213 if (FLAG_log_code) { 1213 if (FLAG_log_code) {
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1430 while (start < end) { 1430 while (start < end) {
1431 GlobalHandles::Destroy(start++); 1431 GlobalHandles::Destroy(start++);
1432 } 1432 }
1433 } 1433 }
1434 }; 1434 };
1435 1435
1436 1436
1437 void Deserializer::Deserialize() { 1437 void Deserializer::Deserialize() {
1438 // No global handles. 1438 // No global handles.
1439 NoGlobalHandlesChecker checker; 1439 NoGlobalHandlesChecker checker;
1440 GlobalHandles::IterateRoots(&checker); 1440 GlobalHandles::IterateStrongRoots(&checker);
1441 // No active threads. 1441 // No active threads.
1442 ASSERT_EQ(NULL, ThreadState::FirstInUse()); 1442 ASSERT_EQ(NULL, ThreadState::FirstInUse());
1443 // No active handles. 1443 // No active handles.
1444 ASSERT(HandleScopeImplementer::instance()->blocks()->is_empty()); 1444 ASSERT(HandleScopeImplementer::instance()->blocks()->is_empty());
1445 reference_decoder_ = new ExternalReferenceDecoder(); 1445 reference_decoder_ = new ExternalReferenceDecoder();
1446 // By setting linear allocation only, we forbid the use of free list 1446 // By setting linear allocation only, we forbid the use of free list
1447 // allocation which is not predicted by SimulatedAddress. 1447 // allocation which is not predicted by SimulatedAddress.
1448 GetHeader(); 1448 GetHeader();
1449 Heap::IterateRoots(this); 1449 Heap::IterateRoots(this, VISIT_ONLY_STRONG);
1450 GetContextStack(); 1450 GetContextStack();
1451 // Any global handles that have been set up by deserialization are leaked 1451 // Any global handles that have been set up by deserialization are leaked
1452 // since noone is keeping track of them. So we discard them now. 1452 // since noone is keeping track of them. So we discard them now.
1453 GlobalHandleDestroyer destroyer; 1453 GlobalHandleDestroyer destroyer;
1454 GlobalHandles::IterateRoots(&destroyer); 1454 GlobalHandles::IterateStrongRoots(&destroyer);
1455 } 1455 }
1456 1456
1457 1457
1458 void Deserializer::VisitPointers(Object** start, Object** end) { 1458 void Deserializer::VisitPointers(Object** start, Object** end) {
1459 bool root = root_; 1459 bool root = root_;
1460 root_ = false; 1460 root_ = false;
1461 for (Object** p = start; p < end; ++p) { 1461 for (Object** p = start; p < end; ++p) {
1462 if (root) { 1462 if (root) {
1463 roots_++; 1463 roots_++;
1464 // Read the next object or pointer from the stream 1464 // Read the next object or pointer from the stream
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
1847 // Don't GC while deserializing - just expand the heap. 1847 // Don't GC while deserializing - just expand the heap.
1848 AlwaysAllocateScope always_allocate; 1848 AlwaysAllocateScope always_allocate;
1849 // Don't use the free lists while deserializing. 1849 // Don't use the free lists while deserializing.
1850 LinearAllocationScope allocate_linearly; 1850 LinearAllocationScope allocate_linearly;
1851 // No active threads. 1851 // No active threads.
1852 ASSERT_EQ(NULL, ThreadState::FirstInUse()); 1852 ASSERT_EQ(NULL, ThreadState::FirstInUse());
1853 // No active handles. 1853 // No active handles.
1854 ASSERT(HandleScopeImplementer::instance()->blocks()->is_empty()); 1854 ASSERT(HandleScopeImplementer::instance()->blocks()->is_empty());
1855 ASSERT(external_reference_decoder_ == NULL); 1855 ASSERT(external_reference_decoder_ == NULL);
1856 external_reference_decoder_ = new ExternalReferenceDecoder(); 1856 external_reference_decoder_ = new ExternalReferenceDecoder();
1857 Heap::IterateRoots(this); 1857 Heap::IterateRoots(this, VISIT_ONLY_STRONG);
1858 ASSERT(source_->AtEOF()); 1858 ASSERT(source_->AtEOF());
1859 delete external_reference_decoder_; 1859 delete external_reference_decoder_;
1860 external_reference_decoder_ = NULL; 1860 external_reference_decoder_ = NULL;
1861 } 1861 }
1862 1862
1863 1863
1864 // This is called on the roots. It is the driver of the deserialization 1864 // This is called on the roots. It is the driver of the deserialization
1865 // process. It is also called on the body of each function. 1865 // process. It is also called on the body of each function.
1866 void Deserializer2::VisitPointers(Object** start, Object** end) { 1866 void Deserializer2::VisitPointers(Object** start, Object** end) {
1867 // The space must be new space. Any other space would cause ReadChunk to try 1867 // The space must be new space. Any other space would cause ReadChunk to try
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
2118 2118
2119 2119
2120 void Serializer2::Serialize() { 2120 void Serializer2::Serialize() {
2121 // No active threads. 2121 // No active threads.
2122 CHECK_EQ(NULL, ThreadState::FirstInUse()); 2122 CHECK_EQ(NULL, ThreadState::FirstInUse());
2123 // No active or weak handles. 2123 // No active or weak handles.
2124 CHECK(HandleScopeImplementer::instance()->blocks()->is_empty()); 2124 CHECK(HandleScopeImplementer::instance()->blocks()->is_empty());
2125 CHECK_EQ(0, GlobalHandles::NumberOfWeakHandles()); 2125 CHECK_EQ(0, GlobalHandles::NumberOfWeakHandles());
2126 ASSERT(external_reference_encoder_ == NULL); 2126 ASSERT(external_reference_encoder_ == NULL);
2127 external_reference_encoder_ = new ExternalReferenceEncoder(); 2127 external_reference_encoder_ = new ExternalReferenceEncoder();
2128 Heap::IterateRoots(this); 2128 Heap::IterateRoots(this, VISIT_ONLY_STRONG);
2129 delete external_reference_encoder_; 2129 delete external_reference_encoder_;
2130 external_reference_encoder_ = NULL; 2130 external_reference_encoder_ = NULL;
2131 } 2131 }
2132 2132
2133 2133
2134 void Serializer2::VisitPointers(Object** start, Object** end) { 2134 void Serializer2::VisitPointers(Object** start, Object** end) {
2135 for (Object** current = start; current < end; current++) { 2135 for (Object** current = start; current < end; current++) {
2136 if ((*current)->IsSmi()) { 2136 if ((*current)->IsSmi()) {
2137 sink_->Put(RAW_DATA_SERIALIZATION, "RawData"); 2137 sink_->Put(RAW_DATA_SERIALIZATION, "RawData");
2138 sink_->PutInt(kPointerSize, "length"); 2138 sink_->PutInt(kPointerSize, "length");
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
2384 fullness_[space] = RoundUp(fullness_[space], Page::kPageSize); 2384 fullness_[space] = RoundUp(fullness_[space], Page::kPageSize);
2385 } 2385 }
2386 } 2386 }
2387 int allocation_address = fullness_[space]; 2387 int allocation_address = fullness_[space];
2388 fullness_[space] = allocation_address + size; 2388 fullness_[space] = allocation_address + size;
2389 return allocation_address; 2389 return allocation_address;
2390 } 2390 }
2391 2391
2392 2392
2393 } } // namespace v8::internal 2393 } } // namespace v8::internal
OLDNEW
« src/global-handles.cc ('K') | « src/mark-compact.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698