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

Unified Diff: src/heap/heap-inl.h

Issue 2549773002: Internalize strings in-place (Closed)
Patch Set: forgot one Created 4 years 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
Index: src/heap/heap-inl.h
diff --git a/src/heap/heap-inl.h b/src/heap/heap-inl.h
index 02e684a3b9d54c46b447f3bf1e79cfdbf9a23fd8..8c2481f45e74d4ae0573ef9b859378d5729fa4a7 100644
--- a/src/heap/heap-inl.h
+++ b/src/heap/heap-inl.h
@@ -224,6 +224,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());
@@ -255,6 +257,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());

Powered by Google App Engine
This is Rietveld 408576698