Mercurial > hg > truffle
annotate src/share/vm/opto/regalloc.cpp @ 17387:0e120f2819ce
Merged
author | Christian Wirth <christian.wirth@oracle.com> |
---|---|
date | Thu, 09 Oct 2014 13:19:31 +0200 |
parents | 4ca6dc0799b6 |
children | 89152779163c |
rev | line source |
---|---|
0 | 1 /* |
14909 | 2 * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "opto/regalloc.hpp" | |
0 | 27 |
28 static const int NodeRegsOverflowSize = 200; | |
29 | |
30 void (*PhaseRegAlloc::_alloc_statistics[MAX_REG_ALLOCATORS])(); | |
31 int PhaseRegAlloc::_num_allocators = 0; | |
32 #ifndef PRODUCT | |
33 int PhaseRegAlloc::_total_framesize = 0; | |
34 int PhaseRegAlloc::_max_framesize = 0; | |
35 #endif | |
36 | |
37 PhaseRegAlloc::PhaseRegAlloc( uint unique, PhaseCFG &cfg, | |
38 Matcher &matcher, | |
39 void (*pr_stats)() ): | |
40 Phase(Register_Allocation), _cfg(cfg), _matcher(matcher), | |
41 _node_oops(Thread::current()->resource_area()), | |
42 _node_regs(0), | |
7636
a7114d3d712e
8005055: pass outputStream to more opto debug routines
kvn
parents:
1972
diff
changeset
|
43 _node_regs_max_index(0), |
0 | 44 _framesize(0xdeadbeef) |
45 { | |
46 int i; | |
47 | |
48 for (i=0; i < _num_allocators; i++) { | |
49 if (_alloc_statistics[i] == pr_stats) | |
50 return; | |
51 } | |
52 assert((_num_allocators + 1) < MAX_REG_ALLOCATORS, "too many register allocators"); | |
53 _alloc_statistics[_num_allocators++] = pr_stats; | |
54 } | |
55 | |
56 | |
57 //------------------------------reg2offset------------------------------------- | |
58 int PhaseRegAlloc::reg2offset_unchecked( OptoReg::Name reg ) const { | |
59 // Slots below _max_in_arg_stack_reg are offset by the entire frame. | |
60 // Slots above _max_in_arg_stack_reg are frame_slots and are not offset. | |
61 int slot = (reg < _matcher._new_SP) | |
62 ? reg - OptoReg::stack0() + _framesize | |
63 : reg - _matcher._new_SP; | |
64 // Note: We use the direct formula (reg - SharedInfo::stack0) instead of | |
65 // OptoReg::reg2stack(reg), in order to avoid asserts in the latter | |
66 // function. This routine must remain unchecked, so that dump_frame() | |
67 // can do its work undisturbed. | |
68 // %%% not really clear why reg2stack would assert here | |
69 | |
70 return slot*VMRegImpl::stack_slot_size; | |
71 } | |
72 | |
73 int PhaseRegAlloc::reg2offset( OptoReg::Name reg ) const { | |
74 | |
75 // Not allowed in the out-preserve area. | |
76 // In-preserve area is allowed so Intel can fetch the return pc out. | |
77 assert( reg < _matcher._old_SP || | |
78 (reg >= OptoReg::add(_matcher._old_SP,C->out_preserve_stack_slots()) && | |
79 reg < _matcher._in_arg_limit) || | |
14909 | 80 reg >= OptoReg::add(_matcher._new_SP,C->out_preserve_stack_slots()), |
0 | 81 "register allocated in a preserve area" ); |
82 return reg2offset_unchecked( reg ); | |
83 } | |
84 | |
85 //------------------------------offset2reg------------------------------------- | |
86 OptoReg::Name PhaseRegAlloc::offset2reg(int stk_offset) const { | |
87 int slot = stk_offset / jintSize; | |
88 int reg = (slot < (int) _framesize) | |
89 ? slot + _matcher._new_SP | |
90 : OptoReg::stack2reg(slot) - _framesize; | |
91 assert(stk_offset == reg2offset((OptoReg::Name) reg), | |
92 "offset2reg does not invert properly"); | |
93 return (OptoReg::Name) reg; | |
94 } | |
95 | |
96 //------------------------------set_oop---------------------------------------- | |
97 void PhaseRegAlloc::set_oop( const Node *n, bool is_an_oop ) { | |
98 if( is_an_oop ) { | |
99 _node_oops.set(n->_idx); | |
100 } | |
101 } | |
102 | |
103 //------------------------------is_oop----------------------------------------- | |
104 bool PhaseRegAlloc::is_oop( const Node *n ) const { | |
105 return _node_oops.test(n->_idx) != 0; | |
106 } | |
107 | |
108 // Allocate _node_regs table with at least "size" elements | |
109 void PhaseRegAlloc::alloc_node_regs(int size) { | |
110 _node_regs_max_index = size + (size >> 1) + NodeRegsOverflowSize; | |
111 _node_regs = NEW_RESOURCE_ARRAY( OptoRegPair, _node_regs_max_index ); | |
112 // We assume our caller will fill in all elements up to size-1, so | |
113 // only the extra space we allocate is initialized here. | |
114 for( uint i = size; i < _node_regs_max_index; ++i ) | |
115 _node_regs[i].set_bad(); | |
116 } | |
117 | |
118 #ifndef PRODUCT | |
119 void | |
120 PhaseRegAlloc::print_statistics() { | |
121 tty->print_cr("Total frameslots = %d, Max frameslots = %d", _total_framesize, _max_framesize); | |
122 int i; | |
123 | |
124 for (i=0; i < _num_allocators; i++) { | |
125 _alloc_statistics[i](); | |
126 } | |
127 } | |
128 #endif |