View Javadoc

1   // ObjectLayout.java, created Mon Feb  5 23:23:19 2001 by joewhaley
2   // Copyright (C) 2001-3 John Whaley <jwhaley@alum.mit.edu>
3   // Licensed under the terms of the GNU LGPL; see COPYING for details.
4   package joeq.Allocator;
5   
6   /*** This interface contains constants that define the joeq object layout.
7    *  You can play with these constants to experiment with different object layouts.
8    *
9    * @author  John Whaley <jwhaley@alum.mit.edu>
10   * @version $Id: ObjectLayout.java 1449 2004-03-09 04:04:18Z jwhaley $
11   */
12  public abstract class ObjectLayout {
13  
14      /***** OFFSETS ****/
15      
16      /*** Offset of array length word, in bytes. */
17      public static final int ARRAY_LENGTH_OFFSET = -12;
18      /*** Offset of status word, in bytes. */
19      public static final int STATUS_WORD_OFFSET = -8;
20      /*** Offset of vtable, in bytes. */
21      public static final int VTABLE_OFFSET = -4;
22      /*** Offset of array element 0, in bytes. */
23      public static final int ARRAY_ELEMENT_OFFSET = 0;
24  
25      
26      /***** HEADER SIZES ****/
27      
28      /*** Size of (non-array) object header, in bytes. */
29      public static final int OBJ_HEADER_SIZE = 8;
30      /*** Size of array header, in bytes. */
31      public static final int ARRAY_HEADER_SIZE = 12;
32  
33      
34      /***** STATUS BITS ****/
35      
36      /*** Object has been hashed.  If it moves, we need to store the old address. */
37      public static final int HASHED       = 0x00000001;
38      /*** Object has been hashed and later moved.  The hash code is stored just past the object. */
39      public static final int HASHED_MOVED = 0x00000002;
40      /*** Bit in object header for use by GC. */
41      public static final int GC_BIT       = 0x00000004;
42      /*** Mask for status flags. */
43      public static final int STATUS_FLAGS_MASK = 0x00000007;
44  
45      
46      /***** LOCKING ****/
47      
48      /*** Bit location of thread id in the status word. */
49      public static final int THREAD_ID_SHIFT   = 9;
50      /*** Mask of the thread id in the status word. */
51      public static final int THREAD_ID_MASK    = 0x7FFFFE00;
52      /*** Mask of the lock count in the status word. */
53      public static final int LOCK_COUNT_MASK   = 0x000001F0;
54      /*** Value to add to status word to increment lock count by one. */
55      public static final int LOCK_COUNT_INC    = 0x00000010;
56      /*** Bit location of lock count in the status word. */
57      public static final int LOCK_COUNT_SHIFT  = 4;
58      /*** Lock has been expanded.
59       *  Masking out this value and the status flags mask gives the address of the expanded lock structure. */
60      public static final int LOCK_EXPANDED     = 0x80000000;
61     
62  }