Skip to content

Commit

Permalink
VM: Fix bug in the new edge counter code on ARM and MIPS.
Browse files Browse the repository at this point in the history
The offset into the edge counter array may exceed the limit
of what fits into an Address operand on ARM and MIPS.

BUG=
[email protected]

Review URL: https://codereview.chromium.org//1373013002 .
  • Loading branch information
fsc8000 committed Sep 28, 2015
1 parent da006ac commit 66bc931
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 4 additions & 5 deletions runtime/vm/flow_graph_compiler_arm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1188,17 +1188,16 @@ void FlowGraphCompiler::EmitEdgeCounter(intptr_t edge_id) {
// optimization/deoptimization cycles we will attempt.
ASSERT(!edge_counters_array_.IsNull());
ASSERT(assembler_->constant_pool_allowed());
const Array& counter = Array::ZoneHandle(zone(), Array::New(1, Heap::kOld));
counter.SetAt(0, Smi::Handle(zone(), Smi::New(0)));
__ Comment("Edge counter");
__ LoadObject(R0, edge_counters_array_);
#if defined(DEBUG)
bool old_use_far_branches = assembler_->use_far_branches();
assembler_->set_use_far_branches(true);
#endif // DEBUG
__ ldr(IP, FieldAddress(R0, Array::element_offset(edge_id)));
__ add(IP, IP, Operand(Smi::RawValue(1)));
__ StoreIntoSmiField(FieldAddress(R0, Array::element_offset(edge_id)), IP);
__ LoadFieldFromOffset(kWord, R1, R0, Array::element_offset(edge_id));
__ add(R1, R1, Operand(Smi::RawValue(1)));
__ StoreIntoObjectNoBarrierOffset(
R0, Array::element_offset(edge_id), R1, Assembler::kOnlySmi);
#if defined(DEBUG)
assembler_->set_use_far_branches(old_use_far_branches);
#endif // DEBUG
Expand Down
4 changes: 2 additions & 2 deletions runtime/vm/flow_graph_compiler_mips.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1207,9 +1207,9 @@ void FlowGraphCompiler::EmitEdgeCounter(intptr_t edge_id) {
ASSERT(!edge_counters_array_.IsNull());
__ Comment("Edge counter");
__ LoadObject(T0, edge_counters_array_);
__ lw(T1, FieldAddress(T0, Array::element_offset(edge_id)));
__ LoadFieldFromOffset(T1, T0, Array::element_offset(edge_id));
__ AddImmediate(T1, T1, Smi::RawValue(1));
__ sw(T1, FieldAddress(T0, Array::element_offset(edge_id)));
__ StoreFieldToOffset(T1, T0, Array::element_offset(edge_id));
}


Expand Down

0 comments on commit 66bc931

Please sign in to comment.