8039904: dtrace/hotspot/Monitors/Monitors001 fails with "assert(s > 0) failed: Bad size calculated"
Summary: Dtrace monitoring uses size before mirror size is set.
Reviewed-by: kamg, hseigel
--- a/hotspot/src/share/vm/gc_interface/collectedHeap.hpp Thu Apr 10 21:36:56 2014 -0400
+++ b/hotspot/src/share/vm/gc_interface/collectedHeap.hpp Fri Apr 11 20:02:37 2014 +0000
@@ -151,7 +151,7 @@
inline static void post_allocation_setup_no_klass_install(KlassHandle klass,
HeapWord* objPtr);
- inline static void post_allocation_setup_obj(KlassHandle klass, HeapWord* obj);
+ inline static void post_allocation_setup_obj(KlassHandle klass, HeapWord* obj, int size);
inline static void post_allocation_setup_array(KlassHandle klass,
HeapWord* obj, int length);
--- a/hotspot/src/share/vm/gc_interface/collectedHeap.inline.hpp Thu Apr 10 21:36:56 2014 -0400
+++ b/hotspot/src/share/vm/gc_interface/collectedHeap.inline.hpp Fri Apr 11 20:02:37 2014 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2014, 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
@@ -70,7 +70,7 @@
}
// Support for jvmti and dtrace
-inline void post_allocation_notify(KlassHandle klass, oop obj) {
+inline void post_allocation_notify(KlassHandle klass, oop obj, int size) {
// support low memory notifications (no-op if not enabled)
LowMemoryDetector::detect_low_memory_for_collected_pools();
@@ -80,18 +80,19 @@
if (DTraceAllocProbes) {
// support for Dtrace object alloc event (no-op most of the time)
if (klass() != NULL && klass()->name() != NULL) {
- SharedRuntime::dtrace_object_alloc(obj);
+ SharedRuntime::dtrace_object_alloc(obj, size);
}
}
}
void CollectedHeap::post_allocation_setup_obj(KlassHandle klass,
- HeapWord* obj) {
+ HeapWord* obj,
+ int size) {
post_allocation_setup_common(klass, obj);
assert(Universe::is_bootstrapping() ||
!((oop)obj)->is_array(), "must not be an array");
// notify jvmti and dtrace
- post_allocation_notify(klass, (oop)obj);
+ post_allocation_notify(klass, (oop)obj, size);
}
void CollectedHeap::post_allocation_setup_array(KlassHandle klass,
@@ -103,9 +104,10 @@
assert(length >= 0, "length should be non-negative");
((arrayOop)obj)->set_length(length);
post_allocation_setup_common(klass, obj);
- assert(((oop)obj)->is_array(), "must be an array");
+ oop new_obj = (oop)obj;
+ assert(new_obj->is_array(), "must be an array");
// notify jvmti and dtrace (must be after length is set for dtrace)
- post_allocation_notify(klass, (oop)obj);
+ post_allocation_notify(klass, new_obj, new_obj->size());
}
HeapWord* CollectedHeap::common_mem_allocate_noinit(KlassHandle klass, size_t size, TRAPS) {
@@ -199,7 +201,7 @@
assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed");
assert(size >= 0, "int won't convert to size_t");
HeapWord* obj = common_mem_allocate_init(klass, size, CHECK_NULL);
- post_allocation_setup_obj(klass, obj);
+ post_allocation_setup_obj(klass, obj, size);
NOT_PRODUCT(Universe::heap()->check_for_bad_heap_word_value(obj, size));
return (oop)obj;
}
--- a/hotspot/src/share/vm/runtime/sharedRuntime.cpp Thu Apr 10 21:36:56 2014 -0400
+++ b/hotspot/src/share/vm/runtime/sharedRuntime.cpp Fri Apr 11 20:02:37 2014 +0000
@@ -946,14 +946,13 @@
* it gets turned into a tail-call on sparc, which runs into dtrace bug
* 6254741. Once that is fixed we can remove the dummy return value.
*/
-int SharedRuntime::dtrace_object_alloc(oopDesc* o) {
- return dtrace_object_alloc_base(Thread::current(), o);
+int SharedRuntime::dtrace_object_alloc(oopDesc* o, int size) {
+ return dtrace_object_alloc_base(Thread::current(), o, size);
}
-int SharedRuntime::dtrace_object_alloc_base(Thread* thread, oopDesc* o) {
+int SharedRuntime::dtrace_object_alloc_base(Thread* thread, oopDesc* o, int size) {
assert(DTraceAllocProbes, "wrong call");
Klass* klass = o->klass();
- int size = o->size();
Symbol* name = klass->name();
HOTSPOT_OBJECT_ALLOC(
get_java_tid(thread),
--- a/hotspot/src/share/vm/runtime/sharedRuntime.hpp Thu Apr 10 21:36:56 2014 -0400
+++ b/hotspot/src/share/vm/runtime/sharedRuntime.hpp Fri Apr 11 20:02:37 2014 +0000
@@ -258,8 +258,8 @@
static void register_finalizer(JavaThread* thread, oopDesc* obj);
// dtrace notifications
- static int dtrace_object_alloc(oopDesc* o);
- static int dtrace_object_alloc_base(Thread* thread, oopDesc* o);
+ static int dtrace_object_alloc(oopDesc* o, int size);
+ static int dtrace_object_alloc_base(Thread* thread, oopDesc* o, int size);
static int dtrace_method_entry(JavaThread* thread, Method* m);
static int dtrace_method_exit(JavaThread* thread, Method* m);