| 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 #ifndef V8_SERIALIZE_H_ | 5 #ifndef V8_SERIALIZE_H_ |
| 6 #define V8_SERIALIZE_H_ | 6 #define V8_SERIALIZE_H_ |
| 7 | 7 |
| 8 #include "src/compiler.h" | 8 #include "src/compiler.h" |
| 9 #include "src/hashmap.h" | 9 #include "src/hashmap.h" |
| 10 #include "src/heap-profiler.h" | 10 #include "src/heap-profiler.h" |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 void DeserializePartial(Isolate* isolate, Object** root); | 245 void DeserializePartial(Isolate* isolate, Object** root); |
| 246 | 246 |
| 247 void set_reservation(int space_number, int reservation) { | 247 void set_reservation(int space_number, int reservation) { |
| 248 ASSERT(space_number >= 0); | 248 ASSERT(space_number >= 0); |
| 249 ASSERT(space_number <= LAST_SPACE); | 249 ASSERT(space_number <= LAST_SPACE); |
| 250 reservations_[space_number] = reservation; | 250 reservations_[space_number] = reservation; |
| 251 } | 251 } |
| 252 | 252 |
| 253 void FlushICacheForNewCodeObjects(); | 253 void FlushICacheForNewCodeObjects(); |
| 254 | 254 |
| 255 // Call this to indicate that the serialized data represents user code. |
| 256 // There are some more wiring up required in this case. |
| 257 void ExpectSerializedCode() { deserialize_code_ = true; } |
| 258 |
| 255 private: | 259 private: |
| 256 virtual void VisitPointers(Object** start, Object** end); | 260 virtual void VisitPointers(Object** start, Object** end); |
| 257 | 261 |
| 258 virtual void VisitRuntimeEntry(RelocInfo* rinfo) { | 262 virtual void VisitRuntimeEntry(RelocInfo* rinfo) { |
| 259 UNREACHABLE(); | 263 UNREACHABLE(); |
| 260 } | 264 } |
| 261 | 265 |
| 262 // Allocation sites are present in the snapshot, and must be linked into | 266 // Allocation sites are present in the snapshot, and must be linked into |
| 263 // a list at deserialization time. | 267 // a list at deserialization time. |
| 264 void RelinkAllocationSite(AllocationSite* site); | 268 void RelinkAllocationSite(AllocationSite* site); |
| 265 | 269 |
| 266 // Fills in some heap data in an area from start to end (non-inclusive). The | 270 // Fills in some heap data in an area from start to end (non-inclusive). The |
| 267 // space id is used for the write barrier. The object_address is the address | 271 // space id is used for the write barrier. The object_address is the address |
| 268 // of the object we are writing into, or NULL if we are not writing into an | 272 // of the object we are writing into, or NULL if we are not writing into an |
| 269 // object, i.e. if we are writing a series of tagged values that are not on | 273 // object, i.e. if we are writing a series of tagged values that are not on |
| 270 // the heap. | 274 // the heap. |
| 271 void ReadChunk( | 275 void ReadChunk( |
| 272 Object** start, Object** end, int space, Address object_address); | 276 Object** start, Object** end, int space, Address object_address); |
| 273 void ReadObject(int space_number, Object** write_back); | 277 void ReadObject(int space_number, Object** write_back); |
| 274 | 278 |
| 279 HeapObject* ProcessObjectFromSerializedCode(HeapObject* obj); |
| 280 |
| 275 // This routine both allocates a new object, and also keeps | 281 // This routine both allocates a new object, and also keeps |
| 276 // track of where objects have been allocated so that we can | 282 // track of where objects have been allocated so that we can |
| 277 // fix back references when deserializing. | 283 // fix back references when deserializing. |
| 278 Address Allocate(int space_index, int size) { | 284 Address Allocate(int space_index, int size) { |
| 279 Address address = high_water_[space_index]; | 285 Address address = high_water_[space_index]; |
| 280 high_water_[space_index] = address + size; | 286 high_water_[space_index] = address + size; |
| 281 return address; | 287 return address; |
| 282 } | 288 } |
| 283 | 289 |
| 284 // This returns the address of an object that has been described in the | 290 // This returns the address of an object that has been described in the |
| 285 // snapshot as being offset bytes back in a particular space. | 291 // snapshot as being offset bytes back in a particular space. |
| 286 HeapObject* GetAddressFromEnd(int space) { | 292 HeapObject* GetAddressFromEnd(int space) { |
| 287 int offset = source_->GetInt(); | 293 int offset = source_->GetInt(); |
| 288 offset <<= kObjectAlignmentBits; | 294 offset <<= kObjectAlignmentBits; |
| 289 return HeapObject::FromAddress(high_water_[space] - offset); | 295 return HeapObject::FromAddress(high_water_[space] - offset); |
| 290 } | 296 } |
| 291 | 297 |
| 292 // Cached current isolate. | 298 // Cached current isolate. |
| 293 Isolate* isolate_; | 299 Isolate* isolate_; |
| 300 bool deserialize_code_; |
| 294 | 301 |
| 295 SnapshotByteSource* source_; | 302 SnapshotByteSource* source_; |
| 296 // This is the address of the next object that will be allocated in each | 303 // This is the address of the next object that will be allocated in each |
| 297 // space. It is used to calculate the addresses of back-references. | 304 // space. It is used to calculate the addresses of back-references. |
| 298 Address high_water_[LAST_SPACE + 1]; | 305 Address high_water_[LAST_SPACE + 1]; |
| 299 | 306 |
| 300 int reservations_[LAST_SPACE + 1]; | 307 int reservations_[LAST_SPACE + 1]; |
| 301 static const intptr_t kUninitializedReservation = -1; | 308 static const intptr_t kUninitializedReservation = -1; |
| 302 | 309 |
| 303 ExternalReferenceDecoder* external_reference_decoder_; | 310 ExternalReferenceDecoder* external_reference_decoder_; |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 static const int kVersionHashOffset = 0; | 635 static const int kVersionHashOffset = 0; |
| 629 static const int kReservationsOffset = 1; | 636 static const int kReservationsOffset = 1; |
| 630 static const int kHeaderEntries = 8; | 637 static const int kHeaderEntries = 8; |
| 631 | 638 |
| 632 ScriptData* script_data_; | 639 ScriptData* script_data_; |
| 633 bool owns_script_data_; | 640 bool owns_script_data_; |
| 634 }; | 641 }; |
| 635 } } // namespace v8::internal | 642 } } // namespace v8::internal |
| 636 | 643 |
| 637 #endif // V8_SERIALIZE_H_ | 644 #endif // V8_SERIALIZE_H_ |
| OLD | NEW |