summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/debugger.cc4
-rw-r--r--runtime/dex/dex_file_annotations.cc2
-rw-r--r--runtime/entrypoints/entrypoint_utils-inl.h21
-rw-r--r--runtime/entrypoints/entrypoint_utils.h4
-rw-r--r--runtime/interpreter/interpreter_common.cc2
-rw-r--r--runtime/interpreter/interpreter_switch_impl-inl.h11
-rw-r--r--runtime/interpreter/mterp/mterp.cc8
-rw-r--r--runtime/interpreter/unstarted_runtime.cc16
-rw-r--r--runtime/jni/jni_internal.cc4
-rw-r--r--runtime/mirror/array.cc16
-rw-r--r--runtime/mirror/array.h2
-rw-r--r--runtime/mirror/class-alloc-inl.h4
-rw-r--r--runtime/mirror/class.h2
-rw-r--r--runtime/mirror/object_array-alloc-inl.h10
-rw-r--r--runtime/mirror/object_test.cc21
-rw-r--r--runtime/mirror/string.cc8
-rw-r--r--runtime/mirror/string.h10
-rw-r--r--runtime/native/dalvik_system_VMRuntime.cc23
-rw-r--r--runtime/native/java_lang_Class.cc2
-rw-r--r--runtime/native/java_lang_String.cc10
-rw-r--r--runtime/native/java_lang_StringFactory.cc32
-rw-r--r--runtime/runtime.cc2
-rw-r--r--runtime/string_builder_append.cc2
-rw-r--r--runtime/transaction_test.cc11
24 files changed, 115 insertions, 112 deletions
diff --git a/runtime/debugger.cc b/runtime/debugger.cc
index c042d19b71..02fb5b6da4 100644
--- a/runtime/debugger.cc
+++ b/runtime/debugger.cc
@@ -1375,7 +1375,7 @@ JDWP::JdwpError Dbg::CreateObject(JDWP::RefTypeId class_id, JDWP::ObjectId* new_
if (c->IsStringClass()) {
// Special case for java.lang.String.
gc::AllocatorType allocator_type = Runtime::Current()->GetHeap()->GetCurrentAllocator();
- new_object = mirror::String::AllocEmptyString<true>(self, allocator_type);
+ new_object = mirror::String::AllocEmptyString(self, allocator_type);
} else {
new_object = c->AllocObject(self);
}
@@ -1404,7 +1404,7 @@ JDWP::JdwpError Dbg::CreateArrayObject(JDWP::RefTypeId array_class_id, uint32_t
Thread* self = Thread::Current();
gc::AllocatorType allocator_type = Runtime::Current()->GetHeap()->GetCurrentAllocator();
ObjPtr<mirror::Array> new_array =
- mirror::Array::Alloc<true>(self, c, length, c->GetComponentSizeShift(), allocator_type);
+ mirror::Array::Alloc(self, c, length, c->GetComponentSizeShift(), allocator_type);
if (new_array == nullptr) {
DCHECK(self->IsExceptionPending());
self->ClearException();
diff --git a/runtime/dex/dex_file_annotations.cc b/runtime/dex/dex_file_annotations.cc
index 050be4ad1c..24b3a3e5fe 100644
--- a/runtime/dex/dex_file_annotations.cc
+++ b/runtime/dex/dex_file_annotations.cc
@@ -605,7 +605,7 @@ bool ProcessAnnotationValue(const ClassData& klass,
StackHandleScope<2> hs(self);
uint32_t size = DecodeUnsignedLeb128(&annotation);
Handle<mirror::Class> component_type(hs.NewHandle(array_class->GetComponentType()));
- Handle<mirror::Array> new_array(hs.NewHandle(mirror::Array::Alloc<true>(
+ Handle<mirror::Array> new_array(hs.NewHandle(mirror::Array::Alloc(
self, array_class.Get(), size, array_class->GetComponentSizeShift(),
Runtime::Current()->GetHeap()->GetCurrentAllocator())));
if (new_array == nullptr) {
diff --git a/runtime/entrypoints/entrypoint_utils-inl.h b/runtime/entrypoints/entrypoint_utils-inl.h
index 53dea7204c..4d24a8ce87 100644
--- a/runtime/entrypoints/entrypoint_utils-inl.h
+++ b/runtime/entrypoints/entrypoint_utils-inl.h
@@ -219,10 +219,11 @@ inline ObjPtr<mirror::Object> AllocObjectFromCodeResolved(ObjPtr<mirror::Class>
// Pass in false since the object cannot be finalizable.
// CheckClassInitializedForObjectAlloc can cause thread suspension which means we may now be
// instrumented.
- return klass->Alloc</*kInstrumented=*/true, false>(self, heap->GetCurrentAllocator());
+ return klass->Alloc</*kInstrumented=*/true, /*kCheckAddFinalizer=*/false>(
+ self, heap->GetCurrentAllocator());
}
// Pass in false since the object cannot be finalizable.
- return klass->Alloc<kInstrumented, false>(self, allocator_type);
+ return klass->Alloc<kInstrumented, /*kCheckAddFinalizer=*/false>(self, allocator_type);
}
// Given the context of a calling Method and an initialized class, create an instance.
@@ -233,7 +234,7 @@ inline ObjPtr<mirror::Object> AllocObjectFromCodeInitialized(ObjPtr<mirror::Clas
gc::AllocatorType allocator_type) {
DCHECK(klass != nullptr);
// Pass in false since the object cannot be finalizable.
- return klass->Alloc<kInstrumented, false>(self, allocator_type);
+ return klass->Alloc<kInstrumented, /*kCheckAddFinalizer=*/false>(self, allocator_type);
}
@@ -296,8 +297,11 @@ inline ObjPtr<mirror::Array> AllocArrayFromCode(dex::TypeIndex type_idx,
klass->GetComponentSizeShift(),
heap->GetCurrentAllocator());
}
- return mirror::Array::Alloc<kInstrumented>(self, klass, component_count,
- klass->GetComponentSizeShift(), allocator_type);
+ return mirror::Array::Alloc<kInstrumented>(self,
+ klass,
+ component_count,
+ klass->GetComponentSizeShift(),
+ allocator_type);
}
template <bool kInstrumented>
@@ -313,8 +317,11 @@ inline ObjPtr<mirror::Array> AllocArrayFromCodeResolved(ObjPtr<mirror::Class> kl
}
// No need to retry a slow-path allocation as the above code won't cause a GC or thread
// suspension.
- return mirror::Array::Alloc<kInstrumented>(self, klass, component_count,
- klass->GetComponentSizeShift(), allocator_type);
+ return mirror::Array::Alloc<kInstrumented>(self,
+ klass,
+ component_count,
+ klass->GetComponentSizeShift(),
+ allocator_type);
}
template<FindFieldType type, bool access_check>
diff --git a/runtime/entrypoints/entrypoint_utils.h b/runtime/entrypoints/entrypoint_utils.h
index a8618bda58..6e75a1eb63 100644
--- a/runtime/entrypoints/entrypoint_utils.h
+++ b/runtime/entrypoints/entrypoint_utils.h
@@ -49,7 +49,7 @@ class Thread;
// Given the context of a calling Method, use its DexCache to resolve a type to a Class. If it
// cannot be resolved, throw an error. If it can, use it to create an instance.
-template <bool kInstrumented>
+template <bool kInstrumented = true>
ALWAYS_INLINE inline ObjPtr<mirror::Object> AllocObjectFromCode(ObjPtr<mirror::Class> klass,
Thread* self,
gc::AllocatorType allocator_type)
@@ -87,7 +87,7 @@ ALWAYS_INLINE inline ObjPtr<mirror::Class> CheckArrayAlloc(dex::TypeIndex type_i
// it cannot be resolved, throw an error. If it can, use it to create an array.
// When verification/compiler hasn't been able to verify access, optionally perform an access
// check.
-template <bool kAccessCheck, bool kInstrumented>
+template <bool kAccessCheck, bool kInstrumented = true>
ALWAYS_INLINE inline ObjPtr<mirror::Array> AllocArrayFromCode(dex::TypeIndex type_idx,
int32_t component_count,
ArtMethod* method,
diff --git a/runtime/interpreter/interpreter_common.cc b/runtime/interpreter/interpreter_common.cc
index d84225e998..4e08e8c85b 100644
--- a/runtime/interpreter/interpreter_common.cc
+++ b/runtime/interpreter/interpreter_common.cc
@@ -1799,7 +1799,7 @@ bool DoFilledNewArray(const Instruction* inst,
}
return false;
}
- ObjPtr<mirror::Object> new_array = mirror::Array::Alloc<true>(
+ ObjPtr<mirror::Object> new_array = mirror::Array::Alloc(
self,
array_class,
length,
diff --git a/runtime/interpreter/interpreter_switch_impl-inl.h b/runtime/interpreter/interpreter_switch_impl-inl.h
index 247fbb7f2f..1a88f1b47d 100644
--- a/runtime/interpreter/interpreter_switch_impl-inl.h
+++ b/runtime/interpreter/interpreter_switch_impl-inl.h
@@ -797,14 +797,11 @@ class InstructionHandler {
false,
do_access_check);
if (LIKELY(c != nullptr)) {
+ gc::AllocatorType allocator_type = Runtime::Current()->GetHeap()->GetCurrentAllocator();
if (UNLIKELY(c->IsStringClass())) {
- gc::AllocatorType allocator_type = Runtime::Current()->GetHeap()->GetCurrentAllocator();
- obj = mirror::String::AllocEmptyString<true>(self, allocator_type);
+ obj = mirror::String::AllocEmptyString(self, allocator_type);
} else {
- obj = AllocObjectFromCode<true>(
- c.Ptr(),
- self,
- Runtime::Current()->GetHeap()->GetCurrentAllocator());
+ obj = AllocObjectFromCode(c, self, allocator_type);
}
}
if (UNLIKELY(obj == nullptr)) {
@@ -825,7 +822,7 @@ class InstructionHandler {
ALWAYS_INLINE void NEW_ARRAY() REQUIRES_SHARED(Locks::mutator_lock_) {
int32_t length = shadow_frame.GetVReg(inst->VRegB_22c(inst_data));
- ObjPtr<mirror::Object> obj = AllocArrayFromCode<do_access_check, true>(
+ ObjPtr<mirror::Object> obj = AllocArrayFromCode<do_access_check>(
dex::TypeIndex(inst->VRegC_22c()),
length,
shadow_frame.GetMethod(),
diff --git a/runtime/interpreter/mterp/mterp.cc b/runtime/interpreter/mterp/mterp.cc
index d4a192679c..80ebf21b40 100644
--- a/runtime/interpreter/mterp/mterp.cc
+++ b/runtime/interpreter/mterp/mterp.cc
@@ -457,11 +457,9 @@ extern "C" size_t MterpNewInstance(ShadowFrame* shadow_frame, Thread* self, uint
if (LIKELY(c != nullptr)) {
if (UNLIKELY(c->IsStringClass())) {
gc::AllocatorType allocator_type = Runtime::Current()->GetHeap()->GetCurrentAllocator();
- obj = mirror::String::AllocEmptyString<true>(self, allocator_type);
+ obj = mirror::String::AllocEmptyString(self, allocator_type);
} else {
- obj = AllocObjectFromCode<true>(c,
- self,
- Runtime::Current()->GetHeap()->GetCurrentAllocator());
+ obj = AllocObjectFromCode(c, self, Runtime::Current()->GetHeap()->GetCurrentAllocator());
}
}
if (UNLIKELY(obj == nullptr)) {
@@ -523,7 +521,7 @@ extern "C" size_t MterpNewArray(ShadowFrame* shadow_frame,
REQUIRES_SHARED(Locks::mutator_lock_) {
const Instruction* inst = Instruction::At(dex_pc_ptr);
int32_t length = shadow_frame->GetVReg(inst->VRegB_22c(inst_data));
- ObjPtr<mirror::Object> obj = AllocArrayFromCode<false, true>(
+ ObjPtr<mirror::Object> obj = AllocArrayFromCode</*kAccessCheck=*/ false>(
dex::TypeIndex(inst->VRegC_22c()), length, shadow_frame->GetMethod(), self,
Runtime::Current()->GetHeap()->GetCurrentAllocator());
if (UNLIKELY(obj == nullptr)) {
diff --git a/runtime/interpreter/unstarted_runtime.cc b/runtime/interpreter/unstarted_runtime.cc
index 9b905eeaed..727cf2f2e8 100644
--- a/runtime/interpreter/unstarted_runtime.cc
+++ b/runtime/interpreter/unstarted_runtime.cc
@@ -1358,7 +1358,8 @@ void UnstartedRuntime::UnstartedStringFactoryNewStringFromChars(
hs.NewHandle(shadow_frame->GetVRegReference(arg_offset + 2)->AsCharArray()));
Runtime* runtime = Runtime::Current();
gc::AllocatorType allocator = runtime->GetHeap()->GetCurrentAllocator();
- result->SetL(mirror::String::AllocFromCharArray<true>(self, char_count, h_char_array, offset, allocator));
+ result->SetL(
+ mirror::String::AllocFromCharArray(self, char_count, h_char_array, offset, allocator));
}
// This allows creating the new style of String objects during compilation.
@@ -1373,8 +1374,8 @@ void UnstartedRuntime::UnstartedStringFactoryNewStringFromString(
Handle<mirror::String> h_string(hs.NewHandle(to_copy));
Runtime* runtime = Runtime::Current();
gc::AllocatorType allocator = runtime->GetHeap()->GetCurrentAllocator();
- result->SetL(mirror::String::AllocFromString<true>(self, h_string->GetLength(), h_string, 0,
- allocator));
+ result->SetL(
+ mirror::String::AllocFromString(self, h_string->GetLength(), h_string, 0, allocator));
}
void UnstartedRuntime::UnstartedStringFastSubstring(
@@ -1390,7 +1391,7 @@ void UnstartedRuntime::UnstartedStringFastSubstring(
DCHECK_LE(start + length, h_string->GetLength());
Runtime* runtime = Runtime::Current();
gc::AllocatorType allocator = runtime->GetHeap()->GetCurrentAllocator();
- result->SetL(mirror::String::AllocFromString<true>(self, length, h_string, start, allocator));
+ result->SetL(mirror::String::AllocFromString(self, length, h_string, start, allocator));
}
// This allows getting the char array for new style of String objects during compilation.
@@ -1720,11 +1721,8 @@ void UnstartedRuntime::UnstartedJNIVMRuntimeNewUnpaddedArray(
runtime->GetClassLinker()->FindArrayClass(self, element_class->AsClass());
DCHECK(array_class != nullptr);
gc::AllocatorType allocator = runtime->GetHeap()->GetCurrentAllocator();
- result->SetL(mirror::Array::Alloc<true, true>(self,
- array_class,
- length,
- array_class->GetComponentSizeShift(),
- allocator));
+ result->SetL(mirror::Array::Alloc</*kIsInstrumented=*/ true, /*kFillUsable=*/ true>(
+ self, array_class, length, array_class->GetComponentSizeShift(), allocator));
}
void UnstartedRuntime::UnstartedJNIVMStackGetCallingClassLoader(
diff --git a/runtime/jni/jni_internal.cc b/runtime/jni/jni_internal.cc
index 7d2d446c27..af335f65ff 100644
--- a/runtime/jni/jni_internal.cc
+++ b/runtime/jni/jni_internal.cc
@@ -908,8 +908,8 @@ class JNI {
}
if (c->IsStringClass()) {
gc::AllocatorType allocator_type = Runtime::Current()->GetHeap()->GetCurrentAllocator();
- return soa.AddLocalReference<jobject>(mirror::String::AllocEmptyString<true>(soa.Self(),
- allocator_type));
+ return soa.AddLocalReference<jobject>(
+ mirror::String::AllocEmptyString(soa.Self(), allocator_type));
}
return soa.AddLocalReference<jobject>(c->AllocObject(soa.Self()));
}
diff --git a/runtime/mirror/array.cc b/runtime/mirror/array.cc
index d42f5a0099..9bff169191 100644
--- a/runtime/mirror/array.cc
+++ b/runtime/mirror/array.cc
@@ -54,8 +54,8 @@ static ObjPtr<Array> RecursiveCreateMultiArray(Thread* self,
Handle<mirror::Class> h_component_type(hs.NewHandle(array_class->GetComponentType()));
size_t component_size_shift = h_component_type->GetPrimitiveTypeSizeShift();
gc::AllocatorType allocator_type = Runtime::Current()->GetHeap()->GetCurrentAllocator();
- Handle<Array> new_array(hs.NewHandle(Array::Alloc<true>(
- self, array_class.Get(), array_length, component_size_shift, allocator_type)));
+ Handle<Array> new_array(hs.NewHandle(
+ Array::Alloc(self, array_class.Get(), array_length, component_size_shift, allocator_type)));
if (UNLIKELY(new_array == nullptr)) {
CHECK(self->IsExceptionPending());
return nullptr;
@@ -122,11 +122,11 @@ ObjPtr<Array> Array::CreateMultiArray(Thread* self,
template<typename T>
ObjPtr<PrimitiveArray<T>> PrimitiveArray<T>::Alloc(Thread* self, size_t length) {
gc::AllocatorType allocator_type = Runtime::Current()->GetHeap()->GetCurrentAllocator();
- ObjPtr<Array> raw_array = Array::Alloc<true>(self,
- GetClassRoot<PrimitiveArray<T>>(),
- length,
- ComponentSizeShiftWidth(sizeof(T)),
- allocator_type);
+ ObjPtr<Array> raw_array = Array::Alloc(self,
+ GetClassRoot<PrimitiveArray<T>>(),
+ length,
+ ComponentSizeShiftWidth(sizeof(T)),
+ allocator_type);
return ObjPtr<PrimitiveArray<T>>::DownCast(raw_array);
}
@@ -151,7 +151,7 @@ ObjPtr<Array> Array::CopyOf(Thread* self, int32_t new_length) {
const auto component_size = klass->GetComponentSize();
const auto component_shift = klass->GetComponentSizeShift();
ObjPtr<Array> new_array =
- Alloc<true>(self, klass, new_length, component_shift, allocator_type); // Invalidates klass.
+ Alloc(self, klass, new_length, component_shift, allocator_type); // Invalidates klass.
if (LIKELY(new_array != nullptr)) {
memcpy(new_array->GetRawData(component_size, 0),
h_this->GetRawData(component_size, 0),
diff --git a/runtime/mirror/array.h b/runtime/mirror/array.h
index f0397b6912..dbc5d2ac46 100644
--- a/runtime/mirror/array.h
+++ b/runtime/mirror/array.h
@@ -43,7 +43,7 @@ class MANAGED Array : public Object {
// Allocates an array with the given properties, if kFillUsable is true the array will be of at
// least component_count size, however, if there's usable space at the end of the allocation the
// array will fill it.
- template <bool kIsInstrumented, bool kFillUsable = false>
+ template <bool kIsInstrumented = true, bool kFillUsable = false>
ALWAYS_INLINE static ObjPtr<Array> Alloc(Thread* self,
ObjPtr<Class> array_class,
int32_t component_count,
diff --git a/runtime/mirror/class-alloc-inl.h b/runtime/mirror/class-alloc-inl.h
index 03c422fc79..cab3c5174b 100644
--- a/runtime/mirror/class-alloc-inl.h
+++ b/runtime/mirror/class-alloc-inl.h
@@ -72,11 +72,11 @@ inline ObjPtr<Object> Class::Alloc(Thread* self, gc::AllocatorType allocator_typ
}
inline ObjPtr<Object> Class::AllocObject(Thread* self) {
- return Alloc<true>(self, Runtime::Current()->GetHeap()->GetCurrentAllocator());
+ return Alloc(self, Runtime::Current()->GetHeap()->GetCurrentAllocator());
}
inline ObjPtr<Object> Class::AllocNonMovableObject(Thread* self) {
- return Alloc<true>(self, Runtime::Current()->GetHeap()->GetCurrentNonMovingAllocator());
+ return Alloc(self, Runtime::Current()->GetHeap()->GetCurrentNonMovingAllocator());
}
} // namespace mirror
diff --git a/runtime/mirror/class.h b/runtime/mirror/class.h
index f2ba7d000c..2bae7e7dd1 100644
--- a/runtime/mirror/class.h
+++ b/runtime/mirror/class.h
@@ -467,7 +467,7 @@ class MANAGED Class final : public Object {
bool IsPrimitiveArray() REQUIRES_SHARED(Locks::mutator_lock_);
// Creates a raw object instance but does not invoke the default constructor.
- template<bool kIsInstrumented, bool kCheckAddFinalizer = true>
+ template<bool kIsInstrumented = true, bool kCheckAddFinalizer = true>
ALWAYS_INLINE ObjPtr<Object> Alloc(Thread* self, gc::AllocatorType allocator_type)
REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
diff --git a/runtime/mirror/object_array-alloc-inl.h b/runtime/mirror/object_array-alloc-inl.h
index 8e96d9fc19..b417b62b11 100644
--- a/runtime/mirror/object_array-alloc-inl.h
+++ b/runtime/mirror/object_array-alloc-inl.h
@@ -37,11 +37,11 @@ inline ObjPtr<ObjectArray<T>> ObjectArray<T>::Alloc(Thread* self,
ObjPtr<Class> object_array_class,
int32_t length,
gc::AllocatorType allocator_type) {
- ObjPtr<Array> array = Array::Alloc<true>(self,
- object_array_class,
- length,
- ComponentSizeShiftWidth(kHeapReferenceSize),
- allocator_type);
+ ObjPtr<Array> array = Array::Alloc(self,
+ object_array_class,
+ length,
+ ComponentSizeShiftWidth(kHeapReferenceSize),
+ allocator_type);
if (UNLIKELY(array == nullptr)) {
return nullptr;
}
diff --git a/runtime/mirror/object_test.cc b/runtime/mirror/object_test.cc
index 1cb22f2a5e..45a0437747 100644
--- a/runtime/mirror/object_test.cc
+++ b/runtime/mirror/object_test.cc
@@ -158,17 +158,17 @@ TEST_F(ObjectTest, AllocArray) {
MutableHandle<Class> c = hs.NewHandle(class_linker_->FindSystemClass(soa.Self(), "[I"));
gc::AllocatorType allocator_type = Runtime::Current()->GetHeap()->GetCurrentAllocator();
MutableHandle<Array> a = hs.NewHandle(
- Array::Alloc<true>(soa.Self(), c.Get(), 1, c->GetComponentSizeShift(), allocator_type));
+ Array::Alloc(soa.Self(), c.Get(), 1, c->GetComponentSizeShift(), allocator_type));
EXPECT_TRUE(c.Get() == a->GetClass());
EXPECT_EQ(1, a->GetLength());
c.Assign(class_linker_->FindSystemClass(soa.Self(), "[Ljava/lang/Object;"));
- a.Assign(Array::Alloc<true>(soa.Self(), c.Get(), 1, c->GetComponentSizeShift(), allocator_type));
+ a.Assign(Array::Alloc(soa.Self(), c.Get(), 1, c->GetComponentSizeShift(), allocator_type));
EXPECT_TRUE(c.Get() == a->GetClass());
EXPECT_EQ(1, a->GetLength());
c.Assign(class_linker_->FindSystemClass(soa.Self(), "[[Ljava/lang/Object;"));
- a.Assign(Array::Alloc<true>(soa.Self(), c.Get(), 1, c->GetComponentSizeShift(), allocator_type));
+ a.Assign(Array::Alloc(soa.Self(), c.Get(), 1, c->GetComponentSizeShift(), allocator_type));
EXPECT_TRUE(c.Get() == a->GetClass());
EXPECT_EQ(1, a->GetLength());
}
@@ -179,25 +179,26 @@ TEST_F(ObjectTest, AllocArray_FillUsable) {
MutableHandle<Class> c = hs.NewHandle(class_linker_->FindSystemClass(soa.Self(), "[B"));
gc::AllocatorType allocator_type = Runtime::Current()->GetHeap()->GetCurrentAllocator();
MutableHandle<Array> a = hs.NewHandle(
- Array::Alloc<true, true>(soa.Self(), c.Get(), 1, c->GetComponentSizeShift(), allocator_type));
+ Array::Alloc</*kIsInstrumented=*/ true, /*kFillUsable=*/ true>(
+ soa.Self(), c.Get(), 1, c->GetComponentSizeShift(), allocator_type));
EXPECT_TRUE(c.Get() == a->GetClass());
EXPECT_LE(1, a->GetLength());
c.Assign(class_linker_->FindSystemClass(soa.Self(), "[I"));
- a.Assign(
- Array::Alloc<true, true>(soa.Self(), c.Get(), 2, c->GetComponentSizeShift(), allocator_type));
+ a.Assign(Array::Alloc</*kIsInstrumented=*/ true, /*kFillUsable=*/ true>(
+ soa.Self(), c.Get(), 2, c->GetComponentSizeShift(), allocator_type));
EXPECT_TRUE(c.Get() == a->GetClass());
EXPECT_LE(2, a->GetLength());
c.Assign(class_linker_->FindSystemClass(soa.Self(), "[Ljava/lang/Object;"));
- a.Assign(
- Array::Alloc<true, true>(soa.Self(), c.Get(), 2, c->GetComponentSizeShift(), allocator_type));
+ a.Assign(Array::Alloc</*kIsInstrumented=*/ true, /*kFillUsable=*/ true>(
+ soa.Self(), c.Get(), 2, c->GetComponentSizeShift(), allocator_type));
EXPECT_TRUE(c.Get() == a->GetClass());
EXPECT_LE(2, a->GetLength());
c.Assign(class_linker_->FindSystemClass(soa.Self(), "[[Ljava/lang/Object;"));
- a.Assign(
- Array::Alloc<true, true>(soa.Self(), c.Get(), 2, c->GetComponentSizeShift(), allocator_type));
+ a.Assign(Array::Alloc</*kIsInstrumented=*/ true, /*kFillUsable=*/ true>(
+ soa.Self(), c.Get(), 2, c->GetComponentSizeShift(), allocator_type));
EXPECT_TRUE(c.Get() == a->GetClass());
EXPECT_LE(2, a->GetLength());
}
diff --git a/runtime/mirror/string.cc b/runtime/mirror/string.cc
index 1881c5782c..b2b68d6fde 100644
--- a/runtime/mirror/string.cc
+++ b/runtime/mirror/string.cc
@@ -89,7 +89,7 @@ ObjPtr<String> String::DoReplace(Thread* self, Handle<String> src, uint16_t old_
gc::AllocatorType allocator_type = Runtime::Current()->GetHeap()->GetCurrentAllocator();
const int32_t length_with_flag = String::GetFlaggedCount(length, compressible);
SetStringCountVisitor visitor(length_with_flag);
- ObjPtr<String> string = Alloc<true>(self, length_with_flag, allocator_type, visitor);
+ ObjPtr<String> string = Alloc(self, length_with_flag, allocator_type, visitor);
if (UNLIKELY(string == nullptr)) {
return nullptr;
}
@@ -130,7 +130,7 @@ ObjPtr<String> String::AllocFromStrings(Thread* self,
const int32_t length_with_flag = String::GetFlaggedCount(length + length2, compressible);
SetStringCountVisitor visitor(length_with_flag);
- ObjPtr<String> new_string = Alloc<true>(self, length_with_flag, allocator_type, visitor);
+ ObjPtr<String> new_string = Alloc(self, length_with_flag, allocator_type, visitor);
if (UNLIKELY(new_string == nullptr)) {
return nullptr;
}
@@ -167,7 +167,7 @@ ObjPtr<String> String::AllocFromUtf16(Thread* self,
String::AllASCII<uint16_t>(utf16_data_in, utf16_length);
int32_t length_with_flag = String::GetFlaggedCount(utf16_length, compressible);
SetStringCountVisitor visitor(length_with_flag);
- ObjPtr<String> string = Alloc<true>(self, length_with_flag, allocator_type, visitor);
+ ObjPtr<String> string = Alloc(self, length_with_flag, allocator_type, visitor);
if (UNLIKELY(string == nullptr)) {
return nullptr;
}
@@ -203,7 +203,7 @@ ObjPtr<String> String::AllocFromModifiedUtf8(Thread* self,
const bool compressible = kUseStringCompression && (utf16_length == utf8_length);
const int32_t utf16_length_with_flag = String::GetFlaggedCount(utf16_length, compressible);
SetStringCountVisitor visitor(utf16_length_with_flag);
- ObjPtr<String> string = Alloc<true>(self, utf16_length_with_flag, allocator_type, visitor);
+ ObjPtr<String> string = Alloc(self, utf16_length_with_flag, allocator_type, visitor);
if (UNLIKELY(string == nullptr)) {
return nullptr;
}
diff --git a/runtime/mirror/string.h b/runtime/mirror/string.h
index 665446c1f4..116ecd1cab 100644
--- a/runtime/mirror/string.h
+++ b/runtime/mirror/string.h
@@ -118,7 +118,7 @@ class MANAGED String final : public Object {
ObjPtr<String> Intern() REQUIRES_SHARED(Locks::mutator_lock_);
- template <bool kIsInstrumented>
+ template <bool kIsInstrumented = true>
ALWAYS_INLINE static ObjPtr<String> AllocFromByteArray(Thread* self,
int32_t byte_length,
Handle<ByteArray> array,
@@ -127,7 +127,7 @@ class MANAGED String final : public Object {
gc::AllocatorType allocator_type)
REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
- template <bool kIsInstrumented>
+ template <bool kIsInstrumented = true>
ALWAYS_INLINE static ObjPtr<String> AllocFromCharArray(Thread* self,
int32_t count,
Handle<CharArray> array,
@@ -135,7 +135,7 @@ class MANAGED String final : public Object {
gc::AllocatorType allocator_type)
REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
- template <bool kIsInstrumented>
+ template <bool kIsInstrumented = true>
ALWAYS_INLINE static ObjPtr<String> AllocFromString(Thread* self,
int32_t string_length,
Handle<String> string,
@@ -143,7 +143,7 @@ class MANAGED String final : public Object {
gc::AllocatorType allocator_type)
REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
- template <bool kIsInstrumented>
+ template <bool kIsInstrumented = true>
ALWAYS_INLINE static ObjPtr<String> AllocEmptyString(Thread* self,
gc::AllocatorType allocator_type)
REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
@@ -252,7 +252,7 @@ class MANAGED String final : public Object {
SetField32<false, false>(OFFSET_OF_OBJECT_MEMBER(String, hash_code_), new_hash_code);
}
- template <bool kIsInstrumented, typename PreFenceVisitor>
+ template <bool kIsInstrumented = true, typename PreFenceVisitor>
ALWAYS_INLINE static ObjPtr<String> Alloc(Thread* self,
int32_t utf16_length_with_flag,
gc::AllocatorType allocator_type,
diff --git a/runtime/native/dalvik_system_VMRuntime.cc b/runtime/native/dalvik_system_VMRuntime.cc
index 399813c60e..410c2295bf 100644
--- a/runtime/native/dalvik_system_VMRuntime.cc
+++ b/runtime/native/dalvik_system_VMRuntime.cc
@@ -118,11 +118,11 @@ static jobject VMRuntime_newNonMovableArray(JNIEnv* env, jobject, jclass javaEle
return nullptr;
}
gc::AllocatorType allocator = runtime->GetHeap()->GetCurrentNonMovingAllocator();
- ObjPtr<mirror::Array> result = mirror::Array::Alloc<true>(soa.Self(),
- array_class,
- length,
- array_class->GetComponentSizeShift(),
- allocator);
+ ObjPtr<mirror::Array> result = mirror::Array::Alloc(soa.Self(),
+ array_class,
+ length,
+ array_class->GetComponentSizeShift(),
+ allocator);
return soa.AddLocalReference<jobject>(result);
}
@@ -145,12 +145,13 @@ static jobject VMRuntime_newUnpaddedArray(JNIEnv* env, jobject, jclass javaEleme
return nullptr;
}
gc::AllocatorType allocator = runtime->GetHeap()->GetCurrentAllocator();
- ObjPtr<mirror::Array> result = mirror::Array::Alloc<true, true>(
- soa.Self(),
- array_class,
- length,
- array_class->GetComponentSizeShift(),
- allocator);
+ ObjPtr<mirror::Array> result =
+ mirror::Array::Alloc</*kIsInstrumented=*/ true, /*kFillUsable=*/ true>(
+ soa.Self(),
+ array_class,
+ length,
+ array_class->GetComponentSizeShift(),
+ allocator);
return soa.AddLocalReference<jobject>(result);
}
diff --git a/runtime/native/java_lang_Class.cc b/runtime/native/java_lang_Class.cc
index 2b75c59c2a..f69d1bc66c 100644
--- a/runtime/native/java_lang_Class.cc
+++ b/runtime/native/java_lang_Class.cc
@@ -823,7 +823,7 @@ static jobject Class_newInstance(JNIEnv* env, jobject javaThis) {
// Invoke the string allocator to return an empty string for the string class.
if (klass->IsStringClass()) {
gc::AllocatorType allocator_type = Runtime::Current()->GetHeap()->GetCurrentAllocator();
- ObjPtr<mirror::Object> obj = mirror::String::AllocEmptyString<true>(soa.Self(), allocator_type);
+ ObjPtr<mirror::Object> obj = mirror::String::AllocEmptyString(soa.Self(), allocator_type);
if (UNLIKELY(soa.Self()->IsExceptionPending())) {
return nullptr;
} else {
diff --git a/runtime/native/java_lang_String.cc b/runtime/native/java_lang_String.cc
index 83498f6eb0..2d9e7dc55d 100644
--- a/runtime/native/java_lang_String.cc
+++ b/runtime/native/java_lang_String.cc
@@ -73,11 +73,11 @@ static jstring String_fastSubstring(JNIEnv* env, jobject java_this, jint start,
StackHandleScope<1> hs(soa.Self());
Handle<mirror::String> string_this(hs.NewHandle(soa.Decode<mirror::String>(java_this)));
gc::AllocatorType allocator_type = Runtime::Current()->GetHeap()->GetCurrentAllocator();
- ObjPtr<mirror::String> result = mirror::String::AllocFromString<true>(soa.Self(),
- length,
- string_this,
- start,
- allocator_type);
+ ObjPtr<mirror::String> result = mirror::String::AllocFromString(soa.Self(),
+ length,
+ string_this,
+ start,
+ allocator_type);
return soa.AddLocalReference<jstring>(result);
}
diff --git a/runtime/native/java_lang_StringFactory.cc b/runtime/native/java_lang_StringFactory.cc
index 13f8d5be8e..178d5dabbd 100644
--- a/runtime/native/java_lang_StringFactory.cc
+++ b/runtime/native/java_lang_StringFactory.cc
@@ -47,12 +47,12 @@ static jstring StringFactory_newStringFromBytes(JNIEnv* env, jclass, jbyteArray
return nullptr;
}
gc::AllocatorType allocator_type = Runtime::Current()->GetHeap()->GetCurrentAllocator();
- ObjPtr<mirror::String> result = mirror::String::AllocFromByteArray<true>(soa.Self(),
- byte_count,
- byte_array,
- offset,
- high,
- allocator_type);
+ ObjPtr<mirror::String> result = mirror::String::AllocFromByteArray(soa.Self(),
+ byte_count,
+ byte_array,
+ offset,
+ high,
+ allocator_type);
return soa.AddLocalReference<jstring>(result);
}
@@ -64,11 +64,11 @@ static jstring StringFactory_newStringFromChars(JNIEnv* env, jclass, jint offset
StackHandleScope<1> hs(soa.Self());
Handle<mirror::CharArray> char_array(hs.NewHandle(soa.Decode<mirror::CharArray>(java_data)));
gc::AllocatorType allocator_type = Runtime::Current()->GetHeap()->GetCurrentAllocator();
- ObjPtr<mirror::String> result = mirror::String::AllocFromCharArray<true>(soa.Self(),
- char_count,
- char_array,
- offset,
- allocator_type);
+ ObjPtr<mirror::String> result = mirror::String::AllocFromCharArray(soa.Self(),
+ char_count,
+ char_array,
+ offset,
+ allocator_type);
return soa.AddLocalReference<jstring>(result);
}
@@ -81,11 +81,11 @@ static jstring StringFactory_newStringFromString(JNIEnv* env, jclass, jstring to
StackHandleScope<1> hs(soa.Self());
Handle<mirror::String> string(hs.NewHandle(soa.Decode<mirror::String>(to_copy)));
gc::AllocatorType allocator_type = Runtime::Current()->GetHeap()->GetCurrentAllocator();
- ObjPtr<mirror::String> result = mirror::String::AllocFromString<true>(soa.Self(),
- string->GetLength(),
- string,
- 0,
- allocator_type);
+ ObjPtr<mirror::String> result = mirror::String::AllocFromString(soa.Self(),
+ string->GetLength(),
+ string,
+ /*offset=*/ 0,
+ allocator_type);
return soa.AddLocalReference<jstring>(result);
}
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 8133193a25..8a3d5402b2 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -1089,7 +1089,7 @@ static inline void CreatePreAllocatedException(Thread* self,
CHECK(klass != nullptr);
gc::AllocatorType allocator_type = runtime->GetHeap()->GetCurrentAllocator();
ObjPtr<mirror::Throwable> exception_object = ObjPtr<mirror::Throwable>::DownCast(
- klass->Alloc</* kIsInstrumented= */ true>(self, allocator_type));
+ klass->Alloc(self, allocator_type));
CHECK(exception_object != nullptr);
*exception = GcRoot<mirror::Throwable>(exception_object);
// Initialize the "detailMessage" field.
diff --git a/runtime/string_builder_append.cc b/runtime/string_builder_append.cc
index 5a34e9368a..85b70eb12b 100644
--- a/runtime/string_builder_append.cc
+++ b/runtime/string_builder_append.cc
@@ -355,7 +355,7 @@ ObjPtr<mirror::String> StringBuilderAppend::AppendF(uint32_t format,
return nullptr;
}
gc::AllocatorType allocator_type = Runtime::Current()->GetHeap()->GetCurrentAllocator();
- ObjPtr<mirror::String> result = mirror::String::Alloc</*kIsInstrumented=*/ true>(
+ ObjPtr<mirror::String> result = mirror::String::Alloc(
self, length_with_flag, allocator_type, builder);
return result;
diff --git a/runtime/transaction_test.cc b/runtime/transaction_test.cc
index aea2211040..7ad741a7a0 100644
--- a/runtime/transaction_test.cc
+++ b/runtime/transaction_test.cc
@@ -145,11 +145,12 @@ TEST_F(TransactionTest, Array_length) {
Runtime::Current()->EnterTransactionMode();
// Allocate an array during transaction.
- Handle<mirror::Array> h_obj(
- hs.NewHandle(
- mirror::Array::Alloc<true>(soa.Self(), h_klass.Get(), kArraySize,
- h_klass->GetComponentSizeShift(),
- Runtime::Current()->GetHeap()->GetCurrentAllocator())));
+ Handle<mirror::Array> h_obj = hs.NewHandle(
+ mirror::Array::Alloc(soa.Self(),
+ h_klass.Get(),
+ kArraySize,
+ h_klass->GetComponentSizeShift(),
+ Runtime::Current()->GetHeap()->GetCurrentAllocator()));
ASSERT_TRUE(h_obj != nullptr);
ASSERT_OBJ_PTR_EQ(h_obj->GetClass(), h_klass.Get());
Runtime::Current()->RollbackAndExitTransactionMode();