android


Native components, armeabi-v7a, and thumb?


When APP_ABI includes armeabi-v7a, Android's build system will include -mthumb as a compile option.
ARMv7-a is a 32-bit processor family. Why does Android use -mthumb rather than -marm?
Must native components compiled with the NDK use -mthumb? Or is it OK to use -marm?
If -marm is OK, do any interworking options need to be present?
Android uses -mthumb because it produces more compact code. The bitness of the processor has nothing to do with it.
In the normal ARM instruction set, each instruction is 32 bit, and each instruction is quite expressive (there's different instructions to do a lot of different things). Unfortunatey this also means that the code can be a bit large, since every single instruction takes 4 bytes.
The thumb instruction set was introduced to work around this issue - here each instruction is only 16 bits long, thus you can fit twice as many instructions in the same space, but since the instructions are shorter, there's not as many different instructions. Each instruction still operates on 32 bit registers and otherwise behaves exactly like the ARM instructions, so it's just a different, more compact way to write (mostly) a subset of the ARM instructions. Due to the limited number of instructions, most things tend to need a bit more instructions than in ARM mode. So depending on what the code actually does, the actual reduction in code size isn't exactly 50%. Also, since there may be more instructions than before, it may actually run slower than before. (But since it's smaller, it uses less instruction cache, which might on the other hand benefit performance.)
In practice, Thumb code tended to be slower than ARM code, but more compact, so for code where size mattered more than speed, you'd use Thumb.
Since Thumb2 (which is available in ARMv7), there's a bit more expressiveness in the Thumb instruction set, so the performance difference is smaller - this is why it's enabled by default in Android - in almost all cases it reduces the code size without significantly affecting the performance. If you've got some really performance critical code, you might want to benchmark to see if it hurts or helps for you. (For building with ndk-build and Android.mk, check the LOCAL_ARM_MODE variable.)
If you build code manually, you can choose whether you add -mthumb or -marm, and AFAIK you don't need any extra interworking options regardless of which one of them you choose.

Related Links

same item value when accessed with getIntent() in other activity
Using a different bank account per app in Google Play
Android - My application crashes if i pause, clear cache and resume
Remove ActionBar icon API < 11
appWidgetManager.updateAppWidget has no effect
How do you load Javascript into android webview?
How to make a bluetooth connection in android?
PhoneStateListener is not working when inherited from another class
Insert Data to android sqlite database doesn't work
Can we make a listview behave like expandablelistview
Button to go back to the previous page
android-what is the role of xmlns:myapp in xml layout file
Android softkeyboard shows (A -Z) text with(1-9) digits after giving input type =“numberpassword”
Android creating text file
worklight auto-generated android folder does not run on avd [duplicate]
Android call onClick method without Clicking

Categories

HOME
beautifulsoup
httparty
facebook-oauth
twitter-bootstrap-3
jpa
checkstyle
rdbms
angular-formly
socket.io
grafana
replace
nsbundle
regular-language
spring-session
special-characters
syntaxnet
pega
java.util.logging
redis-sentinel
ipmitool
altera
linear-algebra
dynamic-sql
foreign-keys
google-maps-autocomplete
kendo-mobile
scriptella
monit
beautifier
bioinformatics
custom-controls
postback
complex-numbers
powershell-ise
database-comparison
autolisp
laravel-eloquent
twos-complement
instantiation
navigator
openerp-7
apic
recurrent-neural-network
apns-php
css-position
linq-to-objects
odoo-website
mongotemplate
azure-cli
java-6
edit
arules
stripe-connect
custom-lists
ziparchive
preprocessor
resourcemanager
windows-azure-queues
i386
hclust
installshield-2010
gogs
clipboard.js
query-by-example
hadoop-partitioning
upx
createprocess
pushbots
invoke-sqlcmd
false-sharing
blitline
boomerang
sciruby
rewrite
poppler
extjs-grid
vacuum
keyup
alloy-ui
ms-access-2000
exceldatareader
mass-assignment
at-job
big-ip
android-usb
mbunit
wp7test
superscrollorama
mysql-error-2013
virtual-pc
alice
bjyauthorize
onmousemove
wcf-configuration
garbage
predicatebuilder
flex-mobile
screen-size
creole
cuteeditor
socketserver
scrollbars
blender-2.49
xpsdocument

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App