Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
| 8 #include "src/api.h" | 8 #include "src/api.h" |
| 9 #include "src/base/platform/platform.h" | 9 #include "src/base/platform/platform.h" |
| 10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
| (...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1202 } | 1202 } |
| 1203 | 1203 |
| 1204 | 1204 |
| 1205 Serializer::Serializer(Isolate* isolate, SnapshotByteSink* sink) | 1205 Serializer::Serializer(Isolate* isolate, SnapshotByteSink* sink) |
| 1206 : isolate_(isolate), | 1206 : isolate_(isolate), |
| 1207 sink_(sink), | 1207 sink_(sink), |
| 1208 external_reference_encoder_(isolate), | 1208 external_reference_encoder_(isolate), |
| 1209 root_index_map_(isolate), | 1209 root_index_map_(isolate), |
| 1210 code_address_map_(NULL), | 1210 code_address_map_(NULL), |
| 1211 large_objects_total_size_(0), | 1211 large_objects_total_size_(0), |
| 1212 seen_large_objects_index_(0) { | 1212 seen_large_objects_index_(0), |
| 1213 instance_type_count_(NULL) { | |
| 1213 // The serializer is meant to be used only to generate initial heap images | 1214 // The serializer is meant to be used only to generate initial heap images |
| 1214 // from a context in which there is only one isolate. | 1215 // from a context in which there is only one isolate. |
| 1215 for (int i = 0; i < kNumberOfPreallocatedSpaces; i++) { | 1216 for (int i = 0; i < kNumberOfPreallocatedSpaces; i++) { |
| 1216 pending_chunk_[i] = 0; | 1217 pending_chunk_[i] = 0; |
| 1217 max_chunk_size_[i] = static_cast<uint32_t>( | 1218 max_chunk_size_[i] = static_cast<uint32_t>( |
| 1218 MemoryAllocator::PageAreaSize(static_cast<AllocationSpace>(i))); | 1219 MemoryAllocator::PageAreaSize(static_cast<AllocationSpace>(i))); |
| 1219 } | 1220 } |
| 1221 | |
| 1222 if (FLAG_serialization_statistics) { | |
| 1223 instance_type_count_ = NewArray<int>(kInstanceTypes); | |
| 1224 for (int i = 0; i < kInstanceTypes; i++) instance_type_count_[i] = 0; | |
| 1225 } | |
| 1220 } | 1226 } |
| 1221 | 1227 |
| 1222 | 1228 |
| 1223 Serializer::~Serializer() { | 1229 Serializer::~Serializer() { |
| 1224 if (code_address_map_ != NULL) delete code_address_map_; | 1230 if (code_address_map_ != NULL) delete code_address_map_; |
| 1231 if (instance_type_count_ != NULL) DeleteArray(instance_type_count_); | |
| 1225 } | 1232 } |
| 1226 | 1233 |
| 1227 | 1234 |
| 1235 void Serializer::OutputStatistics(const char* name) { | |
| 1236 if (!FLAG_serialization_statistics) return; | |
| 1237 PrintF("%s:\n", name); | |
| 1238 PrintF(" Spaces:\n"); | |
|
Jakob Kummerow
2015/04/16 12:32:25
nit: maybe " Space usage (bytes):\n"?
Yang
2015/04/16 13:00:43
Done.
| |
| 1239 for (int space = 0; space < kNumberOfSpaces; space++) { | |
| 1240 PrintF("%16s", AllocationSpaceName(static_cast<AllocationSpace>(space))); | |
| 1241 } | |
| 1242 PrintF("\n"); | |
| 1243 for (int space = 0; space < kNumberOfPreallocatedSpaces; space++) { | |
| 1244 int s = pending_chunk_[space]; | |
|
Jakob Kummerow
2015/04/16 12:32:25
s/int/uint32_t/, as pending_chunk_ is a uint32_t (
Yang
2015/04/16 13:00:43
Done.
| |
| 1245 for (uint32_t chunk_size : completed_chunks_[space]) s += chunk_size; | |
| 1246 PrintF("%16d", s); | |
| 1247 } | |
| 1248 PrintF("%16d\n", large_objects_total_size_); | |
| 1249 #ifdef OBJECT_PRINT | |
| 1250 PrintF(" Instance types:\n"); | |
|
Jakob Kummerow
2015/04/16 12:32:25
nit: maybe " Instance types (count):\n"?
I can h
Yang
2015/04/16 13:00:43
Wish and you shall receive.
| |
| 1251 #define PRINT_INSTANCE_TYPE(Name) \ | |
| 1252 if (instance_type_count_[Name]) { \ | |
| 1253 PrintF("%10d %s\n", instance_type_count_[Name], #Name); \ | |
| 1254 } | |
| 1255 INSTANCE_TYPE_LIST(PRINT_INSTANCE_TYPE) | |
| 1256 #undef PRINT_INSTANCE_TYPE | |
| 1257 PrintF("\n"); | |
| 1258 #endif // OBJECT_PRINT | |
| 1259 } | |
| 1260 | |
| 1261 | |
| 1228 void StartupSerializer::SerializeStrongReferences() { | 1262 void StartupSerializer::SerializeStrongReferences() { |
| 1229 Isolate* isolate = this->isolate(); | 1263 Isolate* isolate = this->isolate(); |
| 1230 // No active threads. | 1264 // No active threads. |
| 1231 CHECK_NULL(isolate->thread_manager()->FirstThreadStateInUse()); | 1265 CHECK_NULL(isolate->thread_manager()->FirstThreadStateInUse()); |
| 1232 // No active or weak handles. | 1266 // No active or weak handles. |
| 1233 CHECK(isolate->handle_scope_implementer()->blocks()->is_empty()); | 1267 CHECK(isolate->handle_scope_implementer()->blocks()->is_empty()); |
| 1234 CHECK_EQ(0, isolate->global_handles()->NumberOfWeakHandles()); | 1268 CHECK_EQ(0, isolate->global_handles()->NumberOfWeakHandles()); |
| 1235 CHECK_EQ(0, isolate->eternal_handles()->NumberOfHandles()); | 1269 CHECK_EQ(0, isolate->eternal_handles()->NumberOfHandles()); |
| 1236 // We don't support serializing installed extensions. | 1270 // We don't support serializing installed extensions. |
| 1237 CHECK(!isolate->has_installed_extensions()); | 1271 CHECK(!isolate->has_installed_extensions()); |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1630 back_reference = serializer_->Allocate(space, size); | 1664 back_reference = serializer_->Allocate(space, size); |
| 1631 } | 1665 } |
| 1632 sink_->Put(kNewObject + reference_representation_ + space, "NewObject"); | 1666 sink_->Put(kNewObject + reference_representation_ + space, "NewObject"); |
| 1633 if (needs_double_align) | 1667 if (needs_double_align) |
| 1634 sink_->PutInt(kDoubleAlignmentSentinel, "DoubleAlignSentinel"); | 1668 sink_->PutInt(kDoubleAlignmentSentinel, "DoubleAlignSentinel"); |
| 1635 int encoded_size = size >> kObjectAlignmentBits; | 1669 int encoded_size = size >> kObjectAlignmentBits; |
| 1636 DCHECK_NE(kDoubleAlignmentSentinel, encoded_size); | 1670 DCHECK_NE(kDoubleAlignmentSentinel, encoded_size); |
| 1637 sink_->PutInt(encoded_size, "ObjectSizeInWords"); | 1671 sink_->PutInt(encoded_size, "ObjectSizeInWords"); |
| 1638 } | 1672 } |
| 1639 | 1673 |
| 1674 if (FLAG_serialization_statistics) { | |
| 1675 serializer_->CountInstanceType(object_->map()->instance_type()); | |
| 1676 } | |
| 1677 | |
| 1640 // Mark this object as already serialized. | 1678 // Mark this object as already serialized. |
| 1641 serializer_->back_reference_map()->Add(object_, back_reference); | 1679 serializer_->back_reference_map()->Add(object_, back_reference); |
| 1642 | 1680 |
| 1643 // Serialize the map (first word of the object). | 1681 // Serialize the map (first word of the object). |
| 1644 serializer_->SerializeObject(map, kPlain, kStartOfObject, 0); | 1682 serializer_->SerializeObject(map, kPlain, kStartOfObject, 0); |
| 1645 } | 1683 } |
| 1646 | 1684 |
| 1647 | 1685 |
| 1648 void Serializer::ObjectSerializer::SerializeExternalString() { | 1686 void Serializer::ObjectSerializer::SerializeExternalString() { |
| 1649 // Instead of serializing this as an external string, we serialize | 1687 // Instead of serializing this as an external string, we serialize |
| (...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2529 DisallowHeapAllocation no_gc; | 2567 DisallowHeapAllocation no_gc; |
| 2530 SerializedCodeData* scd = new SerializedCodeData(cached_data); | 2568 SerializedCodeData* scd = new SerializedCodeData(cached_data); |
| 2531 SanityCheckResult r = scd->SanityCheck(isolate, source); | 2569 SanityCheckResult r = scd->SanityCheck(isolate, source); |
| 2532 if (r == CHECK_SUCCESS) return scd; | 2570 if (r == CHECK_SUCCESS) return scd; |
| 2533 cached_data->Reject(); | 2571 cached_data->Reject(); |
| 2534 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); | 2572 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); |
| 2535 delete scd; | 2573 delete scd; |
| 2536 return NULL; | 2574 return NULL; |
| 2537 } | 2575 } |
| 2538 } } // namespace v8::internal | 2576 } } // namespace v8::internal |
| OLD | NEW |