# HG changeset patch # User rkennke # Date 1541006145 -3600 # Wed Oct 31 18:15:45 2018 +0100 # Node ID 6111932feaf38b4770f6c9977e377bf9701d47c8 # Parent 896e80158d355bb8aebbf1b7193bfe609551912e 8213199: GC abstraction for Assembler::needs_explicit_null_check() diff --git a/src/hotspot/cpu/aarch64/gc/shared/barrierSetAssembler_aarch64.hpp b/src/hotspot/cpu/aarch64/gc/shared/barrierSetAssembler_aarch64.hpp --- a/src/hotspot/cpu/aarch64/gc/shared/barrierSetAssembler_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/gc/shared/barrierSetAssembler_aarch64.hpp @@ -72,6 +72,8 @@ Label& slow_case // continuation point if fast allocation fails ); virtual void barrier_stubs_init() {} + + virtual bool needs_explicit_null_check(intptr_t offset); }; #endif // CPU_AARCH64_GC_SHARED_BARRIERSETASSEMBLER_AARCH64_HPP diff --git a/src/hotspot/cpu/arm/gc/shared/barrierSetAssembler_arm.hpp b/src/hotspot/cpu/arm/gc/shared/barrierSetAssembler_arm.hpp --- a/src/hotspot/cpu/arm/gc/shared/barrierSetAssembler_arm.hpp +++ b/src/hotspot/cpu/arm/gc/shared/barrierSetAssembler_arm.hpp @@ -72,6 +72,8 @@ virtual void resolve(MacroAssembler* masm, DecoratorSet decorators, Register obj) { // Default implementation does not need to do anything. } + + virtual bool needs_explicit_null_check(intptr_t offset); }; #endif // CPU_ARM_GC_SHARED_BARRIERSETASSEMBLER_ARM_HPP diff --git a/src/hotspot/cpu/ppc/gc/shared/barrierSetAssembler_ppc.hpp b/src/hotspot/cpu/ppc/gc/shared/barrierSetAssembler_ppc.hpp --- a/src/hotspot/cpu/ppc/gc/shared/barrierSetAssembler_ppc.hpp +++ b/src/hotspot/cpu/ppc/gc/shared/barrierSetAssembler_ppc.hpp @@ -50,6 +50,8 @@ virtual void resolve_jobject(MacroAssembler* masm, Register value, Register tmp1, Register tmp2, bool needs_frame); virtual void barrier_stubs_init() {} + + virtual bool needs_explicit_null_check(intptr_t offset); }; #endif // CPU_PPC_GC_SHARED_BARRIERSETASSEMBLER_PPC_HPP diff --git a/src/hotspot/cpu/s390/gc/shared/barrierSetAssembler_s390.hpp b/src/hotspot/cpu/s390/gc/shared/barrierSetAssembler_s390.hpp --- a/src/hotspot/cpu/s390/gc/shared/barrierSetAssembler_s390.hpp +++ b/src/hotspot/cpu/s390/gc/shared/barrierSetAssembler_s390.hpp @@ -47,6 +47,8 @@ virtual void resolve_jobject(MacroAssembler* masm, Register value, Register tmp1, Register tmp2); virtual void barrier_stubs_init() {} + + virtual bool needs_explicit_null_check(intptr_t offset); }; #endif // CPU_S390_GC_SHARED_BARRIERSETASSEMBLER_S390_HPP diff --git a/src/hotspot/cpu/sparc/gc/shared/barrierSetAssembler_sparc.hpp b/src/hotspot/cpu/sparc/gc/shared/barrierSetAssembler_sparc.hpp --- a/src/hotspot/cpu/sparc/gc/shared/barrierSetAssembler_sparc.hpp +++ b/src/hotspot/cpu/sparc/gc/shared/barrierSetAssembler_sparc.hpp @@ -49,6 +49,8 @@ Register obj, Register tmp, Label& slowpath); virtual void barrier_stubs_init() {} + + virtual bool needs_explicit_null_check(intptr_t offset); }; #endif // CPU_SPARC_GC_SHARED_BARRIERSETASSEMBLER_SPARC_HPP diff --git a/src/hotspot/cpu/x86/gc/shared/barrierSetAssembler_x86.hpp b/src/hotspot/cpu/x86/gc/shared/barrierSetAssembler_x86.hpp --- a/src/hotspot/cpu/x86/gc/shared/barrierSetAssembler_x86.hpp +++ b/src/hotspot/cpu/x86/gc/shared/barrierSetAssembler_x86.hpp @@ -85,6 +85,8 @@ virtual void barrier_stubs_init() {} virtual void nmethod_entry_barrier(MacroAssembler* masm); + + virtual bool needs_explicit_null_check(intptr_t offset); }; #endif // CPU_X86_GC_SHARED_BARRIERSETASSEMBLER_X86_HPP diff --git a/src/hotspot/share/asm/assembler.cpp b/src/hotspot/share/asm/assembler.cpp --- a/src/hotspot/share/asm/assembler.cpp +++ b/src/hotspot/share/asm/assembler.cpp @@ -308,20 +308,5 @@ } bool MacroAssembler::needs_explicit_null_check(intptr_t offset) { - // Exception handler checks the nmethod's implicit null checks table - // only when this method returns false. -#ifdef _LP64 - if (UseCompressedOops && Universe::narrow_oop_base() != NULL) { - assert (Universe::heap() != NULL, "java heap should be initialized"); - // The first page after heap_base is unmapped and - // the 'offset' is equal to [heap_base + offset] for - // narrow oop implicit null checks. - uintptr_t base = (uintptr_t)Universe::narrow_oop_base(); - if ((uintptr_t)offset >= base) { - // Normalize offset for the next check. - offset = (intptr_t)(pointer_delta((void*)offset, (void*)base, 1)); - } - } -#endif - return offset < 0 || os::vm_page_size() <= offset; + return BarrierSet::barrier_set()->barrier_set_assembler()->needs_explicit_null_check(offset); } diff --git a/src/hotspot/share/gc/shared/barrierSetAssembler.cpp b/src/hotspot/share/gc/shared/barrierSetAssembler.cpp new file mode 100644 --- /dev/null +++ b/src/hotspot/share/gc/shared/barrierSetAssembler.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "gc/shared/barrierSetAssembler.hpp" +#include "memory/universe.hpp" +#include "utilities/globalDefinitions.hpp" + +bool BarrierSetAssembler::needs_explicit_null_check(intptr_t offset) { + // Exception handler checks the nmethod's implicit null checks table + // only when this method returns false. +#ifdef _LP64 + if (UseCompressedOops && Universe::narrow_oop_base() != NULL) { + assert (Universe::heap() != NULL, "java heap should be initialized"); + // The first page after heap_base is unmapped and + // the 'offset' is equal to [heap_base + offset] for + // narrow oop implicit null checks. + uintptr_t base = (uintptr_t)Universe::narrow_oop_base(); + if ((uintptr_t)offset >= base) { + // Normalize offset for the next check. + offset = (intptr_t)(pointer_delta((void*)offset, (void*)base, 1)); + } + } +#endif + return offset < 0 || os::vm_page_size() <= offset; +}