annotate src/share/vm/c1/c1_LIRGenerator.cpp @ 23614:32b682649973 jdk8u75-b04

8132051: Better byte behavior Reviewed-by: coleenp, roland
author kevinw
date Fri, 15 Jan 2016 22:33:15 +0000
parents 8fd636dd1c91
children b5f3a471e646 d109bda16490
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
23614
32b682649973 8132051: Better byte behavior
kevinw
parents: 23158
diff changeset
2 * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1378
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1378
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: 1378
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1873
diff changeset
25 #include "precompiled.hpp"
22851
ddce0b7cee93 8072383: resolve conflicts between open and closed ports
dlong
parents: 22837
diff changeset
26 #include "c1/c1_Defs.hpp"
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1873
diff changeset
27 #include "c1/c1_Compilation.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1873
diff changeset
28 #include "c1/c1_FrameMap.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1873
diff changeset
29 #include "c1/c1_Instruction.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1873
diff changeset
30 #include "c1/c1_LIRAssembler.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1873
diff changeset
31 #include "c1/c1_LIRGenerator.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1873
diff changeset
32 #include "c1/c1_ValueStack.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1873
diff changeset
33 #include "ci/ciArrayKlass.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1873
diff changeset
34 #include "ci/ciInstance.hpp"
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6616
diff changeset
35 #include "ci/ciObjArray.hpp"
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1873
diff changeset
36 #include "runtime/sharedRuntime.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1873
diff changeset
37 #include "runtime/stubRoutines.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1873
diff changeset
38 #include "utilities/bitMap.inline.hpp"
8001
db9981fd3124 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 7425
diff changeset
39 #include "utilities/macros.hpp"
db9981fd3124 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 7425
diff changeset
40 #if INCLUDE_ALL_GCS
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1873
diff changeset
41 #include "gc_implementation/g1/heapRegion.hpp"
8001
db9981fd3124 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 7425
diff changeset
42 #endif // INCLUDE_ALL_GCS
0
a61af66fc99e Initial load
duke
parents:
diff changeset
43
a61af66fc99e Initial load
duke
parents:
diff changeset
44 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
45 #define __ gen()->lir(__FILE__, __LINE__)->
a61af66fc99e Initial load
duke
parents:
diff changeset
46 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
47 #define __ gen()->lir()->
a61af66fc99e Initial load
duke
parents:
diff changeset
48 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
49
22851
ddce0b7cee93 8072383: resolve conflicts between open and closed ports
dlong
parents: 22837
diff changeset
50 #ifndef PATCHED_ADDR
1681
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1584
diff changeset
51 #define PATCHED_ADDR (max_jint)
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1584
diff changeset
52 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
53
a61af66fc99e Initial load
duke
parents:
diff changeset
54 void PhiResolverState::reset(int max_vregs) {
a61af66fc99e Initial load
duke
parents:
diff changeset
55 // Initialize array sizes
a61af66fc99e Initial load
duke
parents:
diff changeset
56 _virtual_operands.at_put_grow(max_vregs - 1, NULL, NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
57 _virtual_operands.trunc_to(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
58 _other_operands.at_put_grow(max_vregs - 1, NULL, NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
59 _other_operands.trunc_to(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
60 _vreg_table.at_put_grow(max_vregs - 1, NULL, NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
61 _vreg_table.trunc_to(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
62 }
a61af66fc99e Initial load
duke
parents:
diff changeset
63
a61af66fc99e Initial load
duke
parents:
diff changeset
64
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 //--------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
67 // PhiResolver
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 // Resolves cycles:
a61af66fc99e Initial load
duke
parents:
diff changeset
70 //
a61af66fc99e Initial load
duke
parents:
diff changeset
71 // r1 := r2 becomes temp := r1
a61af66fc99e Initial load
duke
parents:
diff changeset
72 // r2 := r1 r1 := r2
a61af66fc99e Initial load
duke
parents:
diff changeset
73 // r2 := temp
a61af66fc99e Initial load
duke
parents:
diff changeset
74 // and orders moves:
a61af66fc99e Initial load
duke
parents:
diff changeset
75 //
a61af66fc99e Initial load
duke
parents:
diff changeset
76 // r2 := r3 becomes r1 := r2
a61af66fc99e Initial load
duke
parents:
diff changeset
77 // r1 := r2 r2 := r3
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 PhiResolver::PhiResolver(LIRGenerator* gen, int max_vregs)
a61af66fc99e Initial load
duke
parents:
diff changeset
80 : _gen(gen)
a61af66fc99e Initial load
duke
parents:
diff changeset
81 , _state(gen->resolver_state())
a61af66fc99e Initial load
duke
parents:
diff changeset
82 , _temp(LIR_OprFact::illegalOpr)
a61af66fc99e Initial load
duke
parents:
diff changeset
83 {
a61af66fc99e Initial load
duke
parents:
diff changeset
84 // reinitialize the shared state arrays
a61af66fc99e Initial load
duke
parents:
diff changeset
85 _state.reset(max_vregs);
a61af66fc99e Initial load
duke
parents:
diff changeset
86 }
a61af66fc99e Initial load
duke
parents:
diff changeset
87
a61af66fc99e Initial load
duke
parents:
diff changeset
88
a61af66fc99e Initial load
duke
parents:
diff changeset
89 void PhiResolver::emit_move(LIR_Opr src, LIR_Opr dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
90 assert(src->is_valid(), "");
a61af66fc99e Initial load
duke
parents:
diff changeset
91 assert(dest->is_valid(), "");
a61af66fc99e Initial load
duke
parents:
diff changeset
92 __ move(src, dest);
a61af66fc99e Initial load
duke
parents:
diff changeset
93 }
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95
a61af66fc99e Initial load
duke
parents:
diff changeset
96 void PhiResolver::move_temp_to(LIR_Opr dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
97 assert(_temp->is_valid(), "");
a61af66fc99e Initial load
duke
parents:
diff changeset
98 emit_move(_temp, dest);
a61af66fc99e Initial load
duke
parents:
diff changeset
99 NOT_PRODUCT(_temp = LIR_OprFact::illegalOpr);
a61af66fc99e Initial load
duke
parents:
diff changeset
100 }
a61af66fc99e Initial load
duke
parents:
diff changeset
101
a61af66fc99e Initial load
duke
parents:
diff changeset
102
a61af66fc99e Initial load
duke
parents:
diff changeset
103 void PhiResolver::move_to_temp(LIR_Opr src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
104 assert(_temp->is_illegal(), "");
a61af66fc99e Initial load
duke
parents:
diff changeset
105 _temp = _gen->new_register(src->type());
a61af66fc99e Initial load
duke
parents:
diff changeset
106 emit_move(src, _temp);
a61af66fc99e Initial load
duke
parents:
diff changeset
107 }
a61af66fc99e Initial load
duke
parents:
diff changeset
108
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110 // Traverse assignment graph in depth first order and generate moves in post order
a61af66fc99e Initial load
duke
parents:
diff changeset
111 // ie. two assignments: b := c, a := b start with node c:
a61af66fc99e Initial load
duke
parents:
diff changeset
112 // Call graph: move(NULL, c) -> move(c, b) -> move(b, a)
a61af66fc99e Initial load
duke
parents:
diff changeset
113 // Generates moves in this order: move b to a and move c to b
a61af66fc99e Initial load
duke
parents:
diff changeset
114 // ie. cycle a := b, b := a start with node a
a61af66fc99e Initial load
duke
parents:
diff changeset
115 // Call graph: move(NULL, a) -> move(a, b) -> move(b, a)
a61af66fc99e Initial load
duke
parents:
diff changeset
116 // Generates moves in this order: move b to temp, move a to b, move temp to a
a61af66fc99e Initial load
duke
parents:
diff changeset
117 void PhiResolver::move(ResolveNode* src, ResolveNode* dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
118 if (!dest->visited()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
119 dest->set_visited();
a61af66fc99e Initial load
duke
parents:
diff changeset
120 for (int i = dest->no_of_destinations()-1; i >= 0; i --) {
a61af66fc99e Initial load
duke
parents:
diff changeset
121 move(dest, dest->destination_at(i));
a61af66fc99e Initial load
duke
parents:
diff changeset
122 }
a61af66fc99e Initial load
duke
parents:
diff changeset
123 } else if (!dest->start_node()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
124 // cylce in graph detected
a61af66fc99e Initial load
duke
parents:
diff changeset
125 assert(_loop == NULL, "only one loop valid!");
a61af66fc99e Initial load
duke
parents:
diff changeset
126 _loop = dest;
a61af66fc99e Initial load
duke
parents:
diff changeset
127 move_to_temp(src->operand());
a61af66fc99e Initial load
duke
parents:
diff changeset
128 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
129 } // else dest is a start node
a61af66fc99e Initial load
duke
parents:
diff changeset
130
a61af66fc99e Initial load
duke
parents:
diff changeset
131 if (!dest->assigned()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
132 if (_loop == dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
133 move_temp_to(dest->operand());
a61af66fc99e Initial load
duke
parents:
diff changeset
134 dest->set_assigned();
a61af66fc99e Initial load
duke
parents:
diff changeset
135 } else if (src != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
136 emit_move(src->operand(), dest->operand());
a61af66fc99e Initial load
duke
parents:
diff changeset
137 dest->set_assigned();
a61af66fc99e Initial load
duke
parents:
diff changeset
138 }
a61af66fc99e Initial load
duke
parents:
diff changeset
139 }
a61af66fc99e Initial load
duke
parents:
diff changeset
140 }
a61af66fc99e Initial load
duke
parents:
diff changeset
141
a61af66fc99e Initial load
duke
parents:
diff changeset
142
a61af66fc99e Initial load
duke
parents:
diff changeset
143 PhiResolver::~PhiResolver() {
a61af66fc99e Initial load
duke
parents:
diff changeset
144 int i;
a61af66fc99e Initial load
duke
parents:
diff changeset
145 // resolve any cycles in moves from and to virtual registers
a61af66fc99e Initial load
duke
parents:
diff changeset
146 for (i = virtual_operands().length() - 1; i >= 0; i --) {
a61af66fc99e Initial load
duke
parents:
diff changeset
147 ResolveNode* node = virtual_operands()[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
148 if (!node->visited()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
149 _loop = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
150 move(NULL, node);
a61af66fc99e Initial load
duke
parents:
diff changeset
151 node->set_start_node();
a61af66fc99e Initial load
duke
parents:
diff changeset
152 assert(_temp->is_illegal(), "move_temp_to() call missing");
a61af66fc99e Initial load
duke
parents:
diff changeset
153 }
a61af66fc99e Initial load
duke
parents:
diff changeset
154 }
a61af66fc99e Initial load
duke
parents:
diff changeset
155
a61af66fc99e Initial load
duke
parents:
diff changeset
156 // generate move for move from non virtual register to abitrary destination
a61af66fc99e Initial load
duke
parents:
diff changeset
157 for (i = other_operands().length() - 1; i >= 0; i --) {
a61af66fc99e Initial load
duke
parents:
diff changeset
158 ResolveNode* node = other_operands()[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
159 for (int j = node->no_of_destinations() - 1; j >= 0; j --) {
a61af66fc99e Initial load
duke
parents:
diff changeset
160 emit_move(node->operand(), node->destination_at(j)->operand());
a61af66fc99e Initial load
duke
parents:
diff changeset
161 }
a61af66fc99e Initial load
duke
parents:
diff changeset
162 }
a61af66fc99e Initial load
duke
parents:
diff changeset
163 }
a61af66fc99e Initial load
duke
parents:
diff changeset
164
a61af66fc99e Initial load
duke
parents:
diff changeset
165
a61af66fc99e Initial load
duke
parents:
diff changeset
166 ResolveNode* PhiResolver::create_node(LIR_Opr opr, bool source) {
a61af66fc99e Initial load
duke
parents:
diff changeset
167 ResolveNode* node;
a61af66fc99e Initial load
duke
parents:
diff changeset
168 if (opr->is_virtual()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
169 int vreg_num = opr->vreg_number();
a61af66fc99e Initial load
duke
parents:
diff changeset
170 node = vreg_table().at_grow(vreg_num, NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
171 assert(node == NULL || node->operand() == opr, "");
a61af66fc99e Initial load
duke
parents:
diff changeset
172 if (node == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
173 node = new ResolveNode(opr);
a61af66fc99e Initial load
duke
parents:
diff changeset
174 vreg_table()[vreg_num] = node;
a61af66fc99e Initial load
duke
parents:
diff changeset
175 }
a61af66fc99e Initial load
duke
parents:
diff changeset
176 // Make sure that all virtual operands show up in the list when
a61af66fc99e Initial load
duke
parents:
diff changeset
177 // they are used as the source of a move.
a61af66fc99e Initial load
duke
parents:
diff changeset
178 if (source && !virtual_operands().contains(node)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
179 virtual_operands().append(node);
a61af66fc99e Initial load
duke
parents:
diff changeset
180 }
a61af66fc99e Initial load
duke
parents:
diff changeset
181 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
182 assert(source, "");
a61af66fc99e Initial load
duke
parents:
diff changeset
183 node = new ResolveNode(opr);
a61af66fc99e Initial load
duke
parents:
diff changeset
184 other_operands().append(node);
a61af66fc99e Initial load
duke
parents:
diff changeset
185 }
a61af66fc99e Initial load
duke
parents:
diff changeset
186 return node;
a61af66fc99e Initial load
duke
parents:
diff changeset
187 }
a61af66fc99e Initial load
duke
parents:
diff changeset
188
a61af66fc99e Initial load
duke
parents:
diff changeset
189
a61af66fc99e Initial load
duke
parents:
diff changeset
190 void PhiResolver::move(LIR_Opr src, LIR_Opr dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
191 assert(dest->is_virtual(), "");
a61af66fc99e Initial load
duke
parents:
diff changeset
192 // tty->print("move "); src->print(); tty->print(" to "); dest->print(); tty->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
193 assert(src->is_valid(), "");
a61af66fc99e Initial load
duke
parents:
diff changeset
194 assert(dest->is_valid(), "");
a61af66fc99e Initial load
duke
parents:
diff changeset
195 ResolveNode* source = source_node(src);
a61af66fc99e Initial load
duke
parents:
diff changeset
196 source->append(destination_node(dest));
a61af66fc99e Initial load
duke
parents:
diff changeset
197 }
a61af66fc99e Initial load
duke
parents:
diff changeset
198
a61af66fc99e Initial load
duke
parents:
diff changeset
199
a61af66fc99e Initial load
duke
parents:
diff changeset
200 //--------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
201 // LIRItem
a61af66fc99e Initial load
duke
parents:
diff changeset
202
a61af66fc99e Initial load
duke
parents:
diff changeset
203 void LIRItem::set_result(LIR_Opr opr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
204 assert(value()->operand()->is_illegal() || value()->operand()->is_constant(), "operand should never change");
a61af66fc99e Initial load
duke
parents:
diff changeset
205 value()->set_operand(opr);
a61af66fc99e Initial load
duke
parents:
diff changeset
206
a61af66fc99e Initial load
duke
parents:
diff changeset
207 if (opr->is_virtual()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
208 _gen->_instruction_for_operand.at_put_grow(opr->vreg_number(), value(), NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
209 }
a61af66fc99e Initial load
duke
parents:
diff changeset
210
a61af66fc99e Initial load
duke
parents:
diff changeset
211 _result = opr;
a61af66fc99e Initial load
duke
parents:
diff changeset
212 }
a61af66fc99e Initial load
duke
parents:
diff changeset
213
a61af66fc99e Initial load
duke
parents:
diff changeset
214 void LIRItem::load_item() {
a61af66fc99e Initial load
duke
parents:
diff changeset
215 if (result()->is_illegal()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
216 // update the items result
a61af66fc99e Initial load
duke
parents:
diff changeset
217 _result = value()->operand();
a61af66fc99e Initial load
duke
parents:
diff changeset
218 }
a61af66fc99e Initial load
duke
parents:
diff changeset
219 if (!result()->is_register()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
220 LIR_Opr reg = _gen->new_register(value()->type());
a61af66fc99e Initial load
duke
parents:
diff changeset
221 __ move(result(), reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
222 if (result()->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
223 _result = reg;
a61af66fc99e Initial load
duke
parents:
diff changeset
224 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
225 set_result(reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
226 }
a61af66fc99e Initial load
duke
parents:
diff changeset
227 }
a61af66fc99e Initial load
duke
parents:
diff changeset
228 }
a61af66fc99e Initial load
duke
parents:
diff changeset
229
a61af66fc99e Initial load
duke
parents:
diff changeset
230
a61af66fc99e Initial load
duke
parents:
diff changeset
231 void LIRItem::load_for_store(BasicType type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
232 if (_gen->can_store_as_constant(value(), type)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
233 _result = value()->operand();
a61af66fc99e Initial load
duke
parents:
diff changeset
234 if (!_result->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
235 _result = LIR_OprFact::value_type(value()->type());
a61af66fc99e Initial load
duke
parents:
diff changeset
236 }
a61af66fc99e Initial load
duke
parents:
diff changeset
237 } else if (type == T_BYTE || type == T_BOOLEAN) {
a61af66fc99e Initial load
duke
parents:
diff changeset
238 load_byte_item();
a61af66fc99e Initial load
duke
parents:
diff changeset
239 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
240 load_item();
a61af66fc99e Initial load
duke
parents:
diff changeset
241 }
a61af66fc99e Initial load
duke
parents:
diff changeset
242 }
a61af66fc99e Initial load
duke
parents:
diff changeset
243
a61af66fc99e Initial load
duke
parents:
diff changeset
244 void LIRItem::load_item_force(LIR_Opr reg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
245 LIR_Opr r = result();
a61af66fc99e Initial load
duke
parents:
diff changeset
246 if (r != reg) {
1681
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1584
diff changeset
247 #if !defined(ARM) && !defined(E500V2)
0
a61af66fc99e Initial load
duke
parents:
diff changeset
248 if (r->type() != reg->type()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
249 // moves between different types need an intervening spill slot
1681
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1584
diff changeset
250 r = _gen->force_to_spill(r, reg->type());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
251 }
1681
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1584
diff changeset
252 #endif
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1584
diff changeset
253 __ move(r, reg);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
254 _result = reg;
a61af66fc99e Initial load
duke
parents:
diff changeset
255 }
a61af66fc99e Initial load
duke
parents:
diff changeset
256 }
a61af66fc99e Initial load
duke
parents:
diff changeset
257
a61af66fc99e Initial load
duke
parents:
diff changeset
258 ciObject* LIRItem::get_jobject_constant() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
259 ObjectType* oc = type()->as_ObjectType();
a61af66fc99e Initial load
duke
parents:
diff changeset
260 if (oc) {
a61af66fc99e Initial load
duke
parents:
diff changeset
261 return oc->constant_value();
a61af66fc99e Initial load
duke
parents:
diff changeset
262 }
a61af66fc99e Initial load
duke
parents:
diff changeset
263 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
264 }
a61af66fc99e Initial load
duke
parents:
diff changeset
265
a61af66fc99e Initial load
duke
parents:
diff changeset
266
a61af66fc99e Initial load
duke
parents:
diff changeset
267 jint LIRItem::get_jint_constant() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
268 assert(is_constant() && value() != NULL, "");
a61af66fc99e Initial load
duke
parents:
diff changeset
269 assert(type()->as_IntConstant() != NULL, "type check");
a61af66fc99e Initial load
duke
parents:
diff changeset
270 return type()->as_IntConstant()->value();
a61af66fc99e Initial load
duke
parents:
diff changeset
271 }
a61af66fc99e Initial load
duke
parents:
diff changeset
272
a61af66fc99e Initial load
duke
parents:
diff changeset
273
a61af66fc99e Initial load
duke
parents:
diff changeset
274 jint LIRItem::get_address_constant() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
275 assert(is_constant() && value() != NULL, "");
a61af66fc99e Initial load
duke
parents:
diff changeset
276 assert(type()->as_AddressConstant() != NULL, "type check");
a61af66fc99e Initial load
duke
parents:
diff changeset
277 return type()->as_AddressConstant()->value();
a61af66fc99e Initial load
duke
parents:
diff changeset
278 }
a61af66fc99e Initial load
duke
parents:
diff changeset
279
a61af66fc99e Initial load
duke
parents:
diff changeset
280
a61af66fc99e Initial load
duke
parents:
diff changeset
281 jfloat LIRItem::get_jfloat_constant() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
282 assert(is_constant() && value() != NULL, "");
a61af66fc99e Initial load
duke
parents:
diff changeset
283 assert(type()->as_FloatConstant() != NULL, "type check");
a61af66fc99e Initial load
duke
parents:
diff changeset
284 return type()->as_FloatConstant()->value();
a61af66fc99e Initial load
duke
parents:
diff changeset
285 }
a61af66fc99e Initial load
duke
parents:
diff changeset
286
a61af66fc99e Initial load
duke
parents:
diff changeset
287
a61af66fc99e Initial load
duke
parents:
diff changeset
288 jdouble LIRItem::get_jdouble_constant() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
289 assert(is_constant() && value() != NULL, "");
a61af66fc99e Initial load
duke
parents:
diff changeset
290 assert(type()->as_DoubleConstant() != NULL, "type check");
a61af66fc99e Initial load
duke
parents:
diff changeset
291 return type()->as_DoubleConstant()->value();
a61af66fc99e Initial load
duke
parents:
diff changeset
292 }
a61af66fc99e Initial load
duke
parents:
diff changeset
293
a61af66fc99e Initial load
duke
parents:
diff changeset
294
a61af66fc99e Initial load
duke
parents:
diff changeset
295 jlong LIRItem::get_jlong_constant() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
296 assert(is_constant() && value() != NULL, "");
a61af66fc99e Initial load
duke
parents:
diff changeset
297 assert(type()->as_LongConstant() != NULL, "type check");
a61af66fc99e Initial load
duke
parents:
diff changeset
298 return type()->as_LongConstant()->value();
a61af66fc99e Initial load
duke
parents:
diff changeset
299 }
a61af66fc99e Initial load
duke
parents:
diff changeset
300
a61af66fc99e Initial load
duke
parents:
diff changeset
301
a61af66fc99e Initial load
duke
parents:
diff changeset
302
a61af66fc99e Initial load
duke
parents:
diff changeset
303 //--------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
304
a61af66fc99e Initial load
duke
parents:
diff changeset
305
a61af66fc99e Initial load
duke
parents:
diff changeset
306 void LIRGenerator::init() {
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
307 _bs = Universe::heap()->barrier_set();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
308 }
a61af66fc99e Initial load
duke
parents:
diff changeset
309
a61af66fc99e Initial load
duke
parents:
diff changeset
310
a61af66fc99e Initial load
duke
parents:
diff changeset
311 void LIRGenerator::block_do_prolog(BlockBegin* block) {
a61af66fc99e Initial load
duke
parents:
diff changeset
312 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
313 if (PrintIRWithLIR) {
a61af66fc99e Initial load
duke
parents:
diff changeset
314 block->print();
a61af66fc99e Initial load
duke
parents:
diff changeset
315 }
a61af66fc99e Initial load
duke
parents:
diff changeset
316 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
317
a61af66fc99e Initial load
duke
parents:
diff changeset
318 // set up the list of LIR instructions
a61af66fc99e Initial load
duke
parents:
diff changeset
319 assert(block->lir() == NULL, "LIR list already computed for this block");
a61af66fc99e Initial load
duke
parents:
diff changeset
320 _lir = new LIR_List(compilation(), block);
a61af66fc99e Initial load
duke
parents:
diff changeset
321 block->set_lir(_lir);
a61af66fc99e Initial load
duke
parents:
diff changeset
322
a61af66fc99e Initial load
duke
parents:
diff changeset
323 __ branch_destination(block->label());
a61af66fc99e Initial load
duke
parents:
diff changeset
324
a61af66fc99e Initial load
duke
parents:
diff changeset
325 if (LIRTraceExecution &&
1584
b812ff5abc73 6958292: C1: Enable parallel compilation
iveresov
parents: 1579
diff changeset
326 Compilation::current()->hir()->start()->block_id() != block->block_id() &&
0
a61af66fc99e Initial load
duke
parents:
diff changeset
327 !block->is_set(BlockBegin::exception_entry_flag)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
328 assert(block->lir()->instructions_list()->length() == 1, "should come right after br_dst");
a61af66fc99e Initial load
duke
parents:
diff changeset
329 trace_block_entry(block);
a61af66fc99e Initial load
duke
parents:
diff changeset
330 }
a61af66fc99e Initial load
duke
parents:
diff changeset
331 }
a61af66fc99e Initial load
duke
parents:
diff changeset
332
a61af66fc99e Initial load
duke
parents:
diff changeset
333
a61af66fc99e Initial load
duke
parents:
diff changeset
334 void LIRGenerator::block_do_epilog(BlockBegin* block) {
a61af66fc99e Initial load
duke
parents:
diff changeset
335 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
336 if (PrintIRWithLIR) {
a61af66fc99e Initial load
duke
parents:
diff changeset
337 tty->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
338 }
a61af66fc99e Initial load
duke
parents:
diff changeset
339 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
340
a61af66fc99e Initial load
duke
parents:
diff changeset
341 // LIR_Opr for unpinned constants shouldn't be referenced by other
a61af66fc99e Initial load
duke
parents:
diff changeset
342 // blocks so clear them out after processing the block.
a61af66fc99e Initial load
duke
parents:
diff changeset
343 for (int i = 0; i < _unpinned_constants.length(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
344 _unpinned_constants.at(i)->clear_operand();
a61af66fc99e Initial load
duke
parents:
diff changeset
345 }
a61af66fc99e Initial load
duke
parents:
diff changeset
346 _unpinned_constants.trunc_to(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
347
a61af66fc99e Initial load
duke
parents:
diff changeset
348 // clear our any registers for other local constants
a61af66fc99e Initial load
duke
parents:
diff changeset
349 _constants.trunc_to(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
350 _reg_for_constants.trunc_to(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
351 }
a61af66fc99e Initial load
duke
parents:
diff changeset
352
a61af66fc99e Initial load
duke
parents:
diff changeset
353
a61af66fc99e Initial load
duke
parents:
diff changeset
354 void LIRGenerator::block_do(BlockBegin* block) {
a61af66fc99e Initial load
duke
parents:
diff changeset
355 CHECK_BAILOUT();
a61af66fc99e Initial load
duke
parents:
diff changeset
356
a61af66fc99e Initial load
duke
parents:
diff changeset
357 block_do_prolog(block);
a61af66fc99e Initial load
duke
parents:
diff changeset
358 set_block(block);
a61af66fc99e Initial load
duke
parents:
diff changeset
359
a61af66fc99e Initial load
duke
parents:
diff changeset
360 for (Instruction* instr = block; instr != NULL; instr = instr->next()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
361 if (instr->is_pinned()) do_root(instr);
a61af66fc99e Initial load
duke
parents:
diff changeset
362 }
a61af66fc99e Initial load
duke
parents:
diff changeset
363
a61af66fc99e Initial load
duke
parents:
diff changeset
364 set_block(NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
365 block_do_epilog(block);
a61af66fc99e Initial load
duke
parents:
diff changeset
366 }
a61af66fc99e Initial load
duke
parents:
diff changeset
367
a61af66fc99e Initial load
duke
parents:
diff changeset
368
a61af66fc99e Initial load
duke
parents:
diff changeset
369 //-------------------------LIRGenerator-----------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
370
a61af66fc99e Initial load
duke
parents:
diff changeset
371 // This is where the tree-walk starts; instr must be root;
a61af66fc99e Initial load
duke
parents:
diff changeset
372 void LIRGenerator::do_root(Value instr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
373 CHECK_BAILOUT();
a61af66fc99e Initial load
duke
parents:
diff changeset
374
a61af66fc99e Initial load
duke
parents:
diff changeset
375 InstructionMark im(compilation(), instr);
a61af66fc99e Initial load
duke
parents:
diff changeset
376
a61af66fc99e Initial load
duke
parents:
diff changeset
377 assert(instr->is_pinned(), "use only with roots");
a61af66fc99e Initial load
duke
parents:
diff changeset
378 assert(instr->subst() == instr, "shouldn't have missed substitution");
a61af66fc99e Initial load
duke
parents:
diff changeset
379
a61af66fc99e Initial load
duke
parents:
diff changeset
380 instr->visit(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
381
a61af66fc99e Initial load
duke
parents:
diff changeset
382 assert(!instr->has_uses() || instr->operand()->is_valid() ||
a61af66fc99e Initial load
duke
parents:
diff changeset
383 instr->as_Constant() != NULL || bailed_out(), "invalid item set");
a61af66fc99e Initial load
duke
parents:
diff changeset
384 }
a61af66fc99e Initial load
duke
parents:
diff changeset
385
a61af66fc99e Initial load
duke
parents:
diff changeset
386
a61af66fc99e Initial load
duke
parents:
diff changeset
387 // This is called for each node in tree; the walk stops if a root is reached
a61af66fc99e Initial load
duke
parents:
diff changeset
388 void LIRGenerator::walk(Value instr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
389 InstructionMark im(compilation(), instr);
a61af66fc99e Initial load
duke
parents:
diff changeset
390 //stop walk when encounter a root
a61af66fc99e Initial load
duke
parents:
diff changeset
391 if (instr->is_pinned() && instr->as_Phi() == NULL || instr->operand()->is_valid()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
392 assert(instr->operand() != LIR_OprFact::illegalOpr || instr->as_Constant() != NULL, "this root has not yet been visited");
a61af66fc99e Initial load
duke
parents:
diff changeset
393 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
394 assert(instr->subst() == instr, "shouldn't have missed substitution");
a61af66fc99e Initial load
duke
parents:
diff changeset
395 instr->visit(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
396 // assert(instr->use_count() > 0 || instr->as_Phi() != NULL, "leaf instruction must have a use");
a61af66fc99e Initial load
duke
parents:
diff changeset
397 }
a61af66fc99e Initial load
duke
parents:
diff changeset
398 }
a61af66fc99e Initial load
duke
parents:
diff changeset
399
a61af66fc99e Initial load
duke
parents:
diff changeset
400
a61af66fc99e Initial load
duke
parents:
diff changeset
401 CodeEmitInfo* LIRGenerator::state_for(Instruction* x, ValueStack* state, bool ignore_xhandler) {
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1816
diff changeset
402 assert(state != NULL, "state must be defined");
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1816
diff changeset
403
8860
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
404 #ifndef PRODUCT
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
405 state->verify();
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
406 #endif
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
407
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1816
diff changeset
408 ValueStack* s = state;
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1816
diff changeset
409 for_each_state(s) {
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1816
diff changeset
410 if (s->kind() == ValueStack::EmptyExceptionState) {
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1816
diff changeset
411 assert(s->stack_size() == 0 && s->locals_size() == 0 && (s->locks_size() == 0 || s->locks_size() == 1), "state must be empty");
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1816
diff changeset
412 continue;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
413 }
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1816
diff changeset
414
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1816
diff changeset
415 int index;
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1816
diff changeset
416 Value value;
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1816
diff changeset
417 for_each_stack_value(s, index, value) {
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1816
diff changeset
418 assert(value->subst() == value, "missed substitution");
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1816
diff changeset
419 if (!value->is_pinned() && value->as_Constant() == NULL && value->as_Local() == NULL) {
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1816
diff changeset
420 walk(value);
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1816
diff changeset
421 assert(value->operand()->is_valid(), "must be evaluated now");
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1816
diff changeset
422 }
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1816
diff changeset
423 }
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1816
diff changeset
424
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1816
diff changeset
425 int bci = s->bci();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
426 IRScope* scope = s->scope();
a61af66fc99e Initial load
duke
parents:
diff changeset
427 ciMethod* method = scope->method();
a61af66fc99e Initial load
duke
parents:
diff changeset
428
a61af66fc99e Initial load
duke
parents:
diff changeset
429 MethodLivenessResult liveness = method->liveness_at_bci(bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
430 if (bci == SynchronizationEntryBCI) {
a61af66fc99e Initial load
duke
parents:
diff changeset
431 if (x->as_ExceptionObject() || x->as_Throw()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
432 // all locals are dead on exit from the synthetic unlocker
a61af66fc99e Initial load
duke
parents:
diff changeset
433 liveness.clear();
a61af66fc99e Initial load
duke
parents:
diff changeset
434 } else {
4116
973293defacd 7112085: assert(fr.interpreter_frame_expression_stack_size()==0) failed: only handle empty stacks
iveresov
parents: 3997
diff changeset
435 assert(x->as_MonitorEnter() || x->as_ProfileInvoke(), "only other cases are MonitorEnter and ProfileInvoke");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
436 }
a61af66fc99e Initial load
duke
parents:
diff changeset
437 }
a61af66fc99e Initial load
duke
parents:
diff changeset
438 if (!liveness.is_valid()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
439 // Degenerate or breakpointed method.
a61af66fc99e Initial load
duke
parents:
diff changeset
440 bailout("Degenerate or breakpointed method");
a61af66fc99e Initial load
duke
parents:
diff changeset
441 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
442 assert((int)liveness.size() == s->locals_size(), "error in use of liveness");
a61af66fc99e Initial load
duke
parents:
diff changeset
443 for_each_local_value(s, index, value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
444 assert(value->subst() == value, "missed substition");
a61af66fc99e Initial load
duke
parents:
diff changeset
445 if (liveness.at(index) && !value->type()->is_illegal()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
446 if (!value->is_pinned() && value->as_Constant() == NULL && value->as_Local() == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
447 walk(value);
a61af66fc99e Initial load
duke
parents:
diff changeset
448 assert(value->operand()->is_valid(), "must be evaluated now");
a61af66fc99e Initial load
duke
parents:
diff changeset
449 }
a61af66fc99e Initial load
duke
parents:
diff changeset
450 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
451 // NULL out this local so that linear scan can assume that all non-NULL values are live.
a61af66fc99e Initial load
duke
parents:
diff changeset
452 s->invalidate_local(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
453 }
a61af66fc99e Initial load
duke
parents:
diff changeset
454 }
a61af66fc99e Initial load
duke
parents:
diff changeset
455 }
a61af66fc99e Initial load
duke
parents:
diff changeset
456 }
a61af66fc99e Initial load
duke
parents:
diff changeset
457
8860
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
458 return new CodeEmitInfo(state, ignore_xhandler ? NULL : x->exception_handlers(), x->check_flag(Instruction::DeoptimizeOnException));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
459 }
a61af66fc99e Initial load
duke
parents:
diff changeset
460
a61af66fc99e Initial load
duke
parents:
diff changeset
461
a61af66fc99e Initial load
duke
parents:
diff changeset
462 CodeEmitInfo* LIRGenerator::state_for(Instruction* x) {
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1816
diff changeset
463 return state_for(x, x->exception_state());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
464 }
a61af66fc99e Initial load
duke
parents:
diff changeset
465
a61af66fc99e Initial load
duke
parents:
diff changeset
466
20344
2fd0fd493045 8031994: java/lang/Character/CheckProp test times out
rbackman
parents: 17925
diff changeset
467 void LIRGenerator::klass2reg_with_patching(LIR_Opr r, ciMetadata* obj, CodeEmitInfo* info, bool need_resolve) {
2fd0fd493045 8031994: java/lang/Character/CheckProp test times out
rbackman
parents: 17925
diff changeset
468 /* C2 relies on constant pool entries being resolved (ciTypeFlow), so if TieredCompilation
2fd0fd493045 8031994: java/lang/Character/CheckProp test times out
rbackman
parents: 17925
diff changeset
469 * is active and the class hasn't yet been resolved we need to emit a patch that resolves
2fd0fd493045 8031994: java/lang/Character/CheckProp test times out
rbackman
parents: 17925
diff changeset
470 * the class. */
2fd0fd493045 8031994: java/lang/Character/CheckProp test times out
rbackman
parents: 17925
diff changeset
471 if ((TieredCompilation && need_resolve) || !obj->is_loaded() || PatchALot) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
472 assert(info != NULL, "info must be set if class is not loaded");
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6616
diff changeset
473 __ klass2reg_patch(NULL, r, info);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
474 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
475 // no patching needed
6739
8a02ca5e5576 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 6731
diff changeset
476 __ metadata2reg(obj->constant_encoding(), r);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
477 }
a61af66fc99e Initial load
duke
parents:
diff changeset
478 }
a61af66fc99e Initial load
duke
parents:
diff changeset
479
a61af66fc99e Initial load
duke
parents:
diff changeset
480
a61af66fc99e Initial load
duke
parents:
diff changeset
481 void LIRGenerator::array_range_check(LIR_Opr array, LIR_Opr index,
a61af66fc99e Initial load
duke
parents:
diff changeset
482 CodeEmitInfo* null_check_info, CodeEmitInfo* range_check_info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
483 CodeStub* stub = new RangeCheckStub(range_check_info, index);
a61af66fc99e Initial load
duke
parents:
diff changeset
484 if (index->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
485 cmp_mem_int(lir_cond_belowEqual, array, arrayOopDesc::length_offset_in_bytes(),
a61af66fc99e Initial load
duke
parents:
diff changeset
486 index->as_jint(), null_check_info);
a61af66fc99e Initial load
duke
parents:
diff changeset
487 __ branch(lir_cond_belowEqual, T_INT, stub); // forward branch
a61af66fc99e Initial load
duke
parents:
diff changeset
488 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
489 cmp_reg_mem(lir_cond_aboveEqual, index, array,
a61af66fc99e Initial load
duke
parents:
diff changeset
490 arrayOopDesc::length_offset_in_bytes(), T_INT, null_check_info);
a61af66fc99e Initial load
duke
parents:
diff changeset
491 __ branch(lir_cond_aboveEqual, T_INT, stub); // forward branch
a61af66fc99e Initial load
duke
parents:
diff changeset
492 }
a61af66fc99e Initial load
duke
parents:
diff changeset
493 }
a61af66fc99e Initial load
duke
parents:
diff changeset
494
a61af66fc99e Initial load
duke
parents:
diff changeset
495
a61af66fc99e Initial load
duke
parents:
diff changeset
496 void LIRGenerator::nio_range_check(LIR_Opr buffer, LIR_Opr index, LIR_Opr result, CodeEmitInfo* info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
497 CodeStub* stub = new RangeCheckStub(info, index, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
498 if (index->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
499 cmp_mem_int(lir_cond_belowEqual, buffer, java_nio_Buffer::limit_offset(), index->as_jint(), info);
a61af66fc99e Initial load
duke
parents:
diff changeset
500 __ branch(lir_cond_belowEqual, T_INT, stub); // forward branch
a61af66fc99e Initial load
duke
parents:
diff changeset
501 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
502 cmp_reg_mem(lir_cond_aboveEqual, index, buffer,
a61af66fc99e Initial load
duke
parents:
diff changeset
503 java_nio_Buffer::limit_offset(), T_INT, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
504 __ branch(lir_cond_aboveEqual, T_INT, stub); // forward branch
a61af66fc99e Initial load
duke
parents:
diff changeset
505 }
a61af66fc99e Initial load
duke
parents:
diff changeset
506 __ move(index, result);
a61af66fc99e Initial load
duke
parents:
diff changeset
507 }
a61af66fc99e Initial load
duke
parents:
diff changeset
508
a61af66fc99e Initial load
duke
parents:
diff changeset
509
a61af66fc99e Initial load
duke
parents:
diff changeset
510
a61af66fc99e Initial load
duke
parents:
diff changeset
511 void LIRGenerator::arithmetic_op(Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, bool is_strictfp, LIR_Opr tmp_op, CodeEmitInfo* info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
512 LIR_Opr result_op = result;
a61af66fc99e Initial load
duke
parents:
diff changeset
513 LIR_Opr left_op = left;
a61af66fc99e Initial load
duke
parents:
diff changeset
514 LIR_Opr right_op = right;
a61af66fc99e Initial load
duke
parents:
diff changeset
515
a61af66fc99e Initial load
duke
parents:
diff changeset
516 if (TwoOperandLIRForm && left_op != result_op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
517 assert(right_op != result_op, "malformed");
a61af66fc99e Initial load
duke
parents:
diff changeset
518 __ move(left_op, result_op);
a61af66fc99e Initial load
duke
parents:
diff changeset
519 left_op = result_op;
a61af66fc99e Initial load
duke
parents:
diff changeset
520 }
a61af66fc99e Initial load
duke
parents:
diff changeset
521
a61af66fc99e Initial load
duke
parents:
diff changeset
522 switch(code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
523 case Bytecodes::_dadd:
a61af66fc99e Initial load
duke
parents:
diff changeset
524 case Bytecodes::_fadd:
a61af66fc99e Initial load
duke
parents:
diff changeset
525 case Bytecodes::_ladd:
a61af66fc99e Initial load
duke
parents:
diff changeset
526 case Bytecodes::_iadd: __ add(left_op, right_op, result_op); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
527 case Bytecodes::_fmul:
a61af66fc99e Initial load
duke
parents:
diff changeset
528 case Bytecodes::_lmul: __ mul(left_op, right_op, result_op); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
529
a61af66fc99e Initial load
duke
parents:
diff changeset
530 case Bytecodes::_dmul:
a61af66fc99e Initial load
duke
parents:
diff changeset
531 {
a61af66fc99e Initial load
duke
parents:
diff changeset
532 if (is_strictfp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
533 __ mul_strictfp(left_op, right_op, result_op, tmp_op); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
534 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
535 __ mul(left_op, right_op, result_op); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
536 }
a61af66fc99e Initial load
duke
parents:
diff changeset
537 }
a61af66fc99e Initial load
duke
parents:
diff changeset
538 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
539
a61af66fc99e Initial load
duke
parents:
diff changeset
540 case Bytecodes::_imul:
a61af66fc99e Initial load
duke
parents:
diff changeset
541 {
a61af66fc99e Initial load
duke
parents:
diff changeset
542 bool did_strength_reduce = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
543
a61af66fc99e Initial load
duke
parents:
diff changeset
544 if (right->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
545 int c = right->as_jint();
a61af66fc99e Initial load
duke
parents:
diff changeset
546 if (is_power_of_2(c)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
547 // do not need tmp here
a61af66fc99e Initial load
duke
parents:
diff changeset
548 __ shift_left(left_op, exact_log2(c), result_op);
a61af66fc99e Initial load
duke
parents:
diff changeset
549 did_strength_reduce = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
550 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
551 did_strength_reduce = strength_reduce_multiply(left_op, c, result_op, tmp_op);
a61af66fc99e Initial load
duke
parents:
diff changeset
552 }
a61af66fc99e Initial load
duke
parents:
diff changeset
553 }
a61af66fc99e Initial load
duke
parents:
diff changeset
554 // we couldn't strength reduce so just emit the multiply
a61af66fc99e Initial load
duke
parents:
diff changeset
555 if (!did_strength_reduce) {
a61af66fc99e Initial load
duke
parents:
diff changeset
556 __ mul(left_op, right_op, result_op);
a61af66fc99e Initial load
duke
parents:
diff changeset
557 }
a61af66fc99e Initial load
duke
parents:
diff changeset
558 }
a61af66fc99e Initial load
duke
parents:
diff changeset
559 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
560
a61af66fc99e Initial load
duke
parents:
diff changeset
561 case Bytecodes::_dsub:
a61af66fc99e Initial load
duke
parents:
diff changeset
562 case Bytecodes::_fsub:
a61af66fc99e Initial load
duke
parents:
diff changeset
563 case Bytecodes::_lsub:
a61af66fc99e Initial load
duke
parents:
diff changeset
564 case Bytecodes::_isub: __ sub(left_op, right_op, result_op); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
565
a61af66fc99e Initial load
duke
parents:
diff changeset
566 case Bytecodes::_fdiv: __ div (left_op, right_op, result_op); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
567 // ldiv and lrem are implemented with a direct runtime call
a61af66fc99e Initial load
duke
parents:
diff changeset
568
a61af66fc99e Initial load
duke
parents:
diff changeset
569 case Bytecodes::_ddiv:
a61af66fc99e Initial load
duke
parents:
diff changeset
570 {
a61af66fc99e Initial load
duke
parents:
diff changeset
571 if (is_strictfp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
572 __ div_strictfp (left_op, right_op, result_op, tmp_op); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
573 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
574 __ div (left_op, right_op, result_op); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
575 }
a61af66fc99e Initial load
duke
parents:
diff changeset
576 }
a61af66fc99e Initial load
duke
parents:
diff changeset
577 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
578
a61af66fc99e Initial load
duke
parents:
diff changeset
579 case Bytecodes::_drem:
a61af66fc99e Initial load
duke
parents:
diff changeset
580 case Bytecodes::_frem: __ rem (left_op, right_op, result_op); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
581
a61af66fc99e Initial load
duke
parents:
diff changeset
582 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
583 }
a61af66fc99e Initial load
duke
parents:
diff changeset
584 }
a61af66fc99e Initial load
duke
parents:
diff changeset
585
a61af66fc99e Initial load
duke
parents:
diff changeset
586
a61af66fc99e Initial load
duke
parents:
diff changeset
587 void LIRGenerator::arithmetic_op_int(Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, LIR_Opr tmp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
588 arithmetic_op(code, result, left, right, false, tmp);
a61af66fc99e Initial load
duke
parents:
diff changeset
589 }
a61af66fc99e Initial load
duke
parents:
diff changeset
590
a61af66fc99e Initial load
duke
parents:
diff changeset
591
a61af66fc99e Initial load
duke
parents:
diff changeset
592 void LIRGenerator::arithmetic_op_long(Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, CodeEmitInfo* info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
593 arithmetic_op(code, result, left, right, false, LIR_OprFact::illegalOpr, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
594 }
a61af66fc99e Initial load
duke
parents:
diff changeset
595
a61af66fc99e Initial load
duke
parents:
diff changeset
596
a61af66fc99e Initial load
duke
parents:
diff changeset
597 void LIRGenerator::arithmetic_op_fpu(Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, bool is_strictfp, LIR_Opr tmp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
598 arithmetic_op(code, result, left, right, is_strictfp, tmp);
a61af66fc99e Initial load
duke
parents:
diff changeset
599 }
a61af66fc99e Initial load
duke
parents:
diff changeset
600
a61af66fc99e Initial load
duke
parents:
diff changeset
601
a61af66fc99e Initial load
duke
parents:
diff changeset
602 void LIRGenerator::shift_op(Bytecodes::Code code, LIR_Opr result_op, LIR_Opr value, LIR_Opr count, LIR_Opr tmp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
603 if (TwoOperandLIRForm && value != result_op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
604 assert(count != result_op, "malformed");
a61af66fc99e Initial load
duke
parents:
diff changeset
605 __ move(value, result_op);
a61af66fc99e Initial load
duke
parents:
diff changeset
606 value = result_op;
a61af66fc99e Initial load
duke
parents:
diff changeset
607 }
a61af66fc99e Initial load
duke
parents:
diff changeset
608
a61af66fc99e Initial load
duke
parents:
diff changeset
609 assert(count->is_constant() || count->is_register(), "must be");
a61af66fc99e Initial load
duke
parents:
diff changeset
610 switch(code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
611 case Bytecodes::_ishl:
a61af66fc99e Initial load
duke
parents:
diff changeset
612 case Bytecodes::_lshl: __ shift_left(value, count, result_op, tmp); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
613 case Bytecodes::_ishr:
a61af66fc99e Initial load
duke
parents:
diff changeset
614 case Bytecodes::_lshr: __ shift_right(value, count, result_op, tmp); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
615 case Bytecodes::_iushr:
a61af66fc99e Initial load
duke
parents:
diff changeset
616 case Bytecodes::_lushr: __ unsigned_shift_right(value, count, result_op, tmp); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
617 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
618 }
a61af66fc99e Initial load
duke
parents:
diff changeset
619 }
a61af66fc99e Initial load
duke
parents:
diff changeset
620
a61af66fc99e Initial load
duke
parents:
diff changeset
621
a61af66fc99e Initial load
duke
parents:
diff changeset
622 void LIRGenerator::logic_op (Bytecodes::Code code, LIR_Opr result_op, LIR_Opr left_op, LIR_Opr right_op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
623 if (TwoOperandLIRForm && left_op != result_op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
624 assert(right_op != result_op, "malformed");
a61af66fc99e Initial load
duke
parents:
diff changeset
625 __ move(left_op, result_op);
a61af66fc99e Initial load
duke
parents:
diff changeset
626 left_op = result_op;
a61af66fc99e Initial load
duke
parents:
diff changeset
627 }
a61af66fc99e Initial load
duke
parents:
diff changeset
628
a61af66fc99e Initial load
duke
parents:
diff changeset
629 switch(code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
630 case Bytecodes::_iand:
a61af66fc99e Initial load
duke
parents:
diff changeset
631 case Bytecodes::_land: __ logical_and(left_op, right_op, result_op); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
632
a61af66fc99e Initial load
duke
parents:
diff changeset
633 case Bytecodes::_ior:
a61af66fc99e Initial load
duke
parents:
diff changeset
634 case Bytecodes::_lor: __ logical_or(left_op, right_op, result_op); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
635
a61af66fc99e Initial load
duke
parents:
diff changeset
636 case Bytecodes::_ixor:
a61af66fc99e Initial load
duke
parents:
diff changeset
637 case Bytecodes::_lxor: __ logical_xor(left_op, right_op, result_op); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
638
a61af66fc99e Initial load
duke
parents:
diff changeset
639 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
640 }
a61af66fc99e Initial load
duke
parents:
diff changeset
641 }
a61af66fc99e Initial load
duke
parents:
diff changeset
642
a61af66fc99e Initial load
duke
parents:
diff changeset
643
a61af66fc99e Initial load
duke
parents:
diff changeset
644 void LIRGenerator::monitor_enter(LIR_Opr object, LIR_Opr lock, LIR_Opr hdr, LIR_Opr scratch, int monitor_no, CodeEmitInfo* info_for_exception, CodeEmitInfo* info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
645 if (!GenerateSynchronizationCode) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
646 // for slow path, use debug info for state after successful locking
a61af66fc99e Initial load
duke
parents:
diff changeset
647 CodeStub* slow_path = new MonitorEnterStub(object, lock, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
648 __ load_stack_address_monitor(monitor_no, lock);
a61af66fc99e Initial load
duke
parents:
diff changeset
649 // for handling NullPointerException, use debug info representing just the lock stack before this monitorenter
a61af66fc99e Initial load
duke
parents:
diff changeset
650 __ lock_object(hdr, object, lock, scratch, slow_path, info_for_exception);
a61af66fc99e Initial load
duke
parents:
diff changeset
651 }
a61af66fc99e Initial load
duke
parents:
diff changeset
652
a61af66fc99e Initial load
duke
parents:
diff changeset
653
1681
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1584
diff changeset
654 void LIRGenerator::monitor_exit(LIR_Opr object, LIR_Opr lock, LIR_Opr new_hdr, LIR_Opr scratch, int monitor_no) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
655 if (!GenerateSynchronizationCode) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
656 // setup registers
a61af66fc99e Initial load
duke
parents:
diff changeset
657 LIR_Opr hdr = lock;
a61af66fc99e Initial load
duke
parents:
diff changeset
658 lock = new_hdr;
a61af66fc99e Initial load
duke
parents:
diff changeset
659 CodeStub* slow_path = new MonitorExitStub(lock, UseFastLocking, monitor_no);
a61af66fc99e Initial load
duke
parents:
diff changeset
660 __ load_stack_address_monitor(monitor_no, lock);
1681
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1584
diff changeset
661 __ unlock_object(hdr, object, lock, scratch, slow_path);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
662 }
a61af66fc99e Initial load
duke
parents:
diff changeset
663
20344
2fd0fd493045 8031994: java/lang/Character/CheckProp test times out
rbackman
parents: 17925
diff changeset
664 #ifndef PRODUCT
2fd0fd493045 8031994: java/lang/Character/CheckProp test times out
rbackman
parents: 17925
diff changeset
665 void LIRGenerator::print_if_not_loaded(const NewInstance* new_instance) {
2fd0fd493045 8031994: java/lang/Character/CheckProp test times out
rbackman
parents: 17925
diff changeset
666 if (PrintNotLoaded && !new_instance->klass()->is_loaded()) {
2fd0fd493045 8031994: java/lang/Character/CheckProp test times out
rbackman
parents: 17925
diff changeset
667 tty->print_cr(" ###class not loaded at new bci %d", new_instance->printable_bci());
2fd0fd493045 8031994: java/lang/Character/CheckProp test times out
rbackman
parents: 17925
diff changeset
668 } else if (PrintNotLoaded && (TieredCompilation && new_instance->is_unresolved())) {
2fd0fd493045 8031994: java/lang/Character/CheckProp test times out
rbackman
parents: 17925
diff changeset
669 tty->print_cr(" ###class not resolved at new bci %d", new_instance->printable_bci());
2fd0fd493045 8031994: java/lang/Character/CheckProp test times out
rbackman
parents: 17925
diff changeset
670 }
2fd0fd493045 8031994: java/lang/Character/CheckProp test times out
rbackman
parents: 17925
diff changeset
671 }
2fd0fd493045 8031994: java/lang/Character/CheckProp test times out
rbackman
parents: 17925
diff changeset
672 #endif
2fd0fd493045 8031994: java/lang/Character/CheckProp test times out
rbackman
parents: 17925
diff changeset
673
2fd0fd493045 8031994: java/lang/Character/CheckProp test times out
rbackman
parents: 17925
diff changeset
674 void LIRGenerator::new_instance(LIR_Opr dst, ciInstanceKlass* klass, bool is_unresolved, LIR_Opr scratch1, LIR_Opr scratch2, LIR_Opr scratch3, LIR_Opr scratch4, LIR_Opr klass_reg, CodeEmitInfo* info) {
2fd0fd493045 8031994: java/lang/Character/CheckProp test times out
rbackman
parents: 17925
diff changeset
675 klass2reg_with_patching(klass_reg, klass, info, is_unresolved);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
676 // If klass is not loaded we do not know if the klass has finalizers:
a61af66fc99e Initial load
duke
parents:
diff changeset
677 if (UseFastNewInstance && klass->is_loaded()
a61af66fc99e Initial load
duke
parents:
diff changeset
678 && !Klass::layout_helper_needs_slow_path(klass->layout_helper())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
679
a61af66fc99e Initial load
duke
parents:
diff changeset
680 Runtime1::StubID stub_id = klass->is_initialized() ? Runtime1::fast_new_instance_id : Runtime1::fast_new_instance_init_check_id;
a61af66fc99e Initial load
duke
parents:
diff changeset
681
a61af66fc99e Initial load
duke
parents:
diff changeset
682 CodeStub* slow_path = new NewInstanceStub(klass_reg, dst, klass, info, stub_id);
a61af66fc99e Initial load
duke
parents:
diff changeset
683
a61af66fc99e Initial load
duke
parents:
diff changeset
684 assert(klass->is_loaded(), "must be loaded");
a61af66fc99e Initial load
duke
parents:
diff changeset
685 // allocate space for instance
a61af66fc99e Initial load
duke
parents:
diff changeset
686 assert(klass->size_helper() >= 0, "illegal instance size");
a61af66fc99e Initial load
duke
parents:
diff changeset
687 const int instance_size = align_object_size(klass->size_helper());
a61af66fc99e Initial load
duke
parents:
diff changeset
688 __ allocate_object(dst, scratch1, scratch2, scratch3, scratch4,
a61af66fc99e Initial load
duke
parents:
diff changeset
689 oopDesc::header_size(), instance_size, klass_reg, !klass->is_initialized(), slow_path);
a61af66fc99e Initial load
duke
parents:
diff changeset
690 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
691 CodeStub* slow_path = new NewInstanceStub(klass_reg, dst, klass, info, Runtime1::new_instance_id);
a61af66fc99e Initial load
duke
parents:
diff changeset
692 __ branch(lir_cond_always, T_ILLEGAL, slow_path);
a61af66fc99e Initial load
duke
parents:
diff changeset
693 __ branch_destination(slow_path->continuation());
a61af66fc99e Initial load
duke
parents:
diff changeset
694 }
a61af66fc99e Initial load
duke
parents:
diff changeset
695 }
a61af66fc99e Initial load
duke
parents:
diff changeset
696
a61af66fc99e Initial load
duke
parents:
diff changeset
697
a61af66fc99e Initial load
duke
parents:
diff changeset
698 static bool is_constant_zero(Instruction* inst) {
a61af66fc99e Initial load
duke
parents:
diff changeset
699 IntConstant* c = inst->type()->as_IntConstant();
a61af66fc99e Initial load
duke
parents:
diff changeset
700 if (c) {
a61af66fc99e Initial load
duke
parents:
diff changeset
701 return (c->value() == 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
702 }
a61af66fc99e Initial load
duke
parents:
diff changeset
703 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
704 }
a61af66fc99e Initial load
duke
parents:
diff changeset
705
a61af66fc99e Initial load
duke
parents:
diff changeset
706
a61af66fc99e Initial load
duke
parents:
diff changeset
707 static bool positive_constant(Instruction* inst) {
a61af66fc99e Initial load
duke
parents:
diff changeset
708 IntConstant* c = inst->type()->as_IntConstant();
a61af66fc99e Initial load
duke
parents:
diff changeset
709 if (c) {
a61af66fc99e Initial load
duke
parents:
diff changeset
710 return (c->value() >= 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
711 }
a61af66fc99e Initial load
duke
parents:
diff changeset
712 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
713 }
a61af66fc99e Initial load
duke
parents:
diff changeset
714
a61af66fc99e Initial load
duke
parents:
diff changeset
715
a61af66fc99e Initial load
duke
parents:
diff changeset
716 static ciArrayKlass* as_array_klass(ciType* type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
717 if (type != NULL && type->is_array_klass() && type->is_loaded()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
718 return (ciArrayKlass*)type;
a61af66fc99e Initial load
duke
parents:
diff changeset
719 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
720 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
721 }
a61af66fc99e Initial load
duke
parents:
diff changeset
722 }
a61af66fc99e Initial load
duke
parents:
diff changeset
723
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
724 static ciType* phi_declared_type(Phi* phi) {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
725 ciType* t = phi->operand_at(0)->declared_type();
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
726 if (t == NULL) {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
727 return NULL;
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
728 }
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
729 for(int i = 1; i < phi->operand_count(); i++) {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
730 if (t != phi->operand_at(i)->declared_type()) {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
731 return NULL;
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
732 }
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
733 }
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
734 return t;
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
735 }
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
736
0
a61af66fc99e Initial load
duke
parents:
diff changeset
737 void LIRGenerator::arraycopy_helper(Intrinsic* x, int* flagsp, ciArrayKlass** expected_typep) {
a61af66fc99e Initial load
duke
parents:
diff changeset
738 Instruction* src = x->argument_at(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
739 Instruction* src_pos = x->argument_at(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
740 Instruction* dst = x->argument_at(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
741 Instruction* dst_pos = x->argument_at(3);
a61af66fc99e Initial load
duke
parents:
diff changeset
742 Instruction* length = x->argument_at(4);
a61af66fc99e Initial load
duke
parents:
diff changeset
743
a61af66fc99e Initial load
duke
parents:
diff changeset
744 // first try to identify the likely type of the arrays involved
a61af66fc99e Initial load
duke
parents:
diff changeset
745 ciArrayKlass* expected_type = NULL;
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
746 bool is_exact = false, src_objarray = false, dst_objarray = false;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
747 {
a61af66fc99e Initial load
duke
parents:
diff changeset
748 ciArrayKlass* src_exact_type = as_array_klass(src->exact_type());
a61af66fc99e Initial load
duke
parents:
diff changeset
749 ciArrayKlass* src_declared_type = as_array_klass(src->declared_type());
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
750 Phi* phi;
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
751 if (src_declared_type == NULL && (phi = src->as_Phi()) != NULL) {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
752 src_declared_type = as_array_klass(phi_declared_type(phi));
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
753 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
754 ciArrayKlass* dst_exact_type = as_array_klass(dst->exact_type());
a61af66fc99e Initial load
duke
parents:
diff changeset
755 ciArrayKlass* dst_declared_type = as_array_klass(dst->declared_type());
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
756 if (dst_declared_type == NULL && (phi = dst->as_Phi()) != NULL) {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
757 dst_declared_type = as_array_klass(phi_declared_type(phi));
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
758 }
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
759
0
a61af66fc99e Initial load
duke
parents:
diff changeset
760 if (src_exact_type != NULL && src_exact_type == dst_exact_type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
761 // the types exactly match so the type is fully known
a61af66fc99e Initial load
duke
parents:
diff changeset
762 is_exact = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
763 expected_type = src_exact_type;
a61af66fc99e Initial load
duke
parents:
diff changeset
764 } else if (dst_exact_type != NULL && dst_exact_type->is_obj_array_klass()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
765 ciArrayKlass* dst_type = (ciArrayKlass*) dst_exact_type;
a61af66fc99e Initial load
duke
parents:
diff changeset
766 ciArrayKlass* src_type = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
767 if (src_exact_type != NULL && src_exact_type->is_obj_array_klass()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
768 src_type = (ciArrayKlass*) src_exact_type;
a61af66fc99e Initial load
duke
parents:
diff changeset
769 } else if (src_declared_type != NULL && src_declared_type->is_obj_array_klass()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
770 src_type = (ciArrayKlass*) src_declared_type;
a61af66fc99e Initial load
duke
parents:
diff changeset
771 }
a61af66fc99e Initial load
duke
parents:
diff changeset
772 if (src_type != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
773 if (src_type->element_type()->is_subtype_of(dst_type->element_type())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
774 is_exact = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
775 expected_type = dst_type;
a61af66fc99e Initial load
duke
parents:
diff changeset
776 }
a61af66fc99e Initial load
duke
parents:
diff changeset
777 }
a61af66fc99e Initial load
duke
parents:
diff changeset
778 }
a61af66fc99e Initial load
duke
parents:
diff changeset
779 // at least pass along a good guess
a61af66fc99e Initial load
duke
parents:
diff changeset
780 if (expected_type == NULL) expected_type = dst_exact_type;
a61af66fc99e Initial load
duke
parents:
diff changeset
781 if (expected_type == NULL) expected_type = src_declared_type;
a61af66fc99e Initial load
duke
parents:
diff changeset
782 if (expected_type == NULL) expected_type = dst_declared_type;
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
783
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
784 src_objarray = (src_exact_type && src_exact_type->is_obj_array_klass()) || (src_declared_type && src_declared_type->is_obj_array_klass());
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
785 dst_objarray = (dst_exact_type && dst_exact_type->is_obj_array_klass()) || (dst_declared_type && dst_declared_type->is_obj_array_klass());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
786 }
a61af66fc99e Initial load
duke
parents:
diff changeset
787
a61af66fc99e Initial load
duke
parents:
diff changeset
788 // if a probable array type has been identified, figure out if any
a61af66fc99e Initial load
duke
parents:
diff changeset
789 // of the required checks for a fast case can be elided.
a61af66fc99e Initial load
duke
parents:
diff changeset
790 int flags = LIR_OpArrayCopy::all_flags;
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
791
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
792 if (!src_objarray)
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
793 flags &= ~LIR_OpArrayCopy::src_objarray;
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
794 if (!dst_objarray)
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
795 flags &= ~LIR_OpArrayCopy::dst_objarray;
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
796
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
797 if (!x->arg_needs_null_check(0))
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
798 flags &= ~LIR_OpArrayCopy::src_null_check;
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
799 if (!x->arg_needs_null_check(2))
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
800 flags &= ~LIR_OpArrayCopy::dst_null_check;
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
801
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
802
0
a61af66fc99e Initial load
duke
parents:
diff changeset
803 if (expected_type != NULL) {
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
804 Value length_limit = NULL;
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
805
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
806 IfOp* ifop = length->as_IfOp();
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
807 if (ifop != NULL) {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
808 // look for expressions like min(v, a.length) which ends up as
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
809 // x > y ? y : x or x >= y ? y : x
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
810 if ((ifop->cond() == If::gtr || ifop->cond() == If::geq) &&
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
811 ifop->x() == ifop->fval() &&
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
812 ifop->y() == ifop->tval()) {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
813 length_limit = ifop->y();
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
814 }
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
815 }
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
816
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
817 // try to skip null checks and range checks
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
818 NewArray* src_array = src->as_NewArray();
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
819 if (src_array != NULL) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
820 flags &= ~LIR_OpArrayCopy::src_null_check;
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
821 if (length_limit != NULL &&
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
822 src_array->length() == length_limit &&
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
823 is_constant_zero(src_pos)) {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
824 flags &= ~LIR_OpArrayCopy::src_range_check;
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
825 }
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
826 }
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
827
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
828 NewArray* dst_array = dst->as_NewArray();
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
829 if (dst_array != NULL) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
830 flags &= ~LIR_OpArrayCopy::dst_null_check;
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
831 if (length_limit != NULL &&
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
832 dst_array->length() == length_limit &&
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
833 is_constant_zero(dst_pos)) {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
834 flags &= ~LIR_OpArrayCopy::dst_range_check;
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
835 }
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
836 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
837
a61af66fc99e Initial load
duke
parents:
diff changeset
838 // check from incoming constant values
a61af66fc99e Initial load
duke
parents:
diff changeset
839 if (positive_constant(src_pos))
a61af66fc99e Initial load
duke
parents:
diff changeset
840 flags &= ~LIR_OpArrayCopy::src_pos_positive_check;
a61af66fc99e Initial load
duke
parents:
diff changeset
841 if (positive_constant(dst_pos))
a61af66fc99e Initial load
duke
parents:
diff changeset
842 flags &= ~LIR_OpArrayCopy::dst_pos_positive_check;
a61af66fc99e Initial load
duke
parents:
diff changeset
843 if (positive_constant(length))
a61af66fc99e Initial load
duke
parents:
diff changeset
844 flags &= ~LIR_OpArrayCopy::length_positive_check;
a61af66fc99e Initial load
duke
parents:
diff changeset
845
a61af66fc99e Initial load
duke
parents:
diff changeset
846 // see if the range check can be elided, which might also imply
a61af66fc99e Initial load
duke
parents:
diff changeset
847 // that src or dst is non-null.
a61af66fc99e Initial load
duke
parents:
diff changeset
848 ArrayLength* al = length->as_ArrayLength();
a61af66fc99e Initial load
duke
parents:
diff changeset
849 if (al != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
850 if (al->array() == src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
851 // it's the length of the source array
a61af66fc99e Initial load
duke
parents:
diff changeset
852 flags &= ~LIR_OpArrayCopy::length_positive_check;
a61af66fc99e Initial load
duke
parents:
diff changeset
853 flags &= ~LIR_OpArrayCopy::src_null_check;
a61af66fc99e Initial load
duke
parents:
diff changeset
854 if (is_constant_zero(src_pos))
a61af66fc99e Initial load
duke
parents:
diff changeset
855 flags &= ~LIR_OpArrayCopy::src_range_check;
a61af66fc99e Initial load
duke
parents:
diff changeset
856 }
a61af66fc99e Initial load
duke
parents:
diff changeset
857 if (al->array() == dst) {
a61af66fc99e Initial load
duke
parents:
diff changeset
858 // it's the length of the destination array
a61af66fc99e Initial load
duke
parents:
diff changeset
859 flags &= ~LIR_OpArrayCopy::length_positive_check;
a61af66fc99e Initial load
duke
parents:
diff changeset
860 flags &= ~LIR_OpArrayCopy::dst_null_check;
a61af66fc99e Initial load
duke
parents:
diff changeset
861 if (is_constant_zero(dst_pos))
a61af66fc99e Initial load
duke
parents:
diff changeset
862 flags &= ~LIR_OpArrayCopy::dst_range_check;
a61af66fc99e Initial load
duke
parents:
diff changeset
863 }
a61af66fc99e Initial load
duke
parents:
diff changeset
864 }
a61af66fc99e Initial load
duke
parents:
diff changeset
865 if (is_exact) {
a61af66fc99e Initial load
duke
parents:
diff changeset
866 flags &= ~LIR_OpArrayCopy::type_check;
a61af66fc99e Initial load
duke
parents:
diff changeset
867 }
a61af66fc99e Initial load
duke
parents:
diff changeset
868 }
a61af66fc99e Initial load
duke
parents:
diff changeset
869
2446
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
870 IntConstant* src_int = src_pos->type()->as_IntConstant();
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
871 IntConstant* dst_int = dst_pos->type()->as_IntConstant();
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
872 if (src_int && dst_int) {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
873 int s_offs = src_int->value();
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
874 int d_offs = dst_int->value();
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
875 if (src_int->value() >= dst_int->value()) {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
876 flags &= ~LIR_OpArrayCopy::overlapping;
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
877 }
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
878 if (expected_type != NULL) {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
879 BasicType t = expected_type->element_type()->basic_type();
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
880 int element_size = type2aelembytes(t);
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
881 if (((arrayOopDesc::base_offset_in_bytes(t) + s_offs * element_size) % HeapWordSize == 0) &&
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
882 ((arrayOopDesc::base_offset_in_bytes(t) + d_offs * element_size) % HeapWordSize == 0)) {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
883 flags &= ~LIR_OpArrayCopy::unaligned;
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
884 }
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
885 }
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
886 } else if (src_pos == dst_pos || is_constant_zero(dst_pos)) {
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
887 // src and dest positions are the same, or dst is zero so assume
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
888 // nonoverlapping copy.
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
889 flags &= ~LIR_OpArrayCopy::overlapping;
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
890 }
13bc79b5c9c8 7033154: Improve C1 arraycopy performance
roland
parents: 2357
diff changeset
891
0
a61af66fc99e Initial load
duke
parents:
diff changeset
892 if (src == dst) {
a61af66fc99e Initial load
duke
parents:
diff changeset
893 // moving within a single array so no type checks are needed
a61af66fc99e Initial load
duke
parents:
diff changeset
894 if (flags & LIR_OpArrayCopy::type_check) {
a61af66fc99e Initial load
duke
parents:
diff changeset
895 flags &= ~LIR_OpArrayCopy::type_check;
a61af66fc99e Initial load
duke
parents:
diff changeset
896 }
a61af66fc99e Initial load
duke
parents:
diff changeset
897 }
a61af66fc99e Initial load
duke
parents:
diff changeset
898 *flagsp = flags;
a61af66fc99e Initial load
duke
parents:
diff changeset
899 *expected_typep = (ciArrayKlass*)expected_type;
a61af66fc99e Initial load
duke
parents:
diff changeset
900 }
a61af66fc99e Initial load
duke
parents:
diff changeset
901
a61af66fc99e Initial load
duke
parents:
diff changeset
902
a61af66fc99e Initial load
duke
parents:
diff changeset
903 LIR_Opr LIRGenerator::round_item(LIR_Opr opr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
904 assert(opr->is_register(), "why spill if item is not register?");
a61af66fc99e Initial load
duke
parents:
diff changeset
905
a61af66fc99e Initial load
duke
parents:
diff changeset
906 if (RoundFPResults && UseSSE < 1 && opr->is_single_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
907 LIR_Opr result = new_register(T_FLOAT);
a61af66fc99e Initial load
duke
parents:
diff changeset
908 set_vreg_flag(result, must_start_in_memory);
a61af66fc99e Initial load
duke
parents:
diff changeset
909 assert(opr->is_register(), "only a register can be spilled");
a61af66fc99e Initial load
duke
parents:
diff changeset
910 assert(opr->value_type()->is_float(), "rounding only for floats available");
a61af66fc99e Initial load
duke
parents:
diff changeset
911 __ roundfp(opr, LIR_OprFact::illegalOpr, result);
a61af66fc99e Initial load
duke
parents:
diff changeset
912 return result;
a61af66fc99e Initial load
duke
parents:
diff changeset
913 }
a61af66fc99e Initial load
duke
parents:
diff changeset
914 return opr;
a61af66fc99e Initial load
duke
parents:
diff changeset
915 }
a61af66fc99e Initial load
duke
parents:
diff changeset
916
a61af66fc99e Initial load
duke
parents:
diff changeset
917
a61af66fc99e Initial load
duke
parents:
diff changeset
918 LIR_Opr LIRGenerator::force_to_spill(LIR_Opr value, BasicType t) {
6616
7a302948f5a4 7192167: JSR 292: C1 has old broken code which needs to be removed
twisti
parents: 6615
diff changeset
919 assert(type2size[t] == type2size[value->type()],
7a302948f5a4 7192167: JSR 292: C1 has old broken code which needs to be removed
twisti
parents: 6615
diff changeset
920 err_msg_res("size mismatch: t=%s, value->type()=%s", type2name(t), type2name(value->type())));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
921 if (!value->is_register()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
922 // force into a register
a61af66fc99e Initial load
duke
parents:
diff changeset
923 LIR_Opr r = new_register(value->type());
a61af66fc99e Initial load
duke
parents:
diff changeset
924 __ move(value, r);
a61af66fc99e Initial load
duke
parents:
diff changeset
925 value = r;
a61af66fc99e Initial load
duke
parents:
diff changeset
926 }
a61af66fc99e Initial load
duke
parents:
diff changeset
927
a61af66fc99e Initial load
duke
parents:
diff changeset
928 // create a spill location
a61af66fc99e Initial load
duke
parents:
diff changeset
929 LIR_Opr tmp = new_register(t);
a61af66fc99e Initial load
duke
parents:
diff changeset
930 set_vreg_flag(tmp, LIRGenerator::must_start_in_memory);
a61af66fc99e Initial load
duke
parents:
diff changeset
931
a61af66fc99e Initial load
duke
parents:
diff changeset
932 // move from register to spill
a61af66fc99e Initial load
duke
parents:
diff changeset
933 __ move(value, tmp);
a61af66fc99e Initial load
duke
parents:
diff changeset
934 return tmp;
a61af66fc99e Initial load
duke
parents:
diff changeset
935 }
a61af66fc99e Initial load
duke
parents:
diff changeset
936
a61af66fc99e Initial load
duke
parents:
diff changeset
937 void LIRGenerator::profile_branch(If* if_instr, If::Condition cond) {
a61af66fc99e Initial load
duke
parents:
diff changeset
938 if (if_instr->should_profile()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
939 ciMethod* method = if_instr->profiled_method();
a61af66fc99e Initial load
duke
parents:
diff changeset
940 assert(method != NULL, "method should be set if branch is profiled");
2007
5ddfcf4b079e 7003554: (tiered) assert(is_null_object() || handle() != NULL) failed: cannot embed null pointer
iveresov
parents: 2002
diff changeset
941 ciMethodData* md = method->method_data_or_null();
5ddfcf4b079e 7003554: (tiered) assert(is_null_object() || handle() != NULL) failed: cannot embed null pointer
iveresov
parents: 2002
diff changeset
942 assert(md != NULL, "Sanity");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
943 ciProfileData* data = md->bci_to_data(if_instr->profiled_bci());
a61af66fc99e Initial load
duke
parents:
diff changeset
944 assert(data != NULL, "must have profiling data");
a61af66fc99e Initial load
duke
parents:
diff changeset
945 assert(data->is_BranchData(), "need BranchData for two-way branches");
a61af66fc99e Initial load
duke
parents:
diff changeset
946 int taken_count_offset = md->byte_offset_of_slot(data, BranchData::taken_offset());
a61af66fc99e Initial load
duke
parents:
diff changeset
947 int not_taken_count_offset = md->byte_offset_of_slot(data, BranchData::not_taken_offset());
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
948 if (if_instr->is_swapped()) {
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
949 int t = taken_count_offset;
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
950 taken_count_offset = not_taken_count_offset;
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
951 not_taken_count_offset = t;
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
952 }
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
953
6739
8a02ca5e5576 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 6731
diff changeset
954 LIR_Opr md_reg = new_register(T_METADATA);
8a02ca5e5576 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 6731
diff changeset
955 __ metadata2reg(md->constant_encoding(), md_reg);
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
956
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
957 LIR_Opr data_offset_reg = new_pointer_register();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
958 __ cmove(lir_cond(cond),
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
959 LIR_OprFact::intptrConst(taken_count_offset),
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
960 LIR_OprFact::intptrConst(not_taken_count_offset),
2089
037c727f35fb 7009231: C1: Incorrect CAS code for longs on SPARC 32bit
iveresov
parents: 2007
diff changeset
961 data_offset_reg, as_BasicType(if_instr->x()->type()));
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
962
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
963 // MDO cells are intptr_t, so the data_reg width is arch-dependent.
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
964 LIR_Opr data_reg = new_pointer_register();
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
965 LIR_Address* data_addr = new LIR_Address(md_reg, data_offset_reg, data_reg->type());
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
966 __ move(data_addr, data_reg);
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
967 // Use leal instead of add to avoid destroying condition codes on x86
0
a61af66fc99e Initial load
duke
parents:
diff changeset
968 LIR_Address* fake_incr_value = new LIR_Address(data_reg, DataLayout::counter_increment, T_INT);
a61af66fc99e Initial load
duke
parents:
diff changeset
969 __ leal(LIR_OprFact::address(fake_incr_value), data_reg);
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
970 __ move(data_reg, data_addr);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
971 }
a61af66fc99e Initial load
duke
parents:
diff changeset
972 }
a61af66fc99e Initial load
duke
parents:
diff changeset
973
a61af66fc99e Initial load
duke
parents:
diff changeset
974 // Phi technique:
a61af66fc99e Initial load
duke
parents:
diff changeset
975 // This is about passing live values from one basic block to the other.
a61af66fc99e Initial load
duke
parents:
diff changeset
976 // In code generated with Java it is rather rare that more than one
a61af66fc99e Initial load
duke
parents:
diff changeset
977 // value is on the stack from one basic block to the other.
a61af66fc99e Initial load
duke
parents:
diff changeset
978 // We optimize our technique for efficient passing of one value
a61af66fc99e Initial load
duke
parents:
diff changeset
979 // (of type long, int, double..) but it can be extended.
a61af66fc99e Initial load
duke
parents:
diff changeset
980 // When entering or leaving a basic block, all registers and all spill
a61af66fc99e Initial load
duke
parents:
diff changeset
981 // slots are release and empty. We use the released registers
a61af66fc99e Initial load
duke
parents:
diff changeset
982 // and spill slots to pass the live values from one block
a61af66fc99e Initial load
duke
parents:
diff changeset
983 // to the other. The topmost value, i.e., the value on TOS of expression
a61af66fc99e Initial load
duke
parents:
diff changeset
984 // stack is passed in registers. All other values are stored in spilling
a61af66fc99e Initial load
duke
parents:
diff changeset
985 // area. Every Phi has an index which designates its spill slot
a61af66fc99e Initial load
duke
parents:
diff changeset
986 // At exit of a basic block, we fill the register(s) and spill slots.
a61af66fc99e Initial load
duke
parents:
diff changeset
987 // At entry of a basic block, the block_prolog sets up the content of phi nodes
a61af66fc99e Initial load
duke
parents:
diff changeset
988 // and locks necessary registers and spilling slots.
a61af66fc99e Initial load
duke
parents:
diff changeset
989
a61af66fc99e Initial load
duke
parents:
diff changeset
990
a61af66fc99e Initial load
duke
parents:
diff changeset
991 // move current value to referenced phi function
a61af66fc99e Initial load
duke
parents:
diff changeset
992 void LIRGenerator::move_to_phi(PhiResolver* resolver, Value cur_val, Value sux_val) {
a61af66fc99e Initial load
duke
parents:
diff changeset
993 Phi* phi = sux_val->as_Phi();
a61af66fc99e Initial load
duke
parents:
diff changeset
994 // cur_val can be null without phi being null in conjunction with inlining
a61af66fc99e Initial load
duke
parents:
diff changeset
995 if (phi != NULL && cur_val != NULL && cur_val != phi && !phi->is_illegal()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
996 LIR_Opr operand = cur_val->operand();
a61af66fc99e Initial load
duke
parents:
diff changeset
997 if (cur_val->operand()->is_illegal()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
998 assert(cur_val->as_Constant() != NULL || cur_val->as_Local() != NULL,
a61af66fc99e Initial load
duke
parents:
diff changeset
999 "these can be produced lazily");
a61af66fc99e Initial load
duke
parents:
diff changeset
1000 operand = operand_for_instruction(cur_val);
a61af66fc99e Initial load
duke
parents:
diff changeset
1001 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1002 resolver->move(operand, operand_for_instruction(phi));
a61af66fc99e Initial load
duke
parents:
diff changeset
1003 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1004 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1005
a61af66fc99e Initial load
duke
parents:
diff changeset
1006
a61af66fc99e Initial load
duke
parents:
diff changeset
1007 // Moves all stack values into their PHI position
a61af66fc99e Initial load
duke
parents:
diff changeset
1008 void LIRGenerator::move_to_phi(ValueStack* cur_state) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1009 BlockBegin* bb = block();
a61af66fc99e Initial load
duke
parents:
diff changeset
1010 if (bb->number_of_sux() == 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1011 BlockBegin* sux = bb->sux_at(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1012 assert(sux->number_of_preds() > 0, "invalid CFG");
a61af66fc99e Initial load
duke
parents:
diff changeset
1013
a61af66fc99e Initial load
duke
parents:
diff changeset
1014 // a block with only one predecessor never has phi functions
a61af66fc99e Initial load
duke
parents:
diff changeset
1015 if (sux->number_of_preds() > 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1016 int max_phis = cur_state->stack_size() + cur_state->locals_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
1017 PhiResolver resolver(this, _virtual_register_number + max_phis * 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
1018
a61af66fc99e Initial load
duke
parents:
diff changeset
1019 ValueStack* sux_state = sux->state();
a61af66fc99e Initial load
duke
parents:
diff changeset
1020 Value sux_value;
a61af66fc99e Initial load
duke
parents:
diff changeset
1021 int index;
a61af66fc99e Initial load
duke
parents:
diff changeset
1022
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1816
diff changeset
1023 assert(cur_state->scope() == sux_state->scope(), "not matching");
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1816
diff changeset
1024 assert(cur_state->locals_size() == sux_state->locals_size(), "not matching");
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1816
diff changeset
1025 assert(cur_state->stack_size() == sux_state->stack_size(), "not matching");
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1816
diff changeset
1026
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1027 for_each_stack_value(sux_state, index, sux_value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1028 move_to_phi(&resolver, cur_state->stack_at(index), sux_value);
a61af66fc99e Initial load
duke
parents:
diff changeset
1029 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1030
a61af66fc99e Initial load
duke
parents:
diff changeset
1031 for_each_local_value(sux_state, index, sux_value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1032 move_to_phi(&resolver, cur_state->local_at(index), sux_value);
a61af66fc99e Initial load
duke
parents:
diff changeset
1033 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1034
a61af66fc99e Initial load
duke
parents:
diff changeset
1035 assert(cur_state->caller_state() == sux_state->caller_state(), "caller states must be equal");
a61af66fc99e Initial load
duke
parents:
diff changeset
1036 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1037 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1038 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1039
a61af66fc99e Initial load
duke
parents:
diff changeset
1040
a61af66fc99e Initial load
duke
parents:
diff changeset
1041 LIR_Opr LIRGenerator::new_register(BasicType type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1042 int vreg = _virtual_register_number;
a61af66fc99e Initial load
duke
parents:
diff changeset
1043 // add a little fudge factor for the bailout, since the bailout is
a61af66fc99e Initial load
duke
parents:
diff changeset
1044 // only checked periodically. This gives a few extra registers to
a61af66fc99e Initial load
duke
parents:
diff changeset
1045 // hand out before we really run out, which helps us keep from
a61af66fc99e Initial load
duke
parents:
diff changeset
1046 // tripping over assertions.
a61af66fc99e Initial load
duke
parents:
diff changeset
1047 if (vreg + 20 >= LIR_OprDesc::vreg_max) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1048 bailout("out of virtual registers");
a61af66fc99e Initial load
duke
parents:
diff changeset
1049 if (vreg + 2 >= LIR_OprDesc::vreg_max) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1050 // wrap it around
a61af66fc99e Initial load
duke
parents:
diff changeset
1051 _virtual_register_number = LIR_OprDesc::vreg_base;
a61af66fc99e Initial load
duke
parents:
diff changeset
1052 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1053 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1054 _virtual_register_number += 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
1055 return LIR_OprFact::virtual_register(vreg, type);
a61af66fc99e Initial load
duke
parents:
diff changeset
1056 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1057
a61af66fc99e Initial load
duke
parents:
diff changeset
1058
a61af66fc99e Initial load
duke
parents:
diff changeset
1059 // Try to lock using register in hint
a61af66fc99e Initial load
duke
parents:
diff changeset
1060 LIR_Opr LIRGenerator::rlock(Value instr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1061 return new_register(instr->type());
a61af66fc99e Initial load
duke
parents:
diff changeset
1062 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1063
a61af66fc99e Initial load
duke
parents:
diff changeset
1064
a61af66fc99e Initial load
duke
parents:
diff changeset
1065 // does an rlock and sets result
a61af66fc99e Initial load
duke
parents:
diff changeset
1066 LIR_Opr LIRGenerator::rlock_result(Value x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1067 LIR_Opr reg = rlock(x);
a61af66fc99e Initial load
duke
parents:
diff changeset
1068 set_result(x, reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
1069 return reg;
a61af66fc99e Initial load
duke
parents:
diff changeset
1070 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1071
a61af66fc99e Initial load
duke
parents:
diff changeset
1072
a61af66fc99e Initial load
duke
parents:
diff changeset
1073 // does an rlock and sets result
a61af66fc99e Initial load
duke
parents:
diff changeset
1074 LIR_Opr LIRGenerator::rlock_result(Value x, BasicType type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1075 LIR_Opr reg;
a61af66fc99e Initial load
duke
parents:
diff changeset
1076 switch (type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1077 case T_BYTE:
a61af66fc99e Initial load
duke
parents:
diff changeset
1078 case T_BOOLEAN:
a61af66fc99e Initial load
duke
parents:
diff changeset
1079 reg = rlock_byte(type);
a61af66fc99e Initial load
duke
parents:
diff changeset
1080 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1081 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
1082 reg = rlock(x);
a61af66fc99e Initial load
duke
parents:
diff changeset
1083 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1084 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1085
a61af66fc99e Initial load
duke
parents:
diff changeset
1086 set_result(x, reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
1087 return reg;
a61af66fc99e Initial load
duke
parents:
diff changeset
1088 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1089
a61af66fc99e Initial load
duke
parents:
diff changeset
1090
a61af66fc99e Initial load
duke
parents:
diff changeset
1091 //---------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
1092 ciObject* LIRGenerator::get_jobject_constant(Value value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1093 ObjectType* oc = value->type()->as_ObjectType();
a61af66fc99e Initial load
duke
parents:
diff changeset
1094 if (oc) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1095 return oc->constant_value();
a61af66fc99e Initial load
duke
parents:
diff changeset
1096 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1097 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
1098 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1099
a61af66fc99e Initial load
duke
parents:
diff changeset
1100
a61af66fc99e Initial load
duke
parents:
diff changeset
1101 void LIRGenerator::do_ExceptionObject(ExceptionObject* x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1102 assert(block()->is_set(BlockBegin::exception_entry_flag), "ExceptionObject only allowed in exception handler block");
a61af66fc99e Initial load
duke
parents:
diff changeset
1103 assert(block()->next() == x, "ExceptionObject must be first instruction of block");
a61af66fc99e Initial load
duke
parents:
diff changeset
1104
a61af66fc99e Initial load
duke
parents:
diff changeset
1105 // no moves are created for phi functions at the begin of exception
a61af66fc99e Initial load
duke
parents:
diff changeset
1106 // handlers, so assign operands manually here
a61af66fc99e Initial load
duke
parents:
diff changeset
1107 for_each_phi_fun(block(), phi,
a61af66fc99e Initial load
duke
parents:
diff changeset
1108 operand_for_instruction(phi));
a61af66fc99e Initial load
duke
parents:
diff changeset
1109
a61af66fc99e Initial load
duke
parents:
diff changeset
1110 LIR_Opr thread_reg = getThreadPointer();
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1111 __ move_wide(new LIR_Address(thread_reg, in_bytes(JavaThread::exception_oop_offset()), T_OBJECT),
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1112 exceptionOopOpr());
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1113 __ move_wide(LIR_OprFact::oopConst(NULL),
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1114 new LIR_Address(thread_reg, in_bytes(JavaThread::exception_oop_offset()), T_OBJECT));
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1115 __ move_wide(LIR_OprFact::oopConst(NULL),
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1116 new LIR_Address(thread_reg, in_bytes(JavaThread::exception_pc_offset()), T_OBJECT));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1117
a61af66fc99e Initial load
duke
parents:
diff changeset
1118 LIR_Opr result = new_register(T_OBJECT);
a61af66fc99e Initial load
duke
parents:
diff changeset
1119 __ move(exceptionOopOpr(), result);
a61af66fc99e Initial load
duke
parents:
diff changeset
1120 set_result(x, result);
a61af66fc99e Initial load
duke
parents:
diff changeset
1121 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1122
a61af66fc99e Initial load
duke
parents:
diff changeset
1123
a61af66fc99e Initial load
duke
parents:
diff changeset
1124 //----------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
1125 //----------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
1126 //----------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
1127 //----------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
1128 // visitor functions
a61af66fc99e Initial load
duke
parents:
diff changeset
1129 //----------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
1130 //----------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
1131 //----------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
1132 //----------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
1133
a61af66fc99e Initial load
duke
parents:
diff changeset
1134 void LIRGenerator::do_Phi(Phi* x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1135 // phi functions are never visited directly
a61af66fc99e Initial load
duke
parents:
diff changeset
1136 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1137 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1138
a61af66fc99e Initial load
duke
parents:
diff changeset
1139
a61af66fc99e Initial load
duke
parents:
diff changeset
1140 // Code for a constant is generated lazily unless the constant is frequently used and can't be inlined.
a61af66fc99e Initial load
duke
parents:
diff changeset
1141 void LIRGenerator::do_Constant(Constant* x) {
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1816
diff changeset
1142 if (x->state_before() != NULL) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1143 // Any constant with a ValueStack requires patching so emit the patch here
a61af66fc99e Initial load
duke
parents:
diff changeset
1144 LIR_Opr reg = rlock_result(x);
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1816
diff changeset
1145 CodeEmitInfo* info = state_for(x, x->state_before());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1146 __ oop2reg_patch(NULL, reg, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
1147 } else if (x->use_count() > 1 && !can_inline_as_constant(x)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1148 if (!x->is_pinned()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1149 // unpinned constants are handled specially so that they can be
a61af66fc99e Initial load
duke
parents:
diff changeset
1150 // put into registers when they are used multiple times within a
a61af66fc99e Initial load
duke
parents:
diff changeset
1151 // block. After the block completes their operand will be
a61af66fc99e Initial load
duke
parents:
diff changeset
1152 // cleared so that other blocks can't refer to that register.
a61af66fc99e Initial load
duke
parents:
diff changeset
1153 set_result(x, load_constant(x));
a61af66fc99e Initial load
duke
parents:
diff changeset
1154 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1155 LIR_Opr res = x->operand();
a61af66fc99e Initial load
duke
parents:
diff changeset
1156 if (!res->is_valid()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1157 res = LIR_OprFact::value_type(x->type());
a61af66fc99e Initial load
duke
parents:
diff changeset
1158 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1159 if (res->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1160 LIR_Opr reg = rlock_result(x);
a61af66fc99e Initial load
duke
parents:
diff changeset
1161 __ move(res, reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
1162 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1163 set_result(x, res);
a61af66fc99e Initial load
duke
parents:
diff changeset
1164 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1165 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1166 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1167 set_result(x, LIR_OprFact::value_type(x->type()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1168 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1169 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1170
a61af66fc99e Initial load
duke
parents:
diff changeset
1171
a61af66fc99e Initial load
duke
parents:
diff changeset
1172 void LIRGenerator::do_Local(Local* x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1173 // operand_for_instruction has the side effect of setting the result
a61af66fc99e Initial load
duke
parents:
diff changeset
1174 // so there's no need to do it here.
a61af66fc99e Initial load
duke
parents:
diff changeset
1175 operand_for_instruction(x);
a61af66fc99e Initial load
duke
parents:
diff changeset
1176 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1177
a61af66fc99e Initial load
duke
parents:
diff changeset
1178
a61af66fc99e Initial load
duke
parents:
diff changeset
1179 void LIRGenerator::do_IfInstanceOf(IfInstanceOf* x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1180 Unimplemented();
a61af66fc99e Initial load
duke
parents:
diff changeset
1181 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1182
a61af66fc99e Initial load
duke
parents:
diff changeset
1183
a61af66fc99e Initial load
duke
parents:
diff changeset
1184 void LIRGenerator::do_Return(Return* x) {
780
c96bf21b756f 6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents: 579
diff changeset
1185 if (compilation()->env()->dtrace_method_probes()) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1186 BasicTypeList signature;
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1187 signature.append(LP64_ONLY(T_LONG) NOT_LP64(T_INT)); // thread
12969
9acbfe04b5c3 8026495: JVM Crashes when started with -XX:+DTraceMethodProbes on Solaris x86_64
iveresov
parents: 12962
diff changeset
1188 signature.append(T_METADATA); // Method*
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1189 LIR_OprList* args = new LIR_OprList();
a61af66fc99e Initial load
duke
parents:
diff changeset
1190 args->append(getThreadPointer());
6739
8a02ca5e5576 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 6731
diff changeset
1191 LIR_Opr meth = new_register(T_METADATA);
8a02ca5e5576 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 6731
diff changeset
1192 __ metadata2reg(method()->constant_encoding(), meth);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1193 args->append(meth);
a61af66fc99e Initial load
duke
parents:
diff changeset
1194 call_runtime(&signature, args, CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit), voidType, NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
1195 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1196
a61af66fc99e Initial load
duke
parents:
diff changeset
1197 if (x->type()->is_void()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1198 __ return_op(LIR_OprFact::illegalOpr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1199 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1200 LIR_Opr reg = result_register_for(x->type(), /*callee=*/true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1201 LIRItem result(x->result(), this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1202
a61af66fc99e Initial load
duke
parents:
diff changeset
1203 result.load_item_force(reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
1204 __ return_op(result.result());
a61af66fc99e Initial load
duke
parents:
diff changeset
1205 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1206 set_no_result(x);
a61af66fc99e Initial load
duke
parents:
diff changeset
1207 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1208
3249
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1209 // Examble: ref.get()
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1210 // Combination of LoadField and g1 pre-write barrier
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1211 void LIRGenerator::do_Reference_get(Intrinsic* x) {
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1212
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1213 const int referent_offset = java_lang_ref_Reference::referent_offset;
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1214 guarantee(referent_offset > 0, "referent offset not initialized");
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1215
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1216 assert(x->number_of_arguments() == 1, "wrong type");
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1217
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1218 LIRItem reference(x->argument_at(0), this);
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1219 reference.load_item();
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1220
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1221 // need to perform the null check on the reference objecy
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1222 CodeEmitInfo* info = NULL;
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1223 if (x->needs_null_check()) {
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1224 info = state_for(x);
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1225 }
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1226
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1227 LIR_Address* referent_field_adr =
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1228 new LIR_Address(reference.result(), referent_offset, T_OBJECT);
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1229
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1230 LIR_Opr result = rlock_result(x);
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1231
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1232 __ load(referent_field_adr, result, info);
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1233
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1234 // Register the value in the referent field with the pre-barrier
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1235 pre_barrier(LIR_OprFact::illegalOpr /* addr_opr */,
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1236 result /* pre_val */,
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1237 false /* do_load */,
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1238 false /* patch */,
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1239 NULL /* info */);
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1240 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1241
6135
8f37087fc13f 7171890: C1: add Class.isInstance intrinsic
roland
parents: 6084
diff changeset
1242 // Example: clazz.isInstance(object)
8f37087fc13f 7171890: C1: add Class.isInstance intrinsic
roland
parents: 6084
diff changeset
1243 void LIRGenerator::do_isInstance(Intrinsic* x) {
8f37087fc13f 7171890: C1: add Class.isInstance intrinsic
roland
parents: 6084
diff changeset
1244 assert(x->number_of_arguments() == 2, "wrong type");
8f37087fc13f 7171890: C1: add Class.isInstance intrinsic
roland
parents: 6084
diff changeset
1245
8f37087fc13f 7171890: C1: add Class.isInstance intrinsic
roland
parents: 6084
diff changeset
1246 // TODO could try to substitute this node with an equivalent InstanceOf
8f37087fc13f 7171890: C1: add Class.isInstance intrinsic
roland
parents: 6084
diff changeset
1247 // if clazz is known to be a constant Class. This will pick up newly found
8f37087fc13f 7171890: C1: add Class.isInstance intrinsic
roland
parents: 6084
diff changeset
1248 // constants after HIR construction. I'll leave this to a future change.
8f37087fc13f 7171890: C1: add Class.isInstance intrinsic
roland
parents: 6084
diff changeset
1249
8f37087fc13f 7171890: C1: add Class.isInstance intrinsic
roland
parents: 6084
diff changeset
1250 // as a first cut, make a simple leaf call to runtime to stay platform independent.
8f37087fc13f 7171890: C1: add Class.isInstance intrinsic
roland
parents: 6084
diff changeset
1251 // could follow the aastore example in a future change.
8f37087fc13f 7171890: C1: add Class.isInstance intrinsic
roland
parents: 6084
diff changeset
1252
8f37087fc13f 7171890: C1: add Class.isInstance intrinsic
roland
parents: 6084
diff changeset
1253 LIRItem clazz(x->argument_at(0), this);
8f37087fc13f 7171890: C1: add Class.isInstance intrinsic
roland
parents: 6084
diff changeset
1254 LIRItem object(x->argument_at(1), this);
8f37087fc13f 7171890: C1: add Class.isInstance intrinsic
roland
parents: 6084
diff changeset
1255 clazz.load_item();
8f37087fc13f 7171890: C1: add Class.isInstance intrinsic
roland
parents: 6084
diff changeset
1256 object.load_item();
8f37087fc13f 7171890: C1: add Class.isInstance intrinsic
roland
parents: 6084
diff changeset
1257 LIR_Opr result = rlock_result(x);
8f37087fc13f 7171890: C1: add Class.isInstance intrinsic
roland
parents: 6084
diff changeset
1258
8f37087fc13f 7171890: C1: add Class.isInstance intrinsic
roland
parents: 6084
diff changeset
1259 // need to perform null check on clazz
8f37087fc13f 7171890: C1: add Class.isInstance intrinsic
roland
parents: 6084
diff changeset
1260 if (x->needs_null_check()) {
8f37087fc13f 7171890: C1: add Class.isInstance intrinsic
roland
parents: 6084
diff changeset
1261 CodeEmitInfo* info = state_for(x);
8f37087fc13f 7171890: C1: add Class.isInstance intrinsic
roland
parents: 6084
diff changeset
1262 __ null_check(clazz.result(), info);
8f37087fc13f 7171890: C1: add Class.isInstance intrinsic
roland
parents: 6084
diff changeset
1263 }
8f37087fc13f 7171890: C1: add Class.isInstance intrinsic
roland
parents: 6084
diff changeset
1264
8f37087fc13f 7171890: C1: add Class.isInstance intrinsic
roland
parents: 6084
diff changeset
1265 LIR_Opr call_result = call_runtime(clazz.value(), object.value(),
8f37087fc13f 7171890: C1: add Class.isInstance intrinsic
roland
parents: 6084
diff changeset
1266 CAST_FROM_FN_PTR(address, Runtime1::is_instance_of),
8f37087fc13f 7171890: C1: add Class.isInstance intrinsic
roland
parents: 6084
diff changeset
1267 x->type(),
8f37087fc13f 7171890: C1: add Class.isInstance intrinsic
roland
parents: 6084
diff changeset
1268 NULL); // NULL CodeEmitInfo results in a leaf call
8f37087fc13f 7171890: C1: add Class.isInstance intrinsic
roland
parents: 6084
diff changeset
1269 __ move(call_result, result);
8f37087fc13f 7171890: C1: add Class.isInstance intrinsic
roland
parents: 6084
diff changeset
1270 }
8f37087fc13f 7171890: C1: add Class.isInstance intrinsic
roland
parents: 6084
diff changeset
1271
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1272 // Example: object.getClass ()
a61af66fc99e Initial load
duke
parents:
diff changeset
1273 void LIRGenerator::do_getClass(Intrinsic* x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1274 assert(x->number_of_arguments() == 1, "wrong type");
a61af66fc99e Initial load
duke
parents:
diff changeset
1275
a61af66fc99e Initial load
duke
parents:
diff changeset
1276 LIRItem rcvr(x->argument_at(0), this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1277 rcvr.load_item();
12955
252d541466ea 8008242: VerifyOops is broken on SPARC
morris
parents: 12882
diff changeset
1278 LIR_Opr temp = new_register(T_METADATA);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1279 LIR_Opr result = rlock_result(x);
a61af66fc99e Initial load
duke
parents:
diff changeset
1280
a61af66fc99e Initial load
duke
parents:
diff changeset
1281 // need to perform the null check on the rcvr
a61af66fc99e Initial load
duke
parents:
diff changeset
1282 CodeEmitInfo* info = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
1283 if (x->needs_null_check()) {
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1816
diff changeset
1284 info = state_for(x);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1285 }
12955
252d541466ea 8008242: VerifyOops is broken on SPARC
morris
parents: 12882
diff changeset
1286
252d541466ea 8008242: VerifyOops is broken on SPARC
morris
parents: 12882
diff changeset
1287 // FIXME T_ADDRESS should actually be T_METADATA but it can't because the
252d541466ea 8008242: VerifyOops is broken on SPARC
morris
parents: 12882
diff changeset
1288 // meaning of these two is mixed up (see JDK-8026837).
252d541466ea 8008242: VerifyOops is broken on SPARC
morris
parents: 12882
diff changeset
1289 __ move(new LIR_Address(rcvr.result(), oopDesc::klass_offset_in_bytes(), T_ADDRESS), temp, info);
252d541466ea 8008242: VerifyOops is broken on SPARC
morris
parents: 12882
diff changeset
1290 __ move_wide(new LIR_Address(temp, in_bytes(Klass::java_mirror_offset()), T_OBJECT), result);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1291 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1292
a61af66fc99e Initial load
duke
parents:
diff changeset
1293
a61af66fc99e Initial load
duke
parents:
diff changeset
1294 // Example: Thread.currentThread()
a61af66fc99e Initial load
duke
parents:
diff changeset
1295 void LIRGenerator::do_currentThread(Intrinsic* x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1296 assert(x->number_of_arguments() == 0, "wrong type");
a61af66fc99e Initial load
duke
parents:
diff changeset
1297 LIR_Opr reg = rlock_result(x);
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
1298 __ move_wide(new LIR_Address(getThreadPointer(), in_bytes(JavaThread::threadObj_offset()), T_OBJECT), reg);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1299 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1300
a61af66fc99e Initial load
duke
parents:
diff changeset
1301
a61af66fc99e Initial load
duke
parents:
diff changeset
1302 void LIRGenerator::do_RegisterFinalizer(Intrinsic* x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1303 assert(x->number_of_arguments() == 1, "wrong type");
a61af66fc99e Initial load
duke
parents:
diff changeset
1304 LIRItem receiver(x->argument_at(0), this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1305
a61af66fc99e Initial load
duke
parents:
diff changeset
1306 receiver.load_item();
a61af66fc99e Initial load
duke
parents:
diff changeset
1307 BasicTypeList signature;
a61af66fc99e Initial load
duke
parents:
diff changeset
1308 signature.append(T_OBJECT); // receiver
a61af66fc99e Initial load
duke
parents:
diff changeset
1309 LIR_OprList* args = new LIR_OprList();
a61af66fc99e Initial load
duke
parents:
diff changeset
1310 args->append(receiver.result());
a61af66fc99e Initial load
duke
parents:
diff changeset
1311 CodeEmitInfo* info = state_for(x, x->state());
a61af66fc99e Initial load
duke
parents:
diff changeset
1312 call_runtime(&signature, args,
a61af66fc99e Initial load
duke
parents:
diff changeset
1313 CAST_FROM_FN_PTR(address, Runtime1::entry_for(Runtime1::register_finalizer_id)),
a61af66fc99e Initial load
duke
parents:
diff changeset
1314 voidType, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
1315
a61af66fc99e Initial load
duke
parents:
diff changeset
1316 set_no_result(x);
a61af66fc99e Initial load
duke
parents:
diff changeset
1317 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1318
a61af66fc99e Initial load
duke
parents:
diff changeset
1319
a61af66fc99e Initial load
duke
parents:
diff changeset
1320 //------------------------local access--------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
1321
a61af66fc99e Initial load
duke
parents:
diff changeset
1322 LIR_Opr LIRGenerator::operand_for_instruction(Instruction* x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1323 if (x->operand()->is_illegal()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1324 Constant* c = x->as_Constant();
a61af66fc99e Initial load
duke
parents:
diff changeset
1325 if (c != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1326 x->set_operand(LIR_OprFact::value_type(c->type()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1327 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1328 assert(x->as_Phi() || x->as_Local() != NULL, "only for Phi and Local");
a61af66fc99e Initial load
duke
parents:
diff changeset
1329 // allocate a virtual register for this local or phi
a61af66fc99e Initial load
duke
parents:
diff changeset
1330 x->set_operand(rlock(x));
a61af66fc99e Initial load
duke
parents:
diff changeset
1331 _instruction_for_operand.at_put_grow(x->operand()->vreg_number(), x, NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
1332 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1333 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1334 return x->operand();
a61af66fc99e Initial load
duke
parents:
diff changeset
1335 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1336
a61af66fc99e Initial load
duke
parents:
diff changeset
1337
a61af66fc99e Initial load
duke
parents:
diff changeset
1338 Instruction* LIRGenerator::instruction_for_opr(LIR_Opr opr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1339 if (opr->is_virtual()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1340 return instruction_for_vreg(opr->vreg_number());
a61af66fc99e Initial load
duke
parents:
diff changeset
1341 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1342 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
1343 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1344
a61af66fc99e Initial load
duke
parents:
diff changeset
1345
a61af66fc99e Initial load
duke
parents:
diff changeset
1346 Instruction* LIRGenerator::instruction_for_vreg(int reg_num) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1347 if (reg_num < _instruction_for_operand.length()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1348 return _instruction_for_operand.at(reg_num);
a61af66fc99e Initial load
duke
parents:
diff changeset
1349 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1350 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
1351 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1352
a61af66fc99e Initial load
duke
parents:
diff changeset
1353
a61af66fc99e Initial load
duke
parents:
diff changeset
1354 void LIRGenerator::set_vreg_flag(int vreg_num, VregFlag f) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1355 if (_vreg_flags.size_in_bits() == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1356 BitMap2D temp(100, num_vreg_flags);
a61af66fc99e Initial load
duke
parents:
diff changeset
1357 temp.clear();
a61af66fc99e Initial load
duke
parents:
diff changeset
1358 _vreg_flags = temp;
a61af66fc99e Initial load
duke
parents:
diff changeset
1359 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1360 _vreg_flags.at_put_grow(vreg_num, f, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1361 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1362
a61af66fc99e Initial load
duke
parents:
diff changeset
1363 bool LIRGenerator::is_vreg_flag_set(int vreg_num, VregFlag f) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1364 if (!_vreg_flags.is_valid_index(vreg_num, f)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1365 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
1366 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1367 return _vreg_flags.at(vreg_num, f);
a61af66fc99e Initial load
duke
parents:
diff changeset
1368 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1369
a61af66fc99e Initial load
duke
parents:
diff changeset
1370
a61af66fc99e Initial load
duke
parents:
diff changeset
1371 // Block local constant handling. This code is useful for keeping
a61af66fc99e Initial load
duke
parents:
diff changeset
1372 // unpinned constants and constants which aren't exposed in the IR in
a61af66fc99e Initial load
duke
parents:
diff changeset
1373 // registers. Unpinned Constant instructions have their operands
a61af66fc99e Initial load
duke
parents:
diff changeset
1374 // cleared when the block is finished so that other blocks can't end
a61af66fc99e Initial load
duke
parents:
diff changeset
1375 // up referring to their registers.
a61af66fc99e Initial load
duke
parents:
diff changeset
1376
a61af66fc99e Initial load
duke
parents:
diff changeset
1377 LIR_Opr LIRGenerator::load_constant(Constant* x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1378 assert(!x->is_pinned(), "only for unpinned constants");
a61af66fc99e Initial load
duke
parents:
diff changeset
1379 _unpinned_constants.append(x);
a61af66fc99e Initial load
duke
parents:
diff changeset
1380 return load_constant(LIR_OprFact::value_type(x->type())->as_constant_ptr());
a61af66fc99e Initial load
duke
parents:
diff changeset
1381 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1382
a61af66fc99e Initial load
duke
parents:
diff changeset
1383
a61af66fc99e Initial load
duke
parents:
diff changeset
1384 LIR_Opr LIRGenerator::load_constant(LIR_Const* c) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1385 BasicType t = c->type();
a61af66fc99e Initial load
duke
parents:
diff changeset
1386 for (int i = 0; i < _constants.length(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1387 LIR_Const* other = _constants.at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
1388 if (t == other->type()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1389 switch (t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1390 case T_INT:
a61af66fc99e Initial load
duke
parents:
diff changeset
1391 case T_FLOAT:
a61af66fc99e Initial load
duke
parents:
diff changeset
1392 if (c->as_jint_bits() != other->as_jint_bits()) continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
1393 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1394 case T_LONG:
a61af66fc99e Initial load
duke
parents:
diff changeset
1395 case T_DOUBLE:
486
a738a625039a 6757316: load_constant() produces a wrong long constant, with high a low words swapped
never
parents: 380
diff changeset
1396 if (c->as_jint_hi_bits() != other->as_jint_hi_bits()) continue;
a738a625039a 6757316: load_constant() produces a wrong long constant, with high a low words swapped
never
parents: 380
diff changeset
1397 if (c->as_jint_lo_bits() != other->as_jint_lo_bits()) continue;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1398 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1399 case T_OBJECT:
a61af66fc99e Initial load
duke
parents:
diff changeset
1400 if (c->as_jobject() != other->as_jobject()) continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
1401 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1402 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1403 return _reg_for_constants.at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
1404 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1405 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1406
a61af66fc99e Initial load
duke
parents:
diff changeset
1407 LIR_Opr result = new_register(t);
a61af66fc99e Initial load
duke
parents:
diff changeset
1408 __ move((LIR_Opr)c, result);
a61af66fc99e Initial load
duke
parents:
diff changeset
1409 _constants.append(c);
a61af66fc99e Initial load
duke
parents:
diff changeset
1410 _reg_for_constants.append(result);
a61af66fc99e Initial load
duke
parents:
diff changeset
1411 return result;
a61af66fc99e Initial load
duke
parents:
diff changeset
1412 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1413
a61af66fc99e Initial load
duke
parents:
diff changeset
1414 // Various barriers
a61af66fc99e Initial load
duke
parents:
diff changeset
1415
3249
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1416 void LIRGenerator::pre_barrier(LIR_Opr addr_opr, LIR_Opr pre_val,
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1417 bool do_load, bool patch, CodeEmitInfo* info) {
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1418 // Do the pre-write barrier, if any.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1419 switch (_bs->kind()) {
8001
db9981fd3124 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 7425
diff changeset
1420 #if INCLUDE_ALL_GCS
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1421 case BarrierSet::G1SATBCT:
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1422 case BarrierSet::G1SATBCTLogging:
3249
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1423 G1SATBCardTableModRef_pre_barrier(addr_opr, pre_val, do_load, patch, info);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1424 break;
8001
db9981fd3124 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 7425
diff changeset
1425 #endif // INCLUDE_ALL_GCS
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1426 case BarrierSet::CardTableModRef:
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1427 case BarrierSet::CardTableExtension:
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1428 // No pre barriers
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1429 break;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1430 case BarrierSet::ModRef:
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1431 case BarrierSet::Other:
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1432 // No pre barriers
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1433 break;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1434 default :
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1435 ShouldNotReachHere();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1436
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1437 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1438 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1439
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1440 void LIRGenerator::post_barrier(LIR_OprDesc* addr, LIR_OprDesc* new_val) {
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1441 switch (_bs->kind()) {
8001
db9981fd3124 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 7425
diff changeset
1442 #if INCLUDE_ALL_GCS
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1443 case BarrierSet::G1SATBCT:
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1444 case BarrierSet::G1SATBCTLogging:
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1445 G1SATBCardTableModRef_post_barrier(addr, new_val);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1446 break;
8001
db9981fd3124 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 7425
diff changeset
1447 #endif // INCLUDE_ALL_GCS
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1448 case BarrierSet::CardTableModRef:
a61af66fc99e Initial load
duke
parents:
diff changeset
1449 case BarrierSet::CardTableExtension:
a61af66fc99e Initial load
duke
parents:
diff changeset
1450 CardTableModRef_post_barrier(addr, new_val);
a61af66fc99e Initial load
duke
parents:
diff changeset
1451 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1452 case BarrierSet::ModRef:
a61af66fc99e Initial load
duke
parents:
diff changeset
1453 case BarrierSet::Other:
a61af66fc99e Initial load
duke
parents:
diff changeset
1454 // No post barriers
a61af66fc99e Initial load
duke
parents:
diff changeset
1455 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1456 default :
a61af66fc99e Initial load
duke
parents:
diff changeset
1457 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1458 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1459 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1460
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1461 ////////////////////////////////////////////////////////////////////////
8001
db9981fd3124 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 7425
diff changeset
1462 #if INCLUDE_ALL_GCS
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1463
3249
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1464 void LIRGenerator::G1SATBCardTableModRef_pre_barrier(LIR_Opr addr_opr, LIR_Opr pre_val,
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1465 bool do_load, bool patch, CodeEmitInfo* info) {
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1466 // First we test whether marking is in progress.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1467 BasicType flag_type;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1468 if (in_bytes(PtrQueue::byte_width_of_active()) == 4) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1469 flag_type = T_INT;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1470 } else {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1471 guarantee(in_bytes(PtrQueue::byte_width_of_active()) == 1,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1472 "Assumption");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1473 flag_type = T_BYTE;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1474 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1475 LIR_Opr thrd = getThreadPointer();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1476 LIR_Address* mark_active_flag_addr =
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1477 new LIR_Address(thrd,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1478 in_bytes(JavaThread::satb_mark_queue_offset() +
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1479 PtrQueue::byte_offset_of_active()),
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1480 flag_type);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1481 // Read the marking-in-progress flag.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1482 LIR_Opr flag_val = new_register(T_INT);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1483 __ load(mark_active_flag_addr, flag_val);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1484 __ cmp(lir_cond_notEqual, flag_val, LIR_OprFact::intConst(0));
3249
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1485
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1486 LIR_PatchCode pre_val_patch_code = lir_patch_none;
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1487
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1488 CodeStub* slow;
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1489
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1490 if (do_load) {
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1491 assert(pre_val == LIR_OprFact::illegalOpr, "sanity");
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1492 assert(addr_opr != LIR_OprFact::illegalOpr, "sanity");
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1493
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1494 if (patch)
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1495 pre_val_patch_code = lir_patch_normal;
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1496
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1497 pre_val = new_register(T_OBJECT);
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1498
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1499 if (!addr_opr->is_address()) {
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1500 assert(addr_opr->is_register(), "must be");
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1501 addr_opr = LIR_OprFact::address(new LIR_Address(addr_opr, T_OBJECT));
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1502 }
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1503 slow = new G1PreBarrierStub(addr_opr, pre_val, pre_val_patch_code, info);
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1504 } else {
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1505 assert(addr_opr == LIR_OprFact::illegalOpr, "sanity");
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1506 assert(pre_val->is_register(), "must be");
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1507 assert(pre_val->type() == T_OBJECT, "must be an object");
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1508 assert(info == NULL, "sanity");
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1509
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1510 slow = new G1PreBarrierStub(pre_val);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1511 }
3249
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1512
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1513 __ branch(lir_cond_notEqual, T_INT, slow);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1514 __ branch_destination(slow->continuation());
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1515 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1516
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1517 void LIRGenerator::G1SATBCardTableModRef_post_barrier(LIR_OprDesc* addr, LIR_OprDesc* new_val) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1518 // If the "new_val" is a constant NULL, no barrier is necessary.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1519 if (new_val->is_constant() &&
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1520 new_val->as_constant_ptr()->as_jobject() == NULL) return;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1521
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1522 if (!new_val->is_register()) {
1572
87fc6aca31ab 6955349: C1: Make G1 barriers work with x64
iveresov
parents: 1564
diff changeset
1523 LIR_Opr new_val_reg = new_register(T_OBJECT);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1524 if (new_val->is_constant()) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1525 __ move(new_val, new_val_reg);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1526 } else {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1527 __ leal(new_val, new_val_reg);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1528 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1529 new_val = new_val_reg;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1530 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1531 assert(new_val->is_register(), "must be a register at this point");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1532
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1533 if (addr->is_address()) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1534 LIR_Address* address = addr->as_address_ptr();
2464
d86923d96dca 7034967: C1: assert(false) failed: error (assembler_sparc.cpp:2043)
iveresov
parents: 2446
diff changeset
1535 LIR_Opr ptr = new_pointer_register();
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1536 if (!address->index()->is_valid() && address->disp() == 0) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1537 __ move(address->base(), ptr);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1538 } else {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1539 assert(address->disp() != max_jint, "lea doesn't support patched addresses!");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1540 __ leal(addr, ptr);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1541 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1542 addr = ptr;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1543 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1544 assert(addr->is_register(), "must be a register at this point");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1545
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1546 LIR_Opr xor_res = new_pointer_register();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1547 LIR_Opr xor_shift_res = new_pointer_register();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1548 if (TwoOperandLIRForm ) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1549 __ move(addr, xor_res);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1550 __ logical_xor(xor_res, new_val, xor_res);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1551 __ move(xor_res, xor_shift_res);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1552 __ unsigned_shift_right(xor_shift_res,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1553 LIR_OprFact::intConst(HeapRegion::LogOfHRGrainBytes),
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1554 xor_shift_res,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1555 LIR_OprDesc::illegalOpr());
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1556 } else {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1557 __ logical_xor(addr, new_val, xor_res);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1558 __ unsigned_shift_right(xor_res,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1559 LIR_OprFact::intConst(HeapRegion::LogOfHRGrainBytes),
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1560 xor_shift_res,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1561 LIR_OprDesc::illegalOpr());
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1562 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1563
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1564 if (!new_val->is_register()) {
1572
87fc6aca31ab 6955349: C1: Make G1 barriers work with x64
iveresov
parents: 1564
diff changeset
1565 LIR_Opr new_val_reg = new_register(T_OBJECT);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1566 __ leal(new_val, new_val_reg);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1567 new_val = new_val_reg;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1568 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1569 assert(new_val->is_register(), "must be a register at this point");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1570
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1571 __ cmp(lir_cond_notEqual, xor_shift_res, LIR_OprFact::intptrConst(NULL_WORD));
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1572
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1573 CodeStub* slow = new G1PostBarrierStub(addr, new_val);
1572
87fc6aca31ab 6955349: C1: Make G1 barriers work with x64
iveresov
parents: 1564
diff changeset
1574 __ branch(lir_cond_notEqual, LP64_ONLY(T_LONG) NOT_LP64(T_INT), slow);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1575 __ branch_destination(slow->continuation());
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1576 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1577
8001
db9981fd3124 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 7425
diff changeset
1578 #endif // INCLUDE_ALL_GCS
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1579 ////////////////////////////////////////////////////////////////////////
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1580
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1581 void LIRGenerator::CardTableModRef_post_barrier(LIR_OprDesc* addr, LIR_OprDesc* new_val) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1582
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1583 assert(sizeof(*((CardTableModRefBS*)_bs)->byte_map_base) == sizeof(jbyte), "adjust this code");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1584 LIR_Const* card_table_base = new LIR_Const(((CardTableModRefBS*)_bs)->byte_map_base);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1585 if (addr->is_address()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1586 LIR_Address* address = addr->as_address_ptr();
2464
d86923d96dca 7034967: C1: assert(false) failed: error (assembler_sparc.cpp:2043)
iveresov
parents: 2446
diff changeset
1587 // ptr cannot be an object because we use this barrier for array card marks
d86923d96dca 7034967: C1: assert(false) failed: error (assembler_sparc.cpp:2043)
iveresov
parents: 2446
diff changeset
1588 // and addr can point in the middle of an array.
d86923d96dca 7034967: C1: assert(false) failed: error (assembler_sparc.cpp:2043)
iveresov
parents: 2446
diff changeset
1589 LIR_Opr ptr = new_pointer_register();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1590 if (!address->index()->is_valid() && address->disp() == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1591 __ move(address->base(), ptr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1592 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1593 assert(address->disp() != max_jint, "lea doesn't support patched addresses!");
a61af66fc99e Initial load
duke
parents:
diff changeset
1594 __ leal(addr, ptr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1595 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1596 addr = ptr;
a61af66fc99e Initial load
duke
parents:
diff changeset
1597 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1598 assert(addr->is_register(), "must be a register at this point");
a61af66fc99e Initial load
duke
parents:
diff changeset
1599
22851
ddce0b7cee93 8072383: resolve conflicts between open and closed ports
dlong
parents: 22837
diff changeset
1600 #ifdef CARDTABLEMODREF_POST_BARRIER_HELPER
ddce0b7cee93 8072383: resolve conflicts between open and closed ports
dlong
parents: 22837
diff changeset
1601 CardTableModRef_post_barrier_helper(addr, card_table_base);
ddce0b7cee93 8072383: resolve conflicts between open and closed ports
dlong
parents: 22837
diff changeset
1602 #else
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1603 LIR_Opr tmp = new_pointer_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
1604 if (TwoOperandLIRForm) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1605 __ move(addr, tmp);
a61af66fc99e Initial load
duke
parents:
diff changeset
1606 __ unsigned_shift_right(tmp, CardTableModRefBS::card_shift, tmp);
a61af66fc99e Initial load
duke
parents:
diff changeset
1607 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1608 __ unsigned_shift_right(addr, CardTableModRefBS::card_shift, tmp);
a61af66fc99e Initial load
duke
parents:
diff changeset
1609 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1610 if (can_inline_as_constant(card_table_base)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1611 __ move(LIR_OprFact::intConst(0),
a61af66fc99e Initial load
duke
parents:
diff changeset
1612 new LIR_Address(tmp, card_table_base->as_jint(), T_BYTE));
a61af66fc99e Initial load
duke
parents:
diff changeset
1613 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1614 __ move(LIR_OprFact::intConst(0),
a61af66fc99e Initial load
duke
parents:
diff changeset
1615 new LIR_Address(tmp, load_constant(card_table_base),
a61af66fc99e Initial load
duke
parents:
diff changeset
1616 T_BYTE));
a61af66fc99e Initial load
duke
parents:
diff changeset
1617 }
22851
ddce0b7cee93 8072383: resolve conflicts between open and closed ports
dlong
parents: 22837
diff changeset
1618 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1619 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1620
a61af66fc99e Initial load
duke
parents:
diff changeset
1621
a61af66fc99e Initial load
duke
parents:
diff changeset
1622 //------------------------field access--------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
1623
a61af66fc99e Initial load
duke
parents:
diff changeset
1624 // Comment copied form templateTable_i486.cpp
a61af66fc99e Initial load
duke
parents:
diff changeset
1625 // ----------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
1626 // Volatile variables demand their effects be made known to all CPU's in
a61af66fc99e Initial load
duke
parents:
diff changeset
1627 // order. Store buffers on most chips allow reads & writes to reorder; the
a61af66fc99e Initial load
duke
parents:
diff changeset
1628 // JMM's ReadAfterWrite.java test fails in -Xint mode without some kind of
a61af66fc99e Initial load
duke
parents:
diff changeset
1629 // memory barrier (i.e., it's not sufficient that the interpreter does not
a61af66fc99e Initial load
duke
parents:
diff changeset
1630 // reorder volatile references, the hardware also must not reorder them).
a61af66fc99e Initial load
duke
parents:
diff changeset
1631 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1632 // According to the new Java Memory Model (JMM):
a61af66fc99e Initial load
duke
parents:
diff changeset
1633 // (1) All volatiles are serialized wrt to each other.
a61af66fc99e Initial load
duke
parents:
diff changeset
1634 // ALSO reads & writes act as aquire & release, so:
a61af66fc99e Initial load
duke
parents:
diff changeset
1635 // (2) A read cannot let unrelated NON-volatile memory refs that happen after
a61af66fc99e Initial load
duke
parents:
diff changeset
1636 // the read float up to before the read. It's OK for non-volatile memory refs
a61af66fc99e Initial load
duke
parents:
diff changeset
1637 // that happen before the volatile read to float down below it.
a61af66fc99e Initial load
duke
parents:
diff changeset
1638 // (3) Similar a volatile write cannot let unrelated NON-volatile memory refs
a61af66fc99e Initial load
duke
parents:
diff changeset
1639 // that happen BEFORE the write float down to after the write. It's OK for
a61af66fc99e Initial load
duke
parents:
diff changeset
1640 // non-volatile memory refs that happen after the volatile write to float up
a61af66fc99e Initial load
duke
parents:
diff changeset
1641 // before it.
a61af66fc99e Initial load
duke
parents:
diff changeset
1642 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1643 // We only put in barriers around volatile refs (they are expensive), not
a61af66fc99e Initial load
duke
parents:
diff changeset
1644 // _between_ memory refs (that would require us to track the flavor of the
a61af66fc99e Initial load
duke
parents:
diff changeset
1645 // previous memory refs). Requirements (2) and (3) require some barriers
a61af66fc99e Initial load
duke
parents:
diff changeset
1646 // before volatile stores and after volatile loads. These nearly cover
a61af66fc99e Initial load
duke
parents:
diff changeset
1647 // requirement (1) but miss the volatile-store-volatile-load case. This final
a61af66fc99e Initial load
duke
parents:
diff changeset
1648 // case is placed after volatile-stores although it could just as well go
a61af66fc99e Initial load
duke
parents:
diff changeset
1649 // before volatile-loads.
a61af66fc99e Initial load
duke
parents:
diff changeset
1650
a61af66fc99e Initial load
duke
parents:
diff changeset
1651
a61af66fc99e Initial load
duke
parents:
diff changeset
1652 void LIRGenerator::do_StoreField(StoreField* x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1653 bool needs_patching = x->needs_patching();
a61af66fc99e Initial load
duke
parents:
diff changeset
1654 bool is_volatile = x->field()->is_volatile();
a61af66fc99e Initial load
duke
parents:
diff changeset
1655 BasicType field_type = x->field_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
1656 bool is_oop = (field_type == T_ARRAY || field_type == T_OBJECT);
a61af66fc99e Initial load
duke
parents:
diff changeset
1657
a61af66fc99e Initial load
duke
parents:
diff changeset
1658 CodeEmitInfo* info = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
1659 if (needs_patching) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1660 assert(x->explicit_null_check() == NULL, "can't fold null check into patching field access");
a61af66fc99e Initial load
duke
parents:
diff changeset
1661 info = state_for(x, x->state_before());
a61af66fc99e Initial load
duke
parents:
diff changeset
1662 } else if (x->needs_null_check()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1663 NullCheck* nc = x->explicit_null_check();
a61af66fc99e Initial load
duke
parents:
diff changeset
1664 if (nc == NULL) {
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1816
diff changeset
1665 info = state_for(x);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1666 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1667 info = state_for(nc);
a61af66fc99e Initial load
duke
parents:
diff changeset
1668 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1669 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1670
a61af66fc99e Initial load
duke
parents:
diff changeset
1671
a61af66fc99e Initial load
duke
parents:
diff changeset
1672 LIRItem object(x->obj(), this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1673 LIRItem value(x->value(), this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1674
a61af66fc99e Initial load
duke
parents:
diff changeset
1675 object.load_item();
a61af66fc99e Initial load
duke
parents:
diff changeset
1676
a61af66fc99e Initial load
duke
parents:
diff changeset
1677 if (is_volatile || needs_patching) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1678 // load item if field is volatile (fewer special cases for volatiles)
a61af66fc99e Initial load
duke
parents:
diff changeset
1679 // load item if field not initialized
a61af66fc99e Initial load
duke
parents:
diff changeset
1680 // load item if field not constant
a61af66fc99e Initial load
duke
parents:
diff changeset
1681 // because of code patching we cannot inline constants
a61af66fc99e Initial load
duke
parents:
diff changeset
1682 if (field_type == T_BYTE || field_type == T_BOOLEAN) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1683 value.load_byte_item();
a61af66fc99e Initial load
duke
parents:
diff changeset
1684 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1685 value.load_item();
a61af66fc99e Initial load
duke
parents:
diff changeset
1686 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1687 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1688 value.load_for_store(field_type);
a61af66fc99e Initial load
duke
parents:
diff changeset
1689 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1690
a61af66fc99e Initial load
duke
parents:
diff changeset
1691 set_no_result(x);
a61af66fc99e Initial load
duke
parents:
diff changeset
1692
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1816
diff changeset
1693 #ifndef PRODUCT
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1694 if (PrintNotLoaded && needs_patching) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1695 tty->print_cr(" ###class not loaded at store_%s bci %d",
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1816
diff changeset
1696 x->is_static() ? "static" : "field", x->printable_bci());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1697 }
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1816
diff changeset
1698 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1699
a61af66fc99e Initial load
duke
parents:
diff changeset
1700 if (x->needs_null_check() &&
a61af66fc99e Initial load
duke
parents:
diff changeset
1701 (needs_patching ||
a61af66fc99e Initial load
duke
parents:
diff changeset
1702 MacroAssembler::needs_explicit_null_check(x->offset()))) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1703 // emit an explicit null check because the offset is too large
a61af66fc99e Initial load
duke
parents:
diff changeset
1704 __ null_check(object.result(), new CodeEmitInfo(info));
a61af66fc99e Initial load
duke
parents:
diff changeset
1705 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1706
a61af66fc99e Initial load
duke
parents:
diff changeset
1707 LIR_Address* address;
a61af66fc99e Initial load
duke
parents:
diff changeset
1708 if (needs_patching) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1709 // we need to patch the offset in the instruction so don't allow
a61af66fc99e Initial load
duke
parents:
diff changeset
1710 // generate_address to try to be smart about emitting the -1.
a61af66fc99e Initial load
duke
parents:
diff changeset
1711 // Otherwise the patching code won't know how to find the
a61af66fc99e Initial load
duke
parents:
diff changeset
1712 // instruction to patch.
1681
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1584
diff changeset
1713 address = new LIR_Address(object.result(), PATCHED_ADDR, field_type);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1714 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1715 address = generate_address(object.result(), x->offset(), field_type);
a61af66fc99e Initial load
duke
parents:
diff changeset
1716 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1717
a61af66fc99e Initial load
duke
parents:
diff changeset
1718 if (is_volatile && os::is_MP()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1719 __ membar_release();
a61af66fc99e Initial load
duke
parents:
diff changeset
1720 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1721
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1722 if (is_oop) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1723 // Do the pre-write barrier, if any.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1724 pre_barrier(LIR_OprFact::address(address),
3249
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1725 LIR_OprFact::illegalOpr /* pre_val */,
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
1726 true /* do_load*/,
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1727 needs_patching,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1728 (info ? new CodeEmitInfo(info) : NULL));
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1729 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
1730
2352
425688247f3d 6965570: assert(!needs_patching && x->is_loaded(),"how do we know it's volatile if it's not loaded")
never
parents: 2167
diff changeset
1731 if (is_volatile && !needs_patching) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1732 volatile_field_store(value.result(), address, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
1733 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1734 LIR_PatchCode patch_code = needs_patching ? lir_patch_normal : lir_patch_none;
a61af66fc99e Initial load
duke
parents:
diff changeset
1735 __ store(value.result(), address, info, patch_code);
a61af66fc99e Initial load
duke
parents:
diff changeset
1736 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1737
a61af66fc99e Initial load
duke
parents:
diff changeset
1738 if (is_oop) {
819
c6386080541b 6849574: VM crash using NonBlockingHashMap (high_scale_lib)
never
parents: 780
diff changeset
1739 // Store to object so mark the card of the header
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1740 post_barrier(object.result(), value.result());
a61af66fc99e Initial load
duke
parents:
diff changeset
1741 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1742
a61af66fc99e Initial load
duke
parents:
diff changeset
1743 if (is_volatile && os::is_MP()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1744 __ membar();
a61af66fc99e Initial load
duke
parents:
diff changeset
1745 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1746 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1747
a61af66fc99e Initial load
duke
parents:
diff changeset
1748
a61af66fc99e Initial load
duke
parents:
diff changeset
1749 void LIRGenerator::do_LoadField(LoadField* x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1750 bool needs_patching = x->needs_patching();
a61af66fc99e Initial load
duke
parents:
diff changeset
1751 bool is_volatile = x->field()->is_volatile();
a61af66fc99e Initial load
duke
parents:
diff changeset
1752 BasicType field_type = x->field_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
1753
a61af66fc99e Initial load
duke
parents:
diff changeset
1754 CodeEmitInfo* info = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
1755 if (needs_patching) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1756 assert(x->explicit_null_check() == NULL, "can't fold null check into patching field access");
a61af66fc99e Initial load
duke
parents:
diff changeset
1757 info = state_for(x, x->state_before());
a61af66fc99e Initial load
duke
parents:
diff changeset
1758 } else if (x->needs_null_check()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1759 NullCheck* nc = x->explicit_null_check();
a61af66fc99e Initial load
duke
parents:
diff changeset
1760 if (nc == NULL) {
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1816
diff changeset
1761 info = state_for(x);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1762 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1763 info = state_for(nc);
a61af66fc99e Initial load
duke
parents:
diff changeset
1764 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1765 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1766
a61af66fc99e Initial load
duke
parents:
diff changeset
1767 LIRItem object(x->obj(), this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1768
a61af66fc99e Initial load
duke
parents:
diff changeset
1769 object.load_item();
a61af66fc99e Initial load
duke
parents:
diff changeset
1770
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1816
diff changeset
1771 #ifndef PRODUCT
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1772 if (PrintNotLoaded && needs_patching) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1773 tty->print_cr(" ###class not loaded at load_%s bci %d",
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1816
diff changeset
1774 x->is_static() ? "static" : "field", x->printable_bci());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1775 }
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1816
diff changeset
1776 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1777
8860
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
1778 bool stress_deopt = StressLoopInvariantCodeMotion && info && info->deoptimize_on_exception();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1779 if (x->needs_null_check() &&
a61af66fc99e Initial load
duke
parents:
diff changeset
1780 (needs_patching ||
8860
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
1781 MacroAssembler::needs_explicit_null_check(x->offset()) ||
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
1782 stress_deopt)) {
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
1783 LIR_Opr obj = object.result();
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
1784 if (stress_deopt) {
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
1785 obj = new_register(T_OBJECT);
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
1786 __ move(LIR_OprFact::oopConst(NULL), obj);
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
1787 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1788 // emit an explicit null check because the offset is too large
8860
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
1789 __ null_check(obj, new CodeEmitInfo(info));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1790 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1791
a61af66fc99e Initial load
duke
parents:
diff changeset
1792 LIR_Opr reg = rlock_result(x, field_type);
a61af66fc99e Initial load
duke
parents:
diff changeset
1793 LIR_Address* address;
a61af66fc99e Initial load
duke
parents:
diff changeset
1794 if (needs_patching) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1795 // we need to patch the offset in the instruction so don't allow
a61af66fc99e Initial load
duke
parents:
diff changeset
1796 // generate_address to try to be smart about emitting the -1.
a61af66fc99e Initial load
duke
parents:
diff changeset
1797 // Otherwise the patching code won't know how to find the
a61af66fc99e Initial load
duke
parents:
diff changeset
1798 // instruction to patch.
1681
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1584
diff changeset
1799 address = new LIR_Address(object.result(), PATCHED_ADDR, field_type);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1800 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1801 address = generate_address(object.result(), x->offset(), field_type);
a61af66fc99e Initial load
duke
parents:
diff changeset
1802 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1803
2352
425688247f3d 6965570: assert(!needs_patching && x->is_loaded(),"how do we know it's volatile if it's not loaded")
never
parents: 2167
diff changeset
1804 if (is_volatile && !needs_patching) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1805 volatile_field_load(address, reg, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
1806 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1807 LIR_PatchCode patch_code = needs_patching ? lir_patch_normal : lir_patch_none;
a61af66fc99e Initial load
duke
parents:
diff changeset
1808 __ load(address, reg, info, patch_code);
a61af66fc99e Initial load
duke
parents:
diff changeset
1809 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1810
a61af66fc99e Initial load
duke
parents:
diff changeset
1811 if (is_volatile && os::is_MP()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1812 __ membar_acquire();
a61af66fc99e Initial load
duke
parents:
diff changeset
1813 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1814 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1815
a61af66fc99e Initial load
duke
parents:
diff changeset
1816
a61af66fc99e Initial load
duke
parents:
diff changeset
1817 //------------------------java.nio.Buffer.checkIndex------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
1818
a61af66fc99e Initial load
duke
parents:
diff changeset
1819 // int java.nio.Buffer.checkIndex(int)
a61af66fc99e Initial load
duke
parents:
diff changeset
1820 void LIRGenerator::do_NIOCheckIndex(Intrinsic* x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1821 // NOTE: by the time we are in checkIndex() we are guaranteed that
a61af66fc99e Initial load
duke
parents:
diff changeset
1822 // the buffer is non-null (because checkIndex is package-private and
a61af66fc99e Initial load
duke
parents:
diff changeset
1823 // only called from within other methods in the buffer).
a61af66fc99e Initial load
duke
parents:
diff changeset
1824 assert(x->number_of_arguments() == 2, "wrong type");
a61af66fc99e Initial load
duke
parents:
diff changeset
1825 LIRItem buf (x->argument_at(0), this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1826 LIRItem index(x->argument_at(1), this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1827 buf.load_item();
a61af66fc99e Initial load
duke
parents:
diff changeset
1828 index.load_item();
a61af66fc99e Initial load
duke
parents:
diff changeset
1829
a61af66fc99e Initial load
duke
parents:
diff changeset
1830 LIR_Opr result = rlock_result(x);
a61af66fc99e Initial load
duke
parents:
diff changeset
1831 if (GenerateRangeChecks) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1832 CodeEmitInfo* info = state_for(x);
a61af66fc99e Initial load
duke
parents:
diff changeset
1833 CodeStub* stub = new RangeCheckStub(info, index.result(), true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1834 if (index.result()->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1835 cmp_mem_int(lir_cond_belowEqual, buf.result(), java_nio_Buffer::limit_offset(), index.result()->as_jint(), info);
a61af66fc99e Initial load
duke
parents:
diff changeset
1836 __ branch(lir_cond_belowEqual, T_INT, stub);
a61af66fc99e Initial load
duke
parents:
diff changeset
1837 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1838 cmp_reg_mem(lir_cond_aboveEqual, index.result(), buf.result(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1839 java_nio_Buffer::limit_offset(), T_INT, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
1840 __ branch(lir_cond_aboveEqual, T_INT, stub);
a61af66fc99e Initial load
duke
parents:
diff changeset
1841 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1842 __ move(index.result(), result);
a61af66fc99e Initial load
duke
parents:
diff changeset
1843 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1844 // Just load the index into the result register
a61af66fc99e Initial load
duke
parents:
diff changeset
1845 __ move(index.result(), result);
a61af66fc99e Initial load
duke
parents:
diff changeset
1846 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1847 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1848
a61af66fc99e Initial load
duke
parents:
diff changeset
1849
a61af66fc99e Initial load
duke
parents:
diff changeset
1850 //------------------------array access--------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
1851
a61af66fc99e Initial load
duke
parents:
diff changeset
1852
a61af66fc99e Initial load
duke
parents:
diff changeset
1853 void LIRGenerator::do_ArrayLength(ArrayLength* x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1854 LIRItem array(x->array(), this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1855 array.load_item();
a61af66fc99e Initial load
duke
parents:
diff changeset
1856 LIR_Opr reg = rlock_result(x);
a61af66fc99e Initial load
duke
parents:
diff changeset
1857
a61af66fc99e Initial load
duke
parents:
diff changeset
1858 CodeEmitInfo* info = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
1859 if (x->needs_null_check()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1860 NullCheck* nc = x->explicit_null_check();
a61af66fc99e Initial load
duke
parents:
diff changeset
1861 if (nc == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1862 info = state_for(x);
a61af66fc99e Initial load
duke
parents:
diff changeset
1863 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1864 info = state_for(nc);
a61af66fc99e Initial load
duke
parents:
diff changeset
1865 }
8860
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
1866 if (StressLoopInvariantCodeMotion && info->deoptimize_on_exception()) {
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
1867 LIR_Opr obj = new_register(T_OBJECT);
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
1868 __ move(LIR_OprFact::oopConst(NULL), obj);
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
1869 __ null_check(obj, new CodeEmitInfo(info));
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
1870 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1871 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1872 __ load(new LIR_Address(array.result(), arrayOopDesc::length_offset_in_bytes(), T_INT), reg, info, lir_patch_none);
a61af66fc99e Initial load
duke
parents:
diff changeset
1873 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1874
a61af66fc99e Initial load
duke
parents:
diff changeset
1875
a61af66fc99e Initial load
duke
parents:
diff changeset
1876 void LIRGenerator::do_LoadIndexed(LoadIndexed* x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1877 bool use_length = x->length() != NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
1878 LIRItem array(x->array(), this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1879 LIRItem index(x->index(), this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1880 LIRItem length(this);
8860
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
1881 bool needs_range_check = x->compute_needs_range_check();
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
1882
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
1883 if (use_length && needs_range_check) {
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
1884 length.set_instruction(x->length());
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
1885 length.load_item();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1886 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1887
a61af66fc99e Initial load
duke
parents:
diff changeset
1888 array.load_item();
a61af66fc99e Initial load
duke
parents:
diff changeset
1889 if (index.is_constant() && can_inline_as_constant(x->index())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1890 // let it be a constant
a61af66fc99e Initial load
duke
parents:
diff changeset
1891 index.dont_load_item();
a61af66fc99e Initial load
duke
parents:
diff changeset
1892 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1893 index.load_item();
a61af66fc99e Initial load
duke
parents:
diff changeset
1894 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1895
a61af66fc99e Initial load
duke
parents:
diff changeset
1896 CodeEmitInfo* range_check_info = state_for(x);
a61af66fc99e Initial load
duke
parents:
diff changeset
1897 CodeEmitInfo* null_check_info = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
1898 if (x->needs_null_check()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1899 NullCheck* nc = x->explicit_null_check();
a61af66fc99e Initial load
duke
parents:
diff changeset
1900 if (nc != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1901 null_check_info = state_for(nc);
a61af66fc99e Initial load
duke
parents:
diff changeset
1902 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1903 null_check_info = range_check_info;
a61af66fc99e Initial load
duke
parents:
diff changeset
1904 }
8860
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
1905 if (StressLoopInvariantCodeMotion && null_check_info->deoptimize_on_exception()) {
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
1906 LIR_Opr obj = new_register(T_OBJECT);
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
1907 __ move(LIR_OprFact::oopConst(NULL), obj);
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
1908 __ null_check(obj, new CodeEmitInfo(null_check_info));
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
1909 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1910 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1911
a61af66fc99e Initial load
duke
parents:
diff changeset
1912 // emit array address setup early so it schedules better
a61af66fc99e Initial load
duke
parents:
diff changeset
1913 LIR_Address* array_addr = emit_array_address(array.result(), index.result(), x->elt_type(), false);
a61af66fc99e Initial load
duke
parents:
diff changeset
1914
a61af66fc99e Initial load
duke
parents:
diff changeset
1915 if (GenerateRangeChecks && needs_range_check) {
8860
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
1916 if (StressLoopInvariantCodeMotion && range_check_info->deoptimize_on_exception()) {
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
1917 __ branch(lir_cond_always, T_ILLEGAL, new RangeCheckStub(range_check_info, index.result()));
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
1918 } else if (use_length) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1919 // TODO: use a (modified) version of array_range_check that does not require a
a61af66fc99e Initial load
duke
parents:
diff changeset
1920 // constant length to be loaded to a register
a61af66fc99e Initial load
duke
parents:
diff changeset
1921 __ cmp(lir_cond_belowEqual, length.result(), index.result());
a61af66fc99e Initial load
duke
parents:
diff changeset
1922 __ branch(lir_cond_belowEqual, T_INT, new RangeCheckStub(range_check_info, index.result()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1923 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1924 array_range_check(array.result(), index.result(), null_check_info, range_check_info);
a61af66fc99e Initial load
duke
parents:
diff changeset
1925 // The range check performs the null check, so clear it out for the load
a61af66fc99e Initial load
duke
parents:
diff changeset
1926 null_check_info = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
1927 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1928 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1929
a61af66fc99e Initial load
duke
parents:
diff changeset
1930 __ move(array_addr, rlock_result(x, x->elt_type()), null_check_info);
a61af66fc99e Initial load
duke
parents:
diff changeset
1931 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1932
a61af66fc99e Initial load
duke
parents:
diff changeset
1933
a61af66fc99e Initial load
duke
parents:
diff changeset
1934 void LIRGenerator::do_NullCheck(NullCheck* x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1935 if (x->can_trap()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1936 LIRItem value(x->obj(), this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1937 value.load_item();
a61af66fc99e Initial load
duke
parents:
diff changeset
1938 CodeEmitInfo* info = state_for(x);
a61af66fc99e Initial load
duke
parents:
diff changeset
1939 __ null_check(value.result(), info);
a61af66fc99e Initial load
duke
parents:
diff changeset
1940 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1941 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1942
a61af66fc99e Initial load
duke
parents:
diff changeset
1943
6266
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 6145
diff changeset
1944 void LIRGenerator::do_TypeCast(TypeCast* x) {
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 6145
diff changeset
1945 LIRItem value(x->obj(), this);
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 6145
diff changeset
1946 value.load_item();
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 6145
diff changeset
1947 // the result is the same as from the node we are casting
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 6145
diff changeset
1948 set_result(x, value.result());
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 6145
diff changeset
1949 }
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 6145
diff changeset
1950
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 6145
diff changeset
1951
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1952 void LIRGenerator::do_Throw(Throw* x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1953 LIRItem exception(x->exception(), this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1954 exception.load_item();
a61af66fc99e Initial load
duke
parents:
diff changeset
1955 set_no_result(x);
a61af66fc99e Initial load
duke
parents:
diff changeset
1956 LIR_Opr exception_opr = exception.result();
a61af66fc99e Initial load
duke
parents:
diff changeset
1957 CodeEmitInfo* info = state_for(x, x->state());
a61af66fc99e Initial load
duke
parents:
diff changeset
1958
a61af66fc99e Initial load
duke
parents:
diff changeset
1959 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
1960 if (PrintC1Statistics) {
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
1961 increment_counter(Runtime1::throw_count_address(), T_INT);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1962 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1963 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
1964
a61af66fc99e Initial load
duke
parents:
diff changeset
1965 // check if the instruction has an xhandler in any of the nested scopes
a61af66fc99e Initial load
duke
parents:
diff changeset
1966 bool unwind = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
1967 if (info->exception_handlers()->length() == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1968 // this throw is not inside an xhandler
a61af66fc99e Initial load
duke
parents:
diff changeset
1969 unwind = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
1970 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1971 // get some idea of the throw type
a61af66fc99e Initial load
duke
parents:
diff changeset
1972 bool type_is_exact = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
1973 ciType* throw_type = x->exception()->exact_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
1974 if (throw_type == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1975 type_is_exact = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
1976 throw_type = x->exception()->declared_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
1977 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1978 if (throw_type != NULL && throw_type->is_instance_klass()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1979 ciInstanceKlass* throw_klass = (ciInstanceKlass*)throw_type;
a61af66fc99e Initial load
duke
parents:
diff changeset
1980 unwind = !x->exception_handlers()->could_catch(throw_klass, type_is_exact);
a61af66fc99e Initial load
duke
parents:
diff changeset
1981 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1982 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1983
a61af66fc99e Initial load
duke
parents:
diff changeset
1984 // do null check before moving exception oop into fixed register
a61af66fc99e Initial load
duke
parents:
diff changeset
1985 // to avoid a fixed interval with an oop during the null check.
a61af66fc99e Initial load
duke
parents:
diff changeset
1986 // Use a copy of the CodeEmitInfo because debug information is
a61af66fc99e Initial load
duke
parents:
diff changeset
1987 // different for null_check and throw.
a61af66fc99e Initial load
duke
parents:
diff changeset
1988 if (GenerateCompilerNullChecks &&
a61af66fc99e Initial load
duke
parents:
diff changeset
1989 (x->exception()->as_NewInstance() == NULL && x->exception()->as_ExceptionObject() == NULL)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1990 // if the exception object wasn't created using new then it might be null.
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1816
diff changeset
1991 __ null_check(exception_opr, new CodeEmitInfo(info, x->state()->copy(ValueStack::ExceptionState, x->state()->bci())));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1992 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1993
1378
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1304
diff changeset
1994 if (compilation()->env()->jvmti_can_post_on_exceptions()) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1995 // we need to go through the exception lookup path to get JVMTI
a61af66fc99e Initial load
duke
parents:
diff changeset
1996 // notification done
a61af66fc99e Initial load
duke
parents:
diff changeset
1997 unwind = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
1998 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1999
a61af66fc99e Initial load
duke
parents:
diff changeset
2000 // move exception oop into fixed register
a61af66fc99e Initial load
duke
parents:
diff changeset
2001 __ move(exception_opr, exceptionOopOpr());
a61af66fc99e Initial load
duke
parents:
diff changeset
2002
a61af66fc99e Initial load
duke
parents:
diff changeset
2003 if (unwind) {
1378
9f5b60a14736 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 1304
diff changeset
2004 __ unwind_exception(exceptionOopOpr());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2005 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2006 __ throw_exception(exceptionPcOpr(), exceptionOopOpr(), info);
a61af66fc99e Initial load
duke
parents:
diff changeset
2007 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2008 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2009
a61af66fc99e Initial load
duke
parents:
diff changeset
2010
a61af66fc99e Initial load
duke
parents:
diff changeset
2011 void LIRGenerator::do_RoundFP(RoundFP* x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2012 LIRItem input(x->input(), this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2013 input.load_item();
a61af66fc99e Initial load
duke
parents:
diff changeset
2014 LIR_Opr input_opr = input.result();
a61af66fc99e Initial load
duke
parents:
diff changeset
2015 assert(input_opr->is_register(), "why round if value is not in a register?");
a61af66fc99e Initial load
duke
parents:
diff changeset
2016 assert(input_opr->is_single_fpu() || input_opr->is_double_fpu(), "input should be floating-point value");
a61af66fc99e Initial load
duke
parents:
diff changeset
2017 if (input_opr->is_single_fpu()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2018 set_result(x, round_item(input_opr)); // This code path not currently taken
a61af66fc99e Initial load
duke
parents:
diff changeset
2019 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2020 LIR_Opr result = new_register(T_DOUBLE);
a61af66fc99e Initial load
duke
parents:
diff changeset
2021 set_vreg_flag(result, must_start_in_memory);
a61af66fc99e Initial load
duke
parents:
diff changeset
2022 __ roundfp(input_opr, LIR_OprFact::illegalOpr, result);
a61af66fc99e Initial load
duke
parents:
diff changeset
2023 set_result(x, result);
a61af66fc99e Initial load
duke
parents:
diff changeset
2024 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2025 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2026
20491
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2027 // Here UnsafeGetRaw may have x->base() and x->index() be int or long
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2028 // on both 64 and 32 bits. Expecting x->base() to be always long on 64bit.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2029 void LIRGenerator::do_UnsafeGetRaw(UnsafeGetRaw* x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2030 LIRItem base(x->base(), this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2031 LIRItem idx(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2032
a61af66fc99e Initial load
duke
parents:
diff changeset
2033 base.load_item();
a61af66fc99e Initial load
duke
parents:
diff changeset
2034 if (x->has_index()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2035 idx.set_instruction(x->index());
a61af66fc99e Initial load
duke
parents:
diff changeset
2036 idx.load_nonconstant();
a61af66fc99e Initial load
duke
parents:
diff changeset
2037 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2038
a61af66fc99e Initial load
duke
parents:
diff changeset
2039 LIR_Opr reg = rlock_result(x, x->basic_type());
a61af66fc99e Initial load
duke
parents:
diff changeset
2040
a61af66fc99e Initial load
duke
parents:
diff changeset
2041 int log2_scale = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
2042 if (x->has_index()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2043 log2_scale = x->log2_scale();
a61af66fc99e Initial load
duke
parents:
diff changeset
2044 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2045
a61af66fc99e Initial load
duke
parents:
diff changeset
2046 assert(!x->has_index() || idx.value() == x->index(), "should match");
a61af66fc99e Initial load
duke
parents:
diff changeset
2047
a61af66fc99e Initial load
duke
parents:
diff changeset
2048 LIR_Opr base_op = base.result();
20491
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2049 LIR_Opr index_op = idx.result();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2050 #ifndef _LP64
20519
b29261b17343 8059621: JVM crashes with "unexpected index type" assert in LIRGenerator::do_UnsafeGetRaw
iveresov
parents: 20491
diff changeset
2051 if (base_op->type() == T_LONG) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2052 base_op = new_register(T_INT);
a61af66fc99e Initial load
duke
parents:
diff changeset
2053 __ convert(Bytecodes::_l2i, base.result(), base_op);
20491
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2054 }
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2055 if (x->has_index()) {
20519
b29261b17343 8059621: JVM crashes with "unexpected index type" assert in LIRGenerator::do_UnsafeGetRaw
iveresov
parents: 20491
diff changeset
2056 if (index_op->type() == T_LONG) {
20491
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2057 LIR_Opr long_index_op = index_op;
20519
b29261b17343 8059621: JVM crashes with "unexpected index type" assert in LIRGenerator::do_UnsafeGetRaw
iveresov
parents: 20491
diff changeset
2058 if (index_op->is_constant()) {
20491
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2059 long_index_op = new_register(T_LONG);
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2060 __ move(index_op, long_index_op);
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2061 }
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2062 index_op = new_register(T_INT);
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2063 __ convert(Bytecodes::_l2i, long_index_op, index_op);
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2064 } else {
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2065 assert(x->index()->type()->tag() == intTag, "must be");
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2066 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2067 }
20491
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2068 // At this point base and index should be all ints.
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2069 assert(base_op->type() == T_INT && !base_op->is_constant(), "base should be an non-constant int");
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2070 assert(!x->has_index() || index_op->type() == T_INT, "index should be an int");
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2071 #else
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2072 if (x->has_index()) {
20519
b29261b17343 8059621: JVM crashes with "unexpected index type" assert in LIRGenerator::do_UnsafeGetRaw
iveresov
parents: 20491
diff changeset
2073 if (index_op->type() == T_INT) {
b29261b17343 8059621: JVM crashes with "unexpected index type" assert in LIRGenerator::do_UnsafeGetRaw
iveresov
parents: 20491
diff changeset
2074 if (!index_op->is_constant()) {
20491
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2075 index_op = new_register(T_LONG);
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2076 __ convert(Bytecodes::_i2l, idx.result(), index_op);
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2077 }
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2078 } else {
20519
b29261b17343 8059621: JVM crashes with "unexpected index type" assert in LIRGenerator::do_UnsafeGetRaw
iveresov
parents: 20491
diff changeset
2079 assert(index_op->type() == T_LONG, "must be");
b29261b17343 8059621: JVM crashes with "unexpected index type" assert in LIRGenerator::do_UnsafeGetRaw
iveresov
parents: 20491
diff changeset
2080 if (index_op->is_constant()) {
20491
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2081 index_op = new_register(T_LONG);
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2082 __ move(idx.result(), index_op);
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2083 }
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2084 }
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2085 }
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2086 // At this point base is a long non-constant
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2087 // Index is a long register or a int constant.
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2088 // We allow the constant to stay an int because that would allow us a more compact encoding by
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2089 // embedding an immediate offset in the address expression. If we have a long constant, we have to
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2090 // move it into a register first.
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2091 assert(base_op->type() == T_LONG && !base_op->is_constant(), "base must be a long non-constant");
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2092 assert(!x->has_index() || (index_op->type() == T_INT && index_op->is_constant()) ||
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2093 (index_op->type() == T_LONG && !index_op->is_constant()), "unexpected index type");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2094 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
2095
a61af66fc99e Initial load
duke
parents:
diff changeset
2096 BasicType dst_type = x->basic_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
2097
a61af66fc99e Initial load
duke
parents:
diff changeset
2098 LIR_Address* addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
2099 if (index_op->is_constant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2100 assert(log2_scale == 0, "must not have a scale");
20491
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2101 assert(index_op->type() == T_INT, "only int constants supported");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2102 addr = new LIR_Address(base_op, index_op->as_jint(), dst_type);
a61af66fc99e Initial load
duke
parents:
diff changeset
2103 } else {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
2104 #ifdef X86
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2105 addr = new LIR_Address(base_op, index_op, LIR_Address::Scale(log2_scale), 0, dst_type);
22851
ddce0b7cee93 8072383: resolve conflicts between open and closed ports
dlong
parents: 22837
diff changeset
2106 #elif defined(GENERATE_ADDRESS_IS_PREFERRED)
1681
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1584
diff changeset
2107 addr = generate_address(base_op, index_op, log2_scale, 0, dst_type);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2108 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
2109 if (index_op->is_illegal() || log2_scale == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2110 addr = new LIR_Address(base_op, index_op, dst_type);
a61af66fc99e Initial load
duke
parents:
diff changeset
2111 } else {
1060
323bd24c6520 6769124: various 64-bit fixes for c1
roland
parents: 989
diff changeset
2112 LIR_Opr tmp = new_pointer_register();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2113 __ shift_left(index_op, log2_scale, tmp);
a61af66fc99e Initial load
duke
parents:
diff changeset
2114 addr = new LIR_Address(base_op, tmp, dst_type);
a61af66fc99e Initial load
duke
parents:
diff changeset
2115 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2116 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
2117 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2118
a61af66fc99e Initial load
duke
parents:
diff changeset
2119 if (x->may_be_unaligned() && (dst_type == T_LONG || dst_type == T_DOUBLE)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2120 __ unaligned_move(addr, reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
2121 } else {
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2122 if (dst_type == T_OBJECT && x->is_wide()) {
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2123 __ move_wide(addr, reg);
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2124 } else {
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2125 __ move(addr, reg);
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2126 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2127 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2128 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2129
a61af66fc99e Initial load
duke
parents:
diff changeset
2130
a61af66fc99e Initial load
duke
parents:
diff changeset
2131 void LIRGenerator::do_UnsafePutRaw(UnsafePutRaw* x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2132 int log2_scale = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
2133 BasicType type = x->basic_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
2134
a61af66fc99e Initial load
duke
parents:
diff changeset
2135 if (x->has_index()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2136 log2_scale = x->log2_scale();
a61af66fc99e Initial load
duke
parents:
diff changeset
2137 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2138
a61af66fc99e Initial load
duke
parents:
diff changeset
2139 LIRItem base(x->base(), this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2140 LIRItem value(x->value(), this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2141 LIRItem idx(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2142
a61af66fc99e Initial load
duke
parents:
diff changeset
2143 base.load_item();
a61af66fc99e Initial load
duke
parents:
diff changeset
2144 if (x->has_index()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2145 idx.set_instruction(x->index());
a61af66fc99e Initial load
duke
parents:
diff changeset
2146 idx.load_item();
a61af66fc99e Initial load
duke
parents:
diff changeset
2147 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2148
a61af66fc99e Initial load
duke
parents:
diff changeset
2149 if (type == T_BYTE || type == T_BOOLEAN) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2150 value.load_byte_item();
a61af66fc99e Initial load
duke
parents:
diff changeset
2151 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2152 value.load_item();
a61af66fc99e Initial load
duke
parents:
diff changeset
2153 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2154
a61af66fc99e Initial load
duke
parents:
diff changeset
2155 set_no_result(x);
a61af66fc99e Initial load
duke
parents:
diff changeset
2156
a61af66fc99e Initial load
duke
parents:
diff changeset
2157 LIR_Opr base_op = base.result();
20491
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2158 LIR_Opr index_op = idx.result();
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2159
22851
ddce0b7cee93 8072383: resolve conflicts between open and closed ports
dlong
parents: 22837
diff changeset
2160 #ifdef GENERATE_ADDRESS_IS_PREFERRED
ddce0b7cee93 8072383: resolve conflicts between open and closed ports
dlong
parents: 22837
diff changeset
2161 LIR_Address* addr = generate_address(base_op, index_op, log2_scale, 0, x->basic_type());
ddce0b7cee93 8072383: resolve conflicts between open and closed ports
dlong
parents: 22837
diff changeset
2162 #else
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2163 #ifndef _LP64
20519
b29261b17343 8059621: JVM crashes with "unexpected index type" assert in LIRGenerator::do_UnsafeGetRaw
iveresov
parents: 20491
diff changeset
2164 if (base_op->type() == T_LONG) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2165 base_op = new_register(T_INT);
a61af66fc99e Initial load
duke
parents:
diff changeset
2166 __ convert(Bytecodes::_l2i, base.result(), base_op);
20491
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2167 }
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2168 if (x->has_index()) {
20519
b29261b17343 8059621: JVM crashes with "unexpected index type" assert in LIRGenerator::do_UnsafeGetRaw
iveresov
parents: 20491
diff changeset
2169 if (index_op->type() == T_LONG) {
20491
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2170 index_op = new_register(T_INT);
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2171 __ convert(Bytecodes::_l2i, idx.result(), index_op);
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2172 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2173 }
20491
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2174 // At this point base and index should be all ints and not constants
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2175 assert(base_op->type() == T_INT && !base_op->is_constant(), "base should be an non-constant int");
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2176 assert(!x->has_index() || (index_op->type() == T_INT && !index_op->is_constant()), "index should be an non-constant int");
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2177 #else
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2178 if (x->has_index()) {
20519
b29261b17343 8059621: JVM crashes with "unexpected index type" assert in LIRGenerator::do_UnsafeGetRaw
iveresov
parents: 20491
diff changeset
2179 if (index_op->type() == T_INT) {
20491
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2180 index_op = new_register(T_LONG);
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2181 __ convert(Bytecodes::_i2l, idx.result(), index_op);
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2182 }
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2183 }
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2184 // At this point base and index are long and non-constant
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2185 assert(base_op->type() == T_LONG && !base_op->is_constant(), "base must be a non-constant long");
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2186 assert(!x->has_index() || (index_op->type() == T_LONG && !index_op->is_constant()), "index must be a non-constant long");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2187 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
2188
a61af66fc99e Initial load
duke
parents:
diff changeset
2189 if (log2_scale != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2190 // temporary fix (platform dependent code without shift on Intel would be better)
20491
a60a1309a03a 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 20344
diff changeset
2191 // TODO: ARM also allows embedded shift in the address
23131
3816de51b5e7 8071731: Better scaling for C1
roland
parents: 20519
diff changeset
2192 LIR_Opr tmp = new_pointer_register();
3816de51b5e7 8071731: Better scaling for C1
roland
parents: 20519
diff changeset
2193 if (TwoOperandLIRForm) {
3816de51b5e7 8071731: Better scaling for C1
roland
parents: 20519
diff changeset
2194 __ move(index_op, tmp);
3816de51b5e7 8071731: Better scaling for C1
roland
parents: 20519
diff changeset
2195 index_op = tmp;
3816de51b5e7 8071731: Better scaling for C1
roland
parents: 20519
diff changeset
2196 }
3816de51b5e7 8071731: Better scaling for C1
roland
parents: 20519
diff changeset
2197 __ shift_left(index_op, log2_scale, tmp);
3816de51b5e7 8071731: Better scaling for C1
roland
parents: 20519
diff changeset
2198 if (!TwoOperandLIRForm) {
3816de51b5e7 8071731: Better scaling for C1
roland
parents: 20519
diff changeset
2199 index_op = tmp;
3816de51b5e7 8071731: Better scaling for C1
roland
parents: 20519
diff changeset
2200 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2201 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2202
a61af66fc99e Initial load
duke
parents:
diff changeset
2203 LIR_Address* addr = new LIR_Address(base_op, index_op, x->basic_type());
22851
ddce0b7cee93 8072383: resolve conflicts between open and closed ports
dlong
parents: 22837
diff changeset
2204 #endif // !GENERATE_ADDRESS_IS_PREFERRED
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2205 __ move(value.result(), addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
2206 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2207
a61af66fc99e Initial load
duke
parents:
diff changeset
2208
a61af66fc99e Initial load
duke
parents:
diff changeset
2209 void LIRGenerator::do_UnsafeGetObject(UnsafeGetObject* x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2210 BasicType type = x->basic_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
2211 LIRItem src(x->object(), this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2212 LIRItem off(x->offset(), this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2213
a61af66fc99e Initial load
duke
parents:
diff changeset
2214 off.load_item();
a61af66fc99e Initial load
duke
parents:
diff changeset
2215 src.load_item();
a61af66fc99e Initial load
duke
parents:
diff changeset
2216
6615
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2217 LIR_Opr value = rlock_result(x, x->basic_type());
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2218
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2219 get_Object_unsafe(value, src.result(), off.result(), type, x->is_volatile());
3249
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2220
8001
db9981fd3124 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 7425
diff changeset
2221 #if INCLUDE_ALL_GCS
3249
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2222 // We might be reading the value of the referent field of a
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2223 // Reference object in order to attach it back to the live
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2224 // object graph. If G1 is enabled then we need to record
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2225 // the value that is being returned in an SATB log buffer.
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2226 //
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2227 // We need to generate code similar to the following...
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2228 //
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2229 // if (offset == java_lang_ref_Reference::referent_offset) {
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2230 // if (src != NULL) {
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2231 // if (klass(src)->reference_type() != REF_NONE) {
6615
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2232 // pre_barrier(..., value, ...);
3249
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2233 // }
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2234 // }
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2235 // }
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2236
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2237 if (UseG1GC && type == T_OBJECT) {
6615
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2238 bool gen_pre_barrier = true; // Assume we need to generate pre_barrier.
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2239 bool gen_offset_check = true; // Assume we need to generate the offset guard.
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2240 bool gen_source_check = true; // Assume we need to check the src object for null.
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2241 bool gen_type_check = true; // Assume we need to check the reference_type.
3249
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2242
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2243 if (off.is_constant()) {
3254
59766fd005ff 7035117: G1: nsk/stress/jni/jnistress002 fails with assertion failure
johnc
parents: 3249
diff changeset
2244 jlong off_con = (off.type()->is_int() ?
59766fd005ff 7035117: G1: nsk/stress/jni/jnistress002 fails with assertion failure
johnc
parents: 3249
diff changeset
2245 (jlong) off.get_jint_constant() :
59766fd005ff 7035117: G1: nsk/stress/jni/jnistress002 fails with assertion failure
johnc
parents: 3249
diff changeset
2246 off.get_jlong_constant());
59766fd005ff 7035117: G1: nsk/stress/jni/jnistress002 fails with assertion failure
johnc
parents: 3249
diff changeset
2247
59766fd005ff 7035117: G1: nsk/stress/jni/jnistress002 fails with assertion failure
johnc
parents: 3249
diff changeset
2248
59766fd005ff 7035117: G1: nsk/stress/jni/jnistress002 fails with assertion failure
johnc
parents: 3249
diff changeset
2249 if (off_con != (jlong) java_lang_ref_Reference::referent_offset) {
3249
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2250 // The constant offset is something other than referent_offset.
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2251 // We can skip generating/checking the remaining guards and
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2252 // skip generation of the code stub.
6615
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2253 gen_pre_barrier = false;
3249
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2254 } else {
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2255 // The constant offset is the same as referent_offset -
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2256 // we do not need to generate a runtime offset check.
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2257 gen_offset_check = false;
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2258 }
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2259 }
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2260
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2261 // We don't need to generate stub if the source object is an array
6615
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2262 if (gen_pre_barrier && src.type()->is_array()) {
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2263 gen_pre_barrier = false;
3249
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2264 }
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2265
6615
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2266 if (gen_pre_barrier) {
3249
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2267 // We still need to continue with the checks.
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2268 if (src.is_constant()) {
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2269 ciObject* src_con = src.get_jobject_constant();
10397
075ea888b039 8010724: [parfait] Null pointer dereference in hotspot/src/share/vm/c1/c1_LIRGenerator.cpp
morris
parents: 10116
diff changeset
2270 guarantee(src_con != NULL, "no source constant");
3249
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2271
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2272 if (src_con->is_null_object()) {
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2273 // The constant src object is null - We can skip
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2274 // generating the code stub.
6615
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2275 gen_pre_barrier = false;
3249
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2276 } else {
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2277 // Non-null constant source object. We still have to generate
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2278 // the slow stub - but we don't need to generate the runtime
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2279 // null object check.
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2280 gen_source_check = false;
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2281 }
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2282 }
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2283 }
6615
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2284 if (gen_pre_barrier && !PatchALot) {
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2285 // Can the klass of object be statically determined to be
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2286 // a sub-class of Reference?
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2287 ciType* type = src.value()->declared_type();
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2288 if ((type != NULL) && type->is_loaded()) {
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2289 if (type->is_subtype_of(compilation()->env()->Reference_klass())) {
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2290 gen_type_check = false;
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2291 } else if (type->is_klass() &&
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2292 !compilation()->env()->Object_klass()->is_subtype_of(type->as_klass())) {
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2293 // Not Reference and not Object klass.
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2294 gen_pre_barrier = false;
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2295 }
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2296 }
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2297 }
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2298
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2299 if (gen_pre_barrier) {
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2300 LabelObj* Lcont = new LabelObj();
3249
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2301
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2302 // We can have generate one runtime check here. Let's start with
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2303 // the offset check.
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2304 if (gen_offset_check) {
6615
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2305 // if (offset != referent_offset) -> continue
3254
59766fd005ff 7035117: G1: nsk/stress/jni/jnistress002 fails with assertion failure
johnc
parents: 3249
diff changeset
2306 // If offset is an int then we can do the comparison with the
59766fd005ff 7035117: G1: nsk/stress/jni/jnistress002 fails with assertion failure
johnc
parents: 3249
diff changeset
2307 // referent_offset constant; otherwise we need to move
59766fd005ff 7035117: G1: nsk/stress/jni/jnistress002 fails with assertion failure
johnc
parents: 3249
diff changeset
2308 // referent_offset into a temporary register and generate
59766fd005ff 7035117: G1: nsk/stress/jni/jnistress002 fails with assertion failure
johnc
parents: 3249
diff changeset
2309 // a reg-reg compare.
59766fd005ff 7035117: G1: nsk/stress/jni/jnistress002 fails with assertion failure
johnc
parents: 3249
diff changeset
2310
59766fd005ff 7035117: G1: nsk/stress/jni/jnistress002 fails with assertion failure
johnc
parents: 3249
diff changeset
2311 LIR_Opr referent_off;
59766fd005ff 7035117: G1: nsk/stress/jni/jnistress002 fails with assertion failure
johnc
parents: 3249
diff changeset
2312
59766fd005ff 7035117: G1: nsk/stress/jni/jnistress002 fails with assertion failure
johnc
parents: 3249
diff changeset
2313 if (off.type()->is_int()) {
59766fd005ff 7035117: G1: nsk/stress/jni/jnistress002 fails with assertion failure
johnc
parents: 3249
diff changeset
2314 referent_off = LIR_OprFact::intConst(java_lang_ref_Reference::referent_offset);
59766fd005ff 7035117: G1: nsk/stress/jni/jnistress002 fails with assertion failure
johnc
parents: 3249
diff changeset
2315 } else {
59766fd005ff 7035117: G1: nsk/stress/jni/jnistress002 fails with assertion failure
johnc
parents: 3249
diff changeset
2316 assert(off.type()->is_long(), "what else?");
59766fd005ff 7035117: G1: nsk/stress/jni/jnistress002 fails with assertion failure
johnc
parents: 3249
diff changeset
2317 referent_off = new_register(T_LONG);
59766fd005ff 7035117: G1: nsk/stress/jni/jnistress002 fails with assertion failure
johnc
parents: 3249
diff changeset
2318 __ move(LIR_OprFact::longConst(java_lang_ref_Reference::referent_offset), referent_off);
59766fd005ff 7035117: G1: nsk/stress/jni/jnistress002 fails with assertion failure
johnc
parents: 3249
diff changeset
2319 }
6615
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2320 __ cmp(lir_cond_notEqual, off.result(), referent_off);
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2321 __ branch(lir_cond_notEqual, as_BasicType(off.type()), Lcont->label());
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2322 }
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2323 if (gen_source_check) {
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2324 // offset is a const and equals referent offset
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2325 // if (source == null) -> continue
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2326 __ cmp(lir_cond_equal, src.result(), LIR_OprFact::oopConst(NULL));
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2327 __ branch(lir_cond_equal, T_OBJECT, Lcont->label());
3249
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2328 }
6615
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2329 LIR_Opr src_klass = new_register(T_OBJECT);
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2330 if (gen_type_check) {
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2331 // We have determined that offset == referent_offset && src != null.
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2332 // if (src->_klass->_reference_type == REF_NONE) -> continue
12000
8d77d02828d9 8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents: 11080
diff changeset
2333 __ move(new LIR_Address(src.result(), oopDesc::klass_offset_in_bytes(), T_ADDRESS), src_klass);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6616
diff changeset
2334 LIR_Address* reference_type_addr = new LIR_Address(src_klass, in_bytes(InstanceKlass::reference_type_offset()), T_BYTE);
6615
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2335 LIR_Opr reference_type = new_register(T_INT);
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2336 __ move(reference_type_addr, reference_type);
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2337 __ cmp(lir_cond_equal, reference_type, LIR_OprFact::intConst(REF_NONE));
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2338 __ branch(lir_cond_equal, T_INT, Lcont->label());
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2339 }
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2340 {
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2341 // We have determined that src->_klass->_reference_type != REF_NONE
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2342 // so register the value in the referent field with the pre-barrier.
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2343 pre_barrier(LIR_OprFact::illegalOpr /* addr_opr */,
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2344 value /* pre_val */,
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2345 false /* do_load */,
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2346 false /* patch */,
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2347 NULL /* info */);
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2348 }
09aad8452938 7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents: 6266
diff changeset
2349 __ branch_destination(Lcont->label());
3249
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2350 }
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2351 }
8001
db9981fd3124 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 7425
diff changeset
2352 #endif // INCLUDE_ALL_GCS
3249
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
2353
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2354 if (x->is_volatile() && os::is_MP()) __ membar_acquire();
a61af66fc99e Initial load
duke
parents:
diff changeset
2355 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2356
a61af66fc99e Initial load
duke
parents:
diff changeset
2357
a61af66fc99e Initial load
duke
parents:
diff changeset
2358 void LIRGenerator::do_UnsafePutObject(UnsafePutObject* x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2359 BasicType type = x->basic_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
2360 LIRItem src(x->object(), this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2361 LIRItem off(x->offset(), this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2362 LIRItem data(x->value(), this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2363
a61af66fc99e Initial load
duke
parents:
diff changeset
2364 src.load_item();
a61af66fc99e Initial load
duke
parents:
diff changeset
2365 if (type == T_BOOLEAN || type == T_BYTE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2366 data.load_byte_item();
a61af66fc99e Initial load
duke
parents:
diff changeset
2367 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2368 data.load_item();
a61af66fc99e Initial load
duke
parents:
diff changeset
2369 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2370 off.load_item();
a61af66fc99e Initial load
duke
parents:
diff changeset
2371
a61af66fc99e Initial load
duke
parents:
diff changeset
2372 set_no_result(x);
a61af66fc99e Initial load
duke
parents:
diff changeset
2373
a61af66fc99e Initial load
duke
parents:
diff changeset
2374 if (x->is_volatile() && os::is_MP()) __ membar_release();
a61af66fc99e Initial load
duke
parents:
diff changeset
2375 put_Object_unsafe(src.result(), off.result(), data.result(), type, x->is_volatile());
2123
df307487d610 7010665: Misplaced membar in C1 implementation of Unsafe.get/putXXX
dholmes
parents: 2007
diff changeset
2376 if (x->is_volatile() && os::is_MP()) __ membar();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2377 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2378
a61af66fc99e Initial load
duke
parents:
diff changeset
2379
a61af66fc99e Initial load
duke
parents:
diff changeset
2380 void LIRGenerator::do_UnsafePrefetch(UnsafePrefetch* x, bool is_store) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2381 LIRItem src(x->object(), this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2382 LIRItem off(x->offset(), this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2383
a61af66fc99e Initial load
duke
parents:
diff changeset
2384 src.load_item();
a61af66fc99e Initial load
duke
parents:
diff changeset
2385 if (off.is_constant() && can_inline_as_constant(x->offset())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2386 // let it be a constant
a61af66fc99e Initial load
duke
parents:
diff changeset
2387 off.dont_load_item();
a61af66fc99e Initial load
duke
parents:
diff changeset
2388 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2389 off.load_item();
a61af66fc99e Initial load
duke
parents:
diff changeset
2390 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2391
a61af66fc99e Initial load
duke
parents:
diff changeset
2392 set_no_result(x);
a61af66fc99e Initial load
duke
parents:
diff changeset
2393
a61af66fc99e Initial load
duke
parents:
diff changeset
2394 LIR_Address* addr = generate_address(src.result(), off.result(), 0, 0, T_BYTE);
a61af66fc99e Initial load
duke
parents:
diff changeset
2395 __ prefetch(addr, is_store);
a61af66fc99e Initial load
duke
parents:
diff changeset
2396 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2397
a61af66fc99e Initial load
duke
parents:
diff changeset
2398
a61af66fc99e Initial load
duke
parents:
diff changeset
2399 void LIRGenerator::do_UnsafePrefetchRead(UnsafePrefetchRead* x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2400 do_UnsafePrefetch(x, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
2401 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2402
a61af66fc99e Initial load
duke
parents:
diff changeset
2403
a61af66fc99e Initial load
duke
parents:
diff changeset
2404 void LIRGenerator::do_UnsafePrefetchWrite(UnsafePrefetchWrite* x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2405 do_UnsafePrefetch(x, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
2406 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2407
a61af66fc99e Initial load
duke
parents:
diff changeset
2408
a61af66fc99e Initial load
duke
parents:
diff changeset
2409 void LIRGenerator::do_SwitchRanges(SwitchRangeArray* x, LIR_Opr value, BlockBegin* default_sux) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2410 int lng = x->length();
a61af66fc99e Initial load
duke
parents:
diff changeset
2411
a61af66fc99e Initial load
duke
parents:
diff changeset
2412 for (int i = 0; i < lng; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2413 SwitchRange* one_range = x->at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
2414 int low_key = one_range->low_key();
a61af66fc99e Initial load
duke
parents:
diff changeset
2415 int high_key = one_range->high_key();
a61af66fc99e Initial load
duke
parents:
diff changeset
2416 BlockBegin* dest = one_range->sux();
a61af66fc99e Initial load
duke
parents:
diff changeset
2417 if (low_key == high_key) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2418 __ cmp(lir_cond_equal, value, low_key);
a61af66fc99e Initial load
duke
parents:
diff changeset
2419 __ branch(lir_cond_equal, T_INT, dest);
a61af66fc99e Initial load
duke
parents:
diff changeset
2420 } else if (high_key - low_key == 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2421 __ cmp(lir_cond_equal, value, low_key);
a61af66fc99e Initial load
duke
parents:
diff changeset
2422 __ branch(lir_cond_equal, T_INT, dest);
a61af66fc99e Initial load
duke
parents:
diff changeset
2423 __ cmp(lir_cond_equal, value, high_key);
a61af66fc99e Initial load
duke
parents:
diff changeset
2424 __ branch(lir_cond_equal, T_INT, dest);
a61af66fc99e Initial load
duke
parents:
diff changeset
2425 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2426 LabelObj* L = new LabelObj();
a61af66fc99e Initial load
duke
parents:
diff changeset
2427 __ cmp(lir_cond_less, value, low_key);
4816
9164b8236699 7131028: Switch statement takes wrong path
iveresov
parents: 4762
diff changeset
2428 __ branch(lir_cond_less, T_INT, L->label());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2429 __ cmp(lir_cond_lessEqual, value, high_key);
a61af66fc99e Initial load
duke
parents:
diff changeset
2430 __ branch(lir_cond_lessEqual, T_INT, dest);
a61af66fc99e Initial load
duke
parents:
diff changeset
2431 __ branch_destination(L->label());
a61af66fc99e Initial load
duke
parents:
diff changeset
2432 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2433 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2434 __ jump(default_sux);
a61af66fc99e Initial load
duke
parents:
diff changeset
2435 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2436
a61af66fc99e Initial load
duke
parents:
diff changeset
2437
a61af66fc99e Initial load
duke
parents:
diff changeset
2438 SwitchRangeArray* LIRGenerator::create_lookup_ranges(TableSwitch* x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2439 SwitchRangeList* res = new SwitchRangeList();
a61af66fc99e Initial load
duke
parents:
diff changeset
2440 int len = x->length();
a61af66fc99e Initial load
duke
parents:
diff changeset
2441 if (len > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2442 BlockBegin* sux = x->sux_at(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2443 int key = x->lo_key();
a61af66fc99e Initial load
duke
parents:
diff changeset
2444 BlockBegin* default_sux = x->default_sux();
a61af66fc99e Initial load
duke
parents:
diff changeset
2445 SwitchRange* range = new SwitchRange(key, sux);
a61af66fc99e Initial load
duke
parents:
diff changeset
2446 for (int i = 0; i < len; i++, key++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2447 BlockBegin* new_sux = x->sux_at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
2448 if (sux == new_sux) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2449 // still in same range
a61af66fc99e Initial load
duke
parents:
diff changeset
2450 range->set_high_key(key);
a61af66fc99e Initial load
duke
parents:
diff changeset
2451 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2452 // skip tests which explicitly dispatch to the default
a61af66fc99e Initial load
duke
parents:
diff changeset
2453 if (sux != default_sux) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2454 res->append(range);
a61af66fc99e Initial load
duke
parents:
diff changeset
2455 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2456 range = new SwitchRange(key, new_sux);
a61af66fc99e Initial load
duke
parents:
diff changeset
2457 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2458 sux = new_sux;
a61af66fc99e Initial load
duke
parents:
diff changeset
2459 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2460 if (res->length() == 0 || res->last() != range) res->append(range);
a61af66fc99e Initial load
duke
parents:
diff changeset
2461 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2462 return res;
a61af66fc99e Initial load
duke
parents:
diff changeset
2463 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2464
a61af66fc99e Initial load
duke
parents:
diff changeset
2465
a61af66fc99e Initial load
duke
parents:
diff changeset
2466 // we expect the keys to be sorted by increasing value
a61af66fc99e Initial load
duke
parents:
diff changeset
2467 SwitchRangeArray* LIRGenerator::create_lookup_ranges(LookupSwitch* x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2468 SwitchRangeList* res = new SwitchRangeList();
a61af66fc99e Initial load
duke
parents:
diff changeset
2469 int len = x->length();
a61af66fc99e Initial load
duke
parents:
diff changeset
2470 if (len > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2471 BlockBegin* default_sux = x->default_sux();
a61af66fc99e Initial load
duke
parents:
diff changeset
2472 int key = x->key_at(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2473 BlockBegin* sux = x->sux_at(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2474 SwitchRange* range = new SwitchRange(key, sux);
a61af66fc99e Initial load
duke
parents:
diff changeset
2475 for (int i = 1; i < len; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2476 int new_key = x->key_at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
2477 BlockBegin* new_sux = x->sux_at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
2478 if (key+1 == new_key && sux == new_sux) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2479 // still in same range
a61af66fc99e Initial load
duke
parents:
diff changeset
2480 range->set_high_key(new_key);
a61af66fc99e Initial load
duke
parents:
diff changeset
2481 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2482 // skip tests which explicitly dispatch to the default
a61af66fc99e Initial load
duke
parents:
diff changeset
2483 if (range->sux() != default_sux) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2484 res->append(range);
a61af66fc99e Initial load
duke
parents:
diff changeset
2485 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2486 range = new SwitchRange(new_key, new_sux);
a61af66fc99e Initial load
duke
parents:
diff changeset
2487 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2488 key = new_key;
a61af66fc99e Initial load
duke
parents:
diff changeset
2489 sux = new_sux;
a61af66fc99e Initial load
duke
parents:
diff changeset
2490 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2491 if (res->length() == 0 || res->last() != range) res->append(range);
a61af66fc99e Initial load
duke
parents:
diff changeset
2492 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2493 return res;
a61af66fc99e Initial load
duke
parents:
diff changeset
2494 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2495
a61af66fc99e Initial load
duke
parents:
diff changeset
2496
a61af66fc99e Initial load
duke
parents:
diff changeset
2497 void LIRGenerator::do_TableSwitch(TableSwitch* x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2498 LIRItem tag(x->tag(), this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2499 tag.load_item();
a61af66fc99e Initial load
duke
parents:
diff changeset
2500 set_no_result(x);
a61af66fc99e Initial load
duke
parents:
diff changeset
2501
a61af66fc99e Initial load
duke
parents:
diff changeset
2502 if (x->is_safepoint()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2503 __ safepoint(safepoint_poll_register(), state_for(x, x->state_before()));
a61af66fc99e Initial load
duke
parents:
diff changeset
2504 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2505
a61af66fc99e Initial load
duke
parents:
diff changeset
2506 // move values into phi locations
a61af66fc99e Initial load
duke
parents:
diff changeset
2507 move_to_phi(x->state());
a61af66fc99e Initial load
duke
parents:
diff changeset
2508
a61af66fc99e Initial load
duke
parents:
diff changeset
2509 int lo_key = x->lo_key();
a61af66fc99e Initial load
duke
parents:
diff changeset
2510 int hi_key = x->hi_key();
a61af66fc99e Initial load
duke
parents:
diff changeset
2511 int len = x->length();
a61af66fc99e Initial load
duke
parents:
diff changeset
2512 LIR_Opr value = tag.result();
a61af66fc99e Initial load
duke
parents:
diff changeset
2513 if (UseTableRanges) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2514 do_SwitchRanges(create_lookup_ranges(x), value, x->default_sux());
a61af66fc99e Initial load
duke
parents:
diff changeset
2515 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2516 for (int i = 0; i < len; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2517 __ cmp(lir_cond_equal, value, i + lo_key);
a61af66fc99e Initial load
duke
parents:
diff changeset
2518 __ branch(lir_cond_equal, T_INT, x->sux_at(i));
a61af66fc99e Initial load
duke
parents:
diff changeset
2519 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2520 __ jump(x->default_sux());
a61af66fc99e Initial load
duke
parents:
diff changeset
2521 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2522 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2523
a61af66fc99e Initial load
duke
parents:
diff changeset
2524
a61af66fc99e Initial load
duke
parents:
diff changeset
2525 void LIRGenerator::do_LookupSwitch(LookupSwitch* x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2526 LIRItem tag(x->tag(), this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2527 tag.load_item();
a61af66fc99e Initial load
duke
parents:
diff changeset
2528 set_no_result(x);
a61af66fc99e Initial load
duke
parents:
diff changeset
2529
a61af66fc99e Initial load
duke
parents:
diff changeset
2530 if (x->is_safepoint()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2531 __ safepoint(safepoint_poll_register(), state_for(x, x->state_before()));
a61af66fc99e Initial load
duke
parents:
diff changeset
2532 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2533
a61af66fc99e Initial load
duke
parents:
diff changeset
2534 // move values into phi locations
a61af66fc99e Initial load
duke
parents:
diff changeset
2535 move_to_phi(x->state());
a61af66fc99e Initial load
duke
parents:
diff changeset
2536
a61af66fc99e Initial load
duke
parents:
diff changeset
2537 LIR_Opr value = tag.result();
a61af66fc99e Initial load
duke
parents:
diff changeset
2538 if (UseTableRanges) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2539 do_SwitchRanges(create_lookup_ranges(x), value, x->default_sux());
a61af66fc99e Initial load
duke
parents:
diff changeset
2540 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2541 int len = x->length();
a61af66fc99e Initial load
duke
parents:
diff changeset
2542 for (int i = 0; i < len; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2543 __ cmp(lir_cond_equal, value, x->key_at(i));
a61af66fc99e Initial load
duke
parents:
diff changeset
2544 __ branch(lir_cond_equal, T_INT, x->sux_at(i));
a61af66fc99e Initial load
duke
parents:
diff changeset
2545 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2546 __ jump(x->default_sux());
a61af66fc99e Initial load
duke
parents:
diff changeset
2547 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2548 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2549
a61af66fc99e Initial load
duke
parents:
diff changeset
2550
a61af66fc99e Initial load
duke
parents:
diff changeset
2551 void LIRGenerator::do_Goto(Goto* x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2552 set_no_result(x);
a61af66fc99e Initial load
duke
parents:
diff changeset
2553
a61af66fc99e Initial load
duke
parents:
diff changeset
2554 if (block()->next()->as_OsrEntry()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2555 // need to free up storage used for OSR entry point
a61af66fc99e Initial load
duke
parents:
diff changeset
2556 LIR_Opr osrBuffer = block()->next()->operand();
a61af66fc99e Initial load
duke
parents:
diff changeset
2557 BasicTypeList signature;
22837
134cdf5e0b8a 8037140: C1: Incorrect argument type used for SharedRuntime::OSR_migration_end in LIRGenerator::do_Goto
iveresov
parents: 20519
diff changeset
2558 signature.append(NOT_LP64(T_INT) LP64_ONLY(T_LONG)); // pass a pointer to osrBuffer
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2559 CallingConvention* cc = frame_map()->c_calling_convention(&signature);
a61af66fc99e Initial load
duke
parents:
diff changeset
2560 __ move(osrBuffer, cc->args()->at(0));
a61af66fc99e Initial load
duke
parents:
diff changeset
2561 __ call_runtime_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::OSR_migration_end),
a61af66fc99e Initial load
duke
parents:
diff changeset
2562 getThreadTemp(), LIR_OprFact::illegalOpr, cc->args());
a61af66fc99e Initial load
duke
parents:
diff changeset
2563 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2564
a61af66fc99e Initial load
duke
parents:
diff changeset
2565 if (x->is_safepoint()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2566 ValueStack* state = x->state_before() ? x->state_before() : x->state();
a61af66fc99e Initial load
duke
parents:
diff changeset
2567
a61af66fc99e Initial load
duke
parents:
diff changeset
2568 // increment backedge counter if needed
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
2569 CodeEmitInfo* info = state_for(x, state);
3997
940513efe83a 7097679: Tiered: events with bad bci to Gotos reduced from Ifs
iveresov
parents: 3964
diff changeset
2570 increment_backedge_counter(info, x->profiled_bci());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2571 CodeEmitInfo* safepoint_info = state_for(x, state);
a61af66fc99e Initial load
duke
parents:
diff changeset
2572 __ safepoint(safepoint_poll_register(), safepoint_info);
a61af66fc99e Initial load
duke
parents:
diff changeset
2573 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2574
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
2575 // Gotos can be folded Ifs, handle this case.
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
2576 if (x->should_profile()) {
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
2577 ciMethod* method = x->profiled_method();
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
2578 assert(method != NULL, "method should be set if branch is profiled");
2007
5ddfcf4b079e 7003554: (tiered) assert(is_null_object() || handle() != NULL) failed: cannot embed null pointer
iveresov
parents: 2002
diff changeset
2579 ciMethodData* md = method->method_data_or_null();
5ddfcf4b079e 7003554: (tiered) assert(is_null_object() || handle() != NULL) failed: cannot embed null pointer
iveresov
parents: 2002
diff changeset
2580 assert(md != NULL, "Sanity");
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
2581 ciProfileData* data = md->bci_to_data(x->profiled_bci());
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
2582 assert(data != NULL, "must have profiling data");
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
2583 int offset;
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
2584 if (x->direction() == Goto::taken) {
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
2585 assert(data->is_BranchData(), "need BranchData for two-way branches");
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
2586 offset = md->byte_offset_of_slot(data, BranchData::taken_offset());
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
2587 } else if (x->direction() == Goto::not_taken) {
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
2588 assert(data->is_BranchData(), "need BranchData for two-way branches");
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
2589 offset = md->byte_offset_of_slot(data, BranchData::not_taken_offset());
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
2590 } else {
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
2591 assert(data->is_JumpData(), "need JumpData for branches");
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
2592 offset = md->byte_offset_of_slot(data, JumpData::taken_offset());
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
2593 }
6739
8a02ca5e5576 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 6731
diff changeset
2594 LIR_Opr md_reg = new_register(T_METADATA);
8a02ca5e5576 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 6731
diff changeset
2595 __ metadata2reg(md->constant_encoding(), md_reg);
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
2596
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
2597 increment_counter(new LIR_Address(md_reg, offset,
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
2598 NOT_LP64(T_INT) LP64_ONLY(T_LONG)), DataLayout::counter_increment);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
2599 }
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
2600
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2601 // emit phi-instruction move after safepoint since this simplifies
a61af66fc99e Initial load
duke
parents:
diff changeset
2602 // describing the state as the safepoint.
a61af66fc99e Initial load
duke
parents:
diff changeset
2603 move_to_phi(x->state());
a61af66fc99e Initial load
duke
parents:
diff changeset
2604
a61af66fc99e Initial load
duke
parents:
diff changeset
2605 __ jump(x->default_sux());
a61af66fc99e Initial load
duke
parents:
diff changeset
2606 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2607
13078
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
2608 /**
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
2609 * Emit profiling code if needed for arguments, parameters, return value types
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
2610 *
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
2611 * @param md MDO the code will update at runtime
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
2612 * @param md_base_offset common offset in the MDO for this profile and subsequent ones
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
2613 * @param md_offset offset in the MDO (on top of md_base_offset) for this profile
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
2614 * @param profiled_k current profile
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
2615 * @param obj IR node for the object to be profiled
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
2616 * @param mdp register to hold the pointer inside the MDO (md + md_base_offset).
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
2617 * Set once we find an update to make and use for next ones.
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
2618 * @param not_null true if we know obj cannot be null
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
2619 * @param signature_at_call_k signature at call for obj
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
2620 * @param callee_signature_k signature of callee for obj
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
2621 * at call and callee signatures differ at method handle call
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
2622 * @return the only klass we know will ever be seen at this profile point
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
2623 */
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
2624 ciKlass* LIRGenerator::profile_type(ciMethodData* md, int md_base_offset, int md_offset, intptr_t profiled_k,
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
2625 Value obj, LIR_Opr& mdp, bool not_null, ciKlass* signature_at_call_k,
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
2626 ciKlass* callee_signature_k) {
12875
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2627 ciKlass* result = NULL;
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2628 bool do_null = !not_null && !TypeEntries::was_null_seen(profiled_k);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2629 bool do_update = !TypeEntries::is_type_unknown(profiled_k);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2630 // known not to be null or null bit already set and already set to
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2631 // unknown: nothing we can do to improve profiling
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2632 if (!do_null && !do_update) {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2633 return result;
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2634 }
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2635
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2636 ciKlass* exact_klass = NULL;
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2637 Compilation* comp = Compilation::current();
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2638 if (do_update) {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2639 // try to find exact type, using CHA if possible, so that loading
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2640 // the klass from the object can be avoided
13078
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
2641 ciType* type = obj->exact_type();
12875
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2642 if (type == NULL) {
13078
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
2643 type = obj->declared_type();
12875
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2644 type = comp->cha_exact_type(type);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2645 }
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2646 assert(type == NULL || type->is_klass(), "type should be class");
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2647 exact_klass = (type != NULL && type->is_loaded()) ? (ciKlass*)type : NULL;
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2648
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2649 do_update = exact_klass == NULL || ciTypeEntries::valid_ciklass(profiled_k) != exact_klass;
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2650 }
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2651
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2652 if (!do_null && !do_update) {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2653 return result;
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2654 }
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2655
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2656 ciKlass* exact_signature_k = NULL;
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2657 if (do_update) {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2658 // Is the type from the signature exact (the only one possible)?
13078
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
2659 exact_signature_k = signature_at_call_k->exact_klass();
12875
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2660 if (exact_signature_k == NULL) {
13078
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
2661 exact_signature_k = comp->cha_exact_type(signature_at_call_k);
12875
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2662 } else {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2663 result = exact_signature_k;
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2664 // Known statically. No need to emit any code: prevent
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2665 // LIR_Assembler::emit_profile_type() from emitting useless code
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2666 profiled_k = ciTypeEntries::with_status(result, profiled_k);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2667 }
17925
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents: 17900
diff changeset
2668 // exact_klass and exact_signature_k can be both non NULL but
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents: 17900
diff changeset
2669 // different if exact_klass is loaded after the ciObject for
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents: 17900
diff changeset
2670 // exact_signature_k is created.
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents: 17900
diff changeset
2671 if (exact_klass == NULL && exact_signature_k != NULL && exact_klass != exact_signature_k) {
12875
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2672 // sometimes the type of the signature is better than the best type
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2673 // the compiler has
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2674 exact_klass = exact_signature_k;
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2675 }
13078
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
2676 if (callee_signature_k != NULL &&
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
2677 callee_signature_k != signature_at_call_k) {
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
2678 ciKlass* improved_klass = callee_signature_k->exact_klass();
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
2679 if (improved_klass == NULL) {
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
2680 improved_klass = comp->cha_exact_type(callee_signature_k);
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
2681 }
17925
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents: 17900
diff changeset
2682 if (exact_klass == NULL && improved_klass != NULL && exact_klass != improved_klass) {
13078
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
2683 exact_klass = exact_signature_k;
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
2684 }
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
2685 }
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
2686 do_update = exact_klass == NULL || ciTypeEntries::valid_ciklass(profiled_k) != exact_klass;
12875
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2687 }
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2688
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2689 if (!do_null && !do_update) {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2690 return result;
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2691 }
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2692
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2693 if (mdp == LIR_OprFact::illegalOpr) {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2694 mdp = new_register(T_METADATA);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2695 __ metadata2reg(md->constant_encoding(), mdp);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2696 if (md_base_offset != 0) {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2697 LIR_Address* base_type_address = new LIR_Address(mdp, md_base_offset, T_ADDRESS);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2698 mdp = new_pointer_register();
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2699 __ leal(LIR_OprFact::address(base_type_address), mdp);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2700 }
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2701 }
13078
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
2702 LIRItem value(obj, this);
12875
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2703 value.load_item();
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2704 __ profile_type(new LIR_Address(mdp, md_offset, T_METADATA),
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2705 value.result(), exact_klass, profiled_k, new_pointer_register(), not_null, exact_signature_k != NULL);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2706 return result;
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2707 }
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
2708
12962
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
2709 // profile parameters on entry to the root of the compilation
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
2710 void LIRGenerator::profile_parameters(Base* x) {
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
2711 if (compilation()->profile_parameters()) {
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
2712 CallingConvention* args = compilation()->frame_map()->incoming_arguments();
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
2713 ciMethodData* md = scope()->method()->method_data_or_null();
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
2714 assert(md != NULL, "Sanity");
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
2715
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
2716 if (md->parameters_type_data() != NULL) {
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
2717 ciParametersTypeData* parameters_type_data = md->parameters_type_data();
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
2718 ciTypeStackSlotEntries* parameters = parameters_type_data->parameters();
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
2719 LIR_Opr mdp = LIR_OprFact::illegalOpr;
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
2720 for (int java_index = 0, i = 0, j = 0; j < parameters_type_data->number_of_parameters(); i++) {
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
2721 LIR_Opr src = args->at(i);
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
2722 assert(!src->is_illegal(), "check");
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
2723 BasicType t = src->type();
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
2724 if (t == T_OBJECT || t == T_ARRAY) {
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
2725 intptr_t profiled_k = parameters->type(j);
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
2726 Local* local = x->state()->local_at(java_index)->as_Local();
13078
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
2727 ciKlass* exact = profile_type(md, md->byte_offset_of_slot(parameters_type_data, ParametersTypeData::type_offset(0)),
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
2728 in_bytes(ParametersTypeData::type_offset(j)) - in_bytes(ParametersTypeData::type_offset(0)),
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
2729 profiled_k, local, mdp, false, local->declared_type()->as_klass(), NULL);
12962
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
2730 // If the profile is known statically set it once for all and do not emit any code
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
2731 if (exact != NULL) {
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
2732 md->set_parameter_type(j, exact);
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
2733 }
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
2734 j++;
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
2735 }
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
2736 java_index += type2size[t];
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
2737 }
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
2738 }
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
2739 }
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
2740 }
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
2741
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2742 void LIRGenerator::do_Base(Base* x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2743 __ std_entry(LIR_OprFact::illegalOpr);
a61af66fc99e Initial load
duke
parents:
diff changeset
2744 // Emit moves from physical registers / stack slots to virtual registers
a61af66fc99e Initial load
duke
parents:
diff changeset
2745 CallingConvention* args = compilation()->frame_map()->incoming_arguments();
a61af66fc99e Initial load
duke
parents:
diff changeset
2746 IRScope* irScope = compilation()->hir()->top_scope();
a61af66fc99e Initial load
duke
parents:
diff changeset
2747 int java_index = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
2748 for (int i = 0; i < args->length(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2749 LIR_Opr src = args->at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
2750 assert(!src->is_illegal(), "check");
a61af66fc99e Initial load
duke
parents:
diff changeset
2751 BasicType t = src->type();
a61af66fc99e Initial load
duke
parents:
diff changeset
2752
a61af66fc99e Initial load
duke
parents:
diff changeset
2753 // Types which are smaller than int are passed as int, so
a61af66fc99e Initial load
duke
parents:
diff changeset
2754 // correct the type which passed.
a61af66fc99e Initial load
duke
parents:
diff changeset
2755 switch (t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2756 case T_BYTE:
a61af66fc99e Initial load
duke
parents:
diff changeset
2757 case T_BOOLEAN:
a61af66fc99e Initial load
duke
parents:
diff changeset
2758 case T_SHORT:
a61af66fc99e Initial load
duke
parents:
diff changeset
2759 case T_CHAR:
a61af66fc99e Initial load
duke
parents:
diff changeset
2760 t = T_INT;
a61af66fc99e Initial load
duke
parents:
diff changeset
2761 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2762 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2763
a61af66fc99e Initial load
duke
parents:
diff changeset
2764 LIR_Opr dest = new_register(t);
a61af66fc99e Initial load
duke
parents:
diff changeset
2765 __ move(src, dest);
a61af66fc99e Initial load
duke
parents:
diff changeset
2766
a61af66fc99e Initial load
duke
parents:
diff changeset
2767 // Assign new location to Local instruction for this local
a61af66fc99e Initial load
duke
parents:
diff changeset
2768 Local* local = x->state()->local_at(java_index)->as_Local();
a61af66fc99e Initial load
duke
parents:
diff changeset
2769 assert(local != NULL, "Locals for incoming arguments must have been created");
1681
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1584
diff changeset
2770 #ifndef __SOFTFP__
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1584
diff changeset
2771 // The java calling convention passes double as long and float as int.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2772 assert(as_ValueType(t)->tag() == local->type()->tag(), "check");
1681
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1584
diff changeset
2773 #endif // __SOFTFP__
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2774 local->set_operand(dest);
a61af66fc99e Initial load
duke
parents:
diff changeset
2775 _instruction_for_operand.at_put_grow(dest->vreg_number(), local, NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
2776 java_index += type2size[t];
a61af66fc99e Initial load
duke
parents:
diff changeset
2777 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2778
780
c96bf21b756f 6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents: 579
diff changeset
2779 if (compilation()->env()->dtrace_method_probes()) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2780 BasicTypeList signature;
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2781 signature.append(LP64_ONLY(T_LONG) NOT_LP64(T_INT)); // thread
12969
9acbfe04b5c3 8026495: JVM Crashes when started with -XX:+DTraceMethodProbes on Solaris x86_64
iveresov
parents: 12962
diff changeset
2782 signature.append(T_METADATA); // Method*
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2783 LIR_OprList* args = new LIR_OprList();
a61af66fc99e Initial load
duke
parents:
diff changeset
2784 args->append(getThreadPointer());
6739
8a02ca5e5576 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 6731
diff changeset
2785 LIR_Opr meth = new_register(T_METADATA);
8a02ca5e5576 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 6731
diff changeset
2786 __ metadata2reg(method()->constant_encoding(), meth);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2787 args->append(meth);
a61af66fc99e Initial load
duke
parents:
diff changeset
2788 call_runtime(&signature, args, CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_entry), voidType, NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
2789 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2790
a61af66fc99e Initial load
duke
parents:
diff changeset
2791 if (method()->is_synchronized()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2792 LIR_Opr obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
2793 if (method()->is_static()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2794 obj = new_register(T_OBJECT);
989
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 819
diff changeset
2795 __ oop2reg(method()->holder()->java_mirror()->constant_encoding(), obj);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2796 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2797 Local* receiver = x->state()->local_at(0)->as_Local();
a61af66fc99e Initial load
duke
parents:
diff changeset
2798 assert(receiver != NULL, "must already exist");
a61af66fc99e Initial load
duke
parents:
diff changeset
2799 obj = receiver->operand();
a61af66fc99e Initial load
duke
parents:
diff changeset
2800 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2801 assert(obj->is_valid(), "must be valid");
a61af66fc99e Initial load
duke
parents:
diff changeset
2802
a61af66fc99e Initial load
duke
parents:
diff changeset
2803 if (method()->is_synchronized() && GenerateSynchronizationCode) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2804 LIR_Opr lock = new_register(T_INT);
a61af66fc99e Initial load
duke
parents:
diff changeset
2805 __ load_stack_address_monitor(0, lock);
a61af66fc99e Initial load
duke
parents:
diff changeset
2806
8860
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
2807 CodeEmitInfo* info = new CodeEmitInfo(scope()->start()->state()->copy(ValueStack::StateBefore, SynchronizationEntryBCI), NULL, x->check_flag(Instruction::DeoptimizeOnException));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2808 CodeStub* slow_path = new MonitorEnterStub(obj, lock, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
2809
a61af66fc99e Initial load
duke
parents:
diff changeset
2810 // receiver is guaranteed non-NULL so don't need CodeEmitInfo
a61af66fc99e Initial load
duke
parents:
diff changeset
2811 __ lock_object(syncTempOpr(), obj, lock, new_register(T_OBJECT), slow_path, NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
2812 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2813 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2814
a61af66fc99e Initial load
duke
parents:
diff changeset
2815 // increment invocation counters if needed
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
2816 if (!method()->is_accessor()) { // Accessors do not have MDOs, so no counting.
12962
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
2817 profile_parameters(x);
8860
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
2818 CodeEmitInfo* info = new CodeEmitInfo(scope()->start()->state()->copy(ValueStack::StateBefore, SynchronizationEntryBCI), NULL, false);
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
2819 increment_invocation_counter(info);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
2820 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2821
a61af66fc99e Initial load
duke
parents:
diff changeset
2822 // all blocks with a successor must end with an unconditional jump
a61af66fc99e Initial load
duke
parents:
diff changeset
2823 // to the successor even if they are consecutive
a61af66fc99e Initial load
duke
parents:
diff changeset
2824 __ jump(x->default_sux());
a61af66fc99e Initial load
duke
parents:
diff changeset
2825 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2826
a61af66fc99e Initial load
duke
parents:
diff changeset
2827
a61af66fc99e Initial load
duke
parents:
diff changeset
2828 void LIRGenerator::do_OsrEntry(OsrEntry* x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2829 // construct our frame and model the production of incoming pointer
a61af66fc99e Initial load
duke
parents:
diff changeset
2830 // to the OSR buffer.
a61af66fc99e Initial load
duke
parents:
diff changeset
2831 __ osr_entry(LIR_Assembler::osrBufferPointer());
a61af66fc99e Initial load
duke
parents:
diff changeset
2832 LIR_Opr result = rlock_result(x);
a61af66fc99e Initial load
duke
parents:
diff changeset
2833 __ move(LIR_Assembler::osrBufferPointer(), result);
a61af66fc99e Initial load
duke
parents:
diff changeset
2834 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2835
a61af66fc99e Initial load
duke
parents:
diff changeset
2836
a61af66fc99e Initial load
duke
parents:
diff changeset
2837 void LIRGenerator::invoke_load_arguments(Invoke* x, LIRItemList* args, const LIR_OprList* arg_list) {
6616
7a302948f5a4 7192167: JSR 292: C1 has old broken code which needs to be removed
twisti
parents: 6615
diff changeset
2838 assert(args->length() == arg_list->length(),
7a302948f5a4 7192167: JSR 292: C1 has old broken code which needs to be removed
twisti
parents: 6615
diff changeset
2839 err_msg_res("args=%d, arg_list=%d", args->length(), arg_list->length()));
7a302948f5a4 7192167: JSR 292: C1 has old broken code which needs to be removed
twisti
parents: 6615
diff changeset
2840 for (int i = x->has_receiver() ? 1 : 0; i < args->length(); i++) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2841 LIRItem* param = args->at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
2842 LIR_Opr loc = arg_list->at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
2843 if (loc->is_register()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2844 param->load_item_force(loc);
a61af66fc99e Initial load
duke
parents:
diff changeset
2845 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2846 LIR_Address* addr = loc->as_address_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
2847 param->load_for_store(addr->type());
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2848 if (addr->type() == T_OBJECT) {
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2849 __ move_wide(param->result(), addr);
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2850 } else
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2851 if (addr->type() == T_LONG || addr->type() == T_DOUBLE) {
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2852 __ unaligned_move(param->result(), addr);
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2853 } else {
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2854 __ move(param->result(), addr);
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2855 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2856 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2857 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2858
a61af66fc99e Initial load
duke
parents:
diff changeset
2859 if (x->has_receiver()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2860 LIRItem* receiver = args->at(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2861 LIR_Opr loc = arg_list->at(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2862 if (loc->is_register()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2863 receiver->load_item_force(loc);
a61af66fc99e Initial load
duke
parents:
diff changeset
2864 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2865 assert(loc->is_address(), "just checking");
a61af66fc99e Initial load
duke
parents:
diff changeset
2866 receiver->load_for_store(T_OBJECT);
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
2867 __ move_wide(receiver->result(), loc->as_address_ptr());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2868 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2869 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2870 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2871
a61af66fc99e Initial load
duke
parents:
diff changeset
2872
a61af66fc99e Initial load
duke
parents:
diff changeset
2873 // Visits all arguments, returns appropriate items without loading them
a61af66fc99e Initial load
duke
parents:
diff changeset
2874 LIRItemList* LIRGenerator::invoke_visit_arguments(Invoke* x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2875 LIRItemList* argument_items = new LIRItemList();
a61af66fc99e Initial load
duke
parents:
diff changeset
2876 if (x->has_receiver()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2877 LIRItem* receiver = new LIRItem(x->receiver(), this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2878 argument_items->append(receiver);
a61af66fc99e Initial load
duke
parents:
diff changeset
2879 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2880 for (int i = 0; i < x->number_of_arguments(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2881 LIRItem* param = new LIRItem(x->argument_at(i), this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2882 argument_items->append(param);
a61af66fc99e Initial load
duke
parents:
diff changeset
2883 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2884 return argument_items;
a61af66fc99e Initial load
duke
parents:
diff changeset
2885 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2886
a61af66fc99e Initial load
duke
parents:
diff changeset
2887
a61af66fc99e Initial load
duke
parents:
diff changeset
2888 // The invoke with receiver has following phases:
a61af66fc99e Initial load
duke
parents:
diff changeset
2889 // a) traverse and load/lock receiver;
a61af66fc99e Initial load
duke
parents:
diff changeset
2890 // b) traverse all arguments -> item-array (invoke_visit_argument)
a61af66fc99e Initial load
duke
parents:
diff changeset
2891 // c) push receiver on stack
a61af66fc99e Initial load
duke
parents:
diff changeset
2892 // d) load each of the items and push on stack
a61af66fc99e Initial load
duke
parents:
diff changeset
2893 // e) unlock receiver
a61af66fc99e Initial load
duke
parents:
diff changeset
2894 // f) move receiver into receiver-register %o0
a61af66fc99e Initial load
duke
parents:
diff changeset
2895 // g) lock result registers and emit call operation
a61af66fc99e Initial load
duke
parents:
diff changeset
2896 //
a61af66fc99e Initial load
duke
parents:
diff changeset
2897 // Before issuing a call, we must spill-save all values on stack
23050
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 22851
diff changeset
2898 // that are in caller-save register. "spill-save" moves those registers
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2899 // either in a free callee-save register or spills them if no free
a61af66fc99e Initial load
duke
parents:
diff changeset
2900 // callee save register is available.
a61af66fc99e Initial load
duke
parents:
diff changeset
2901 //
a61af66fc99e Initial load
duke
parents:
diff changeset
2902 // The problem is where to invoke spill-save.
a61af66fc99e Initial load
duke
parents:
diff changeset
2903 // - if invoked between e) and f), we may lock callee save
a61af66fc99e Initial load
duke
parents:
diff changeset
2904 // register in "spill-save" that destroys the receiver register
a61af66fc99e Initial load
duke
parents:
diff changeset
2905 // before f) is executed
23050
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 22851
diff changeset
2906 // - if we rearrange f) to be earlier (by loading %o0) it
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2907 // may destroy a value on the stack that is currently in %o0
a61af66fc99e Initial load
duke
parents:
diff changeset
2908 // and is waiting to be spilled
a61af66fc99e Initial load
duke
parents:
diff changeset
2909 // - if we keep the receiver locked while doing spill-save,
a61af66fc99e Initial load
duke
parents:
diff changeset
2910 // we cannot spill it as it is spill-locked
a61af66fc99e Initial load
duke
parents:
diff changeset
2911 //
a61af66fc99e Initial load
duke
parents:
diff changeset
2912 void LIRGenerator::do_Invoke(Invoke* x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2913 CallingConvention* cc = frame_map()->java_calling_convention(x->signature(), true);
a61af66fc99e Initial load
duke
parents:
diff changeset
2914
a61af66fc99e Initial load
duke
parents:
diff changeset
2915 LIR_OprList* arg_list = cc->args();
a61af66fc99e Initial load
duke
parents:
diff changeset
2916 LIRItemList* args = invoke_visit_arguments(x);
a61af66fc99e Initial load
duke
parents:
diff changeset
2917 LIR_Opr receiver = LIR_OprFact::illegalOpr;
a61af66fc99e Initial load
duke
parents:
diff changeset
2918
a61af66fc99e Initial load
duke
parents:
diff changeset
2919 // setup result register
a61af66fc99e Initial load
duke
parents:
diff changeset
2920 LIR_Opr result_register = LIR_OprFact::illegalOpr;
a61af66fc99e Initial load
duke
parents:
diff changeset
2921 if (x->type() != voidType) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2922 result_register = result_register_for(x->type());
a61af66fc99e Initial load
duke
parents:
diff changeset
2923 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2924
a61af66fc99e Initial load
duke
parents:
diff changeset
2925 CodeEmitInfo* info = state_for(x, x->state());
a61af66fc99e Initial load
duke
parents:
diff changeset
2926
a61af66fc99e Initial load
duke
parents:
diff changeset
2927 invoke_load_arguments(x, args, arg_list);
a61af66fc99e Initial load
duke
parents:
diff changeset
2928
a61af66fc99e Initial load
duke
parents:
diff changeset
2929 if (x->has_receiver()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2930 args->at(0)->load_item_force(LIR_Assembler::receiverOpr());
a61af66fc99e Initial load
duke
parents:
diff changeset
2931 receiver = args->at(0)->result();
a61af66fc99e Initial load
duke
parents:
diff changeset
2932 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2933
a61af66fc99e Initial load
duke
parents:
diff changeset
2934 // emit invoke code
a61af66fc99e Initial load
duke
parents:
diff changeset
2935 bool optimized = x->target_is_loaded() && x->target_is_final();
a61af66fc99e Initial load
duke
parents:
diff changeset
2936 assert(receiver->is_illegal() || receiver->is_equal(LIR_Assembler::receiverOpr()), "must match");
a61af66fc99e Initial load
duke
parents:
diff changeset
2937
1564
61b2245abf36 6930772: JSR 292 needs to support SPARC C1
twisti
parents: 1378
diff changeset
2938 // JSR 292
23050
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 22851
diff changeset
2939 // Preserve the SP over MethodHandle call sites, if needed.
1564
61b2245abf36 6930772: JSR 292 needs to support SPARC C1
twisti
parents: 1378
diff changeset
2940 ciMethod* target = x->target();
6266
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 6145
diff changeset
2941 bool is_method_handle_invoke = (// %%% FIXME: Are both of these relevant?
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 6145
diff changeset
2942 target->is_method_handle_intrinsic() ||
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 6145
diff changeset
2943 target->is_compiled_lambda_form());
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 6145
diff changeset
2944 if (is_method_handle_invoke) {
1564
61b2245abf36 6930772: JSR 292 needs to support SPARC C1
twisti
parents: 1378
diff changeset
2945 info->set_is_method_handle_invoke(true);
23050
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 22851
diff changeset
2946 if(FrameMap::method_handle_invoke_SP_save_opr() != LIR_OprFact::illegalOpr) {
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 22851
diff changeset
2947 __ move(FrameMap::stack_pointer(), FrameMap::method_handle_invoke_SP_save_opr());
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 22851
diff changeset
2948 }
1564
61b2245abf36 6930772: JSR 292 needs to support SPARC C1
twisti
parents: 1378
diff changeset
2949 }
61b2245abf36 6930772: JSR 292 needs to support SPARC C1
twisti
parents: 1378
diff changeset
2950
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2951 switch (x->code()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2952 case Bytecodes::_invokestatic:
1564
61b2245abf36 6930772: JSR 292 needs to support SPARC C1
twisti
parents: 1378
diff changeset
2953 __ call_static(target, result_register,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2954 SharedRuntime::get_resolve_static_call_stub(),
a61af66fc99e Initial load
duke
parents:
diff changeset
2955 arg_list, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
2956 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2957 case Bytecodes::_invokespecial:
a61af66fc99e Initial load
duke
parents:
diff changeset
2958 case Bytecodes::_invokevirtual:
a61af66fc99e Initial load
duke
parents:
diff changeset
2959 case Bytecodes::_invokeinterface:
a61af66fc99e Initial load
duke
parents:
diff changeset
2960 // for final target we still produce an inline cache, in order
a61af66fc99e Initial load
duke
parents:
diff changeset
2961 // to be able to call mixed mode
a61af66fc99e Initial load
duke
parents:
diff changeset
2962 if (x->code() == Bytecodes::_invokespecial || optimized) {
1564
61b2245abf36 6930772: JSR 292 needs to support SPARC C1
twisti
parents: 1378
diff changeset
2963 __ call_opt_virtual(target, receiver, result_register,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2964 SharedRuntime::get_resolve_opt_virtual_call_stub(),
a61af66fc99e Initial load
duke
parents:
diff changeset
2965 arg_list, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
2966 } else if (x->vtable_index() < 0) {
1564
61b2245abf36 6930772: JSR 292 needs to support SPARC C1
twisti
parents: 1378
diff changeset
2967 __ call_icvirtual(target, receiver, result_register,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2968 SharedRuntime::get_resolve_virtual_call_stub(),
a61af66fc99e Initial load
duke
parents:
diff changeset
2969 arg_list, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
2970 } else {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6616
diff changeset
2971 int entry_offset = InstanceKlass::vtable_start_offset() + x->vtable_index() * vtableEntry::size();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2972 int vtable_offset = entry_offset * wordSize + vtableEntry::method_offset_in_bytes();
1564
61b2245abf36 6930772: JSR 292 needs to support SPARC C1
twisti
parents: 1378
diff changeset
2973 __ call_virtual(target, receiver, result_register, vtable_offset, arg_list, info);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2974 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2975 break;
1295
3cf667df43ef 6919934: JSR 292 needs to support x86 C1
twisti
parents: 1213
diff changeset
2976 case Bytecodes::_invokedynamic: {
1564
61b2245abf36 6930772: JSR 292 needs to support SPARC C1
twisti
parents: 1378
diff changeset
2977 __ call_dynamic(target, receiver, result_register,
6616
7a302948f5a4 7192167: JSR 292: C1 has old broken code which needs to be removed
twisti
parents: 6615
diff changeset
2978 SharedRuntime::get_resolve_static_call_stub(),
1295
3cf667df43ef 6919934: JSR 292 needs to support x86 C1
twisti
parents: 1213
diff changeset
2979 arg_list, info);
3cf667df43ef 6919934: JSR 292 needs to support x86 C1
twisti
parents: 1213
diff changeset
2980 break;
3cf667df43ef 6919934: JSR 292 needs to support x86 C1
twisti
parents: 1213
diff changeset
2981 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2982 default:
6145
e2fe93124108 7174928: JSR 292: unresolved invokedynamic call sites deopt and osr infinitely
twisti
parents: 6143
diff changeset
2983 fatal(err_msg("unexpected bytecode: %s", Bytecodes::name(x->code())));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2984 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2985 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2986
1564
61b2245abf36 6930772: JSR 292 needs to support SPARC C1
twisti
parents: 1378
diff changeset
2987 // JSR 292
23050
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 22851
diff changeset
2988 // Restore the SP after MethodHandle call sites, if needed.
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 22851
diff changeset
2989 if (is_method_handle_invoke
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 22851
diff changeset
2990 && FrameMap::method_handle_invoke_SP_save_opr() != LIR_OprFact::illegalOpr) {
1564
61b2245abf36 6930772: JSR 292 needs to support SPARC C1
twisti
parents: 1378
diff changeset
2991 __ move(FrameMap::method_handle_invoke_SP_save_opr(), FrameMap::stack_pointer());
61b2245abf36 6930772: JSR 292 needs to support SPARC C1
twisti
parents: 1378
diff changeset
2992 }
61b2245abf36 6930772: JSR 292 needs to support SPARC C1
twisti
parents: 1378
diff changeset
2993
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2994 if (x->type()->is_float() || x->type()->is_double()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2995 // Force rounding of results from non-strictfp when in strictfp
a61af66fc99e Initial load
duke
parents:
diff changeset
2996 // scope (or when we don't know the strictness of the callee, to
a61af66fc99e Initial load
duke
parents:
diff changeset
2997 // be safe.)
a61af66fc99e Initial load
duke
parents:
diff changeset
2998 if (method()->is_strict()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2999 if (!x->target_is_loaded() || !x->target_is_strictfp()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3000 result_register = round_item(result_register);
a61af66fc99e Initial load
duke
parents:
diff changeset
3001 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3002 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3003 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3004
a61af66fc99e Initial load
duke
parents:
diff changeset
3005 if (result_register->is_valid()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3006 LIR_Opr result = rlock_result(x);
a61af66fc99e Initial load
duke
parents:
diff changeset
3007 __ move(result_register, result);
a61af66fc99e Initial load
duke
parents:
diff changeset
3008 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3009 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3010
a61af66fc99e Initial load
duke
parents:
diff changeset
3011
a61af66fc99e Initial load
duke
parents:
diff changeset
3012 void LIRGenerator::do_FPIntrinsics(Intrinsic* x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3013 assert(x->number_of_arguments() == 1, "wrong type");
a61af66fc99e Initial load
duke
parents:
diff changeset
3014 LIRItem value (x->argument_at(0), this);
a61af66fc99e Initial load
duke
parents:
diff changeset
3015 LIR_Opr reg = rlock_result(x);
a61af66fc99e Initial load
duke
parents:
diff changeset
3016 value.load_item();
a61af66fc99e Initial load
duke
parents:
diff changeset
3017 LIR_Opr tmp = force_to_spill(value.result(), as_BasicType(x->type()));
a61af66fc99e Initial load
duke
parents:
diff changeset
3018 __ move(tmp, reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
3019 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3020
a61af66fc99e Initial load
duke
parents:
diff changeset
3021
a61af66fc99e Initial load
duke
parents:
diff changeset
3022
a61af66fc99e Initial load
duke
parents:
diff changeset
3023 // Code for : x->x() {x->cond()} x->y() ? x->tval() : x->fval()
a61af66fc99e Initial load
duke
parents:
diff changeset
3024 void LIRGenerator::do_IfOp(IfOp* x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3025 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
3026 {
a61af66fc99e Initial load
duke
parents:
diff changeset
3027 ValueTag xtag = x->x()->type()->tag();
a61af66fc99e Initial load
duke
parents:
diff changeset
3028 ValueTag ttag = x->tval()->type()->tag();
a61af66fc99e Initial load
duke
parents:
diff changeset
3029 assert(xtag == intTag || xtag == objectTag, "cannot handle others");
a61af66fc99e Initial load
duke
parents:
diff changeset
3030 assert(ttag == addressTag || ttag == intTag || ttag == objectTag || ttag == longTag, "cannot handle others");
a61af66fc99e Initial load
duke
parents:
diff changeset
3031 assert(ttag == x->fval()->type()->tag(), "cannot handle others");
a61af66fc99e Initial load
duke
parents:
diff changeset
3032 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3033 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
3034
a61af66fc99e Initial load
duke
parents:
diff changeset
3035 LIRItem left(x->x(), this);
a61af66fc99e Initial load
duke
parents:
diff changeset
3036 LIRItem right(x->y(), this);
a61af66fc99e Initial load
duke
parents:
diff changeset
3037 left.load_item();
a61af66fc99e Initial load
duke
parents:
diff changeset
3038 if (can_inline_as_constant(right.value())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3039 right.dont_load_item();
a61af66fc99e Initial load
duke
parents:
diff changeset
3040 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3041 right.load_item();
a61af66fc99e Initial load
duke
parents:
diff changeset
3042 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3043
a61af66fc99e Initial load
duke
parents:
diff changeset
3044 LIRItem t_val(x->tval(), this);
a61af66fc99e Initial load
duke
parents:
diff changeset
3045 LIRItem f_val(x->fval(), this);
a61af66fc99e Initial load
duke
parents:
diff changeset
3046 t_val.dont_load_item();
a61af66fc99e Initial load
duke
parents:
diff changeset
3047 f_val.dont_load_item();
a61af66fc99e Initial load
duke
parents:
diff changeset
3048 LIR_Opr reg = rlock_result(x);
a61af66fc99e Initial load
duke
parents:
diff changeset
3049
a61af66fc99e Initial load
duke
parents:
diff changeset
3050 __ cmp(lir_cond(x->cond()), left.result(), right.result());
2089
037c727f35fb 7009231: C1: Incorrect CAS code for longs on SPARC 32bit
iveresov
parents: 2007
diff changeset
3051 __ cmove(lir_cond(x->cond()), t_val.result(), f_val.result(), reg, as_BasicType(x->x()->type()));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3052 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3053
6006
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3054 void LIRGenerator::do_RuntimeCall(address routine, int expected_arguments, Intrinsic* x) {
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3055 assert(x->number_of_arguments() == expected_arguments, "wrong type");
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3056 LIR_Opr reg = result_register_for(x->type());
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3057 __ call_runtime_leaf(routine, getThreadTemp(),
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3058 reg, new LIR_OprList());
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3059 LIR_Opr result = rlock_result(x);
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3060 __ move(reg, result);
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3061 }
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3062
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3063 #ifdef TRACE_HAVE_INTRINSICS
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3064 void LIRGenerator::do_ThreadIDIntrinsic(Intrinsic* x) {
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3065 LIR_Opr thread = getThreadPointer();
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3066 LIR_Opr osthread = new_pointer_register();
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3067 __ move(new LIR_Address(thread, in_bytes(JavaThread::osthread_offset()), osthread->type()), osthread);
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3068 size_t thread_id_size = OSThread::thread_id_size();
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3069 if (thread_id_size == (size_t) BytesPerLong) {
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3070 LIR_Opr id = new_register(T_LONG);
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3071 __ move(new LIR_Address(osthread, in_bytes(OSThread::thread_id_offset()), T_LONG), id);
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3072 __ convert(Bytecodes::_l2i, id, rlock_result(x));
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3073 } else if (thread_id_size == (size_t) BytesPerInt) {
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3074 __ move(new LIR_Address(osthread, in_bytes(OSThread::thread_id_offset()), T_INT), rlock_result(x));
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3075 } else {
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3076 ShouldNotReachHere();
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3077 }
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3078 }
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3079
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3080 void LIRGenerator::do_ClassIDIntrinsic(Intrinsic* x) {
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3081 CodeEmitInfo* info = state_for(x);
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3082 CodeEmitInfo* info2 = new CodeEmitInfo(info); // Clone for the second null check
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6616
diff changeset
3083 BasicType klass_pointer_type = NOT_LP64(T_INT) LP64_ONLY(T_LONG);
6006
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3084 assert(info != NULL, "must have info");
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3085 LIRItem arg(x->argument_at(1), this);
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3086 arg.load_item();
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6616
diff changeset
3087 LIR_Opr klass = new_pointer_register();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6616
diff changeset
3088 __ move(new LIR_Address(arg.result(), java_lang_Class::klass_offset_in_bytes(), klass_pointer_type), klass, info);
6006
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3089 LIR_Opr id = new_register(T_LONG);
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3090 ByteSize offset = TRACE_ID_OFFSET;
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3091 LIR_Address* trace_id_addr = new LIR_Address(klass, in_bytes(offset), T_LONG);
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3092 __ move(trace_id_addr, id);
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3093 __ logical_or(id, LIR_OprFact::longConst(0x01l), id);
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3094 __ store(id, trace_id_addr);
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3095 __ logical_and(id, LIR_OprFact::longConst(~0x3l), id);
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3096 __ move(id, rlock_result(x));
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3097 }
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3098 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3099
a61af66fc99e Initial load
duke
parents:
diff changeset
3100 void LIRGenerator::do_Intrinsic(Intrinsic* x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3101 switch (x->id()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3102 case vmIntrinsics::_intBitsToFloat :
a61af66fc99e Initial load
duke
parents:
diff changeset
3103 case vmIntrinsics::_doubleToRawLongBits :
a61af66fc99e Initial load
duke
parents:
diff changeset
3104 case vmIntrinsics::_longBitsToDouble :
a61af66fc99e Initial load
duke
parents:
diff changeset
3105 case vmIntrinsics::_floatToRawIntBits : {
a61af66fc99e Initial load
duke
parents:
diff changeset
3106 do_FPIntrinsics(x);
a61af66fc99e Initial load
duke
parents:
diff changeset
3107 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
3108 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3109
6006
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3110 #ifdef TRACE_HAVE_INTRINSICS
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3111 case vmIntrinsics::_threadID: do_ThreadIDIntrinsic(x); break;
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3112 case vmIntrinsics::_classID: do_ClassIDIntrinsic(x); break;
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3113 case vmIntrinsics::_counterTime:
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3114 do_RuntimeCall(CAST_FROM_FN_PTR(address, TRACE_TIME_METHOD), 0, x);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3115 break;
6006
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3116 #endif
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3117
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3118 case vmIntrinsics::_currentTimeMillis:
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3119 do_RuntimeCall(CAST_FROM_FN_PTR(address, os::javaTimeMillis), 0, x);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3120 break;
6006
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3121
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3122 case vmIntrinsics::_nanoTime:
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3123 do_RuntimeCall(CAST_FROM_FN_PTR(address, os::javaTimeNanos), 0, x);
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 4966
diff changeset
3124 break;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3125
a61af66fc99e Initial load
duke
parents:
diff changeset
3126 case vmIntrinsics::_Object_init: do_RegisterFinalizer(x); break;
6135
8f37087fc13f 7171890: C1: add Class.isInstance intrinsic
roland
parents: 6084
diff changeset
3127 case vmIntrinsics::_isInstance: do_isInstance(x); break;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3128 case vmIntrinsics::_getClass: do_getClass(x); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
3129 case vmIntrinsics::_currentThread: do_currentThread(x); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
3130
a61af66fc99e Initial load
duke
parents:
diff changeset
3131 case vmIntrinsics::_dlog: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
3132 case vmIntrinsics::_dlog10: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
3133 case vmIntrinsics::_dabs: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
3134 case vmIntrinsics::_dsqrt: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
3135 case vmIntrinsics::_dtan: // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
3136 case vmIntrinsics::_dsin : // fall through
6084
6759698e3140 7133857: exp() and pow() should use the x87 ISA on x86
roland
parents: 6006
diff changeset
3137 case vmIntrinsics::_dcos : // fall through
6759698e3140 7133857: exp() and pow() should use the x87 ISA on x86
roland
parents: 6006
diff changeset
3138 case vmIntrinsics::_dexp : // fall through
6759698e3140 7133857: exp() and pow() should use the x87 ISA on x86
roland
parents: 6006
diff changeset
3139 case vmIntrinsics::_dpow : do_MathIntrinsic(x); break;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3140 case vmIntrinsics::_arraycopy: do_ArrayCopy(x); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
3141
a61af66fc99e Initial load
duke
parents:
diff changeset
3142 // java.nio.Buffer.checkIndex
a61af66fc99e Initial load
duke
parents:
diff changeset
3143 case vmIntrinsics::_checkIndex: do_NIOCheckIndex(x); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
3144
a61af66fc99e Initial load
duke
parents:
diff changeset
3145 case vmIntrinsics::_compareAndSwapObject:
a61af66fc99e Initial load
duke
parents:
diff changeset
3146 do_CompareAndSwap(x, objectType);
a61af66fc99e Initial load
duke
parents:
diff changeset
3147 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
3148 case vmIntrinsics::_compareAndSwapInt:
a61af66fc99e Initial load
duke
parents:
diff changeset
3149 do_CompareAndSwap(x, intType);
a61af66fc99e Initial load
duke
parents:
diff changeset
3150 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
3151 case vmIntrinsics::_compareAndSwapLong:
a61af66fc99e Initial load
duke
parents:
diff changeset
3152 do_CompareAndSwap(x, longType);
a61af66fc99e Initial load
duke
parents:
diff changeset
3153 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
3154
7425
1e41b0bc58a0 8004318: JEP-171: Support Unsafe fences intrinsics
kvn
parents: 6848
diff changeset
3155 case vmIntrinsics::_loadFence :
1e41b0bc58a0 8004318: JEP-171: Support Unsafe fences intrinsics
kvn
parents: 6848
diff changeset
3156 if (os::is_MP()) __ membar_acquire();
1e41b0bc58a0 8004318: JEP-171: Support Unsafe fences intrinsics
kvn
parents: 6848
diff changeset
3157 break;
1e41b0bc58a0 8004318: JEP-171: Support Unsafe fences intrinsics
kvn
parents: 6848
diff changeset
3158 case vmIntrinsics::_storeFence:
1e41b0bc58a0 8004318: JEP-171: Support Unsafe fences intrinsics
kvn
parents: 6848
diff changeset
3159 if (os::is_MP()) __ membar_release();
1e41b0bc58a0 8004318: JEP-171: Support Unsafe fences intrinsics
kvn
parents: 6848
diff changeset
3160 break;
1e41b0bc58a0 8004318: JEP-171: Support Unsafe fences intrinsics
kvn
parents: 6848
diff changeset
3161 case vmIntrinsics::_fullFence :
1e41b0bc58a0 8004318: JEP-171: Support Unsafe fences intrinsics
kvn
parents: 6848
diff changeset
3162 if (os::is_MP()) __ membar();
1e41b0bc58a0 8004318: JEP-171: Support Unsafe fences intrinsics
kvn
parents: 6848
diff changeset
3163 break;
1e41b0bc58a0 8004318: JEP-171: Support Unsafe fences intrinsics
kvn
parents: 6848
diff changeset
3164
3249
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
3165 case vmIntrinsics::_Reference_get:
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
3166 do_Reference_get(x);
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
3167 break;
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2357
diff changeset
3168
11080
b800986664f4 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 10397
diff changeset
3169 case vmIntrinsics::_updateCRC32:
b800986664f4 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 10397
diff changeset
3170 case vmIntrinsics::_updateBytesCRC32:
b800986664f4 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 10397
diff changeset
3171 case vmIntrinsics::_updateByteBufferCRC32:
b800986664f4 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 10397
diff changeset
3172 do_update_CRC32(x);
b800986664f4 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 10397
diff changeset
3173 break;
b800986664f4 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 10397
diff changeset
3174
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3175 default: ShouldNotReachHere(); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
3176 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3177 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3178
12875
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
3179 void LIRGenerator::profile_arguments(ProfileCall* x) {
12962
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3180 if (compilation()->profile_arguments()) {
12875
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
3181 int bci = x->bci_of_invoke();
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
3182 ciMethodData* md = x->method()->method_data_or_null();
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
3183 ciProfileData* data = md->bci_to_data(bci);
12962
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3184 if ((data->is_CallTypeData() && data->as_CallTypeData()->has_arguments()) ||
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3185 (data->is_VirtualCallTypeData() && data->as_VirtualCallTypeData()->has_arguments())) {
12875
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
3186 ByteSize extra = data->is_CallTypeData() ? CallTypeData::args_data_offset() : VirtualCallTypeData::args_data_offset();
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
3187 int base_offset = md->byte_offset_of_slot(data, extra);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
3188 LIR_Opr mdp = LIR_OprFact::illegalOpr;
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
3189 ciTypeStackSlotEntries* args = data->is_CallTypeData() ? ((ciCallTypeData*)data)->args() : ((ciVirtualCallTypeData*)data)->args();
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
3190
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
3191 Bytecodes::Code bc = x->method()->java_code_at_bci(bci);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
3192 int start = 0;
12882
ce0cc25bc5e2 8026054: New type profiling points: type of return values at calls
roland
parents: 12875
diff changeset
3193 int stop = data->is_CallTypeData() ? ((ciCallTypeData*)data)->number_of_arguments() : ((ciVirtualCallTypeData*)data)->number_of_arguments();
13078
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
3194 if (x->inlined() && x->callee()->is_static() && Bytecodes::has_receiver(bc)) {
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
3195 // first argument is not profiled at call (method handle invoke)
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
3196 assert(x->method()->raw_code_at_bci(bci) == Bytecodes::_invokehandle, "invokehandle expected");
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
3197 start = 1;
12875
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
3198 }
13078
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
3199 ciSignature* callee_signature = x->callee()->signature();
12875
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
3200 // method handle call to virtual method
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
3201 bool has_receiver = x->inlined() && !x->callee()->is_static() && !Bytecodes::has_receiver(bc);
13078
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
3202 ciSignatureStream callee_signature_stream(callee_signature, has_receiver ? x->callee()->holder() : NULL);
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
3203
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
3204 bool ignored_will_link;
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
3205 ciSignature* signature_at_call = NULL;
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
3206 x->method()->get_method_at_bci(bci, ignored_will_link, &signature_at_call);
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
3207 ciSignatureStream signature_at_call_stream(signature_at_call);
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
3208
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
3209 // if called through method handle invoke, some arguments may have been popped
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
3210 for (int i = 0; i < stop && i+start < x->nb_profiled_args(); i++) {
12882
ce0cc25bc5e2 8026054: New type profiling points: type of return values at calls
roland
parents: 12875
diff changeset
3211 int off = in_bytes(TypeEntriesAtCall::argument_type_offset(i)) - in_bytes(TypeEntriesAtCall::args_data_offset());
13078
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
3212 ciKlass* exact = profile_type(md, base_offset, off,
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
3213 args->type(i), x->profiled_arg_at(i+start), mdp,
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
3214 !x->arg_needs_null_check(i+start),
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
3215 signature_at_call_stream.next_klass(), callee_signature_stream.next_klass());
12875
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
3216 if (exact != NULL) {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
3217 md->set_argument_type(bci, i, exact);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
3218 }
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
3219 }
12962
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3220 } else {
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3221 #ifdef ASSERT
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3222 Bytecodes::Code code = x->method()->raw_code_at_bci(x->bci_of_invoke());
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3223 int n = x->nb_profiled_args();
17900
ce9fd31ffd14 8039975: SIGSEGV in MethodData::next_data(ProfileData*)
roland
parents: 17628
diff changeset
3224 assert(MethodData::profile_parameters() && (MethodData::profile_arguments_jsr292_only() ||
ce9fd31ffd14 8039975: SIGSEGV in MethodData::next_data(ProfileData*)
roland
parents: 17628
diff changeset
3225 (x->inlined() && ((code == Bytecodes::_invokedynamic && n <= 1) || (code == Bytecodes::_invokehandle && n <= 2)))),
12962
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3226 "only at JSR292 bytecodes");
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3227 #endif
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3228 }
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3229 }
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3230 }
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3231
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3232 // profile parameters on entry to an inlined method
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3233 void LIRGenerator::profile_parameters_at_call(ProfileCall* x) {
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3234 if (compilation()->profile_parameters() && x->inlined()) {
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3235 ciMethodData* md = x->callee()->method_data_or_null();
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3236 if (md != NULL) {
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3237 ciParametersTypeData* parameters_type_data = md->parameters_type_data();
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3238 if (parameters_type_data != NULL) {
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3239 ciTypeStackSlotEntries* parameters = parameters_type_data->parameters();
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3240 LIR_Opr mdp = LIR_OprFact::illegalOpr;
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3241 bool has_receiver = !x->callee()->is_static();
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3242 ciSignature* sig = x->callee()->signature();
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3243 ciSignatureStream sig_stream(sig, has_receiver ? x->callee()->holder() : NULL);
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3244 int i = 0; // to iterate on the Instructions
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3245 Value arg = x->recv();
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3246 bool not_null = false;
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3247 int bci = x->bci_of_invoke();
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3248 Bytecodes::Code bc = x->method()->java_code_at_bci(bci);
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3249 // The first parameter is the receiver so that's what we start
13078
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
3250 // with if it exists. One exception is method handle call to
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
3251 // virtual method: the receiver is in the args list
12962
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3252 if (arg == NULL || !Bytecodes::has_receiver(bc)) {
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3253 i = 1;
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3254 arg = x->profiled_arg_at(0);
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3255 not_null = !x->arg_needs_null_check(0);
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3256 }
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3257 int k = 0; // to iterate on the profile data
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3258 for (;;) {
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3259 intptr_t profiled_k = parameters->type(k);
13078
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
3260 ciKlass* exact = profile_type(md, md->byte_offset_of_slot(parameters_type_data, ParametersTypeData::type_offset(0)),
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
3261 in_bytes(ParametersTypeData::type_offset(k)) - in_bytes(ParametersTypeData::type_offset(0)),
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
3262 profiled_k, arg, mdp, not_null, sig_stream.next_klass(), NULL);
12962
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3263 // If the profile is known statically set it once for all and do not emit any code
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3264 if (exact != NULL) {
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3265 md->set_parameter_type(k, exact);
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3266 }
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3267 k++;
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3268 if (k >= parameters_type_data->number_of_parameters()) {
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3269 #ifdef ASSERT
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3270 int extra = 0;
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3271 if (MethodData::profile_arguments() && TypeProfileParmsLimit != -1 &&
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3272 x->nb_profiled_args() >= TypeProfileParmsLimit &&
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3273 x->recv() != NULL && Bytecodes::has_receiver(bc)) {
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3274 extra += 1;
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3275 }
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3276 assert(i == x->nb_profiled_args() - extra || (TypeProfileParmsLimit != -1 && TypeProfileArgsLimit > TypeProfileParmsLimit), "unused parameters?");
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3277 #endif
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3278 break;
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3279 }
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3280 arg = x->profiled_arg_at(i);
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3281 not_null = !x->arg_needs_null_check(i);
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3282 i++;
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3283 }
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3284 }
12875
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
3285 }
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
3286 }
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
3287 }
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
3288
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3289 void LIRGenerator::do_ProfileCall(ProfileCall* x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3290 // Need recv in a temporary register so it interferes with the other temporaries
a61af66fc99e Initial load
duke
parents:
diff changeset
3291 LIR_Opr recv = LIR_OprFact::illegalOpr;
a61af66fc99e Initial load
duke
parents:
diff changeset
3292 LIR_Opr mdo = new_register(T_OBJECT);
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3293 // tmp is used to hold the counters on SPARC
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3294 LIR_Opr tmp = new_pointer_register();
12875
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
3295
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
3296 if (x->nb_profiled_args() > 0) {
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
3297 profile_arguments(x);
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
3298 }
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 12868
diff changeset
3299
12962
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3300 // profile parameters on inlined method entry including receiver
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3301 if (x->recv() != NULL || x->nb_profiled_args() > 0) {
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3302 profile_parameters_at_call(x);
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3303 }
5ccbab1c69f3 8026251: New type profiling points: parameters to methods
roland
parents: 12955
diff changeset
3304
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3305 if (x->recv() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3306 LIRItem value(x->recv(), this);
a61af66fc99e Initial load
duke
parents:
diff changeset
3307 value.load_item();
a61af66fc99e Initial load
duke
parents:
diff changeset
3308 recv = new_register(T_OBJECT);
a61af66fc99e Initial load
duke
parents:
diff changeset
3309 __ move(value.result(), recv);
a61af66fc99e Initial load
duke
parents:
diff changeset
3310 }
6266
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 6145
diff changeset
3311 __ profile_call(x->method(), x->bci_of_invoke(), x->callee(), mdo, recv, tmp, x->known_holder());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3312 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3313
12882
ce0cc25bc5e2 8026054: New type profiling points: type of return values at calls
roland
parents: 12875
diff changeset
3314 void LIRGenerator::do_ProfileReturnType(ProfileReturnType* x) {
ce0cc25bc5e2 8026054: New type profiling points: type of return values at calls
roland
parents: 12875
diff changeset
3315 int bci = x->bci_of_invoke();
ce0cc25bc5e2 8026054: New type profiling points: type of return values at calls
roland
parents: 12875
diff changeset
3316 ciMethodData* md = x->method()->method_data_or_null();
ce0cc25bc5e2 8026054: New type profiling points: type of return values at calls
roland
parents: 12875
diff changeset
3317 ciProfileData* data = md->bci_to_data(bci);
ce0cc25bc5e2 8026054: New type profiling points: type of return values at calls
roland
parents: 12875
diff changeset
3318 assert(data->is_CallTypeData() || data->is_VirtualCallTypeData(), "wrong profile data type");
ce0cc25bc5e2 8026054: New type profiling points: type of return values at calls
roland
parents: 12875
diff changeset
3319 ciReturnTypeEntry* ret = data->is_CallTypeData() ? ((ciCallTypeData*)data)->ret() : ((ciVirtualCallTypeData*)data)->ret();
ce0cc25bc5e2 8026054: New type profiling points: type of return values at calls
roland
parents: 12875
diff changeset
3320 LIR_Opr mdp = LIR_OprFact::illegalOpr;
13078
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
3321
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
3322 bool ignored_will_link;
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
3323 ciSignature* signature_at_call = NULL;
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
3324 x->method()->get_method_at_bci(bci, ignored_will_link, &signature_at_call);
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
3325
17628
add2caa66e7e 8026253: New type profiling points: sparc support
roland
parents: 13078
diff changeset
3326 // The offset within the MDO of the entry to update may be too large
add2caa66e7e 8026253: New type profiling points: sparc support
roland
parents: 13078
diff changeset
3327 // to be used in load/store instructions on some platforms. So have
add2caa66e7e 8026253: New type profiling points: sparc support
roland
parents: 13078
diff changeset
3328 // profile_type() compute the address of the profile in a register.
add2caa66e7e 8026253: New type profiling points: sparc support
roland
parents: 13078
diff changeset
3329 ciKlass* exact = profile_type(md, md->byte_offset_of_slot(data, ret->type_offset()), 0,
13078
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
3330 ret->type(), x->ret(), mdp,
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
3331 !x->needs_null_check(),
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
3332 signature_at_call->return_type()->as_klass(),
e6ba215af802 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 12969
diff changeset
3333 x->callee()->signature()->return_type()->as_klass());
12882
ce0cc25bc5e2 8026054: New type profiling points: type of return values at calls
roland
parents: 12875
diff changeset
3334 if (exact != NULL) {
ce0cc25bc5e2 8026054: New type profiling points: type of return values at calls
roland
parents: 12875
diff changeset
3335 md->set_return_type(bci, exact);
ce0cc25bc5e2 8026054: New type profiling points: type of return values at calls
roland
parents: 12875
diff changeset
3336 }
ce0cc25bc5e2 8026054: New type profiling points: type of return values at calls
roland
parents: 12875
diff changeset
3337 }
ce0cc25bc5e2 8026054: New type profiling points: type of return values at calls
roland
parents: 12875
diff changeset
3338
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3339 void LIRGenerator::do_ProfileInvoke(ProfileInvoke* x) {
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3340 // We can safely ignore accessors here, since c2 will inline them anyway,
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3341 // accessors are also always mature.
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3342 if (!x->inlinee()->is_accessor()) {
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3343 CodeEmitInfo* info = state_for(x, x->state(), true);
3964
dc45ae774613 7096639: Tiered: Incorrect counter overflow handling for inlined methods
iveresov
parents: 3756
diff changeset
3344 // Notify the runtime very infrequently only to take care of counter overflows
dc45ae774613 7096639: Tiered: Incorrect counter overflow handling for inlined methods
iveresov
parents: 3756
diff changeset
3345 increment_event_counter_impl(info, x->inlinee(), (1 << Tier23InlineeNotifyFreqLog) - 1, InvocationEntryBci, false, true);
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3346 }
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3347 }
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3348
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3349 void LIRGenerator::increment_event_counter(CodeEmitInfo* info, int bci, bool backedge) {
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3350 int freq_log;
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3351 int level = compilation()->env()->comp_level();
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3352 if (level == CompLevel_limited_profile) {
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3353 freq_log = (backedge ? Tier2BackedgeNotifyFreqLog : Tier2InvokeNotifyFreqLog);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3354 } else if (level == CompLevel_full_profile) {
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3355 freq_log = (backedge ? Tier3BackedgeNotifyFreqLog : Tier3InvokeNotifyFreqLog);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3356 } else {
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3357 ShouldNotReachHere();
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3358 }
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3359 // Increment the appropriate invocation/backedge counter and notify the runtime.
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3360 increment_event_counter_impl(info, info->scope()->method(), (1 << freq_log) - 1, bci, backedge, true);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3361 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3362
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3363 void LIRGenerator::increment_event_counter_impl(CodeEmitInfo* info,
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3364 ciMethod *method, int frequency,
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3365 int bci, bool backedge, bool notify) {
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3366 assert(frequency == 0 || is_power_of_2(frequency + 1), "Frequency must be x^2 - 1 or 0");
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3367 int level = _compilation->env()->comp_level();
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3368 assert(level > CompLevel_simple, "Shouldn't be here");
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3369
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3370 int offset = -1;
10105
aeaca88565e6 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 8869
diff changeset
3371 LIR_Opr counter_holder;
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3372 if (level == CompLevel_limited_profile) {
12868
c775af091fe9 8025566: EXCEPTION_ACCESS_VIOLATION in compiled by C1 String.valueOf method
twisti
parents: 12000
diff changeset
3373 MethodCounters* counters_adr = method->ensure_method_counters();
c775af091fe9 8025566: EXCEPTION_ACCESS_VIOLATION in compiled by C1 String.valueOf method
twisti
parents: 12000
diff changeset
3374 if (counters_adr == NULL) {
c775af091fe9 8025566: EXCEPTION_ACCESS_VIOLATION in compiled by C1 String.valueOf method
twisti
parents: 12000
diff changeset
3375 bailout("method counters allocation failed");
c775af091fe9 8025566: EXCEPTION_ACCESS_VIOLATION in compiled by C1 String.valueOf method
twisti
parents: 12000
diff changeset
3376 return;
c775af091fe9 8025566: EXCEPTION_ACCESS_VIOLATION in compiled by C1 String.valueOf method
twisti
parents: 12000
diff changeset
3377 }
10105
aeaca88565e6 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 8869
diff changeset
3378 counter_holder = new_pointer_register();
aeaca88565e6 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 8869
diff changeset
3379 __ move(LIR_OprFact::intptrConst(counters_adr), counter_holder);
aeaca88565e6 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 8869
diff changeset
3380 offset = in_bytes(backedge ? MethodCounters::backedge_counter_offset() :
aeaca88565e6 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 8869
diff changeset
3381 MethodCounters::invocation_counter_offset());
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3382 } else if (level == CompLevel_full_profile) {
10105
aeaca88565e6 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 8869
diff changeset
3383 counter_holder = new_register(T_METADATA);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6616
diff changeset
3384 offset = in_bytes(backedge ? MethodData::backedge_counter_offset() :
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6616
diff changeset
3385 MethodData::invocation_counter_offset());
2007
5ddfcf4b079e 7003554: (tiered) assert(is_null_object() || handle() != NULL) failed: cannot embed null pointer
iveresov
parents: 2002
diff changeset
3386 ciMethodData* md = method->method_data_or_null();
5ddfcf4b079e 7003554: (tiered) assert(is_null_object() || handle() != NULL) failed: cannot embed null pointer
iveresov
parents: 2002
diff changeset
3387 assert(md != NULL, "Sanity");
6739
8a02ca5e5576 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 6731
diff changeset
3388 __ metadata2reg(md->constant_encoding(), counter_holder);
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3389 } else {
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3390 ShouldNotReachHere();
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3391 }
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3392 LIR_Address* counter = new LIR_Address(counter_holder, offset, T_INT);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3393 LIR_Opr result = new_register(T_INT);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3394 __ load(counter, result);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3395 __ add(result, LIR_OprFact::intConst(InvocationCounter::count_increment), result);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3396 __ store(result, counter);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3397 if (notify) {
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3398 LIR_Opr mask = load_immediate(frequency << InvocationCounter::count_shift, T_INT);
10105
aeaca88565e6 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 8869
diff changeset
3399 LIR_Opr meth = new_register(T_METADATA);
aeaca88565e6 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 8869
diff changeset
3400 __ metadata2reg(method->constant_encoding(), meth);
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3401 __ logical_and(result, mask, result);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3402 __ cmp(lir_cond_equal, result, LIR_OprFact::intConst(0));
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3403 // The bci for info can point to cmp for if's we want the if bci
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3404 CodeStub* overflow = new CounterOverflowStub(info, bci, meth);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3405 __ branch(lir_cond_equal, T_INT, overflow);
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3406 __ branch_destination(overflow->continuation());
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3407 }
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1681
diff changeset
3408 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3409
2166
403dc4c1d7f5 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 2089
diff changeset
3410 void LIRGenerator::do_RuntimeCall(RuntimeCall* x) {
403dc4c1d7f5 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 2089
diff changeset
3411 LIR_OprList* args = new LIR_OprList(x->number_of_arguments());
403dc4c1d7f5 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 2089
diff changeset
3412 BasicTypeList* signature = new BasicTypeList(x->number_of_arguments());
403dc4c1d7f5 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 2089
diff changeset
3413
403dc4c1d7f5 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 2089
diff changeset
3414 if (x->pass_thread()) {
12969
9acbfe04b5c3 8026495: JVM Crashes when started with -XX:+DTraceMethodProbes on Solaris x86_64
iveresov
parents: 12962
diff changeset
3415 signature->append(LP64_ONLY(T_LONG) NOT_LP64(T_INT)); // thread
2166
403dc4c1d7f5 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 2089
diff changeset
3416 args->append(getThreadPointer());
403dc4c1d7f5 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 2089
diff changeset
3417 }
403dc4c1d7f5 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 2089
diff changeset
3418
403dc4c1d7f5 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 2089
diff changeset
3419 for (int i = 0; i < x->number_of_arguments(); i++) {
403dc4c1d7f5 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 2089
diff changeset
3420 Value a = x->argument_at(i);
403dc4c1d7f5 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 2089
diff changeset
3421 LIRItem* item = new LIRItem(a, this);
403dc4c1d7f5 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 2089
diff changeset
3422 item->load_item();
403dc4c1d7f5 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 2089
diff changeset
3423 args->append(item->result());
403dc4c1d7f5 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 2089
diff changeset
3424 signature->append(as_BasicType(a->type()));
403dc4c1d7f5 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 2089
diff changeset
3425 }
403dc4c1d7f5 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 2089
diff changeset
3426
403dc4c1d7f5 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 2089
diff changeset
3427 LIR_Opr result = call_runtime(signature, args, x->entry(), x->type(), NULL);
403dc4c1d7f5 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 2089
diff changeset
3428 if (x->type() == voidType) {
403dc4c1d7f5 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 2089
diff changeset
3429 set_no_result(x);
403dc4c1d7f5 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 2089
diff changeset
3430 } else {
403dc4c1d7f5 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 2089
diff changeset
3431 __ move(result, rlock_result(x));
403dc4c1d7f5 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 2089
diff changeset
3432 }
403dc4c1d7f5 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 2089
diff changeset
3433 }
403dc4c1d7f5 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 2089
diff changeset
3434
9156
acadb114c818 8011648: C1: optimized build is broken after 7153771
roland
parents: 9062
diff changeset
3435 #ifdef ASSERT
8860
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3436 void LIRGenerator::do_Assert(Assert *x) {
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3437 ValueTag tag = x->x()->type()->tag();
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3438 If::Condition cond = x->cond();
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3439
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3440 LIRItem xitem(x->x(), this);
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3441 LIRItem yitem(x->y(), this);
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3442 LIRItem* xin = &xitem;
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3443 LIRItem* yin = &yitem;
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3444
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3445 assert(tag == intTag, "Only integer assertions are valid!");
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3446
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3447 xin->load_item();
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3448 yin->dont_load_item();
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3449
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3450 set_no_result(x);
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3451
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3452 LIR_Opr left = xin->result();
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3453 LIR_Opr right = yin->result();
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3454
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3455 __ lir_assert(lir_cond(x->cond()), left, right, x->message(), true);
9156
acadb114c818 8011648: C1: optimized build is broken after 7153771
roland
parents: 9062
diff changeset
3456 }
8860
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3457 #endif
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3458
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3459 void LIRGenerator::do_RangeCheckPredicate(RangeCheckPredicate *x) {
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3460
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3461
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3462 Instruction *a = x->x();
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3463 Instruction *b = x->y();
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3464 if (!a || StressRangeCheckElimination) {
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3465 assert(!b || StressRangeCheckElimination, "B must also be null");
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3466
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3467 CodeEmitInfo *info = state_for(x, x->state());
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3468 CodeStub* stub = new PredicateFailedStub(info);
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3469
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3470 __ jump(stub);
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3471 } else if (a->type()->as_IntConstant() && b->type()->as_IntConstant()) {
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3472 int a_int = a->type()->as_IntConstant()->value();
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3473 int b_int = b->type()->as_IntConstant()->value();
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3474
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3475 bool ok = false;
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3476
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3477 switch(x->cond()) {
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3478 case Instruction::eql: ok = (a_int == b_int); break;
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3479 case Instruction::neq: ok = (a_int != b_int); break;
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3480 case Instruction::lss: ok = (a_int < b_int); break;
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3481 case Instruction::leq: ok = (a_int <= b_int); break;
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3482 case Instruction::gtr: ok = (a_int > b_int); break;
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3483 case Instruction::geq: ok = (a_int >= b_int); break;
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3484 case Instruction::aeq: ok = ((unsigned int)a_int >= (unsigned int)b_int); break;
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3485 case Instruction::beq: ok = ((unsigned int)a_int <= (unsigned int)b_int); break;
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3486 default: ShouldNotReachHere();
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3487 }
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3488
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3489 if (ok) {
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3490
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3491 CodeEmitInfo *info = state_for(x, x->state());
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3492 CodeStub* stub = new PredicateFailedStub(info);
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3493
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3494 __ jump(stub);
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3495 }
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3496 } else {
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3497
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3498 ValueTag tag = x->x()->type()->tag();
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3499 If::Condition cond = x->cond();
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3500 LIRItem xitem(x->x(), this);
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3501 LIRItem yitem(x->y(), this);
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3502 LIRItem* xin = &xitem;
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3503 LIRItem* yin = &yitem;
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3504
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3505 assert(tag == intTag, "Only integer deoptimizations are valid!");
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3506
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3507 xin->load_item();
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3508 yin->dont_load_item();
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3509 set_no_result(x);
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3510
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3511 LIR_Opr left = xin->result();
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3512 LIR_Opr right = yin->result();
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3513
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3514 CodeEmitInfo *info = state_for(x, x->state());
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3515 CodeStub* stub = new PredicateFailedStub(info);
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3516
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3517 __ cmp(lir_cond(cond), left, right);
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3518 __ branch(lir_cond(cond), right->type(), stub);
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3519 }
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3520 }
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3521
46f6f063b272 7153771: array bound check elimination for c1
roland
parents: 8001
diff changeset
3522
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3523 LIR_Opr LIRGenerator::call_runtime(Value arg1, address entry, ValueType* result_type, CodeEmitInfo* info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3524 LIRItemList args(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
3525 LIRItem value(arg1, this);
a61af66fc99e Initial load
duke
parents:
diff changeset
3526 args.append(&value);
a61af66fc99e Initial load
duke
parents:
diff changeset
3527 BasicTypeList signature;
a61af66fc99e Initial load
duke
parents:
diff changeset
3528 signature.append(as_BasicType(arg1->type()));
a61af66fc99e Initial load
duke
parents:
diff changeset
3529
a61af66fc99e Initial load
duke
parents:
diff changeset
3530 return call_runtime(&signature, &args, entry, result_type, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
3531 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3532
a61af66fc99e Initial load
duke
parents:
diff changeset
3533
a61af66fc99e Initial load
duke
parents:
diff changeset
3534 LIR_Opr LIRGenerator::call_runtime(Value arg1, Value arg2, address entry, ValueType* result_type, CodeEmitInfo* info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3535 LIRItemList args(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
3536 LIRItem value1(arg1, this);
a61af66fc99e Initial load
duke
parents:
diff changeset
3537 LIRItem value2(arg2, this);
a61af66fc99e Initial load
duke
parents:
diff changeset
3538 args.append(&value1);
a61af66fc99e Initial load
duke
parents:
diff changeset
3539 args.append(&value2);
a61af66fc99e Initial load
duke
parents:
diff changeset
3540 BasicTypeList signature;
a61af66fc99e Initial load
duke
parents:
diff changeset
3541 signature.append(as_BasicType(arg1->type()));
a61af66fc99e Initial load
duke
parents:
diff changeset
3542 signature.append(as_BasicType(arg2->type()));
a61af66fc99e Initial load
duke
parents:
diff changeset
3543
a61af66fc99e Initial load
duke
parents:
diff changeset
3544 return call_runtime(&signature, &args, entry, result_type, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
3545 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3546
a61af66fc99e Initial load
duke
parents:
diff changeset
3547
a61af66fc99e Initial load
duke
parents:
diff changeset
3548 LIR_Opr LIRGenerator::call_runtime(BasicTypeArray* signature, LIR_OprList* args,
a61af66fc99e Initial load
duke
parents:
diff changeset
3549 address entry, ValueType* result_type, CodeEmitInfo* info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3550 // get a result register
a61af66fc99e Initial load
duke
parents:
diff changeset
3551 LIR_Opr phys_reg = LIR_OprFact::illegalOpr;
a61af66fc99e Initial load
duke
parents:
diff changeset
3552 LIR_Opr result = LIR_OprFact::illegalOpr;
a61af66fc99e Initial load
duke
parents:
diff changeset
3553 if (result_type->tag() != voidTag) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3554 result = new_register(result_type);
a61af66fc99e Initial load
duke
parents:
diff changeset
3555 phys_reg = result_register_for(result_type);
a61af66fc99e Initial load
duke
parents:
diff changeset
3556 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3557
a61af66fc99e Initial load
duke
parents:
diff changeset
3558 // move the arguments into the correct location
a61af66fc99e Initial load
duke
parents:
diff changeset
3559 CallingConvention* cc = frame_map()->c_calling_convention(signature);
a61af66fc99e Initial load
duke
parents:
diff changeset
3560 assert(cc->length() == args->length(), "argument mismatch");
a61af66fc99e Initial load
duke
parents:
diff changeset
3561 for (int i = 0; i < args->length(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3562 LIR_Opr arg = args->at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
3563 LIR_Opr loc = cc->at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
3564 if (loc->is_register()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3565 __ move(arg, loc);
a61af66fc99e Initial load
duke
parents:
diff changeset
3566 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3567 LIR_Address* addr = loc->as_address_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
3568 // if (!can_store_as_constant(arg)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3569 // LIR_Opr tmp = new_register(arg->type());
a61af66fc99e Initial load
duke
parents:
diff changeset
3570 // __ move(arg, tmp);
a61af66fc99e Initial load
duke
parents:
diff changeset
3571 // arg = tmp;
a61af66fc99e Initial load
duke
parents:
diff changeset
3572 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
3573 if (addr->type() == T_LONG || addr->type() == T_DOUBLE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3574 __ unaligned_move(arg, addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
3575 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3576 __ move(arg, addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
3577 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3578 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3579 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3580
a61af66fc99e Initial load
duke
parents:
diff changeset
3581 if (info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3582 __ call_runtime(entry, getThreadTemp(), phys_reg, cc->args(), info);
a61af66fc99e Initial load
duke
parents:
diff changeset
3583 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3584 __ call_runtime_leaf(entry, getThreadTemp(), phys_reg, cc->args());
a61af66fc99e Initial load
duke
parents:
diff changeset
3585 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3586 if (result->is_valid()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3587 __ move(phys_reg, result);
a61af66fc99e Initial load
duke
parents:
diff changeset
3588 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3589 return result;
a61af66fc99e Initial load
duke
parents:
diff changeset
3590 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3591
a61af66fc99e Initial load
duke
parents:
diff changeset
3592
a61af66fc99e Initial load
duke
parents:
diff changeset
3593 LIR_Opr LIRGenerator::call_runtime(BasicTypeArray* signature, LIRItemList* args,
a61af66fc99e Initial load
duke
parents:
diff changeset
3594 address entry, ValueType* result_type, CodeEmitInfo* info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3595 // get a result register
a61af66fc99e Initial load
duke
parents:
diff changeset
3596 LIR_Opr phys_reg = LIR_OprFact::illegalOpr;
a61af66fc99e Initial load
duke
parents:
diff changeset
3597 LIR_Opr result = LIR_OprFact::illegalOpr;
a61af66fc99e Initial load
duke
parents:
diff changeset
3598 if (result_type->tag() != voidTag) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3599 result = new_register(result_type);
a61af66fc99e Initial load
duke
parents:
diff changeset
3600 phys_reg = result_register_for(result_type);
a61af66fc99e Initial load
duke
parents:
diff changeset
3601 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3602
a61af66fc99e Initial load
duke
parents:
diff changeset
3603 // move the arguments into the correct location
a61af66fc99e Initial load
duke
parents:
diff changeset
3604 CallingConvention* cc = frame_map()->c_calling_convention(signature);
a61af66fc99e Initial load
duke
parents:
diff changeset
3605
a61af66fc99e Initial load
duke
parents:
diff changeset
3606 assert(cc->length() == args->length(), "argument mismatch");
a61af66fc99e Initial load
duke
parents:
diff changeset
3607 for (int i = 0; i < args->length(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3608 LIRItem* arg = args->at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
3609 LIR_Opr loc = cc->at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
3610 if (loc->is_register()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3611 arg->load_item_force(loc);
a61af66fc99e Initial load
duke
parents:
diff changeset
3612 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3613 LIR_Address* addr = loc->as_address_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
3614 arg->load_for_store(addr->type());
a61af66fc99e Initial load
duke
parents:
diff changeset
3615 if (addr->type() == T_LONG || addr->type() == T_DOUBLE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3616 __ unaligned_move(arg->result(), addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
3617 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3618 __ move(arg->result(), addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
3619 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3620 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3621 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3622
a61af66fc99e Initial load
duke
parents:
diff changeset
3623 if (info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3624 __ call_runtime(entry, getThreadTemp(), phys_reg, cc->args(), info);
a61af66fc99e Initial load
duke
parents:
diff changeset
3625 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3626 __ call_runtime_leaf(entry, getThreadTemp(), phys_reg, cc->args());
a61af66fc99e Initial load
duke
parents:
diff changeset
3627 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3628 if (result->is_valid()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3629 __ move(phys_reg, result);
a61af66fc99e Initial load
duke
parents:
diff changeset
3630 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3631 return result;
a61af66fc99e Initial load
duke
parents:
diff changeset
3632 }
4966
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4816
diff changeset
3633
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4816
diff changeset
3634 void LIRGenerator::do_MemBar(MemBar* x) {
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4816
diff changeset
3635 if (os::is_MP()) {
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4816
diff changeset
3636 LIR_Code code = x->code();
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4816
diff changeset
3637 switch(code) {
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4816
diff changeset
3638 case lir_membar_acquire : __ membar_acquire(); break;
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4816
diff changeset
3639 case lir_membar_release : __ membar_release(); break;
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4816
diff changeset
3640 case lir_membar : __ membar(); break;
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4816
diff changeset
3641 case lir_membar_loadload : __ membar_loadload(); break;
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4816
diff changeset
3642 case lir_membar_storestore: __ membar_storestore(); break;
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4816
diff changeset
3643 case lir_membar_loadstore : __ membar_loadstore(); break;
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4816
diff changeset
3644 case lir_membar_storeload : __ membar_storeload(); break;
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4816
diff changeset
3645 default : ShouldNotReachHere(); break;
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4816
diff changeset
3646 }
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4816
diff changeset
3647 }
701a83c86f28 7120481: storeStore barrier in constructor with final field
jiangli
parents: 4816
diff changeset
3648 }
23614
32b682649973 8132051: Better byte behavior
kevinw
parents: 23158
diff changeset
3649
32b682649973 8132051: Better byte behavior
kevinw
parents: 23158
diff changeset
3650 LIR_Opr LIRGenerator::maybe_mask_boolean(StoreIndexed* x, LIR_Opr array, LIR_Opr value, CodeEmitInfo*& null_check_info) {
32b682649973 8132051: Better byte behavior
kevinw
parents: 23158
diff changeset
3651 if (x->check_boolean()) {
32b682649973 8132051: Better byte behavior
kevinw
parents: 23158
diff changeset
3652 LIR_Opr value_fixed = rlock_byte(T_BYTE);
32b682649973 8132051: Better byte behavior
kevinw
parents: 23158
diff changeset
3653 if (TwoOperandLIRForm) {
32b682649973 8132051: Better byte behavior
kevinw
parents: 23158
diff changeset
3654 __ move(value, value_fixed);
32b682649973 8132051: Better byte behavior
kevinw
parents: 23158
diff changeset
3655 __ logical_and(value_fixed, LIR_OprFact::intConst(1), value_fixed);
32b682649973 8132051: Better byte behavior
kevinw
parents: 23158
diff changeset
3656 } else {
32b682649973 8132051: Better byte behavior
kevinw
parents: 23158
diff changeset
3657 __ logical_and(value, LIR_OprFact::intConst(1), value_fixed);
32b682649973 8132051: Better byte behavior
kevinw
parents: 23158
diff changeset
3658 }
32b682649973 8132051: Better byte behavior
kevinw
parents: 23158
diff changeset
3659 LIR_Opr klass = new_register(T_METADATA);
32b682649973 8132051: Better byte behavior
kevinw
parents: 23158
diff changeset
3660 __ move(new LIR_Address(array, oopDesc::klass_offset_in_bytes(), T_ADDRESS), klass, null_check_info);
32b682649973 8132051: Better byte behavior
kevinw
parents: 23158
diff changeset
3661 null_check_info = NULL;
32b682649973 8132051: Better byte behavior
kevinw
parents: 23158
diff changeset
3662 LIR_Opr layout = new_register(T_INT);
32b682649973 8132051: Better byte behavior
kevinw
parents: 23158
diff changeset
3663 __ move(new LIR_Address(klass, in_bytes(Klass::layout_helper_offset()), T_INT), layout);
32b682649973 8132051: Better byte behavior
kevinw
parents: 23158
diff changeset
3664 int diffbit = Klass::layout_helper_boolean_diffbit();
32b682649973 8132051: Better byte behavior
kevinw
parents: 23158
diff changeset
3665 __ logical_and(layout, LIR_OprFact::intConst(diffbit), layout);
32b682649973 8132051: Better byte behavior
kevinw
parents: 23158
diff changeset
3666 __ cmp(lir_cond_notEqual, layout, LIR_OprFact::intConst(0));
32b682649973 8132051: Better byte behavior
kevinw
parents: 23158
diff changeset
3667 __ cmove(lir_cond_notEqual, value_fixed, value, value_fixed, T_BYTE);
32b682649973 8132051: Better byte behavior
kevinw
parents: 23158
diff changeset
3668 value = value_fixed;
32b682649973 8132051: Better byte behavior
kevinw
parents: 23158
diff changeset
3669 }
32b682649973 8132051: Better byte behavior
kevinw
parents: 23158
diff changeset
3670 return value;
32b682649973 8132051: Better byte behavior
kevinw
parents: 23158
diff changeset
3671 }