aboutsummaryrefslogtreecommitdiff
path: root/src/share
diff options
context:
space:
mode:
authordcubed <none@none>2010-02-01 17:35:05 -0700
committerdcubed <none@none>2010-02-01 17:35:05 -0700
commitdf7cb5f7fa422ddb60bc9f0151665dcbcb74f516 (patch)
tree07aa0cce7f24246ea5485336e68932f6b84716ef /src/share
parentc404404df557087af477099dcdbeb7d5b0761a8d (diff)
6902182: 4/4 Starting with jdwp agent should not incur performance penalty
Summary: Rename can_post_exceptions support to can_post_on_exceptions. Add support for should_post_on_exceptions flag to permit per JavaThread optimizations. Reviewed-by: never, kvn, dcubed Contributed-by: tom.deneau@amd.com
Diffstat (limited to 'src/share')
-rw-r--r--src/share/vm/c1/c1_LIRGenerator.cpp4
-rw-r--r--src/share/vm/c1/c1_Runtime1.cpp10
-rw-r--r--src/share/vm/ci/ciEnv.cpp8
-rw-r--r--src/share/vm/ci/ciEnv.hpp6
-rw-r--r--src/share/vm/interpreter/interpreterRuntime.cpp6
-rw-r--r--src/share/vm/opto/graphKit.cpp42
-rw-r--r--src/share/vm/opto/graphKit.hpp7
-rw-r--r--src/share/vm/opto/parse2.cpp14
-rw-r--r--src/share/vm/opto/runtime.cpp8
-rw-r--r--src/share/vm/prims/jvmtiEventController.cpp13
-rw-r--r--src/share/vm/prims/jvmtiExport.cpp3
-rw-r--r--src/share/vm/prims/jvmtiExport.hpp5
-rw-r--r--src/share/vm/prims/jvmtiManageCapabilities.cpp4
-rw-r--r--src/share/vm/prims/jvmtiThreadState.hpp5
-rw-r--r--src/share/vm/runtime/sharedRuntime.cpp2
-rw-r--r--src/share/vm/runtime/thread.cpp3
-rw-r--r--src/share/vm/runtime/thread.hpp15
17 files changed, 107 insertions, 48 deletions
diff --git a/src/share/vm/c1/c1_LIRGenerator.cpp b/src/share/vm/c1/c1_LIRGenerator.cpp
index a39302879..05e479f26 100644
--- a/src/share/vm/c1/c1_LIRGenerator.cpp
+++ b/src/share/vm/c1/c1_LIRGenerator.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2005-2010 Sun Microsystems, Inc. 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
@@ -1765,7 +1765,7 @@ void LIRGenerator::do_Throw(Throw* x) {
__ null_check(exception_opr, new CodeEmitInfo(info, true));
}
- if (compilation()->env()->jvmti_can_post_exceptions() &&
+ if (compilation()->env()->jvmti_can_post_on_exceptions() &&
!block()->is_set(BlockBegin::default_exception_handler_flag)) {
// we need to go through the exception lookup path to get JVMTI
// notification done
diff --git a/src/share/vm/c1/c1_Runtime1.cpp b/src/share/vm/c1/c1_Runtime1.cpp
index 9093885ce..6c618cb8f 100644
--- a/src/share/vm/c1/c1_Runtime1.cpp
+++ b/src/share/vm/c1/c1_Runtime1.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1999-2010 Sun Microsystems, Inc. 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
@@ -110,8 +110,8 @@ static void deopt_caller() {
RegisterMap reg_map(thread, false);
frame runtime_frame = thread->last_frame();
frame caller_frame = runtime_frame.sender(&reg_map);
- VM_DeoptimizeFrame deopt(thread, caller_frame.id());
- VMThread::execute(&deopt);
+ // bypass VM_DeoptimizeFrame and deoptimize the frame directly
+ Deoptimization::deoptimize_frame(thread, caller_frame.id());
assert(caller_is_deopted(), "Must be deoptimized");
}
}
@@ -354,7 +354,7 @@ JRT_END
JRT_ENTRY(void, Runtime1::post_jvmti_exception_throw(JavaThread* thread))
- if (JvmtiExport::can_post_exceptions()) {
+ if (JvmtiExport::can_post_on_exceptions()) {
vframeStream vfst(thread, true);
address bcp = vfst.method()->bcp_from(vfst.bci());
JvmtiExport::post_exception_throw(thread, vfst.method(), bcp, thread->exception_oop());
@@ -437,7 +437,7 @@ JRT_ENTRY_NO_ASYNC(static address, exception_handler_for_pc_helper(JavaThread* t
bool guard_pages_enabled = thread->stack_yellow_zone_enabled();
if (!guard_pages_enabled) guard_pages_enabled = thread->reguard_stack();
- if (JvmtiExport::can_post_exceptions()) {
+ if (JvmtiExport::can_post_on_exceptions()) {
// To ensure correct notification of exception catches and throws
// we have to deoptimize here. If we attempted to notify the
// catches and throws during this exception lookup it's possible
diff --git a/src/share/vm/ci/ciEnv.cpp b/src/share/vm/ci/ciEnv.cpp
index e09c66a74..964ed249b 100644
--- a/src/share/vm/ci/ciEnv.cpp
+++ b/src/share/vm/ci/ciEnv.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1999-2010 Sun Microsystems, Inc. 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
@@ -178,7 +178,7 @@ void ciEnv::cache_jvmti_state() {
_jvmti_can_hotswap_or_post_breakpoint = JvmtiExport::can_hotswap_or_post_breakpoint();
_jvmti_can_examine_or_deopt_anywhere = JvmtiExport::can_examine_or_deopt_anywhere();
_jvmti_can_access_local_variables = JvmtiExport::can_access_local_variables();
- _jvmti_can_post_exceptions = JvmtiExport::can_post_exceptions();
+ _jvmti_can_post_on_exceptions = JvmtiExport::can_post_on_exceptions();
}
// ------------------------------------------------------------------
@@ -891,8 +891,8 @@ void ciEnv::register_method(ciMethod* target,
JvmtiExport::can_examine_or_deopt_anywhere()) ||
(!jvmti_can_access_local_variables() &&
JvmtiExport::can_access_local_variables()) ||
- (!jvmti_can_post_exceptions() &&
- JvmtiExport::can_post_exceptions()) )) {
+ (!jvmti_can_post_on_exceptions() &&
+ JvmtiExport::can_post_on_exceptions()) )) {
record_failure("Jvmti state change invalidated dependencies");
}
diff --git a/src/share/vm/ci/ciEnv.hpp b/src/share/vm/ci/ciEnv.hpp
index 63b5ffe57..d20c1d1a3 100644
--- a/src/share/vm/ci/ciEnv.hpp
+++ b/src/share/vm/ci/ciEnv.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1999-2010 Sun Microsystems, Inc. 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
@@ -57,7 +57,7 @@ private:
bool _jvmti_can_hotswap_or_post_breakpoint;
bool _jvmti_can_examine_or_deopt_anywhere;
bool _jvmti_can_access_local_variables;
- bool _jvmti_can_post_exceptions;
+ bool _jvmti_can_post_on_exceptions;
// Cache DTrace flags
bool _dtrace_extended_probes;
@@ -259,7 +259,7 @@ public:
bool jvmti_can_hotswap_or_post_breakpoint() const { return _jvmti_can_hotswap_or_post_breakpoint; }
bool jvmti_can_examine_or_deopt_anywhere() const { return _jvmti_can_examine_or_deopt_anywhere; }
bool jvmti_can_access_local_variables() const { return _jvmti_can_access_local_variables; }
- bool jvmti_can_post_exceptions() const { return _jvmti_can_post_exceptions; }
+ bool jvmti_can_post_on_exceptions() const { return _jvmti_can_post_on_exceptions; }
// Cache DTrace flags
void cache_dtrace_flags();
diff --git a/src/share/vm/interpreter/interpreterRuntime.cpp b/src/share/vm/interpreter/interpreterRuntime.cpp
index bd9fc8d7c..78a6af554 100644
--- a/src/share/vm/interpreter/interpreterRuntime.cpp
+++ b/src/share/vm/interpreter/interpreterRuntime.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2010 Sun Microsystems, Inc. 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
@@ -397,7 +397,7 @@ IRT_ENTRY(address, InterpreterRuntime::exception_handler_for_exception(JavaThrea
// notify JVMTI of an exception throw; JVMTI will detect if this is a first
// time throw or a stack unwinding throw and accordingly notify the debugger
- if (JvmtiExport::can_post_exceptions()) {
+ if (JvmtiExport::can_post_on_exceptions()) {
JvmtiExport::post_exception_throw(thread, h_method(), bcp(thread), h_exception());
}
@@ -426,7 +426,7 @@ IRT_ENTRY(address, InterpreterRuntime::exception_handler_for_exception(JavaThrea
}
// notify debugger of an exception catch
// (this is good for exceptions caught in native methods as well)
- if (JvmtiExport::can_post_exceptions()) {
+ if (JvmtiExport::can_post_on_exceptions()) {
JvmtiExport::notice_unwind_due_to_exception(thread, h_method(), handler_pc, h_exception(), (handler_pc != NULL));
}
diff --git a/src/share/vm/opto/graphKit.cpp b/src/share/vm/opto/graphKit.cpp
index 57fea6480..d70fe1eef 100644
--- a/src/share/vm/opto/graphKit.cpp
+++ b/src/share/vm/opto/graphKit.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2001-2010 Sun Microsystems, Inc. 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
@@ -455,16 +455,44 @@ Bytecodes::Code GraphKit::java_bc() const {
return Bytecodes::_illegal;
}
+void GraphKit::uncommon_trap_if_should_post_on_exceptions(Deoptimization::DeoptReason reason,
+ bool must_throw) {
+ // if the exception capability is set, then we will generate code
+ // to check the JavaThread.should_post_on_exceptions flag to see
+ // if we actually need to report exception events (for this
+ // thread). If we don't need to report exception events, we will
+ // take the normal fast path provided by add_exception_events. If
+ // exception event reporting is enabled for this thread, we will
+ // take the uncommon_trap in the BuildCutout below.
+
+ // first must access the should_post_on_exceptions_flag in this thread's JavaThread
+ Node* jthread = _gvn.transform(new (C, 1) ThreadLocalNode());
+ Node* adr = basic_plus_adr(top(), jthread, in_bytes(JavaThread::should_post_on_exceptions_flag_offset()));
+ Node* should_post_flag = make_load(control(), adr, TypeInt::INT, T_INT, Compile::AliasIdxRaw, false);
+
+ // Test the should_post_on_exceptions_flag vs. 0
+ Node* chk = _gvn.transform( new (C, 3) CmpINode(should_post_flag, intcon(0)) );
+ Node* tst = _gvn.transform( new (C, 2) BoolNode(chk, BoolTest::eq) );
+
+ // Branch to slow_path if should_post_on_exceptions_flag was true
+ { BuildCutout unless(this, tst, PROB_MAX);
+ // Do not try anything fancy if we're notifying the VM on every throw.
+ // Cf. case Bytecodes::_athrow in parse2.cpp.
+ uncommon_trap(reason, Deoptimization::Action_none,
+ (ciKlass*)NULL, (char*)NULL, must_throw);
+ }
+
+}
+
//------------------------------builtin_throw----------------------------------
void GraphKit::builtin_throw(Deoptimization::DeoptReason reason, Node* arg) {
bool must_throw = true;
- if (env()->jvmti_can_post_exceptions()) {
- // Do not try anything fancy if we're notifying the VM on every throw.
- // Cf. case Bytecodes::_athrow in parse2.cpp.
- uncommon_trap(reason, Deoptimization::Action_none,
- (ciKlass*)NULL, (char*)NULL, must_throw);
- return;
+ if (env()->jvmti_can_post_on_exceptions()) {
+ // check if we must post exception events, take uncommon trap if so
+ uncommon_trap_if_should_post_on_exceptions(reason, must_throw);
+ // here if should_post_on_exceptions is false
+ // continue on with the normal codegen
}
// If this particular condition has not yet happened at this
diff --git a/src/share/vm/opto/graphKit.hpp b/src/share/vm/opto/graphKit.hpp
index 8135aca2d..b08c5859d 100644
--- a/src/share/vm/opto/graphKit.hpp
+++ b/src/share/vm/opto/graphKit.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2001-2010 Sun Microsystems, Inc. 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
@@ -251,6 +251,11 @@ class GraphKit : public Phase {
// via an uncommon trap.
void builtin_throw(Deoptimization::DeoptReason reason, Node* arg = NULL);
+ // Helper to check the JavaThread::_should_post_on_exceptions flag
+ // and branch to an uncommon_trap if it is true (with the specified reason and must_throw)
+ void uncommon_trap_if_should_post_on_exceptions(Deoptimization::DeoptReason reason,
+ bool must_throw) ;
+
// Helper Functions for adding debug information
void kill_dead_locals();
#ifdef ASSERT
diff --git a/src/share/vm/opto/parse2.cpp b/src/share/vm/opto/parse2.cpp
index 869266c17..e0012681a 100644
--- a/src/share/vm/opto/parse2.cpp
+++ b/src/share/vm/opto/parse2.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1998-2010 Sun Microsystems, Inc. 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
@@ -2079,13 +2079,6 @@ void Parse::do_one_bytecode() {
// null exception oop throws NULL pointer exception
do_null_check(peek(), T_OBJECT);
if (stopped()) return;
- if (env()->jvmti_can_post_exceptions()) {
- // "Full-speed throwing" is not necessary here,
- // since we're notifying the VM on every throw.
- uncommon_trap(Deoptimization::Reason_unhandled,
- Deoptimization::Action_none);
- return;
- }
// Hook the thrown exception directly to subsequent handlers.
if (BailoutToInterpreterForThrows) {
// Keep method interpreted from now on.
@@ -2093,6 +2086,11 @@ void Parse::do_one_bytecode() {
Deoptimization::Action_make_not_compilable);
return;
}
+ if (env()->jvmti_can_post_on_exceptions()) {
+ // check if we must post exception events, take uncommon trap if so (with must_throw = false)
+ uncommon_trap_if_should_post_on_exceptions(Deoptimization::Reason_unhandled, false);
+ }
+ // Here if either can_post_on_exceptions or should_post_on_exceptions is false
add_exception_state(make_exception_state(peek()));
break;
diff --git a/src/share/vm/opto/runtime.cpp b/src/share/vm/opto/runtime.cpp
index f0d0c2170..2f39cfeb0 100644
--- a/src/share/vm/opto/runtime.cpp
+++ b/src/share/vm/opto/runtime.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1998-2010 Sun Microsystems, Inc. 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
@@ -810,7 +810,7 @@ JRT_ENTRY_NO_ASYNC(address, OptoRuntime::handle_exception_C_helper(JavaThread* t
// we are switching to old paradigm: search for exception handler in caller_frame
// instead in exception handler of caller_frame.sender()
- if (JvmtiExport::can_post_exceptions()) {
+ if (JvmtiExport::can_post_on_exceptions()) {
// "Full-speed catching" is not necessary here,
// since we're notifying the VM on every catch.
// Force deoptimization and the rest of the lookup
@@ -975,8 +975,8 @@ void OptoRuntime::deoptimize_caller_frame(JavaThread *thread, bool doit) {
assert(stub_frame.is_runtime_frame() || exception_blob()->contains(stub_frame.pc()), "sanity check");
frame caller_frame = stub_frame.sender(&reg_map);
- VM_DeoptimizeFrame deopt(thread, caller_frame.id());
- VMThread::execute(&deopt);
+ // bypass VM_DeoptimizeFrame and deoptimize the frame directly
+ Deoptimization::deoptimize_frame(thread, caller_frame.id());
}
}
diff --git a/src/share/vm/prims/jvmtiEventController.cpp b/src/share/vm/prims/jvmtiEventController.cpp
index 4e07d6f84..4eb2d5870 100644
--- a/src/share/vm/prims/jvmtiEventController.cpp
+++ b/src/share/vm/prims/jvmtiEventController.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2010 Sun Microsystems, Inc. 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
@@ -82,7 +82,7 @@ static const jlong EARLY_EVENT_BITS = CLASS_FILE_LOAD_HOOK_BIT |
THREAD_START_BIT | THREAD_END_BIT |
DYNAMIC_CODE_GENERATED_BIT;
static const jlong GLOBAL_EVENT_BITS = ~THREAD_FILTERED_EVENT_BITS;
-
+static const jlong SHOULD_POST_ON_EXCEPTIONS_BITS = EXCEPTION_BITS | METHOD_EXIT_BIT | FRAME_POP_BIT;
///////////////////////////////////////////////////////////////
//
@@ -511,7 +511,12 @@ JvmtiEventControllerPrivate::recompute_thread_enabled(JvmtiThreadState *state) {
leave_interp_only_mode(state);
}
}
+
+ // update the JavaThread cached value for thread-specific should_post_on_exceptions value
+ bool should_post_on_exceptions = (any_env_enabled & SHOULD_POST_ON_EXCEPTIONS_BITS) != 0;
+ state->set_should_post_on_exceptions(should_post_on_exceptions);
}
+
return any_env_enabled;
}
@@ -615,6 +620,10 @@ JvmtiEventControllerPrivate::recompute_enabled() {
// set global truly enabled, that is, any thread in any environment
JvmtiEventController::_universal_global_event_enabled.set_bits(any_env_thread_enabled);
+
+ // set global should_post_on_exceptions
+ JvmtiExport::set_should_post_on_exceptions((any_env_thread_enabled & SHOULD_POST_ON_EXCEPTIONS_BITS) != 0);
+
}
EC_TRACE(("JVMTI [-] # recompute enabled - after %llx", any_env_thread_enabled));
diff --git a/src/share/vm/prims/jvmtiExport.cpp b/src/share/vm/prims/jvmtiExport.cpp
index 7b2fffdbd..7d189e5be 100644
--- a/src/share/vm/prims/jvmtiExport.cpp
+++ b/src/share/vm/prims/jvmtiExport.cpp
@@ -877,7 +877,7 @@ void JvmtiExport::post_raw_breakpoint(JavaThread *thread, methodOop method, addr
bool JvmtiExport::_can_get_source_debug_extension = false;
bool JvmtiExport::_can_maintain_original_method_order = false;
bool JvmtiExport::_can_post_interpreter_events = false;
-bool JvmtiExport::_can_post_exceptions = false;
+bool JvmtiExport::_can_post_on_exceptions = false;
bool JvmtiExport::_can_post_breakpoint = false;
bool JvmtiExport::_can_post_field_access = false;
bool JvmtiExport::_can_post_field_modification = false;
@@ -908,6 +908,7 @@ bool JvmtiExport::_should_post_garbage_collection_finish = fals
bool JvmtiExport::_should_post_object_free = false;
bool JvmtiExport::_should_post_resource_exhausted = false;
bool JvmtiExport::_should_post_vm_object_alloc = false;
+bool JvmtiExport::_should_post_on_exceptions = false;
////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/share/vm/prims/jvmtiExport.hpp b/src/share/vm/prims/jvmtiExport.hpp
index 20214aecf..a7e264ba7 100644
--- a/src/share/vm/prims/jvmtiExport.hpp
+++ b/src/share/vm/prims/jvmtiExport.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1998-2010 Sun Microsystems, Inc. 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
@@ -66,7 +66,7 @@ class JvmtiExport : public AllStatic {
JVMTI_SUPPORT_FLAG(can_get_source_debug_extension)
JVMTI_SUPPORT_FLAG(can_maintain_original_method_order)
JVMTI_SUPPORT_FLAG(can_post_interpreter_events)
- JVMTI_SUPPORT_FLAG(can_post_exceptions)
+ JVMTI_SUPPORT_FLAG(can_post_on_exceptions)
JVMTI_SUPPORT_FLAG(can_post_breakpoint)
JVMTI_SUPPORT_FLAG(can_post_field_access)
JVMTI_SUPPORT_FLAG(can_post_field_modification)
@@ -93,6 +93,7 @@ class JvmtiExport : public AllStatic {
JVMTI_SUPPORT_FLAG(should_post_data_dump)
JVMTI_SUPPORT_FLAG(should_post_garbage_collection_start)
JVMTI_SUPPORT_FLAG(should_post_garbage_collection_finish)
+ JVMTI_SUPPORT_FLAG(should_post_on_exceptions)
// ------ the below maybe don't have to be (but are for now)
// fixed conditions here ------------
diff --git a/src/share/vm/prims/jvmtiManageCapabilities.cpp b/src/share/vm/prims/jvmtiManageCapabilities.cpp
index 82ddb4adf..195607346 100644
--- a/src/share/vm/prims/jvmtiManageCapabilities.cpp
+++ b/src/share/vm/prims/jvmtiManageCapabilities.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2010 Sun Microsystems, Inc. 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
@@ -357,7 +357,7 @@ void JvmtiManageCapabilities::update() {
avail.can_access_local_variables ||
avail.can_redefine_classes ||
avail.can_retransform_classes);
- JvmtiExport::set_can_post_exceptions(
+ JvmtiExport::set_can_post_on_exceptions(
avail.can_generate_exception_events ||
avail.can_generate_frame_pop_events ||
avail.can_generate_method_exit_events);
diff --git a/src/share/vm/prims/jvmtiThreadState.hpp b/src/share/vm/prims/jvmtiThreadState.hpp
index d77d2a8a4..8103aa22a 100644
--- a/src/share/vm/prims/jvmtiThreadState.hpp
+++ b/src/share/vm/prims/jvmtiThreadState.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2010 Sun Microsystems, Inc. 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
@@ -381,6 +381,9 @@ class JvmtiThreadState : public CHeapObj {
static ByteSize earlyret_value_offset() { return byte_offset_of(JvmtiThreadState, _earlyret_value); }
void oops_do(OopClosure* f); // GC support
+
+public:
+ void set_should_post_on_exceptions(bool val) { _thread->set_should_post_on_exceptions_flag(val ? JNI_TRUE : JNI_FALSE); }
};
class RedefineVerifyMark : public StackObj {
diff --git a/src/share/vm/runtime/sharedRuntime.cpp b/src/share/vm/runtime/sharedRuntime.cpp
index bf100e714..a8b34a24b 100644
--- a/src/share/vm/runtime/sharedRuntime.cpp
+++ b/src/share/vm/runtime/sharedRuntime.cpp
@@ -364,7 +364,7 @@ oop SharedRuntime::retrieve_receiver( symbolHandle sig, frame caller ) {
void SharedRuntime::throw_and_post_jvmti_exception(JavaThread *thread, Handle h_exception) {
- if (JvmtiExport::can_post_exceptions()) {
+ if (JvmtiExport::can_post_on_exceptions()) {
vframeStream vfst(thread, true);
methodHandle method = methodHandle(thread, vfst.method());
address bcp = method()->bcp_from(vfst.bci());
diff --git a/src/share/vm/runtime/thread.cpp b/src/share/vm/runtime/thread.cpp
index db90e0ef5..3bdf8dad0 100644
--- a/src/share/vm/runtime/thread.cpp
+++ b/src/share/vm/runtime/thread.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2010 Sun Microsystems, Inc. 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
@@ -1173,6 +1173,7 @@ void JavaThread::initialize() {
_exception_handler_pc = 0;
_exception_stack_size = 0;
_jvmti_thread_state= NULL;
+ _should_post_on_exceptions_flag = JNI_FALSE;
_jvmti_get_loaded_classes_closure = NULL;
_interp_only_mode = 0;
_special_runtime_exit_condition = _no_async_condition;
diff --git a/src/share/vm/runtime/thread.hpp b/src/share/vm/runtime/thread.hpp
index a06477bd2..49112fe23 100644
--- a/src/share/vm/runtime/thread.hpp
+++ b/src/share/vm/runtime/thread.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2010 Sun Microsystems, Inc. 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
@@ -1193,6 +1193,9 @@ class JavaThread: public Thread {
static ByteSize suspend_flags_offset() { return byte_offset_of(JavaThread, _suspend_flags ); }
static ByteSize do_not_unlock_if_synchronized_offset() { return byte_offset_of(JavaThread, _do_not_unlock_if_synchronized); }
+ static ByteSize should_post_on_exceptions_flag_offset() {
+ return byte_offset_of(JavaThread, _should_post_on_exceptions_flag);
+ }
#ifndef SERIALGC
static ByteSize satb_mark_queue_offset() { return byte_offset_of(JavaThread, _satb_mark_queue); }
@@ -1432,6 +1435,16 @@ public:
void increment_interp_only_mode() { ++_interp_only_mode; }
void decrement_interp_only_mode() { --_interp_only_mode; }
+ // support for cached flag that indicates whether exceptions need to be posted for this thread
+ // if this is false, we can avoid deoptimizing when events are thrown
+ // this gets set to reflect whether jvmtiExport::post_exception_throw would actually do anything
+ private:
+ int _should_post_on_exceptions_flag;
+
+ public:
+ int should_post_on_exceptions_flag() { return _should_post_on_exceptions_flag; }
+ void set_should_post_on_exceptions_flag(int val) { _should_post_on_exceptions_flag = val; }
+
private:
ThreadStatistics *_thread_stat;