Skip to content

Commit

Permalink
8259870: zBarrier.inline.hpp should not include javaClasses.hpp
Browse files Browse the repository at this point in the history
Reviewed-by: stefank, tschatzl
  • Loading branch information
iklam committed Jan 19, 2021
1 parent a1a851b commit 14ce8f1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
17 changes: 16 additions & 1 deletion src/hotspot/share/gc/z/zBarrier.cpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2021, 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
Expand All @@ -22,6 +22,7 @@
*/

#include "precompiled.hpp"
#include "classfile/javaClasses.hpp"
#include "gc/z/zBarrier.inline.hpp"
#include "gc/z/zHeap.inline.hpp"
#include "gc/z/zOop.inline.hpp"
Expand Down Expand Up @@ -239,6 +240,20 @@ oop ZBarrier::weak_load_barrier_on_phantom_oop_field_preloaded(volatile narrowOo
return NULL;
}

#ifdef ASSERT

// ON_WEAK barriers should only ever be applied to j.l.r.Reference.referents.
void ZBarrier::verify_on_weak(volatile oop* referent_addr) {
if (referent_addr != NULL) {
uintptr_t base = (uintptr_t)referent_addr - java_lang_ref_Reference::referent_offset();
oop obj = cast_to_oop(base);
assert(oopDesc::is_oop(obj), "Verification failed for: ref " PTR_FORMAT " obj: " PTR_FORMAT, (uintptr_t)referent_addr, base);
assert(java_lang_ref_Reference::is_referent_field(obj, java_lang_ref_Reference::referent_offset()), "Sanity");
}
}

#endif

void ZLoadBarrierOopClosure::do_oop(oop* p) {
ZBarrier::load_barrier_on_oop_field(p);
}
Expand Down
4 changes: 3 additions & 1 deletion src/hotspot/share/gc/z/zBarrier.hpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2021, 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
Expand Down Expand Up @@ -75,6 +75,8 @@ class ZBarrier : public AllStatic {
static uintptr_t mark_barrier_on_oop_slow_path(uintptr_t addr);
static uintptr_t mark_barrier_on_finalizable_oop_slow_path(uintptr_t addr);

static void verify_on_weak(volatile oop* referent_addr) NOT_DEBUG_RETURN;

public:
// Load barrier
static oop load_barrier_on_oop(oop o);
Expand Down
15 changes: 1 addition & 14 deletions src/hotspot/share/gc/z/zBarrier.inline.hpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2021, 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
Expand All @@ -24,7 +24,6 @@
#ifndef SHARE_GC_Z_ZBARRIER_INLINE_HPP
#define SHARE_GC_Z_ZBARRIER_INLINE_HPP

#include "classfile/javaClasses.hpp"
#include "gc/z/zAddress.inline.hpp"
#include "gc/z/zBarrier.hpp"
#include "gc/z/zOop.inline.hpp"
Expand Down Expand Up @@ -242,18 +241,6 @@ inline void ZBarrier::load_barrier_on_oop_array(volatile oop* p, size_t length)
}
}

// ON_WEAK barriers should only ever be applied to j.l.r.Reference.referents.
inline void verify_on_weak(volatile oop* referent_addr) {
#ifdef ASSERT
if (referent_addr != NULL) {
uintptr_t base = (uintptr_t)referent_addr - java_lang_ref_Reference::referent_offset();
oop obj = cast_to_oop(base);
assert(oopDesc::is_oop(obj), "Verification failed for: ref " PTR_FORMAT " obj: " PTR_FORMAT, (uintptr_t)referent_addr, base);
assert(java_lang_ref_Reference::is_referent_field(obj, java_lang_ref_Reference::referent_offset()), "Sanity");
}
#endif
}

inline oop ZBarrier::load_barrier_on_weak_oop_field_preloaded(volatile oop* p, oop o) {
verify_on_weak(p);

Expand Down

1 comment on commit 14ce8f1

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.