| 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 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 926 | 926 |
| 927 | 927 |
| 928 void Serializer::Finalize(char** str, int* len) { | 928 void Serializer::Finalize(char** str, int* len) { |
| 929 writer_->GetString(str, len); | 929 writer_->GetString(str, len); |
| 930 } | 930 } |
| 931 | 931 |
| 932 | 932 |
| 933 // Serialize objects by writing them into the stream. | 933 // Serialize objects by writing them into the stream. |
| 934 | 934 |
| 935 void Serializer::VisitPointers(Object** start, Object** end) { | 935 void Serializer::VisitPointers(Object** start, Object** end) { |
| 936 bool root = root_; | 936 TempAssign<bool> temp_root(&root_, false); |
| 937 root_ = false; | |
| 938 for (Object** p = start; p < end; ++p) { | 937 for (Object** p = start; p < end; ++p) { |
| 939 bool serialized; | 938 bool serialized; |
| 940 Address a = Encode(*p, &serialized); | 939 Address a = Encode(*p, &serialized); |
| 941 if (root) { | 940 if (temp_root.old_value()) { |
| 942 roots_++; | 941 roots_++; |
| 943 // If the object was not just serialized, | 942 // If the object was not just serialized, |
| 944 // write its encoded address instead. | 943 // write its encoded address instead. |
| 945 if (!serialized) PutEncodedAddress(a); | 944 if (!serialized) PutEncodedAddress(a); |
| 946 } | 945 } |
| 947 } | 946 } |
| 948 root_ = root; | |
| 949 } | 947 } |
| 950 | 948 |
| 951 | 949 |
| 952 class GlobalHandlesRetriever: public ObjectVisitor { | 950 class GlobalHandlesRetriever: public ObjectVisitor { |
| 953 public: | 951 public: |
| 954 explicit GlobalHandlesRetriever(List<Object**>* handles) | 952 explicit GlobalHandlesRetriever(List<Object**>* handles) |
| 955 : global_handles_(handles) {} | 953 : global_handles_(handles) {} |
| 956 | 954 |
| 957 virtual void VisitPointers(Object** start, Object** end) { | 955 virtual void VisitPointers(Object** start, Object** end) { |
| 958 for (; start != end; ++start) { | 956 for (; start != end; ++start) { |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1229 reference_decoder_ = new ExternalReferenceDecoder(); | 1227 reference_decoder_ = new ExternalReferenceDecoder(); |
| 1230 // By setting linear allocation only, we forbid the use of free list | 1228 // By setting linear allocation only, we forbid the use of free list |
| 1231 // allocation which is not predicted by SimulatedAddress. | 1229 // allocation which is not predicted by SimulatedAddress. |
| 1232 GetHeader(); | 1230 GetHeader(); |
| 1233 Heap::IterateRoots(this); | 1231 Heap::IterateRoots(this); |
| 1234 GetContextStack(); | 1232 GetContextStack(); |
| 1235 } | 1233 } |
| 1236 | 1234 |
| 1237 | 1235 |
| 1238 void Deserializer::VisitPointers(Object** start, Object** end) { | 1236 void Deserializer::VisitPointers(Object** start, Object** end) { |
| 1239 bool root = root_; | 1237 TempAssign<bool> temp_root(&root_, false); |
| 1240 root_ = false; | |
| 1241 for (Object** p = start; p < end; ++p) { | 1238 for (Object** p = start; p < end; ++p) { |
| 1242 if (root) { | 1239 if (temp_root.old_value()) { |
| 1243 roots_++; | 1240 roots_++; |
| 1244 // Read the next object or pointer from the stream | 1241 // Read the next object or pointer from the stream |
| 1245 // pointer in the stream. | 1242 // pointer in the stream. |
| 1246 int c = reader_.GetC(); | 1243 int c = reader_.GetC(); |
| 1247 if (c == '[') { | 1244 if (c == '[') { |
| 1248 *p = GetObject(); // embedded object | 1245 *p = GetObject(); // embedded object |
| 1249 } else { | 1246 } else { |
| 1250 ASSERT(c == 'P'); // pointer to previously serialized object | 1247 ASSERT(c == 'P'); // pointer to previously serialized object |
| 1251 *p = Resolve(reinterpret_cast<Address>(reader_.GetInt())); | 1248 *p = Resolve(reinterpret_cast<Address>(reader_.GetInt())); |
| 1252 } | 1249 } |
| 1253 } else { | 1250 } else { |
| 1254 // A pointer internal to a HeapObject that we've already | 1251 // A pointer internal to a HeapObject that we've already |
| 1255 // read: resolve it to a true address (or Smi) | 1252 // read: resolve it to a true address (or Smi) |
| 1256 *p = Resolve(reinterpret_cast<Address>(*p)); | 1253 *p = Resolve(reinterpret_cast<Address>(*p)); |
| 1257 } | 1254 } |
| 1258 } | 1255 } |
| 1259 root_ = root; | |
| 1260 } | 1256 } |
| 1261 | 1257 |
| 1262 | 1258 |
| 1263 void Deserializer::VisitExternalReferences(Address* start, Address* end) { | 1259 void Deserializer::VisitExternalReferences(Address* start, Address* end) { |
| 1264 for (Address* p = start; p < end; ++p) { | 1260 for (Address* p = start; p < end; ++p) { |
| 1265 uint32_t code = reinterpret_cast<uint32_t>(*p); | 1261 uint32_t code = reinterpret_cast<uint32_t>(*p); |
| 1266 *p = reference_decoder_->Decode(code); | 1262 *p = reference_decoder_->Decode(code); |
| 1267 } | 1263 } |
| 1268 } | 1264 } |
| 1269 | 1265 |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1515 ASSERT(index < large_objects_.length()); | 1511 ASSERT(index < large_objects_.length()); |
| 1516 } | 1512 } |
| 1517 return large_objects_[index]; // s.page_offset() is ignored. | 1513 return large_objects_[index]; // s.page_offset() is ignored. |
| 1518 } | 1514 } |
| 1519 UNREACHABLE(); | 1515 UNREACHABLE(); |
| 1520 return NULL; | 1516 return NULL; |
| 1521 } | 1517 } |
| 1522 | 1518 |
| 1523 | 1519 |
| 1524 } } // namespace v8::internal | 1520 } } // namespace v8::internal |
| OLD | NEW |