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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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(); ref_addr = stub->ref_addr()->as_pointer_register();
} else { } else {
// Load address into tmp register // 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(); 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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 align_call(LIR_Code code);
void negate(LIR_Opr left, LIR_Opr dest, LIR_Opr tmp = LIR_OprFact::illegalOpr); 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); 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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) { if (resolve_in_register) {
LIR_Opr resolved_addr = gen->new_pointer_register(); LIR_Opr resolved_addr = gen->new_pointer_register();
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); __ leal(addr_opr, resolved_addr);
resolved_addr = LIR_OprFact::address(new LIR_Address(resolved_addr, access.type())); }
return resolved_addr; return LIR_OprFact::address(new LIR_Address(resolved_addr, access.type()));
} else { } else {
return addr_opr; 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -102,6 +102,7 @@ public:
void set_resolved_addr(LIR_Opr addr) { _resolved_addr = addr; } void set_resolved_addr(LIR_Opr addr) { _resolved_addr = addr; }
bool is_oop() const { return _type == T_ARRAY || _type == T_OBJECT; } bool is_oop() const { return _type == T_ARRAY || _type == T_OBJECT; }
DecoratorSet decorators() const { return _decorators; } DecoratorSet decorators() const { return _decorators; }
void clear_decorators(DecoratorSet ds) { _decorators &= ~ds; }
bool is_raw() const { return (_decorators & AS_RAW) != 0; } bool is_raw() const { return (_decorators & AS_RAW) != 0; }
}; };

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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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_addr(access.resolved_addr()),
_ref(ref), _ref(ref),
_tmp(LIR_OprFact::illegalOpr), _tmp(LIR_OprFact::illegalOpr),
_patch_info(access.patch_emit_info()),
_runtime_stub(runtime_stub) { _runtime_stub(runtime_stub) {
// Allocate tmp register if needed // Allocate tmp register if needed
@ -72,28 +71,14 @@ LIR_Opr ZLoadBarrierStubC1::tmp() const {
return _tmp; 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 { address ZLoadBarrierStubC1::runtime_stub() const {
return _runtime_stub; return _runtime_stub;
} }
void ZLoadBarrierStubC1::visit(LIR_OpVisitState* visitor) { 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_input(_ref_addr);
visitor->do_output(_ref); visitor->do_output(_ref);
if (_tmp->is_valid()) { if (_tmp->is_valid()) {
visitor->do_temp(_tmp); visitor->do_temp(_tmp);
} }
@ -174,6 +159,14 @@ void ZBarrierSetC1::load_barrier(LIRAccess& access, LIR_Opr result) const {
__ branch_destination(stub->continuation()); __ 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 __ #undef __
void ZBarrierSetC1::load_at_resolved(LIRAccess& access, LIR_Opr result) { 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -36,7 +36,6 @@ private:
LIR_Opr _ref_addr; LIR_Opr _ref_addr;
LIR_Opr _ref; LIR_Opr _ref;
LIR_Opr _tmp; LIR_Opr _tmp;
CodeEmitInfo* _patch_info;
address _runtime_stub; address _runtime_stub;
public: public:
@ -46,8 +45,6 @@ public:
LIR_Opr ref() const; LIR_Opr ref() const;
LIR_Opr ref_addr() const; LIR_Opr ref_addr() const;
LIR_Opr tmp() const; LIR_Opr tmp() const;
LIR_PatchCode patch_code() const;
CodeEmitInfo*& patch_info();
address runtime_stub() const; address runtime_stub() const;
virtual void emit_code(LIR_Assembler* ce); virtual void emit_code(LIR_Assembler* ce);
@ -67,6 +64,7 @@ private:
void load_barrier(LIRAccess& access, LIR_Opr result) const; void load_barrier(LIRAccess& access, LIR_Opr result) const;
protected: protected:
virtual LIR_Opr resolve_address(LIRAccess& access, bool resolve_in_register);
virtual void load_at_resolved(LIRAccess& access, LIR_Opr result); 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_xchg_at_resolved(LIRAccess& access, LIRItem& value);
virtual LIR_Opr atomic_cmpxchg_at_resolved(LIRAccess& access, LIRItem& cmp_value, LIRItem& new_value); virtual LIR_Opr atomic_cmpxchg_at_resolved(LIRAccess& access, LIRItem& cmp_value, LIRItem& new_value);