<code root>/dalvik/vm/Sync.cpp
에 정렬 왜하는 struct Monitor
가 : Monitor
가 8 바이트로 정렬 왜 이해할 수 없다달빅 모니터가 8 바이트 경계
struct Monitor {
Thread* owner; /* which thread currently owns the lock? */
int lockCount; /* owner's recursive lock depth */
Object* obj; /* what object are we part of [debug only] */
Thread* waitSet; /* threads currently waiting on this monitor */
pthread_mutex_t lock;
Monitor* next;
/*
* Who last acquired this monitor, when lock sampling is enabled.
* Even when enabled, ownerMethod may be NULL.
*/
const Method* ownerMethod;
u4 ownerPc;
};
. 모든 멤버 (포인터, int
& pthread_mutex_t
)의 길이가 4 바이트이기 때문에 4 바이트 씩 정렬해야한다고 생각합니다.
답장을 보내 주셔서 감사합니다. 하지만 모니터의 모든 구성원은 4 바이트이므로 모니터는 4 바이트로 정렬해야합니다. 왜 dalvik은 모니터의 주소를 8로 지정할 수 있습니까? – Ray
@ 레이 내 생각 엔 컴파일러가 패딩 바이트를 추가하고 있다는 것입니다. – 0x499602D2
@ 0x499602D2 멤버 패딩과 아무 관련이 없음 – laalto