V8 Project
v8::internal::PartialSerializer Class Reference

#include <serialize.h>

+ Inheritance diagram for v8::internal::PartialSerializer:
+ Collaboration diagram for v8::internal::PartialSerializer:

Public Member Functions

 PartialSerializer (Isolate *isolate, Serializer *startup_snapshot_serializer, SnapshotByteSink *sink)
 
void Serialize (Object **o)
 
virtual void SerializeObject (Object *o, HowToCode how_to_code, WhereToPoint where_to_point, int skip)
 
- Public Member Functions inherited from v8::internal::Serializer
 Serializer (Isolate *isolate, SnapshotByteSink *sink)
 
 ~Serializer ()
 
void VisitPointers (Object **start, Object **end)
 
int CurrentAllocationAddress (int space) const
 
Isolateisolate () const
 
SerializationAddressMapperaddress_mapper ()
 
void PutRoot (int index, HeapObject *object, HowToCode how, WhereToPoint where, int skip)
 

Private Member Functions

int PartialSnapshotCacheIndex (HeapObject *o)
 
bool ShouldBeInThePartialSnapshotCache (HeapObject *o)
 
 DISALLOW_COPY_AND_ASSIGN (PartialSerializer)
 

Private Attributes

Serializerstartup_serializer_
 

Additional Inherited Members

- Static Public Member Functions inherited from v8::internal::SerializerDeserializer
static void Iterate (Isolate *isolate, ObjectVisitor *visitor)
 
static int nop ()
 
- Static Public Attributes inherited from v8::internal::SerializerDeserializer
static const int kNumberOfPreallocatedSpaces = LO_SPACE
 
static const int kNumberOfSpaces = INVALID_SPACE
 
- Protected Types inherited from v8::internal::SerializerDeserializer
enum  Where {
  kNewObject = 0 , kRootArray = 0x9 , kPartialSnapshotCache = 0xa , kExternalReference = 0xb ,
  kSkip = 0xc , kBuiltin = 0xd , kAttachedReference = 0xe , kNop = 0xf ,
  kBackref = 0x10 , kBackrefWithSkip = 0x18 , kPointedToMask = 0x3f
}
 
enum  HowToCode { kPlain = 0 , kFromCode = 0x40 , kHowToCodeMask = 0x40 }
 
enum  WithSkip { kNoSkipDistance = 0 , kHasSkipDistance = 0x40 , kWithSkipMask = 0x40 }
 
enum  WhereToPoint { kStartOfObject = 0 , kInnerPointer = 0x80 , kWhereToPointMask = 0x80 }
 
- Protected Member Functions inherited from v8::internal::Serializer
int RootIndex (HeapObject *heap_object, HowToCode from)
 
intptr_t root_index_wave_front ()
 
void set_root_index_wave_front (intptr_t value)
 
void SerializeReferenceToPreviousObject (HeapObject *heap_object, HowToCode how_to_code, WhereToPoint where_to_point, int skip)
 
void InitializeAllocators ()
 
int AllocateLargeObject (int size)
 
int Allocate (int space, int size)
 
int EncodeExternalReference (Address addr)
 
int SpaceAreaSize (int space)
 
bool ShouldBeSkipped (Object **current)
 
void Pad ()
 
void InitializeCodeAddressMap ()
 
- Protected Member Functions inherited from v8::internal::SerializerDeserializer
 STATIC_ASSERT (kNumberOfSpaces<=kSpaceMask+1)
 
- Static Protected Member Functions inherited from v8::internal::Serializer
static int SpaceOfObject (HeapObject *object)
 
- Static Protected Member Functions inherited from v8::internal::SerializerDeserializer
static int CodeForRepeats (int repeats)
 
static int RepeatsForCode (int byte_code)
 
static int RootArrayConstantFromByteCode (int byte_code)
 
- Protected Attributes inherited from v8::internal::Serializer
Isolateisolate_
 
int fullness_ [kNumberOfSpaces]
 
SnapshotByteSinksink_
 
ExternalReferenceEncoderexternal_reference_encoder_
 
SerializationAddressMapper address_mapper_
 
intptr_t root_index_wave_front_
 
- Static Protected Attributes inherited from v8::internal::Serializer
static const int kInvalidRootIndex = -1
 
- Static Protected Attributes inherited from v8::internal::SerializerDeserializer
static const int kRawData = 0x20
 
static const int kSynchronize = 0x70
 
static const int kNativesStringResource = 0x71
 
static const int kRepeat = 0x72
 
static const int kConstantRepeat = 0x73
 
