Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: Bootstrap/BootstrapHeapAddress.java


1   // BootstrapHeapAddress.java, created Wed Sep 18  1:22:47 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 Bootstrap;
5   
6   import Clazz.jq_Class;
7   import Memory.Address;
8   import Memory.HeapAddress;
9   import Util.Assert;
10  import Util.Strings;
11  
12  /**
13   * BootstrapHeapAddress
14   *
15   * @author  John Whaley <jwhaley@alum.mit.edu>
16   * @version $Id: BootstrapHeapAddress.java,v 1.7 2003/03/05 08:41:34 joewhaley Exp $
17   */
18  public class BootstrapHeapAddress extends HeapAddress implements BootstrapAddress {
19  
20      public static BootstrapHeapAddressFactory FACTORY = new BootstrapHeapAddressFactory(BootImage.DEFAULT);
21      
22      public static class BootstrapHeapAddressFactory extends HeapAddressFactory {
23          BootImage bi;
24          public BootstrapHeapAddressFactory(BootImage bi) {
25              Assert._assert(bi != null);
26              this.bi = bi;
27          }
28          public int size() { return 4; }
29          public int logSize() { return 2; }
30          public int pageAlign() { return 12; }
31          public HeapAddress getNull() { return NULL; }
32          public HeapAddress addressOf(Object o) {
33              //if (o == null) return NULL;
34              return bi.getOrAllocateObject(o);
35          }
36          public HeapAddress address32(int v) {
37              return new BootstrapHeapAddress(v);
38          }
39          public static final BootstrapHeapAddress NULL = new BootstrapHeapAddress(0);
40      }
41      
42      public final int value;
43      
44      public BootstrapHeapAddress(int value) { this.value = value; }
45      
46      public Address peek() { Assert.UNREACHABLE(); return null; }
47      public byte    peek1() { Assert.UNREACHABLE(); return 0; }
48      public short   peek2() { Assert.UNREACHABLE(); return 0; }
49      public int     peek4() { Assert.UNREACHABLE(); return 0; }
50      public long    peek8() { Assert.UNREACHABLE(); return 0; }
51      
52      public void poke(Address v) { Assert.UNREACHABLE(); }
53      public void poke1(byte v) { Assert.UNREACHABLE(); }
54      public void poke2(short v) { Assert.UNREACHABLE(); }
55      public void poke4(int v) { Assert.UNREACHABLE(); }
56      public void poke8(long v) { Assert.UNREACHABLE(); }
57      
58      public Address offset(int offset) { return new BootstrapHeapAddress(value+offset); }
59      public Address align(int shift) {
60          int mask = (1 << shift) - 1;
61          return new BootstrapHeapAddress((value+mask)&~mask);
62      }
63      public int difference(Address v) { return this.value - v.to32BitValue(); }
64      public boolean isNull() { return value == 0; }
65      
66      public int to32BitValue() { return value; }
67      public String stringRep() { return Strings.hex8(value); }
68      
69      public static final jq_Class _class;
70      static {
71          _class = (jq_Class) PrimordialClassLoader.loader.getOrCreateBSType("LBootstrap/BootstrapHeapAddress;");
72      }
73  }