summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Mythri Alle <mythria@google.com> 2024-05-23 07:38:46 +0000
committer Mythri Alle <mythria@google.com> 2024-05-23 10:21:01 +0000
commitd11c004a5df78a67e6e9021492a8e096de336db3 (patch)
treea0459ea58fc12779b5ff4c362e138e7595394921
parent068bee12ad89e9ed46da04ec8791cd00d917b6f5 (diff)
Reland "Report method unwind events for native methods"
This reverts commit db0551d164783866acf0cdcf9a7741ee6f21f0f2. Reason for revert: Updated test to a use method declared in the Test class instead of the hidden java.lang.classForName. Change-Id: Ifa725b5465163fa73e4808d87a2b205b92aa110f
-rw-r--r--runtime/quick_exception_handler.cc33
-rw-r--r--test/989-method-trace-throw/expected-stdout.txt222
-rw-r--r--test/989-method-trace-throw/method_trace.cc6
-rw-r--r--test/989-method-trace-throw/src/art/Test989.java89
-rw-r--r--test/jvmti-common/Trace.java5
-rw-r--r--test/ti-agent/trace_helper.cc9
6 files changed, 328 insertions, 36 deletions
diff --git a/runtime/quick_exception_handler.cc b/runtime/quick_exception_handler.cc
index 2ebcbb0fd0..37734f7d74 100644
--- a/runtime/quick_exception_handler.cc
+++ b/runtime/quick_exception_handler.cc
@@ -439,19 +439,41 @@ class DeoptimizeStackVisitor final : public StackVisitor {
ArtMethod* method = GetMethod();
VLOG(deopt) << "Deoptimizing stack: depth: " << GetFrameDepth()
<< " at method " << ArtMethod::PrettyMethod(method);
+
if (method == nullptr || single_frame_done_) {
FinishStackWalk();
return false; // End stack walk.
- } else if (method->IsRuntimeMethod()) {
+ }
+
+ // Update if method exit event needs to be reported. We should report exit event only if we
+ // have reported an entry event. So tell interpreter if/ an entry event was reported.
+ bool supports_exit_events = Runtime::Current()->GetInstrumentation()->MethodSupportsExitEvents(
+ method, GetCurrentOatQuickMethodHeader());
+
+ if (method->IsRuntimeMethod()) {
// Ignore callee save method.
DCHECK(method->IsCalleeSaveMethod());
return true;
} else if (method->IsNative()) {
// If we return from JNI with a pending exception and want to deoptimize, we need to skip
// the native method. The top method is a runtime method, the native method comes next.
- // We also deoptimize due to method instrumentation reasons from method entry / exit
- // callbacks. In these cases native method is at the top of stack.
+ // We also deoptimize due to method instrumentation reasons from method exit callbacks.
+ // In these cases native method is at the top of stack.
CHECK((GetFrameDepth() == 1U) || (GetFrameDepth() == 0U));
+ // We see a native frame when:
+ // 1. returning from JNI with a pending exception
+ // 2. deopting from method exit callbacks (with or without a pending exception).
+ // skip_method_exit_callbacks_ is set in this case
+ // 3. handling async exception on suspend points for fast native methods.
+ // We only need to call method unwind event in the first case.
+ if (supports_exit_events &&
+ !skip_method_exit_callbacks_ &&
+ GetThread()->IsExceptionPending()) {
+ // An exception has occurred in a native method and we are deoptimizing past the native
+ // method. So report method unwind event here.
+ Runtime::Current()->GetInstrumentation()->MethodUnwindEvent(
+ GetThread(), method, dex::kDexNoIndex);
+ }
callee_method_ = method;
return true;
} else if (!single_frame_deopt_ &&
@@ -482,11 +504,6 @@ class DeoptimizeStackVisitor final : public StackVisitor {
} else {
HandleOptimizingDeoptimization(method, new_frame, updated_vregs);
}
- // Update if method exit event needs to be reported. We should report exit event only if we
- // have reported an entry event. So tell interpreter if/ an entry event was reported.
- bool supports_exit_events =
- Runtime::Current()->GetInstrumentation()->MethodSupportsExitEvents(
- method, GetCurrentOatQuickMethodHeader());
new_frame->SetSkipMethodExitEvents(!supports_exit_events);
// If we are deoptimizing after method exit callback we shouldn't call the method exit
// callbacks again for the top frame. We may have to deopt after the callback if the callback
diff --git a/test/989-method-trace-throw/expected-stdout.txt b/test/989-method-trace-throw/expected-stdout.txt
index 0911bc35e8..6bd7357699 100644
--- a/test/989-method-trace-throw/expected-stdout.txt
+++ b/test/989-method-trace-throw/expected-stdout.txt
@@ -10,6 +10,11 @@ Received expected error for test[class art.Test989$NormalTracer, class art.Test9
Normal: Entering public static native void art.Test989.throwANative()
Normal: Leaving public static native void art.Test989.throwANative() returned <exception>
Received expected error for test[class art.Test989$NormalTracer, class art.Test989$throwANativeClass] - art.Test989$ErrorA: Throwing Error A
+Normal: Entering public static void art.Test989.throwNativeException()
+Normal: Entering public static native void art.Test989.doThrowNative()
+Normal: Leaving public static native void art.Test989.doThrowNative() returned <exception>
+Normal: Leaving public static void art.Test989.throwNativeException() returned <exception>
+Received expected error for test[class art.Test989$NormalTracer, class art.Test989$throwNativeExceptionClass] - java.lang.Error: Error
Normal: Entering public static java.lang.Object art.Test989.returnValue()
Normal: Leaving public static java.lang.Object art.Test989.returnValue() returned TestObject(0)
returnValue returned: TestObject(0)
@@ -57,6 +62,9 @@ Received expected error for test[class art.Test989$ThrowEnterTracer, class art.T
ThrowEnter: Entering public static native void art.Test989.throwANative()
ThrowEnter: Leaving public static native void art.Test989.throwANative() returned <exception>
Received expected error for test[class art.Test989$ThrowEnterTracer, class art.Test989$throwANativeClass] - art.Test989$ErrorB: Throwing error while entering public static native void art.Test989.throwANative()
+ThrowEnter: Entering public static void art.Test989.throwNativeException()
+ThrowEnter: Leaving public static void art.Test989.throwNativeException() returned <exception>
+Received expected error for test[class art.Test989$ThrowEnterTracer, class art.Test989$throwNativeExceptionClass] - art.Test989$ErrorB: Throwing error while entering public static void art.Test989.throwNativeException()
ThrowEnter: Entering public static java.lang.Object art.Test989.returnValue()
ThrowEnter: Leaving public static java.lang.Object art.Test989.returnValue() returned <exception>
Received expected error for test[class art.Test989$ThrowEnterTracer, class art.Test989$returnValueClass] - art.Test989$ErrorB: Throwing error while entering public static java.lang.Object art.Test989.returnValue()
@@ -96,6 +104,11 @@ Received expected error for test[class art.Test989$ThrowExitTracer, class art.Te
ThrowExit: Entering public static native void art.Test989.throwANative()
ThrowExit: Leaving public static native void art.Test989.throwANative() returned <exception>
Received expected error for test[class art.Test989$ThrowExitTracer, class art.Test989$throwANativeClass] - art.Test989$ErrorB: Throwing error while exit public static native void art.Test989.throwANative() returned <exception>
+ThrowExit: Entering public static void art.Test989.throwNativeException()
+ThrowExit: Entering public static native void art.Test989.doThrowNative()
+ThrowExit: Leaving public static native void art.Test989.doThrowNative() returned <exception>
+ThrowExit: Leaving public static void art.Test989.throwNativeException() returned <exception>
+Received expected error for test[class art.Test989$ThrowExitTracer, class art.Test989$throwNativeExceptionClass] - art.Test989$ErrorB: Throwing error while exit public static void art.Test989.throwNativeException() returned <exception>
ThrowExit: Entering public static java.lang.Object art.Test989.returnValue()
ThrowExit: Leaving public static java.lang.Object art.Test989.returnValue() returned TestObject(7)
Received expected error for test[class art.Test989$ThrowExitTracer, class art.Test989$returnValueClass] - art.Test989$ErrorB: Throwing error while exit public static java.lang.Object art.Test989.returnValue() returned TestObject(7)
@@ -137,6 +150,9 @@ Received expected error for test[class art.Test989$ThrowBothTracer, class art.Te
ThrowBoth: Entering public static native void art.Test989.throwANative()
ThrowBoth: Leaving public static native void art.Test989.throwANative() returned <exception>
Received expected error for test[class art.Test989$ThrowBothTracer, class art.Test989$throwANativeClass] - art.Test989$ErrorC: Throwing error while exit public static native void art.Test989.throwANative() returned <exception>
+ThrowBoth: Entering public static void art.Test989.throwNativeException()
+ThrowBoth: Leaving public static void art.Test989.throwNativeException() returned <exception>
+Received expected error for test[class art.Test989$ThrowBothTracer, class art.Test989$throwNativeExceptionClass] - art.Test989$ErrorC: Throwing error while exit public static void art.Test989.throwNativeException() returned <exception>
ThrowBoth: Entering public static java.lang.Object art.Test989.returnValue()
ThrowBoth: Leaving public static java.lang.Object art.Test989.returnValue() returned <exception>
Received expected error for test[class art.Test989$ThrowBothTracer, class art.Test989$returnValueClass] - art.Test989$ErrorC: Throwing error while exit public static java.lang.Object art.Test989.returnValue() returned <exception>
@@ -168,6 +184,7 @@ Received no exception as expected for test[class art.Test989$ForceGCTracer, clas
Received no exception as expected for test[class art.Test989$ForceGCTracer, class art.Test989$doNothingNativeClass].
Received expected error for test[class art.Test989$ForceGCTracer, class art.Test989$throwAClass] - art.Test989$ErrorA: Throwing Error A
Received expected error for test[class art.Test989$ForceGCTracer, class art.Test989$throwANativeClass] - art.Test989$ErrorA: Throwing Error A
+Received expected error for test[class art.Test989$ForceGCTracer, class art.Test989$throwNativeExceptionClass] - java.lang.Error: Error
returnValue returned: TestObject(14)
Received no exception as expected for test[class art.Test989$ForceGCTracer, class art.Test989$returnValueClass].
returnValueNative returned: TestObject(15)
@@ -185,4 +202,209 @@ returnDouble returned: 3.14159628
Received no exception as expected for test[class art.Test989$ForceGCTracer, class art.Test989$returnDoubleClass].
returnDoubleNative returned: 3.14159628
Received no exception as expected for test[class art.Test989$ForceGCTracer, class art.Test989$returnDoubleNativeClass].
+Finished - without non-standard exits!
+Normal: Entering public static void art.Test989.doNothing()
+Normal: Leaving public static void art.Test989.doNothing() returned null
+Received no exception as expected for test[class art.Test989$NormalTracer, class art.Test989$doNothingClass].
+Normal: Entering public static native void art.Test989.doNothingNative()
+Normal: Leaving public static native void art.Test989.doNothingNative() returned null
+Received no exception as expected for test[class art.Test989$NormalTracer, class art.Test989$doNothingNativeClass].
+Normal: Entering public static void art.Test989.throwA()
+Normal: Leaving public static void art.Test989.throwA() returned <exception>
+Received expected error for test[class art.Test989$NormalTracer, class art.Test989$throwAClass] - art.Test989$ErrorA: Throwing Error A
+Normal: Entering public static native void art.Test989.throwANative()
+Normal: Leaving public static native void art.Test989.throwANative() returned <exception>
+Received expected error for test[class art.Test989$NormalTracer, class art.Test989$throwANativeClass] - art.Test989$ErrorA: Throwing Error A
+Normal: Entering public static void art.Test989.throwNativeException()
+Normal: Entering public static native void art.Test989.doThrowNative()
+Normal: Leaving public static native void art.Test989.doThrowNative() returned <exception>
+Normal: Leaving public static void art.Test989.throwNativeException() returned <exception>
+Received expected error for test[class art.Test989$NormalTracer, class art.Test989$throwNativeExceptionClass] - java.lang.Error: Error
+Normal: Entering public static java.lang.Object art.Test989.returnValue()
+Normal: Leaving public static java.lang.Object art.Test989.returnValue() returned TestObject(19)
+returnValue returned: TestObject(19)
+Received no exception as expected for test[class art.Test989$NormalTracer, class art.Test989$returnValueClass].
+Normal: Entering public static native java.lang.Object art.Test989.returnValueNative()
+Normal: Leaving public static native java.lang.Object art.Test989.returnValueNative() returned TestObject(20)
+returnValueNative returned: TestObject(20)
+Received no exception as expected for test[class art.Test989$NormalTracer, class art.Test989$returnValueNativeClass].
+Normal: Entering public static void art.Test989.acceptValue(java.lang.Object)
+Recieved TestObject(21)
+Normal: Leaving public static void art.Test989.acceptValue(java.lang.Object) returned null
+Received no exception as expected for test[class art.Test989$NormalTracer, class art.Test989$acceptValueClass].
+Normal: Entering public static native void art.Test989.acceptValueNative(java.lang.Object)
+Recieved TestObject(22)
+Normal: Leaving public static native void art.Test989.acceptValueNative(java.lang.Object) returned null
+Received no exception as expected for test[class art.Test989$NormalTracer, class art.Test989$acceptValueNativeClass].
+Normal: Entering public static void art.Test989.tryCatchExit()
+Normal: Leaving public static void art.Test989.tryCatchExit() returned null
+Received no exception as expected for test[class art.Test989$NormalTracer, class art.Test989$tryCatchExitClass].
+Normal: Entering public static float art.Test989.returnFloat()
+Normal: Leaving public static float art.Test989.returnFloat() returned 1.618
+returnFloat returned: 1.618
+Received no exception as expected for test[class art.Test989$NormalTracer, class art.Test989$returnFloatClass].
+Normal: Entering public static native float art.Test989.returnFloatNative()
+Normal: Leaving public static native float art.Test989.returnFloatNative() returned 1.618
+returnFloatNative returned: 1.618
+Received no exception as expected for test[class art.Test989$NormalTracer, class art.Test989$returnFloatNativeClass].
+Normal: Entering public static double art.Test989.returnDouble()
+Normal: Leaving public static double art.Test989.returnDouble() returned 3.14159628
+returnDouble returned: 3.14159628
+Received no exception as expected for test[class art.Test989$NormalTracer, class art.Test989$returnDoubleClass].
+Normal: Entering public static native double art.Test989.returnDoubleNative()
+Normal: Leaving public static native double art.Test989.returnDoubleNative() returned 3.14159628
+returnDoubleNative returned: 3.14159628
+Received no exception as expected for test[class art.Test989$NormalTracer, class art.Test989$returnDoubleNativeClass].
+ThrowEnter: Entering public static void art.Test989.doNothing()
+ThrowEnter: Leaving public static void art.Test989.doNothing() returned <exception>
+Received expected error for test[class art.Test989$ThrowEnterTracer, class art.Test989$doNothingClass] - art.Test989$ErrorB: Throwing error while entering public static void art.Test989.doNothing()
+ThrowEnter: Entering public static native void art.Test989.doNothingNative()
+ThrowEnter: Leaving public static native void art.Test989.doNothingNative() returned <exception>
+Received expected error for test[class art.Test989$ThrowEnterTracer, class art.Test989$doNothingNativeClass] - art.Test989$ErrorB: Throwing error while entering public static native void art.Test989.doNothingNative()
+ThrowEnter: Entering public static void art.Test989.throwA()
+ThrowEnter: Leaving public static void art.Test989.throwA() returned <exception>
+Received expected error for test[class art.Test989$ThrowEnterTracer, class art.Test989$throwAClass] - art.Test989$ErrorB: Throwing error while entering public static void art.Test989.throwA()
+ThrowEnter: Entering public static native void art.Test989.throwANative()
+ThrowEnter: Leaving public static native void art.Test989.throwANative() returned <exception>
+Received expected error for test[class art.Test989$ThrowEnterTracer, class art.Test989$throwANativeClass] - art.Test989$ErrorB: Throwing error while entering public static native void art.Test989.throwANative()
+ThrowEnter: Entering public static void art.Test989.throwNativeException()
+ThrowEnter: Leaving public static void art.Test989.throwNativeException() returned <exception>
+Received expected error for test[class art.Test989$ThrowEnterTracer, class art.Test989$throwNativeExceptionClass] - art.Test989$ErrorB: Throwing error while entering public static void art.Test989.throwNativeException()
+ThrowEnter: Entering public static java.lang.Object art.Test989.returnValue()
+ThrowEnter: Leaving public static java.lang.Object art.Test989.returnValue() returned <exception>
+Received expected error for test[class art.Test989$ThrowEnterTracer, class art.Test989$returnValueClass] - art.Test989$ErrorB: Throwing error while entering public static java.lang.Object art.Test989.returnValue()
+ThrowEnter: Entering public static native java.lang.Object art.Test989.returnValueNative()
+ThrowEnter: Leaving public static native java.lang.Object art.Test989.returnValueNative() returned <exception>
+Received expected error for test[class art.Test989$ThrowEnterTracer, class art.Test989$returnValueNativeClass] - art.Test989$ErrorB: Throwing error while entering public static native java.lang.Object art.Test989.returnValueNative()
+ThrowEnter: Entering public static void art.Test989.acceptValue(java.lang.Object)
+ThrowEnter: Leaving public static void art.Test989.acceptValue(java.lang.Object) returned <exception>
+Received expected error for test[class art.Test989$ThrowEnterTracer, class art.Test989$acceptValueClass] - art.Test989$ErrorB: Throwing error while entering public static void art.Test989.acceptValue(java.lang.Object)
+ThrowEnter: Entering public static native void art.Test989.acceptValueNative(java.lang.Object)
+ThrowEnter: Leaving public static native void art.Test989.acceptValueNative(java.lang.Object) returned <exception>
+Received expected error for test[class art.Test989$ThrowEnterTracer, class art.Test989$acceptValueNativeClass] - art.Test989$ErrorB: Throwing error while entering public static native void art.Test989.acceptValueNative(java.lang.Object)
+ThrowEnter: Entering public static void art.Test989.tryCatchExit()
+ThrowEnter: Leaving public static void art.Test989.tryCatchExit() returned <exception>
+Received expected error for test[class art.Test989$ThrowEnterTracer, class art.Test989$tryCatchExitClass] - art.Test989$ErrorB: Throwing error while entering public static void art.Test989.tryCatchExit()
+ThrowEnter: Entering public static float art.Test989.returnFloat()
+ThrowEnter: Leaving public static float art.Test989.returnFloat() returned <exception>
+Received expected error for test[class art.Test989$ThrowEnterTracer, class art.Test989$returnFloatClass] - art.Test989$ErrorB: Throwing error while entering public static float art.Test989.returnFloat()
+ThrowEnter: Entering public static native float art.Test989.returnFloatNative()
+ThrowEnter: Leaving public static native float art.Test989.returnFloatNative() returned <exception>
+Received expected error for test[class art.Test989$ThrowEnterTracer, class art.Test989$returnFloatNativeClass] - art.Test989$ErrorB: Throwing error while entering public static native float art.Test989.returnFloatNative()
+ThrowEnter: Entering public static double art.Test989.returnDouble()
+ThrowEnter: Leaving public static double art.Test989.returnDouble() returned <exception>
+Received expected error for test[class art.Test989$ThrowEnterTracer, class art.Test989$returnDoubleClass] - art.Test989$ErrorB: Throwing error while entering public static double art.Test989.returnDouble()
+ThrowEnter: Entering public static native double art.Test989.returnDoubleNative()
+ThrowEnter: Leaving public static native double art.Test989.returnDoubleNative() returned <exception>
+Received expected error for test[class art.Test989$ThrowEnterTracer, class art.Test989$returnDoubleNativeClass] - art.Test989$ErrorB: Throwing error while entering public static native double art.Test989.returnDoubleNative()
+ThrowExit: Entering public static void art.Test989.doNothing()
+ThrowExit: Leaving public static void art.Test989.doNothing() returned null
+Received expected error for test[class art.Test989$ThrowExitTracer, class art.Test989$doNothingClass] - art.Test989$ErrorB: Throwing error while exit public static void art.Test989.doNothing() returned null
+ThrowExit: Entering public static native void art.Test989.doNothingNative()
+ThrowExit: Leaving public static native void art.Test989.doNothingNative() returned null
+Received expected error for test[class art.Test989$ThrowExitTracer, class art.Test989$doNothingNativeClass] - art.Test989$ErrorB: Throwing error while exit public static native void art.Test989.doNothingNative() returned null
+ThrowExit: Entering public static void art.Test989.throwA()
+ThrowExit: Leaving public static void art.Test989.throwA() returned <exception>
+Received expected error for test[class art.Test989$ThrowExitTracer, class art.Test989$throwAClass] - art.Test989$ErrorB: Throwing error while exit public static void art.Test989.throwA() returned <exception>
+ThrowExit: Entering public static native void art.Test989.throwANative()
+ThrowExit: Leaving public static native void art.Test989.throwANative() returned <exception>
+Received expected error for test[class art.Test989$ThrowExitTracer, class art.Test989$throwANativeClass] - art.Test989$ErrorB: Throwing error while exit public static native void art.Test989.throwANative() returned <exception>
+ThrowExit: Entering public static void art.Test989.throwNativeException()
+ThrowExit: Entering public static native void art.Test989.doThrowNative()
+ThrowExit: Leaving public static native void art.Test989.doThrowNative() returned <exception>
+ThrowExit: Leaving public static void art.Test989.throwNativeException() returned <exception>
+Received expected error for test[class art.Test989$ThrowExitTracer, class art.Test989$throwNativeExceptionClass] - art.Test989$ErrorB: Throwing error while exit public static void art.Test989.throwNativeException() returned <exception>
+ThrowExit: Entering public static java.lang.Object art.Test989.returnValue()
+ThrowExit: Leaving public static java.lang.Object art.Test989.returnValue() returned TestObject(26)
+Received expected error for test[class art.Test989$ThrowExitTracer, class art.Test989$returnValueClass] - art.Test989$ErrorB: Throwing error while exit public static java.lang.Object art.Test989.returnValue() returned TestObject(26)
+ThrowExit: Entering public static native java.lang.Object art.Test989.returnValueNative()
+ThrowExit: Leaving public static native java.lang.Object art.Test989.returnValueNative() returned TestObject(27)
+Received expected error for test[class art.Test989$ThrowExitTracer, class art.Test989$returnValueNativeClass] - art.Test989$ErrorB: Throwing error while exit public static native java.lang.Object art.Test989.returnValueNative() returned TestObject(27)
+ThrowExit: Entering public static void art.Test989.acceptValue(java.lang.Object)
+Recieved TestObject(28)
+ThrowExit: Leaving public static void art.Test989.acceptValue(java.lang.Object) returned null
+Received expected error for test[class art.Test989$ThrowExitTracer, class art.Test989$acceptValueClass] - art.Test989$ErrorB: Throwing error while exit public static void art.Test989.acceptValue(java.lang.Object) returned null
+ThrowExit: Entering public static native void art.Test989.acceptValueNative(java.lang.Object)
+Recieved TestObject(29)
+ThrowExit: Leaving public static native void art.Test989.acceptValueNative(java.lang.Object) returned null
+Received expected error for test[class art.Test989$ThrowExitTracer, class art.Test989$acceptValueNativeClass] - art.Test989$ErrorB: Throwing error while exit public static native void art.Test989.acceptValueNative(java.lang.Object) returned null
+ThrowExit: Entering public static void art.Test989.tryCatchExit()
+ThrowExit: Leaving public static void art.Test989.tryCatchExit() returned null
+Received expected error for test[class art.Test989$ThrowExitTracer, class art.Test989$tryCatchExitClass] - art.Test989$ErrorB: Throwing error while exit public static void art.Test989.tryCatchExit() returned null
+ThrowExit: Entering public static float art.Test989.returnFloat()
+ThrowExit: Leaving public static float art.Test989.returnFloat() returned 1.618
+Received expected error for test[class art.Test989$ThrowExitTracer, class art.Test989$returnFloatClass] - art.Test989$ErrorB: Throwing error while exit public static float art.Test989.returnFloat() returned 1.618
+ThrowExit: Entering public static native float art.Test989.returnFloatNative()
+ThrowExit: Leaving public static native float art.Test989.returnFloatNative() returned 1.618
+Received expected error for test[class art.Test989$ThrowExitTracer, class art.Test989$returnFloatNativeClass] - art.Test989$ErrorB: Throwing error while exit public static native float art.Test989.returnFloatNative() returned 1.618
+ThrowExit: Entering public static double art.Test989.returnDouble()
+ThrowExit: Leaving public static double art.Test989.returnDouble() returned 3.14159628
+Received expected error for test[class art.Test989$ThrowExitTracer, class art.Test989$returnDoubleClass] - art.Test989$ErrorB: Throwing error while exit public static double art.Test989.returnDouble() returned 3.14159628
+ThrowExit: Entering public static native double art.Test989.returnDoubleNative()
+ThrowExit: Leaving public static native double art.Test989.returnDoubleNative() returned 3.14159628
+Received expected error for test[class art.Test989$ThrowExitTracer, class art.Test989$returnDoubleNativeClass] - art.Test989$ErrorB: Throwing error while exit public static native double art.Test989.returnDoubleNative() returned 3.14159628
+ThrowBoth: Entering public static void art.Test989.doNothing()
+ThrowBoth: Leaving public static void art.Test989.doNothing() returned <exception>
+Received expected error for test[class art.Test989$ThrowBothTracer, class art.Test989$doNothingClass] - art.Test989$ErrorC: Throwing error while exit public static void art.Test989.doNothing() returned <exception>
+ThrowBoth: Entering public static native void art.Test989.doNothingNative()
+ThrowBoth: Leaving public static native void art.Test989.doNothingNative() returned <exception>
+Received expected error for test[class art.Test989$ThrowBothTracer, class art.Test989$doNothingNativeClass] - art.Test989$ErrorC: Throwing error while exit public static native void art.Test989.doNothingNative() returned <exception>
+ThrowBoth: Entering public static void art.Test989.throwA()
+ThrowBoth: Leaving public static void art.Test989.throwA() returned <exception>
+Received expected error for test[class art.Test989$ThrowBothTracer, class art.Test989$throwAClass] - art.Test989$ErrorC: Throwing error while exit public static void art.Test989.throwA() returned <exception>
+ThrowBoth: Entering public static native void art.Test989.throwANative()
+ThrowBoth: Leaving public static native void art.Test989.throwANative() returned <exception>
+Received expected error for test[class art.Test989$ThrowBothTracer, class art.Test989$throwANativeClass] - art.Test989$ErrorC: Throwing error while exit public static native void art.Test989.throwANative() returned <exception>
+ThrowBoth: Entering public static void art.Test989.throwNativeException()
+ThrowBoth: Leaving public static void art.Test989.throwNativeException() returned <exception>
+Received expected error for test[class art.Test989$ThrowBothTracer, class art.Test989$throwNativeExceptionClass] - art.Test989$ErrorC: Throwing error while exit public static void art.Test989.throwNativeException() returned <exception>
+ThrowBoth: Entering public static java.lang.Object art.Test989.returnValue()
+ThrowBoth: Leaving public static java.lang.Object art.Test989.returnValue() returned <exception>
+Received expected error for test[class art.Test989$ThrowBothTracer, class art.Test989$returnValueClass] - art.Test989$ErrorC: Throwing error while exit public static java.lang.Object art.Test989.returnValue() returned <exception>
+ThrowBoth: Entering public static native java.lang.Object art.Test989.returnValueNative()
+ThrowBoth: Leaving public static native java.lang.Object art.Test989.returnValueNative() returned <exception>
+Received expected error for test[class art.Test989$ThrowBothTracer, class art.Test989$returnValueNativeClass] - art.Test989$ErrorC: Throwing error while exit public static native java.lang.Object art.Test989.returnValueNative() returned <exception>
+ThrowBoth: Entering public static void art.Test989.acceptValue(java.lang.Object)
+ThrowBoth: Leaving public static void art.Test989.acceptValue(java.lang.Object) returned <exception>
+Received expected error for test[class art.Test989$ThrowBothTracer, class art.Test989$acceptValueClass] - art.Test989$ErrorC: Throwing error while exit public static void art.Test989.acceptValue(java.lang.Object) returned <exception>
+ThrowBoth: Entering public static native void art.Test989.acceptValueNative(java.lang.Object)
+ThrowBoth: Leaving public static native void art.Test989.acceptValueNative(java.lang.Object) returned <exception>
+Received expected error for test[class art.Test989$ThrowBothTracer, class art.Test989$acceptValueNativeClass] - art.Test989$ErrorC: Throwing error while exit public static native void art.Test989.acceptValueNative(java.lang.Object) returned <exception>
+ThrowBoth: Entering public static void art.Test989.tryCatchExit()
+ThrowBoth: Leaving public static void art.Test989.tryCatchExit() returned <exception>
+Received expected error for test[class art.Test989$ThrowBothTracer, class art.Test989$tryCatchExitClass] - art.Test989$ErrorC: Throwing error while exit public static void art.Test989.tryCatchExit() returned <exception>
+ThrowBoth: Entering public static float art.Test989.returnFloat()
+ThrowBoth: Leaving public static float art.Test989.returnFloat() returned <exception>
+Received expected error for test[class art.Test989$ThrowBothTracer, class art.Test989$returnFloatClass] - art.Test989$ErrorC: Throwing error while exit public static float art.Test989.returnFloat() returned <exception>
+ThrowBoth: Entering public static native float art.Test989.returnFloatNative()
+ThrowBoth: Leaving public static native float art.Test989.returnFloatNative() returned <exception>
+Received expected error for test[class art.Test989$ThrowBothTracer, class art.Test989$returnFloatNativeClass] - art.Test989$ErrorC: Throwing error while exit public static native float art.Test989.returnFloatNative() returned <exception>
+ThrowBoth: Entering public static double art.Test989.returnDouble()
+ThrowBoth: Leaving public static double art.Test989.returnDouble() returned <exception>
+Received expected error for test[class art.Test989$ThrowBothTracer, class art.Test989$returnDoubleClass] - art.Test989$ErrorC: Throwing error while exit public static double art.Test989.returnDouble() returned <exception>
+ThrowBoth: Entering public static native double art.Test989.returnDoubleNative()
+ThrowBoth: Leaving public static native double art.Test989.returnDoubleNative() returned <exception>
+Received expected error for test[class art.Test989$ThrowBothTracer, class art.Test989$returnDoubleNativeClass] - art.Test989$ErrorC: Throwing error while exit public static native double art.Test989.returnDoubleNative() returned <exception>
+Received no exception as expected for test[class art.Test989$ForceGCTracer, class art.Test989$doNothingClass].
+Received no exception as expected for test[class art.Test989$ForceGCTracer, class art.Test989$doNothingNativeClass].
+Received expected error for test[class art.Test989$ForceGCTracer, class art.Test989$throwAClass] - art.Test989$ErrorA: Throwing Error A
+Received expected error for test[class art.Test989$ForceGCTracer, class art.Test989$throwANativeClass] - art.Test989$ErrorA: Throwing Error A
+Received expected error for test[class art.Test989$ForceGCTracer, class art.Test989$throwNativeExceptionClass] - java.lang.Error: Error
+returnValue returned: TestObject(33)
+Received no exception as expected for test[class art.Test989$ForceGCTracer, class art.Test989$returnValueClass].
+returnValueNative returned: TestObject(34)
+Received no exception as expected for test[class art.Test989$ForceGCTracer, class art.Test989$returnValueNativeClass].
+Recieved TestObject(35)
+Received no exception as expected for test[class art.Test989$ForceGCTracer, class art.Test989$acceptValueClass].
+Recieved TestObject(36)
+Received no exception as expected for test[class art.Test989$ForceGCTracer, class art.Test989$acceptValueNativeClass].
+Received no exception as expected for test[class art.Test989$ForceGCTracer, class art.Test989$tryCatchExitClass].
+returnFloat returned: 1.618
+Received no exception as expected for test[class art.Test989$ForceGCTracer, class art.Test989$returnFloatClass].
+returnFloatNative returned: 1.618
+Received no exception as expected for test[class art.Test989$ForceGCTracer, class art.Test989$returnFloatNativeClass].
+returnDouble returned: 3.14159628
+Received no exception as expected for test[class art.Test989$ForceGCTracer, class art.Test989$returnDoubleClass].
+returnDoubleNative returned: 3.14159628
+Received no exception as expected for test[class art.Test989$ForceGCTracer, class art.Test989$returnDoubleNativeClass].
Finished!
diff --git a/test/989-method-trace-throw/method_trace.cc b/test/989-method-trace-throw/method_trace.cc
index edfff907a0..1f62aa7607 100644
--- a/test/989-method-trace-throw/method_trace.cc
+++ b/test/989-method-trace-throw/method_trace.cc
@@ -63,6 +63,12 @@ extern "C" JNIEXPORT void JNICALL Java_art_Test989_throwANative(JNIEnv* env,
env->CallStaticVoidMethod(klass, targetMethod);
}
+extern "C" JNIEXPORT void JNICALL Java_art_Test989_doThrowNative(JNIEnv* env,
+ [[maybe_unused]] jclass klass) {
+ jclass exception_cls = env->FindClass("java/lang/Error");
+ env->ThrowNew(exception_cls, "Error");
+}
+
extern "C" JNIEXPORT void JNICALL Java_art_Test989_acceptValueNative(JNIEnv* env,
jclass klass,
jobject arg) {
diff --git a/test/989-method-trace-throw/src/art/Test989.java b/test/989-method-trace-throw/src/art/Test989.java
index f18d5ef3d6..fec09e0934 100644
--- a/test/989-method-trace-throw/src/art/Test989.java
+++ b/test/989-method-trace-throw/src/art/Test989.java
@@ -37,6 +37,7 @@ public class Test989 {
testMethods.add(Test989.class.getDeclaredMethod("doNothingNative"));
testMethods.add(Test989.class.getDeclaredMethod("throwA"));
testMethods.add(Test989.class.getDeclaredMethod("throwANative"));
+ testMethods.add(Test989.class.getDeclaredMethod("throwNativeException"));
testMethods.add(Test989.class.getDeclaredMethod("returnFloat"));
testMethods.add(Test989.class.getDeclaredMethod("returnFloatNative"));
testMethods.add(Test989.class.getDeclaredMethod("returnDouble"));
@@ -46,6 +47,7 @@ public class Test989 {
testMethods.add(Test989.class.getDeclaredMethod("acceptValue", Object.class));
testMethods.add(Test989.class.getDeclaredMethod("acceptValueNative", Object.class));
testMethods.add(Test989.class.getDeclaredMethod("tryCatchExit"));
+ testMethods.add(Test989.class.getDeclaredMethod("doThrowNative"));
} catch (Exception e) {
throw new Error("Bad static!", e);
}
@@ -244,35 +246,50 @@ public class Test989 {
}
public static void run() throws Exception {
- MyRunnable[] testCases = new MyRunnable[] {
- new doNothingClass(),
- new doNothingNativeClass(),
- new throwAClass(),
- new throwANativeClass(),
- new returnValueClass(),
- new returnValueNativeClass(),
- new acceptValueClass(),
- new acceptValueNativeClass(),
- new tryCatchExitClass(),
- new returnFloatClass(),
- new returnFloatNativeClass(),
- new returnDoubleClass(),
- new returnDoubleNativeClass(),
- };
- MethodTracer[] tracers = new MethodTracer[] {
- new NormalTracer(),
- new ThrowEnterTracer(),
- new ThrowExitTracer(),
- new ThrowBothTracer(),
- new ForceGCTracer(),
- };
-
- setupTracing();
- for (MethodTracer t : tracers) {
- for (MyRunnable r : testCases) {
- doTest(t, r);
+ MyRunnable[] testCases = new MyRunnable[] {
+ new doNothingClass(),
+ new doNothingNativeClass(),
+ new throwAClass(),
+ new throwANativeClass(),
+ new throwNativeExceptionClass(),
+ new returnValueClass(),
+ new returnValueNativeClass(),
+ new acceptValueClass(),
+ new acceptValueNativeClass(),
+ new tryCatchExitClass(),
+ new returnFloatClass(),
+ new returnFloatNativeClass(),
+ new returnDoubleClass(),
+ new returnDoubleNativeClass(),
+ };
+ MethodTracer[] tracers = new MethodTracer[] {
+ new NormalTracer(),
+ new ThrowEnterTracer(),
+ new ThrowExitTracer(),
+ new ThrowBothTracer(),
+ new ForceGCTracer(),
+ };
+
+ setupTracing();
+ for (MethodTracer t : tracers) {
+ for (MyRunnable r : testCases) {
+ doTest(t, r);
+ }
+ }
+
+ maybeDisableTracing();
+ System.out.println("Finished - without non-standard exits!");
+ Trace.disableTracing(Thread.currentThread());
+
+ // Enabling frame pop events force a different path and deoptimize more often. So redo the
+ // tests by enabling frame pop events.
+ Trace.enableFramePopEvents();
+ setupTracing();
+ for (MethodTracer t : tracers) {
+ for (MyRunnable r : testCases) {
+ doTest(t, r);
+ }
}
- }
maybeDisableTracing();
System.out.println("Finished!");
@@ -299,6 +316,17 @@ public class Test989 {
}
}
+ private static final class throwNativeExceptionClass implements MyRunnable {
+ public void run() {
+ throwNativeException();
+ }
+
+ @Override
+ public Class<?> expectedThrow() {
+ return Error.class;
+ }
+ }
+
private static final class tryCatchExitClass implements MyRunnable {
public void run() {
tryCatchExit();
@@ -419,6 +447,10 @@ public class Test989 {
throw new ErrorA("Throwing Error A");
}
+ public static void throwNativeException() {
+ doThrowNative();
+ }
+
static final class TestObject {
private int idx;
public TestObject(int v) {
@@ -464,4 +496,5 @@ public class Test989 {
public static native void throwANative();
public static native float returnFloatNative();
public static native double returnDoubleNative();
+ public static native void doThrowNative();
}
diff --git a/test/jvmti-common/Trace.java b/test/jvmti-common/Trace.java
index 8999bb1368..3df1737c91 100644
--- a/test/jvmti-common/Trace.java
+++ b/test/jvmti-common/Trace.java
@@ -28,6 +28,7 @@ public class Trace {
Method singleStep,
Thread thr);
public static native void disableTracing(Thread thr);
+ public static native void nativeEnableFramePopEvents();
public static void enableFieldTracing(Class<?> methodClass,
Method fieldAccess,
@@ -43,6 +44,10 @@ public class Trace {
enableTracing(methodClass, entryMethod, exitMethod, null, null, null, thr);
}
+ public static void enableFramePopEvents() {
+ nativeEnableFramePopEvents();
+ }
+
public static void enableSingleStepTracing(Class<?> methodClass,
Method singleStep,
Thread thr) {
diff --git a/test/ti-agent/trace_helper.cc b/test/ti-agent/trace_helper.cc
index 58958cb268..e34b5bdce9 100644
--- a/test/ti-agent/trace_helper.cc
+++ b/test/ti-agent/trace_helper.cc
@@ -466,6 +466,15 @@ extern "C" JNIEXPORT void JNICALL Java_art_Trace_watchFieldAccess(
env->DeleteLocalRef(klass);
}
+extern "C" JNIEXPORT void JNICALL Java_art_Trace_nativeEnableFramePopEvents(JNIEnv* env) {
+ jvmtiCapabilities caps;
+ memset(&caps, 0, sizeof(caps));
+ caps.can_pop_frame = 1;
+ if (JvmtiErrorToException(env, jvmti_env, jvmti_env->AddCapabilities(&caps))) {
+ return;
+ }
+}
+
extern "C" JNIEXPORT void JNICALL Java_art_Trace_enableTracing2(
JNIEnv* env,
[[maybe_unused]] jclass trace,