diff options
author | Hiroshi Yamauchi <yamauchi@google.com> | 2014-09-25 11:46:46 -0700 |
---|---|---|
committer | Hiroshi Yamauchi <yamauchi@google.com> | 2014-09-25 15:53:54 -0700 |
commit | f0edfc355893d53d1104b05501c99ad5ccf305c4 (patch) | |
tree | 7e1fa49875759512f5d02b1c45435d3e3366b920 /runtime/native/java_lang_reflect_Array.cc | |
parent | 1ed5b27ee329208fd8ae22b8a9a61d708e2c1ffb (diff) | |
download | android_art-f0edfc355893d53d1104b05501c99ad5ccf305c4.tar.gz android_art-f0edfc355893d53d1104b05501c99ad5ccf305c4.tar.bz2 android_art-f0edfc355893d53d1104b05501c99ad5ccf305c4.zip |
Some optimizations for the array alloc path.
- Force Array::Alloc() to be inlined.
- Simplify the array size overflow check.
- Turn fill_usable into a template parameter.
- Remove a branch in Array::DataOffset() and avoid
Primitive::ComponentSize(), which has a switch, in the array alloc
path.
- Strength reductions in the array size computation by using component
size shifts instead of component sizes. Store component size shift
in the upper 16 bits of primitive_type field.
- Speedup: ~4% (3435->3284) in MemAllocTest on N4.
Bug: 9986565
Change-Id: I4b142ffac4ab8b5b915836f1660a949d6442344c
Diffstat (limited to 'runtime/native/java_lang_reflect_Array.cc')
-rw-r--r-- | runtime/native/java_lang_reflect_Array.cc | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/runtime/native/java_lang_reflect_Array.cc b/runtime/native/java_lang_reflect_Array.cc index 058458fa39..763a6645b9 100644 --- a/runtime/native/java_lang_reflect_Array.cc +++ b/runtime/native/java_lang_reflect_Array.cc @@ -59,9 +59,10 @@ static jobject Array_createObjectArray(JNIEnv* env, jclass, jclass javaElementCl return NULL; } DCHECK(array_class->IsObjectArrayClass()); - mirror::Array* new_array = mirror::Array::Alloc<true>(soa.Self(), array_class, length, - sizeof(mirror::HeapReference<mirror::Object>), - runtime->GetHeap()->GetCurrentAllocator()); + mirror::Array* new_array = mirror::Array::Alloc<true>( + soa.Self(), array_class, length, + ComponentSizeShiftWidth<sizeof(mirror::HeapReference<mirror::Object>)>(), + runtime->GetHeap()->GetCurrentAllocator()); return soa.AddLocalReference<jobject>(new_array); } |