Mercurial > hg > icedtea8-forest > hotspot
changeset 10867:5f51c6044a7c
8255717: Fix JFR crash in WriteObjectSampleStacktrace due to object not initialized
Reviewed-by: phh
author | hshi |
---|---|
date | Thu, 12 Nov 2020 20:01:00 +0800 |
parents | 739dd6193ede |
children | 3fcf88579cd6 |
files | src/share/vm/gc_interface/collectedHeap.cpp src/share/vm/gc_interface/collectedHeap.inline.hpp src/share/vm/memory/threadLocalAllocBuffer.hpp |
diffstat | 3 files changed, 20 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/share/vm/gc_interface/collectedHeap.cpp Fri Nov 22 00:29:48 2019 +0000 +++ b/src/share/vm/gc_interface/collectedHeap.cpp Thu Nov 12 20:01:00 2020 +0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2020, 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 @@ -286,8 +286,6 @@ return NULL; } - AllocTracer::send_allocation_in_new_tlab_event(klass, obj, new_tlab_size * HeapWordSize, size * HeapWordSize, Thread::current()); - if (ZeroTLAB) { // ..and clear it. Copy::zero_to_words(obj, new_tlab_size);
--- a/src/share/vm/gc_interface/collectedHeap.inline.hpp Fri Nov 22 00:29:48 2019 +0000 +++ b/src/share/vm/gc_interface/collectedHeap.inline.hpp Thu Nov 12 20:01:00 2020 +0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2020, 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 @@ -65,8 +65,22 @@ } } -// Support for jvmti and dtrace +inline void send_jfr_allocation_event(KlassHandle klass, HeapWord* obj, size_t size) { + Thread* t = Thread::current(); + ThreadLocalAllocBuffer& tlab = t->tlab(); + if (obj == tlab.start()) { + // allocate in new TLAB + size_t new_tlab_size = tlab.hard_size_bytes(); + AllocTracer::send_allocation_in_new_tlab_event(klass, obj, new_tlab_size, size * HeapWordSize, t); + } else if (!tlab.in_used(obj)) { + // allocate outside TLAB + AllocTracer::send_allocation_outside_tlab_event(klass, obj, size * HeapWordSize, t); + } +} + +// Support for jvmti, dtrace and jfr inline void post_allocation_notify(KlassHandle klass, oop obj, int size) { + send_jfr_allocation_event(klass, (HeapWord*)obj, size); // support low memory notifications (no-op if not enabled) LowMemoryDetector::detect_low_memory_for_collected_pools(); @@ -137,8 +151,6 @@ "Unexpected exception, will result in uninitialized storage"); THREAD->incr_allocated_bytes(size * HeapWordSize); - AllocTracer::send_allocation_outside_tlab_event(klass, result, size * HeapWordSize, Thread::current()); - return result; }
--- a/src/share/vm/memory/threadLocalAllocBuffer.hpp Fri Nov 22 00:29:48 2019 +0000 +++ b/src/share/vm/memory/threadLocalAllocBuffer.hpp Thu Nov 12 20:01:00 2020 +0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2020, 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 @@ -120,6 +120,8 @@ size_t free() const { return pointer_delta(end(), top()); } // Don't discard tlab if remaining space is larger than this. size_t refill_waste_limit() const { return _refill_waste_limit; } + size_t hard_size_bytes() const { return pointer_delta(hard_end(), start(), 1); } + bool in_used(HeapWord* addr) const { return addr >= start() && addr < top(); } // Allocate size HeapWords. The memory is NOT initialized to zero. inline HeapWord* allocate(size_t size);