author | neliasso |
Thu, 14 Feb 2019 14:54:05 +0100 | |
changeset 55307 | ed12027517c0 |
parent 54995 | 181986c54764 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
24424
diff
changeset
|
2 |
* Copyright (c) 1997, 2017, 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:
3283
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3283
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:
3283
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
26 |
#include "code/debugInfo.hpp" |
|
49592
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
47816
diff
changeset
|
27 |
#include "oops/compressedOops.inline.hpp" |
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
47816
diff
changeset
|
28 |
#include "oops/oop.hpp" |
7397 | 29 |
#include "runtime/frame.inline.hpp" |
30 |
#include "runtime/handles.inline.hpp" |
|
31 |
#include "runtime/stackValue.hpp" |
|
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
49592
diff
changeset
|
32 |
#if INCLUDE_ZGC |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
49592
diff
changeset
|
33 |
#include "gc/z/zBarrier.inline.hpp" |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
49592
diff
changeset
|
34 |
#endif |
54995
181986c54764
8224522: Shenandoah should apply barriers on deoptimization
shade
parents:
54780
diff
changeset
|
35 |
#if INCLUDE_SHENANDOAHGC |
181986c54764
8224522: Shenandoah should apply barriers on deoptimization
shade
parents:
54780
diff
changeset
|
36 |
#include "gc/shenandoah/shenandoahBarrierSet.hpp" |
181986c54764
8224522: Shenandoah should apply barriers on deoptimization
shade
parents:
54780
diff
changeset
|
37 |
#endif |
1 | 38 |
|
39 |
StackValue* StackValue::create_stack_value(const frame* fr, const RegisterMap* reg_map, ScopeValue* sv) { |
|
40 |
if (sv->is_location()) { |
|
41 |
// Stack or register value |
|
42 |
Location loc = ((LocationValue *)sv)->location(); |
|
43 |
||
44 |
#ifdef SPARC |
|
45 |
// %%%%% Callee-save floats will NOT be working on a Sparc until we |
|
46 |
// handle the case of a 2 floats in a single double register. |
|
47 |
assert( !(loc.is_register() && loc.type() == Location::float_in_dbl), "Sparc does not handle callee-save floats yet" ); |
|
48 |
#endif // SPARC |
|
49 |
||
50 |
// First find address of value |
|
51 |
||
52 |
address value_addr = loc.is_register() |
|
53 |
// Value was in a callee-save register |
|
54 |
? reg_map->location(VMRegImpl::as_VMReg(loc.register_number())) |
|
55 |
// Else value was directly saved on the stack. The frame's original stack pointer, |
|
56 |
// before any extension by its callee (due to Compiler1 linkage on SPARC), must be used. |
|
57 |
: ((address)fr->unextended_sp()) + loc.stack_offset(); |
|
58 |
||
59 |
// Then package it right depending on type |
|
60 |
// Note: the transfer of the data is thru a union that contains |
|
61 |
// an intptr_t. This is because an interpreter stack slot is |
|
62 |
// really an intptr_t. The use of a union containing an intptr_t |
|
63 |
// ensures that on a 64 bit platform we have proper alignment |
|
64 |
// and that we store the value where the interpreter will expect |
|
65 |
// to find it (i.e. proper endian). Similarly on a 32bit platform |
|
66 |
// using the intptr_t ensures that when a value is larger than |
|
67 |
// a stack slot (jlong/jdouble) that we capture the proper part |
|
68 |
// of the value for the stack slot in question. |
|
69 |
// |
|
70 |
switch( loc.type() ) { |
|
71 |
case Location::float_in_dbl: { // Holds a float in a double register? |
|
72 |
// The callee has no clue whether the register holds a float, |
|
73 |
// double or is unused. He always saves a double. Here we know |
|
74 |
// a double was saved, but we only want a float back. Narrow the |
|
75 |
// saved double to the float that the JVM wants. |
|
76 |
assert( loc.is_register(), "floats always saved to stack in 1 word" ); |
|
77 |
union { intptr_t p; jfloat jf; } value; |
|
78 |
value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF); |
|
79 |
value.jf = (jfloat) *(jdouble*) value_addr; |
|
80 |
return new StackValue(value.p); // 64-bit high half is stack junk |
|
81 |
} |
|
82 |
case Location::int_in_long: { // Holds an int in a long register? |
|
83 |
// The callee has no clue whether the register holds an int, |
|
84 |
// long or is unused. He always saves a long. Here we know |
|
85 |
// a long was saved, but we only want an int back. Narrow the |
|
86 |
// saved long to the int that the JVM wants. |
|
87 |
assert( loc.is_register(), "ints always saved to stack in 1 word" ); |
|
88 |
union { intptr_t p; jint ji;} value; |
|
89 |
value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF); |
|
90 |
value.ji = (jint) *(jlong*) value_addr; |
|
91 |
return new StackValue(value.p); // 64-bit high half is stack junk |
|
92 |
} |
|
93 |
#ifdef _LP64 |
|
94 |
case Location::dbl: |
|
95 |
// Double value in an aligned adjacent pair |
|
96 |
return new StackValue(*(intptr_t*)value_addr); |
|
97 |
case Location::lng: |
|
98 |
// Long value in an aligned adjacent pair |
|
99 |
return new StackValue(*(intptr_t*)value_addr); |
|
1135 | 100 |
case Location::narrowoop: { |
101 |
union { intptr_t p; narrowOop noop;} value; |
|
102 |
value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF); |
|
103 |
if (loc.is_register()) { |
|
104 |
// The callee has no clue whether the register holds an int, |
|
105 |
// long or is unused. He always saves a long. Here we know |
|
106 |
// a long was saved, but we only want an int back. Narrow the |
|
107 |
// saved long to the int that the JVM wants. |
|
108 |
value.noop = (narrowOop) *(julong*) value_addr; |
|
109 |
} else { |
|
110 |
value.noop = *(narrowOop*) value_addr; |
|
111 |
} |
|
54995
181986c54764
8224522: Shenandoah should apply barriers on deoptimization
shade
parents:
54780
diff
changeset
|
112 |
// Decode narrowoop |
181986c54764
8224522: Shenandoah should apply barriers on deoptimization
shade
parents:
54780
diff
changeset
|
113 |
oop val = CompressedOops::decode(value.noop); |
181986c54764
8224522: Shenandoah should apply barriers on deoptimization
shade
parents:
54780
diff
changeset
|
114 |
// Deoptimization must make sure all oops have passed load barriers |
181986c54764
8224522: Shenandoah should apply barriers on deoptimization
shade
parents:
54780
diff
changeset
|
115 |
#if INCLUDE_SHENANDOAHGC |
181986c54764
8224522: Shenandoah should apply barriers on deoptimization
shade
parents:
54780
diff
changeset
|
116 |
if (UseShenandoahGC) { |
181986c54764
8224522: Shenandoah should apply barriers on deoptimization
shade
parents:
54780
diff
changeset
|
117 |
val = ShenandoahBarrierSet::barrier_set()->load_reference_barrier(val); |
181986c54764
8224522: Shenandoah should apply barriers on deoptimization
shade
parents:
54780
diff
changeset
|
118 |
} |
181986c54764
8224522: Shenandoah should apply barriers on deoptimization
shade
parents:
54780
diff
changeset
|
119 |
#endif |
181986c54764
8224522: Shenandoah should apply barriers on deoptimization
shade
parents:
54780
diff
changeset
|
120 |
Handle h(Thread::current(), val); // Wrap a handle around the oop |
1135 | 121 |
return new StackValue(h); |
122 |
} |
|
1 | 123 |
#endif |
124 |
case Location::oop: { |
|
3275 | 125 |
oop val = *(oop *)value_addr; |
126 |
#ifdef _LP64 |
|
54780
f8d182aedc92
8223136: Move compressed oops functions to CompressedOops class
stefank
parents:
53401
diff
changeset
|
127 |
if (CompressedOops::is_base(val)) { |
3275 | 128 |
// Compiled code may produce decoded oop = narrow_oop_base |
129 |
// when a narrow oop implicit null check is used. |
|
130 |
// The narrow_oop_base could be NULL or be the address |
|
131 |
// of the page below heap. Use NULL value for both cases. |
|
132 |
val = (oop)NULL; |
|
133 |
} |
|
134 |
#endif |
|
54995
181986c54764
8224522: Shenandoah should apply barriers on deoptimization
shade
parents:
54780
diff
changeset
|
135 |
// Deoptimization must make sure all oops have passed load barriers |
181986c54764
8224522: Shenandoah should apply barriers on deoptimization
shade
parents:
54780
diff
changeset
|
136 |
#if INCLUDE_SHENANDOAHGC |
181986c54764
8224522: Shenandoah should apply barriers on deoptimization
shade
parents:
54780
diff
changeset
|
137 |
if (UseShenandoahGC) { |
181986c54764
8224522: Shenandoah should apply barriers on deoptimization
shade
parents:
54780
diff
changeset
|
138 |
val = ShenandoahBarrierSet::barrier_set()->load_reference_barrier(val); |
181986c54764
8224522: Shenandoah should apply barriers on deoptimization
shade
parents:
54780
diff
changeset
|
139 |
} |
181986c54764
8224522: Shenandoah should apply barriers on deoptimization
shade
parents:
54780
diff
changeset
|
140 |
#endif |
55307 | 141 |
assert(oopDesc::is_oop_or_null(val, false), "bad oop found"); |
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
24424
diff
changeset
|
142 |
Handle h(Thread::current(), val); // Wrap a handle around the oop |
1 | 143 |
return new StackValue(h); |
144 |
} |
|
145 |
case Location::addr: { |
|
146 |
ShouldNotReachHere(); // both C1 and C2 now inline jsrs |
|
147 |
} |
|
148 |
case Location::normal: { |
|
149 |
// Just copy all other bits straight through |
|
150 |
union { intptr_t p; jint ji;} value; |
|
151 |
value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF); |
|
152 |
value.ji = *(jint*)value_addr; |
|
153 |
return new StackValue(value.p); |
|
154 |
} |
|
155 |
case Location::invalid: |
|
156 |
return new StackValue(); |
|
157 |
default: |
|
158 |
ShouldNotReachHere(); |
|
159 |
} |
|
160 |
||
161 |
} else if (sv->is_constant_int()) { |
|
162 |
// Constant int: treat same as register int. |
|
163 |
union { intptr_t p; jint ji;} value; |
|
164 |
value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF); |
|
165 |
value.ji = (jint)((ConstantIntValue*)sv)->value(); |
|
166 |
return new StackValue(value.p); |
|
167 |
} else if (sv->is_constant_oop()) { |
|
168 |
// constant oop |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7397
diff
changeset
|
169 |
return new StackValue(sv->as_ConstantOopReadValue()->value()); |
1 | 170 |
#ifdef _LP64 |
171 |
} else if (sv->is_constant_double()) { |
|
172 |
// Constant double in a single stack slot |
|
173 |
union { intptr_t p; double d; } value; |
|
174 |
value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF); |
|
175 |
value.d = ((ConstantDoubleValue *)sv)->value(); |
|
176 |
return new StackValue(value.p); |
|
177 |
} else if (sv->is_constant_long()) { |
|
178 |
// Constant long in a single stack slot |
|
179 |
union { intptr_t p; jlong jl; } value; |
|
180 |
value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF); |
|
181 |
value.jl = ((ConstantLongValue *)sv)->value(); |
|
182 |
return new StackValue(value.p); |
|
183 |
#endif |
|
3171
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1135
diff
changeset
|
184 |
} else if (sv->is_object()) { // Scalar replaced object in compiled frame |
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1135
diff
changeset
|
185 |
Handle ov = ((ObjectValue *)sv)->value(); |
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1135
diff
changeset
|
186 |
return new StackValue(ov, (ov.is_null()) ? 1 : 0); |
1 | 187 |
} |
188 |
||
189 |
// Unknown ScopeValue type |
|
190 |
ShouldNotReachHere(); |
|
191 |
return new StackValue((intptr_t) 0); // dummy |
|
192 |
} |
|
193 |
||
194 |
||
195 |
BasicLock* StackValue::resolve_monitor_lock(const frame* fr, Location location) { |
|
196 |
assert(location.is_stack(), "for now we only look at the stack"); |
|
197 |
int word_offset = location.stack_offset() / wordSize; |
|
198 |
// (stack picture) |
|
199 |
// high: [ ] word_offset + 1 |
|
200 |
// low [ ] word_offset |
|
201 |
// |
|
202 |
// sp-> [ ] 0 |
|
203 |
// the word_offset is the distance from the stack pointer to the lowest address |
|
204 |
// The frame's original stack pointer, before any extension by its callee |
|
205 |
// (due to Compiler1 linkage on SPARC), must be used. |
|
206 |
return (BasicLock*) (fr->unextended_sp() + word_offset); |
|
207 |
} |
|
208 |
||
209 |
||
210 |
#ifndef PRODUCT |
|
211 |
||
212 |
void StackValue::print_on(outputStream* st) const { |
|
213 |
switch(_type) { |
|
214 |
case T_INT: |
|
47816 | 215 |
st->print("%d (int) %f (float) %x (hex)", *(int *)&_integer_value, *(float *)&_integer_value, *(int *)&_integer_value); |
1 | 216 |
break; |
217 |
||
218 |
case T_OBJECT: |
|
53401
3f224e4a891e
8217407: StackValue::print_on() crashes on NULL handle
vlivanov
parents:
50525
diff
changeset
|
219 |
if (_handle_value() != NULL) { |
3f224e4a891e
8217407: StackValue::print_on() crashes on NULL handle
vlivanov
parents:
50525
diff
changeset
|
220 |
_handle_value()->print_value_on(st); |
3f224e4a891e
8217407: StackValue::print_on() crashes on NULL handle
vlivanov
parents:
50525
diff
changeset
|
221 |
} else { |
3f224e4a891e
8217407: StackValue::print_on() crashes on NULL handle
vlivanov
parents:
50525
diff
changeset
|
222 |
st->print("NULL"); |
3f224e4a891e
8217407: StackValue::print_on() crashes on NULL handle
vlivanov
parents:
50525
diff
changeset
|
223 |
} |
47816 | 224 |
st->print(" <" INTPTR_FORMAT ">", p2i((address)_handle_value())); |
1 | 225 |
break; |
226 |
||
227 |
case T_CONFLICT: |
|
228 |
st->print("conflict"); |
|
229 |
break; |
|
230 |
||
231 |
default: |
|
232 |
ShouldNotReachHere(); |
|
233 |
} |
|
234 |
} |
|
235 |
||
236 |
#endif |