Every doc I've found about using Android's atomics says, "stop".

"* A handful of basic atomic operations.  The appropriate pthread
 * functions should be used instead of these whenever possible."

"... we recommend stopping from using these functions entirely. Very fortunately, GCC provides handy intrinsics functions that work with very reasonable performance and always provide a full barrier."

As far as I can tell, there's no code generation change here: both the __sync atomics and the android_ atomics use full memory barriers.  (And now with this all unified, it'll be easier to get the real wins by switching everything to __atomic atomics, which are like __sync atomics but allow control over memory barriers.)

BUG=skia:
R=bungeman@google.com, djsollen@google.com, mtklein@google.com, reed@google.com

Author: mtklein@chromium.org

Review URL: https://codereview.chromium.org/305593002

git-svn-id: http://skia.googlecode.com/svn/trunk@14896 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
commit-bot@chromium.org 2014-05-27 15:55:35 +00:00
Родитель e8765c4654
Коммит 64f6d15451
5 изменённых файлов: 1 добавлений и 59 удалений

Просмотреть файл

@ -305,7 +305,7 @@
'SK_DISABLE_PIXELREF_LOCKCOUNT_BALANCE_CHECK',
'SkLONGLONG int64_t',
'SK_DEFAULT_FONT_CACHE_LIMIT (768 * 1024)',
'SK_ATOMICS_PLATFORM_H "../../src/ports/SkAtomics_android.h"',
'SK_ATOMICS_PLATFORM_H "../../src/ports/SkAtomics_sync.h"',
'SK_MUTEX_PLATFORM_H "../../src/ports/SkMutex_pthread.h"',
# Still need to switch Android to the new name for N32.
'kNative_8888_SkColorType kN32_SkColorType',

Просмотреть файл

@ -80,12 +80,6 @@
'android_deps.gyp:cpu_features',
],
}],
[ 'skia_android_framework', {
'libraries': [
# Required for SkAtomics_android.h
'-lcutils',
],
}],
[ 'skia_arch_type == "arm"', {
# The code in SkUtilsArm.cpp can be used on an ARM-based Linux system, not only Android.
'sources': [

Просмотреть файл

@ -23,7 +23,6 @@
'../src/utils',
],
'sources': [
'../src/ports/SkAtomics_android.h',
'../src/ports/SkAtomics_sync.h',
'../src/ports/SkAtomics_win.h',
'../src/ports/SkMutex_pthread.h',

Просмотреть файл

@ -386,8 +386,6 @@
#ifndef SK_ATOMICS_PLATFORM_H
# if defined(_MSC_VER)
# define SK_ATOMICS_PLATFORM_H "../../src/ports/SkAtomics_win.h"
# elif defined(SK_BUILD_FOR_ANDROID_FRAMEWORK)
# define SK_ATOMICS_PLATFORM_H "../../src/ports/SkAtomics_android.h"
# else
# define SK_ATOMICS_PLATFORM_H "../../src/ports/SkAtomics_sync.h"
# endif

Просмотреть файл

@ -1,49 +0,0 @@
/*
* Copyright 2013 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkAtomics_android_DEFINED
#define SkAtomics_android_DEFINED
/** Android framework atomics. */
#include <cutils/atomic.h>
#include <stdint.h>
static inline __attribute__((always_inline)) int32_t sk_atomic_inc(int32_t* addr) {
return android_atomic_inc(addr);
}
static inline __attribute__((always_inline)) int32_t sk_atomic_add(int32_t* addr, int32_t inc) {
return android_atomic_add(inc, addr);
}
static inline __attribute__((always_inline)) int32_t sk_atomic_dec(int32_t* addr) {
return android_atomic_dec(addr);
}
static inline __attribute__((always_inline)) void sk_membar_acquire__after_atomic_dec() {
//HACK: Android is actually using full memory barriers.
// Should this change, uncomment below.
//int dummy;
//android_atomic_acquire_store(0, &dummy);
}
static inline __attribute__((always_inline)) bool sk_atomic_cas(int32_t* addr,
int32_t before,
int32_t after) {
// android_atomic_release_cas returns 0 for success (if *addr == before and it wrote after).
return android_atomic_release_cas(before, after, addr) == 0;
}
static inline __attribute__((always_inline)) void sk_membar_acquire__after_atomic_conditional_inc() {
//HACK: Android is actually using full memory barriers.
// Should this change, uncomment below.
//int dummy;
//android_atomic_acquire_store(0, &dummy);
}
#endif