diff options
author | Andreas Gampe <agampe@google.com> | 2015-02-23 08:12:24 -0800 |
---|---|---|
committer | Andreas Gampe <agampe@google.com> | 2015-02-23 10:23:06 -0800 |
commit | 794ad76e8d5b5b9132819d5b08a0570e27615644 (patch) | |
tree | 74b420e4337ecf9e5df689cc376fa965d765a908 | |
parent | d98ff78976696fdde1e7868d4687719a0439544b (diff) | |
download | android_art-794ad76e8d5b5b9132819d5b08a0570e27615644.tar.gz android_art-794ad76e8d5b5b9132819d5b08a0570e27615644.tar.bz2 android_art-794ad76e8d5b5b9132819d5b08a0570e27615644.zip |
ART: Introduce NO_RETURN, Mark DoLongJump noreturn
Add NO_RETURN macro that adds C++11 noreturn attribute. Mark
DoLongJump methods as noreturn.
Change-Id: Ifde4318e370493237050d4c1349285a0382df23f
-rw-r--r-- | dex2oat/dex2oat.cc | 5 | ||||
-rw-r--r-- | patchoat/patchoat.cc | 2 | ||||
-rw-r--r-- | runtime/arch/arm/context_arm.cc | 2 | ||||
-rw-r--r-- | runtime/arch/arm/context_arm.h | 3 | ||||
-rw-r--r-- | runtime/arch/arm64/context_arm64.cc | 2 | ||||
-rw-r--r-- | runtime/arch/arm64/context_arm64.h | 3 | ||||
-rw-r--r-- | runtime/arch/context.h | 3 | ||||
-rw-r--r-- | runtime/arch/mips/context_mips.cc | 2 | ||||
-rw-r--r-- | runtime/arch/mips/context_mips.h | 3 | ||||
-rw-r--r-- | runtime/arch/mips64/context_mips64.cc | 2 | ||||
-rw-r--r-- | runtime/arch/mips64/context_mips64.h | 3 | ||||
-rw-r--r-- | runtime/arch/x86/context_x86.cc | 1 | ||||
-rw-r--r-- | runtime/arch/x86/context_x86.h | 3 | ||||
-rw-r--r-- | runtime/arch/x86_64/context_x86_64.cc | 3 | ||||
-rw-r--r-- | runtime/arch/x86_64/context_x86_64.h | 3 | ||||
-rw-r--r-- | runtime/base/macros.h | 3 | ||||
-rw-r--r-- | runtime/interpreter/interpreter_common.h | 5 | ||||
-rw-r--r-- | runtime/native/java_lang_Runtime.cc | 3 | ||||
-rw-r--r-- | runtime/quick_exception_handler.cc | 1 | ||||
-rw-r--r-- | runtime/quick_exception_handler.h | 3 | ||||
-rw-r--r-- | runtime/runtime.h | 3 | ||||
-rw-r--r-- | runtime/thread.cc | 2 | ||||
-rw-r--r-- | runtime/thread.h | 2 | ||||
-rw-r--r-- | runtime/thread_list.cc | 3 |
24 files changed, 40 insertions, 25 deletions
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc index e607e15a13..0b1f14dd94 100644 --- a/dex2oat/dex2oat.cc +++ b/dex2oat/dex2oat.cc @@ -36,6 +36,7 @@ #include "arch/instruction_set_features.h" #include "arch/mips/instruction_set_features_mips.h" #include "base/dumpable.h" +#include "base/macros.h" #include "base/stl_util.h" #include "base/stringpiece.h" #include "base/timing_logger.h" @@ -97,7 +98,7 @@ static void UsageError(const char* fmt, ...) { va_end(ap); } -[[noreturn]] static void Usage(const char* fmt, ...) { +NO_RETURN static void Usage(const char* fmt, ...) { va_list ap; va_start(ap, fmt); UsageErrorV(fmt, ap); @@ -326,7 +327,7 @@ class WatchDog { message.c_str()); } - [[noreturn]] static void Fatal(const std::string& message) { + NO_RETURN static void Fatal(const std::string& message) { Message('F', message); exit(1); } diff --git a/patchoat/patchoat.cc b/patchoat/patchoat.cc index 2059a96c70..3c6a23d8a1 100644 --- a/patchoat/patchoat.cc +++ b/patchoat/patchoat.cc @@ -763,7 +763,7 @@ static void UsageError(const char* fmt, ...) { va_end(ap); } -[[noreturn]] static void Usage(const char *fmt, ...) { +NO_RETURN static void Usage(const char *fmt, ...) { va_list ap; va_start(ap, fmt); UsageErrorV(fmt, ap); diff --git a/runtime/arch/arm/context_arm.cc b/runtime/arch/arm/context_arm.cc index c181e43132..5bd23d0def 100644 --- a/runtime/arch/arm/context_arm.cc +++ b/runtime/arch/arm/context_arm.cc @@ -106,7 +106,7 @@ void ArmContext::SmashCallerSaves() { fprs_[S15] = nullptr; } -extern "C" void art_quick_do_long_jump(uint32_t*, uint32_t*); +extern "C" NO_RETURN void art_quick_do_long_jump(uint32_t*, uint32_t*); void ArmContext::DoLongJump() { uintptr_t gprs[kNumberOfCoreRegisters]; diff --git a/runtime/arch/arm/context_arm.h b/runtime/arch/arm/context_arm.h index 1ca973eb80..5bdeda7f81 100644 --- a/runtime/arch/arm/context_arm.h +++ b/runtime/arch/arm/context_arm.h @@ -19,6 +19,7 @@ #include "arch/context.h" #include "base/logging.h" +#include "base/macros.h" #include "registers_arm.h" namespace art { @@ -76,7 +77,7 @@ class ArmContext : public Context { void SetFPR(uint32_t reg, uintptr_t value) OVERRIDE; void SmashCallerSaves() OVERRIDE; - void DoLongJump() OVERRIDE; + NO_RETURN void DoLongJump() OVERRIDE; private: // Pointers to register locations, initialized to NULL or the specific registers below. diff --git a/runtime/arch/arm64/context_arm64.cc b/runtime/arch/arm64/context_arm64.cc index 7fc0555c5b..ec9c122fc3 100644 --- a/runtime/arch/arm64/context_arm64.cc +++ b/runtime/arch/arm64/context_arm64.cc @@ -133,7 +133,7 @@ void Arm64Context::SmashCallerSaves() { fprs_[D31] = nullptr; } -extern "C" void art_quick_do_long_jump(uint64_t*, uint64_t*); +extern "C" NO_RETURN void art_quick_do_long_jump(uint64_t*, uint64_t*); void Arm64Context::DoLongJump() { uint64_t gprs[kNumberOfXRegisters]; diff --git a/runtime/arch/arm64/context_arm64.h b/runtime/arch/arm64/context_arm64.h index 6a4485b259..f4867797f0 100644 --- a/runtime/arch/arm64/context_arm64.h +++ b/runtime/arch/arm64/context_arm64.h @@ -19,6 +19,7 @@ #include "arch/context.h" #include "base/logging.h" +#include "base/macros.h" #include "registers_arm64.h" namespace art { @@ -76,7 +77,7 @@ class Arm64Context : public Context { void SetFPR(uint32_t reg, uintptr_t value) OVERRIDE; void SmashCallerSaves() OVERRIDE; - void DoLongJump() OVERRIDE; + NO_RETURN void DoLongJump() OVERRIDE; private: // Pointers to register locations, initialized to NULL or the specific registers below. diff --git a/runtime/arch/context.h b/runtime/arch/context.h index ed8cab0cd2..f86f9ae117 100644 --- a/runtime/arch/context.h +++ b/runtime/arch/context.h @@ -20,6 +20,7 @@ #include <stddef.h> #include <stdint.h> +#include "base/macros.h" #include "base/mutex.h" namespace art { @@ -78,7 +79,7 @@ class Context { virtual void SmashCallerSaves() = 0; // Switches execution of the executing context to this context - virtual void DoLongJump() = 0; + NO_RETURN virtual void DoLongJump() = 0; protected: enum { diff --git a/runtime/arch/mips/context_mips.cc b/runtime/arch/mips/context_mips.cc index 6c0ab98947..3b525be122 100644 --- a/runtime/arch/mips/context_mips.cc +++ b/runtime/arch/mips/context_mips.cc @@ -90,7 +90,7 @@ void MipsContext::SmashCallerSaves() { gprs_[A3] = nullptr; } -extern "C" void art_quick_do_long_jump(uint32_t*, uint32_t*); +extern "C" NO_RETURN void art_quick_do_long_jump(uint32_t*, uint32_t*); void MipsContext::DoLongJump() { uintptr_t gprs[kNumberOfCoreRegisters]; diff --git a/runtime/arch/mips/context_mips.h b/runtime/arch/mips/context_mips.h index d8a0b673c8..cbad3f963a 100644 --- a/runtime/arch/mips/context_mips.h +++ b/runtime/arch/mips/context_mips.h @@ -19,6 +19,7 @@ #include "arch/context.h" #include "base/logging.h" +#include "base/macros.h" #include "registers_mips.h" namespace art { @@ -75,7 +76,7 @@ class MipsContext : public Context { void SetFPR(uint32_t reg, uintptr_t value) OVERRIDE; void SmashCallerSaves() OVERRIDE; - void DoLongJump() OVERRIDE; + NO_RETURN void DoLongJump() OVERRIDE; private: // Pointers to registers in the stack, initialized to NULL except for the special cases below. diff --git a/runtime/arch/mips64/context_mips64.cc b/runtime/arch/mips64/context_mips64.cc index 1c96bd43ab..ce99b40b92 100644 --- a/runtime/arch/mips64/context_mips64.cc +++ b/runtime/arch/mips64/context_mips64.cc @@ -121,7 +121,7 @@ void Mips64Context::SmashCallerSaves() { fprs_[F23] = nullptr; } -extern "C" void art_quick_do_long_jump(uintptr_t*, uintptr_t*); +extern "C" NO_RETURN void art_quick_do_long_jump(uintptr_t*, uintptr_t*); void Mips64Context::DoLongJump() { uintptr_t gprs[kNumberOfGpuRegisters]; diff --git a/runtime/arch/mips64/context_mips64.h b/runtime/arch/mips64/context_mips64.h index 104672348b..2cc2b8df3e 100644 --- a/runtime/arch/mips64/context_mips64.h +++ b/runtime/arch/mips64/context_mips64.h @@ -19,6 +19,7 @@ #include "arch/context.h" #include "base/logging.h" +#include "base/macros.h" #include "registers_mips64.h" namespace art { @@ -75,7 +76,7 @@ class Mips64Context : public Context { void SetFPR(uint32_t reg, uintptr_t value) OVERRIDE; void SmashCallerSaves() OVERRIDE; - void DoLongJump() OVERRIDE; + NO_RETURN void DoLongJump() OVERRIDE; private: // Pointers to registers in the stack, initialized to NULL except for the special cases below. diff --git a/runtime/arch/x86/context_x86.cc b/runtime/arch/x86/context_x86.cc index 4ea4684f06..52a35dde92 100644 --- a/runtime/arch/x86/context_x86.cc +++ b/runtime/arch/x86/context_x86.cc @@ -133,6 +133,7 @@ void X86Context::DoLongJump() { #else UNIMPLEMENTED(FATAL); #endif + UNREACHABLE(); } } // namespace x86 diff --git a/runtime/arch/x86/context_x86.h b/runtime/arch/x86/context_x86.h index c66a9dcb19..ace4670136 100644 --- a/runtime/arch/x86/context_x86.h +++ b/runtime/arch/x86/context_x86.h @@ -19,6 +19,7 @@ #include "arch/context.h" #include "base/logging.h" +#include "base/macros.h" #include "registers_x86.h" namespace art { @@ -75,7 +76,7 @@ class X86Context : public Context { void SetFPR(uint32_t reg, uintptr_t value) OVERRIDE; void SmashCallerSaves() OVERRIDE; - void DoLongJump() OVERRIDE; + NO_RETURN void DoLongJump() OVERRIDE; private: // Pretend XMM registers are made of uin32_t pieces, because they are manipulated diff --git a/runtime/arch/x86_64/context_x86_64.cc b/runtime/arch/x86_64/context_x86_64.cc index cdc2ec71da..63365411e8 100644 --- a/runtime/arch/x86_64/context_x86_64.cc +++ b/runtime/arch/x86_64/context_x86_64.cc @@ -105,7 +105,7 @@ void X86_64Context::SetFPR(uint32_t reg, uintptr_t value) { *fprs_[reg] = value; } -extern "C" void art_quick_do_long_jump(uintptr_t*, uintptr_t*); +extern "C" NO_RETURN void art_quick_do_long_jump(uintptr_t*, uintptr_t*); void X86_64Context::DoLongJump() { #if defined(__x86_64__) @@ -127,6 +127,7 @@ void X86_64Context::DoLongJump() { art_quick_do_long_jump(gprs, fprs); #else UNIMPLEMENTED(FATAL); + UNREACHABLE(); #endif } diff --git a/runtime/arch/x86_64/context_x86_64.h b/runtime/arch/x86_64/context_x86_64.h index 0dda06ec4a..d03aa45237 100644 --- a/runtime/arch/x86_64/context_x86_64.h +++ b/runtime/arch/x86_64/context_x86_64.h @@ -19,6 +19,7 @@ #include "arch/context.h" #include "base/logging.h" +#include "base/macros.h" #include "registers_x86_64.h" namespace art { @@ -75,7 +76,7 @@ class X86_64Context : public Context { void SetFPR(uint32_t reg, uintptr_t value) OVERRIDE; void SmashCallerSaves() OVERRIDE; - void DoLongJump() OVERRIDE; + NO_RETURN void DoLongJump() OVERRIDE; private: // Pointers to register locations. Values are initialized to NULL or the special registers below. diff --git a/runtime/base/macros.h b/runtime/base/macros.h index f705469c89..3a9de5fecd 100644 --- a/runtime/base/macros.h +++ b/runtime/base/macros.h @@ -186,6 +186,9 @@ template<typename... T> void UNUSED(const T&...) {} // without the UNREACHABLE a return statement would be necessary. #define UNREACHABLE __builtin_unreachable +// Add the C++11 noreturn attribute. +#define NO_RETURN [[ noreturn ]] // NOLINT[whitespace/braces] [5] + // The FALLTHROUGH_INTENDED macro can be used to annotate implicit fall-through // between switch labels: // switch (x) { diff --git a/runtime/interpreter/interpreter_common.h b/runtime/interpreter/interpreter_common.h index ce7c1c3817..06b809f028 100644 --- a/runtime/interpreter/interpreter_common.h +++ b/runtime/interpreter/interpreter_common.h @@ -25,6 +25,7 @@ #include <sstream> #include "base/logging.h" +#include "base/macros.h" #include "class_linker-inl.h" #include "common_throws.h" #include "dex_file-inl.h" @@ -349,8 +350,8 @@ uint32_t FindNextInstructionFollowingException(Thread* self, ShadowFrame& shadow uint32_t dex_pc, const instrumentation::Instrumentation* instrumentation) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); -void UnexpectedOpcode(const Instruction* inst, const ShadowFrame& shadow_frame) - __attribute__((cold, noreturn)) +NO_RETURN void UnexpectedOpcode(const Instruction* inst, const ShadowFrame& shadow_frame) + __attribute__((cold)) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); static inline void TraceExecution(const ShadowFrame& shadow_frame, const Instruction* inst, diff --git a/runtime/native/java_lang_Runtime.cc b/runtime/native/java_lang_Runtime.cc index 97b17bfd45..84b18ab382 100644 --- a/runtime/native/java_lang_Runtime.cc +++ b/runtime/native/java_lang_Runtime.cc @@ -20,6 +20,7 @@ #include <limits.h> #include <unistd.h> +#include "base/macros.h" #include "gc/heap.h" #include "handle_scope-inl.h" #include "jni_internal.h" @@ -39,7 +40,7 @@ static void Runtime_gc(JNIEnv*, jclass) { Runtime::Current()->GetHeap()->CollectGarbage(false); } -[[noreturn]] static void Runtime_nativeExit(JNIEnv*, jclass, jint status) { +NO_RETURN static void Runtime_nativeExit(JNIEnv*, jclass, jint status) { LOG(INFO) << "System.exit called, status: " << status; Runtime::Current()->CallExitHook(status); exit(status); diff --git a/runtime/quick_exception_handler.cc b/runtime/quick_exception_handler.cc index 85ec80314e..7bdf652355 100644 --- a/runtime/quick_exception_handler.cc +++ b/runtime/quick_exception_handler.cc @@ -353,6 +353,7 @@ void QuickExceptionHandler::DoLongJump() { context_->SetPC(handler_quick_frame_pc_); context_->SmashCallerSaves(); context_->DoLongJump(); + UNREACHABLE(); } } // namespace art diff --git a/runtime/quick_exception_handler.h b/runtime/quick_exception_handler.h index 31622de984..162b1dc74c 100644 --- a/runtime/quick_exception_handler.h +++ b/runtime/quick_exception_handler.h @@ -18,6 +18,7 @@ #define ART_RUNTIME_QUICK_EXCEPTION_HANDLER_H_ #include "base/logging.h" +#include "base/macros.h" #include "base/mutex.h" #include "stack.h" // StackReference @@ -48,7 +49,7 @@ class QuickExceptionHandler { SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void DeoptimizeStack() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void UpdateInstrumentationStack() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void DoLongJump() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + NO_RETURN void DoLongJump() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void SetHandlerQuickFrame(StackReference<mirror::ArtMethod>* handler_quick_frame) { handler_quick_frame_ = handler_quick_frame; diff --git a/runtime/runtime.h b/runtime/runtime.h index 118c838397..e6304bd153 100644 --- a/runtime/runtime.h +++ b/runtime/runtime.h @@ -28,6 +28,7 @@ #include "arch/instruction_set.h" #include "base/allocator.h" +#include "base/macros.h" #include "compiler_callbacks.h" #include "gc_root.h" #include "instrumentation.h" @@ -185,7 +186,7 @@ class Runtime { // Aborts semi-cleanly. Used in the implementation of LOG(FATAL), which most // callers should prefer. - [[noreturn]] static void Abort() LOCKS_EXCLUDED(Locks::abort_lock_); + NO_RETURN static void Abort() LOCKS_EXCLUDED(Locks::abort_lock_); // Returns the "main" ThreadGroup, used when attaching user threads. jobject GetMainThreadGroup() const; diff --git a/runtime/thread.cc b/runtime/thread.cc index cb6ed64f60..3b48f49fb4 100644 --- a/runtime/thread.cc +++ b/runtime/thread.cc @@ -2044,8 +2044,6 @@ void Thread::QuickDeliverException() { } exception_handler.UpdateInstrumentationStack(); exception_handler.DoLongJump(); - LOG(FATAL) << "UNREACHABLE"; - UNREACHABLE(); } Context* Thread::GetLongJumpContext() { diff --git a/runtime/thread.h b/runtime/thread.h index 26b7b6f22c..83cedbb7f2 100644 --- a/runtime/thread.h +++ b/runtime/thread.h @@ -353,7 +353,7 @@ class Thread { } // Find catch block and perform long jump to appropriate exception handle - void QuickDeliverException() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + NO_RETURN void QuickDeliverException() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); Context* GetLongJumpContext(); void ReleaseLongJumpContext(Context* context) { diff --git a/runtime/thread_list.cc b/runtime/thread_list.cc index 05a0bff135..d0f014ab11 100644 --- a/runtime/thread_list.cc +++ b/runtime/thread_list.cc @@ -228,8 +228,7 @@ void ThreadList::AssertThreadsAreSuspended(Thread* self, Thread* ignore1, Thread #if HAVE_TIMED_RWLOCK // Attempt to rectify locks so that we dump thread list with required locks before exiting. -static void UnsafeLogFatalForThreadSuspendAllTimeout() __attribute__((noreturn)); -static void UnsafeLogFatalForThreadSuspendAllTimeout() { +NO_RETURN static void UnsafeLogFatalForThreadSuspendAllTimeout() { Runtime* runtime = Runtime::Current(); std::ostringstream ss; ss << "Thread suspend timeout\n"; |