summaryrefslogtreecommitdiff
path: root/runtime/interpreter/interpreter_switch_impl.cc
diff options
context:
space:
mode:
author Jeff Hao <jeffhao@google.com> 2015-04-28 02:04:09 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2015-04-28 02:04:09 +0000
commit9d1e19035a59ff8bf05a09ad880ede99806ba73f (patch)
tree7eb3c9eb01d4f581f3e354d947300547582fdd38 /runtime/interpreter/interpreter_switch_impl.cc
parent3fd79afbb7490f52817f737ecceb694f6618dcf9 (diff)
parent848f70a3d73833fc1bf3032a9ff6812e429661d9 (diff)
Merge "Replace String CharArray with internal uint16_t array."
Diffstat (limited to 'runtime/interpreter/interpreter_switch_impl.cc')
-rw-r--r--runtime/interpreter/interpreter_switch_impl.cc18
1 files changed, 14 insertions, 4 deletions
diff --git a/runtime/interpreter/interpreter_switch_impl.cc b/runtime/interpreter/interpreter_switch_impl.cc
index 82f0009b85..a5e5299b34 100644
--- a/runtime/interpreter/interpreter_switch_impl.cc
+++ b/runtime/interpreter/interpreter_switch_impl.cc
@@ -428,10 +428,20 @@ JValue ExecuteSwitchImpl(Thread* self, const DexFile::CodeItem* code_item,
}
case Instruction::NEW_INSTANCE: {
PREAMBLE();
- Runtime* runtime = Runtime::Current();
- Object* obj = AllocObjectFromCode<do_access_check, true>(
- inst->VRegB_21c(), shadow_frame.GetMethod(), self,
- runtime->GetHeap()->GetCurrentAllocator());
+ Object* obj = nullptr;
+ Class* c = ResolveVerifyAndClinit(inst->VRegB_21c(), shadow_frame.GetMethod(),
+ self, false, do_access_check);
+ if (LIKELY(c != nullptr)) {
+ if (UNLIKELY(c->IsStringClass())) {
+ gc::AllocatorType allocator_type = Runtime::Current()->GetHeap()->GetCurrentAllocator();
+ mirror::SetStringCountVisitor visitor(0);
+ obj = String::Alloc<true>(self, 0, allocator_type, visitor);
+ } else {
+ obj = AllocObjectFromCode<do_access_check, true>(
+ inst->VRegB_21c(), shadow_frame.GetMethod(), self,
+ Runtime::Current()->GetHeap()->GetCurrentAllocator());
+ }
+ }
if (UNLIKELY(obj == nullptr)) {
HANDLE_PENDING_EXCEPTION();
} else {