Update to V8 with partial snapshots. This is taken from the partial_snapshot branch of V8.
diff --git a/src/serialize.h b/src/serialize.h
index ce3b006..ab2ae9f 100644
--- a/src/serialize.h
+++ b/src/serialize.h
@@ -120,28 +120,9 @@
return data_[position_++];
}
- void CopyRaw(byte* to, int number_of_bytes) {
- memcpy(to, data_ + position_, number_of_bytes);
- position_ += number_of_bytes;
- }
+ inline void CopyRaw(byte* to, int number_of_bytes);
- int GetInt() {
- // A little unwind to catch the really small ints.
- int snapshot_byte = Get();
- if ((snapshot_byte & 0x80) == 0) {
- return snapshot_byte;
- }
- int accumulator = (snapshot_byte & 0x7f) << 7;
- while (true) {
- snapshot_byte = Get();
- if ((snapshot_byte & 0x80) == 0) {
- return accumulator | snapshot_byte;
- }
- accumulator = (accumulator | (snapshot_byte & 0x7f)) << 7;
- }
- UNREACHABLE();
- return accumulator;
- }
+ inline int GetInt();
bool AtEOF() {
return position_ == length_;
@@ -235,11 +216,35 @@
}
static int partial_snapshot_cache_length_;
- static const int kPartialSnapshotCacheCapacity = 1024;
+ static const int kPartialSnapshotCacheCapacity = 1300;
static Object* partial_snapshot_cache_[];
};
+int SnapshotByteSource::GetInt() {
+ // A little unwind to catch the really small ints.
+ int snapshot_byte = Get();
+ if ((snapshot_byte & 0x80) == 0) {
+ return snapshot_byte;
+ }
+ int accumulator = (snapshot_byte & 0x7f) << 7;
+ while (true) {
+ snapshot_byte = Get();
+ if ((snapshot_byte & 0x80) == 0) {
+ return accumulator | snapshot_byte;
+ }
+ accumulator = (accumulator | (snapshot_byte & 0x7f)) << 7;
+ }
+ UNREACHABLE();
+ return accumulator;
+}
+
+
+void SnapshotByteSource::CopyRaw(byte* to, int number_of_bytes) {
+ memcpy(to, data_ + position_, number_of_bytes);
+ position_ += number_of_bytes;
+}
+
// A Deserializer reads a snapshot and reconstructs the Object graph it defines.
class Deserializer: public SerializerDeserializer {
@@ -364,6 +369,7 @@
class Serializer : public SerializerDeserializer {
public:
explicit Serializer(SnapshotByteSink* sink);
+ ~Serializer();
void VisitPointers(Object** start, Object** end);
// You can call this after serialization to find out how much space was used
// in each space.
@@ -492,7 +498,12 @@
virtual int RootIndex(HeapObject* o);
virtual int PartialSnapshotCacheIndex(HeapObject* o);
virtual bool ShouldBeInThePartialSnapshotCache(HeapObject* o) {
- return o->IsString() || o->IsSharedFunctionInfo();
+ // Scripts should be referred only through shared function infos. We can't
+ // allow them to be part of the partial snapshot because they contain a
+ // unique ID, and deserializing several partial snapshots containing script
+ // would cause dupes.
+ ASSERT(!o->IsScript());
+ return o->IsString() || o->IsSharedFunctionInfo() || o->IsHeapNumber();
}
private:
@@ -530,6 +541,7 @@
}
};
+
} } // namespace v8::internal
#endif // V8_SERIALIZE_H_