static const int kMaxRepeats = 0x7f - 0x72
 
static const int kRootArrayConstants = 0xa0
 
static const int kRootArrayNumberOfConstantEncodings = 0x20
 
static const int kAnyOldSpace = -1
 
static const int kSpaceMask = 7
 

Detailed Description

Definition at line 507 of file serialize.h.

Constructor & Destructor Documentation

◆ PartialSerializer()

v8::internal::PartialSerializer::PartialSerializer ( Isolate isolate,
Serializer startup_snapshot_serializer,
SnapshotByteSink sink 
)
inline

Definition at line 509 of file serialize.h.

512  : Serializer(isolate, sink),
513  startup_serializer_(startup_snapshot_serializer) {
516  }
@ kStrongRootListLength
Definition: heap.h:1073
Serializer(Isolate *isolate, SnapshotByteSink *sink)
Definition: serialize.cc:1214
Isolate * isolate() const
Definition: serialize.h:390
void set_root_index_wave_front(intptr_t value)
Definition: serialize.h:404

References v8::internal::Serializer::InitializeCodeAddressMap(), v8::internal::Heap::kStrongRootListLength, and v8::internal::Serializer::set_root_index_wave_front().

+ Here is the call graph for this function:

Member Function Documentation

◆ DISALLOW_COPY_AND_ASSIGN()

v8::internal::PartialSerializer::DISALLOW_COPY_AND_ASSIGN ( PartialSerializer  )
private

◆ PartialSnapshotCacheIndex()

int v8::internal::PartialSerializer::PartialSnapshotCacheIndex ( HeapObject o)
private

Definition at line 1313 of file serialize.cc.

1313  {
1314  Isolate* isolate = this->isolate();
1315 
1316  for (int i = 0;
1317  i < isolate->serialize_partial_snapshot_cache_length();
1318  i++) {
1319  Object* entry = isolate->serialize_partial_snapshot_cache()[i];
1320  if (entry == heap_object) return i;
1321  }
1322 
1323  // We didn't find the object in the cache. So we add it to the cache and
1324  // then visit the pointer so that it becomes part of the startup snapshot
1325  // and we can refer to it from the partial snapshot.
1326  int length = isolate->serialize_partial_snapshot_cache_length();
1327  isolate->PushToPartialSnapshotCache(heap_object);
1328  startup_serializer_->VisitPointer(reinterpret_cast<Object**>(&heap_object));
1329  // We don't recurse from the startup snapshot generator into the partial
1330  // snapshot generator.
1331  DCHECK(length == isolate->serialize_partial_snapshot_cache_length() - 1);
1332  return length;
1333 }
void PushToPartialSnapshotCache(Object *obj)
Definition: isolate.cc:1656
#define DCHECK(condition)
Definition: logging.h:205
kSerializedDataOffset Object
Definition: objects-inl.h:5322

References DCHECK, v8::internal::Serializer::isolate(), v8::internal::Isolate::PushToPartialSnapshotCache(), and startup_serializer_.

Referenced by SerializeObject().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Serialize()

void v8::internal::PartialSerializer::Serialize ( Object **  o)

Definition at line 1248 of file serialize.cc.

1248  {
1249  this->VisitPointer(object);
1250  Pad();
1251 }

References v8::internal::Serializer::Pad().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SerializeObject()

void v8::internal::PartialSerializer::SerializeObject ( Object o,
HowToCode  how_to_code,
WhereToPoint  where_to_point,
int  skip 
)
virtual

Implements v8::internal::Serializer.

Definition at line 1456 of file serialize.cc.

