From 119c6bd97f7ac24b64eaf4e9333abb44acbf780f Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Fri, 9 May 2014 14:11:47 -0700 Subject: Fix stub_test to pass with SS collector. Changed the test to access the allocation entrypoints from the thread. Change the order roots are visited to prevent a rare error where the java lang reflect art method would move before it was checked in SanityCheckFrame. Change-Id: Ifb96220f3fbb74ea5d720777f130450f04c0e044 --- runtime/arch/stub_test.cc | 33 ++++++++++++--------------------- runtime/runtime.cc | 2 +- runtime/stack.cc | 2 +- runtime/thread.h | 1 + 4 files changed, 15 insertions(+), 23 deletions(-) diff --git a/runtime/arch/stub_test.cc b/runtime/arch/stub_test.cc index 4438f25..d7a2a86 100644 --- a/runtime/arch/stub_test.cc +++ b/runtime/arch/stub_test.cc @@ -51,6 +51,11 @@ class StubTest : public CommonRuntimeTest { } } + // Helper function needed since TEST_F makes a new class. + Thread::tls_ptr_sized_values* GetTlsPtr(Thread* self) { + return &self->tlsPtr_; + } + size_t Invoke3(size_t arg0, size_t arg1, size_t arg2, uintptr_t code, Thread* self) { // Push a transition back into managed code onto the linked list in thread. ManagedStack fragment; @@ -727,13 +732,6 @@ TEST_F(StubTest, APutObj) { #endif } - -#if defined(__i386__) || defined(__arm__) || defined(__aarch64__) || defined(__x86_64__) -extern "C" void art_quick_alloc_object_rosalloc(void); -extern "C" void art_quick_alloc_object_resolved_rosalloc(void); -extern "C" void art_quick_alloc_object_initialized_rosalloc(void); -#endif - TEST_F(StubTest, AllocObject) { TEST_DISABLED_FOR_HEAP_REFERENCE_POISONING(); @@ -751,13 +749,12 @@ TEST_F(StubTest, AllocObject) { // Play with it... EXPECT_FALSE(self->IsExceptionPending()); - { // Use an arbitrary method from c to use as referrer size_t result = Invoke3(static_cast(c->GetDexTypeIndex()), // type_idx reinterpret_cast(c->GetVirtualMethod(0)), // arbitrary 0U, - reinterpret_cast(&art_quick_alloc_object_rosalloc), + reinterpret_cast(GetTlsPtr(self)->quick_entrypoints.pAllocObject), self); EXPECT_FALSE(self->IsExceptionPending()); @@ -771,7 +768,7 @@ TEST_F(StubTest, AllocObject) { // We can use nullptr in the second argument as we do not need a method here (not used in // resolved/initialized cases) size_t result = Invoke3(reinterpret_cast(c.get()), reinterpret_cast(nullptr), 0U, - reinterpret_cast(&art_quick_alloc_object_resolved_rosalloc), + reinterpret_cast(GetTlsPtr(self)->quick_entrypoints.pAllocObjectResolved), self); EXPECT_FALSE(self->IsExceptionPending()); @@ -785,7 +782,7 @@ TEST_F(StubTest, AllocObject) { // We can use nullptr in the second argument as we do not need a method here (not used in // resolved/initialized cases) size_t result = Invoke3(reinterpret_cast(c.get()), reinterpret_cast(nullptr), 0U, - reinterpret_cast(&art_quick_alloc_object_initialized_rosalloc), + reinterpret_cast(GetTlsPtr(self)->quick_entrypoints.pAllocObjectInitialized), self); EXPECT_FALSE(self->IsExceptionPending()); @@ -842,7 +839,7 @@ TEST_F(StubTest, AllocObject) { self->ClearException(); size_t result = Invoke3(reinterpret_cast(c.get()), reinterpret_cast(nullptr), 0U, - reinterpret_cast(&art_quick_alloc_object_initialized_rosalloc), + reinterpret_cast(GetTlsPtr(self)->quick_entrypoints.pAllocObjectInitialized), self); EXPECT_TRUE(self->IsExceptionPending()); @@ -866,12 +863,6 @@ TEST_F(StubTest, AllocObject) { #endif } - -#if defined(__i386__) || defined(__arm__) || defined(__aarch64__) || defined(__x86_64__) -extern "C" void art_quick_alloc_array_rosalloc(void); -extern "C" void art_quick_alloc_array_resolved_rosalloc(void); -#endif - TEST_F(StubTest, AllocObjectArray) { TEST_DISABLED_FOR_HEAP_REFERENCE_POISONING(); @@ -902,7 +893,7 @@ TEST_F(StubTest, AllocObjectArray) { size_t result = Invoke3(static_cast(c->GetDexTypeIndex()), // type_idx reinterpret_cast(c_obj->GetVirtualMethod(0)), // arbitrary 10U, - reinterpret_cast(&art_quick_alloc_array_rosalloc), + reinterpret_cast(GetTlsPtr(self)->quick_entrypoints.pAllocArray), self); EXPECT_FALSE(self->IsExceptionPending()); @@ -917,7 +908,7 @@ TEST_F(StubTest, AllocObjectArray) { // We can use nullptr in the second argument as we do not need a method here (not used in // resolved/initialized cases) size_t result = Invoke3(reinterpret_cast(c.get()), reinterpret_cast(nullptr), 10U, - reinterpret_cast(&art_quick_alloc_array_resolved_rosalloc), + reinterpret_cast(GetTlsPtr(self)->quick_entrypoints.pAllocArrayResolved), self); EXPECT_FALSE(self->IsExceptionPending()) << PrettyTypeOf(self->GetException(nullptr)); @@ -937,7 +928,7 @@ TEST_F(StubTest, AllocObjectArray) { { size_t result = Invoke3(reinterpret_cast(c.get()), reinterpret_cast(nullptr), GB, // that should fail... - reinterpret_cast(&art_quick_alloc_array_resolved_rosalloc), + reinterpret_cast(GetTlsPtr(self)->quick_entrypoints.pAllocArrayResolved), self); EXPECT_TRUE(self->IsExceptionPending()); diff --git a/runtime/runtime.cc b/runtime/runtime.cc index 6d9dfa6..7a652ed 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -940,8 +940,8 @@ void Runtime::VisitNonConcurrentRoots(RootCallback* callback, void* arg) { } void Runtime::VisitRoots(RootCallback* callback, void* arg, VisitRootFlags flags) { - VisitConcurrentRoots(callback, arg, flags); VisitNonConcurrentRoots(callback, arg); + VisitConcurrentRoots(callback, arg, flags); } mirror::ObjectArray* Runtime::CreateDefaultImt(ClassLinker* cl) { diff --git a/runtime/stack.cc b/runtime/stack.cc index 5e64e59..6667419 100644 --- a/runtime/stack.cc +++ b/runtime/stack.cc @@ -270,7 +270,7 @@ instrumentation::InstrumentationStackFrame& StackVisitor::GetInstrumentationStac void StackVisitor::SanityCheckFrame() const { if (kIsDebugBuild) { mirror::ArtMethod* method = GetMethod(); - CHECK(method->GetClass() == mirror::ArtMethod::GetJavaLangReflectArtMethod()); + CHECK_EQ(method->GetClass(), mirror::ArtMethod::GetJavaLangReflectArtMethod()); if (cur_quick_frame_ != nullptr) { method->AssertPcIsWithinQuickCode(cur_quick_frame_pc_); // Frame sanity. diff --git a/runtime/thread.h b/runtime/thread.h index 8c17082..32311e1 100644 --- a/runtime/thread.h +++ b/runtime/thread.h @@ -1082,6 +1082,7 @@ class Thread { friend class Runtime; // For CreatePeer. friend class ScopedThreadStateChange; friend class SignalCatcher; // For SetStateUnsafe. + friend class StubTest; // For accessing entrypoints. friend class ThreadList; // For ~Thread and Destroy. DISALLOW_COPY_AND_ASSIGN(Thread); -- cgit v1.1