summaryrefslogtreecommitdiff
path: root/deps/v8/src/snapshot/deserializer.h
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/snapshot/deserializer.h')
-rw-r--r--deps/v8/src/snapshot/deserializer.h94
1 files changed, 30 insertions, 64 deletions
diff --git a/deps/v8/src/snapshot/deserializer.h b/deps/v8/src/snapshot/deserializer.h
index 5aa2f8d656..5c9bda43ac 100644
--- a/deps/v8/src/snapshot/deserializer.h
+++ b/deps/v8/src/snapshot/deserializer.h
@@ -7,14 +7,17 @@
#include <vector>
-#include "src/heap/heap.h"
-#include "src/objects.h"
+#include "src/objects/js-array.h"
+#include "src/snapshot/default-deserializer-allocator.h"
#include "src/snapshot/serializer-common.h"
#include "src/snapshot/snapshot-source-sink.h"
namespace v8 {
namespace internal {
+class HeapObject;
+class Object;
+
// Used for platforms with embedded constant pools to trigger deserialization
// of objects found in code.
#if defined(V8_TARGET_ARCH_MIPS) || defined(V8_TARGET_ARCH_MIPS64) || \
@@ -25,55 +28,33 @@ namespace internal {
#define V8_CODE_EMBEDS_OBJECT_POINTER 0
#endif
-class BuiltinDeserializer;
-class Heap;
-class StartupDeserializer;
-
// A Deserializer reads a snapshot and reconstructs the Object graph it defines.
+template <class AllocatorT = DefaultDeserializerAllocator>
class Deserializer : public SerializerDeserializer {
public:
~Deserializer() override;
- // Add an object to back an attached reference. The order to add objects must
- // mirror the order they are added in the serializer.
- void AddAttachedObject(Handle<HeapObject> attached_object) {
- attached_objects_.push_back(attached_object);
- }
-
void SetRehashability(bool v) { can_rehash_ = v; }
protected:
// Create a deserializer from a snapshot byte source.
template <class Data>
Deserializer(Data* data, bool deserializing_user_code)
- : isolate_(NULL),
+ : isolate_(nullptr),
source_(data->Payload()),
magic_number_(data->GetMagicNumber()),
- next_map_index_(0),
- external_reference_table_(NULL),
- deserialized_large_objects_(0),
+ external_reference_table_(nullptr),
+ allocator_(this),
deserializing_user_code_(deserializing_user_code),
- next_alignment_(kWordAligned),
can_rehash_(false) {
- DecodeReservation(data->Reservations());
- // We start the indicies here at 1, so that we can distinguish between an
+ allocator()->DecodeReservation(data->Reservations());
+ // We start the indices here at 1, so that we can distinguish between an
// actual index and a nullptr in a deserialized object requiring fix-up.
off_heap_backing_stores_.push_back(nullptr);
}
- bool ReserveSpace();
-
- // Atomically reserves space for the two given deserializers. Guarantees
- // reservation for both without garbage collection in-between.
- static bool ReserveSpace(StartupDeserializer* startup_deserializer,
- BuiltinDeserializer* builtin_deserializer);
- bool ReservesOnlyCodeSpace() const;
-
void Initialize(Isolate* isolate);
void DeserializeDeferredObjects();
- void RegisterDeserializedObjectsForBlackAllocation();
-
- virtual Address Allocate(int space_index, int size);
// Deserializes into a single pointer and returns the resulting object.
Object* ReadDataSingle();
@@ -82,8 +63,11 @@ class Deserializer : public SerializerDeserializer {
// snapshot by chunk index and offset.
HeapObject* GetBackReferencedObject(int space);
- // Sort descriptors of deserialized maps using new string hashes.
- void SortMapDescriptors();
+ // Add an object to back an attached reference. The order to add objects must
+ // mirror the order they are added in the serializer.
+ void AddAttachedObject(Handle<HeapObject> attached_object) {
+ attached_objects_.push_back(attached_object);
+ }
Isolate* isolate() const { return isolate_; }
SnapshotByteSource* source() { return &source_; }
@@ -93,42 +77,36 @@ class Deserializer : public SerializerDeserializer {
const std::vector<AccessorInfo*>& accessor_infos() const {
return accessor_infos_;
}
+ const std::vector<CallHandlerInfo*>& call_handler_infos() const {
+ return call_handler_infos_;
+ }
const std::vector<Handle<String>>& new_internalized_strings() const {
return new_internalized_strings_;
}
const std::vector<Handle<Script>>& new_scripts() const {
return new_scripts_;
}
- const std::vector<TransitionArray*>& transition_arrays() const {
- return transition_arrays_;
- }
+
+ AllocatorT* allocator() { return &allocator_; }
bool deserializing_user_code() const { return deserializing_user_code_; }
bool can_rehash() const { return can_rehash_; }
bool IsLazyDeserializationEnabled() const;
+ void Rehash();
+
private:
void VisitRootPointers(Root root, Object** start, Object** end) override;
void Synchronize(VisitorSynchronization::SyncTag tag) override;
- void DecodeReservation(Vector<const SerializedData::Reservation> res);
-
void UnalignedCopy(Object** dest, Object** src) {
memcpy(dest, src, sizeof(*src));
}
- void SetAlignment(byte data) {
- DCHECK_EQ(kWordAligned, next_alignment_);
- int alignment = data - (kAlignmentPrefix - 1);
- DCHECK_LE(kWordAligned, alignment);
- DCHECK_LE(alignment, kDoubleUnaligned);
- next_alignment_ = static_cast<AllocationAlignment>(alignment);
- }
-
// Fills in some heap data in an area from start to end (non-inclusive). The
// space id is used for the write barrier. The object_address is the address
- // of the object we are writing into, or NULL if we are not writing into an
+ // of the object we are writing into, or nullptr if we are not writing into an
// object, i.e. if we are writing a series of tagged values that are not on
// the heap. Return false if the object content has been deferred.
bool ReadData(Object** start, Object** end, int space,
@@ -159,41 +137,29 @@ class Deserializer : public SerializerDeserializer {
SnapshotByteSource source_;
uint32_t magic_number_;
- // The address of the next object that will be allocated in each space.
- // Each space has a number of chunks reserved by the GC, with each chunk
- // fitting into a page. Deserialized objects are allocated into the
- // current chunk of the target space by bumping up high water mark.
- Heap::Reservation reservations_[kNumberOfSpaces];
- uint32_t current_chunk_[kNumberOfPreallocatedSpaces];
- Address high_water_[kNumberOfPreallocatedSpaces];
- int next_map_index_;
- std::vector<Address> allocated_maps_;
-
ExternalReferenceTable* external_reference_table_;
- std::vector<HeapObject*> deserialized_large_objects_;
std::vector<Code*> new_code_objects_;
std::vector<AccessorInfo*> accessor_infos_;
+ std::vector<CallHandlerInfo*> call_handler_infos_;
std::vector<Handle<String>> new_internalized_strings_;
std::vector<Handle<Script>> new_scripts_;
- std::vector<TransitionArray*> transition_arrays_;
std::vector<byte*> off_heap_backing_stores_;
+ AllocatorT allocator_;
const bool deserializing_user_code_;
- // TODO(jgruber): This workaround will no longer be necessary once builtin
- // reference patching has been removed (through advance allocation).
- bool deserializing_builtins_ = false;
-
- AllocationAlignment next_alignment_;
-
// TODO(6593): generalize rehashing, and remove this flag.
bool can_rehash_;
+ std::vector<HeapObject*> to_rehash_;
#ifdef DEBUG
uint32_t num_api_references_;
#endif // DEBUG
+ // For source(), isolate(), and allocator().
+ friend class DefaultDeserializerAllocator;
+
DISALLOW_COPY_AND_ASSIGN(Deserializer);
};