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