Index: src/heap/heap-inl.h |
diff --git a/src/heap/heap-inl.h b/src/heap/heap-inl.h |
index 11b587886e013f331d354254e484fdca2d28895a..79885f131b0ed6fc6819f73f42aab433399bb678 100644 |
--- a/src/heap/heap-inl.h |
+++ b/src/heap/heap-inl.h |
@@ -225,6 +225,8 @@ AllocationResult Heap::AllocateInternalizedStringImpl(T t, int chars, |
AllocationResult Heap::AllocateOneByteInternalizedString( |
Vector<const uint8_t> str, uint32_t hash_field) { |
CHECK_GE(String::kMaxLength, str.length()); |
+ // The canonical empty_string is the only zero-length string we allow. |
+ DCHECK_IMPLIES(str.length() == 0, roots_[kempty_stringRootIndex] == nullptr); |
// Compute map and object size. |
Map* map = one_byte_internalized_string_map(); |
int size = SeqOneByteString::SizeFor(str.length()); |
@@ -256,6 +258,7 @@ AllocationResult Heap::AllocateOneByteInternalizedString( |
AllocationResult Heap::AllocateTwoByteInternalizedString(Vector<const uc16> str, |
uint32_t hash_field) { |
CHECK_GE(String::kMaxLength, str.length()); |
+ DCHECK_NE(0, str.length()); // Use Heap::empty_string() instead. |
// Compute map and object size. |
Map* map = internalized_string_map(); |
int size = SeqTwoByteString::SizeFor(str.length()); |