28 #ifndef V8_SERIALIZE_H_
29 #define V8_SERIALIZE_H_
72 int size()
const {
return refs_.length(); }
76 uint32_t
code(
int i) {
return refs_[i].code; }
78 const char*
name(
int i) {
return refs_[i].name; }
84 PopulateTable(isolate);
87 struct ExternalReferenceEntry {
93 void PopulateTable(Isolate* isolate);
104 List<ExternalReferenceEntry> refs_;
119 static uint32_t Hash(
Address key) {
120 return static_cast<uint32_t
>(
reinterpret_cast<uintptr_t
>(key) >> 2);
123 int IndexOf(
Address key)
const;
125 static bool Match(
void* key1,
void* key2) {
return key1 == key2; }
127 void Put(
Address key,
int index);
139 if (key == 0)
return NULL;
146 Address* Lookup(uint32_t key)
const {
150 return &encodings_[
type][id];
153 void Put(uint32_t key,
Address value) {
154 *Lookup(key) = value;
164 : data_(array), length_(length), position_(0) { }
166 bool HasMore() {
return position_ < length_; }
169 ASSERT(position_ < length_);
170 return data_[position_++];
173 inline void CopyRaw(
byte* to,
int number_of_bytes);
178 return position_ == length_;
190 #define COMMON_RAW_LENGTHS(f) \
212 static void Iterate(ObjectVisitor* visitor);
270 return 0x73 + repeats;
274 return byte_code - 0x73;
283 int constant = (byte_code & 0xf) | ((byte_code & 0x40) >> 2);
307 int snapshot_byte =
Get();
308 if ((snapshot_byte & 0x80) == 0) {
309 return snapshot_byte;
311 int accumulator = (snapshot_byte & 0x7f) << 7;
313 snapshot_byte =
Get();
314 if ((snapshot_byte & 0x80) == 0) {
315 return accumulator | snapshot_byte;
317 accumulator = (accumulator | (snapshot_byte & 0x7f)) << 7;
325 memcpy(to, data_ + position_, number_of_bytes);
326 position_ += number_of_bytes;
345 virtual void VisitPointers(
Object** start,
Object** end);
347 virtual void VisitExternalReferences(
Address* start,
Address* end) {
351 virtual void VisitRuntimeEntry(RelocInfo* rinfo) {
363 inline HeapObject* GetAddressFromEnd(
int space);
364 Address Allocate(
int space_number,
Space* space,
int size);
365 void ReadObject(
int space_number,
Space* space,
Object** write_back);
394 virtual void Put(
int byte,
const char* description) = 0;
396 Put(byte, description);
398 void PutInt(uintptr_t integer,
const char* description);
408 : serialization_map_(new
HashMap(&SerializationMatchFun)),
412 delete serialization_map_;
413 delete no_allocation_;
417 return serialization_map_->
Lookup(Key(obj), Hash(obj),
false) !=
NULL;
422 return static_cast<int>(
reinterpret_cast<intptr_t
>(
423 serialization_map_->
Lookup(Key(obj), Hash(obj),
false)->value));
428 HashMap::Entry* entry =
429 serialization_map_->
Lookup(Key(obj), Hash(obj),
true);
430 entry->value =
Value(to);
434 static bool SerializationMatchFun(
void* key1,
void* key2) {
438 static uint32_t Hash(HeapObject* obj) {
439 return static_cast<int32_t>(
reinterpret_cast<intptr_t
>(obj->address()));
442 static void* Key(HeapObject* obj) {
443 return reinterpret_cast<void*
>(obj->address());
446 static void* Value(
int v) {
447 return reinterpret_cast<void*
>(v);
451 AssertNoAllocation* no_allocation_;
503 : serializer_(serializer),
506 reference_representation_(how_to_code + where_to_point),
507 bytes_processed_so_far_(0) { }
527 void OutputRawData(
Address up_to);
532 int reference_representation_;
533 int bytes_processed_so_far_;
554 int Allocate(
int space,
int size,
bool* new_page_started);
590 startup_serializer_(startup_snapshot_serializer) {
608 return o->IsString() || o->IsSharedFunctionInfo() ||
609 o->IsHeapNumber() || o->IsCode() ||
611 o->
map() ==
HEAP->fixed_cow_array_map();
627 Isolate::Current()->set_serialize_partial_snapshot_cache_length(0);
644 virtual bool ShouldBeInThePartialSnapshotCache(
HeapObject* o) {
652 #endif // V8_SERIALIZE_H_
static const int kInvalidRootIndex
void VisitCodeTarget(RelocInfo *target)
int CurrentAllocationAddress(int space)
SerializationAddressMapper address_mapper_
void CopyRaw(byte *to, int number_of_bytes)
ObjectSerializer(Serializer *serializer, Object *o, SnapshotByteSink *sink, HowToCode how_to_code, WhereToPoint where_to_point)
const int kReferenceTypeShift
void AddMapping(HeapObject *obj, int to)
static const int kRootArrayNumberOfLowConstantEncodings
virtual void Serialize(Object **o)
static bool too_late_to_enable_now_
bool IsMapped(HeapObject *obj)
static int RootArrayConstantFromByteCode(int byte_code)
virtual ~SnapshotByteSink()
intptr_t root_index_wave_front()
virtual void SerializeStrongReferences()
virtual void SerializeObject(Object *o, HowToCode how_to_code, WhereToPoint where_to_point)
static const int kRootArrayHighConstants
void SerializeWeakReferences()
Serializer(SnapshotByteSink *sink)
int SpaceAreaSize(int space)
void VisitRuntimeEntry(RelocInfo *reloc)
#define ASSERT(condition)
static const int kNewPage
int EncodeExternalReference(Address addr)
static const int kSpaceMask
void VisitPointers(Object **start, Object **end)
static const int kAnyOldSpace
void DeserializePartial(Object **root)
static int CodeForRepeats(int repeats)
const int kReferenceIdMask
static void Iterate(ObjectVisitor *visitor)
void PutInt(uintptr_t integer, const char *description)
Address Decode(uint32_t key) const
intptr_t root_index_wave_front_
static const int kLargeData
void VisitCodeEntry(Address entry_address)
void VisitPointers(Object **start, Object **end)
static bool SpaceIsPaged(int space)
void VisitExternalTwoByteString(v8::String::ExternalStringResource **resource)
int fullness_[LAST_SPACE+1]
static const int kConstantRepeat
static bool SpaceIsLarge(int space)
ExternalReferenceDecoder()
static const int kMaxRepeats
Deserializer(SnapshotByteSource *source)
void InitializeAllocators()
static const int kRawData
virtual int PartialSnapshotCacheIndex(HeapObject *o)
~ExternalReferenceTable()
static int SpaceOfObject(HeapObject *object)
SerializationAddressMapper * address_mapper()
static void TooLateToEnableNow()
~SerializationAddressMapper()
ExternalReferenceEncoder * external_reference_encoder_
Entry * Lookup(void *key, uint32_t hash, bool insert, AllocationPolicy allocator=AllocationPolicy())
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
static const int kNumberOfSpaces
void SerializeReferenceToPreviousObject(int space, int address, HowToCode how_to_code, WhereToPoint where_to_point)
static const int kLargeFixedArray
static const int kRootArrayNumberOfConstantEncodings
static const int kLargeCode
uint32_t Encode(Address key) const
static bool serialization_enabled_
static int RepeatsForCode(int byte_code)
SerializationAddressMapper()
void VisitExternalReferences(Address *start, Address *end)
~ExternalReferenceDecoder()
const int kDebugRegisterBits
virtual void SerializeObject(Object *o, HowToCode how_to_code, WhereToPoint where_to_point)=0
static int SpaceOfAlreadySerializedObject(HeapObject *object)
StartupSerializer(SnapshotByteSink *sink)
int Allocate(int space, int size, bool *new_page_started)
TemplateHashMapImpl< FreeStoreAllocationPolicy > HashMap
void VisitExternalAsciiString(v8::String::ExternalAsciiStringResource **resource)
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination trace on stack replacement optimize closures functions with arguments object optimize functions containing for in loops profiler considers IC stability primitive functions trigger their own optimization re try self optimization if it failed insert an interrupt check at function exit execution budget before interrupt is triggered call count before self optimization self_optimization count_based_interrupts weighted_back_edges trace_opt emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 enable use of ARMv7 instructions if enable use of MIPS FPU instructions if NULL
PartialSerializer(Serializer *startup_snapshot_serializer, SnapshotByteSink *sink)
void set_root_index_wave_front(intptr_t value)
static const int kSynchronize
const int kReferenceIdBits
static const int kNativesStringResource
int RootIndex(HeapObject *heap_object, HowToCode from)
virtual bool ShouldBeInThePartialSnapshotCache(HeapObject *o)=0
static void SetSnapshotCacheSize(int size)
static const int kRootArrayLowConstants
virtual void Put(int byte, const char *description)=0
void VisitGlobalPropertyCell(RelocInfo *rinfo)
static ExternalReferenceTable * instance(Isolate *isolate)
virtual bool ShouldBeInThePartialSnapshotCache(HeapObject *o)
void PutRoot(int index, HeapObject *object, HowToCode how, WhereToPoint where)
virtual void SerializeObject(Object *o, HowToCode how_to_code, WhereToPoint where_to_point)
int MappedTo(HeapObject *obj)
SnapshotByteSource(const byte *array, int length)
virtual void PutSection(int byte, const char *description)
void VisitExternalReference(RelocInfo *rinfo)
void VisitEmbeddedPointer(RelocInfo *target)
ExternalReferenceEncoder()
const char * NameOfAddress(Address key) const