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

Unified Diff: src/serialize.cc

Issue 604373008: Serialize all external strings except for native source code strings. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 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/heap/heap.cc ('k') | test/cctest/test-serialize.cc » ('j') | 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 1ced5ce0c523b9bf78b6ef89bf24944a35b451e4..0cc629df780dcb7916f1ba6776fc4acce3906bf7 100644
--- a/src/serialize.cc
+++ b/src/serialize.cc
@@ -1552,8 +1552,9 @@ void Serializer::ObjectSerializer::SerializePrologue(int space, int size,
void Serializer::ObjectSerializer::SerializeExternalString() {
// Instead of serializing this as an external string, we serialize
// an imaginary sequential string with the same content.
- DCHECK(object_->IsExternalString() && object_->IsInternalizedString());
Isolate* isolate = serializer_->isolate();
+ DCHECK(object_->IsExternalString());
+ DCHECK(object_->map() != isolate->heap()->native_source_string_map());
ExternalString* string = ExternalString::cast(object_);
int length = string->length();
Map* map;
@@ -1600,24 +1601,30 @@ void Serializer::ObjectSerializer::SerializeExternalString() {
void Serializer::ObjectSerializer::Serialize() {
- if (object_->IsExternalString() && object_->IsInternalizedString()) {
- // Native source code strings are not internalized and are handled in
- // VisitExternalOneByteString. We deal with embedded external strings
- // by serializing them as sequential strings on the heap.
- // This can only happen with CodeSerializer.
- SerializeExternalString();
- } else {
- int size = object_->Size();
- Map* map = object_->map();
- SerializePrologue(Serializer::SpaceOfObject(object_), size, map);
+ if (object_->IsExternalString()) {
+ Heap* heap = serializer_->isolate()->heap();
+ if (object_->map() != heap->native_source_string_map()) {
+ // Usually we cannot recreate resources for external strings. To work
+ // around this, external strings are serialized to look like ordinary
+ // sequential strings.
+ // The exception are native source code strings, since we can recreate
+ // their resources. In that case we fall through and leave it to
+ // VisitExternalOneByteString further down.
+ SerializeExternalString();
+ return;
+ }
+ }
- // Serialize the rest of the object.
- CHECK_EQ(0, bytes_processed_so_far_);
- bytes_processed_so_far_ = kPointerSize;
+ int size = object_->Size();
+ Map* map = object_->map();
+ SerializePrologue(Serializer::SpaceOfObject(object_), size, map);
- object_->IterateBody(map->instance_type(), size, this);
- OutputRawData(object_->address() + size);
- }
+ // Serialize the rest of the object.
+ CHECK_EQ(0, bytes_processed_so_far_);
+ bytes_processed_so_far_ = kPointerSize;
+
+ object_->IterateBody(map->instance_type(), size, this);
+ OutputRawData(object_->address() + size);
}
« no previous file with comments | « src/heap/heap.cc ('k') | test/cctest/test-serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698