From 06a04e0e776875303577c2d871b53a53c78da1b5 Mon Sep 17 00:00:00 2001 From: Igor Murashkin Date: Tue, 13 Sep 2016 15:57:37 -0700 Subject: jni: Implement generic JNI support for @CriticalNative/@FastNative Also: * Extend existing test cases to check generic JNI for the above. * Re-enable previously blacklisted @CriticalNative JNI run-tests. Bug: 31400248 Change-Id: I436ed00c8b8880e936a0c3483bc0dc251f0c0ce2 --- compiler/jni/jni_compiler_test.cc | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) (limited to 'compiler/jni/jni_compiler_test.cc') diff --git a/compiler/jni/jni_compiler_test.cc b/compiler/jni/jni_compiler_test.cc index cdd4c68470..b692c6d9ad 100644 --- a/compiler/jni/jni_compiler_test.cc +++ b/compiler/jni/jni_compiler_test.cc @@ -391,12 +391,12 @@ jobject JniCompilerTest::class_loader_; // 3) synchronized keyword // -- TODO: We can support (1) if we remove the mutator lock assert during stub lookup. # define JNI_TEST_NORMAL_ONLY(TestName) \ - TEST_F(JniCompilerTest, TestName ## Default) { \ + TEST_F(JniCompilerTest, TestName ## NormalCompiler) { \ SCOPED_TRACE("Normal JNI with compiler"); \ gCurrentJni = static_cast(JniKind::kNormal); \ TestName ## Impl(); \ } \ - TEST_F(JniCompilerTest, TestName ## Generic) { \ + TEST_F(JniCompilerTest, TestName ## NormalGeneric) { \ SCOPED_TRACE("Normal JNI with generic"); \ gCurrentJni = static_cast(JniKind::kNormal); \ TEST_DISABLED_FOR_MIPS(); \ @@ -404,46 +404,41 @@ jobject JniCompilerTest::class_loader_; TestName ## Impl(); \ } -// Test normal compiler, @FastNative compiler, and normal/@FastNative generic for normal natives. +// Test (normal, @FastNative) x (compiler, generic). #define JNI_TEST(TestName) \ JNI_TEST_NORMAL_ONLY(TestName) \ - TEST_F(JniCompilerTest, TestName ## Fast) { \ + TEST_F(JniCompilerTest, TestName ## FastCompiler) { \ SCOPED_TRACE("@FastNative JNI with compiler"); \ gCurrentJni = static_cast(JniKind::kFast); \ TestName ## Impl(); \ } \ - \ - -// TODO: maybe. @FastNative generic JNI support? -#if 0 + \ TEST_F(JniCompilerTest, TestName ## FastGeneric) { \ + SCOPED_TRACE("@FastNative JNI with generic"); \ gCurrentJni = static_cast(JniKind::kFast); \ TEST_DISABLED_FOR_MIPS(); \ SetCheckGenericJni(true); \ TestName ## Impl(); \ } -#endif +// Test (@CriticalNative) x (compiler, generic) only. #define JNI_TEST_CRITICAL_ONLY(TestName) \ - TEST_F(JniCompilerTest, TestName ## DefaultCritical) { \ + TEST_F(JniCompilerTest, TestName ## CriticalCompiler) { \ SCOPED_TRACE("@CriticalNative JNI with compiler"); \ gCurrentJni = static_cast(JniKind::kCritical); \ TestName ## Impl(); \ + } \ + TEST_F(JniCompilerTest, TestName ## CriticalGeneric) { \ + SCOPED_TRACE("@CriticalNative JNI with generic"); \ + gCurrentJni = static_cast(JniKind::kCritical); \ + TestName ## Impl(); \ } -// Test everything above and also the @CriticalNative compiler, and @CriticalNative generic JNI. +// Test everything: (normal, @FastNative, @CriticalNative) x (compiler, generic). #define JNI_TEST_CRITICAL(TestName) \ JNI_TEST(TestName) \ JNI_TEST_CRITICAL_ONLY(TestName) \ -// TODO: maybe, more likely since calling convention changed. @Criticalnative generic JNI support? -#if 0 - TEST_F(JniCompilerTest, TestName ## GenericCritical) { \ - gCurrentJni = static_cast(JniKind::kCritical); \ - TestName ## Impl(); \ - } -#endif - static void expectValidThreadState() { // Normal JNI always transitions to "Native". Other JNIs stay in the "Runnable" state. if (IsCurrentJniNormal()) { @@ -506,6 +501,7 @@ static void expectValidJniEnvAndClass(JNIEnv* env, jclass kls) { // Temporarily disable the EXPECT_NUM_STACK_REFERENCES check (for a single test). struct ScopedDisableCheckNumStackReferences { ScopedDisableCheckNumStackReferences() { + CHECK(sCheckNumStackReferences); // No nested support. sCheckNumStackReferences = false; } -- cgit v1.2.3-59-g8ed1b