Skip to content

Commit

Permalink
8307462: [REDO] VmObjectAlloc is not generated by intrinsics methods …
Browse files Browse the repository at this point in the history
…which allocate objects

Reviewed-by: sspitsyn, thartmann
  • Loading branch information
lmesnik committed Aug 9, 2023
1 parent 0a42c44 commit 3fb4805
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 4 deletions.
26 changes: 26 additions & 0 deletions src/hotspot/share/opto/library_call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include "opto/runtime.hpp"
#include "opto/rootnode.hpp"
#include "opto/subnode.hpp"
#include "prims/jvmtiExport.hpp"
#include "prims/jvmtiThreadState.hpp"
#include "prims/unsafe.hpp"
#include "runtime/jniHandles.inline.hpp"
Expand Down Expand Up @@ -2810,6 +2811,13 @@ bool LibraryCallKit::inline_unsafe_writebackSync0(bool is_pre) {
//----------------------------inline_unsafe_allocate---------------------------
// public native Object Unsafe.allocateInstance(Class<?> cls);
bool LibraryCallKit::inline_unsafe_allocate() {

#if INCLUDE_JVMTI
if (too_many_traps(Deoptimization::Reason_intrinsic)) {
return false;
}
#endif //INCLUDE_JVMTI

if (callee()->is_static()) return false; // caller must have the capability!

null_check_receiver(); // null-check, then ignore
Expand All @@ -2820,6 +2828,24 @@ bool LibraryCallKit::inline_unsafe_allocate() {
kls = null_check(kls);
if (stopped()) return true; // argument was like int.class

#if INCLUDE_JVMTI
// Don't try to access new allocated obj in the intrinsic.
// It causes perfomance issues even when jvmti event VmObjectAlloc is disabled.
// Deoptimize and allocate in interpreter instead.
Node* addr = makecon(TypeRawPtr::make((address) &JvmtiExport::_should_notify_object_alloc));
Node* should_post_vm_object_alloc = make_load(this->control(), addr, TypeInt::INT, T_INT, MemNode::unordered);
Node* chk = _gvn.transform(new CmpINode(should_post_vm_object_alloc, intcon(0)));
Node* tst = _gvn.transform(new BoolNode(chk, BoolTest::eq));
{
BuildCutout unless(this, tst, PROB_MAX);
uncommon_trap(Deoptimization::Reason_intrinsic,
Deoptimization::Action_make_not_entrant);
}
if (stopped()) {
return true;
}
#endif //INCLUDE_JVMTI

Node* test = nullptr;
if (LibraryCallKit::klass_needs_init_guard(kls)) {
// Note: The argument might still be an illegal value like
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/prims/jvmtiEventController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,7 @@ JvmtiEventControllerPrivate::recompute_enabled() {
// set global should_post_on_exceptions
JvmtiExport::set_should_post_on_exceptions((any_env_thread_enabled & SHOULD_POST_ON_EXCEPTIONS_BITS) != 0);

JvmtiExport::_should_notify_object_alloc = JvmtiExport::should_post_vm_object_alloc();
}

EC_TRACE(("[-] # recompute enabled - after " JULONG_FORMAT_X, any_env_thread_enabled));
Expand Down
3 changes: 3 additions & 0 deletions src/hotspot/share/prims/jvmtiExport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,9 @@ bool JvmtiExport::has_early_class_hook_env() {

bool JvmtiExport::_should_post_class_file_load_hook = false;

// This flag is read by C2 during VM internal objects allocation
int JvmtiExport::_should_notify_object_alloc = 0;

// this entry is for class file load hook on class load, redefine and retransform
bool JvmtiExport::post_class_file_load_hook(Symbol* h_name,
Handle class_loader,
Expand Down
3 changes: 3 additions & 0 deletions src/hotspot/share/prims/jvmtiExport.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,9 @@ class JvmtiExport : public AllStatic {
}
}

// Used by C2 to deoptimize allocation intrinsics and post vm_object_alloc
static int _should_notify_object_alloc;

static void record_sampled_internal_object_allocation(oop object) NOT_JVMTI_RETURN;
// Post objects collected by sampled_object_alloc_event_collector.
static void post_sampled_object_alloc(JavaThread *thread, oop object) NOT_JVMTI_RETURN;
Expand Down
3 changes: 0 additions & 3 deletions test/hotspot/jtreg/ProblemList-Xcomp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#############################################################################

vmTestbase/nsk/jvmti/AttachOnDemand/attach020/TestDescription.java 8287324 generic-all
vmTestbase/nsk/jvmti/AttachOnDemand/attach022/TestDescription.java 8307462 generic-all
vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw001/TestDescription.java 8205957 generic-all
vmTestbase/nsk/jvmti/SetFieldModificationWatch/setfmodw001/TestDescription.java 8205957 linux-x64,windows-x64
vmTestbase/nsk/jvmti/scenarios/sampling/SP07/sp07t002/TestDescription.java 8245680 windows-x64
Expand All @@ -39,8 +38,6 @@ serviceability/AsyncGetCallTrace/MyPackage/ASGCTBaseTest.java 8303168 linux-x64

serviceability/sa/TestJhsdbJstackMixed.java 8248675 linux-aarch64

serviceability/jvmti/VMObjectAlloc/VMObjectAllocTest.java 8307462 generic-all

serviceability/sa/ClhsdbInspect.java 8283578 windows-x64

vmTestbase/vm/mlvm/indy/func/jvmti/mergeCP_indy2manyDiff_a/TestDescription.java 8308367 windows-x64
Expand Down
1 change: 0 additions & 1 deletion test/hotspot/jtreg/ProblemList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ vmTestbase/metaspace/gc/firstGC_50m/TestDescription.java 8208250 generic-all
vmTestbase/metaspace/gc/firstGC_99m/TestDescription.java 8208250 generic-all
vmTestbase/metaspace/gc/firstGC_default/TestDescription.java 8208250 generic-all

vmTestbase/nsk/jvmti/AttachOnDemand/attach002a/TestDescription.java 8307462 generic-all
vmTestbase/nsk/jvmti/AttachOnDemand/attach045/TestDescription.java 8202971 generic-all
vmTestbase/nsk/jvmti/scenarios/jni_interception/JI05/ji05t001/TestDescription.java 8219652 aix-ppc64
vmTestbase/nsk/jvmti/scenarios/jni_interception/JI06/ji06t001/TestDescription.java 8219652 aix-ppc64
Expand Down

1 comment on commit 3fb4805

@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.