View Javadoc

1   // HeapAddress.java, created Wed Sep 18  1:22:46 2002 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.Memory;
5   
6   import joeq.Class.PrimordialClassLoader;
7   import joeq.Class.jq_Class;
8   import joeq.Class.jq_Reference;
9   import joeq.Class.jq_StaticField;
10  
11  /***
12   * @author  John Whaley <jwhaley@alum.mit.edu>
13   * @version $Id: HeapAddress.java 1538 2004-03-23 11:48:23Z joewhaley $
14   */
15  public class HeapAddress extends Address {
16  
17      public static HeapAddressFactory FACTORY;
18  
19      public abstract static class HeapAddressFactory {
20          public abstract int size();
21  
22          public abstract int logSize();
23          
24          public abstract int pageAlign();
25  
26          public abstract HeapAddress getNull();
27  
28          public abstract HeapAddress addressOf(Object o);
29  
30          public abstract HeapAddress address32(int val);
31      }
32  
33      public static final int size() {
34          return FACTORY.size();
35      }
36  
37      public static final int logSize() {
38          return FACTORY.logSize();
39      }
40      
41      public static final int pageAlign() {
42          return FACTORY.pageAlign();
43      }
44      
45      public static final HeapAddress getNull() {
46          return FACTORY.getNull();
47      }
48  
49      public static final HeapAddress addressOf(Object o) {
50          return FACTORY.addressOf(o);
51      }
52  
53      public static final HeapAddress address32(int val) {
54          return FACTORY.address32(val);
55      }
56  
57      public native Object asObject();
58  
59      public native jq_Reference asReferenceType();
60  
61      public native void atomicAdd(int v);
62  
63      public native void atomicSub(int v);
64  
65      public native void atomicAnd(int v);
66  
67      public native int atomicCas4(int before, int after);
68  
69      public native long atomicCas8(long before, long after);
70  
71      public native Address peek();
72  
73      public native byte peek1();
74  
75      public native short peek2();
76  
77      public native int peek4();
78  
79      public native long peek8();
80  
81      public native void poke(Address v);
82  
83      public native void poke1(byte v);
84  
85      public native void poke2(short v);
86  
87      public native void poke4(int v);
88  
89      public native void poke8(long v);
90  
91      public native Address offset(int offset);
92  
93      public native Address align(int shift);
94  
95      public native int difference(Address v);
96  
97      public native boolean isNull();
98  
99      public native int to32BitValue();
100 
101     public native String stringRep();
102 
103     public static final jq_Class _class;
104     public static final jq_StaticField _FACTORY;
105 
106     static {
107         _class = (jq_Class) PrimordialClassLoader.loader.getOrCreateBSType("Ljoeq/Memory/HeapAddress;");
108         _FACTORY = _class.getOrCreateStaticField("FACTORY", "Ljoeq/Memory/HeapAddress$HeapAddressFactory;");
109     }
110 }