summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2014-11-17 23:02:16 +0300
committerIvan Maidanski <ivmai@mail.ru>2014-11-17 23:02:16 +0300
commit0322b83386fde8b8ed89ed742933fc2cae81afbd (patch)
treecb3a73552ba3103681a75efcf43764096bef3b3d
parent946796d0d5ad3b2848bc841bd871c0cd43a758ac (diff)
downloadbdwgc-0322b83386fde8b8ed89ed742933fc2cae81afbd.tar.gz
GC_stack_range_for iOS 32/64-bit code refactoring (Darwin/arm)
* darwin_stop_world.c (kCFCoreFoundationVersionNumber_iOS_8_0): Move definition out of GC_stack_range_for. * darwin_stop_world.c (GC_stack_range_for): Refine comment and abort message; eliminate code duplication regarding thread_get_state call.
-rw-r--r--darwin_stop_world.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/darwin_stop_world.c b/darwin_stop_world.c
index 57548990..b4799d96 100644
--- a/darwin_stop_world.c
+++ b/darwin_stop_world.c
@@ -122,6 +122,10 @@ GC_API void GC_CALL GC_use_threads_discovery(void)
# endif
}
+#ifndef kCFCoreFoundationVersionNumber_iOS_8_0
+# define kCFCoreFoundationVersionNumber_iOS_8_0 1140.1
+#endif
+
/* Evaluates the stack range for a given thread. Returns the lower */
/* bound and sets *phi to the upper one. */
STATIC ptr_t GC_stack_range_for(ptr_t *phi, thread_act_t thread, GC_thread p,
@@ -146,45 +150,41 @@ STATIC ptr_t GC_stack_range_for(ptr_t *phi, thread_act_t thread, GC_thread p,
/* everywhere. Hence we use our own version. Alternatively, */
/* we could use THREAD_STATE_MAX (but seems to be not optimal). */
kern_return_t kern_result;
- mach_msg_type_number_t thread_state_count = GC_MACH_THREAD_STATE_COUNT;
GC_THREAD_STATE_T state;
# if defined(ARM32) && defined(ARM_THREAD_STATE32)
-# ifndef kCFCoreFoundationVersionNumber_iOS_8_0
-# define kCFCoreFoundationVersionNumber_iOS_8_0 1140.1
-# endif
- /* Use ARM_UNIFIED_THREAD_STATE on iOS7 64-bit and up and iOS8 */
- /* 32-bit and up. iOS7 was the first iOS with 64-bit support so */
- /* if we run on a 64-bit CPU we know we're on iOS7 or higher. */
+ /* Use ARM_UNIFIED_THREAD_STATE on iOS8+ 32-bit targets and on */
+ /* 64-bit H/W (iOS7+ 32-bit mode). */
size_t size;
static cpu_type_t cputype = 0;
+
if (cputype == 0) {
sysctlbyname("hw.cputype", &cputype, &size, NULL, 0);
}
- if (cputype == CPU_TYPE_ARM64 || kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_8_0) {
+ if (cputype == CPU_TYPE_ARM64
+ || kCFCoreFoundationVersionNumber
+ >= kCFCoreFoundationVersionNumber_iOS_8_0) {
arm_unified_thread_state_t unified_state;
- mach_msg_type_number_t unified_thread_state_count = ARM_UNIFIED_THREAD_STATE_COUNT;
+ mach_msg_type_number_t unified_thread_state_count
+ = ARM_UNIFIED_THREAD_STATE_COUNT;
+
kern_result = thread_get_state(thread, ARM_UNIFIED_THREAD_STATE,
(natural_t *)&unified_state,
&unified_thread_state_count);
if (unified_state.ash.flavor != ARM_THREAD_STATE32) {
- // Sanity check. The flavor in the header should always be ARM_THREAD_STATE32
- ABORT("unified_state.ash.flavor != ARM_THREAD_STATE32");
+ ABORT("unified_state flavor should be ARM_THREAD_STATE32");
}
state = unified_state.ts_32;
- thread_state_count = unified_state.ash.count;
- } else {
- kern_result = thread_get_state(thread, ARM_THREAD_STATE,
- (natural_t *)&state,
- &thread_state_count);
- }
-# else
-
- /* Get the thread state (registers, etc) */
- kern_result = thread_get_state(thread, GC_MACH_THREAD_STATE,
- (natural_t *)&state,
- &thread_state_count);
+ } else
# endif
+ /* else */ {
+ mach_msg_type_number_t thread_state_count = GC_MACH_THREAD_STATE_COUNT;
+
+ /* Get the thread state (registers, etc) */
+ kern_result = thread_get_state(thread, GC_MACH_THREAD_STATE,
+ (natural_t *)&state,
+ &thread_state_count);
+ }
# ifdef DEBUG_THREADS
GC_log_printf("thread_get_state returns value = %d\n", kern_result);
# endif