OSDN Git Service

String Compression (interpreter only) bug fix
authorjessicahandojo <jessicahandojo@google.com>
Sat, 10 Sep 2016 02:05:34 +0000 (19:05 -0700)
committerjessicahandojo <jessicahandojo@google.com>
Sat, 10 Sep 2016 02:05:34 +0000 (19:05 -0700)
String with length 0 considered to be compressible,
so the length should be -2147483648 or -(1 << 31).

Change-Id: Ie71f17a0e66efe9a65a8a76d4cee776db636550f

runtime/mirror/string-inl.h

index 86e5139..aea6ff1 100644 (file)
@@ -245,8 +245,9 @@ inline String* String::Alloc(Thread* self, int32_t utf16_length_with_flag,
 
 template <bool kIsInstrumented>
 inline String* String::AllocEmptyString(Thread* self, gc::AllocatorType allocator_type) {
-  SetStringCountVisitor visitor(0);
-  return Alloc<kIsInstrumented>(self, 0, allocator_type, visitor);
+  const int32_t length_with_flag = String::GetFlaggedCount(0);
+  SetStringCountVisitor visitor(length_with_flag);
+  return Alloc<kIsInstrumented>(self, length_with_flag, allocator_type, visitor);
 }
 
 template <bool kIsInstrumented>