Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(913)

Side by Side Diff: runtime/vm/flow_graph_allocator.cc

Issue 10882055: Put live register bits in stackmaps. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Handle XMM registers in stackmaps. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/flow_graph_allocator.h" 5 #include "vm/flow_graph_allocator.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/intermediate_language.h" 8 #include "vm/intermediate_language.h"
9 #include "vm/il_printer.h" 9 #include "vm/il_printer.h"
10 #include "vm/flow_graph.h" 10 #include "vm/flow_graph.h"
(...skipping 17 matching lines...) Expand all
28 #else 28 #else
29 #define TRACE_ALLOC(statement) 29 #define TRACE_ALLOC(statement)
30 #endif 30 #endif
31 31
32 32
33 static const intptr_t kNoVirtualRegister = -1; 33 static const intptr_t kNoVirtualRegister = -1;
34 static const intptr_t kTempVirtualRegister = -2; 34 static const intptr_t kTempVirtualRegister = -2;
35 static const intptr_t kIllegalPosition = -1; 35 static const intptr_t kIllegalPosition = -1;
36 static const intptr_t kMaxPosition = 0x7FFFFFFF; 36 static const intptr_t kMaxPosition = 0x7FFFFFFF;
37 37
38 // Number of stack slots needed for a double spill slot.
39 static const intptr_t kDoubleSpillSlotFactor = kDoubleSize / kWordSize;
40
41
42 static intptr_t MinPosition(intptr_t a, intptr_t b) { 38 static intptr_t MinPosition(intptr_t a, intptr_t b) {
43 return (a < b) ? a : b; 39 return (a < b) ? a : b;
44 } 40 }
45 41
46 42
47 static bool IsInstructionStartPosition(intptr_t pos) { 43 static bool IsInstructionStartPosition(intptr_t pos) {
48 return (pos & 1) == 0; 44 return (pos & 1) == 0;
49 } 45 }
50 46
51 47
(...skipping 1711 matching lines...) Expand 10 before | Expand all | Expand 10 after
1763 1759
1764 TRACE_ALLOC(OS::Print("range [%d, %d) for v%d has been allocated to ", 1760 TRACE_ALLOC(OS::Print("range [%d, %d) for v%d has been allocated to ",
1765 range->Start(), range->End(), range->vreg())); 1761 range->Start(), range->End(), range->vreg()));
1766 TRACE_ALLOC(loc.Print()); 1762 TRACE_ALLOC(loc.Print());
1767 TRACE_ALLOC(OS::Print(":\n")); 1763 TRACE_ALLOC(OS::Print(":\n"));
1768 1764
1769 for (UsePosition* use = range->first_use(); use != NULL; use = use->next()) { 1765 for (UsePosition* use = range->first_use(); use != NULL; use = use->next()) {
1770 ConvertUseTo(use, loc); 1766 ConvertUseTo(use, loc);
1771 } 1767 }
1772 1768
1769 // Add live registers at all safepoints for instructions with slow-path
1770 // code.
1773 if (loc.IsMachineRegister()) { 1771 if (loc.IsMachineRegister()) {
1774 for (SafepointPosition* safepoint = range->first_safepoint(); 1772 for (SafepointPosition* safepoint = range->first_safepoint();
1775 safepoint != NULL; 1773 safepoint != NULL;
1776 safepoint = safepoint->next()) { 1774 safepoint = safepoint->next()) {
1777 safepoint->locs()->live_registers()->Add(loc); 1775 if (!safepoint->locs()->always_calls()) {
1776 ASSERT(safepoint->locs()->can_call());
1777 safepoint->locs()->live_registers()->Add(loc);
1778 }
1778 } 1779 }
1779 } 1780 }
1780 } 1781 }
1781 1782
1782 1783
1783 void FlowGraphAllocator::AdvanceActiveIntervals(const intptr_t start) { 1784 void FlowGraphAllocator::AdvanceActiveIntervals(const intptr_t start) {
1784 for (intptr_t reg = 0; reg < NumberOfRegisters(); reg++) { 1785 for (intptr_t reg = 0; reg < NumberOfRegisters(); reg++) {
1785 if (registers_[reg].is_empty()) continue; 1786 if (registers_[reg].is_empty()) continue;
1786 1787
1787 intptr_t first_evicted = -1; 1788 intptr_t first_evicted = -1;
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
2111 2112
2112 PrepareForAllocation(Location::kXmmRegister, 2113 PrepareForAllocation(Location::kXmmRegister,
2113 kNumberOfXmmRegisters, 2114 kNumberOfXmmRegisters,
2114 unallocated_xmm_, 2115 unallocated_xmm_,
2115 xmm_regs_, 2116 xmm_regs_,
2116 blocked_xmm_registers_); 2117 blocked_xmm_registers_);
2117 AllocateUnallocatedRanges(); 2118 AllocateUnallocatedRanges();
2118 2119
2119 ResolveControlFlow(); 2120 ResolveControlFlow();
2120 2121
2121 // Reserve spill slots for XMM registers alive across slow path code.
2122 // TODO(vegorov): remove this code when safepoints with registers are
2123 // implemented.
2124 intptr_t deferred_xmm_spills = 0;
2125 for (intptr_t i = 0; i < safepoints_.length(); i++) {
2126 if (!safepoints_[i]->locs()->always_calls()) {
2127 const intptr_t count =
2128 safepoints_[i]->locs()->live_registers()->xmm_regs_count();
2129 if (count > deferred_xmm_spills) deferred_xmm_spills = count;
2130 }
2131 }
2132
2133 GraphEntryInstr* entry = block_order_[0]->AsGraphEntry(); 2122 GraphEntryInstr* entry = block_order_[0]->AsGraphEntry();
2134 ASSERT(entry != NULL); 2123 ASSERT(entry != NULL);
2135 entry->set_spill_slot_count( 2124 intptr_t double_spill_slot_count =
2136 (deferred_xmm_spills + spill_slots_.length()) * kDoubleSpillSlotFactor + 2125 spill_slots_.length() * kDoubleSpillSlotFactor;
2137 cpu_spill_slot_count_); 2126 entry->set_spill_slot_count(cpu_spill_slot_count_ + double_spill_slot_count);
2138 2127
2139 if (FLAG_print_ssa_liveranges) { 2128 if (FLAG_print_ssa_liveranges) {
2140 const Function& function = flow_graph_.parsed_function().function(); 2129 const Function& function = flow_graph_.parsed_function().function();
2141 2130
2142 OS::Print("-- [after ssa allocator] ranges [%s] ---------\n", 2131 OS::Print("-- [after ssa allocator] ranges [%s] ---------\n",
2143 function.ToFullyQualifiedCString()); 2132 function.ToFullyQualifiedCString());
2144 PrintLiveRanges(); 2133 PrintLiveRanges();
2145 OS::Print("----------------------------------------------\n"); 2134 OS::Print("----------------------------------------------\n");
2146 2135
2147 OS::Print("-- [after ssa allocator] ir [%s] -------------\n", 2136 OS::Print("-- [after ssa allocator] ir [%s] -------------\n",
2148 function.ToFullyQualifiedCString()); 2137 function.ToFullyQualifiedCString());
2149 FlowGraphPrinter printer(flow_graph_, true); 2138 FlowGraphPrinter printer(flow_graph_, true);
2150 printer.PrintBlocks(); 2139 printer.PrintBlocks();
2151 OS::Print("----------------------------------------------\n"); 2140 OS::Print("----------------------------------------------\n");
2152 } 2141 }
2153 } 2142 }
2154 2143
2155 2144
2156 } // namespace dart 2145 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698