| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 |
| 11 // with the distribution. | 11 // with the distribution. |
| (...skipping 1062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1074 void SnapshotByteSink::PutInt(uintptr_t integer, const char* description) { | 1074 void SnapshotByteSink::PutInt(uintptr_t integer, const char* description) { |
| 1075 const int max_shift = ((kPointerSize * kBitsPerByte) / 7) * 7; | 1075 const int max_shift = ((kPointerSize * kBitsPerByte) / 7) * 7; |
| 1076 for (int shift = max_shift; shift > 0; shift -= 7) { | 1076 for (int shift = max_shift; shift > 0; shift -= 7) { |
| 1077 if (integer >= static_cast<uintptr_t>(1u) << shift) { | 1077 if (integer >= static_cast<uintptr_t>(1u) << shift) { |
| 1078 Put((static_cast<int>((integer >> shift)) & 0x7f) | 0x80, "IntPart"); | 1078 Put((static_cast<int>((integer >> shift)) & 0x7f) | 0x80, "IntPart"); |
| 1079 } | 1079 } |
| 1080 } | 1080 } |
| 1081 PutSection(static_cast<int>(integer & 0x7f), "IntLastPart"); | 1081 PutSection(static_cast<int>(integer & 0x7f), "IntLastPart"); |
| 1082 } | 1082 } |
| 1083 | 1083 |
| 1084 #ifdef DEBUG | |
| 1085 | |
| 1086 void Deserializer::Synchronize(const char* tag) { | |
| 1087 int data = source_->Get(); | |
| 1088 // If this assert fails then that indicates that you have a mismatch between | |
| 1089 // the number of GC roots when serializing and deserializing. | |
| 1090 ASSERT_EQ(kSynchronize, data); | |
| 1091 do { | |
| 1092 int character = source_->Get(); | |
| 1093 if (character == 0) break; | |
| 1094 if (FLAG_debug_serialization) { | |
| 1095 PrintF("%c", character); | |
| 1096 } | |
| 1097 } while (true); | |
| 1098 if (FLAG_debug_serialization) { | |
| 1099 PrintF("\n"); | |
| 1100 } | |
| 1101 } | |
| 1102 | |
| 1103 | |
| 1104 void Serializer::Synchronize(const char* tag) { | |
| 1105 sink_->Put(kSynchronize, tag); | |
| 1106 int character; | |
| 1107 do { | |
| 1108 character = *tag++; | |
| 1109 sink_->PutSection(character, "TagCharacter"); | |
| 1110 } while (character != 0); | |
| 1111 } | |
| 1112 | |
| 1113 #endif | |
| 1114 | 1084 |
| 1115 Serializer::Serializer(SnapshotByteSink* sink) | 1085 Serializer::Serializer(SnapshotByteSink* sink) |
| 1116 : sink_(sink), | 1086 : sink_(sink), |
| 1117 current_root_index_(0), | 1087 current_root_index_(0), |
| 1118 external_reference_encoder_(new ExternalReferenceEncoder), | 1088 external_reference_encoder_(new ExternalReferenceEncoder), |
| 1119 large_object_total_(0), | 1089 large_object_total_(0), |
| 1120 root_index_wave_front_(0) { | 1090 root_index_wave_front_(0) { |
| 1121 // The serializer is meant to be used only to generate initial heap images | 1091 // The serializer is meant to be used only to generate initial heap images |
| 1122 // from a context in which there is only one isolate. | 1092 // from a context in which there is only one isolate. |
| 1123 ASSERT(Isolate::Current()->IsDefaultIsolate()); | 1093 ASSERT(Isolate::Current()->IsDefaultIsolate()); |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1678 fullness_[space] = RoundUp(fullness_[space], Page::kPageSize); | 1648 fullness_[space] = RoundUp(fullness_[space], Page::kPageSize); |
| 1679 } | 1649 } |
| 1680 } | 1650 } |
| 1681 int allocation_address = fullness_[space]; | 1651 int allocation_address = fullness_[space]; |
| 1682 fullness_[space] = allocation_address + size; | 1652 fullness_[space] = allocation_address + size; |
| 1683 return allocation_address; | 1653 return allocation_address; |
| 1684 } | 1654 } |
| 1685 | 1655 |
| 1686 | 1656 |
| 1687 } } // namespace v8::internal | 1657 } } // namespace v8::internal |
| OLD | NEW |