Skip to content
Permalink
Browse files
8253047: [lworld] C2 compilation fails with guarantee(sect->end() <= …
…sect->limit()) failed: sanity
  • Loading branch information
TobiHartmann committed Sep 11, 2020
1 parent dee85ce commit 74a852385098f1e8e8cb0ecfa29232d589f4dbf5
Showing 4 changed files with 114 additions and 4 deletions.
@@ -122,6 +122,10 @@ bool ciInlineKlass::contains_oops() const {
GUARDED_VM_ENTRY(return get_InlineKlass()->contains_oops();)
}

int ciInlineKlass::oop_count() const {
GUARDED_VM_ENTRY(return get_InlineKlass()->nonstatic_oop_count();)
}

Array<SigEntry>* ciInlineKlass::extended_sig() const {
GUARDED_VM_ENTRY(return get_InlineKlass()->extended_sig();)
}
@@ -86,6 +86,7 @@ class ciInlineKlass : public ciInstanceKlass {
int default_value_offset() const;
ciInstance* default_instance() const;
bool contains_oops() const;
int oop_count() const;
Array<SigEntry>* extended_sig() const;
address pack_handler() const;
address unpack_handler() const;
@@ -3234,12 +3234,16 @@ void PhaseOutput::init_scratch_buffer_blob(int const_size) {
ResourceMark rm;
_scratch_const_size = const_size;
int size = C2Compiler::initial_code_buffer_size(const_size);
#ifdef ASSERT
if (C->has_scalarized_args()) {
// Oop verification for loading object fields from scalarized inline types in the new entry point requires lots of space
size += 5120;
// Inline type entry points (MachVEPNodes) require lots of space for GC barriers and oop verification
// when loading object fields from the buffered argument. Increase scratch buffer size accordingly.
int barrier_size = UseZGC ? 200 : (7 DEBUG_ONLY(+ 37));
for (ciSignatureStream str(C->method()->signature()); !str.at_return_type(); str.next()) {
if (str.type()->is_inlinetype() && str.type()->as_inline_klass()->can_be_passed_as_fields()) {
size += str.type()->as_inline_klass()->oop_count() * barrier_size;
}
}
}
#endif
blob = BufferBlob::create("Compile::scratch_buffer", size);
// Record the buffer blob for next time.
set_scratch_buffer_blob(blob);
@@ -800,4 +800,105 @@ public void test38_verifier(boolean warmup) {
MyValueEmpty res = test38(vt);
Asserts.assertEQ(res, vt);
}

static inline class LargeValueWithOops {
// Use all 6 int registers + 50/2 on stack = 29
Object o1 = null;
Object o2 = null;
Object o3 = null;
Object o4 = null;
Object o5 = null;
Object o6 = null;
Object o7 = null;
Object o8 = null;
Object o9 = null;
Object o10 = null;
Object o11 = null;
Object o12 = null;
Object o13 = null;
Object o14 = null;
Object o15 = null;
Object o16 = null;
Object o17 = null;
Object o18 = null;
Object o19 = null;
Object o20 = null;
Object o21 = null;
Object o22 = null;
Object o23 = null;
Object o24 = null;
Object o25 = null;
Object o26 = null;
Object o27 = null;
Object o28 = null;
Object o29 = null;
}

static inline class LargeValueWithoutOops {
// Use all 6 int registers + 50/2 on stack = 29
int i1 = 0;
int i2 = 0;
int i3 = 0;
int i4 = 0;
int i5 = 0;
int i6 = 0;
int i7 = 0;
int i8 = 0;
int i9 = 0;
int i10 = 0;
int i11 = 0;
int i12 = 0;
int i13 = 0;
int i14 = 0;
int i15 = 0;
int i16 = 0;
int i17 = 0;
int i18 = 0;
int i19 = 0;
int i20 = 0;
int i21 = 0;
int i22 = 0;
int i23 = 0;
int i24 = 0;
int i25 = 0;
int i26 = 0;
int i27 = 0;
int i28 = 0;
int i29 = 0;
// Use all 7 float registers
double d1 = 0;
double d2 = 0;
double d3 = 0;
double d4 = 0;
double d5 = 0;
double d6 = 0;
double d7 = 0;
double d8 = 0;
}

// Test passing/returning a large inline type with oop fields
@Test()
public static LargeValueWithOops test39(LargeValueWithOops vt) {
return vt;
}

@DontCompile
public void test39_verifier(boolean warmup) {
LargeValueWithOops vt = new LargeValueWithOops();
LargeValueWithOops res = test39(vt);
Asserts.assertEQ(res, vt);
}

// Test passing/returning a large inline type with only int/float fields
@Test()
public static LargeValueWithoutOops test40(LargeValueWithoutOops vt) {
return vt;
}

@DontCompile
public void test40_verifier(boolean warmup) {
LargeValueWithoutOops vt = new LargeValueWithoutOops();
LargeValueWithoutOops res = test40(vt);
Asserts.assertEQ(res, vt);
}
}

0 comments on commit 74a8523

Please sign in to comment.