diff options
Diffstat (limited to 'deps/v8/src/serialize.h')
-rw-r--r-- | deps/v8/src/serialize.h | 70 |
1 files changed, 27 insertions, 43 deletions
diff --git a/deps/v8/src/serialize.h b/deps/v8/src/serialize.h index 49695ec964..c070923326 100644 --- a/deps/v8/src/serialize.h +++ b/deps/v8/src/serialize.h @@ -187,6 +187,24 @@ class SnapshotByteSource { }; +// It is very common to have a reference to objects at certain offsets in the +// heap. These offsets have been determined experimentally. We code +// references to such objects in a single byte that encodes the way the pointer +// is written (only plain pointers allowed), the space number and the offset. +// This only works for objects in the first page of a space. Don't use this for +// things in newspace since it bypasses the write barrier. + +static const int k64 = (sizeof(uintptr_t) - 4) / 4; + +#define COMMON_REFERENCE_PATTERNS(f) \ + f(kNumberOfSpaces, 2, (11 - k64)) \ + f((kNumberOfSpaces + 1), 2, 0) \ + f((kNumberOfSpaces + 2), 2, (142 - 16 * k64)) \ + f((kNumberOfSpaces + 3), 2, (74 - 15 * k64)) \ + f((kNumberOfSpaces + 4), 2, 5) \ + f((kNumberOfSpaces + 5), 1, 135) \ + f((kNumberOfSpaces + 6), 2, (228 - 39 * k64)) + #define COMMON_RAW_LENGTHS(f) \ f(1, 1) \ f(2, 2) \ @@ -224,7 +242,7 @@ class SerializerDeserializer: public ObjectVisitor { // 0xd-0xf Free. kBackref = 0x10, // Object is described relative to end. // 0x11-0x18 One per space. - // 0x19-0x1f Free. + // 0x19-0x1f Common backref offsets. kFromStart = 0x20, // Object is described relative to start. // 0x21-0x28 One per space. // 0x29-0x2f Free. @@ -261,29 +279,9 @@ class SerializerDeserializer: public ObjectVisitor { // is referred to from external strings in the snapshot. static const int kNativesStringResource = 0x71; static const int kNewPage = 0x72; - static const int kRepeat = 0x73; - static const int kConstantRepeat = 0x74; - // 0x74-0x7f Repeat last word (subtract 0x73 to get the count). - static const int kMaxRepeats = 0x7f - 0x73; - static int CodeForRepeats(int repeats) { - ASSERT(repeats >= 1 && repeats <= kMaxRepeats); - return 0x73 + repeats; - } - static int RepeatsForCode(int byte_code) { - ASSERT(byte_code >= kConstantRepeat && byte_code <= 0x7f); - return byte_code - 0x73; - } - static const int kRootArrayLowConstants = 0xb0; - // 0xb0-0xbf Things from the first 16 elements of the root array. - static const int kRootArrayHighConstants = 0xf0; - // 0xf0-0xff Things from the next 16 elements of the root array. - static const int kRootArrayNumberOfConstantEncodings = 0x20; - static const int kRootArrayNumberOfLowConstantEncodings = 0x10; - static int RootArrayConstantFromByteCode(int byte_code) { - int constant = (byte_code & 0xf) | ((byte_code & 0x40) >> 2); - ASSERT(constant >= 0 && constant < kRootArrayNumberOfConstantEncodings); - return constant; - } + // 0x73-0x7f Free. + // 0xb0-0xbf Free. + // 0xf0-0xff Free. static const int kLargeData = LAST_SPACE; @@ -356,13 +354,7 @@ class Deserializer: public SerializerDeserializer { UNREACHABLE(); } - // 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 - // object, ie if we are writing a series of tagged values that are not on the - // heap. - void ReadChunk( - Object** start, Object** end, int space, Address object_address); + void ReadChunk(Object** start, Object** end, int space, Address address); HeapObject* GetAddressFromStart(int space); inline HeapObject* GetAddressFromEnd(int space); Address Allocate(int space_number, Space* space, int size); @@ -483,22 +475,14 @@ class Serializer : public SerializerDeserializer { static void TooLateToEnableNow() { too_late_to_enable_now_ = true; } static bool enabled() { return serialization_enabled_; } SerializationAddressMapper* address_mapper() { return &address_mapper_; } - void PutRoot( - int index, HeapObject* object, HowToCode how, WhereToPoint where); #ifdef DEBUG virtual void Synchronize(const char* tag); #endif protected: static const int kInvalidRootIndex = -1; - - int RootIndex(HeapObject* heap_object); + virtual int RootIndex(HeapObject* heap_object) = 0; virtual bool ShouldBeInThePartialSnapshotCache(HeapObject* o) = 0; - intptr_t root_index_wave_front() { return root_index_wave_front_; } - void set_root_index_wave_front(intptr_t value) { - ASSERT(value >= root_index_wave_front_); - root_index_wave_front_ = value; - } class ObjectSerializer : public ObjectVisitor { public: @@ -574,7 +558,6 @@ class Serializer : public SerializerDeserializer { static bool too_late_to_enable_now_; int large_object_total_; SerializationAddressMapper address_mapper_; - intptr_t root_index_wave_front_; friend class ObjectSerializer; friend class Deserializer; @@ -589,7 +572,6 @@ class PartialSerializer : public Serializer { SnapshotByteSink* sink) : Serializer(sink), startup_serializer_(startup_snapshot_serializer) { - set_root_index_wave_front(Heap::kStrongRootListLength); } // Serialize the objects reachable from a single object pointer. @@ -599,6 +581,7 @@ class PartialSerializer : public Serializer { WhereToPoint where_to_point); protected: + virtual int RootIndex(HeapObject* o); virtual int PartialSnapshotCacheIndex(HeapObject* o); virtual bool ShouldBeInThePartialSnapshotCache(HeapObject* o) { // Scripts should be referred only through shared function infos. We can't @@ -623,7 +606,7 @@ class StartupSerializer : public Serializer { explicit StartupSerializer(SnapshotByteSink* sink) : Serializer(sink) { // Clear the cache of objects used by the partial snapshot. After the // strong roots have been serialized we can create a partial snapshot - // which will repopulate the cache with objects needed by that partial + // which will repopulate the cache with objects neede by that partial // snapshot. Isolate::Current()->set_serialize_partial_snapshot_cache_length(0); } @@ -642,6 +625,7 @@ class StartupSerializer : public Serializer { } private: + virtual int RootIndex(HeapObject* o) { return kInvalidRootIndex; } virtual bool ShouldBeInThePartialSnapshotCache(HeapObject* o) { return false; } |