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_++];
174 #if defined(V8_HOST_CAN_READ_UNALIGNED) && __BYTE_ORDER == __LITTLE_ENDIAN
176 ASSERT(position_ +
sizeof(answer) <= length_ + 0u);
177 answer = *
reinterpret_cast<const int32_t*
>(data_ + position_);
179 int32_t answer = data_[position_];
180 answer |= data_[position_ + 1] << 8;
181 answer |= data_[position_ + 2] << 16;
182 answer |= data_[position_ + 3] << 24;
189 inline void CopyRaw(
byte* to,
int number_of_bytes);
209 static void Iterate(ObjectVisitor* visitor);
276 return 0x72 + repeats;
280 return byte_code - 0x72;
286 return byte_code & 0x1f;
301 int bytes = answer & 3;
303 uint32_t mask = 0xffffffffu;
304 mask >>= 32 - (bytes << 3);
312 memcpy(to, data_ + position_, number_of_bytes);
313 position_ += number_of_bytes;
332 ASSERT(space_number >= 0);
334 reservations_[space_number] = reservation;
338 virtual void VisitPointers(
Object** start,
Object** end);
340 virtual void VisitExternalReferences(
Address* start,
Address* end) {
344 virtual void VisitRuntimeEntry(RelocInfo* rinfo) {
355 void ReadObject(
int space_number,
Object** write_back);
360 Address Allocate(
int space_index,
int size) {
361 Address address = high_water_[space_index];
362 high_water_[space_index] = address + size;
368 HeapObject* GetAddressFromEnd(
int space) {
369 int offset = source_->
GetInt();
378 SnapshotByteSource* source_;
384 static const intptr_t kUninitializedReservation = -1;
386 ExternalReferenceDecoder* external_reference_decoder_;
395 virtual void Put(
int byte,
const char* description) = 0;
397 Put(byte, description);
399 void PutInt(uintptr_t integer,
const char* description);
409 : serialization_map_(new
HashMap(&SerializationMatchFun)),
413 delete serialization_map_;
414 delete no_allocation_;
418 return serialization_map_->
Lookup(Key(obj), Hash(obj),
false) !=
NULL;
423 return static_cast<int>(
reinterpret_cast<intptr_t
>(
424 serialization_map_->
Lookup(Key(obj), Hash(obj),
false)->value));
429 HashMap::Entry* entry =
430 serialization_map_->
Lookup(Key(obj), Hash(obj),
true);
431 entry->value =
Value(to);
435 static bool SerializationMatchFun(
void* key1,
void* key2) {
439 static uint32_t Hash(HeapObject* obj) {
440 return static_cast<int32_t>(
reinterpret_cast<intptr_t
>(obj->address()));
443 static void* Key(HeapObject* obj) {
444 return reinterpret_cast<void*
>(obj->address());
447 static void* Value(
int v) {
448 return reinterpret_cast<void*
>(v);
452 AssertNoAllocation* no_allocation_;
507 : serializer_(serializer),
510 reference_representation_(how_to_code + where_to_point),
511 bytes_processed_so_far_(0),
512 code_object_(o->IsCode()),
513 code_has_been_output_(
false) { }
533 enum ReturnSkip { kCanReturnSkipInsteadOfSkipping, kIgnoringReturn };
538 int OutputRawData(
Address up_to, ReturnSkip return_skip = kIgnoringReturn);
543 int reference_representation_;
544 int bytes_processed_so_far_;
546 bool code_has_been_output_;
596 startup_serializer_(startup_snapshot_serializer) {
615 return o->IsString() || o->IsSharedFunctionInfo() ||
616 o->IsHeapNumber() || o->IsCode() ||
618 o->
map() ==
HEAP->fixed_cow_array_map();
634 Isolate::Current()->set_serialize_partial_snapshot_cache_length(0);
653 virtual bool ShouldBeInThePartialSnapshotCache(
HeapObject* o) {
661 #endif // V8_SERIALIZE_H_
virtual void SerializeObject(Object *o, HowToCode how_to_code, WhereToPoint where_to_point, int skip)=0
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)
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()
void SerializeWeakReferences()
Serializer(SnapshotByteSink *sink)
int SpaceAreaSize(int space)
void VisitRuntimeEntry(RelocInfo *reloc)
#define ASSERT(condition)
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_
void PutRoot(int index, HeapObject *object, HowToCode how, WhereToPoint where, int skip)
void VisitCodeEntry(Address entry_address)
void set_reservation(int space_number, int reservation)
void VisitPointers(Object **start, Object **end)
void VisitExternalTwoByteString(v8::String::ExternalStringResource **resource)
int fullness_[LAST_SPACE+1]
static const int kConstantRepeat
ExternalReferenceDecoder()
static const int kMaxRepeats
int32_t GetUnalignedInt()
Deserializer(SnapshotByteSource *source)
void InitializeAllocators()
static const int kRawData
virtual int PartialSnapshotCacheIndex(HeapObject *o)
~ExternalReferenceTable()
static const int kRootArrayConstants
static int SpaceOfObject(HeapObject *object)
SerializationAddressMapper * address_mapper()
static void TooLateToEnableNow()
virtual void SerializeObject(Object *o, HowToCode how_to_code, WhereToPoint where_to_point, int skip)
~SerializationAddressMapper()
ExternalReferenceEncoder * external_reference_encoder_
Entry * Lookup(void *key, uint32_t hash, bool insert, AllocationPolicy allocator=AllocationPolicy())
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
int Allocate(int space, int size)
static const int kNumberOfSpaces
static const int kRootArrayNumberOfConstantEncodings
uint32_t Encode(Address key) const
static bool serialization_enabled_
static int RepeatsForCode(int byte_code)
SerializationAddressMapper()
activate correct semantics for inheriting readonliness false
void VisitExternalReferences(Address *start, Address *end)
void SerializeReferenceToPreviousObject(int space, int address, HowToCode how_to_code, WhereToPoint where_to_point, int skip)
~ExternalReferenceDecoder()
const int kDebugRegisterBits
StartupSerializer(SnapshotByteSink *sink)
const int kObjectAlignmentBits
TemplateHashMapImpl< FreeStoreAllocationPolicy > HashMap
void VisitExternalAsciiString(v8::String::ExternalAsciiStringResource **resource)
virtual void SerializeObject(Object *o, HowToCode how_to_code, WhereToPoint where_to_point, int skip)
PartialSerializer(Serializer *startup_snapshot_serializer, SnapshotByteSink *sink)
void set_root_index_wave_front(intptr_t value)
static HeapObject * FromAddress(Address address)
static const int kSynchronize
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 use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra 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 and VFP2 enable use of VFP2 instructions if available enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of MIPS FPU instructions if NULL
const int kReferenceIdBits
static const int kNativesStringResource
int RootIndex(HeapObject *heap_object, HowToCode from)
virtual bool ShouldBeInThePartialSnapshotCache(HeapObject *o)=0
virtual void Put(int byte, const char *description)=0
void VisitGlobalPropertyCell(RelocInfo *rinfo)
static ExternalReferenceTable * instance(Isolate *isolate)
virtual bool ShouldBeInThePartialSnapshotCache(HeapObject *o)
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