1460  {
1461  CHECK(o->IsHeapObject());
1462  HeapObject* heap_object = HeapObject::cast(o);
1463 
1464  if (heap_object->IsMap()) {
1465  // The code-caches link to context-specific code objects, which
1466  // the startup and context serializes cannot currently handle.
1467  DCHECK(Map::cast(heap_object)->code_cache() ==
1468  heap_object->GetHeap()->empty_fixed_array());
1469  }
1470 
1471  int root_index;
1472  if ((root_index = RootIndex(heap_object, how_to_code)) != kInvalidRootIndex) {
1473  PutRoot(root_index, heap_object, how_to_code, where_to_point, skip);
1474  return;
1475  }
1476 
1477  if (ShouldBeInThePartialSnapshotCache(heap_object)) {
1478  if (skip != 0) {
1479  sink_->Put(kSkip, "SkipFromSerializeObject");
1480  sink_->PutInt(skip, "SkipDistanceFromSerializeObject");
1481  }
1482 
1483  int cache_index = PartialSnapshotCacheIndex(heap_object);
1484  sink_->Put(kPartialSnapshotCache + how_to_code + where_to_point,
1485  "PartialSnapshotCache");
1486  sink_->PutInt(cache_index, "partial_snapshot_cache_index");
1487  return;
1488  }
1489 
1490  // Pointers from the partial snapshot to the objects in the startup snapshot
1491  // should go through the root array or through the partial snapshot cache.
1492  // If this is not the case you may have to add something to the root array.
1494  // All the internalized strings that the partial snapshot needs should be
1495  // either in the root table or in the partial snapshot cache.
1496  DCHECK(!heap_object->IsInternalizedString());
1497 
1498  if (address_mapper_.IsMapped(heap_object)) {
1499  SerializeReferenceToPreviousObject(heap_object, how_to_code, where_to_point,
1500  skip);
1501  } else {
1502  if (skip != 0) {
1503  sink_->Put(kSkip, "SkipFromSerializeObject");
1504  sink_->PutInt(skip, "SkipDistanceFromSerializeObject");
1505  }
1506  // Object has not yet been serialized. Serialize it here.
1507  ObjectSerializer serializer(this,
1508  heap_object,
1509  sink_,
1510  how_to_code,
1511  where_to_point);
1512  serializer.Serialize();
1513  }
1514 }
int PartialSnapshotCacheIndex(HeapObject *o)
Definition: serialize.cc:1313
bool ShouldBeInThePartialSnapshotCache(HeapObject *o)
Definition: serialize.h:527
friend class ObjectSerializer
Definition: serialize.h:492
void SerializeReferenceToPreviousObject(HeapObject *heap_object, HowToCode how_to_code, WhereToPoint where_to_point, int skip)
Definition: serialize.cc:1353
int RootIndex(HeapObject *heap_object, HowToCode from)
Definition: serialize.cc:1336
SerializationAddressMapper * address_mapper()
Definition: serialize.h:392
SnapshotByteSink * sink_
Definition: serialize.h:485
static const int kInvalidRootIndex
Definition: serialize.h:400
SerializationAddressMapper address_mapper_
Definition: serialize.h:488
void PutRoot(int index, HeapObject *object, HowToCode how, WhereToPoint where, int skip)
Definition: serialize.cc:1428
virtual void Put(byte b, const char *description)=0
void PutInt(uintptr_t integer, const char *description)
#define CHECK(condition)
Definition: logging.h:36

References v8::internal::Serializer::address_mapper(), v8::internal::Serializer::address_mapper_, CHECK, DCHECK, v8::internal::HeapObject::GetHeap(), v8::internal::SerializationAddressMapper::IsMapped(), v8::internal::Serializer::kInvalidRootIndex, v8::internal::SerializerDeserializer::kPartialSnapshotCache, v8::internal::SerializerDeserializer::kSkip, PartialSnapshotCacheIndex(), v8::internal::SnapshotByteSink::Put(), v8::internal::SnapshotByteSink::PutInt(), v8::internal::Serializer::PutRoot(), v8::internal::Serializer::RootIndex(), v8::internal::Serializer::ObjectSerializer::Serialize(), v8::internal::Serializer::SerializeReferenceToPreviousObject(), ShouldBeInThePartialSnapshotCache(), v8::internal::Serializer::sink_, and startup_serializer_.

+ Here is the call graph for this function:

◆ ShouldBeInThePartialSnapshotCache()

bool v8::internal::PartialSerializer::ShouldBeInThePartialSnapshotCache ( HeapObject o)
inlineprivate

Definition at line 527 of file serialize.h.

527  {
528  // Scripts should be referred only through shared function infos. We can't
529  // allow them to be part of the partial snapshot because they contain a
530  // unique ID, and deserializing several partial snapshots containing script
531  // would cause dupes.
532  DCHECK(!o->IsScript());
533  return o->IsName() || o->IsSharedFunctionInfo() ||
534  o->IsHeapNumber() || o->IsCode() ||
535  o->IsScopeInfo() ||
536  o->map() ==
537  startup_serializer_->isolate()->heap()->fixed_cow_array_map();
538  }

References DCHECK, v8::internal::Isolate::heap(), v8::internal::Serializer::isolate(), v8::internal::HeapObject::map(), and startup_serializer_.

Referenced by SerializeObject().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ startup_serializer_

Serializer* v8::internal::PartialSerializer::startup_serializer_
private

The documentation for this class was generated from the following files: