OLD | NEW |
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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 int roots() { return roots_; } | 141 int roots() { return roots_; } |
142 int objects() { return objects_; } | 142 int objects() { return objects_; } |
143 | 143 |
144 #ifdef DEBUG | 144 #ifdef DEBUG |
145 // insert "tag" into the serialized stream | 145 // insert "tag" into the serialized stream |
146 virtual void Synchronize(const char* tag); | 146 virtual void Synchronize(const char* tag); |
147 #endif | 147 #endif |
148 | 148 |
149 static bool enabled() { return serialization_enabled_; } | 149 static bool enabled() { return serialization_enabled_; } |
150 | 150 |
151 static void Enable() { serialization_enabled_ = true; } | 151 static void Enable() { |
| 152 if (!serialization_enabled_) { |
| 153 ASSERT(!too_late_to_enable_now_); |
| 154 } |
| 155 serialization_enabled_ = true; |
| 156 } |
| 157 |
152 static void Disable() { serialization_enabled_ = false; } | 158 static void Disable() { serialization_enabled_ = false; } |
| 159 // Call this when you have made use of the fact that there is no serialization |
| 160 // going on. |
| 161 static void TooLateToEnableNow() { too_late_to_enable_now_ = true; } |
153 | 162 |
154 private: | 163 private: |
155 friend class ReferenceUpdater; | 164 friend class ReferenceUpdater; |
156 | 165 |
157 virtual void VisitPointers(Object** start, Object** end); | 166 virtual void VisitPointers(Object** start, Object** end); |
158 virtual void VisitCodeTarget(RelocInfo* rinfo); | 167 virtual void VisitCodeTarget(RelocInfo* rinfo); |
159 bool IsVisited(HeapObject* obj); | 168 bool IsVisited(HeapObject* obj); |
160 | 169 |
161 Address GetSavedAddress(HeapObject* obj); | 170 Address GetSavedAddress(HeapObject* obj); |
162 | 171 |
(...skipping 24 matching lines...) Expand all Loading... |
187 RelativeAddress Allocate(HeapObject* obj); | 196 RelativeAddress Allocate(HeapObject* obj); |
188 | 197 |
189 void InitializeAllocators(); | 198 void InitializeAllocators(); |
190 | 199 |
191 SnapshotWriter* writer_; | 200 SnapshotWriter* writer_; |
192 bool root_; // serializing a root? | 201 bool root_; // serializing a root? |
193 int roots_; // number of roots visited | 202 int roots_; // number of roots visited |
194 int objects_; // number of objects serialized | 203 int objects_; // number of objects serialized |
195 | 204 |
196 static bool serialization_enabled_; | 205 static bool serialization_enabled_; |
| 206 // Did we already make use of the fact that serialization was not enabled? |
| 207 static bool too_late_to_enable_now_; |
197 | 208 |
198 int flags_end_; // The position right after the flags. | 209 int flags_end_; // The position right after the flags. |
199 | 210 |
200 // An array of per-space SimulatedHeapSpaces used as memory allocators. | 211 // An array of per-space SimulatedHeapSpaces used as memory allocators. |
201 SimulatedHeapSpace* allocator_[LAST_SPACE+1]; | 212 SimulatedHeapSpace* allocator_[LAST_SPACE+1]; |
202 // A list of global handles at serialization time. | 213 // A list of global handles at serialization time. |
203 List<Object**> global_handles_; | 214 List<Object**> global_handles_; |
204 | 215 |
205 ExternalReferenceEncoder* reference_encoder_; | 216 ExternalReferenceEncoder* reference_encoder_; |
206 | 217 |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 | 629 |
619 friend class ObjectSerializer; | 630 friend class ObjectSerializer; |
620 friend class Deserializer2; | 631 friend class Deserializer2; |
621 | 632 |
622 DISALLOW_COPY_AND_ASSIGN(Serializer2); | 633 DISALLOW_COPY_AND_ASSIGN(Serializer2); |
623 }; | 634 }; |
624 | 635 |
625 } } // namespace v8::internal | 636 } } // namespace v8::internal |
626 | 637 |
627 #endif // V8_SERIALIZE_H_ | 638 #endif // V8_SERIALIZE_H_ |
OLD | NEW |