Index: runtime/vm/flow_graph_compiler_ia32.cc |
diff --git a/runtime/vm/flow_graph_compiler_ia32.cc b/runtime/vm/flow_graph_compiler_ia32.cc |
index 15761b3c4210d39e308eeac76e768f2e171a7ff1..748b3bf57e0a920396dab420392e9fcd6f8f68d6 100644 |
--- a/runtime/vm/flow_graph_compiler_ia32.cc |
+++ b/runtime/vm/flow_graph_compiler_ia32.cc |
@@ -958,15 +958,24 @@ void FlowGraphCompiler::CompileGraph() { |
} else { |
CopyParameters(); |
} |
+ |
+ // TODO(vegorov): introduce stack maps and stop initializing all spill slots |
+ // with null. |
+ const int stack_slot_count = |
srdjan
2012/07/26 00:33:56
s/int/intptr_t/
Vyacheslav Egorov (Google)
2012/07/26 11:33:53
Done.
|
+ is_ssa_ ? block_order_[0]->AsGraphEntry()->spill_slot_count() |
+ : local_count; |
+ |
+ const int slot_base = |
srdjan
2012/07/26 00:33:56
ditto
Vyacheslav Egorov (Google)
2012/07/26 11:33:53
Done.
|
+ is_ssa_ ? -2 : parsed_function().first_stack_local_index(); |
srdjan
2012/07/26 00:33:56
Why is this needed? parsed_function().first_stack_
Vyacheslav Egorov (Google)
2012/07/26 11:33:53
Removed.
|
+ |
// Initialize (non-argument) stack allocated locals to null. |
- if (local_count > 0) { |
+ if (stack_slot_count > 0) { |
const Immediate raw_null = |
Immediate(reinterpret_cast<intptr_t>(Object::null())); |
__ movl(EAX, raw_null); |
- const int base = parsed_function().first_stack_local_index(); |
- for (int i = 0; i < local_count; ++i) { |
+ for (int i = 0; i < stack_slot_count; ++i) { |
// Subtract index i (locals lie at lower addresses than EBP). |
- __ movl(Address(EBP, (base - i) * kWordSize), EAX); |
+ __ movl(Address(EBP, (slot_base - i) * kWordSize), EAX); |
} |
} |
@@ -1110,11 +1119,17 @@ void FlowGraphCompiler::LoadDoubleOrSmiToXmm(XmmRegister result, |
#define __ compiler_->assembler()-> |
-static Address ToSpillAddress(Location loc) { |
- ASSERT(loc.IsSpillSlot()); |
- const intptr_t offset = |
- (ParsedFunction::kFirstLocalSlotIndex - loc.spill_index()) * kWordSize; |
- return Address(EBP, offset); |
+static Address ToStackSlotAddress(Location loc) { |
+ ASSERT(loc.IsStackSlot()); |
+ const intptr_t index = loc.stack_index(); |
+ if (index < 0) { |
+ const intptr_t offset = (1 - index) * kWordSize; |
+ return Address(EBP, offset); |
+ } else { |
+ const intptr_t offset = |
+ (ParsedFunction::kFirstLocalSlotIndex - index) * kWordSize; |
+ return Address(EBP, offset); |
+ } |
} |
@@ -1127,23 +1142,24 @@ void ParallelMoveResolver::EmitMove(int index) { |
if (destination.IsRegister()) { |
__ movl(destination.reg(), source.reg()); |
} else { |
- ASSERT(destination.IsSpillSlot()); |
- __ movl(ToSpillAddress(destination), source.reg()); |
+ ASSERT(destination.IsStackSlot()); |
+ __ movl(ToStackSlotAddress(destination), source.reg()); |
} |
- } else if (source.IsSpillSlot()) { |
+ } else if (source.IsStackSlot()) { |
if (destination.IsRegister()) { |
- __ movl(destination.reg(), ToSpillAddress(source)); |
+ __ movl(destination.reg(), ToStackSlotAddress(source)); |
} else { |
- ASSERT(destination.IsSpillSlot()); |
- MoveMemoryToMemory(ToSpillAddress(destination), ToSpillAddress(source)); |
+ ASSERT(destination.IsStackSlot()); |
+ MoveMemoryToMemory(ToStackSlotAddress(destination), |
+ ToStackSlotAddress(source)); |
} |
} else { |
ASSERT(source.IsConstant()); |
if (destination.IsRegister()) { |
__ LoadObject(destination.reg(), source.constant()); |
} else { |
- ASSERT(destination.IsSpillSlot()); |
- StoreObject(ToSpillAddress(destination), source.constant()); |
+ ASSERT(destination.IsStackSlot()); |
+ StoreObject(ToStackSlotAddress(destination), source.constant()); |
} |
} |
@@ -1158,12 +1174,12 @@ void ParallelMoveResolver::EmitSwap(int index) { |
if (source.IsRegister() && destination.IsRegister()) { |
__ xchgl(destination.reg(), source.reg()); |
- } else if (source.IsRegister() && destination.IsSpillSlot()) { |
- Exchange(source.reg(), ToSpillAddress(destination)); |
- } else if (source.IsSpillSlot() && destination.IsRegister()) { |
- Exchange(destination.reg(), ToSpillAddress(source)); |
- } else if (source.IsSpillSlot() && destination.IsSpillSlot()) { |
- Exchange(ToSpillAddress(destination), ToSpillAddress(source)); |
+ } else if (source.IsRegister() && destination.IsStackSlot()) { |
+ Exchange(source.reg(), ToStackSlotAddress(destination)); |
+ } else if (source.IsStackSlot() && destination.IsRegister()) { |
+ Exchange(destination.reg(), ToStackSlotAddress(source)); |
+ } else if (source.IsStackSlot() && destination.IsStackSlot()) { |
+ Exchange(ToStackSlotAddress(destination), ToStackSlotAddress(source)); |
} else { |
UNREACHABLE(); |
} |