출처: Android Open Source code, dalvik/doc/dexopt.hml

Dalvik Optimization and Verification


Dalvik Optimization and Verification with dexopt


  • class 데이터(특히 bytecode), 는 시스템 메모리 사용을 최소화하기 위해 프로세스간 공유함
  • app을 띄울때 응답성을 높이기 위해 overhead를 줄임
  • class 데이터를 각 개개별의 파일에 저장할 경우 낭비가 심하여, 이를 방지함
  • class 데이터 파싱을 하면 class 로딩 시에 많은 overhead가 발생하므로, C 타입의 data value로 처리하는게 유리함
  • Bytecode verification은 필요하나 느리므로, app의 실행외에 verify 하는 방향으로 추진
  • Bytecode 최적화는 속도와 배터리 수명을 위해 매우 중요함
  • 보안을 위해 프로세스는 공유 코드를 못 고침

일반적인 VM implementation은 compressed archive 에서 (uncompressed) individual classes를 꺼내와 heap에 저장함.
이는 곧, 모든 프로세스마다 각 class들의 카피를 가지고 있고, app이 시작할때 코드의 압축을 풀어야 하기 때문에 느림.  반면에 로컬 heap에 bytecode를 가지고 있으면, rewrite 하기 쉽다는 장점이 있음
 

결론적으로 다음과 같은 결과물이 필요하다.


  • multiple class들은 하나의 "DEX" file로 통합됨
  • DEX 파일은 read-only로 맵핑되며 프로세스간에 공유됨
  • Byte ordering 과 word alignment는 local system에 맞게 변경가능함
  • Bytecode verification은 필요하나 "pre-verify"를 함
  • bytecode를 rewrite해야 하는 최적화는 반드시 선행되어야 함

VM Operation


어플리케이션 코드는 어플이름.jar 혹은 어플이름.apk 로 시스템이 전달되는데, 이는 단지 어플이름.zip 에 meta-data를 첨가한 것이다.  Dalvik DEX data 파일은 항상 clases.dex라고 표기된다.

bytecode는 zip 형태로 데이터가 압축되어 있고, 파일의 시작이 word-aligned가 아닐 수 있으므로, 메모리 맵핑되거나 zip 파일로부터 곧바로 실행이 불가능하다.  그러므로 classes.dex를 압축해제 하고 필요한 다른 액션(예를 들어 realignment, optimization, verification등)을 취해줘야 한다.  그럼 누가 이런 결과물을 만들어내고 저장해야 하는가??


Preparation


"preapred" DEX file을 생성하는데는 적어도 3가지의 방법이 있다.


  1. VM 이 'Just-In-Time'(보통 JIT)을 통해 dalvik-cache 디렉터리에 결과물을 저장. desktop이나 engineering-only 디바이스에 적합하다.(dalvik-cache의 퍼미션 문제로 양산품에는 적용불가함)
  2. dalvik-cache에 쓸 권한을 가진 시스템 인스톨러가 어플리케이션이 처음 추가되었을 때 한다. 
  3. classes.dex를 제외한 관련 jar나 apk파일들을 이용해  빌드시스템이 선행적으로 진행한다. optimized DEX 파일은 오리지널 zip 아카이브 옆에 놓이며, 시스템 이미지의 일부분이 된다.

dalvik-cache 디렉터리는 $ANDROID_DATA/data/dalvik-cache이다.  이 디렉터리 안의 파일 이름은 source DEX의 full path를 사용하며, 이 디렉터리는 system을 owner로 0771 권한을 가지고 있다.  안의 optimized DEX 파일들은 system이 owner이며 application 이 gropu으로, 0644 권한을 가지고 있다.




'안드로이드 > 프레임워크' 카테고리의 다른 글

Bionic libc (2)  (0) 2012.11.08
Bionic libc  (0) 2012.10.30
안드로이드 init.rc (oom_adj값)  (0) 2012.09.27
안드로이드 바인더 ipc  (0) 2011.10.23
안드로이드 프레임워크 *Java에서 전처리기 사용하기*  (0) 2011.06.06
Posted by code cat
프로그래밍/JAVA2012. 8. 6. 10:41

https://developers.google.com/java-dev-tools/download-wbpro 에서 알려준 링크


Eclipse 3.7 (Indigo)


http://dl.google.com/eclipse/inst/d2wbpro/latest/3.7


를 사용하면 다음과 같이 인스톨이 제대로 되지 않는다.  


Cannot complete the install because one or more required items could not be found.



이는 WindowBuilder Pro에서 필요한 컴포넌트들이 WindowBuilder Pro 사이트에 존재하지 않아서 이다.


대신, eclipse Indigo 사이트에서 다운을 받아보자.



indigo관련 릴리즈들이 많아서 처음에 오래 걸린다.


리스트가 뜨면, Filter에 WindowBuilder 와 SWT 와 Swing 등으로 필터를 걸고 찾아서 인스톨 하면 된다.



'프로그래밍 > JAVA' 카테고리의 다른 글

OTA Package Utility  (0) 2013.11.25
Swing desiginer LookAndFeel 종류  (0) 2013.11.19
Java Generics  (0) 2012.10.01
ant 빌드가 안될 때  (0) 2011.10.19
Posted by code cat

최근에 svn 버젼을 보니 폴더마다 .svn이 사라진 거 같다.  그러나 아직 예전 .svn 저장소를 쓰는 이들을 위해 다음과 같은 명령어가 유용하게 쓰일 수 있겠다. 


(실제로, 얼마전 svn 으로 관리되는 코드를 git으로 바꿀 때 써먹었다.)


하위 폴더까지 .svn 지우기

 

rm -rf `find . -type d -name .svn`


Posted by code cat

tar 압출 풀기

tar xfj arm-2012.03-57-arm-none-linux-gnueabi-i686-pc-linux-gnu

 

/opt/ 밑으로 옮기기

mv arm-2012.03 /opt/


환경설정

vi ~/.bashrc

export PATH=/opt/arm-2012.03/bin:$PATH
# source ~/.bashrc

 

arm-none 정도 쳐보고 tab쳐서 나오면 패스 설정은 제대로 됬음을 확인 할 수 있다.

Posted by code cat


ctrl + q를 눌러주면 된다.  자세한 내용은 아래를 참조하자.

Screen CTRL-S Bug

When switching between terminals and text editors the occasional ctrl-s gets accidentally typed into the terminal. For along time I thought that this was a bug in screen but it is a standard terminal feature. Ctrl-s calls the software flow control method XOFF which stops the character flow to the terminal, which when you did not realise what you pressed just seems to freeze the terminal.

ctrl-q calls XON and starts the terminal again.

For a more permanent fix you can add this to your .bashrc (not sure how other shells are effected).

stty ixany

Which allows any character to call XON, so the character press is sent and displayed and you will never be aware of the terminal freezing.

If this does not work for you, or you also don't seem to be able to send ctrl-s ctrl-q commands to terminal applications you can use
stty stop undef To unmap ctrl-s
stty start undef To unmap ctrl-q

Or to stop XOFF and XON being sent from the keyboard but still allowing other software to send the commands use
stty ixoff -ixon
NB: ctrl-q can now be used to shutdown rtorrent

'리눅스 > 스크립트/유틸' 카테고리의 다른 글

.svn 지우기  (0) 2012.08.05
Code Sourcery 설치하기  (0) 2012.07.31
vi 검색한 내용 copy, paste 하기  (0) 2012.07.02
samba 로그인 정보 지우기/보기  (0) 2012.06.23
SVN in conflict  (0) 2012.06.21
Posted by code cat