Index: src/objects-inl.h |
diff --git a/src/objects-inl.h b/src/objects-inl.h |
index 0aca5cfcdb488b0718af22d18c95afc69a17da19..36e7eb1758769709f12c17d6abf609f422dd9359 100644 |
--- a/src/objects-inl.h |
+++ b/src/objects-inl.h |
@@ -6580,6 +6580,32 @@ bool String::AsArrayIndex(uint32_t* index) { |
} |
+void String::SetForwardedInternalizedString(String* canonical) { |
+ ASSERT(IsInternalizedString()); |
+ ASSERT(HasHashCode()); |
+ if (canonical == this) return; // No need to forward. |
+ ASSERT(SlowEquals(canonical)); |
+ ASSERT(canonical->IsInternalizedString()); |
+ ASSERT(canonical->HasHashCode()); |
+ WRITE_FIELD(this, kHashFieldOffset, canonical); |
+ // Setting the hash field to a tagged value sets the LSB, causing the hash |
+ // code to be interpreted as uninitialized. We use this fact to recognize |
+ // that we have a forwarded string. |
+ ASSERT(!HasHashCode()); |
+} |
+ |
+ |
+String* String::GetForwardedInternalizedString() { |
+ ASSERT(IsInternalizedString()); |
+ if (HasHashCode()) return this; |
+ String* canonical = String::cast(READ_FIELD(this, kHashFieldOffset)); |
+ ASSERT(canonical->IsInternalizedString()); |
+ ASSERT(SlowEquals(canonical)); |
+ ASSERT(canonical->HasHashCode()); |
+ return canonical; |
+} |
+ |
+ |
Object* JSReceiver::GetConstructor() { |
return map()->constructor(); |
} |