Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1268)

Unified Diff: src/serialize.cc

Issue 946073003: Remove reinvented wheel for partial snapshot cache. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/serialize.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/serialize.cc
diff --git a/src/serialize.cc b/src/serialize.cc
index 1d18fac04c086342035649eb3349f55c4e724ca6..f30c8e046a699179ae0c3d8806ae7b1e1becc5b9 100644
--- a/src/serialize.cc
+++ b/src/serialize.cc
@@ -998,7 +998,7 @@ void Deserializer::ReadData(Object** current, Object** limit, int source_space,
emit_write_barrier = isolate->heap()->InNewSpace(new_object); \
} else if (where == kPartialSnapshotCache) { \
int cache_index = source_.GetInt(); \
- new_object = isolate->serialize_partial_snapshot_cache()[cache_index]; \
+ new_object = isolate->partial_snapshot_cache()->at(cache_index); \
emit_write_barrier = isolate->heap()->InNewSpace(new_object); \
} else if (where == kExternalReference) { \
int skip = source_.GetInt(); \
@@ -1508,43 +1508,34 @@ void Serializer::EncodeReservations(
void SerializerDeserializer::Iterate(Isolate* isolate,
ObjectVisitor* visitor) {
if (isolate->serializer_enabled()) return;
- for (int i = 0; ; i++) {
- if (isolate->serialize_partial_snapshot_cache_length() <= i) {
- // Extend the array ready to get a value from the visitor when
- // deserializing.
- isolate->PushToPartialSnapshotCache(Smi::FromInt(0));
- }
- Object** cache = isolate->serialize_partial_snapshot_cache();
- visitor->VisitPointers(&cache[i], &cache[i + 1]);
+ List<Object*>* cache = isolate->partial_snapshot_cache();
+ for (int i = 0;; ++i) {
+ // Extend the array ready to get a value when deserializing.
+ if (cache->length() <= i) cache->Add(Smi::FromInt(0));
+ visitor->VisitPointer(&cache->at(i));
// Sentinel is the undefined object, which is a root so it will not normally
// be found in the cache.
- if (cache[i] == isolate->heap()->undefined_value()) {
- break;
- }
+ if (cache->at(i)->IsUndefined()) break;
}
}
int PartialSerializer::PartialSnapshotCacheIndex(HeapObject* heap_object) {
Isolate* isolate = this->isolate();
-
- for (int i = 0;
- i < isolate->serialize_partial_snapshot_cache_length();
- i++) {
- Object* entry = isolate->serialize_partial_snapshot_cache()[i];
+ List<Object*>* cache = isolate->partial_snapshot_cache();
+ for (int i = 0; i < cache->length(); ++i) {
+ Object* entry = cache->at(i);
if (entry == heap_object) return i;
}
// We didn't find the object in the cache. So we add it to the cache and
// then visit the pointer so that it becomes part of the startup snapshot
// and we can refer to it from the partial snapshot.
- int length = isolate->serialize_partial_snapshot_cache_length();
- isolate->PushToPartialSnapshotCache(heap_object);
+ cache->Add(heap_object);
startup_serializer_->VisitPointer(reinterpret_cast<Object**>(&heap_object));
// We don't recurse from the startup snapshot generator into the partial
// snapshot generator.
- DCHECK(length == isolate->serialize_partial_snapshot_cache_length() - 1);
- return length;
+ return cache->length() - 1;
}
« no previous file with comments | « src/serialize.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698