Index: runtime/vm/simulator_dbc.cc |
diff --git a/runtime/vm/simulator_dbc.cc b/runtime/vm/simulator_dbc.cc |
index 75b94dd9236a77ce62d06c7b8c67fdcb81cbf762..3a9b2d8414b70a5574ac244ed85d12e38565671c 100644 |
--- a/runtime/vm/simulator_dbc.cc |
+++ b/runtime/vm/simulator_dbc.cc |
@@ -2955,33 +2955,36 @@ RawObject* Simulator::Call(const Code& code, |
{ |
BYTECODE(CreateArrayOpt, A_B_C); |
- const intptr_t length = Smi::Value(RAW_CAST(Smi, FP[rB])); |
- if (LIKELY(static_cast<uintptr_t>(length) <= Array::kMaxElements)) { |
- const intptr_t fixed_size_plus_alignment_padding = |
- sizeof(RawArray) + kObjectAlignment - 1; |
- const intptr_t instance_size = |
- (fixed_size_plus_alignment_padding + length * kWordSize) & |
- ~(kObjectAlignment - 1); |
- const uword start = |
- thread->heap()->new_space()->TryAllocate(instance_size); |
- if (LIKELY(start != 0)) { |
- const intptr_t cid = kArrayCid; |
- uword tags = 0; |
- if (LIKELY(instance_size <= RawObject::SizeTag::kMaxSizeTag)) { |
- tags = RawObject::SizeTag::update(instance_size, tags); |
- } |
- tags = RawObject::ClassIdTag::update(cid, tags); |
- *reinterpret_cast<uword*>(start + Instance::tags_offset()) = tags; |
- *reinterpret_cast<RawObject**>(start + Array::length_offset()) = FP[rB]; |
- *reinterpret_cast<RawObject**>(start + Array::type_arguments_offset()) = |
- FP[rC]; |
- RawObject** data = |
- reinterpret_cast<RawObject**>(start + Array::data_offset()); |
- for (intptr_t i = 0; i < length; i++) { |
- data[i] = null_value; |
+ if (LIKELY(!FP[rB]->IsHeapObject())) { |
+ const intptr_t length = Smi::Value(RAW_CAST(Smi, FP[rB])); |
+ if (LIKELY(static_cast<uintptr_t>(length) <= Array::kMaxElements)) { |
+ const intptr_t fixed_size_plus_alignment_padding = |
+ sizeof(RawArray) + kObjectAlignment - 1; |
+ const intptr_t instance_size = |
+ (fixed_size_plus_alignment_padding + length * kWordSize) & |
+ ~(kObjectAlignment - 1); |
+ const uword start = |
+ thread->heap()->new_space()->TryAllocate(instance_size); |
+ if (LIKELY(start != 0)) { |
+ const intptr_t cid = kArrayCid; |
+ uword tags = 0; |
+ if (LIKELY(instance_size <= RawObject::SizeTag::kMaxSizeTag)) { |
+ tags = RawObject::SizeTag::update(instance_size, tags); |
+ } |
+ tags = RawObject::ClassIdTag::update(cid, tags); |
+ *reinterpret_cast<uword*>(start + Instance::tags_offset()) = tags; |
+ *reinterpret_cast<RawObject**>(start + Array::length_offset()) = |
+ FP[rB]; |
+ *reinterpret_cast<RawObject**>( |
+ start + Array::type_arguments_offset()) = FP[rC]; |
+ RawObject** data = |
+ reinterpret_cast<RawObject**>(start + Array::data_offset()); |
+ for (intptr_t i = 0; i < length; i++) { |
+ data[i] = null_value; |
+ } |
+ FP[rA] = reinterpret_cast<RawObject*>(start + kHeapObjectTag); |
+ pc += 4; |
} |
- FP[rA] = reinterpret_cast<RawObject*>(start + kHeapObjectTag); |
- pc += 4; |
} |
} |
DISPATCH(); |