From c0b69ecc9729300f2dde34d904e81dd4ac88536d Mon Sep 17 00:00:00 2001 From: phh Date: Thu, 20 Dec 2018 20:11:38 +0000 Subject: [PATCH] 8206075: On x86, assert on unbound assembler Labels used as branch targets 8208480: Test failure: assert(is_bound() || is_unused()) after JDK-8206075 in C1 Summary: Combine unbound Label assertion checking backports Reviewed-by: andrew, coffeys --- src/cpu/x86/vm/interp_masm_x86_32.cpp | 6 ++++-- src/cpu/x86/vm/interp_masm_x86_64.cpp | 6 ++++-- src/cpu/x86/vm/templateTable_x86_32.cpp | 9 +++++---- src/cpu/x86/vm/templateTable_x86_64.cpp | 9 +++++---- src/share/vm/asm/assembler.hpp | 10 +++++++++- src/share/vm/c1/c1_LIRAssembler.cpp | 5 ++++- 6 files changed, 31 insertions(+), 14 deletions(-) diff --git a/src/cpu/x86/vm/interp_masm_x86_32.cpp b/src/cpu/x86/vm/interp_masm_x86_32.cpp index 8a132c12f..84cdc94dd 100644 --- a/src/cpu/x86/vm/interp_masm_x86_32.cpp +++ b/src/cpu/x86/vm/interp_masm_x86_32.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2018, 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 @@ -1445,5 +1445,7 @@ void InterpreterMacroAssembler::increment_mask_and_jump(Address counter_addr, incrementl(scratch, increment); movl(counter_addr, scratch); andl(scratch, mask); - jcc(cond, *where); + if (where != NULL) { + jcc(cond, *where); + } } diff --git a/src/cpu/x86/vm/interp_masm_x86_64.cpp b/src/cpu/x86/vm/interp_masm_x86_64.cpp index 693ac7958..727207ec1 100644 --- a/src/cpu/x86/vm/interp_masm_x86_64.cpp +++ b/src/cpu/x86/vm/interp_masm_x86_64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2018, 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 @@ -1505,5 +1505,7 @@ void InterpreterMacroAssembler::increment_mask_and_jump(Address counter_addr, incrementl(scratch, increment); movl(counter_addr, scratch); andl(scratch, mask); - jcc(cond, *where); + if (where != NULL) { + jcc(cond, *where); + } } diff --git a/src/cpu/x86/vm/templateTable_x86_32.cpp b/src/cpu/x86/vm/templateTable_x86_32.cpp index df497868b..5d33addcc 100644 --- a/src/cpu/x86/vm/templateTable_x86_32.cpp +++ b/src/cpu/x86/vm/templateTable_x86_32.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2018, 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 @@ -1640,15 +1640,16 @@ void TemplateTable::branch(bool is_jsr, bool is_wide) { // Increment the MDO backedge counter const Address mdo_backedge_counter(rbx, in_bytes(MethodData::backedge_counter_offset()) + in_bytes(InvocationCounter::counter_offset())); - __ increment_mask_and_jump(mdo_backedge_counter, increment, mask, - rax, false, Assembler::zero, &backedge_counter_overflow); + __ increment_mask_and_jump(mdo_backedge_counter, increment, mask, rax, false, Assembler::zero, + UseOnStackReplacement ? &backedge_counter_overflow : NULL); __ jmp(dispatch); } __ bind(no_mdo); // Increment backedge counter in MethodCounters* __ movptr(rcx, Address(rcx, Method::method_counters_offset())); __ increment_mask_and_jump(Address(rcx, be_offset), increment, mask, - rax, false, Assembler::zero, &backedge_counter_overflow); + rax, false, Assembler::zero, + UseOnStackReplacement ? &backedge_counter_overflow : NULL); } else { // increment counter __ movptr(rcx, Address(rcx, Method::method_counters_offset())); diff --git a/src/cpu/x86/vm/templateTable_x86_64.cpp b/src/cpu/x86/vm/templateTable_x86_64.cpp index 301acb440..a619f44d6 100644 --- a/src/cpu/x86/vm/templateTable_x86_64.cpp +++ b/src/cpu/x86/vm/templateTable_x86_64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2018, 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 @@ -1665,15 +1665,16 @@ void TemplateTable::branch(bool is_jsr, bool is_wide) { // Increment the MDO backedge counter const Address mdo_backedge_counter(rbx, in_bytes(MethodData::backedge_counter_offset()) + in_bytes(InvocationCounter::counter_offset())); - __ increment_mask_and_jump(mdo_backedge_counter, increment, mask, - rax, false, Assembler::zero, &backedge_counter_overflow); + __ increment_mask_and_jump(mdo_backedge_counter, increment, mask, rax, false, Assembler::zero, + UseOnStackReplacement ? &backedge_counter_overflow : NULL); __ jmp(dispatch); } __ bind(no_mdo); // Increment backedge counter in MethodCounters* __ movptr(rcx, Address(rcx, Method::method_counters_offset())); __ increment_mask_and_jump(Address(rcx, be_offset), increment, mask, - rax, false, Assembler::zero, &backedge_counter_overflow); + rax, false, Assembler::zero, + UseOnStackReplacement ? &backedge_counter_overflow : NULL); } else { // increment counter __ movptr(rcx, Address(rcx, Method::method_counters_offset())); diff --git a/src/share/vm/asm/assembler.hpp b/src/share/vm/asm/assembler.hpp index ec8ec5eb4..ac39e6ac4 100644 --- a/src/share/vm/asm/assembler.hpp +++ b/src/share/vm/asm/assembler.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2018, 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 @@ -169,6 +169,14 @@ class Label VALUE_OBJ_CLASS_SPEC { Label() { init(); } + + ~Label() { + assert(is_bound() || is_unused(), "Label was never bound to a location, but it was used as a jmp target"); + } + + void reset() { + init(); //leave _patch_overflow because it points to CodeBuffer. + } }; // A union type for code which has to assemble both constant and diff --git a/src/share/vm/c1/c1_LIRAssembler.cpp b/src/share/vm/c1/c1_LIRAssembler.cpp index 3447e0703..a2cf5f269 100644 --- a/src/share/vm/c1/c1_LIRAssembler.cpp +++ b/src/share/vm/c1/c1_LIRAssembler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2018, 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 @@ -128,6 +128,9 @@ LIR_Assembler::LIR_Assembler(Compilation* c): LIR_Assembler::~LIR_Assembler() { + // The unwind handler label may be unbound if this destructor is invoked because of a bail-out. + // Reset it here to avoid an assertion. + _unwind_handler_entry.reset(); } -- GitLab