Skip to content

Instantly share code, notes, and snippets.

@piscisaureus
Created December 30, 2011 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save piscisaureus/21111d7639e97f3db4cb to your computer and use it in GitHub Desktop.
Save piscisaureus/21111d7639e97f3db4cb to your computer and use it in GitHub Desktop.
diff --git a/deps/v8/src/serialize.cc b/deps/v8/src/serialize.cc
index ecb480a..bdc653a 100644
--- a/deps/v8/src/serialize.cc
+++ b/deps/v8/src/serialize.cc
@@ -1328,10 +1328,27 @@ void Serializer::ObjectSerializer::Serialize() {
// Serialize the map (first word of the object).
serializer_->SerializeObject(object_->map(), kPlain, kStartOfObject);
-
- // Serialize the rest of the object.
CHECK_EQ(0, bytes_processed_so_far_);
bytes_processed_so_far_ = kPointerSize;
+
+ if (object_->IsString()) {
+ // Output the data between the object header and the hash field. This
+ // assumes that there's no object pointers between the header and the
+ // hash field.
+ OutputRawData(object_->address() + String::kHashFieldOffset);
+ CHECK_EQ(String::kHashFieldOffset, bytes_processed_so_far_);
+
+ // String hashes don't survive serialization. Instead of writing the
+ // computed hash value, write a tag that marks that hash as uncomputed.
+ const char* data = reinterpret_cast<const char*>(
+ &String::kHashNotComputedMask);
+ for (int i = 0; i < sizeof uint32_t; i++) {
+ sink_->Put(data[i], "StringHash");
+ }
+ bytes_processed_so_far_ += sizeof uint32_t;
+ }
+
+ // Serialize the rest of the object.
object_->IterateBody(object_->map()->instance_type(), size, this);
OutputRawData(object_->address() + size);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment