Skip to content

Commit 185c8bc

Browse files
committed
8255338: CodeSections are never frozen
Reviewed-by: neliasso, kvn
1 parent cc86113 commit 185c8bc

File tree

3 files changed

+2
-81
lines changed

3 files changed

+2
-81
lines changed

src/hotspot/share/asm/assembler.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -199,19 +199,6 @@ void Label::patch_instructions(MacroAssembler* masm) {
199199
continue;
200200
}
201201

202-
#ifdef ASSERT
203-
// Cross-section branches only work if the
204-
// intermediate section boundaries are frozen.
205-
if (target_sect != branch_sect) {
206-
for (int n = MIN2(target_sect, branch_sect),
207-
nlimit = (target_sect + branch_sect) - n;
208-
n < nlimit; n++) {
209-
CodeSection* cs = cb->code_section(n);
210-
assert(cs->is_frozen(), "cross-section branch needs stable offsets");
211-
}
212-
}
213-
#endif //ASSERT
214-
215202
// Push the target offset into the branch instruction.
216203
masm->pd_patch_instruction(branch, target, file, line);
217204
}

src/hotspot/share/asm/codeBuffer.cpp

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -176,28 +176,6 @@ void CodeBuffer::initialize_section_size(CodeSection* cs, csize_t size) {
176176
if (_insts.has_locs()) cs->initialize_locs(1);
177177
}
178178

179-
void CodeBuffer::freeze_section(CodeSection* cs) {
180-
CodeSection* next_cs = (cs == consts())? NULL: code_section(cs->index()+1);
181-
csize_t frozen_size = cs->size();
182-
if (next_cs != NULL) {
183-
frozen_size = next_cs->align_at_start(frozen_size);
184-
}
185-
address old_limit = cs->limit();
186-
address new_limit = cs->start() + frozen_size;
187-
relocInfo* old_locs_limit = cs->locs_limit();
188-
relocInfo* new_locs_limit = cs->locs_end();
189-
// Patch the limits.
190-
cs->_limit = new_limit;
191-
cs->_locs_limit = new_locs_limit;
192-
cs->_frozen = true;
193-
if (next_cs != NULL && !next_cs->is_allocated() && !next_cs->is_frozen()) {
194-
// Give remaining buffer space to the following section.
195-
next_cs->initialize(new_limit, old_limit - new_limit);
196-
next_cs->initialize_shared_locs(new_locs_limit,
197-
old_locs_limit - new_locs_limit);
198-
}
199-
}
200-
201179
void CodeBuffer::set_blob(BufferBlob* blob) {
202180
_blob = blob;
203181
if (blob != NULL) {
@@ -501,18 +479,6 @@ void CodeBuffer::compute_final_layout(CodeBuffer* dest) const {
501479
} else {
502480
guarantee(padding == 0, "In first iteration no padding should be needed.");
503481
}
504-
#ifdef ASSERT
505-
if (prev_cs != NULL && prev_cs->is_frozen() && n < (SECT_LIMIT - 1)) {
506-
// Make sure the ends still match up.
507-
// This is important because a branch in a frozen section
508-
// might target code in a following section, via a Label,
509-
// and without a relocation record. See Label::patch_instructions.
510-
address dest_start = buf+buf_offset;
511-
csize_t start2start = cs->start() - prev_cs->start();
512-
csize_t dest_start2start = dest_start - prev_dest_cs->start();
513-
assert(start2start == dest_start2start, "cannot stretch frozen sect");
514-
}
515-
#endif //ASSERT
516482
prev_dest_cs = dest_cs;
517483
prev_cs = cs;
518484
}
@@ -891,9 +857,6 @@ void CodeBuffer::expand(CodeSection* which_cs, csize_t amount) {
891857
// Resizing must be allowed
892858
{
893859
if (blob() == NULL) return; // caller must check for blob == NULL
894-
for (int n = 0; n < (int)SECT_LIMIT; n++) {
895-
guarantee(!code_section(n)->is_frozen(), "resizing not allowed when frozen");
896-
}
897860
}
898861

899862
// Figure new capacity for each section.
@@ -1219,9 +1182,8 @@ void CodeBuffer::decode() {
12191182

12201183
void CodeSection::print(const char* name) {
12211184
csize_t locs_size = locs_end() - locs_start();
1222-
tty->print_cr(" %7s.code = " PTR_FORMAT " : " PTR_FORMAT " : " PTR_FORMAT " (%d of %d)%s",
1223-
name, p2i(start()), p2i(end()), p2i(limit()), size(), capacity(),
1224-
is_frozen()? " [frozen]": "");
1185+
tty->print_cr(" %7s.code = " PTR_FORMAT " : " PTR_FORMAT " : " PTR_FORMAT " (%d of %d)",
1186+
name, p2i(start()), p2i(end()), p2i(limit()), size(), capacity());
12251187
tty->print_cr(" %7s.locs = " PTR_FORMAT " : " PTR_FORMAT " : " PTR_FORMAT " (%d of %d) point=%d",
12261188
name, p2i(locs_start()), p2i(locs_end()), p2i(locs_limit()), locs_size, locs_capacity(), locs_point_off());
12271189
if (PrintRelocations) {

src/hotspot/share/asm/codeBuffer.hpp

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ class CodeSection {
9292
relocInfo* _locs_limit; // first byte after relocation information buf
9393
address _locs_point; // last relocated position (grows upward)
9494
bool _locs_own; // did I allocate the locs myself?
95-
bool _frozen; // no more expansion of this section
9695
bool _scratch_emit; // Buffer is used for scratch emit, don't relocate.
9796
char _index; // my section number (SECT_INST, etc.)
9897
CodeBuffer* _outer; // enclosing CodeBuffer
@@ -109,7 +108,6 @@ class CodeSection {
109108
_locs_limit = NULL;
110109
_locs_point = NULL;
111110
_locs_own = false;
112-
_frozen = false;
113111
_scratch_emit = false;
114112
debug_only(_index = (char)-1);
115113
debug_only(_outer = (CodeBuffer*)badAddress);
@@ -161,12 +159,10 @@ class CodeSection {
161159
address locs_point() const { return _locs_point; }
162160
csize_t locs_point_off() const{ return (csize_t)(_locs_point - _start); }
163161
csize_t locs_capacity() const { return (csize_t)(_locs_limit - _locs_start); }
164-
csize_t locs_remaining()const { return (csize_t)(_locs_limit - _locs_end); }
165162

166163
int index() const { return _index; }
167164
bool is_allocated() const { return _start != NULL; }
168165
bool is_empty() const { return _start == _end; }
169-
bool is_frozen() const { return _frozen; }
170166
bool has_locs() const { return _locs_end != NULL; }
171167

172168
// Mark scratch buffer.
@@ -184,8 +180,6 @@ class CodeSection {
184180
void set_end(address pc) { assert(allocates2(pc), "not in CodeBuffer memory: " INTPTR_FORMAT " <= " INTPTR_FORMAT " <= " INTPTR_FORMAT, p2i(_start), p2i(pc), p2i(_limit)); _end = pc; }
185181
void set_mark(address pc) { assert(contains2(pc), "not in codeBuffer");
186182
_mark = pc; }
187-
void set_mark_off(int offset) { assert(contains2(offset+_start),"not in codeBuffer");
188-
_mark = offset + _start; }
189183
void set_mark() { _mark = _end; }
190184
void clear_mark() { _mark = NULL; }
191185

@@ -259,10 +253,6 @@ class CodeSection {
259253

260254
csize_t align_at_start(csize_t off) const { return (csize_t) align_up(off, alignment()); }
261255

262-
// Mark a section frozen. Assign its remaining space to
263-
// the following section. It will never expand after this point.
264-
inline void freeze(); // { _outer->freeze_section(this); }
265-
266256
// Ensure there's enough space left in the current section.
267257
// Return true if there was an expansion.
268258
bool maybe_expand_to_ensure_remaining(csize_t amount);
@@ -463,8 +453,6 @@ class CodeBuffer: public StackObj {
463453

464454
void initialize_section_size(CodeSection* cs, csize_t size);
465455

466-
void freeze_section(CodeSection* cs);
467-
468456
// helper for CodeBuffer::expand()
469457
void take_over_code_from(CodeBuffer* cs);
470458

@@ -577,10 +565,8 @@ class CodeBuffer: public StackObj {
577565
address insts_begin() const { return _insts.start(); }
578566
address insts_end() const { return _insts.end(); }
579567
void set_insts_end(address end) { _insts.set_end(end); }
580-
address insts_limit() const { return _insts.limit(); }
581568
address insts_mark() const { return _insts.mark(); }
582569
void set_insts_mark() { _insts.set_mark(); }
583-
void clear_insts_mark() { _insts.clear_mark(); }
584570

585571
// is there anything in the buffer other than the current section?
586572
bool is_pure() const { return insts_size() == total_content_size(); }
@@ -652,12 +638,6 @@ class CodeBuffer: public StackObj {
652638
_code_strings.free(); // sets _strings Null as a side-effect.
653639
}
654640
}
655-
656-
// Print the comment associated with offset on stream, if there is one.
657-
virtual void print_block_comment(outputStream* stream, address block_begin) {
658-
intptr_t offset = (intptr_t)(block_begin - _total_start); // I assume total_start is not correct for all code sections.
659-
_code_strings.print_block_comment(stream, offset);
660-
}
661641
#endif
662642

663643
// Code generation
@@ -683,9 +663,6 @@ class CodeBuffer: public StackObj {
683663
}
684664
}
685665

686-
// Transform an address from the code in this code buffer to a specified code buffer
687-
address transform_address(const CodeBuffer &cb, address addr) const;
688-
689666
void block_comment(intptr_t offset, const char * comment) PRODUCT_RETURN;
690667
const char* code_string(const char* str) PRODUCT_RETURN_(return NULL;);
691668

@@ -714,11 +691,6 @@ class CodeBuffer: public StackObj {
714691

715692
};
716693

717-
718-
inline void CodeSection::freeze() {
719-
_outer->freeze_section(this);
720-
}
721-
722694
inline bool CodeSection::maybe_expand_to_ensure_remaining(csize_t amount) {
723695
if (remaining() < amount) { _outer->expand(this, amount); return true; }
724696
return false;

0 commit comments

Comments
 (0)