changeset 12568:30810338dfa9

Merge.
author Christian Humer <christian.humer@gmail.com>
date Thu, 24 Oct 2013 22:28:09 +0200
parents 0d3e4d940925 (current diff) 6264d434aca2 (diff)
children 04e51b3026c0
files
diffstat 32 files changed, 1539 insertions(+), 749 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java	Thu Oct 24 16:01:44 2013 +0200
+++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java	Thu Oct 24 22:28:09 2013 +0200
@@ -1189,6 +1189,7 @@
                 return new Iterator<NodeClass.Position>() {
                     int i = 0;
 
+                    @Override
                     public void remove() {
                         throw new UnsupportedOperationException();
                     }
@@ -1219,6 +1220,7 @@
                 return new Iterator<NodeClass.Position>() {
                     int i = 0;
 
+                    @Override
                     public void remove() {
                         throw new UnsupportedOperationException();
                     }
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java	Thu Oct 24 16:01:44 2013 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java	Thu Oct 24 22:28:09 2013 +0200
@@ -252,7 +252,7 @@
     /**
      * @param installedCodeOwner see {@link Backend#emitCode}
      */
-    protected void emitCodePrefix(ResolvedJavaMethod installedCodeOwner, TargetMethodAssembler tasm, AMD64MacroAssembler asm, RegisterConfig regConfig, HotSpotVMConfig config, Label verifiedStub) {
+    public void emitCodePrefix(ResolvedJavaMethod installedCodeOwner, TargetMethodAssembler tasm, AMD64MacroAssembler asm, RegisterConfig regConfig, HotSpotVMConfig config, Label verifiedStub) {
         HotSpotProviders providers = getProviders();
         if (installedCodeOwner != null && !isStatic(installedCodeOwner.getModifiers())) {
             tasm.recordMark(Marks.MARK_UNVERIFIED_ENTRY);
@@ -282,14 +282,14 @@
     /**
      * @param installedCodeOwner see {@link Backend#emitCode}
      */
-    protected void emitCodeBody(ResolvedJavaMethod installedCodeOwner, TargetMethodAssembler tasm, LIRGenerator lirGen) {
+    public void emitCodeBody(ResolvedJavaMethod installedCodeOwner, TargetMethodAssembler tasm, LIRGenerator lirGen) {
         lirGen.lir.emitCode(tasm);
     }
 
     /**
      * @param installedCodeOwner see {@link Backend#emitCode}
      */
-    protected void emitCodeSuffix(ResolvedJavaMethod installedCodeOwner, TargetMethodAssembler tasm, LIRGenerator lirGen, AMD64MacroAssembler asm, FrameMap frameMap) {
+    public void emitCodeSuffix(ResolvedJavaMethod installedCodeOwner, TargetMethodAssembler tasm, LIRGenerator lirGen, AMD64MacroAssembler asm, FrameMap frameMap) {
         HotSpotProviders providers = getProviders();
         HotSpotFrameContext frameContext = (HotSpotFrameContext) tasm.frameContext;
         if (frameContext != null && !frameContext.isStub) {
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java	Thu Oct 24 16:01:44 2013 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java	Thu Oct 24 22:28:09 2013 +0200
@@ -265,9 +265,9 @@
         if (linkage.canDeoptimize()) {
             assert info != null || stub != null;
             Register thread = getProviders().getRegisters().getThreadRegister();
-            append(new AMD64HotSpotCRuntimeCallPrologueOp(config.threadLastJavaSpOffset, thread));
+            append(new AMD64HotSpotCRuntimeCallPrologueOp(config.threadLastJavaSpOffset(), thread));
             result = super.emitForeignCall(linkage, info, args);
-            append(new AMD64HotSpotCRuntimeCallEpilogueOp(config.threadLastJavaSpOffset, config.threadLastJavaFpOffset, thread));
+            append(new AMD64HotSpotCRuntimeCallEpilogueOp(config.threadLastJavaSpOffset(), config.threadLastJavaFpOffset(), thread));
         } else {
             result = super.emitForeignCall(linkage, null, args);
         }
@@ -521,7 +521,7 @@
     }
 
     private int getLogMinObjectAlignment() {
-        return config.logMinObjAlignment;
+        return config.logMinObjAlignment();
     }
 
     private int getNarrowOopShift() {
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotSafepointOp.java	Thu Oct 24 16:01:44 2013 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotSafepointOp.java	Thu Oct 24 22:28:09 2013 +0200
@@ -27,6 +27,7 @@
 
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.asm.*;
 import com.oracle.graal.asm.amd64.*;
 import com.oracle.graal.hotspot.*;
 import com.oracle.graal.lir.*;
@@ -57,9 +58,19 @@
         emitCode(tasm, asm, config, false, state, scratch.getRegister());
     }
 
+    /**
+     * Tests if the polling page address can be reached from the code cache with 32-bit
+     * displacements.
+     */
+    private static boolean isPollingPageFar(HotSpotVMConfig config) {
+        final long pollingPageAddress = config.safepointPollingAddress;
+        // TODO return ForceUnreachable ||
+        return !NumUtil.isInt(pollingPageAddress - config.codeCacheLowBoundary()) || !NumUtil.isInt(pollingPageAddress - config.codeCacheHighBoundary());
+    }
+
     public static void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler asm, HotSpotVMConfig config, boolean atReturn, LIRFrameState state, Register scratch) {
         final int pos = asm.codeBuffer.position();
-        if (config.isPollingPageFar) {
+        if (isPollingPageFar(config)) {
             asm.movq(scratch, config.safepointPollingAddress);
             tasm.recordMark(atReturn ? MARK_POLL_RETURN_FAR : MARK_POLL_FAR);
             if (state != null) {
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotLIRGenerator.java	Thu Oct 24 16:01:44 2013 +0200
+++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotLIRGenerator.java	Thu Oct 24 22:28:09 2013 +0200
@@ -60,7 +60,7 @@
         assert access == null || access instanceof HeapAccess;
         if (config.useCompressedOops && isCompressCandidate(access)) {
             Variable scratch = newVariable(Kind.Long);
-            append(new LoadCompressedPointer(kind, result, scratch, loadAddress, state, config.narrowOopBase, config.narrowOopShift, config.logMinObjAlignment));
+            append(new LoadCompressedPointer(kind, result, scratch, loadAddress, state, config.narrowOopBase, config.narrowOopShift, config.logMinObjAlignment()));
         } else {
             append(new LoadOp(kind, result, loadAddress, state));
         }
@@ -74,7 +74,7 @@
         Variable input = load(inputVal);
         if (config.useCompressedOops && isCompressCandidate(access)) {
             Variable scratch = newVariable(Kind.Long);
-            append(new StoreCompressedPointer(kind, storeAddress, input, scratch, state, config.narrowOopBase, config.narrowOopShift, config.logMinObjAlignment));
+            append(new StoreCompressedPointer(kind, storeAddress, input, scratch, state, config.narrowOopBase, config.narrowOopShift, config.logMinObjAlignment()));
         } else {
             append(new StoreOp(kind, storeAddress, input, state));
         }
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java	Thu Oct 24 16:01:44 2013 +0200
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java	Thu Oct 24 22:28:09 2013 +0200
@@ -103,9 +103,9 @@
             HotSpotRegistersProvider registers = getProviders().getRegisters();
             Register thread = registers.getThreadRegister();
             Register stackPointer = registers.getStackPointerRegister();
-            append(new SPARCHotSpotCRuntimeCallPrologueOp(config.threadLastJavaSpOffset, thread, stackPointer));
+            append(new SPARCHotSpotCRuntimeCallPrologueOp(config.threadLastJavaSpOffset(), thread, stackPointer));
             result = super.emitForeignCall(linkage, info, args);
-            append(new SPARCHotSpotCRuntimeCallEpilogueOp(config.threadLastJavaSpOffset, config.threadLastJavaPcOffset, config.threadJavaFrameAnchorFlagsOffset, thread));
+            append(new SPARCHotSpotCRuntimeCallEpilogueOp(config.threadLastJavaSpOffset(), config.threadLastJavaPcOffset(), config.threadJavaFrameAnchorFlagsOffset(), thread));
         } else {
             result = super.emitForeignCall(linkage, null, args);
         }
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotSafepointOp.java	Thu Oct 24 16:01:44 2013 +0200
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotSafepointOp.java	Thu Oct 24 22:28:09 2013 +0200
@@ -61,7 +61,6 @@
     public static void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm, HotSpotVMConfig config, boolean atReturn, LIRFrameState state, Register scratch) {
         final int pos = masm.codeBuffer.position();
         new Setx(config.safepointPollingAddress, scratch).emit(masm);
-        assert !config.isPollingPageFar;
         tasm.recordMark(atReturn ? MARK_POLL_RETURN_NEAR : MARK_POLL_NEAR);
         if (state != null) {
             tasm.recordInfopoint(pos, state, InfopointReason.SAFEPOINT);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Thu Oct 24 16:01:44 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Thu Oct 24 22:28:09 2013 +0200
@@ -22,274 +22,792 @@
  */
 package com.oracle.graal.hotspot;
 
+import static com.oracle.graal.graph.UnsafeAccess.*;
+
 import java.lang.reflect.*;
+import java.util.*;
 
+import com.oracle.graal.graph.*;
 import com.oracle.graal.hotspot.bridge.*;
-import com.sun.management.HotSpotDiagnosticMXBean;
-
-import sun.management.ManagementFactoryHelper;
 
 /**
  * Used to access native configuration details.
  * 
- * All non-static, public fields in this class are final so that they can be compiled as constants.
+ * All non-static, public fields in this class are so that they can be compiled as constants.
  */
-public final class HotSpotVMConfig extends CompilerObject {
+public class HotSpotVMConfig extends CompilerObject {
 
     private static final long serialVersionUID = -4744897993263044184L;
 
-    private static final HotSpotDiagnosticMXBean diagnostic = ManagementFactoryHelper.getDiagnosticMXBean();
+    HotSpotVMConfig(CompilerToVM compilerToVm) {
+        compilerToVm.initializeConfiguration(this);
+
+        // Fill the VM fields hash map.
+        HashMap<String, VMFields.Field> vmFields = new HashMap<>();
+        for (VMFields.Field e : new VMFields(gHotSpotVMStructs)) {
+            vmFields.put(e.getName(), e);
+        }
+
+        // Fill the VM types hash map.
+        HashMap<String, VMTypes.Type> vmTypes = new HashMap<>();
+        for (VMTypes.Type e : new VMTypes(gHotSpotVMTypes)) {
+            vmTypes.put(e.getTypeName(), e);
+        }
+
+        // Fill the VM constants hash map.
+        HashMap<String, AbstractConstant> vmConstants = new HashMap<>();
+        for (AbstractConstant e : new VMIntConstants(gHotSpotVMIntConstants)) {
+            vmConstants.put(e.getName(), e);
+        }
+        for (AbstractConstant e : new VMLongConstants(gHotSpotVMLongConstants)) {
+            vmConstants.put(e.getName(), e);
+        }
+
+        // Fill the flags hash map.
+        HashMap<String, Flags.Flag> flags = new HashMap<>();
+        for (Flags.Flag e : new Flags(vmFields, vmTypes)) {
+            flags.put(e.getName(), e);
+        }
 
-    HotSpotVMConfig(CompilerToVM c2vm) {
-        c2vm.initializeConfiguration(this);
+        for (Field f : HotSpotVMConfig.class.getDeclaredFields()) {
+            if (f.isAnnotationPresent(HotSpotVMField.class)) {
+                HotSpotVMField annotation = f.getAnnotation(HotSpotVMField.class);
+                String name = annotation.name();
+                VMFields.Field entry = vmFields.get(name);
+                if (entry == null) {
+                    if (annotation.optional()) {
+                        continue;
+                    } else {
+                        throw new IllegalArgumentException("field not found: " + name);
+                    }
+                }
+                switch (annotation.get()) {
+                    case OFFSET:
+                        setField(f, entry.getOffset());
+                        break;
+                    case ADDRESS:
+                        setField(f, entry.getAddress());
+                        break;
+                    case VALUE:
+                        setField(f, entry.getValue());
+                        break;
+                    default:
+                        throw GraalInternalError.shouldNotReachHere("unknown kind " + annotation.get());
+                }
+            } else if (f.isAnnotationPresent(HotSpotVMType.class)) {
+                HotSpotVMType annotation = f.getAnnotation(HotSpotVMType.class);
+                String name = annotation.name();
+                VMTypes.Type entry = vmTypes.get(name);
+                if (entry == null) {
+                    throw new IllegalArgumentException("type not found: " + name);
+                }
+                switch (annotation.get()) {
+                    case SIZE:
+                        setField(f, entry.getSize());
+                        break;
+                    default:
+                        throw GraalInternalError.shouldNotReachHere("unknown kind " + annotation.get());
+                }
+            } else if (f.isAnnotationPresent(HotSpotVMConstant.class)) {
+                HotSpotVMConstant annotation = f.getAnnotation(HotSpotVMConstant.class);
+                String name = annotation.name();
+                AbstractConstant entry = vmConstants.get(name);
+                if (entry == null) {
+                    if (annotation.optional()) {
+                        continue;
+                    } else {
+                        throw new IllegalArgumentException("constant not found: " + name);
+                    }
+                }
+                setField(f, entry.getValue());
+            } else if (f.isAnnotationPresent(HotSpotVMFlag.class)) {
+                HotSpotVMFlag annotation = f.getAnnotation(HotSpotVMFlag.class);
+                String name = annotation.name();
+                Flags.Flag entry = flags.get(name);
+                if (entry == null) {
+                    if (annotation.optional()) {
+                        continue;
+                    } else {
+                        throw new IllegalArgumentException("flag not found: " + name);
+                    }
+                }
+                setField(f, entry.getValue());
+            }
+        }
+
         assert check();
     }
 
+    private void setField(Field field, Object value) {
+        try {
+            Class<?> fieldType = field.getType();
+            if (fieldType == boolean.class) {
+                if (value instanceof String) {
+                    field.setBoolean(this, Boolean.valueOf((String) value));
+                } else if (value instanceof Boolean) {
+                    field.setBoolean(this, (boolean) value);
+                } else if (value instanceof Long) {
+                    field.setBoolean(this, ((long) value) != 0);
+                } else {
+                    GraalInternalError.shouldNotReachHere(value.getClass().getSimpleName());
+                }
+            } else if (fieldType == int.class) {
+                if (value instanceof Integer) {
+                    field.setInt(this, (int) value);
+                } else if (value instanceof Long) {
+                    field.setInt(this, (int) (long) value);
+                } else {
+                    GraalInternalError.shouldNotReachHere(value.getClass().getSimpleName());
+                }
+            } else if (fieldType == long.class) {
+                field.setLong(this, (long) value);
+            } else {
+                GraalInternalError.shouldNotReachHere(field.toString());
+            }
+        } catch (IllegalAccessException e) {
+            throw GraalInternalError.shouldNotReachHere(field.toString() + ": " + e);
+        }
+    }
+
     /**
-     * Gets the value of an VM option.
-     * 
-     * @param name option's name
-     * @return value of option
-     * @throws IllegalArgumentException if option doesn't exist
+     * VMStructEntry (see vmStructs.hpp).
      */
-    public static int getVMOptionInt(String name) {
-        String value = diagnostic.getVMOption(name).getValue();
-        return Integer.valueOf(value).intValue();
-    }
+    private long gHotSpotVMStructs;
+    private long gHotSpotVMStructEntryTypeNameOffset;
+    private long gHotSpotVMStructEntryFieldNameOffset;
+    private long gHotSpotVMStructEntryTypeStringOffset;
+    private long gHotSpotVMStructEntryIsStaticOffset;
+    private long gHotSpotVMStructEntryOffsetOffset;
+    private long gHotSpotVMStructEntryAddressOffset;
+    private long gHotSpotVMStructEntryArrayStride;
+
+    class VMFields implements Iterable<VMFields.Field> {
+
+        private long address;
+
+        public VMFields(long address) {
+            this.address = address;
+        }
+
+        public Iterator<VMFields.Field> iterator() {
+            return new Iterator<VMFields.Field>() {
+
+                private int index = 0;
+
+                private Field current() {
+                    return new Field(address + gHotSpotVMStructEntryArrayStride * index);
+                }
+
+                /**
+                 * The last entry is identified by a NULL fieldName.
+                 */
+                public boolean hasNext() {
+                    Field entry = current();
+                    return entry.getFieldName() != null;
+                }
+
+                public Field next() {
+                    Field entry = current();
+                    index++;
+                    return entry;
+                }
+
+                @Override
+                public void remove() {
+                    throw GraalInternalError.unimplemented();
+                }
+            };
+        }
+
+        class Field {
+
+            private long entryAddress;
 
-    /**
-     * Gets the value of an VM option.
-     * 
-     * @param name option's name
-     * @param defaultValue default value if option is not exists (e.g. development options)
-     * @return value of option or defaultValue if option doesn't exist
-     */
-    public static int getVMOption(String name, int defaultValue) {
-        try {
-            return getVMOptionInt(name);
-        } catch (IllegalArgumentException e) {
-            return defaultValue;
+            Field(long address) {
+                this.entryAddress = address;
+            }
+
+            public String getTypeName() {
+                long typeNameAddress = unsafe.getAddress(entryAddress + gHotSpotVMStructEntryTypeNameOffset);
+                return readCStringAsString(typeNameAddress);
+            }
+
+            public String getFieldName() {
+                long fieldNameAddress = unsafe.getAddress(entryAddress + gHotSpotVMStructEntryFieldNameOffset);
+                return readCStringAsString(fieldNameAddress);
+            }
+
+            public String getTypeString() {
+                long typeStringAddress = unsafe.getAddress(entryAddress + gHotSpotVMStructEntryTypeStringOffset);
+                return readCStringAsString(typeStringAddress);
+            }
+
+            public boolean isStatic() {
+                return unsafe.getInt(entryAddress + gHotSpotVMStructEntryIsStaticOffset) != 0;
+            }
+
+            public long getOffset() {
+                return unsafe.getLong(entryAddress + gHotSpotVMStructEntryOffsetOffset);
+            }
+
+            public long getAddress() {
+                return unsafe.getAddress(entryAddress + gHotSpotVMStructEntryAddressOffset);
+            }
+
+            public String getName() {
+                String typeName = getTypeName();
+                String fieldName = getFieldName();
+                return typeName + "::" + fieldName;
+            }
+
+            public long getValue() {
+                String type = getTypeString();
+                switch (type) {
+                    case "int":
+                        return unsafe.getInt(getAddress());
+                    case "address":
+                    case "intptr_t":
+                        return unsafe.getAddress(getAddress());
+                    default:
+                        // All foo* types are addresses.
+                        if (type.endsWith("*")) {
+                            return unsafe.getAddress(getAddress());
+                        }
+                        throw GraalInternalError.shouldNotReachHere(type);
+                }
+            }
+
+            @Override
+            public String toString() {
+                return String.format("Field[typeName=%s, fieldName=%s, typeString=%s, isStatic=%b, offset=%d, address=0x%x]", getTypeName(), getFieldName(), getTypeString(), isStatic(), getOffset(),
+                                getAddress());
+            }
         }
     }
 
     /**
-     * Gets the value of an VM option.
-     * 
-     * @param name option's name
-     * @return value of option
-     * @throws IllegalArgumentException if option doesn't exist
+     * VMTypeEntry (see vmStructs.hpp).
      */
-    public static boolean getVMOption(String name) {
-        String value = diagnostic.getVMOption(name).getValue();
-        return Boolean.valueOf(value).booleanValue();
+    private long gHotSpotVMTypes;
+    private long gHotSpotVMTypeEntryTypeNameOffset;
+    private long gHotSpotVMTypeEntrySuperclassNameOffset;
+    private long gHotSpotVMTypeEntryIsOopTypeOffset;
+    private long gHotSpotVMTypeEntryIsIntegerTypeOffset;
+    private long gHotSpotVMTypeEntryIsUnsignedOffset;
+    private long gHotSpotVMTypeEntrySizeOffset;
+    private long gHotSpotVMTypeEntryArrayStride;
+
+    class VMTypes implements Iterable<VMTypes.Type> {
+
+        private long address;
+
+        public VMTypes(long address) {
+            this.address = address;
+        }
+
+        public Iterator<VMTypes.Type> iterator() {
+            return new Iterator<VMTypes.Type>() {
+
+                private int index = 0;
+
+                private Type current() {
+                    return new Type(address + gHotSpotVMTypeEntryArrayStride * index);
+                }
+
+                /**
+                 * The last entry is identified by a NULL type name.
+                 */
+                public boolean hasNext() {
+                    Type entry = current();
+                    return entry.getTypeName() != null;
+                }
+
+                public Type next() {
+                    Type entry = current();
+                    index++;
+                    return entry;
+                }
+
+                @Override
+                public void remove() {
+                    throw GraalInternalError.unimplemented();
+                }
+            };
+        }
+
+        class Type {
+
+            private long entryAddress;
+
+            Type(long address) {
+                this.entryAddress = address;
+            }
+
+            public String getTypeName() {
+                long typeNameAddress = unsafe.getAddress(entryAddress + gHotSpotVMTypeEntryTypeNameOffset);
+                return readCStringAsString(typeNameAddress);
+            }
+
+            public String getSuperclassName() {
+                long superclassNameAddress = unsafe.getAddress(entryAddress + gHotSpotVMTypeEntrySuperclassNameOffset);
+                return readCStringAsString(superclassNameAddress);
+            }
+
+            public boolean isOopType() {
+                return unsafe.getInt(entryAddress + gHotSpotVMTypeEntryIsOopTypeOffset) != 0;
+            }
+
+            public boolean isIntegerType() {
+                return unsafe.getInt(entryAddress + gHotSpotVMTypeEntryIsIntegerTypeOffset) != 0;
+            }
+
+            public boolean isUnsigned() {
+                return unsafe.getInt(entryAddress + gHotSpotVMTypeEntryIsUnsignedOffset) != 0;
+            }
+
+            public long getSize() {
+                return unsafe.getLong(entryAddress + gHotSpotVMTypeEntrySizeOffset);
+            }
+
+            @Override
+            public String toString() {
+                return String.format("Type[typeName=%s, superclassName=%s, isOopType=%b, isIntegerType=%b, isUnsigned=%b, size=%d]", getTypeName(), getSuperclassName(), isOopType(), isIntegerType(),
+                                isUnsigned(), getSize());
+            }
+        }
+    }
+
+    public abstract class AbstractConstant {
+
+        protected long address;
+        protected long nameOffset;
+        protected long valueOffset;
+
+        AbstractConstant(long address, long nameOffset, long valueOffset) {
+            this.address = address;
+            this.nameOffset = nameOffset;
+            this.valueOffset = valueOffset;
+        }
+
+        public String getName() {
+            long nameAddress = unsafe.getAddress(address + nameOffset);
+            return readCStringAsString(nameAddress);
+        }
+
+        public abstract long getValue();
+    }
+
+    /**
+     * VMIntConstantEntry (see vmStructs.hpp).
+     */
+    private long gHotSpotVMIntConstants;
+    private long gHotSpotVMIntConstantEntryNameOffset;
+    private long gHotSpotVMIntConstantEntryValueOffset;
+    private long gHotSpotVMIntConstantEntryArrayStride;
+
+    class VMIntConstants implements Iterable<VMIntConstants.Constant> {
+
+        private long address;
+
+        public VMIntConstants(long address) {
+            this.address = address;
+        }
+
+        public Iterator<VMIntConstants.Constant> iterator() {
+            return new Iterator<VMIntConstants.Constant>() {
+
+                private int index = 0;
+
+                private Constant current() {
+                    return new Constant(address + gHotSpotVMIntConstantEntryArrayStride * index);
+                }
+
+                /**
+                 * The last entry is identified by a NULL name.
+                 */
+                public boolean hasNext() {
+                    Constant entry = current();
+                    return entry.getName() != null;
+                }
+
+                public Constant next() {
+                    Constant entry = current();
+                    index++;
+                    return entry;
+                }
+
+                @Override
+                public void remove() {
+                    throw GraalInternalError.unimplemented();
+                }
+            };
+        }
+
+        class Constant extends AbstractConstant {
+
+            Constant(long address) {
+                super(address, gHotSpotVMIntConstantEntryNameOffset, gHotSpotVMIntConstantEntryValueOffset);
+            }
+
+            @Override
+            public long getValue() {
+                return unsafe.getInt(address + valueOffset);
+            }
+
+            @Override
+            public String toString() {
+                return String.format("IntConstant[name=%s, value=%d (0x%x)]", getName(), getValue(), getValue());
+            }
+        }
     }
 
     /**
-     * Gets the value of an VM option.
-     * 
-     * @param name option's name
-     * @param defaultValue default value if option is not exists (e.g. development options)
-     * @return value of option or defaultValue if option doesn't exist
+     * VMLongConstantEntry (see vmStructs.hpp).
      */
-    public static boolean getVMOption(String name, boolean defaultValue) {
-        try {
-            return getVMOption(name);
-        } catch (IllegalArgumentException e) {
-            return defaultValue;
+    private long gHotSpotVMLongConstants;
+    private long gHotSpotVMLongConstantEntryNameOffset;
+    private long gHotSpotVMLongConstantEntryValueOffset;
+    private long gHotSpotVMLongConstantEntryArrayStride;
+
+    class VMLongConstants implements Iterable<VMLongConstants.Constant> {
+
+        private long address;
+
+        public VMLongConstants(long address) {
+            this.address = address;
+        }
+
+        public Iterator<VMLongConstants.Constant> iterator() {
+            return new Iterator<VMLongConstants.Constant>() {
+
+                private int index = 0;
+
+                private Constant currentEntry() {
+                    return new Constant(address + gHotSpotVMLongConstantEntryArrayStride * index);
+                }
+
+                /**
+                 * The last entry is identified by a NULL name.
+                 */
+                public boolean hasNext() {
+                    Constant entry = currentEntry();
+                    return entry.getName() != null;
+                }
+
+                public Constant next() {
+                    Constant entry = currentEntry();
+                    index++;
+                    return entry;
+                }
+
+                @Override
+                public void remove() {
+                    throw GraalInternalError.unimplemented();
+                }
+            };
+        }
+
+        class Constant extends AbstractConstant {
+
+            Constant(long address) {
+                super(address, gHotSpotVMLongConstantEntryNameOffset, gHotSpotVMLongConstantEntryValueOffset);
+            }
+
+            @Override
+            public long getValue() {
+                return unsafe.getLong(address + valueOffset);
+            }
+
+            @Override
+            public String toString() {
+                return String.format("LongConstant[name=%s, value=%d (0x%x)]", getName(), getValue(), getValue());
+            }
         }
     }
 
-    // Using systenm properties ensures the Java source compilers can never
-    // optimize away an access to a config field
-    private static final boolean UNINITIALIZED_BOOLEAN = Boolean.getBoolean("graal.config.uninitializedBoolean");
-    private static final long UNINITIALIZED_LONG = Long.getLong("graal.config.uninitializedLong", 0L);
-    private static final int UNINITIALIZED_INT = Integer.getInteger("graal.config.uninitializedInt", 0);
+    class Flags implements Iterable<Flags.Flag> {
+
+        private long address;
+        private long entrySize;
+        private long typeOffset;
+        private long nameOffset;
+        private long addrOffset;
+
+        public Flags(HashMap<String, VMFields.Field> vmStructs, HashMap<String, VMTypes.Type> vmTypes) {
+            address = vmStructs.get("Flag::flags").getValue();
+            entrySize = vmTypes.get("Flag").getSize();
+            typeOffset = vmStructs.get("Flag::_type").getOffset();
+            nameOffset = vmStructs.get("Flag::_name").getOffset();
+            addrOffset = vmStructs.get("Flag::_addr").getOffset();
+
+            // TODO use the following after we switched to JDK 8
+            assert vmTypes.get("bool").getSize() == Byte.SIZE / Byte.SIZE; // TODO Byte.BYTES;
+            assert vmTypes.get("intx").getSize() == Long.SIZE / Byte.SIZE; // TODO Long.BYTES;
+            assert vmTypes.get("uintx").getSize() == Long.SIZE / Byte.SIZE; // TODO Long.BYTES;
+        }
+
+        public Iterator<Flags.Flag> iterator() {
+            return new Iterator<Flags.Flag>() {
+
+                private int index = 0;
+
+                private Flag current() {
+                    return new Flag(address + entrySize * index);
+                }
+
+                /**
+                 * The last entry is identified by a NULL name.
+                 */
+                public boolean hasNext() {
+                    Flag entry = current();
+                    return entry.getName() != null;
+                }
+
+                public Flag next() {
+                    Flag entry = current();
+                    index++;
+                    return entry;
+                }
 
-    private static int getUninitializedInt() {
-        return UNINITIALIZED_INT;
+                @Override
+                public void remove() {
+                    throw GraalInternalError.unimplemented();
+                }
+            };
+        }
+
+        class Flag {
+
+            private long entryAddress;
+
+            Flag(long address) {
+                this.entryAddress = address;
+            }
+
+            public String getType() {
+                long typeAddress = unsafe.getAddress(entryAddress + typeOffset);
+                return readCStringAsString(typeAddress);
+            }
+
+            public String getName() {
+                long nameAddress = unsafe.getAddress(entryAddress + nameOffset);
+                return readCStringAsString(nameAddress);
+            }
+
+            public long getAddr() {
+                return unsafe.getAddress(entryAddress + addrOffset);
+            }
+
+            public Object getValue() {
+                switch (getType()) {
+                    case "bool":
+                        return Boolean.valueOf(unsafe.getByte(getAddr()) != 0);
+                    case "intx":
+                    case "uintx":
+                    case "uint64_t":
+                        return Long.valueOf(unsafe.getLong(getAddr()));
+                    case "double":
+                        return Double.valueOf(unsafe.getDouble(getAddr()));
+                    case "ccstr":
+                    case "ccstrlist":
+                        return readCStringAsString(getAddr());
+                    default:
+                        throw GraalInternalError.shouldNotReachHere(getType());
+                }
+            }
+
+            @Override
+            public String toString() {
+                return String.format("Flag[type=%s, name=%s, value=%s]", getType(), getName(), getValue());
+            }
+        }
     }
 
-    private static long getUninitializedLong() {
-        return UNINITIALIZED_LONG;
-    }
-
-    private static boolean getUninitializedBoolean() {
-        return UNINITIALIZED_BOOLEAN;
+    /**
+     * Read a null-terminated C string from memory and convert it to a Java String.
+     */
+    private static String readCStringAsString(long address) {
+        if (address == 0) {
+            return null;
+        }
+        StringBuffer sb = new StringBuffer();
+        for (int i = 0;; i++) {
+            char c = (char) unsafe.getByte(address + i);
+            if (c == 0) {
+                break;
+            }
+            sb.append(c);
+        }
+        return sb.toString();
     }
 
     // os information, register layout, code generation, ...
-    public final boolean cAssertions = getUninitializedBoolean();
+    @HotSpotVMConstant(name = "ASSERT") @Stable public boolean cAssertions;
     public final boolean windowsOs = System.getProperty("os.name", "").startsWith("Windows");
-    public final int codeEntryAlignment = getUninitializedInt();
-    public final boolean verifyOops = getVMOption("VerifyOops", false);
-    public final boolean ciTime = getVMOption("CITime");
-    public final int compileThreshold = getVMOptionInt("CompileThreshold");
-    public final boolean compileTheWorld = getVMOption("CompileTheWorld", false);
-    public final int compileTheWorldStartAt = getVMOption("CompileTheWorldStartAt", 1);
-    public final int compileTheWorldStopAt = getVMOption("CompileTheWorldStopAt", Integer.MAX_VALUE);
-    public final boolean printCompilation = getVMOption("PrintCompilation");
-    public final boolean printInlining = getVMOption("PrintInlining", false);
-    public final boolean useFastLocking = getVMOption("GraalUseFastLocking", true);
-    public final boolean useTLAB = getVMOption("UseTLAB");
-    public final boolean useBiasedLocking = getVMOption("UseBiasedLocking");
-    public final boolean usePopCountInstruction = getVMOption("UsePopCountInstruction");
-    public final boolean useAESIntrinsics = getVMOption("UseAESIntrinsics");
-    public final boolean useCRC32Intrinsics = getVMOption("UseCRC32Intrinsics");
-    public final boolean useG1GC = getVMOption("UseG1GC");
-    public final long gcTotalCollectionsAddress = getUninitializedLong();
-    public final boolean useDeferredInitBarriers = getVMOption("GraalDeferredInitBarriers");
+
+    @HotSpotVMFlag(name = "CodeEntryAlignment") @Stable public int codeEntryAlignment;
+    @HotSpotVMFlag(name = "VerifyOops") @Stable public boolean verifyOops;
+    @HotSpotVMFlag(name = "CITime") @Stable public boolean ciTime;
+    @HotSpotVMFlag(name = "CompileThreshold") @Stable public long compileThreshold;
+    @HotSpotVMFlag(name = "CompileTheWorld") @Stable public boolean compileTheWorld;
+    @HotSpotVMFlag(name = "CompileTheWorldStartAt") @Stable public int compileTheWorldStartAt;
+    @HotSpotVMFlag(name = "CompileTheWorldStopAt") @Stable public int compileTheWorldStopAt;
+    @HotSpotVMFlag(name = "PrintCompilation") @Stable public boolean printCompilation;
+    @HotSpotVMFlag(name = "PrintInlining") @Stable public boolean printInlining;
+    @HotSpotVMFlag(name = "GraalUseFastLocking") @Stable public boolean useFastLocking;
+
+    @HotSpotVMFlag(name = "UseTLAB") @Stable public boolean useTLAB;
+    @HotSpotVMFlag(name = "UseBiasedLocking") @Stable public boolean useBiasedLocking;
+    @HotSpotVMFlag(name = "UsePopCountInstruction") @Stable public boolean usePopCountInstruction;
+    @HotSpotVMFlag(name = "UseAESIntrinsics") @Stable public boolean useAESIntrinsics;
+    @HotSpotVMFlag(name = "UseCRC32Intrinsics") @Stable public boolean useCRC32Intrinsics;
+    @HotSpotVMFlag(name = "UseG1GC") @Stable public boolean useG1GC;
+
+    @HotSpotVMField(name = "Universe::_collectedHeap", get = HotSpotVMField.Type.VALUE) @Stable private long universeCollectedHeap;
+    @HotSpotVMField(name = "CollectedHeap::_total_collections", get = HotSpotVMField.Type.OFFSET) @Stable private int collectedHeapTotalCollectionsOffset;
+
+    public long gcTotalCollectionsAddress() {
+        return universeCollectedHeap + collectedHeapTotalCollectionsOffset;
+    }
+
+    @HotSpotVMFlag(name = "GraalDeferredInitBarriers") @Stable public boolean useDeferredInitBarriers;
 
     // Compressed Oops related values.
-    public final boolean useCompressedOops = getVMOption("UseCompressedOops");
-    public final boolean useCompressedClassPointers = getVMOption("UseCompressedClassPointers");
-    public final long narrowOopBase = getUninitializedLong();
-    public final int narrowOopShift = getUninitializedInt();
-    public final int logMinObjAlignment = (int) (Math.log(getVMOptionInt("ObjectAlignmentInBytes")) / Math.log(2));
-    public final long narrowKlassBase = getUninitializedLong();
-    public final int narrowKlassShift = getUninitializedInt();
-    public final int logKlassAlignment = getUninitializedInt();
+    @HotSpotVMFlag(name = "UseCompressedOops") @Stable public boolean useCompressedOops;
+    @HotSpotVMFlag(name = "UseCompressedClassPointers") @Stable public boolean useCompressedClassPointers;
+
+    @HotSpotVMField(name = "Universe::_narrow_oop._base", get = HotSpotVMField.Type.VALUE) @Stable public long narrowOopBase;
+    @HotSpotVMField(name = "Universe::_narrow_oop._shift", get = HotSpotVMField.Type.VALUE) @Stable public int narrowOopShift;
+    @HotSpotVMFlag(name = "ObjectAlignmentInBytes") @Stable public int objectAlignment;
+
+    public int logMinObjAlignment() {
+        return (int) (Math.log(objectAlignment) / Math.log(2));
+    }
+
+    @HotSpotVMField(name = "Universe::_narrow_klass._base", get = HotSpotVMField.Type.VALUE) @Stable public long narrowKlassBase;
+    @HotSpotVMField(name = "Universe::_narrow_klass._shift", get = HotSpotVMField.Type.VALUE) @Stable public int narrowKlassShift;
+    @HotSpotVMConstant(name = "LogKlassAlignmentInBytes") @Stable public int logKlassAlignment;
 
     // CPU capabilities
-    public final int useSSE = getVMOptionInt("UseSSE");
-    public final int useAVX = getVMOption("UseAVX", 99);
+    @HotSpotVMFlag(name = "UseSSE") @Stable public int useSSE;
+    @HotSpotVMFlag(name = "UseAVX", optional = true) @Stable public int useAVX;
 
     // offsets, ...
-    public final int stackShadowPages = getVMOptionInt("StackShadowPages");
+    @HotSpotVMFlag(name = "StackShadowPages") @Stable public int stackShadowPages;
 
-    /**
-     * The offset of the mark word in an object's header.
-     */
-    public final int markOffset = getUninitializedInt();
-
-    /**
-     * The offset of the hub (i.e. Klass*) in an object's header.
-     */
-    public final int hubOffset = getUninitializedInt();
+    @HotSpotVMField(name = "oopDesc::_mark", get = HotSpotVMField.Type.OFFSET) @Stable public int markOffset;
+    @HotSpotVMField(name = "oopDesc::_metadata._klass", get = HotSpotVMField.Type.OFFSET) @Stable public int hubOffset;
 
-    /**
-     * The offset of the _prototype_header field in a Klass.
-     */
-    public final int prototypeMarkWordOffset = getUninitializedInt();
+    @HotSpotVMField(name = "Klass::_prototype_header", get = HotSpotVMField.Type.OFFSET) @Stable public int prototypeMarkWordOffset;
+    @HotSpotVMField(name = "Klass::_subklass", get = HotSpotVMField.Type.OFFSET) @Stable public int subklassOffset;
+    @HotSpotVMField(name = "Klass::_next_sibling", get = HotSpotVMField.Type.OFFSET) @Stable public int nextSiblingOffset;
+    @HotSpotVMField(name = "Klass::_super_check_offset", get = HotSpotVMField.Type.OFFSET) @Stable public int superCheckOffsetOffset;
+    @HotSpotVMField(name = "Klass::_secondary_super_cache", get = HotSpotVMField.Type.OFFSET) @Stable public int secondarySuperCacheOffset;
+    @HotSpotVMField(name = "Klass::_secondary_supers", get = HotSpotVMField.Type.OFFSET) @Stable public int secondarySupersOffset;
 
-    /**
-     * The offset of the _subklass field in a Klass.
-     */
-    public final int subklassOffset = getUninitializedInt();
-
-    /**
-     * The offset of the _next_sibling field in a Klass.
-     */
-    public final int nextSiblingOffset = getUninitializedInt();
+    @HotSpotVMType(name = "vtableEntry", get = HotSpotVMType.Type.SIZE) @Stable public int vtableEntrySize;
+    @HotSpotVMField(name = "vtableEntry::_method", get = HotSpotVMField.Type.OFFSET) @Stable public int vtableEntryMethodOffset;
+    @Stable public int instanceKlassVtableStartOffset;
 
     /**
      * The offset of the array length word in an array object's header.
      */
-    public final int arrayLengthOffset = getUninitializedInt();
+    @Stable public int arrayLengthOffset;
+
+    @HotSpotVMField(name = "Array<Klass*>::_length", get = HotSpotVMField.Type.OFFSET) @Stable public int metaspaceArrayLengthOffset;
+    @HotSpotVMField(name = "Array<Klass*>::_data", get = HotSpotVMField.Type.OFFSET) @Stable public int metaspaceArrayBaseOffset;
 
-    /**
-     * The offset of the _length field in an Array metaspace object (see array.hpp).
-     */
-    public final int metaspaceArrayLengthOffset = getUninitializedInt();
+    @HotSpotVMField(name = "InstanceKlass::_init_state", get = HotSpotVMField.Type.OFFSET) @Stable public int klassStateOffset;
+    @HotSpotVMConstant(name = "InstanceKlass::fully_initialized") @Stable public int klassStateFullyInitialized;
+    @HotSpotVMField(name = "InstanceKlass::_constants", get = HotSpotVMField.Type.OFFSET) @Stable public int instanceKlassConstantsOffset;
+
+    @HotSpotVMField(name = "ObjArrayKlass::_element_klass", get = HotSpotVMField.Type.OFFSET) @Stable public int arrayClassElementOffset;
 
-    /**
-     * The offset of the _data field in an Array metaspace object (see array.hpp).
-     */
-    public final int metaspaceArrayBaseOffset = getUninitializedInt();
+    @HotSpotVMField(name = "Thread::_tlab", get = HotSpotVMField.Type.OFFSET) @Stable public int threadTlabOffset;
 
-    /**
-     * The offset of the _super_check_offset field in a Klass.
-     */
-    public final int superCheckOffsetOffset = getUninitializedInt();
+    @HotSpotVMField(name = "JavaThread::_anchor", get = HotSpotVMField.Type.OFFSET) @Stable public int javaThreadAnchorOffset;
+    @HotSpotVMField(name = "JavaThread::_threadObj", get = HotSpotVMField.Type.OFFSET) @Stable public int threadObjectOffset;
+    @HotSpotVMField(name = "JavaThread::_osthread", get = HotSpotVMField.Type.OFFSET) @Stable public int osThreadOffset;
+    @HotSpotVMField(name = "JavaThread::_dirty_card_queue", get = HotSpotVMField.Type.OFFSET) @Stable public int javaThreadDirtyCardQueueOffset;
+    @HotSpotVMField(name = "JavaThread::_is_method_handle_return", get = HotSpotVMField.Type.OFFSET) @Stable public int threadIsMethodHandleReturnOffset;
+    @HotSpotVMField(name = "JavaThread::_satb_mark_queue", get = HotSpotVMField.Type.OFFSET) @Stable public int javaThreadSatbMarkQueueOffset;
+    @HotSpotVMField(name = "JavaThread::_vm_result", get = HotSpotVMField.Type.OFFSET) @Stable public int threadObjectResultOffset;
+    @HotSpotVMField(name = "JavaThread::_graal_counters[0]", get = HotSpotVMField.Type.OFFSET, optional = true) @Stable public int graalCountersThreadOffset;
 
-    /**
-     * The offset of the _secondary_super_cache field in a Klass.
-     */
-    public final int secondarySuperCacheOffset = getUninitializedInt();
+    @HotSpotVMConstant(name = "GRAAL_COUNTERS_SIZE", optional = true) @Stable public int graalCountersSize;
 
     /**
-     * The offset of the _secondary_supers field in a Klass.
-     */
-    public final int secondarySupersOffset = getUninitializedInt();
-
-    /**
-     * The offset of the _init_state field in an instanceKlass.
+     * This field is used to pass exception objects into and out of the runtime system during
+     * exception handling for compiled code.
+     * <p>
+     * <b>NOTE: This is not the same as {@link #pendingExceptionOffset}.</b>
      */
-    public final int klassStateOffset = getUninitializedInt();
-
-    /**
-     * The value of instanceKlass::fully_initialized.
-     */
-    public final int klassStateFullyInitialized = getUninitializedInt();
+    @HotSpotVMField(name = "JavaThread::_exception_oop", get = HotSpotVMField.Type.OFFSET) @Stable public int threadExceptionOopOffset;
+    @HotSpotVMField(name = "JavaThread::_exception_pc", get = HotSpotVMField.Type.OFFSET) @Stable public int threadExceptionPcOffset;
 
-    /**
-     * The value of objArrayKlass::element_klass_offset().
-     */
-    public final int arrayClassElementOffset = getUninitializedInt();
+    @HotSpotVMField(name = "JavaFrameAnchor::_last_Java_sp", get = HotSpotVMField.Type.OFFSET) @Stable private int javaFrameAnchorLastJavaSpOffset;
+    @HotSpotVMField(name = "JavaFrameAnchor::_last_Java_pc", get = HotSpotVMField.Type.OFFSET) @Stable private int javaFrameAnchorLastJavaPcOffset;
+    @HotSpotVMField(name = "JavaFrameAnchor::_last_Java_fp", get = HotSpotVMField.Type.OFFSET, optional = true) @Stable private int javaFrameAnchorLastJavaFpOffset;
+    @HotSpotVMField(name = "JavaFrameAnchor::_flags", get = HotSpotVMField.Type.OFFSET, optional = true) @Stable private int javaFrameAnchorFlagsOffset;
 
-    /**
-     * The value of JavaThread::tlab_top_offset().
-     */
-    public final int threadTlabTopOffset = getUninitializedInt();
+    public int threadLastJavaSpOffset() {
+        return javaThreadAnchorOffset + javaFrameAnchorLastJavaSpOffset;
+    }
 
-    /**
-     * The value of JavaThread::tlab_end_offset().
-     */
-    public final int threadTlabEndOffset = getUninitializedInt();
+    public int threadLastJavaPcOffset() {
+        return javaThreadAnchorOffset + javaFrameAnchorLastJavaPcOffset;
+    }
 
     /**
-     * The value of JavaThread::threadObj_offset().
-     */
-    public final int threadObjectOffset = getUninitializedInt();
-
-    /**
-     * The value of JavaThread::osthread_offset().
-     */
-    public final int osThreadOffset = getUninitializedInt();
-
-    /**
-     * The value of JavaThread::graal_counters_offset().
+     * This value is only valid on AMD64.
      */
-    public final int graalCountersThreadOffset = getUninitializedInt();
-
-    /**
-     * The length of the JavaThread::_graal_counters array.
-     */
-    public final int graalCountersSize = getUninitializedInt();
-
-    /**
-     * The value of OSThread::interrupted_offset().
-     */
-    public final int osThreadInterruptedOffset = getUninitializedInt();
+    public int threadLastJavaFpOffset() {
+        // TODO add an assert for AMD64
+        return javaThreadAnchorOffset + javaFrameAnchorLastJavaFpOffset;
+    }
 
     /**
-     * The value of markOopDesc::unlocked_value.
+     * This value is only valid on SPARC.
      */
-    public final int unlockedMask = getUninitializedInt();
+    public int threadJavaFrameAnchorFlagsOffset() {
+        // TODO add an assert for SPARC
+        return javaThreadAnchorOffset + javaFrameAnchorFlagsOffset;
+    }
+
+    @HotSpotVMField(name = "PtrQueue::_active", get = HotSpotVMField.Type.OFFSET) @Stable public int ptrQueueActiveOffset;
+    @HotSpotVMField(name = "PtrQueue::_buf", get = HotSpotVMField.Type.OFFSET) @Stable public int ptrQueueBufferOffset;
+    @HotSpotVMField(name = "PtrQueue::_index", get = HotSpotVMField.Type.OFFSET) @Stable public int ptrQueueIndexOffset;
+
+    @HotSpotVMField(name = "OSThread::_interrupted", get = HotSpotVMField.Type.OFFSET) @Stable public int osThreadInterruptedOffset;
 
-    /**
-     * The value of markOopDesc::biased_lock_mask_in_place.
-     */
-    public final int biasedLockMaskInPlace = getUninitializedInt();
+    @HotSpotVMConstant(name = "markOopDesc::unlocked_value") @Stable public int unlockedMask;
+    @HotSpotVMConstant(name = "markOopDesc::biased_lock_mask_in_place") @Stable public int biasedLockMaskInPlace;
+    @HotSpotVMConstant(name = "markOopDesc::age_mask_in_place") @Stable public int ageMaskInPlace;
+    @HotSpotVMConstant(name = "markOopDesc::epoch_mask_in_place") @Stable public int epochMaskInPlace;
+
+    @HotSpotVMConstant(name = "markOopDesc::hash_shift") @Stable public long markOopDescHashShift;
+    @HotSpotVMConstant(name = "markOopDesc::hash_mask") @Stable public long markOopDescHashMask;
+    @HotSpotVMConstant(name = "markOopDesc::hash_mask_in_place") @Stable public long markOopDescHashMaskInPlace;
+
+    @HotSpotVMConstant(name = "markOopDesc::biased_lock_pattern") @Stable public int biasedLockPattern;
+    @HotSpotVMConstant(name = "markOopDesc::no_hash_in_place") @Stable public int markWordNoHashInPlace;
+    @HotSpotVMConstant(name = "markOopDesc::no_lock_in_place") @Stable public int markWordNoLockInPlace;
 
     /**
-     * The value of markOopDesc::age_mask_in_place.
+     * See markOopDesc::prototype().
      */
-    public final int ageMaskInPlace = getUninitializedInt();
+    public long arrayPrototypeMarkWord() {
+        return markWordNoHashInPlace | markWordNoLockInPlace;
+    }
 
     /**
-     * The value of markOopDesc::epoch_mask_in_place.
-     */
-    public final int epochMaskInPlace = getUninitializedInt();
-
-    /**
-     * The value of markOopDesc::biased_lock_pattern.
+     * See markOopDesc::copy_set_hash().
      */
-    public final int biasedLockPattern = getUninitializedInt();
-
-    /**
-     * Identity hash code value when uninitialized.
-     */
-    public final int uninitializedIdentityHashCodeValue = getUninitializedInt();
+    public long tlabIntArrayMarkWord() {
+        long tmp = arrayPrototypeMarkWord() & (~markOopDescHashMaskInPlace);
+        tmp |= ((0x2 & markOopDescHashMask) << markOopDescHashShift);
+        return tmp;
+    }
 
     /**
      * Offset of the _pending_exception field in ThreadShadow (defined in exceptions.hpp). This
@@ -297,301 +815,344 @@
      * <p>
      * <b>NOTE: This is not the same as {@link #threadExceptionOopOffset}.</b>
      */
-    public final int pendingExceptionOffset = getUninitializedInt();
-
-    /**
-     * Offset of the pending deoptimization field.
-     */
-    public final int pendingDeoptimizationOffset = getUninitializedInt();
+    @HotSpotVMField(name = "ThreadShadow::_pending_exception", get = HotSpotVMField.Type.OFFSET) @Stable public int pendingExceptionOffset;
+    @HotSpotVMField(name = "ThreadShadow::_pending_deoptimization", get = HotSpotVMField.Type.OFFSET) @Stable public int pendingDeoptimizationOffset;
 
     /**
      * Mark word right shift to get identity hash code.
      */
-    public final int identityHashCodeShift = getUninitializedInt();
-
-    /**
-     * Offset of _access_flags in a metaspace Method object.
-     */
-    public final int methodAccessFlagsOffset = getUninitializedInt();
-
-    /**
-     * JVM_ACC_QUEUED defined in accessFlags.hpp and used for marking a Method object as queued for
-     * compilation.
-     */
-    public final int methodQueuedForCompilationBit = getUninitializedInt();
+    @HotSpotVMConstant(name = "markOopDesc::hash_shift") @Stable public int identityHashCodeShift;
 
     /**
-     * Offset of _intrinsic_id in a metaspace Method object.
-     */
-    public final int methodIntrinsicIdOffset = getUninitializedInt();
-
-    /**
-     * Offset of _max_locals in a metaspace Method object.
+     * Identity hash code value when uninitialized.
      */
-    public final int methodMaxLocalsOffset = getUninitializedInt();
-
-    /**
-     * Offset of _constMethod in a metaspace Method object.
-     */
-    public final int methodConstMethodOffset = getUninitializedInt();
+    @HotSpotVMConstant(name = "markOopDesc::no_hash") @Stable public int uninitializedIdentityHashCodeValue;
 
     /**
-     * Offset of _max_stack in a metaspace ConstMethod object.
+     * Used for marking a Method object as queued for compilation.
      */
-    public final int constMethodMaxStackOffset = getUninitializedInt();
+    @HotSpotVMConstant(name = "JVM_ACC_QUEUED") @Stable public int methodQueuedForCompilationBit;
 
-    /**
-     * Offset of _constants in a metaspace ConstMethod object.
-     */
-    public final int constMethodConstantsOffset = getUninitializedInt();
+    @HotSpotVMField(name = "Method::_access_flags", get = HotSpotVMField.Type.OFFSET) @Stable public int methodAccessFlagsOffset;
+    @HotSpotVMField(name = "Method::_constMethod", get = HotSpotVMField.Type.OFFSET) @Stable public int methodConstMethodOffset;
+    @HotSpotVMField(name = "Method::_intrinsic_id", get = HotSpotVMField.Type.OFFSET) @Stable public int methodIntrinsicIdOffset;
+    @HotSpotVMField(name = "Method::_vtable_index", get = HotSpotVMField.Type.OFFSET) @Stable public int methodVtableIndexOffset;
 
     /**
-     * Offset of _pool_holder in a metaspace ConstantPool object.
+     * Value of Method::extra_stack_entries().
      */
-    public final int constantPoolHolderOffset = getUninitializedInt();
-
-    /**
-     * Value of extra_stack_entries() in method.hpp.
-     */
-    public final int extraStackEntries = getUninitializedInt();
+    @Stable public int extraStackEntries;
 
-    /**
-     * Value of JVM_ACC_HAS_FINALIZER in accessFlags.hpp.
-     */
-    public final int klassHasFinalizerFlag = getUninitializedInt();
+    @HotSpotVMField(name = "ConstMethod::_max_stack", get = HotSpotVMField.Type.OFFSET) @Stable public int constMethodMaxStackOffset;
+    @HotSpotVMField(name = "ConstMethod::_max_locals", get = HotSpotVMField.Type.OFFSET) @Stable public int methodMaxLocalsOffset;
+    @HotSpotVMField(name = "ConstMethod::_constants", get = HotSpotVMField.Type.OFFSET) @Stable public int constMethodConstantsOffset;
 
-    /**
-     * The value of JavaThread::is_method_handle_return_offset().
-     */
-    public final int threadIsMethodHandleReturnOffset = getUninitializedInt();
+    @HotSpotVMField(name = "ConstantPool::_pool_holder", get = HotSpotVMField.Type.OFFSET) @Stable public int constantPoolHolderOffset;
+    @HotSpotVMField(name = "ConstantPool::_length", get = HotSpotVMField.Type.OFFSET) @Stable public int constantPoolLengthOffset;
+
+    @HotSpotVMConstant(name = "JVM_ACC_HAS_FINALIZER") @Stable public int klassHasFinalizerFlag;
 
     /**
      * Bit pattern that represents a non-oop. Neither the high bits nor the low bits of this value
      * are allowed to look like (respectively) the high or low bits of a real oop.
      */
-    public final long nonOopBits = getUninitializedLong();
+    @HotSpotVMField(name = "Universe::_non_oop_bits", get = HotSpotVMField.Type.VALUE) @Stable public long nonOopBits;
+
+    @HotSpotVMField(name = "StubRoutines::_verify_oop_count", get = HotSpotVMField.Type.ADDRESS) @Stable public long verifyOopCounterAddress;
+    @Stable public long verifyOopMask;
+    @Stable public long verifyOopBits;
+
+    @HotSpotVMField(name = "CollectedHeap::_barrier_set", get = HotSpotVMField.Type.OFFSET) @Stable public int collectedHeapBarrierSetOffset;
 
-    public final long verifyOopCounterAddress = getUninitializedLong();
-    public final long verifyOopMask = getUninitializedLong();
-    public final long verifyOopBits = getUninitializedLong();
+    @HotSpotVMField(name = "HeapRegion::LogOfHRGrainBytes", get = HotSpotVMField.Type.VALUE) @Stable public int logOfHRGrainBytes;
+
+    @HotSpotVMField(name = "BarrierSet::_kind", get = HotSpotVMField.Type.OFFSET) @Stable public int barrierSetKindOffset;
+    @HotSpotVMConstant(name = "BarrierSet::CardTableModRef") @Stable public int barrierSetCardTableModRef;
+    @HotSpotVMConstant(name = "BarrierSet::CardTableExtension") @Stable public int barrierSetCardTableExtension;
+    @HotSpotVMConstant(name = "BarrierSet::G1SATBCT") @Stable public int barrierSetG1SATBCT;
+    @HotSpotVMConstant(name = "BarrierSet::G1SATBCTLogging") @Stable public int barrierSetG1SATBCTLogging;
+    @HotSpotVMConstant(name = "BarrierSet::ModRef") @Stable public int barrierSetModRef;
+    @HotSpotVMConstant(name = "BarrierSet::Other") @Stable public int barrierSetOther;
 
-    /**
-     * Offset of the _exception_oop field in Thread (defined in thread.hpp). This field is used to
-     * pass exception objects into and out of the runtime system during exception handling for
-     * compiled code.
-     * <p>
-     * <b>NOTE: This is not the same as {@link #pendingExceptionOffset}.</b>
-     */
-    public final int threadExceptionOopOffset = getUninitializedInt();
+    @HotSpotVMField(name = "CardTableModRefBS::byte_map_base", get = HotSpotVMField.Type.OFFSET) @Stable public int cardTableModRefBSByteMapBaseOffset;
+    @HotSpotVMConstant(name = "CardTableModRefBS::card_shift") @Stable public int cardTableModRefBSCardShift;
+
+    public long cardtableStartAddress() {
+        final long barrierSetAddress = unsafe.getAddress(universeCollectedHeap + collectedHeapBarrierSetOffset);
+        final int kind = unsafe.getInt(barrierSetAddress + barrierSetKindOffset);
+        if ((kind == barrierSetCardTableModRef) || (kind == barrierSetCardTableExtension) || (kind == barrierSetG1SATBCT) || (kind == barrierSetG1SATBCTLogging)) {
+            final long base = unsafe.getAddress(barrierSetAddress + cardTableModRefBSByteMapBaseOffset);
+            assert base != 0 : "unexpected byte_map_base: " + base;
+            return base;
+        }
+        if ((kind == barrierSetModRef) || (kind == barrierSetOther)) {
+            // No post barriers
+            return 0;
+        }
+        throw GraalInternalError.shouldNotReachHere("kind: " + kind);
+    }
 
-    public final int threadExceptionPcOffset = getUninitializedInt();
-    public final long cardtableStartAddress = getUninitializedLong();
-    public final int cardtableShift = getUninitializedInt();
-    public final long safepointPollingAddress = getUninitializedLong();
-    public final boolean isPollingPageFar = getUninitializedBoolean();
+    public int cardtableShift() {
+        final long barrierSetAddress = unsafe.getAddress(universeCollectedHeap + collectedHeapBarrierSetOffset);
+        final int kind = unsafe.getInt(barrierSetAddress + barrierSetKindOffset);
+        if ((kind == barrierSetCardTableModRef) || (kind == barrierSetCardTableExtension) || (kind == barrierSetG1SATBCT) || (kind == barrierSetG1SATBCTLogging)) {
+            return cardTableModRefBSCardShift;
+        }
+        if ((kind == barrierSetModRef) || (kind == barrierSetOther)) {
+            // No post barriers
+            return 0;
+        }
+        throw GraalInternalError.shouldNotReachHere("kind: " + kind);
+    }
+
+    @HotSpotVMField(name = "os::_polling_page", get = HotSpotVMField.Type.VALUE) @Stable public long safepointPollingAddress;
+
+    // G1 Collector Related Values.
 
-    /**
-     * G1 Collector Related Values.
-     */
-    public final int g1CardQueueIndexOffset = getUninitializedInt();
-    public final int g1CardQueueBufferOffset = getUninitializedInt();
-    public final int logOfHRGrainBytes = getUninitializedInt();
-    public final int g1SATBQueueMarkingOffset = getUninitializedInt();
-    public final int g1SATBQueueIndexOffset = getUninitializedInt();
-    public final int g1SATBQueueBufferOffset = getUninitializedInt();
+    public int g1CardQueueIndexOffset() {
+        return javaThreadDirtyCardQueueOffset + ptrQueueIndexOffset;
+    }
+
+    public int g1CardQueueBufferOffset() {
+        return javaThreadDirtyCardQueueOffset + ptrQueueBufferOffset;
+    }
+
+    public int g1SATBQueueMarkingOffset() {
+        return javaThreadSatbMarkQueueOffset + ptrQueueActiveOffset;
+    }
+
+    public int g1SATBQueueIndexOffset() {
+        return javaThreadSatbMarkQueueOffset + ptrQueueIndexOffset;
+    }
+
+    public int g1SATBQueueBufferOffset() {
+        return javaThreadSatbMarkQueueOffset + ptrQueueBufferOffset;
+    }
 
     /**
      * The offset of the _java_mirror field (of type {@link Class}) in a Klass.
      */
-    public final int classMirrorOffset = getUninitializedInt();
-
-    public final int runtimeCallStackSize = getUninitializedInt();
+    @HotSpotVMField(name = "Klass::_java_mirror", get = HotSpotVMField.Type.OFFSET) @Stable public int classMirrorOffset;
 
-    /**
-     * The offset of the _modifier_flags field in a Klass.
-     */
-    public final int klassModifierFlagsOffset = getUninitializedInt();
+    @HotSpotVMConstant(name = "frame::arg_reg_save_area_bytes", optional = true) @Stable public int runtimeCallStackSize;
 
-    /**
-     * The offset of the _access_flags field in a Klass.
-     */
-    public final int klassAccessFlagsOffset = getUninitializedInt();
-
-    /**
-     * The offset of the _layout_helper field in a Klass.
-     */
-    public final int klassLayoutHelperOffset = getUninitializedInt();
+    @HotSpotVMField(name = "Klass::_super", get = HotSpotVMField.Type.OFFSET) @Stable public int klassSuperKlassOffset;
+    @HotSpotVMField(name = "Klass::_modifier_flags", get = HotSpotVMField.Type.OFFSET) @Stable public int klassModifierFlagsOffset;
+    @HotSpotVMField(name = "Klass::_access_flags", get = HotSpotVMField.Type.OFFSET) @Stable public int klassAccessFlagsOffset;
+    @HotSpotVMField(name = "Klass::_layout_helper", get = HotSpotVMField.Type.OFFSET) @Stable public int klassLayoutHelperOffset;
+    @HotSpotVMField(name = "Klass::_layout_helper", get = HotSpotVMField.Type.OFFSET) @Stable public int klassInstanceSizeOffset;
 
     /**
      * Bit pattern in the klass layout helper that can be used to identify arrays.
      */
-    public final int arrayKlassLayoutHelperIdentifier = getUninitializedInt();
+    public final int arrayKlassLayoutHelperIdentifier = 0x80000000;
+
+    @HotSpotVMField(name = "ArrayKlass::_component_mirror", get = HotSpotVMField.Type.OFFSET) @Stable public int arrayKlassComponentMirrorOffset;
+
+    @HotSpotVMField(name = "java_lang_Class::_klass_offset", get = HotSpotVMField.Type.VALUE) @Stable public int klassOffset;
+    @HotSpotVMField(name = "java_lang_Class::_array_klass_offset", get = HotSpotVMField.Type.VALUE) @Stable public int arrayKlassOffset;
+    @HotSpotVMField(name = "java_lang_Class::_graal_mirror_offset", get = HotSpotVMField.Type.VALUE) @Stable public int graalMirrorInClassOffset;
+
+    @HotSpotVMField(name = "Method::_method_data", get = HotSpotVMField.Type.OFFSET) @Stable public int methodDataOffset;
+    @HotSpotVMField(name = "Method::_from_compiled_entry", get = HotSpotVMField.Type.OFFSET) @Stable public int methodCompiledEntryOffset;
+
+    @HotSpotVMField(name = "nmethod::_verified_entry_point", get = HotSpotVMField.Type.OFFSET) @Stable public int nmethodEntryOffset;
+
+    @HotSpotVMType(name = "BasicLock", get = HotSpotVMType.Type.SIZE) @Stable public int basicLockSize;
+    @HotSpotVMField(name = "BasicLock::_displaced_header", get = HotSpotVMField.Type.OFFSET) @Stable public int basicLockDisplacedHeaderOffset;
 
-    /**
-     * The offset of the _componentMirror field in an ArrayKlass.
-     */
-    public final int arrayKlassComponentMirrorOffset = getUninitializedInt();
+    @Stable public long heapEndAddress;
+    @Stable public long heapTopAddress;
+
+    @HotSpotVMField(name = "Thread::_allocated_bytes", get = HotSpotVMField.Type.OFFSET) @Stable public int threadAllocatedBytesOffset;
+
+    @HotSpotVMFlag(name = "TLABWasteIncrement") @Stable public int tlabRefillWasteIncrement;
+    @Stable public int tlabAlignmentReserve;
+
+    @HotSpotVMField(name = "ThreadLocalAllocBuffer::_start", get = HotSpotVMField.Type.OFFSET) @Stable public int threadLocalAllocBufferStartOffset;
+    @HotSpotVMField(name = "ThreadLocalAllocBuffer::_end", get = HotSpotVMField.Type.OFFSET) @Stable public int threadLocalAllocBufferEndOffset;
+    @HotSpotVMField(name = "ThreadLocalAllocBuffer::_top", get = HotSpotVMField.Type.OFFSET) @Stable public int threadLocalAllocBufferTopOffset;
+    @HotSpotVMField(name = "ThreadLocalAllocBuffer::_slow_allocations", get = HotSpotVMField.Type.OFFSET) @Stable public int threadLocalAllocBufferSlowAllocationsOffset;
+    @HotSpotVMField(name = "ThreadLocalAllocBuffer::_fast_refill_waste", get = HotSpotVMField.Type.OFFSET) @Stable public int threadLocalAllocBufferFastRefillWasteOffset;
+    @HotSpotVMField(name = "ThreadLocalAllocBuffer::_number_of_refills", get = HotSpotVMField.Type.OFFSET) @Stable public int threadLocalAllocBufferNumberOfRefillsOffset;
+    @HotSpotVMField(name = "ThreadLocalAllocBuffer::_refill_waste_limit", get = HotSpotVMField.Type.OFFSET) @Stable public int threadLocalAllocBufferRefillWasteLimitOffset;
+    @HotSpotVMField(name = "ThreadLocalAllocBuffer::_desired_size", get = HotSpotVMField.Type.OFFSET) @Stable public int threadLocalAllocBufferDesiredSizeOffset;
+
+    public int tlabSlowAllocationsOffset() {
+        return threadTlabOffset + threadLocalAllocBufferSlowAllocationsOffset;
+    }
 
-    /**
-     * The offset of the _super field in a Klass.
-     */
-    public final int klassSuperKlassOffset = getUninitializedInt();
+    public int tlabFastRefillWasteOffset() {
+        return threadTlabOffset + threadLocalAllocBufferFastRefillWasteOffset;
+    }
+
+    public int tlabNumberOfRefillsOffset() {
+        return threadTlabOffset + threadLocalAllocBufferNumberOfRefillsOffset;
+    }
+
+    public int tlabRefillWasteLimitOffset() {
+        return threadTlabOffset + threadLocalAllocBufferRefillWasteLimitOffset;
+    }
+
+    public int threadTlabSizeOffset() {
+        return threadTlabOffset + threadLocalAllocBufferDesiredSizeOffset;
+    }
+
+    public int threadTlabStartOffset() {
+        return threadTlabOffset + threadLocalAllocBufferStartOffset;
+    }
 
-    /**
-     * The offset of the injected klass field in a {@link Class}.
-     */
-    public final int klassOffset = getUninitializedInt();
+    public int threadTlabEndOffset() {
+        return threadTlabOffset + threadLocalAllocBufferEndOffset;
+    }
+
+    public int threadTlabTopOffset() {
+        return threadTlabOffset + threadLocalAllocBufferTopOffset;
+    }
+
+    @HotSpotVMFlag(name = "TLABStats") @Stable public boolean tlabStats;
+    @Stable public boolean inlineContiguousAllocationSupported;
 
-    /**
-     * The offset of the injected array klass field in a {@link Class}.
-     */
-    public final int arrayKlassOffset = getUninitializedInt();
+    @HotSpotVMField(name = "Klass::_layout_helper", get = HotSpotVMField.Type.OFFSET) @Stable public int layoutHelperOffset;
+    @HotSpotVMConstant(name = "Klass::_lh_log2_element_size_shift") @Stable public int layoutHelperLog2ElementSizeShift;
+    @HotSpotVMConstant(name = "Klass::_lh_log2_element_size_mask") @Stable public int layoutHelperLog2ElementSizeMask;
+    @HotSpotVMConstant(name = "Klass::_lh_element_type_shift") @Stable public int layoutHelperElementTypeShift;
+    @HotSpotVMConstant(name = "Klass::_lh_element_type_mask") @Stable public int layoutHelperElementTypeMask;
+    @HotSpotVMConstant(name = "Klass::_lh_header_size_shift") @Stable public int layoutHelperHeaderSizeShift;
+    @HotSpotVMConstant(name = "Klass::_lh_header_size_mask") @Stable public int layoutHelperHeaderSizeMask;
+    @HotSpotVMConstant(name = "Klass::_lh_array_tag_shift") @Stable public int layoutHelperArrayTagShift;
+    @HotSpotVMConstant(name = "Klass::_lh_array_tag_type_value") @Stable public int layoutHelperArrayTagTypeValue;
+    @HotSpotVMConstant(name = "Klass::_lh_array_tag_obj_value") @Stable public int layoutHelperArrayTagObjectValue;
 
     /**
-     * The offset of the injected graal_mirror field in a {@link Class}.
+     * This filters out the bit that differentiates a type array from an object array.
      */
-    public final int graalMirrorInClassOffset = getUninitializedInt();
-
-    /**
-     * The offset of the _method_data field in a metaspace Method.
-     */
-    public final int methodDataOffset = getUninitializedInt();
+    public int layoutHelperElementTypePrimitiveInPlace() {
+        return (layoutHelperArrayTagTypeValue & ~layoutHelperArrayTagObjectValue) << layoutHelperArrayTagShift;
+    }
 
-    public final int nmethodEntryOffset = getUninitializedInt();
-    public final int methodCompiledEntryOffset = getUninitializedInt();
-    public final int basicLockSize = getUninitializedInt();
-    public final int basicLockDisplacedHeaderOffset = getUninitializedInt();
-    public final long tlabIntArrayMarkWord = getUninitializedLong();
-    public final long heapEndAddress = getUninitializedLong();
-    public final long heapTopAddress = getUninitializedLong();
-    public final int threadTlabStartOffset = getUninitializedInt();
-    public final int threadTlabSizeOffset = getUninitializedInt();
-    public final int threadAllocatedBytesOffset = getUninitializedInt();
-    public final int threadLastJavaSpOffset = getUninitializedInt();
-    public final int threadLastJavaPcOffset = getUninitializedInt();
-
-    /**
-     * This value is only valid on AMD64.
-     */
-    public final int threadLastJavaFpOffset = getUninitializedInt();
+    @HotSpotVMField(name = "MethodData::_data[0]", get = HotSpotVMField.Type.OFFSET) @Stable public int methodDataOopDataOffset;
+    @HotSpotVMField(name = "MethodData::_trap_hist._array[0]", get = HotSpotVMField.Type.OFFSET) @Stable public int methodDataOopTrapHistoryOffset;
 
     /**
-     * This value is only valid on SPARC.
+     * The DataLayout header size is the same as the cell size.
      */
-    public final int threadJavaFrameAnchorFlagsOffset = getUninitializedInt();
+    @HotSpotVMConstant(name = "DataLayout::cell_size") @Stable public int dataLayoutHeaderSize;
+    @HotSpotVMField(name = "DataLayout::_header._struct._tag", get = HotSpotVMField.Type.OFFSET) @Stable public int dataLayoutTagOffset;
+    @HotSpotVMField(name = "DataLayout::_header._struct._flags", get = HotSpotVMField.Type.OFFSET) @Stable public int dataLayoutFlagsOffset;
+    @HotSpotVMField(name = "DataLayout::_header._struct._bci", get = HotSpotVMField.Type.OFFSET) @Stable public int dataLayoutBCIOffset;
+    @HotSpotVMField(name = "DataLayout::_cells[0]", get = HotSpotVMField.Type.OFFSET) @Stable public int dataLayoutCellsOffset;
+    @HotSpotVMConstant(name = "DataLayout::cell_size") @Stable public int dataLayoutCellSize;
 
-    public final int threadObjectResultOffset = getUninitializedInt();
-    public final int tlabRefillWasteLimitOffset = getUninitializedInt();
-    public final int tlabRefillWasteIncrement = getUninitializedInt();
-    public final int tlabAlignmentReserve = getUninitializedInt();
-    public final int tlabSlowAllocationsOffset = getUninitializedInt();
-    public final int tlabFastRefillWasteOffset = getUninitializedInt();
-    public final int tlabNumberOfRefillsOffset = getUninitializedInt();
-    public final boolean tlabStats = getVMOption("TLABStats");
-    public final int klassInstanceSizeOffset = getUninitializedInt();
-    public final boolean inlineContiguousAllocationSupported = getUninitializedBoolean();
-    public final long arrayPrototypeMarkWord = getUninitializedLong();
-    public final int layoutHelperLog2ElementSizeShift = getUninitializedInt();
-    public final int layoutHelperLog2ElementSizeMask = getUninitializedInt();
-    public final int layoutHelperElementTypeShift = getUninitializedInt();
-    public final int layoutHelperElementTypeMask = getUninitializedInt();
-    public final int layoutHelperElementTypePrimitiveInPlace = getUninitializedInt();
-    public final int layoutHelperHeaderSizeShift = getUninitializedInt();
-    public final int layoutHelperHeaderSizeMask = getUninitializedInt();
-    public final int layoutHelperOffset = getUninitializedInt();
+    @HotSpotVMFlag(name = "BciProfileWidth") @Stable public int bciProfileWidth;
+    @HotSpotVMFlag(name = "TypeProfileWidth") @Stable public int typeProfileWidth;
+    @HotSpotVMFlag(name = "MethodProfileWidth") @Stable public int methodProfileWidth;
+
+    @HotSpotVMField(name = "CodeBlob::_code_offset", get = HotSpotVMField.Type.OFFSET) @Stable private int codeBlobCodeOffsetOffset;
+    @HotSpotVMField(name = "SharedRuntime::_ic_miss_blob", get = HotSpotVMField.Type.VALUE) @Stable private long inlineCacheMissBlob;
+
+    public long inlineCacheMissStub() {
+        return inlineCacheMissBlob + unsafe.getInt(inlineCacheMissBlob + codeBlobCodeOffsetOffset);
+    }
 
-    // methodData information
-    public final int methodDataOopDataOffset = getUninitializedInt();
-    public final int methodDataOopTrapHistoryOffset = getUninitializedInt();
-    public final int dataLayoutHeaderSize = getUninitializedInt();
-    public final int dataLayoutTagOffset = getUninitializedInt();
-    public final int dataLayoutFlagsOffset = getUninitializedInt();
-    public final int dataLayoutBCIOffset = getUninitializedInt();
-    public final int dataLayoutCellsOffset = getUninitializedInt();
-    public final int dataLayoutCellSize = getUninitializedInt();
+    @HotSpotVMField(name = "CodeCache::_heap", get = HotSpotVMField.Type.VALUE) @Stable private long codeCacheHeap;
+    @HotSpotVMField(name = "CodeHeap::_memory", get = HotSpotVMField.Type.OFFSET) @Stable private int codeHeapMemoryOffset;
+    @HotSpotVMField(name = "VirtualSpace::_low_boundary", get = HotSpotVMField.Type.OFFSET) @Stable private int virtualSpaceLowBoundaryOffset;
+    @HotSpotVMField(name = "VirtualSpace::_high_boundary", get = HotSpotVMField.Type.OFFSET) @Stable private int virtualSpaceHighBoundaryOffset;
 
-    // develop flag; might change
-    public final int bciProfileWidth = getVMOption("BciProfileWidth", 2);
+    /**
+     * @return CodeCache::_heap->_memory._low_boundary
+     */
+    public long codeCacheLowBoundary() {
+        return unsafe.getAddress(codeCacheHeap + codeHeapMemoryOffset + virtualSpaceLowBoundaryOffset);
+    }
 
-    public final int typeProfileWidth = getVMOptionInt("TypeProfileWidth");
-    public final int methodProfileWidth = getVMOptionInt("MethodProfileWidth");
+    /**
+     * @return CodeCache::_heap->_memory._high_boundary
+     */
+    public long codeCacheHighBoundary() {
+        return unsafe.getAddress(codeCacheHeap + codeHeapMemoryOffset + virtualSpaceHighBoundaryOffset);
+    }
 
-    public final long inlineCacheMissStub = getUninitializedLong();
-    public final long handleDeoptStub = getUninitializedLong();
-    public final long uncommonTrapStub = getUninitializedLong();
+    @Stable public long handleDeoptStub;
+    @Stable public long uncommonTrapStub;
 
-    public final long aescryptEncryptBlockStub = getUninitializedLong();
-    public final long aescryptDecryptBlockStub = getUninitializedLong();
-    public final long cipherBlockChainingEncryptAESCryptStub = getUninitializedLong();
-    public final long cipherBlockChainingDecryptAESCryptStub = getUninitializedLong();
-    public final long updateBytesCRC32Stub = getUninitializedLong();
+    @HotSpotVMField(name = "StubRoutines::_aescrypt_encryptBlock", get = HotSpotVMField.Type.VALUE) @Stable public long aescryptEncryptBlockStub;
+    @HotSpotVMField(name = "StubRoutines::_aescrypt_decryptBlock", get = HotSpotVMField.Type.VALUE) @Stable public long aescryptDecryptBlockStub;
+    @HotSpotVMField(name = "StubRoutines::_cipherBlockChaining_encryptAESCrypt", get = HotSpotVMField.Type.VALUE) @Stable public long cipherBlockChainingEncryptAESCryptStub;
+    @HotSpotVMField(name = "StubRoutines::_cipherBlockChaining_decryptAESCrypt", get = HotSpotVMField.Type.VALUE) @Stable public long cipherBlockChainingDecryptAESCryptStub;
+    @HotSpotVMField(name = "StubRoutines::_updateBytesCRC32", get = HotSpotVMField.Type.VALUE) @Stable public long updateBytesCRC32Stub;
+    @HotSpotVMField(name = "StubRoutines::_crc_table_adr", get = HotSpotVMField.Type.VALUE) @Stable public long crcTableAddress;
 
-    public final long newInstanceAddress = getUninitializedLong();
-    public final long newArrayAddress = getUninitializedLong();
-    public final long newMultiArrayAddress = getUninitializedLong();
-    public final long dynamicNewArrayAddress = getUninitializedLong();
-    public final long registerFinalizerAddress = getUninitializedLong();
-    public final long threadIsInterruptedAddress = getUninitializedLong();
-    public final long vmMessageAddress = getUninitializedLong();
-    public final long identityHashCodeAddress = getUninitializedLong();
-    public final long exceptionHandlerForPcAddress = getUninitializedLong();
-    public final long exceptionHandlerForReturnAddressAddress = getUninitializedLong();
-    public final long osrMigrationEndAddress = getUninitializedLong();
-    public final long monitorenterAddress = getUninitializedLong();
-    public final long monitorexitAddress = getUninitializedLong();
-    public final long createNullPointerExceptionAddress = getUninitializedLong();
-    public final long createOutOfBoundsExceptionAddress = getUninitializedLong();
-    public final long logPrimitiveAddress = getUninitializedLong();
-    public final long logObjectAddress = getUninitializedLong();
-    public final long logPrintfAddress = getUninitializedLong();
-    public final long vmErrorAddress = getUninitializedLong();
-    public final long writeBarrierPreAddress = getUninitializedLong();
-    public final long writeBarrierPostAddress = getUninitializedLong();
-    public final long validateObject = getUninitializedLong();
-    public final long javaTimeMillisAddress = getUninitializedLong();
-    public final long javaTimeNanosAddress = getUninitializedLong();
-    public final long arithmeticSinAddress = getUninitializedLong();
-    public final long arithmeticCosAddress = getUninitializedLong();
-    public final long arithmeticTanAddress = getUninitializedLong();
-    public final long loadAndClearExceptionAddress = getUninitializedLong();
-    public final long crcTableAddress = getUninitializedLong();
+    @Stable public long newInstanceAddress;
+    @Stable public long newArrayAddress;
+    @Stable public long newMultiArrayAddress;
+    @Stable public long dynamicNewArrayAddress;
+    @Stable public long registerFinalizerAddress;
+    @Stable public long threadIsInterruptedAddress;
+    @Stable public long vmMessageAddress;
+    @Stable public long identityHashCodeAddress;
+    @Stable public long exceptionHandlerForPcAddress;
+    @Stable public long exceptionHandlerForReturnAddressAddress;
+    @Stable public long osrMigrationEndAddress;
+    @Stable public long monitorenterAddress;
+    @Stable public long monitorexitAddress;
+    @Stable public long createNullPointerExceptionAddress;
+    @Stable public long createOutOfBoundsExceptionAddress;
+    @Stable public long logPrimitiveAddress;
+    @Stable public long logObjectAddress;
+    @Stable public long logPrintfAddress;
+    @Stable public long vmErrorAddress;
+    @Stable public long writeBarrierPreAddress;
+    @Stable public long writeBarrierPostAddress;
+    @Stable public long validateObject;
+    @Stable public long javaTimeMillisAddress;
+    @Stable public long javaTimeNanosAddress;
+    @Stable public long arithmeticSinAddress;
+    @Stable public long arithmeticCosAddress;
+    @Stable public long arithmeticTanAddress;
+    @Stable public long loadAndClearExceptionAddress;
 
-    public final int deoptReasonNone = getUninitializedInt();
-    public final int deoptReasonNullCheck = getUninitializedInt();
-    public final int deoptReasonRangeCheck = getUninitializedInt();
-    public final int deoptReasonClassCheck = getUninitializedInt();
-    public final int deoptReasonArrayCheck = getUninitializedInt();
-    public final int deoptReasonUnreached0 = getUninitializedInt();
-    public final int deoptReasonTypeCheckInlining = getUninitializedInt();
-    public final int deoptReasonOptimizedTypeCheck = getUninitializedInt();
-    public final int deoptReasonNotCompiledExceptionHandler = getUninitializedInt();
-    public final int deoptReasonUnresolved = getUninitializedInt();
-    public final int deoptReasonJsrMismatch = getUninitializedInt();
-    public final int deoptReasonDiv0Check = getUninitializedInt();
-    public final int deoptReasonConstraint = getUninitializedInt();
-    public final int deoptReasonLoopLimitCheck = getUninitializedInt();
+    @HotSpotVMConstant(name = "Deoptimization::Reason_none") @Stable public int deoptReasonNone;
+    @HotSpotVMConstant(name = "Deoptimization::Reason_null_check") @Stable public int deoptReasonNullCheck;
+    @HotSpotVMConstant(name = "Deoptimization::Reason_range_check") @Stable public int deoptReasonRangeCheck;
+    @HotSpotVMConstant(name = "Deoptimization::Reason_class_check") @Stable public int deoptReasonClassCheck;
+    @HotSpotVMConstant(name = "Deoptimization::Reason_array_check") @Stable public int deoptReasonArrayCheck;
+    @HotSpotVMConstant(name = "Deoptimization::Reason_null_assert") @Stable public int deoptReasonUnreached0;
+    @HotSpotVMConstant(name = "Deoptimization::Reason_intrinsic") @Stable public int deoptReasonTypeCheckInlining;
+    @HotSpotVMConstant(name = "Deoptimization::Reason_bimorphic") @Stable public int deoptReasonOptimizedTypeCheck;
+    @HotSpotVMConstant(name = "Deoptimization::Reason_unhandled") @Stable public int deoptReasonNotCompiledExceptionHandler;
+    @HotSpotVMConstant(name = "Deoptimization::Reason_uninitialized") @Stable public int deoptReasonUnresolved;
+    @HotSpotVMConstant(name = "Deoptimization::Reason_age") @Stable public int deoptReasonJsrMismatch;
+    @HotSpotVMConstant(name = "Deoptimization::Reason_div0_check") @Stable public int deoptReasonDiv0Check;
+    @HotSpotVMConstant(name = "Deoptimization::Reason_constraint") @Stable public int deoptReasonConstraint;
+    @HotSpotVMConstant(name = "Deoptimization::Reason_loop_limit_check") @Stable public int deoptReasonLoopLimitCheck;
 
-    public final int deoptActionNone = getUninitializedInt();
-    public final int deoptActionMaybeRecompile = getUninitializedInt();
-    public final int deoptActionReinterpret = getUninitializedInt();
-    public final int deoptActionMakeNotEntrant = getUninitializedInt();
-    public final int deoptActionMakeNotCompilable = getUninitializedInt();
+    @HotSpotVMConstant(name = "Deoptimization::Action_none") @Stable public int deoptActionNone;
+    @HotSpotVMConstant(name = "Deoptimization::Action_maybe_recompile") @Stable public int deoptActionMaybeRecompile;
+    @HotSpotVMConstant(name = "Deoptimization::Action_reinterpret") @Stable public int deoptActionReinterpret;
+    @HotSpotVMConstant(name = "Deoptimization::Action_make_not_entrant") @Stable public int deoptActionMakeNotEntrant;
+    @HotSpotVMConstant(name = "Deoptimization::Action_make_not_compilable") @Stable public int deoptActionMakeNotCompilable;
 
-    public final int vmIntrinsicInvokeBasic = getUninitializedInt();
-    public final int vmIntrinsicLinkToVirtual = getUninitializedInt();
-    public final int vmIntrinsicLinkToStatic = getUninitializedInt();
-    public final int vmIntrinsicLinkToSpecial = getUninitializedInt();
-    public final int vmIntrinsicLinkToInterface = getUninitializedInt();
+    @HotSpotVMConstant(name = "vmIntrinsics::_invokeBasic") @Stable public int vmIntrinsicInvokeBasic;
+    @HotSpotVMConstant(name = "vmIntrinsics::_linkToVirtual") @Stable public int vmIntrinsicLinkToVirtual;
+    @HotSpotVMConstant(name = "vmIntrinsics::_linkToStatic") @Stable public int vmIntrinsicLinkToStatic;
+    @HotSpotVMConstant(name = "vmIntrinsics::_linkToSpecial") @Stable public int vmIntrinsicLinkToSpecial;
+    @HotSpotVMConstant(name = "vmIntrinsics::_linkToInterface") @Stable public int vmIntrinsicLinkToInterface;
 
     public boolean check() {
-        assert codeEntryAlignment > 0 : codeEntryAlignment;
-        assert stackShadowPages > 0;
         for (Field f : getClass().getDeclaredFields()) {
             int modifiers = f.getModifiers();
             if (Modifier.isPublic(modifiers) && !Modifier.isStatic(modifiers)) {
-                assert Modifier.isFinal(modifiers) : "field should be final: " + f;
+                assert Modifier.isFinal(modifiers) || f.getAnnotation(Stable.class) != null : "field should either be final or @Stable: " + f;
             }
         }
+
+        assert codeEntryAlignment > 0 : codeEntryAlignment;
+        assert stackShadowPages > 0 : stackShadowPages;
+
+        assert (layoutHelperArrayTagObjectValue & layoutHelperArrayTagTypeValue & arrayKlassLayoutHelperIdentifier) != 0 : "object array and type array must have first bit set";
+
         return true;
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConstant.java	Thu Oct 24 22:28:09 2013 +0200
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot;
+
+import java.lang.annotation.*;
+
+@Target(ElementType.FIELD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface HotSpotVMConstant {
+
+    String name();
+
+    boolean optional() default false;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMField.java	Thu Oct 24 22:28:09 2013 +0200
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot;
+
+import java.lang.annotation.*;
+
+@Target(ElementType.FIELD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface HotSpotVMField {
+
+    enum Type {
+        OFFSET, ADDRESS, VALUE;
+    }
+
+    String name();
+
+    Type get();
+
+    boolean optional() default false;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMFlag.java	Thu Oct 24 22:28:09 2013 +0200
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot;
+
+import java.lang.annotation.*;
+
+@Target(ElementType.FIELD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface HotSpotVMFlag {
+
+    String name();
+
+    boolean optional() default false;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMType.java	Thu Oct 24 22:28:09 2013 +0200
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot;
+
+import java.lang.annotation.*;
+
+@Target(ElementType.FIELD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface HotSpotVMType {
+
+    enum Type {
+        SIZE;
+    }
+
+    String name();
+
+    Type get();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/Stable.java	Thu Oct 24 22:28:09 2013 +0200
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.graal.hotspot;
+
+import java.lang.annotation.*;
+
+// TODO remove this annotation after we moved to JDK 8 and use sun.invoke.Stable instead
+
+@Target(ElementType.FIELD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Stable {
+}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java	Thu Oct 24 16:01:44 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java	Thu Oct 24 22:28:09 2013 +0200
@@ -120,8 +120,6 @@
      */
     JavaType lookupType(String name, HotSpotResolvedObjectType accessingClass, boolean eagerResolve);
 
-    int constantPoolLength(HotSpotResolvedObjectType pool);
-
     Object lookupConstantInPool(HotSpotResolvedObjectType pool, int cpi);
 
     JavaMethod lookupMethodInPool(HotSpotResolvedObjectType pool, int cpi, byte opcode);
@@ -202,10 +200,6 @@
 
     Object executeCompiledMethodVarargs(Object[] args, HotSpotInstalledCode hotspotInstalledCode) throws InvalidInstalledCodeException;
 
-    int getVtableEntryOffset(long metaspaceMethod);
-
-    boolean hasVtableEntry(long metaspaceMethod);
-
     long[] getDeoptedLeafGraphIds();
 
     long[] getLineNumberTable(HotSpotResolvedJavaMethod method);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java	Thu Oct 24 16:01:44 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java	Thu Oct 24 22:28:09 2013 +0200
@@ -76,9 +76,6 @@
     public native JavaType lookupType(String name, HotSpotResolvedObjectType accessingClass, boolean eagerResolve);
 
     @Override
-    public native int constantPoolLength(HotSpotResolvedObjectType pool);
-
-    @Override
     public native Object lookupConstantInPool(HotSpotResolvedObjectType pool, int cpi);
 
     @Override
@@ -145,12 +142,6 @@
     public native Object executeCompiledMethodVarargs(Object[] args, HotSpotInstalledCode hotspotInstalledCode);
 
     @Override
-    public native int getVtableEntryOffset(long metaspaceMethod);
-
-    @Override
-    public native boolean hasVtableEntry(long metaspaceMethod);
-
-    @Override
     public native long[] getDeoptedLeafGraphIds();
 
     @Override
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotConstantPool.java	Thu Oct 24 16:01:44 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotConstantPool.java	Thu Oct 24 22:28:09 2013 +0200
@@ -22,6 +22,7 @@
  */
 package com.oracle.graal.hotspot.meta;
 
+import static com.oracle.graal.graph.UnsafeAccess.*;
 import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
 
 import com.oracle.graal.api.meta.*;
@@ -43,7 +44,9 @@
 
     @Override
     public int length() {
-        return runtime().getCompilerToVM().constantPoolLength(type);
+        HotSpotVMConfig config = runtime().getConfig();
+        long constantPoolAddress = unsafe.getAddress(type.metaspaceKlass() + config.instanceKlassConstantsOffset);
+        return unsafe.getInt(constantPoolAddress + config.constantPoolLengthOffset);
     }
 
     @Override
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotHostForeignCallsProvider.java	Thu Oct 24 16:01:44 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotHostForeignCallsProvider.java	Thu Oct 24 22:28:09 2013 +0200
@@ -164,7 +164,7 @@
 
         registerForeignCall(UNCOMMON_TRAP, c.uncommonTrapStub, NativeCall, PRESERVES_REGISTERS, LEAF, REEXECUTABLE, NO_LOCATIONS);
         registerForeignCall(DEOPT_HANDLER, c.handleDeoptStub, NativeCall, PRESERVES_REGISTERS, LEAF, REEXECUTABLE, NO_LOCATIONS);
-        registerForeignCall(IC_MISS_HANDLER, c.inlineCacheMissStub, NativeCall, PRESERVES_REGISTERS, LEAF, REEXECUTABLE, NO_LOCATIONS);
+        registerForeignCall(IC_MISS_HANDLER, c.inlineCacheMissStub(), NativeCall, PRESERVES_REGISTERS, LEAF, REEXECUTABLE, NO_LOCATIONS);
 
         registerForeignCall(JAVA_TIME_MILLIS, c.javaTimeMillisAddress, NativeCall, DESTROYS_REGISTERS, LEAF, REEXECUTABLE, NO_LOCATIONS);
         registerForeignCall(JAVA_TIME_NANOS, c.javaTimeNanosAddress, NativeCall, DESTROYS_REGISTERS, LEAF, REEXECUTABLE, NO_LOCATIONS);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaField.java	Thu Oct 24 16:01:44 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaField.java	Thu Oct 24 22:28:09 2013 +0200
@@ -199,6 +199,11 @@
                 if (assumeNonStaticFinalFieldsAsFinal(object.getClass()) || !value.isDefaultForKind()) {
                     return value;
                 }
+            } else if (isStable()) {
+                Constant value = readValue(receiver);
+                if (assumeDefaultStableFieldsAsFinal(object.getClass()) || !value.isDefaultForKind()) {
+                    return value;
+                }
             } else {
                 Class<?> clazz = object.getClass();
                 if (StableOptionValue.class.isAssignableFrom(clazz)) {
@@ -229,6 +234,20 @@
         return clazz == SnippetCounter.class;
     }
 
+    /**
+     * Usually {@link Stable} fields are not considered constant if the value is the
+     * {@link Constant#isDefaultForKind default value}. For some special classes we want to override
+     * this behavior.
+     */
+    private static boolean assumeDefaultStableFieldsAsFinal(Class<?> clazz) {
+        // HotSpotVMConfig has a lot of zero-value fields which we know are stable and want to be
+        // considered as constants.
+        if (clazz == HotSpotVMConfig.class) {
+            return true;
+        }
+        return false;
+    }
+
     @Override
     public HotSpotResolvedObjectType getDeclaringClass() {
         return holder;
@@ -267,6 +286,16 @@
         return false;
     }
 
+    /**
+     * Checks if this field has the {@link Stable} annotation.
+     * 
+     * @return true if field has {@link Stable} annotation, false otherwise
+     */
+    public boolean isStable() {
+        Annotation annotation = getAnnotation(Stable.class);
+        return annotation != null;
+    }
+
     @Override
     public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
         Field javaField = toJava();
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java	Thu Oct 24 16:01:44 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java	Thu Oct 24 22:28:09 2013 +0200
@@ -448,7 +448,7 @@
     }
 
     /**
-     * Returns the offset of this method into the v-table. The method must have a v-table entry has
+     * Returns the offset of this method into the v-table. The method must have a v-table entry as
      * indicated by {@link #isInVirtualMethodTable()}, otherwise an exception is thrown.
      * 
      * @return the offset of this method into the v-table
@@ -457,12 +457,19 @@
         if (!isInVirtualMethodTable() || !holder.isInitialized()) {
             throw new GraalInternalError("%s does not have a vtable entry", this);
         }
-        return runtime().getCompilerToVM().getVtableEntryOffset(metaspaceMethod);
+        HotSpotVMConfig config = runtime().getConfig();
+        final int vtableIndex = getVtableIndex();
+        return config.instanceKlassVtableStartOffset + vtableIndex * config.vtableEntrySize + config.vtableEntryMethodOffset;
     }
 
     @Override
     public boolean isInVirtualMethodTable() {
-        return runtime().getCompilerToVM().hasVtableEntry(metaspaceMethod);
+        return getVtableIndex() >= 0;
+    }
+
+    private int getVtableIndex() {
+        HotSpotVMConfig config = runtime().getConfig();
+        return unsafe.getInt(metaspaceMethod + config.methodVtableIndexOffset);
     }
 
     public void setCurrentTask(CompilationTask task) {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java	Thu Oct 24 16:01:44 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java	Thu Oct 24 22:28:09 2013 +0200
@@ -488,6 +488,13 @@
         return Constant.forIntegerKind(runtime().getTarget().wordKind, metaspaceKlass, this);
     }
 
+    /**
+     * Gets the address of the C++ Klass object for this type.
+     */
+    public long metaspaceKlass() {
+        return metaspaceKlass;
+    }
+
     public boolean isPrimaryType() {
         return runtime().getConfig().secondarySuperCacheOffset != superCheckOffset();
     }
@@ -500,7 +507,7 @@
     public long prototypeMarkWord() {
         HotSpotVMConfig config = runtime().getConfig();
         if (isArray()) {
-            return config.arrayPrototypeMarkWord;
+            return config.arrayPrototypeMarkWord();
         } else {
             return unsafeReadWord(metaspaceKlass + config.prototypeMarkWordOffset);
         }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotReplacementsUtil.java	Thu Oct 24 16:01:44 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotReplacementsUtil.java	Thu Oct 24 22:28:09 2013 +0200
@@ -81,21 +81,21 @@
 
     @Fold
     public static int threadTlabTopOffset() {
-        return config().threadTlabTopOffset;
+        return config().threadTlabTopOffset();
     }
 
     public static final LocationIdentity TLAB_END_LOCATION = new NamedLocationIdentity("TlabEnd");
 
     @Fold
     private static int threadTlabEndOffset() {
-        return config().threadTlabEndOffset;
+        return config().threadTlabEndOffset();
     }
 
     public static final LocationIdentity TLAB_START_LOCATION = new NamedLocationIdentity("TlabStart");
 
     @Fold
     private static int threadTlabStartOffset() {
-        return config().threadTlabStartOffset;
+        return config().threadTlabStartOffset();
     }
 
     public static final LocationIdentity PENDING_EXCEPTION_LOCATION = new NamedLocationIdentity("PendingException");
@@ -230,7 +230,7 @@
 
     @Fold
     public static long arrayPrototypeMarkWord() {
-        return config().arrayPrototypeMarkWord;
+        return config().arrayPrototypeMarkWord();
     }
 
     @Fold
@@ -358,22 +358,22 @@
 
     @Fold
     public static int cardTableShift() {
-        return config().cardtableShift;
+        return config().cardtableShift();
     }
 
     @Fold
     public static long cardTableStart() {
-        return config().cardtableStartAddress;
+        return config().cardtableStartAddress();
     }
 
     @Fold
     public static int g1CardQueueIndexOffset() {
-        return config().g1CardQueueIndexOffset;
+        return config().g1CardQueueIndexOffset();
     }
 
     @Fold
     public static int g1CardQueueBufferOffset() {
-        return config().g1CardQueueBufferOffset;
+        return config().g1CardQueueBufferOffset();
     }
 
     @Fold
@@ -383,17 +383,17 @@
 
     @Fold
     public static int g1SATBQueueMarkingOffset() {
-        return config().g1SATBQueueMarkingOffset;
+        return config().g1SATBQueueMarkingOffset();
     }
 
     @Fold
     public static int g1SATBQueueIndexOffset() {
-        return config().g1SATBQueueIndexOffset;
+        return config().g1SATBQueueIndexOffset();
     }
 
     @Fold
     public static int g1SATBQueueBufferOffset() {
-        return config().g1SATBQueueBufferOffset;
+        return config().g1SATBQueueBufferOffset();
     }
 
     @Fold
@@ -561,7 +561,7 @@
 
     @Fold
     public static long tlabIntArrayMarkWord() {
-        return config().tlabIntArrayMarkWord;
+        return config().tlabIntArrayMarkWord();
     }
 
     @Fold
@@ -578,7 +578,7 @@
 
     @Fold
     public static int threadTlabSizeOffset() {
-        return config().threadTlabSizeOffset;
+        return config().threadTlabSizeOffset();
     }
 
     public static final LocationIdentity TLAB_THREAD_ALLOCATED_BYTES_LOCATION = new NamedLocationIdentity("TlabThreadAllocatedBytes");
@@ -592,28 +592,28 @@
 
     @Fold
     public static int tlabRefillWasteLimitOffset() {
-        return config().tlabRefillWasteLimitOffset;
+        return config().tlabRefillWasteLimitOffset();
     }
 
     public static final LocationIdentity TLAB_NOF_REFILLS_LOCATION = new NamedLocationIdentity("TlabNOfRefills");
 
     @Fold
     public static int tlabNumberOfRefillsOffset() {
-        return config().tlabNumberOfRefillsOffset;
+        return config().tlabNumberOfRefillsOffset();
     }
 
     public static final LocationIdentity TLAB_FAST_REFILL_WASTE_LOCATION = new NamedLocationIdentity("TlabFastRefillWaste");
 
     @Fold
     public static int tlabFastRefillWasteOffset() {
-        return config().tlabFastRefillWasteOffset;
+        return config().tlabFastRefillWasteOffset();
     }
 
     public static final LocationIdentity TLAB_SLOW_ALLOCATIONS_LOCATION = new NamedLocationIdentity("TlabSlowAllocations");
 
     @Fold
     public static int tlabSlowAllocationsOffset() {
-        return config().tlabSlowAllocationsOffset;
+        return config().tlabSlowAllocationsOffset();
     }
 
     @Fold
@@ -663,7 +663,7 @@
 
     @Fold
     public static int layoutHelperElementTypePrimitiveInPlace() {
-        return config().layoutHelperElementTypePrimitiveInPlace;
+        return config().layoutHelperElementTypePrimitiveInPlace();
     }
 
     static {
@@ -705,7 +705,7 @@
 
     @Fold
     public static long gcTotalCollectionsAddress() {
-        return config().gcTotalCollectionsAddress;
+        return config().gcTotalCollectionsAddress();
     }
 
     @Fold
--- a/graal/com.oracle.graal.nodes.test/src/com/oracle/graal/nodes/test/IntegerStampTest.java	Thu Oct 24 16:01:44 2013 +0200
+++ b/graal/com.oracle.graal.nodes.test/src/com/oracle/graal/nodes/test/IntegerStampTest.java	Thu Oct 24 22:28:09 2013 +0200
@@ -174,6 +174,13 @@
                         StampTool.add(StampFactory.forInteger(Kind.Long, Long.MIN_VALUE, Long.MIN_VALUE + 1), StampFactory.forInteger(Kind.Long, Integer.MIN_VALUE, Integer.MAX_VALUE)));
         assertEquals(StampFactory.forInteger(Kind.Int, -2147483647, 31 - 2147483647),
                         StampTool.add(StampFactory.forInteger(Kind.Int, 0, 31), StampFactory.forInteger(Kind.Int, -2147483647, -2147483647)));
+
+        assertEquals(StampFactory.forInteger(Kind.Int, 0x8000007e, 0x8000007f, 0x8000007eL, 0x8000007fL),
+                        StampTool.add(StampFactory.forInteger(Kind.Int, 0x7ffffffe, 0x7fffffff, 0x7ffffffeL, 0x7fffffffL), StampFactory.forInteger(Kind.Int, 128, 128)));
+
+        assertEquals(StampFactory.forInteger(Kind.Long, -9223372036854775808L, 9223372036854775806L, 0, 0xfffffffffffffffeL),
+                        StampTool.add(StampFactory.forInteger(Kind.Long, -9223372036854775808L, 9223372036854775806L, 0, 0xfffffffffffffffeL),
+                                        StampFactory.forInteger(Kind.Long, -9223372036854775808L, 9223372036854775806L, 0, 0xfffffffffffffffeL)));
     }
 
     @Test
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/StampTool.java	Thu Oct 24 16:01:44 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/StampTool.java	Thu Oct 24 22:28:09 2013 +0200
@@ -114,13 +114,23 @@
         return StampFactory.forKind(kind);
     }
 
-    private static boolean addOverflows(long x, long y, Kind kind) {
+    private static boolean addOverflowsPositively(long x, long y, Kind kind) {
         long result = x + y;
         if (kind == Kind.Long) {
-            return ((x ^ result) & (y ^ result)) < 0;
+            return (~x & ~y & result) < 0;
         } else {
             assert kind == Kind.Int;
-            return result > Integer.MAX_VALUE || result < Integer.MIN_VALUE;
+            return result > Integer.MAX_VALUE;
+        }
+    }
+
+    private static boolean addOverflowsNegatively(long x, long y, Kind kind) {
+        long result = x + y;
+        if (kind == Kind.Long) {
+            return (x & y & ~result) < 0;
+        } else {
+            assert kind == Kind.Int;
+            return result < Integer.MIN_VALUE;
         }
     }
 
@@ -142,16 +152,22 @@
 
             long lowerBound;
             long upperBound;
-            if (addOverflows(stamp1.lowerBound(), stamp2.lowerBound(), kind) || addOverflows(stamp1.upperBound(), stamp2.upperBound(), kind)) {
+            boolean lowerOverflowsPositively = addOverflowsPositively(stamp1.lowerBound(), stamp2.lowerBound(), kind);
+            boolean upperOverflowsPositively = addOverflowsPositively(stamp1.upperBound(), stamp2.upperBound(), kind);
+            boolean lowerOverflowsNegatively = addOverflowsNegatively(stamp1.lowerBound(), stamp2.lowerBound(), kind);
+            boolean upperOverflowsNegatively = addOverflowsNegatively(stamp1.upperBound(), stamp2.upperBound(), kind);
+            if ((lowerOverflowsNegatively && !upperOverflowsNegatively) || (!lowerOverflowsNegatively && !lowerOverflowsPositively && upperOverflowsPositively)) {
                 lowerBound = kind.getMinValue();
                 upperBound = kind.getMaxValue();
             } else {
-                lowerBound = stamp1.lowerBound() + stamp2.lowerBound();
-                upperBound = stamp1.upperBound() + stamp2.upperBound();
+                lowerBound = signExtend(stamp1.lowerBound() + stamp2.lowerBound(), kind);
+                upperBound = signExtend(stamp1.upperBound() + stamp2.upperBound(), kind);
             }
             IntegerStamp limit = StampFactory.forInteger(kind, lowerBound, upperBound);
             newUpMask &= limit.upMask();
-            return new IntegerStamp(kind, lowerBound | newDownMask, signExtend(upperBound & newUpMask, kind), newDownMask, newUpMask);
+            upperBound = signExtend(upperBound & newUpMask, kind);
+            lowerBound |= newDownMask;
+            return new IntegerStamp(kind, lowerBound, upperBound, newDownMask, newUpMask);
         } catch (Throwable e) {
             throw new RuntimeException(stamp1 + " + " + stamp2, e);
         }
@@ -239,14 +255,15 @@
                 long lowerBound;
                 long upperBound;
                 long downMask = value.downMask() >>> shiftCount;
+                long upMask = value.upMask() >>> shiftCount;
                 if (value.lowerBound() < 0) {
                     lowerBound = downMask;
-                    upperBound = IntegerStamp.defaultMask(kind) >>> shiftCount;
+                    upperBound = upMask;
                 } else {
                     lowerBound = value.lowerBound() >>> shiftCount;
                     upperBound = value.upperBound() >>> shiftCount;
                 }
-                return new IntegerStamp(kind, lowerBound, upperBound, downMask, value.upMask() >>> shiftCount);
+                return new IntegerStamp(kind, lowerBound, upperBound, downMask, upMask);
             }
         }
         long mask = IntegerStamp.upMaskFor(kind, value.lowerBound(), value.upperBound());
@@ -310,7 +327,7 @@
     }
 
     private static long signExtend(long value, Kind valueKind) {
-        if (valueKind != Kind.Char && (value >>> (valueKind.getBitCount() - 1) & 1) == 1) {
+        if (valueKind != Kind.Char && valueKind != Kind.Long && (value >>> (valueKind.getBitCount() - 1) & 1) == 1) {
             return value | (-1L << valueKind.getBitCount());
         } else {
             return value;
--- a/graal/com.oracle.graal.truffle.hotspot.amd64/src/com/oracle/graal/truffle/hotspot/amd64/AMD64HotSpotTruffleBackend.java	Thu Oct 24 16:01:44 2013 +0200
+++ b/graal/com.oracle.graal.truffle.hotspot.amd64/src/com/oracle/graal/truffle/hotspot/amd64/AMD64HotSpotTruffleBackend.java	Thu Oct 24 22:28:09 2013 +0200
@@ -29,27 +29,35 @@
 import com.oracle.graal.asm.*;
 import com.oracle.graal.asm.amd64.*;
 import com.oracle.graal.asm.amd64.AMD64Assembler.ConditionFlag;
+import com.oracle.graal.compiler.gen.*;
+import com.oracle.graal.compiler.target.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.hotspot.*;
 import com.oracle.graal.hotspot.amd64.*;
 import com.oracle.graal.hotspot.meta.*;
+import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.asm.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.phases.tiers.*;
 import com.oracle.graal.truffle.*;
 import com.oracle.graal.truffle.hotspot.amd64.util.*;
 import com.oracle.truffle.api.*;
 import com.oracle.truffle.api.frame.*;
 
 /**
- * Subclass of {@link AMD64HotSpotBackend} that injects special code into
+ * Backend that decorates an existing {@link AMD64HotSpotBackend}, injecting special code into
  * {@link OptimizedCallTarget#call(PackedFrame, Arguments)} for making a tail-call to the entry
  * point of the target callee.
  */
-class AMD64HotSpotTruffleBackend extends AMD64HotSpotBackend {
+class AMD64HotSpotTruffleBackend extends Backend {
+
+    private final AMD64HotSpotBackend original;
 
     private HotSpotResolvedJavaMethod optimizedCallTargetCall;
 
-    public AMD64HotSpotTruffleBackend(HotSpotGraalRuntime runtime, HotSpotProviders providers) {
-        super(runtime, providers);
+    public AMD64HotSpotTruffleBackend(AMD64HotSpotBackend original) {
+        super(original.getProviders());
+        this.original = original;
     }
 
     private ResolvedJavaMethod getInstrumentedMethod() throws GraalInternalError {
@@ -66,34 +74,88 @@
     }
 
     @Override
-    protected void emitCodePrefix(ResolvedJavaMethod installedCodeOwner, TargetMethodAssembler tasm, AMD64MacroAssembler asm, RegisterConfig regConfig, HotSpotVMConfig config, Label verifiedStub) {
-        super.emitCodePrefix(installedCodeOwner, tasm, asm, regConfig, config, verifiedStub);
-        if (getInstrumentedMethod().equals(installedCodeOwner)) {
-            HotSpotProviders providers = getRuntime().getHostProviders();
-            Register thisRegister = providers.getCodeCache().getRegisterConfig().getCallingConventionRegisters(Type.JavaCall, Kind.Object)[0];
-            Register spillRegister = AMD64.r10; // TODO(mg): fix me
-            AMD64Address nMethodAddress = new AMD64Address(thisRegister, OptimizedCallTargetFieldInfo.getCompiledMethodFieldOffset());
-            if (config.useCompressedOops) {
-                asm.movl(spillRegister, nMethodAddress);
-                AMD64HotSpotMove.decodePointer(asm, spillRegister, providers.getRegisters().getHeapBaseRegister(), config.narrowOopBase, config.narrowOopShift, config.logMinObjAlignment);
-            } else {
-                asm.movq(spillRegister, nMethodAddress);
-            }
-            Label doProlog = new Label();
+    public SuitesProvider getSuites() {
+        return original.getSuites();
+    }
+
+    @Override
+    public DisassemblerProvider getDisassembler() {
+        return original.getDisassembler();
+    }
+
+    @Override
+    public FrameMap newFrameMap() {
+        return original.newFrameMap();
+    }
+
+    @Override
+    public LIRGenerator newLIRGenerator(StructuredGraph graph, FrameMap frameMap, CallingConvention cc, LIR lir) {
+        return original.newLIRGenerator(graph, frameMap, cc, lir);
+    }
+
+    @Override
+    protected AbstractAssembler createAssembler(FrameMap frameMap) {
+        return null;
+    }
+
+    @Override
+    public TargetMethodAssembler newAssembler(LIRGenerator lirGen, CompilationResult compilationResult) {
+        return original.newAssembler(lirGen, compilationResult);
+    }
+
+    @Override
+    public boolean shouldAllocateRegisters() {
+        return original.shouldAllocateRegisters();
+    }
+
+    @Override
+    public void emitCode(TargetMethodAssembler tasm, LIRGenerator lirGen, ResolvedJavaMethod installedCodeOwner) {
+        AMD64MacroAssembler asm = (AMD64MacroAssembler) tasm.asm;
+        FrameMap frameMap = tasm.frameMap;
+        RegisterConfig regConfig = frameMap.registerConfig;
+        HotSpotVMConfig config = original.getRuntime().getConfig();
+        Label verifiedStub = new Label();
 
-            asm.cmpq(spillRegister, 0);
-            asm.jcc(ConditionFlag.Equal, doProlog);
+        // Emit the prefix
+        original.emitCodePrefix(installedCodeOwner, tasm, asm, regConfig, config, verifiedStub);
+
+        if (getInstrumentedMethod().equals(installedCodeOwner)) {
+            // Inject code for {@link OptimizedCallTarget#call(PackedFrame, Arguments)}
+            injectCode(asm, config);
+        }
+
+        // Emit code for the LIR
+        original.emitCodeBody(installedCodeOwner, tasm, lirGen);
+
+        // Emit the suffix
+        original.emitCodeSuffix(installedCodeOwner, tasm, lirGen, asm, frameMap);
+    }
 
-            AMD64Address codeBlobAddress = new AMD64Address(spillRegister, OptimizedCallTargetFieldInfo.getCodeBlobFieldOffset());
-            asm.movq(spillRegister, codeBlobAddress);
-            asm.cmpq(spillRegister, 0);
-            asm.jcc(ConditionFlag.Equal, doProlog);
+    private void injectCode(AMD64MacroAssembler asm, HotSpotVMConfig config) {
+        HotSpotProviders providers = original.getRuntime().getHostProviders();
+        Register thisRegister = providers.getCodeCache().getRegisterConfig().getCallingConventionRegisters(Type.JavaCall, Kind.Object)[0];
+        Register spillRegister = AMD64.r10; // TODO(mg): fix me
+        AMD64Address nMethodAddress = new AMD64Address(thisRegister, OptimizedCallTargetFieldInfo.getCompiledMethodFieldOffset());
+        if (config.useCompressedOops) {
+            asm.movl(spillRegister, nMethodAddress);
+            AMD64HotSpotMove.decodePointer(asm, spillRegister, providers.getRegisters().getHeapBaseRegister(), config.narrowOopBase, config.narrowOopShift, config.logMinObjAlignment());
+        } else {
+            asm.movq(spillRegister, nMethodAddress);
+        }
+        Label doProlog = new Label();
 
-            AMD64Address verifiedEntryPointAddress = new AMD64Address(spillRegister, config.nmethodEntryOffset);
-            asm.movq(spillRegister, verifiedEntryPointAddress);
-            asm.jmp(spillRegister);
+        asm.cmpq(spillRegister, 0);
+        asm.jcc(ConditionFlag.Equal, doProlog);
 
-            asm.bind(doProlog);
-        }
+        AMD64Address codeBlobAddress = new AMD64Address(spillRegister, OptimizedCallTargetFieldInfo.getCodeBlobFieldOffset());
+        asm.movq(spillRegister, codeBlobAddress);
+        asm.cmpq(spillRegister, 0);
+        asm.jcc(ConditionFlag.Equal, doProlog);
+
+        AMD64Address verifiedEntryPointAddress = new AMD64Address(spillRegister, config.nmethodEntryOffset);
+        asm.movq(spillRegister, verifiedEntryPointAddress);
+        asm.jmp(spillRegister);
+
+        asm.bind(doProlog);
     }
 }
--- a/graal/com.oracle.graal.truffle.hotspot.amd64/src/com/oracle/graal/truffle/hotspot/amd64/AMD64HotSpotTruffleBackendFactory.java	Thu Oct 24 16:01:44 2013 +0200
+++ b/graal/com.oracle.graal.truffle.hotspot.amd64/src/com/oracle/graal/truffle/hotspot/amd64/AMD64HotSpotTruffleBackendFactory.java	Thu Oct 24 22:28:09 2013 +0200
@@ -23,18 +23,22 @@
 package com.oracle.graal.truffle.hotspot.amd64;
 
 import com.oracle.graal.api.runtime.*;
-import com.oracle.graal.hotspot.*;
+import com.oracle.graal.compiler.target.*;
 import com.oracle.graal.hotspot.amd64.*;
-import com.oracle.graal.hotspot.meta.*;
+import com.oracle.graal.truffle.*;
 
 /**
  * Factory to create a Truffle-specialized AMD64 HotSpot backend.
  */
-@ServiceProvider(HotSpotBackendFactory.class)
-public class AMD64HotSpotTruffleBackendFactory extends AMD64HotSpotBackendFactory {
+@ServiceProvider(TruffleBackendFactory.class)
+public class AMD64HotSpotTruffleBackendFactory implements TruffleBackendFactory {
 
     @Override
-    protected AMD64HotSpotBackend createBackend(HotSpotGraalRuntime runtime, HotSpotProviders providers) {
-        return new AMD64HotSpotTruffleBackend(runtime, providers);
+    public Backend createBackend(Backend original) {
+        return new AMD64HotSpotTruffleBackend((AMD64HotSpotBackend) original);
+    }
+
+    public String getArchitecture() {
+        return "AMD64";
     }
 }
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java	Thu Oct 24 16:01:44 2013 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java	Thu Oct 24 22:28:09 2013 +0200
@@ -174,6 +174,18 @@
         return method;
     }
 
+    private static Backend instrumentBackend(Backend original) {
+        String arch = original.getTarget().arch.getName();
+
+        for (TruffleBackendFactory factory : ServiceLoader.loadInstalled(TruffleBackendFactory.class)) {
+            if (factory.getArchitecture().equals(arch)) {
+                return factory.createBackend(original);
+            }
+        }
+
+        return original;
+    }
+
     private static CompilationResult compileMethod(ResolvedJavaMethod javaMethod) {
         Providers providers = getGraalProviders();
         MetaAccessProvider metaAccess = providers.getMetaAccess();
@@ -187,8 +199,8 @@
         phasePlan.addPhase(PhasePosition.AFTER_PARSING, graphBuilderPhase);
         CallingConvention cc = getCallingConvention(providers.getCodeCache(), Type.JavaCallee, graph.method(), false);
         Backend backend = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend();
-        return GraalCompiler.compileGraph(graph, cc, javaMethod, providers, backend, providers.getCodeCache().getTarget(), null, phasePlan, OptimisticOptimizations.ALL, new SpeculationLog(), suites,
-                        new CompilationResult());
+        return GraalCompiler.compileGraph(graph, cc, javaMethod, providers, instrumentBackend(backend), providers.getCodeCache().getTarget(), null, phasePlan, OptimisticOptimizations.ALL,
+                        new SpeculationLog(), suites, new CompilationResult());
     }
 
     private static Providers getGraalProviders() {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleBackendFactory.java	Thu Oct 24 22:28:09 2013 +0200
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.truffle;
+
+import com.oracle.graal.compiler.target.*;
+
+public interface TruffleBackendFactory {
+
+    Backend createBackend(Backend original);
+
+    /**
+     * Gets the CPU architecture of this backend.
+     */
+    String getArchitecture();
+}
--- a/src/cpu/x86/vm/vmStructs_x86.hpp	Thu Oct 24 16:01:44 2013 +0200
+++ b/src/cpu/x86/vm/vmStructs_x86.hpp	Thu Oct 24 22:28:09 2013 +0200
@@ -43,7 +43,8 @@
 
 #define VM_TYPES_CPU(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type, declare_c1_toplevel_type, declare_c2_type, declare_c2_toplevel_type)
 
-#define VM_INT_CONSTANTS_CPU(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant)
+#define VM_INT_CONSTANTS_CPU(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant) \
+  declare_constant(frame::arg_reg_save_area_bytes)
 
 #define VM_LONG_CONSTANTS_CPU(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant)
 
--- a/src/share/vm/gc_interface/collectedHeap.hpp	Thu Oct 24 16:01:44 2013 +0200
+++ b/src/share/vm/gc_interface/collectedHeap.hpp	Thu Oct 24 22:28:09 2013 +0200
@@ -491,9 +491,7 @@
   // Total number of GC collections (started)
   unsigned int total_collections() const { return _total_collections; }
   unsigned int total_full_collections() const { return _total_full_collections;}
-#ifdef GRAAL
-  unsigned int* total_collections_address() { return &_total_collections;}
-#endif
+
   // Increment total number of GC collections (started)
   // Should be protected but used by PSMarkSweep - cleanup for 1.4.2
   void increment_total_collections(bool full = false) {
--- a/src/share/vm/graal/graalCompilerToVM.cpp	Thu Oct 24 16:01:44 2013 +0200
+++ b/src/share/vm/graal/graalCompilerToVM.cpp	Thu Oct 24 22:28:09 2013 +0200
@@ -38,6 +38,8 @@
 #include "graal/graalCodeInstaller.hpp"
 #include "graal/graalVMToCompiler.hpp"
 #include "gc_implementation/g1/heapRegion.hpp"
+#include "runtime/javaCalls.hpp"
+#include "runtime/vmStructs.hpp"
 
 
 Method* getMethodFromHotSpotMethod(oop hotspot_method) {
@@ -307,11 +309,6 @@
   return code == NULL ? 0 : code->insts_size();
 C2V_END
 
-C2V_VMENTRY(jint, constantPoolLength, (JNIEnv *env, jobject, jobject type))
-  ConstantPool* cp = InstanceKlass::cast(java_lang_Class::as_Klass(HotSpotResolvedObjectType::javaMirror(type)))->constants();
-  return cp->length();
-C2V_END
-
 C2V_VMENTRY(jobject, lookupType, (JNIEnv *env, jobject, jstring jname, jobject accessingClass, jboolean eagerResolve))
   ResourceMark rm;
 
@@ -547,12 +544,14 @@
   return JNIHandles::make_local(THREAD, VMToCompiler::createResolvedJavaMethod(holder, method(), THREAD));
 C2V_END
 
+// TODO move to Java
 C2V_VMENTRY(jboolean, isTypeInitialized,(JNIEnv *, jobject, jobject hotspot_klass))
   Klass* klass = java_lang_Class::as_Klass(HotSpotResolvedObjectType::javaMirror(hotspot_klass));
   assert(klass != NULL, "method must not be called for primitive types");
   return InstanceKlass::cast(klass)->is_initialized();
 C2V_END
 
+// TODO move to Java
 C2V_VMENTRY(jboolean, isTypeLinked,(JNIEnv *, jobject, jobject hotspot_klass))
   Klass* klass = java_lang_Class::as_Klass(HotSpotResolvedObjectType::javaMirror(hotspot_klass));
   assert(klass != NULL, "method must not be called for primitive types");
@@ -649,152 +648,113 @@
   method->set_dont_inline(true);
 C2V_END
 
+extern "C" {
+extern VMStructEntry* gHotSpotVMStructs;
+extern uint64_t gHotSpotVMStructEntryTypeNameOffset;
+extern uint64_t gHotSpotVMStructEntryFieldNameOffset;
+extern uint64_t gHotSpotVMStructEntryTypeStringOffset;
+extern uint64_t gHotSpotVMStructEntryIsStaticOffset;
+extern uint64_t gHotSpotVMStructEntryOffsetOffset;
+extern uint64_t gHotSpotVMStructEntryAddressOffset;
+extern uint64_t gHotSpotVMStructEntryArrayStride;
+
+extern VMTypeEntry* gHotSpotVMTypes;
+extern uint64_t gHotSpotVMTypeEntryTypeNameOffset;
+extern uint64_t gHotSpotVMTypeEntrySuperclassNameOffset;
+extern uint64_t gHotSpotVMTypeEntryIsOopTypeOffset;
+extern uint64_t gHotSpotVMTypeEntryIsIntegerTypeOffset;
+extern uint64_t gHotSpotVMTypeEntryIsUnsignedOffset;
+extern uint64_t gHotSpotVMTypeEntrySizeOffset;
+extern uint64_t gHotSpotVMTypeEntryArrayStride;
+
+extern VMIntConstantEntry* gHotSpotVMIntConstants;
+extern uint64_t gHotSpotVMIntConstantEntryNameOffset;
+extern uint64_t gHotSpotVMIntConstantEntryValueOffset;
+extern uint64_t gHotSpotVMIntConstantEntryArrayStride;
+
+extern VMLongConstantEntry* gHotSpotVMLongConstants;
+extern uint64_t gHotSpotVMLongConstantEntryNameOffset;
+extern uint64_t gHotSpotVMLongConstantEntryValueOffset;
+extern uint64_t gHotSpotVMLongConstantEntryArrayStride;
+}
+
 C2V_ENTRY(void, initializeConfiguration, (JNIEnv *env, jobject, jobject config))
 
 #define set_boolean(name, value) do { env->SetBooleanField(config, getFieldID(env, config, name, "Z"), value); } while (0)
 #define set_int(name, value) do { env->SetIntField(config, getFieldID(env, config, name, "I"), value); } while (0)
 #define set_long(name, value) do { env->SetLongField(config, getFieldID(env, config, name, "J"), value); } while (0)
 #define set_address(name, value) do { set_long(name, (jlong) value); } while (0)
-#define set_object(name, value) do { env->SetObjectField(config, getFieldID(env, config, name, "Ljava/lang/Object;"), value); } while (0)
 
   guarantee(HeapWordSize == sizeof(char*), "Graal assumption that HeadWordSize == machine word size is wrong");
 
-  set_boolean("cAssertions", DEBUG_ONLY(true) NOT_DEBUG(false));
-  set_int("codeEntryAlignment", CodeEntryAlignment);
-  set_int("hubOffset", oopDesc::klass_offset_in_bytes());
-  set_int("markOffset", oopDesc::mark_offset_in_bytes());
-  set_int("prototypeMarkWordOffset", in_bytes(Klass::prototype_header_offset()));
-  set_int("superCheckOffsetOffset", in_bytes(Klass::super_check_offset_offset()));
-  set_int("secondarySuperCacheOffset", in_bytes(Klass::secondary_super_cache_offset()));
-  set_int("secondarySupersOffset", in_bytes(Klass::secondary_supers_offset()));
-  set_int("subklassOffset", in_bytes(Klass::subklass_offset()));
-  set_int("nextSiblingOffset", in_bytes(Klass::next_sibling_offset()));
+  set_address("gHotSpotVMStructs", gHotSpotVMStructs);
+  set_long("gHotSpotVMStructEntryTypeNameOffset",   gHotSpotVMStructEntryTypeNameOffset);
+  set_long("gHotSpotVMStructEntryFieldNameOffset",  gHotSpotVMStructEntryFieldNameOffset);
+  set_long("gHotSpotVMStructEntryTypeStringOffset", gHotSpotVMStructEntryTypeStringOffset);
+  set_long("gHotSpotVMStructEntryIsStaticOffset",   gHotSpotVMStructEntryIsStaticOffset);
+  set_long("gHotSpotVMStructEntryOffsetOffset",     gHotSpotVMStructEntryOffsetOffset);
+  set_long("gHotSpotVMStructEntryAddressOffset",    gHotSpotVMStructEntryAddressOffset);
+  set_long("gHotSpotVMStructEntryArrayStride",      gHotSpotVMStructEntryArrayStride);
+
+  set_address("gHotSpotVMTypes", gHotSpotVMTypes);
+  set_long("gHotSpotVMTypeEntryTypeNameOffset",       gHotSpotVMTypeEntryTypeNameOffset);
+  set_long("gHotSpotVMTypeEntrySuperclassNameOffset", gHotSpotVMTypeEntrySuperclassNameOffset);
+  set_long("gHotSpotVMTypeEntryIsOopTypeOffset",      gHotSpotVMTypeEntryIsOopTypeOffset);
+  set_long("gHotSpotVMTypeEntryIsIntegerTypeOffset",  gHotSpotVMTypeEntryIsIntegerTypeOffset);
+  set_long("gHotSpotVMTypeEntryIsUnsignedOffset",     gHotSpotVMTypeEntryIsUnsignedOffset);
+  set_long("gHotSpotVMTypeEntrySizeOffset",           gHotSpotVMTypeEntrySizeOffset);
+  set_long("gHotSpotVMTypeEntryArrayStride",          gHotSpotVMTypeEntryArrayStride);
+
+  set_address("gHotSpotVMIntConstants", gHotSpotVMIntConstants);
+  set_long("gHotSpotVMIntConstantEntryNameOffset",  gHotSpotVMIntConstantEntryNameOffset);
+  set_long("gHotSpotVMIntConstantEntryValueOffset", gHotSpotVMIntConstantEntryValueOffset);
+  set_long("gHotSpotVMIntConstantEntryArrayStride", gHotSpotVMIntConstantEntryArrayStride);
+
+  set_address("gHotSpotVMLongConstants", gHotSpotVMLongConstants);
+  set_long("gHotSpotVMLongConstantEntryNameOffset",  gHotSpotVMLongConstantEntryNameOffset);
+  set_long("gHotSpotVMLongConstantEntryValueOffset", gHotSpotVMLongConstantEntryValueOffset);
+  set_long("gHotSpotVMLongConstantEntryArrayStride", gHotSpotVMLongConstantEntryArrayStride);
+
+  //------------------------------------------------------------------------------------------------
+
   set_int("arrayLengthOffset", arrayOopDesc::length_offset_in_bytes());
-  set_int("klassStateOffset", in_bytes(InstanceKlass::init_state_offset()));
-  set_int("klassStateFullyInitialized", (int)InstanceKlass::fully_initialized);
-  set_int("threadTlabTopOffset", in_bytes(JavaThread::tlab_top_offset()));
-  set_int("threadTlabEndOffset", in_bytes(JavaThread::tlab_end_offset()));
-  set_int("threadObjectOffset", in_bytes(JavaThread::threadObj_offset()));
-  set_int("threadIsMethodHandleReturnOffset", in_bytes(JavaThread::is_method_handle_return_offset()));
-  set_int("osThreadOffset", in_bytes(JavaThread::osthread_offset()));
-  set_int("osThreadInterruptedOffset", in_bytes(OSThread::interrupted_offset()));
-  set_int("unlockedMask", (int) markOopDesc::unlocked_value);
-  set_int("biasedLockMaskInPlace", (int) markOopDesc::biased_lock_mask_in_place);
-  set_int("ageMaskInPlace", (int) markOopDesc::age_mask_in_place);
-  set_int("epochMaskInPlace", (int) markOopDesc::epoch_mask_in_place);
-  set_int("biasedLockPattern", (int) markOopDesc::biased_lock_pattern);
-  set_int("methodMaxLocalsOffset", in_bytes(ConstMethod::size_of_locals_offset()));
-  set_int("methodConstMethodOffset", in_bytes(Method::const_offset()));
-  set_int("constMethodMaxStackOffset", in_bytes(ConstMethod::max_stack_offset()));
-  set_int("constMethodConstantsOffset", in_bytes(ConstMethod::constants_offset()));
-  set_int("constantPoolHolderOffset", ConstantPool::pool_holder_offset_in_bytes());
+
   set_int("extraStackEntries", Method::extra_stack_entries());
-  set_int("methodAccessFlagsOffset", in_bytes(Method::access_flags_offset()));
-  set_int("methodQueuedForCompilationBit", (int) JVM_ACC_QUEUED);
-  set_int("methodIntrinsicIdOffset", Method::intrinsic_id_offset_in_bytes());
-  set_int("klassHasFinalizerFlag", JVM_ACC_HAS_FINALIZER);
-  set_int("threadExceptionOopOffset", in_bytes(JavaThread::exception_oop_offset()));
-  set_int("threadExceptionPcOffset", in_bytes(JavaThread::exception_pc_offset()));
-  set_long("safepointPollingAddress", (jlong)(os::get_polling_page()));
-#ifdef TARGET_ARCH_x86
-  set_boolean("isPollingPageFar", Assembler::is_polling_page_far());
-  set_int("runtimeCallStackSize", (jint)frame::arg_reg_save_area_bytes);
-#endif
-  set_int("classMirrorOffset", in_bytes(Klass::java_mirror_offset()));
-  set_int("klassModifierFlagsOffset", in_bytes(Klass::modifier_flags_offset()));
-  set_int("klassAccessFlagsOffset", in_bytes(Klass::access_flags_offset()));
-  set_int("klassOffset", java_lang_Class::klass_offset_in_bytes());
-  set_int("arrayKlassOffset", java_lang_Class::array_klass_offset_in_bytes());
-  set_int("graalMirrorInClassOffset", java_lang_Class::graal_mirror_offset_in_bytes());
-  set_int("klassLayoutHelperOffset", in_bytes(Klass::layout_helper_offset()));
-  set_int("klassSuperKlassOffset", in_bytes(Klass::super_offset()));
-  set_int("methodDataOffset", in_bytes(Method::method_data_offset()));
-  set_int("nmethodEntryOffset", nmethod::verified_entry_point_offset());
-  set_int("methodCompiledEntryOffset", in_bytes(Method::from_compiled_offset()));
-  set_int("basicLockSize", sizeof(BasicLock));
-  set_int("basicLockDisplacedHeaderOffset", BasicLock::displaced_header_offset_in_bytes());
-  set_int("uninitializedIdentityHashCodeValue", markOopDesc::no_hash);
-  set_int("identityHashCodeShift", markOopDesc::hash_shift);
-
-  set_int("arrayKlassLayoutHelperIdentifier", 0x80000000);
-  assert((Klass::_lh_array_tag_obj_value & Klass::_lh_array_tag_type_value & 0x80000000) != 0, "obj_array and type_array must have first bit set");
-  set_int("arrayKlassComponentMirrorOffset", in_bytes(ArrayKlass::component_mirror_offset()));
-
-
-  set_int("pendingExceptionOffset", in_bytes(ThreadShadow::pending_exception_offset()));
-  set_int("pendingDeoptimizationOffset", in_bytes(ThreadShadow::pending_deoptimization_offset()));
-
-  set_int("metaspaceArrayLengthOffset", Array<Klass*>::length_offset_in_bytes());
-  set_int("metaspaceArrayBaseOffset", Array<Klass*>::base_offset_in_bytes());
-  set_int("methodDataOopDataOffset", in_bytes(MethodData::data_offset()));
-  set_int("methodDataOopTrapHistoryOffset", in_bytes(MethodData::trap_history_offset()));
-  set_int("dataLayoutHeaderSize", DataLayout::header_size_in_bytes());
-  set_int("dataLayoutTagOffset", in_bytes(DataLayout::tag_offset()));
-  set_int("dataLayoutFlagsOffset", in_bytes(DataLayout::flags_offset()));
-  set_int("dataLayoutBCIOffset", in_bytes(DataLayout::bci_offset()));
-  set_int("dataLayoutCellsOffset", in_bytes(DataLayout::cell_offset(0)));
-  set_int("dataLayoutCellSize", DataLayout::cell_size);
 
   set_int("tlabAlignmentReserve", (int32_t)ThreadLocalAllocBuffer::alignment_reserve());
-  set_long("tlabIntArrayMarkWord", (intptr_t)markOopDesc::prototype()->copy_set_hash(0x2));
   set_long("heapTopAddress", (jlong)(address) Universe::heap()->top_addr());
   set_long("heapEndAddress", (jlong)(address) Universe::heap()->end_addr());
-  set_int("threadTlabStartOffset", in_bytes(JavaThread::tlab_start_offset()));
-  set_int("threadTlabSizeOffset", in_bytes(JavaThread::tlab_size_offset()));
-  set_int("threadAllocatedBytesOffset", in_bytes(JavaThread::allocated_bytes_offset()));
-  set_int("threadLastJavaSpOffset", in_bytes(JavaThread::last_Java_sp_offset()));
-  set_int("threadLastJavaPcOffset", in_bytes(JavaThread::last_Java_pc_offset()));
-#ifdef TARGET_ARCH_x86
-  set_int("threadLastJavaFpOffset", in_bytes(JavaThread::last_Java_fp_offset()));
-#endif
-#ifdef TARGET_ARCH_sparc
-  set_int("threadJavaFrameAnchorFlagsOffset", in_bytes(JavaThread::frame_anchor_offset() + JavaFrameAnchor::flags_offset()));
-#endif
-  set_int("threadObjectResultOffset", in_bytes(JavaThread::vm_result_offset()));
-  set_int("tlabSlowAllocationsOffset", in_bytes(JavaThread::tlab_slow_allocations_offset()));
-  set_int("tlabFastRefillWasteOffset", in_bytes(JavaThread::tlab_fast_refill_waste_offset()));
-  set_int("tlabNumberOfRefillsOffset", in_bytes(JavaThread::tlab_number_of_refills_offset()));
-  set_int("tlabRefillWasteLimitOffset", in_bytes(JavaThread::tlab_refill_waste_limit_offset()));
-  set_int("tlabRefillWasteIncrement", (int32_t) ThreadLocalAllocBuffer::refill_waste_limit_increment());
-  set_int("klassInstanceSizeOffset", in_bytes(Klass::layout_helper_offset()));
+
   set_boolean("inlineContiguousAllocationSupported", !CMSIncrementalMode && Universe::heap()->supports_inline_contig_alloc());
 
-  set_address("nonOopBits", Universe::non_oop_word());
-  set_long("verifyOopCounterAddress", (jlong)(address) StubRoutines::verify_oop_count_addr());
   set_long("verifyOopMask", Universe::verify_oop_mask());
   set_long("verifyOopBits", Universe::verify_oop_bits());
 
-  set_long("arrayPrototypeMarkWord", (intptr_t)markOopDesc::prototype());
-  set_int("layoutHelperLog2ElementSizeShift", Klass::_lh_log2_element_size_shift);
-  set_int("layoutHelperLog2ElementSizeMask", Klass::_lh_log2_element_size_mask);
-  set_int("layoutHelperElementTypeShift", Klass::_lh_element_type_shift);
-  set_int("layoutHelperElementTypeMask", Klass::_lh_element_type_mask);
-  // this filters out the bit that differentiates a type array from an object array
-  set_int("layoutHelperElementTypePrimitiveInPlace", (Klass::_lh_array_tag_type_value & ~Klass::_lh_array_tag_obj_value) << Klass::_lh_array_tag_shift);
-  set_int("layoutHelperHeaderSizeShift", Klass::_lh_header_size_shift);
-  set_int("layoutHelperHeaderSizeMask", Klass::_lh_header_size_mask);
-  set_int("layoutHelperOffset", in_bytes(Klass::layout_helper_offset()));
+  set_int("instanceKlassVtableStartOffset", InstanceKlass::vtable_start_offset() * HeapWordSize);
+
+  //------------------------------------------------------------------------------------------------
+
+  set_address("handleDeoptStub", SharedRuntime::deopt_blob()->unpack());
+  set_address("uncommonTrapStub", SharedRuntime::deopt_blob()->uncommon_trap());
 
-  set_address("inlineCacheMissStub", SharedRuntime::get_ic_miss_stub());
-  set_address("handleDeoptStub", SharedRuntime::deopt_blob()->unpack());
-  set_address("aescryptEncryptBlockStub", StubRoutines::aescrypt_encryptBlock());
-  set_address("aescryptDecryptBlockStub", StubRoutines::aescrypt_decryptBlock());
-  set_address("cipherBlockChainingEncryptAESCryptStub", StubRoutines::cipherBlockChaining_encryptAESCrypt());
-  set_address("cipherBlockChainingDecryptAESCryptStub", StubRoutines::cipherBlockChaining_decryptAESCrypt());
-  set_address("updateBytesCRC32Stub", StubRoutines::updateBytesCRC32());
+  set_address("registerFinalizerAddress", SharedRuntime::register_finalizer);
+  set_address("exceptionHandlerForReturnAddressAddress", SharedRuntime::exception_handler_for_return_address);
+  set_address("osrMigrationEndAddress", SharedRuntime::OSR_migration_end);
+
+  set_address("javaTimeMillisAddress", CAST_FROM_FN_PTR(address, os::javaTimeMillis));
+  set_address("javaTimeNanosAddress", CAST_FROM_FN_PTR(address, os::javaTimeNanos));
+  set_address("arithmeticSinAddress", CAST_FROM_FN_PTR(address, SharedRuntime::dsin));
+  set_address("arithmeticCosAddress", CAST_FROM_FN_PTR(address, SharedRuntime::dcos));
+  set_address("arithmeticTanAddress", CAST_FROM_FN_PTR(address, SharedRuntime::dtan));
 
   set_address("newInstanceAddress", GraalRuntime::new_instance);
   set_address("newArrayAddress", GraalRuntime::new_array);
   set_address("newMultiArrayAddress", GraalRuntime::new_multi_array);
   set_address("dynamicNewArrayAddress", GraalRuntime::dynamic_new_array);
-  set_address("registerFinalizerAddress", SharedRuntime::register_finalizer);
   set_address("threadIsInterruptedAddress", GraalRuntime::thread_is_interrupted);
-  set_address("uncommonTrapStub", SharedRuntime::deopt_blob()->uncommon_trap());
   set_address("vmMessageAddress", GraalRuntime::vm_message);
   set_address("identityHashCodeAddress", GraalRuntime::identity_hash_code);
   set_address("exceptionHandlerForPcAddress", GraalRuntime::exception_handler_for_pc);
-  set_address("exceptionHandlerForReturnAddressAddress", SharedRuntime::exception_handler_for_return_address);
-  set_address("osrMigrationEndAddress", SharedRuntime::OSR_migration_end);
   set_address("monitorenterAddress", GraalRuntime::monitorenter);
   set_address("monitorexitAddress", GraalRuntime::monitorexit);
   set_address("createNullPointerExceptionAddress", GraalRuntime::create_null_exception);
@@ -804,82 +764,11 @@
   set_address("logPrintfAddress", GraalRuntime::log_printf);
   set_address("vmErrorAddress", GraalRuntime::vm_error);
   set_address("loadAndClearExceptionAddress", GraalRuntime::load_and_clear_exception);
-  set_address("javaTimeMillisAddress", CAST_FROM_FN_PTR(address, os::javaTimeMillis));
-  set_address("javaTimeNanosAddress", CAST_FROM_FN_PTR(address, os::javaTimeNanos));
-  set_address("arithmeticSinAddress", CAST_FROM_FN_PTR(address, SharedRuntime::dsin));
-  set_address("arithmeticCosAddress", CAST_FROM_FN_PTR(address, SharedRuntime::dcos));
-  set_address("arithmeticTanAddress", CAST_FROM_FN_PTR(address, SharedRuntime::dtan));
-  set_address("crcTableAddress", StubRoutines::crc_table_addr());
-
-  set_int("deoptReasonNone", Deoptimization::Reason_none);
-  set_int("deoptReasonNullCheck", Deoptimization::Reason_null_check);
-  set_int("deoptReasonRangeCheck", Deoptimization::Reason_range_check);
-  set_int("deoptReasonClassCheck", Deoptimization::Reason_class_check);
-  set_int("deoptReasonArrayCheck", Deoptimization::Reason_array_check);
-  set_int("deoptReasonUnreached0", Deoptimization::Reason_unreached0);
-  set_int("deoptReasonTypeCheckInlining", Deoptimization::Reason_type_checked_inlining);
-  set_int("deoptReasonOptimizedTypeCheck", Deoptimization::Reason_optimized_type_check);
-  set_int("deoptReasonNotCompiledExceptionHandler", Deoptimization::Reason_not_compiled_exception_handler);
-  set_int("deoptReasonUnresolved", Deoptimization::Reason_unresolved);
-  set_int("deoptReasonJsrMismatch", Deoptimization::Reason_jsr_mismatch);
-  set_int("deoptReasonDiv0Check", Deoptimization::Reason_div0_check);
-  set_int("deoptReasonConstraint", Deoptimization::Reason_constraint);
-  set_int("deoptReasonLoopLimitCheck", Deoptimization::Reason_loop_limit_check);
-
-  set_int("deoptActionNone", Deoptimization::Action_none);
-  set_int("deoptActionMaybeRecompile", Deoptimization::Action_maybe_recompile);
-  set_int("deoptActionReinterpret", Deoptimization::Action_reinterpret);
-  set_int("deoptActionMakeNotEntrant", Deoptimization::Action_make_not_entrant);
-  set_int("deoptActionMakeNotCompilable", Deoptimization::Action_make_not_compilable);
-
-  set_int("vmIntrinsicInvokeBasic", vmIntrinsics::_invokeBasic);
-  set_int("vmIntrinsicLinkToVirtual", vmIntrinsics::_linkToVirtual);
-  set_int("vmIntrinsicLinkToStatic", vmIntrinsics::_linkToStatic);
-  set_int("vmIntrinsicLinkToSpecial", vmIntrinsics::_linkToSpecial);
-  set_int("vmIntrinsicLinkToInterface", vmIntrinsics::_linkToInterface);
-
-  set_address("narrowOopBase", Universe::narrow_oop_base());
-  set_int("narrowOopShift", Universe::narrow_oop_shift());
-  set_address("narrowKlassBase", Universe::narrow_klass_base());
-  set_int("narrowKlassShift", Universe::narrow_klass_shift());
-  set_int("logKlassAlignment", LogKlassAlignmentInBytes);
-
-
-  set_int("g1CardQueueIndexOffset", in_bytes(JavaThread::dirty_card_queue_offset() + PtrQueue::byte_offset_of_index()));
-  set_int("g1CardQueueBufferOffset", in_bytes(JavaThread::dirty_card_queue_offset() + PtrQueue::byte_offset_of_buf()));
-  set_int("logOfHRGrainBytes", HeapRegion::LogOfHRGrainBytes);
-  set_int("g1SATBQueueMarkingOffset", in_bytes(JavaThread::satb_mark_queue_offset() + PtrQueue::byte_offset_of_active()));
-  set_int("g1SATBQueueIndexOffset", in_bytes(JavaThread::satb_mark_queue_offset() +  PtrQueue::byte_offset_of_index()));
-  set_int("g1SATBQueueBufferOffset", in_bytes(JavaThread::satb_mark_queue_offset() + PtrQueue::byte_offset_of_buf()));
   set_address("writeBarrierPreAddress", GraalRuntime::write_barrier_pre);
   set_address("writeBarrierPostAddress", GraalRuntime::write_barrier_post);
-  set_address("gcTotalCollectionsAddress", (jlong)(address)(Universe::heap()->total_collections_address()));
   set_address("validateObject", GraalRuntime::validate_object);
 
-  BarrierSet* bs = Universe::heap()->barrier_set();
-  switch (bs->kind()) {
-    case BarrierSet::CardTableModRef:
-    case BarrierSet::CardTableExtension:
-    case BarrierSet::G1SATBCT:
-    case BarrierSet::G1SATBCTLogging:{
-      jlong base = (jlong)((CardTableModRefBS*)bs)->byte_map_base;
-      assert(base != 0, "unexpected byte_map_base");
-      set_long("cardtableStartAddress", base);
-      set_int("cardtableShift", CardTableModRefBS::card_shift);
-      break;
-    }
-    case BarrierSet::ModRef:
-    case BarrierSet::Other:
-      set_long("cardtableStartAddress", 0);
-      set_int("cardtableShift", 0);
-      // No post barriers
-      break;
-    default:
-      ShouldNotReachHere();
-      break;
-    }
-
-  set_int("arrayClassElementOffset", in_bytes(ObjArrayKlass::element_klass_offset()));
+  //------------------------------------------------------------------------------------------------
 
   set_int("graalCountersThreadOffset", in_bytes(JavaThread::graal_counters_offset()));
   set_int("graalCountersSize", (jint) GRAAL_COUNTERS_SIZE);
@@ -887,7 +776,6 @@
 #undef set_boolean
 #undef set_int
 #undef set_long
-#undef set_object
 
 C2V_END
 
@@ -1003,26 +891,6 @@
   }
 C2V_END
 
-C2V_VMENTRY(jint, getVtableEntryOffset, (JNIEnv *, jobject, jlong metaspace_method))
-
-  Method* method = asMethod(metaspace_method);
-  assert(!InstanceKlass::cast(method->method_holder())->is_interface(), "vtableEntryOffset cannot be called for interface methods");
-  assert(InstanceKlass::cast(method->method_holder())->is_linked(), "vtableEntryOffset cannot be called is holder is not linked");
-  assert(method->vtable_index() >= 0, "vtable entry offset should not be used");
-
-  // get entry offset in words
-  int vtable_entry_offset = InstanceKlass::vtable_start_offset() + method->vtable_index() * vtableEntry::size();
-  // convert to bytes
-  vtable_entry_offset = vtable_entry_offset * wordSize + vtableEntry::method_offset_in_bytes();
-
-  return vtable_entry_offset;
-C2V_END
-
-C2V_VMENTRY(jboolean, hasVtableEntry, (JNIEnv *, jobject, jlong metaspace_method))
-  Method* method = asMethod(metaspace_method);
-  return method->vtable_index() >= 0;
-C2V_END
-
 C2V_VMENTRY(jobject, getDeoptedLeafGraphIds, (JNIEnv *, jobject))
 
   // the contract for this method is as follows:
@@ -1145,7 +1013,7 @@
 
 C2V_VMENTRY(jobject, readUnsafeUncompressedPointer, (JNIEnv *env, jobject, jobject o, jlong offset))
   oop resolved_o = JNIHandles::resolve(o);
-  address addr = offset + (address)resolved_o;
+  address addr = ((address)resolved_o) + offset;
   return JNIHandles::make_local(*((oop*)addr));
 C2V_END
 
@@ -1207,9 +1075,6 @@
   {CC"initializeMethodData",          CC"("METASPACE_METHOD_DATA METHOD_DATA")V",                       FN_PTR(initializeMethodData)},
   {CC"isMethodCompilable",            CC"("METASPACE_METHOD")Z",                                        FN_PTR(isMethodCompilable)},
   {CC"getCompiledCodeSize",           CC"("METASPACE_METHOD")I",                                        FN_PTR(getCompiledCodeSize)},
-  {CC"getVtableEntryOffset",          CC"("METASPACE_METHOD")I",                                        FN_PTR(getVtableEntryOffset)},
-  {CC"hasVtableEntry",                CC"("METASPACE_METHOD")Z",                                        FN_PTR(hasVtableEntry)},
-  {CC"constantPoolLength",            CC"("HS_RESOLVED_TYPE")I",                                        FN_PTR(constantPoolLength)},
   {CC"lookupType",                    CC"("STRING HS_RESOLVED_TYPE"Z)"TYPE,                             FN_PTR(lookupType)},
   {CC"lookupConstantInPool",          CC"("HS_RESOLVED_TYPE"I)"OBJECT,                                  FN_PTR(lookupConstantInPool)},
   {CC"lookupAppendixInPool",          CC"("HS_RESOLVED_TYPE"IB)"OBJECT,                                 FN_PTR(lookupAppendixInPool)},
--- a/src/share/vm/runtime/deoptimization.cpp	Thu Oct 24 16:01:44 2013 +0200
+++ b/src/share/vm/runtime/deoptimization.cpp	Thu Oct 24 22:28:09 2013 +0200
@@ -1430,7 +1430,7 @@
           } else {
             tty->print(" (Graal: installed code has no name) ");
           }
-        } else {
+        } else if (nm->is_compiled_by_graal()) {
           tty->print(" (Graal: no installed code) ");
         }
 #endif //GRAAL
--- a/src/share/vm/runtime/vmStructs.cpp	Thu Oct 24 16:01:44 2013 +0200
+++ b/src/share/vm/runtime/vmStructs.cpp	Thu Oct 24 22:28:09 2013 +0200
@@ -563,6 +563,8 @@
   nonstatic_field(Space,                       _bottom,                                       HeapWord*)                             \
   nonstatic_field(Space,                       _end,                                          HeapWord*)                             \
                                                                                                                                      \
+     static_field(HeapRegion,                  LogOfHRGrainBytes,                             int)                                   \
+                                                                                                                                     \
   nonstatic_field(ThreadLocalAllocBuffer,      _start,                                        HeapWord*)                             \
   nonstatic_field(ThreadLocalAllocBuffer,      _top,                                          HeapWord*)                             \
   nonstatic_field(ThreadLocalAllocBuffer,      _end,                                          HeapWord*)                             \
@@ -890,6 +892,7 @@
      static_field(Threads,                     _return_code,                                  int)                                   \
                                                                                                                                      \
   nonstatic_field(ThreadShadow,                _pending_exception,                            oop)                                   \
+  nonstatic_field(ThreadShadow,                _pending_deoptimization,                       int)                                   \
   nonstatic_field(ThreadShadow,                _exception_file,                               const char*)                           \
   nonstatic_field(ThreadShadow,                _exception_line,                               int)                                   \
    volatile_nonstatic_field(Thread,            _suspend_flags,                                uint32_t)                              \
@@ -1243,6 +1246,7 @@
   static_field(java_lang_Class,                _array_klass_offset,                           int)                                   \
   static_field(java_lang_Class,                _oop_size_offset,                              int)                                   \
   static_field(java_lang_Class,                _static_oop_field_count_offset,                int)                                   \
+  GRAAL_ONLY(static_field(java_lang_Class,     _graal_mirror_offset,                          int))                                  \
                                                                                                                                      \
   /************************/                                                                                                         \
   /* Miscellaneous fields */                                                                                                         \
@@ -1482,6 +1486,8 @@
            declare_type(EdenSpace,                    ContiguousSpace)    \
            declare_type(OffsetTableContigSpace,       ContiguousSpace)    \
            declare_type(TenuredSpace,                 OffsetTableContigSpace) \
+           declare_type(G1OffsetTableContigSpace,     ContiguousSpace)    \
+           declare_type(HeapRegion,                   G1OffsetTableContigSpace) \
   declare_toplevel_type(BarrierSet)                                       \
            declare_type(ModRefBarrierSet,             BarrierSet)         \
            declare_type(CardTableModRefBS,            ModRefBarrierSet)   \