Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.
/ jdk13u-dev Public archive

Commit 40e0519

Browse files
Olga MikhaltsovaYuri Nesterenko
Olga Mikhaltsova
authored and
Yuri Nesterenko
committed
8231586: enlarge encoding space for OopMapValue offsets
Backport-of: 4a41f86
1 parent e0445f1 commit 40e0519

File tree

6 files changed

+77
-137
lines changed

6 files changed

+77
-137
lines changed

src/hotspot/share/compiler/oopMap.cpp

+29-63
Original file line numberDiff line numberDiff line change
@@ -48,29 +48,25 @@
4848

4949
// OopMapStream
5050

51-
OopMapStream::OopMapStream(OopMap* oop_map, int oop_types_mask) {
51+
OopMapStream::OopMapStream(OopMap* oop_map) {
5252
_stream = new CompressedReadStream(oop_map->write_stream()->buffer());
53-
_mask = oop_types_mask;
5453
_size = oop_map->omv_count();
5554
_position = 0;
5655
_valid_omv = false;
5756
}
5857

59-
OopMapStream::OopMapStream(const ImmutableOopMap* oop_map, int oop_types_mask) {
58+
OopMapStream::OopMapStream(const ImmutableOopMap* oop_map) {
6059
_stream = new CompressedReadStream(oop_map->data_addr());
61-
_mask = oop_types_mask;
6260
_size = oop_map->count();
6361
_position = 0;
6462
_valid_omv = false;
6563
}
6664

6765
void OopMapStream::find_next() {
68-
while(_position++ < _size) {
66+
if (_position++ < _size) {
6967
_omv.read_from(_stream);
70-
if(((int)_omv.type() & _mask) > 0) {
71-
_valid_omv = true;
72-
return;
73-
}
68+
_valid_omv = true;
69+
return;
7470
}
7571
_valid_omv = false;
7672
}
@@ -140,16 +136,7 @@ void OopMap::set_xxx(VMReg reg, OopMapValue::oop_types x, VMReg optional) {
140136
assert( _locs_used[reg->value()] == OopMapValue::unused_value, "cannot insert twice" );
141137
debug_only( _locs_used[reg->value()] = x; )
142138

143-
OopMapValue o(reg, x);
144-
145-
if(x == OopMapValue::callee_saved_value) {
146-
// This can never be a stack location, so we don't need to transform it.
147-
assert(optional->is_reg(), "Trying to callee save a stack location");
148-
o.set_content_reg(optional);
149-
} else if(x == OopMapValue::derived_oop_value) {
150-
o.set_content_reg(optional);
151-
}
152-
139+
OopMapValue o(reg, x, optional);
153140
o.write_on(write_stream());
154141
increment_count();
155142
}
@@ -160,11 +147,6 @@ void OopMap::set_oop(VMReg reg) {
160147
}
161148

162149

163-
void OopMap::set_value(VMReg reg) {
164-
// At this time, we don't need value entries in our OopMap.
165-
}
166-
167-
168150
void OopMap::set_narrowoop(VMReg reg) {
169151
set_xxx(reg, OopMapValue::narrowoop_value, VMRegImpl::Bad());
170152
}
@@ -328,7 +310,7 @@ void OopMapSet::all_do(const frame *fr, const RegisterMap *reg_map,
328310
// changed before derived pointer offset has been collected)
329311
OopMapValue omv;
330312
{
331-
OopMapStream oms(map,OopMapValue::derived_oop_value);
313+
OopMapStream oms(map);
332314
if (!oms.is_done()) {
333315
#ifndef TIERED
334316
COMPILER1_PRESENT(ShouldNotReachHere();)
@@ -340,27 +322,28 @@ void OopMapSet::all_do(const frame *fr, const RegisterMap *reg_map,
340322
#endif // !TIERED
341323
do {
342324
omv = oms.current();
343-
oop* loc = fr->oopmapreg_to_location(omv.reg(),reg_map);
344-
guarantee(loc != NULL, "missing saved register");
345-
oop *derived_loc = loc;
346-
oop *base_loc = fr->oopmapreg_to_location(omv.content_reg(), reg_map);
347-
// Ignore NULL oops and decoded NULL narrow oops which
348-
// equal to CompressedOops::base() when a narrow oop
349-
// implicit null check is used in compiled code.
350-
// The narrow_oop_base could be NULL or be the address
351-
// of the page below heap depending on compressed oops mode.
352-
if (base_loc != NULL && *base_loc != NULL && !CompressedOops::is_base(*base_loc)) {
353-
derived_oop_fn(base_loc, derived_loc);
325+
if (omv.type() == OopMapValue::derived_oop_value) {
326+
oop* loc = fr->oopmapreg_to_location(omv.reg(),reg_map);
327+
guarantee(loc != NULL, "missing saved register");
328+
oop *derived_loc = loc;
329+
oop *base_loc = fr->oopmapreg_to_location(omv.content_reg(), reg_map);
330+
// Ignore NULL oops and decoded NULL narrow oops which
331+
// equal to CompressedOops::base() when a narrow oop
332+
// implicit null check is used in compiled code.
333+
// The narrow_oop_base could be NULL or be the address
334+
// of the page below heap depending on compressed oops mode.
335+
if (base_loc != NULL && *base_loc != NULL && !CompressedOops::is_base(*base_loc)) {
336+
derived_oop_fn(base_loc, derived_loc);
337+
}
354338
}
355339
oms.next();
356340
} while (!oms.is_done());
357341
}
358342
}
359343

360-
// We want coop and oop oop_types
361-
int mask = OopMapValue::oop_value | OopMapValue::narrowoop_value;
362344
{
363-
for (OopMapStream oms(map,mask); !oms.is_done(); oms.next()) {
345+
// We want coop and oop oop_types
346+
for (OopMapStream oms(map); !oms.is_done(); oms.next()) {
364347
omv = oms.current();
365348
oop* loc = fr->oopmapreg_to_location(omv.reg(),reg_map);
366349
// It should be an error if no location can be found for a
@@ -436,12 +419,14 @@ void OopMapSet::update_register_map(const frame *fr, RegisterMap *reg_map) {
436419
assert(map != NULL, "no ptr map found");
437420
DEBUG_ONLY(int nof_callee = 0;)
438421

439-
for (OopMapStream oms(map, OopMapValue::callee_saved_value); !oms.is_done(); oms.next()) {
422+
for (OopMapStream oms(map); !oms.is_done(); oms.next()) {
440423
OopMapValue omv = oms.current();
441-
VMReg reg = omv.content_reg();
442-
oop* loc = fr->oopmapreg_to_location(omv.reg(), reg_map);
443-
reg_map->set_location(reg, (address) loc);
444-
DEBUG_ONLY(nof_callee++;)
424+
if (omv.type() == OopMapValue::callee_saved_value) {
425+
VMReg reg = omv.content_reg();
426+
oop* loc = fr->oopmapreg_to_location(omv.reg(), reg_map);
427+
reg_map->set_location(reg, (address) loc);
428+
DEBUG_ONLY(nof_callee++;)
429+
}
445430
}
446431

447432
// Check that runtime stubs save all callee-saved registers
@@ -452,25 +437,6 @@ void OopMapSet::update_register_map(const frame *fr, RegisterMap *reg_map) {
452437
#endif // COMPILER2
453438
}
454439

455-
//=============================================================================
456-
// Non-Product code
457-
458-
#ifndef PRODUCT
459-
460-
bool ImmutableOopMap::has_derived_pointer() const {
461-
#if !defined(TIERED) && !INCLUDE_JVMCI
462-
COMPILER1_PRESENT(return false);
463-
#endif // !TIERED
464-
#if COMPILER2_OR_JVMCI
465-
OopMapStream oms(this,OopMapValue::derived_oop_value);
466-
return oms.is_done();
467-
#else
468-
return false;
469-
#endif // COMPILER2_OR_JVMCI
470-
}
471-
472-
#endif //PRODUCT
473-
474440
// Printing code is present in product build for -XX:+PrintAssembly.
475441

476442
static

src/hotspot/share/compiler/oopMap.hpp

+37-33
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class OopMapValue: public StackObj {
5353

5454
public:
5555
// Constants
56-
enum { type_bits = 4,
56+
enum { type_bits = 2,
5757
register_bits = BitsPerShort - type_bits };
5858

5959
enum { type_shift = 0,
@@ -64,19 +64,41 @@ class OopMapValue: public StackObj {
6464
register_mask = right_n_bits(register_bits),
6565
register_mask_in_place = register_mask << register_shift };
6666

67-
enum oop_types { // must fit in type_bits
68-
unused_value =0, // powers of 2, for masking OopMapStream
69-
oop_value = 1,
70-
narrowoop_value = 2,
71-
callee_saved_value = 4,
72-
derived_oop_value= 8 };
67+
enum oop_types {
68+
oop_value,
69+
narrowoop_value,
70+
callee_saved_value,
71+
derived_oop_value,
72+
unused_value = -1 // Only used as a sentinel value
73+
};
7374

7475
// Constructors
7576
OopMapValue () { set_value(0); set_content_reg(VMRegImpl::Bad()); }
76-
OopMapValue (VMReg reg, oop_types t) { set_reg_type(reg, t); set_content_reg(VMRegImpl::Bad()); }
77-
OopMapValue (VMReg reg, oop_types t, VMReg reg2) { set_reg_type(reg, t); set_content_reg(reg2); }
78-
OopMapValue (CompressedReadStream* stream) { read_from(stream); }
77+
OopMapValue (VMReg reg, oop_types t, VMReg reg2) {
78+
set_reg_type(reg, t);
79+
set_content_reg(reg2);
80+
}
81+
82+
private:
83+
void set_reg_type(VMReg p, oop_types t) {
84+
set_value((p->value() << register_shift) | t);
85+
assert(reg() == p, "sanity check" );
86+
assert(type() == t, "sanity check" );
87+
}
88+
89+
void set_content_reg(VMReg r) {
90+
if (is_callee_saved()) {
91+
// This can never be a stack location, so we don't need to transform it.
92+
assert(r->is_reg(), "Trying to callee save a stack location");
93+
} else if (is_derived_oop()) {
94+
assert (r->is_valid(), "must have a valid VMReg");
95+
} else {
96+
assert (!r->is_valid(), "valid VMReg not allowed");
97+
}
98+
_content_reg = r->value();
99+
}
79100

101+
public:
80102
// Archiving
81103
void write_on(CompressedWriteStream* stream) {
82104
stream->write_int(value());
@@ -94,31 +116,18 @@ class OopMapValue: public StackObj {
94116

95117
// Querying
96118
bool is_oop() { return mask_bits(value(), type_mask_in_place) == oop_value; }
97-
bool is_narrowoop() { return mask_bits(value(), type_mask_in_place) == narrowoop_value; }
119+
bool is_narrowoop() { return mask_bits(value(), type_mask_in_place) == narrowoop_value; }
98120
bool is_callee_saved() { return mask_bits(value(), type_mask_in_place) == callee_saved_value; }
99121
bool is_derived_oop() { return mask_bits(value(), type_mask_in_place) == derived_oop_value; }
100122

101-
void set_oop() { set_value((value() & register_mask_in_place) | oop_value); }
102-
void set_narrowoop() { set_value((value() & register_mask_in_place) | narrowoop_value); }
103-
void set_callee_saved() { set_value((value() & register_mask_in_place) | callee_saved_value); }
104-
void set_derived_oop() { set_value((value() & register_mask_in_place) | derived_oop_value); }
105-
106123
VMReg reg() const { return VMRegImpl::as_VMReg(mask_bits(value(), register_mask_in_place) >> register_shift); }
107124
oop_types type() const { return (oop_types)mask_bits(value(), type_mask_in_place); }
108125

109126
static bool legal_vm_reg_name(VMReg p) {
110127
return (p->value() == (p->value() & register_mask));
111128
}
112129

113-
void set_reg_type(VMReg p, oop_types t) {
114-
set_value((p->value() << register_shift) | t);
115-
assert(reg() == p, "sanity check" );
116-
assert(type() == t, "sanity check" );
117-
}
118-
119-
120130
VMReg content_reg() const { return VMRegImpl::as_VMReg(_content_reg, true); }
121-
void set_content_reg(VMReg r) { _content_reg = r->value(); }
122131

123132
// Physical location queries
124133
bool is_register_loc() { return reg()->is_reg(); }
@@ -156,6 +165,8 @@ class OopMap: public ResourceObj {
156165
enum DeepCopyToken { _deep_copy_token };
157166
OopMap(DeepCopyToken, OopMap* source); // used only by deep_copy
158167

168+
void set_xxx(VMReg reg, OopMapValue::oop_types x, VMReg optional);
169+
159170
public:
160171
OopMap(int frame_size, int arg_count);
161172

@@ -173,19 +184,14 @@ class OopMap: public ResourceObj {
173184
// frame_size units are stack-slots (4 bytes) NOT intptr_t; we can name odd
174185
// slots to hold 4-byte values like ints and floats in the LP64 build.
175186
void set_oop ( VMReg local);
176-
void set_value( VMReg local);
177187
void set_narrowoop(VMReg local);
178-
void set_dead ( VMReg local);
179188
void set_callee_saved( VMReg local, VMReg caller_machine_register );
180189
void set_derived_oop ( VMReg local, VMReg derived_from_local_register );
181-
void set_xxx(VMReg reg, OopMapValue::oop_types x, VMReg optional);
182190

183191
int heap_size() const;
184192
void copy_data_to(address addr) const;
185193
OopMap* deep_copy();
186194

187-
bool has_derived_pointer() const PRODUCT_RETURN0;
188-
189195
bool legal_vm_reg_name(VMReg local) {
190196
return OopMapValue::legal_vm_reg_name(local);
191197
}
@@ -269,7 +275,6 @@ class ImmutableOopMap {
269275
public:
270276
ImmutableOopMap(const OopMap* oopmap);
271277

272-
bool has_derived_pointer() const PRODUCT_RETURN0;
273278
int count() const { return _count; }
274279
#ifdef ASSERT
275280
int nr_of_bytes() const; // this is an expensive operation, only used in debug builds
@@ -334,16 +339,15 @@ class ImmutableOopMapSet {
334339
class OopMapStream : public StackObj {
335340
private:
336341
CompressedReadStream* _stream;
337-
int _mask;
338342
int _size;
339343
int _position;
340344
bool _valid_omv;
341345
OopMapValue _omv;
342346
void find_next();
343347

344348
public:
345-
OopMapStream(OopMap* oop_map, int oop_types_mask = OopMapValue::type_mask_in_place);
346-
OopMapStream(const ImmutableOopMap* oop_map, int oop_types_mask = OopMapValue::type_mask_in_place);
349+
OopMapStream(OopMap* oop_map);
350+
OopMapStream(const ImmutableOopMap* oop_map);
347351
bool is_done() { if(!_valid_omv) { find_next(); } return !_valid_omv; }
348352
void next() { find_next(); }
349353
OopMapValue current() { return _omv; }

src/hotspot/share/opto/buildOopMap.cpp

+10-4
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,6 @@ OopMap *OopFlow::build_oop_map( Node *n, int max_reg, PhaseRegAlloc *regalloc, i
352352

353353
} else {
354354
// Other - some reaching non-oop value
355-
omap->set_value( r);
356355
#ifdef ASSERT
357356
if( t->isa_rawptr() && C->cfg()->_raw_oops.member(def) ) {
358357
def->dump();
@@ -377,11 +376,18 @@ OopMap *OopFlow::build_oop_map( Node *n, int max_reg, PhaseRegAlloc *regalloc, i
377376
#endif
378377

379378
#ifdef ASSERT
380-
for( OopMapStream oms1(omap, OopMapValue::derived_oop_value); !oms1.is_done(); oms1.next()) {
379+
for( OopMapStream oms1(omap); !oms1.is_done(); oms1.next()) {
381380
OopMapValue omv1 = oms1.current();
381+
if (omv1.type() != OopMapValue::derived_oop_value) {
382+
continue;
383+
}
382384
bool found = false;
383-
for( OopMapStream oms2(omap,OopMapValue::oop_value); !oms2.is_done(); oms2.next()) {
384-
if( omv1.content_reg() == oms2.current().reg() ) {
385+
for( OopMapStream oms2(omap); !oms2.is_done(); oms2.next()) {
386+
OopMapValue omv2 = oms2.current();
387+
if (omv2.type() != OopMapValue::oop_value) {
388+
continue;
389+
}
390+
if( omv1.content_reg() == omv2.reg() ) {
385391
found = true;
386392
break;
387393
}

src/hotspot/share/runtime/interfaceSupport.cpp

-31
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,6 @@ VMEntryWrapper::~VMEntryWrapper() {
5555
if (WalkStackALot) {
5656
InterfaceSupport::walk_stack();
5757
}
58-
#ifdef COMPILER2
59-
// This option is not used by Compiler 1
60-
if (StressDerivedPointers) {
61-
InterfaceSupport::stress_derived_pointers();
62-
}
63-
#endif
6458
if (DeoptimizeALot || DeoptimizeRandom) {
6559
InterfaceSupport::deoptimizeAll();
6660
}
@@ -226,31 +220,6 @@ void InterfaceSupport::deoptimizeAll() {
226220
}
227221

228222

229-
void InterfaceSupport::stress_derived_pointers() {
230-
#ifdef COMPILER2
231-
JavaThread *thread = JavaThread::current();
232-
if (!is_init_completed()) return;
233-
ResourceMark rm(thread);
234-
bool found = false;
235-
for (StackFrameStream sfs(thread); !sfs.is_done() && !found; sfs.next()) {
236-
CodeBlob* cb = sfs.current()->cb();
237-
if (cb != NULL && cb->oop_maps() ) {
238-
// Find oopmap for current method
239-
const ImmutableOopMap* map = cb->oop_map_for_return_address(sfs.current()->pc());
240-
assert(map != NULL, "no oopmap found for pc");
241-
found = map->has_derived_pointer();
242-
}
243-
}
244-
if (found) {
245-
// $$$ Not sure what to do here.
246-
/*
247-
Scavenge::invoke(0);
248-
*/
249-
}
250-
#endif
251-
}
252-
253-
254223
void InterfaceSupport::verify_stack() {
255224
JavaThread* thread = JavaThread::current();
256225
ResourceMark rm(thread);

src/hotspot/share/runtime/interfaceSupport.inline.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ class InterfaceSupport: AllStatic {
6262

6363
static void zombieAll();
6464
static void deoptimizeAll();
65-
static void stress_derived_pointers();
6665
static void verify_stack();
6766
static void verify_last_frame();
6867
# endif

0 commit comments

Comments
 (0)