Chromium Code Reviews| Index: src/serialize.h |
| diff --git a/src/serialize.h b/src/serialize.h |
| index 70482d8dcfbdef1f963a5257ed3f6b5fdf437506..66beede1fa0d5d04ea1df7bfe57c174a0316f1c9 100644 |
| --- a/src/serialize.h |
| +++ b/src/serialize.h |
| @@ -8,6 +8,7 @@ |
| #include "src/hashmap.h" |
| #include "src/heap-profiler.h" |
| #include "src/isolate.h" |
| +#include "src/parser.h" |
|
vogelheim
2014/07/07 15:20:01
parser.h draws in a rather large amount of headers
Yang
2014/07/08 09:01:05
Yup. Doing this later.
|
| #include "src/snapshot-source-sink.h" |
| namespace v8 { |
| @@ -469,6 +470,7 @@ class Serializer : public SerializerDeserializer { |
| SerializationAddressMapper address_mapper_; |
| intptr_t root_index_wave_front_; |
| void Pad(); |
| + void PadByte(); |
| friend class ObjectSerializer; |
| friend class Deserializer; |
| @@ -551,6 +553,69 @@ class StartupSerializer : public Serializer { |
| }; |
| +class CodeSerializer : public Serializer { |
| + public: |
| + CodeSerializer(Isolate* isolate, SnapshotByteSink* sink) |
| + : Serializer(isolate, sink) { |
| + set_root_index_wave_front(Heap::kStrongRootListLength); |
| + InitializeCodeAddressMap(); |
| + } |
| + |
| + static ScriptData* Serialize(Handle<SharedFunctionInfo> info); |
| + virtual void SerializeObject(Object* o, HowToCode how_to_code, |
| + WhereToPoint where_to_point, int skip); |
| + |
| + static Object* Deserialize(Isolate* isolate, ScriptData* data); |
| + |
| + // The data header consists of |
| + // [0] version hash |
|
vogelheim
2014/07/07 15:20:01
nitpick: It took me a while to understand these ar
Yang
2014/07/08 09:01:05
Done.
|
| + // [1] length in bytes |
| + // [2..8] reservation sizes for spaces from NEW_SPACE to PROPERTY_CELL_SPACE. |
| + static const int kHeaderSize = 9; |
| + static const int kVersionHashOffset = 0; |
| + static const int kPayloadLengthOffset = 1; |
| + static const int kReservationsOffset = 2; |
| +}; |
| + |
| + |
| +class DummySnapshotSink : public SnapshotByteSink { |
|
vogelheim
2014/07/07 15:20:01
If these (and the following) *Sinks are of general
Yang
2014/07/08 09:01:05
Done.
|
| + public: |
| + DummySnapshotSink() : length_(0) {} |
| + virtual ~DummySnapshotSink() {} |
| + virtual void Put(int byte, const char* description) { length_++; } |
| + virtual int Position() { return length_; } |
| + |
| + private: |
| + int length_; |
| +}; |
| + |
| + |
| +// Wrap a SnapshotByteSink into a DebugSnapshotSink to get debugging output. |
| +class DebugSnapshotSink : public SnapshotByteSink { |
| + public: |
| + explicit DebugSnapshotSink(SnapshotByteSink* chained) : sink_(chained) {} |
| + virtual ~DebugSnapshotSink() {} |
| + virtual void Put(int byte, const char* description) { |
| + printf("%24s: %x\n", description, byte); |
|
vogelheim
2014/07/07 15:20:01
nitpick: This header does not include stdio.h (and
Yang
2014/07/08 09:01:05
Using PrintF instead.
|
| + sink_->Put(byte, description); |
| + } |
| + virtual int Position() { return sink_->Position(); } |
| + |
| + private: |
| + SnapshotByteSink* sink_; |
| +}; |
| + |
| + |
| +class ListSnapshotSink : public i::SnapshotByteSink { |
| + public: |
| + explicit ListSnapshotSink(i::List<char>* data) : data_(data) {} |
| + virtual ~ListSnapshotSink() {} |
| + virtual void Put(int byte, const char* description) { data_->Add(byte); } |
| + virtual int Position() { return data_->length(); } |
| + |
| + private: |
| + i::List<char>* data_; |
| +}; |
| } } // namespace v8::internal |
| #endif // V8_SERIALIZE_H_ |