8217717: ZGC: Broken oop map in C1 load barrier stub

Co-authored-by: Erik Osterlund <erik.osterlund@oracle.com>
Reviewed-by: eosterlund, neliasso
This commit is contained in:
Per Lidén 2019-01-28 08:58:42 +01:00
parent 0f1fde187a
commit 7f6d6c8a8c
6 changed files with 42 additions and 46 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -280,7 +280,7 @@ void ZBarrierSetAssembler::generate_c1_load_barrier_stub(LIR_Assembler* ce,
ref_addr = stub->ref_addr()->as_pointer_register();
} else {
// Load address into tmp register
ce->leal(stub->ref_addr(), stub->tmp(), stub->patch_code(), stub->patch_info());
ce->leal(stub->ref_addr(), stub->tmp());
ref_addr = stub->tmp()->as_pointer_register();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -240,7 +240,7 @@ class LIR_Assembler: public CompilationResourceObj {
void align_call(LIR_Code code);
void negate(LIR_Opr left, LIR_Opr dest, LIR_Opr tmp = LIR_OprFact::illegalOpr);
void leal(LIR_Opr src, LIR_Opr dest, LIR_PatchCode patch_code, CodeEmitInfo* info);
void leal(LIR_Opr src, LIR_Opr dest, LIR_PatchCode patch_code = lir_patch_none, CodeEmitInfo* info = NULL);
void rt_call(LIR_Opr result, address dest, const LIR_OprList* args, LIR_Opr tmp, CodeEmitInfo* info);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -62,9 +62,13 @@ LIR_Opr BarrierSetC1::resolve_address(LIRAccess& access, bool resolve_in_registe
if (resolve_in_register) {
LIR_Opr resolved_addr = gen->new_pointer_register();
__ leal(addr_opr, resolved_addr);
resolved_addr = LIR_OprFact::address(new LIR_Address(resolved_addr, access.type()));
return resolved_addr;
if (needs_patching) {
__ leal(addr_opr, resolved_addr, lir_patch_normal, access.patch_emit_info());
access.clear_decorators(C1_NEEDS_PATCHING);
} else {
__ leal(addr_opr, resolved_addr);
}
return LIR_OprFact::address(new LIR_Address(resolved_addr, access.type()));
} else {
return addr_opr;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -92,17 +92,18 @@ public:
load_offset();
}
LIRGenerator* gen() const { return _gen; }
CodeEmitInfo*& patch_emit_info() { return _patch_emit_info; }
CodeEmitInfo*& access_emit_info() { return _access_emit_info; }
LIRAddressOpr& base() { return _base; }
LIRAddressOpr& offset() { return _offset; }
BasicType type() const { return _type; }
LIR_Opr resolved_addr() const { return _resolved_addr; }
void set_resolved_addr(LIR_Opr addr) { _resolved_addr = addr; }
bool is_oop() const { return _type == T_ARRAY || _type == T_OBJECT; }
DecoratorSet decorators() const { return _decorators; }
bool is_raw() const { return (_decorators & AS_RAW) != 0; }
LIRGenerator* gen() const { return _gen; }
CodeEmitInfo*& patch_emit_info() { return _patch_emit_info; }
CodeEmitInfo*& access_emit_info() { return _access_emit_info; }
LIRAddressOpr& base() { return _base; }
LIRAddressOpr& offset() { return _offset; }
BasicType type() const { return _type; }
LIR_Opr resolved_addr() const { return _resolved_addr; }
void set_resolved_addr(LIR_Opr addr) { _resolved_addr = addr; }
bool is_oop() const { return _type == T_ARRAY || _type == T_OBJECT; }
DecoratorSet decorators() const { return _decorators; }
void clear_decorators(DecoratorSet ds) { _decorators &= ~ds; }
bool is_raw() const { return (_decorators & AS_RAW) != 0; }
};
// The BarrierSetC1 class is the main entry point for the GC backend of the Access API in C1.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -36,7 +36,6 @@ ZLoadBarrierStubC1::ZLoadBarrierStubC1(LIRAccess& access, LIR_Opr ref, address r
_ref_addr(access.resolved_addr()),
_ref(ref),
_tmp(LIR_OprFact::illegalOpr),
_patch_info(access.patch_emit_info()),
_runtime_stub(runtime_stub) {
// Allocate tmp register if needed
@ -72,28 +71,14 @@ LIR_Opr ZLoadBarrierStubC1::tmp() const {
return _tmp;
}
LIR_PatchCode ZLoadBarrierStubC1::patch_code() const {
return (_decorators & C1_NEEDS_PATCHING) != 0 ? lir_patch_normal : lir_patch_none;
}
CodeEmitInfo*& ZLoadBarrierStubC1::patch_info() {
return _patch_info;
}
address ZLoadBarrierStubC1::runtime_stub() const {
return _runtime_stub;
}
void ZLoadBarrierStubC1::visit(LIR_OpVisitState* visitor) {
if (_patch_info != NULL) {
visitor->do_slow_case(_patch_info);
} else {
visitor->do_slow_case();
}
visitor->do_slow_case();
visitor->do_input(_ref_addr);
visitor->do_output(_ref);
if (_tmp->is_valid()) {
visitor->do_temp(_tmp);
}
@ -174,6 +159,14 @@ void ZBarrierSetC1::load_barrier(LIRAccess& access, LIR_Opr result) const {
__ branch_destination(stub->continuation());
}
LIR_Opr ZBarrierSetC1::resolve_address(LIRAccess& access, bool resolve_in_register) {
// We must resolve in register when patching. This is to avoid
// having a patch area in the load barrier stub, since the call
// into the runtime to patch will not have the proper oop map.
const bool patch_before_barrier = barrier_needed(access) && (access.decorators() & C1_NEEDS_PATCHING) != 0;
return BarrierSetC1::resolve_address(access, resolve_in_register || patch_before_barrier);
}
#undef __
void ZBarrierSetC1::load_at_resolved(LIRAccess& access, LIR_Opr result) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -32,12 +32,11 @@
class ZLoadBarrierStubC1 : public CodeStub {
private:
DecoratorSet _decorators;
LIR_Opr _ref_addr;
LIR_Opr _ref;
LIR_Opr _tmp;
CodeEmitInfo* _patch_info;
address _runtime_stub;
DecoratorSet _decorators;
LIR_Opr _ref_addr;
LIR_Opr _ref;
LIR_Opr _tmp;
address _runtime_stub;
public:
ZLoadBarrierStubC1(LIRAccess& access, LIR_Opr ref, address runtime_stub);
@ -46,8 +45,6 @@ public:
LIR_Opr ref() const;
LIR_Opr ref_addr() const;
LIR_Opr tmp() const;
LIR_PatchCode patch_code() const;
CodeEmitInfo*& patch_info();
address runtime_stub() const;
virtual void emit_code(LIR_Assembler* ce);
@ -67,6 +64,7 @@ private:
void load_barrier(LIRAccess& access, LIR_Opr result) const;
protected:
virtual LIR_Opr resolve_address(LIRAccess& access, bool resolve_in_register);
virtual void load_at_resolved(LIRAccess& access, LIR_Opr result);
virtual LIR_Opr atomic_xchg_at_resolved(LIRAccess& access, LIRItem& value);
virtual LIR_Opr atomic_cmpxchg_at_resolved(LIRAccess& access, LIRItem& cmp_value, LIRItem& new_value);