diff options
author | Carl Shapiro <cshapiro@google.com> | 2009-12-21 11:42:59 -0800 |
---|---|---|
committer | Carl Shapiro <cshapiro@google.com> | 2009-12-21 15:43:29 -0800 |
commit | 94338aadf8355b28846f0d21c49142ca29479dc4 (patch) | |
tree | bfc4e126727a3758c21c3f51a111dea7bef41d11 /vm/Sync.h | |
parent | 2692bae61c54b358248ec57de07e7e4b5dc18c2d (diff) | |
download | android_dalvik-94338aadf8355b28846f0d21c49142ca29479dc4.tar.gz android_dalvik-94338aadf8355b28846f0d21c49142ca29479dc4.tar.bz2 android_dalvik-94338aadf8355b28846f0d21c49142ca29479dc4.zip |
Repurpose bits 1 and 2 of the lockword for encoding the hash state of
an object. Invert the meaning of the shape bit to match the encoding
scheme described in Bacon's paper. Consequently, monitor pointers
must have the lower 3 bits stripped before they may be dereferenced.
Diffstat (limited to 'vm/Sync.h')
-rw-r--r-- | vm/Sync.h | 35 |
1 files changed, 30 insertions, 5 deletions
@@ -19,6 +19,29 @@ #ifndef _DALVIK_SYNC #define _DALVIK_SYNC +#define LW_SHAPE_THIN 0 +#define LW_SHAPE_FAT 1 +#define LW_SHAPE_MASK 0x1 +#define LW_SHAPE(x) ((x) & LW_SHAPE_MASK) + +#define LW_HASH_STATE_UNHASHED 0 +#define LW_HASH_STATE_HASHED 1 +#define LW_HASH_STATE_HASHED_AND_MOVED 2 +#define LW_HASH_STATE_MASK 0x3 +#define LW_HASH_STATE_SHIFT 1 +#define LW_HASH_STATE(x) (((x) >> LW_HASH_STATE_SHIFT) & LW_HASH_STATE_MASK) + +#define LW_MONITOR(x) \ + ((Monitor*)((x) & ~((LW_HASH_STATE_MASK << LW_HASH_STATE_SHIFT) | LW_SHAPE_MASK))) + +#define LW_LOCK_OWNER_MASK 0xffff +#define LW_LOCK_OWNER_SHIFT 3 +#define LW_LOCK_OWNER(x) (((x) >> LW_LOCK_OWNER_SHIFT) & LW_LOCK_OWNER_MASK) + +#define LW_LOCK_COUNT_MASK 0x1fff +#define LW_LOCK_COUNT_SHIFT 19 +#define LW_LOCK_COUNT(x) (((x) >> LW_LOCK_COUNT_SHIFT) & LW_LOCK_COUNT_MASK) + struct Object; struct Monitor; struct Thread; @@ -43,18 +66,15 @@ typedef union Lock { * This is necessary for thin locking. */ #define THIN_LOCKING 1 -#if THIN_LOCKING -#define DVM_LOCK_INITIAL_THIN_VALUE (0x1) -#else #define DVM_LOCK_INITIAL_THIN_VALUE (0) -#endif + #define DVM_LOCK_INIT(lock) \ do { (lock)->thin = DVM_LOCK_INITIAL_THIN_VALUE; } while (0) /* * Returns true if the lock has been fattened. */ -#define IS_LOCK_FAT(lock) (((lock)->thin & 1) == 0 && (lock)->mon != NULL) +#define IS_LOCK_FAT(lock) (((lock)->thin & 1) == 1 && (lock)->mon != NULL) /* * Acquire the object's monitor. @@ -75,6 +95,11 @@ void dvmObjectNotify(struct Thread* self, struct Object* obj); void dvmObjectNotifyAll(struct Thread* self, struct Object* obj); /* + * Implementation of System.identityHashCode(). + */ +u4 dvmIdentityHashCode(struct Object* obj); + +/* * Implementation of Thread.sleep(). */ void dvmThreadSleep(u8 msec, u4 nsec); |