changeset 1465:2c754f3a2722

Inlining of static final field values. Java mirror instead of VmID. Support for PrintMetrics option.
author Thomas Wuerthinger <wuerthinger@ssw.jku.at>
date Thu, 18 Nov 2010 17:27:43 +0100
parents 7bc14f75a077
children 243c729b5ded
files c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/Compiler.java c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotConstantPool.java c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotField.java c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotMethodUnresolved.java c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotRuntime.java c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotTypeResolved.java c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotXirGenerator.java c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMExits.java c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMExitsNative.java src/share/vm/c1x/c1x_CodeInstaller.cpp src/share/vm/c1x/c1x_Compiler.cpp src/share/vm/c1x/c1x_TargetMethod.hpp src/share/vm/c1x/c1x_VMEntries.cpp src/share/vm/c1x/c1x_VMExits.cpp src/share/vm/c1x/c1x_VMExits.hpp src/share/vm/classfile/systemDictionary.hpp src/share/vm/classfile/vmSymbols.hpp src/share/vm/runtime/globals.hpp
diffstat 18 files changed, 154 insertions(+), 137 deletions(-) [+]
line wrap: on
line diff
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/Compiler.java	Mon Nov 15 11:06:38 2010 +0100
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/Compiler.java	Thu Nov 18 17:27:43 2010 +0100
@@ -56,6 +56,9 @@
         @Override
         public void run() {
             VMExitsNative.compileMethods = false;
+            if (C1XOptions.PrintMetrics) {
+                C1XMetrics.print();
+            }
             if (C1XOptions.PrintTimers) {
                 C1XTimers.print();
             }
@@ -156,7 +159,6 @@
 
         // these options are important - c1x4hotspot will not generate correct code without them
         C1XOptions.GenSpecialDivChecks = true;
-        C1XOptions.AlignCallsForPatching = true;
         C1XOptions.NullCheckUniquePc = true;
         C1XOptions.invokeinterfaceTemplatePos = true;
         C1XOptions.StackShadowPages = config.stackShadowPages;
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotConstantPool.java	Mon Nov 15 11:06:38 2010 +0100
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotConstantPool.java	Thu Nov 18 17:27:43 2010 +0100
@@ -20,7 +20,6 @@
  */
 package com.sun.hotspot.c1x;
 
-import com.sun.cri.ci.*;
 import com.sun.cri.ri.*;
 
 /**
@@ -37,12 +36,6 @@
     }
 
     @Override
-    public CiConstant encoding() {
-        // TODO: Check if this is correct.
-        return CiConstant.forObject(vmId);
-    }
-
-    @Override
     public Object lookupConstant(int cpi) {
         return Compiler.getVMEntries().RiConstantPool_lookupConstant(vmId, cpi);
     }
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotField.java	Mon Nov 15 11:06:38 2010 +0100
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotField.java	Thu Nov 18 17:27:43 2010 +0100
@@ -37,6 +37,7 @@
     private final String name;
     private final RiType type;
     private final int offset;
+    private CiConstant constant;
 
     public HotSpotField(RiType holder, String name, RiType type, int offset) {
         this.holder = holder;
@@ -53,7 +54,10 @@
 
     @Override
     public CiConstant constantValue(Object object) {
-        // TODO Auto-generated method stub
+        if (object == null) {
+            // Constant part only valid for static fields.
+            return constant;
+        }
         return null;
     }
 
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotMethodUnresolved.java	Mon Nov 15 11:06:38 2010 +0100
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotMethodUnresolved.java	Thu Nov 18 17:27:43 2010 +0100
@@ -140,7 +140,7 @@
 
     @Override
     public String toString() {
-        return "HotSpotMethod<" + name + ", unresolved>";
+        return "HotSpotMethod<" + holder.name() + ". " + name + ", unresolved>";
     }
 
     @Override
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotRuntime.java	Mon Nov 15 11:06:38 2010 +0100
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotRuntime.java	Thu Nov 18 17:27:43 2010 +0100
@@ -139,10 +139,7 @@
 
     @Override
     public RiType getRiType(Class<?> javaClass) {
-        if (javaClass == Object[].class || javaClass == Long.class || javaClass == Integer.class || javaClass == Throwable.class) {
-            return Compiler.getVMEntries().getType(javaClass);
-        }
-        throw new UnsupportedOperationException("unexpected class in getRiType: " + javaClass);
+        return Compiler.getVMEntries().getType(javaClass);
     }
 
     @Override
@@ -208,14 +205,7 @@
 
     @Override
     public boolean compareConstantObjects(Object x, Object y) {
-        if (x == null && y == null) {
-            return true;
-        } else if (x == null || y == null) {
-            return false;
-        } else if (x instanceof Long && y instanceof Long) {
-            return (Long) x == (long) (Long) y;
-        }
-        throw new UnsupportedOperationException("compareConstantObjects: " + x + ", " + y);
+        return x == y;
     }
 
     @Override
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotTypeResolved.java	Mon Nov 15 11:06:38 2010 +0100
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotTypeResolved.java	Thu Nov 18 17:27:43 2010 +0100
@@ -33,36 +33,19 @@
  */
 public class HotSpotTypeResolved implements HotSpotType {
 
-    private final long vmId;
-    private final long javaMirrorVmId;
-    private final String name;
-    private final int accessFlags;
-    private final boolean hasFinalizer;
-    private final boolean hasSubclass;
-    private final boolean hasFinalizableSubclass;
-    private final boolean isInitialized;
-    private final boolean isArrayClass;
-    private final boolean isInstanceClass;
-    private final boolean isInterface;
-    private final int instanceSize;
-    private final RiType componentType;
-
-    public HotSpotTypeResolved(long vmId, long javaMirrorVmId, String name, int accessFlags, boolean hasFinalizer, boolean hasSubclass, boolean hasFinalizableSubclass, boolean isInitialized,
-                    boolean isArrayClass, boolean isInstanceClass, boolean isInterface, int instanceSize, RiType componentType) {
-        this.vmId = vmId;
-        this.javaMirrorVmId = javaMirrorVmId;
-        this.name = name;
-        this.accessFlags = accessFlags;
-        this.hasFinalizer = hasFinalizer;
-        this.hasSubclass = hasSubclass;
-        this.hasFinalizableSubclass = hasFinalizableSubclass;
-        this.isInitialized = isInitialized;
-        this.isArrayClass = isArrayClass;
-        this.isInstanceClass = isInstanceClass;
-        this.isInterface = isInterface;
-        this.instanceSize = instanceSize;
-        this.componentType = componentType;
-    }
+    private long vmId;
+    private Class javaMirror;
+    private String name;
+    private int accessFlags;
+    private boolean hasFinalizer;
+    private boolean hasSubclass;
+    private boolean hasFinalizableSubclass;
+    private boolean isInitialized;
+    private boolean isArrayClass;
+    private boolean isInstanceClass;
+    private boolean isInterface;
+    private int instanceSize;
+    private RiType componentType;
 
     @Override
     public int accessFlags() {
@@ -78,7 +61,6 @@
 
     @Override
     public RiType componentType() {
-        Logger.log("componentType " + name + " isarray: " + isArrayClass);
         return Compiler.getVMEntries().RiType_componentType(vmId);
     }
 
@@ -95,7 +77,7 @@
     public CiConstant getEncoding(Representation r) {
         switch (r) {
             case JavaClass:
-                return CiConstant.forObject((Long) javaMirrorVmId);
+                return CiConstant.forObject(javaMirror);
             case ObjectHub:
                 return CiConstant.forObject(this);
             case StaticFields:
@@ -139,7 +121,7 @@
 
     @Override
     public boolean isInstance(Object obj) {
-        throw new UnsupportedOperationException();
+        return javaMirror.isInstance(obj);
     }
 
     @Override
@@ -168,7 +150,7 @@
 
     @Override
     public Class<?> javaClass() {
-        return null;
+        return javaMirror;
     }
 
     @Override
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotXirGenerator.java	Mon Nov 15 11:06:38 2010 +0100
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotXirGenerator.java	Thu Nov 18 17:27:43 2010 +0100
@@ -260,7 +260,7 @@
 
             // -- out of line -------------------------------------------------------
             asm.bindOutOfLine(stub);
-            XirOperand method = asm.createRegisterTemp("method", CiKind.Object, AMD64.rbx);
+            XirOperand method = asm.createRegisterTemp("method", CiKind.Word, AMD64.rbx);
             asm.mark(MARK_STATIC_CALL_STUB, XirMark.CALLSITE);
             asm.mov(method, asm.w(0L));
             XirLabel dummy = asm.createOutOfLineLabel("dummy");
@@ -283,7 +283,7 @@
 
             // -- out of line -------------------------------------------------------
             asm.bindOutOfLine(stub);
-            XirOperand method = asm.createRegisterTemp("method", CiKind.Object, AMD64.rbx);
+            XirOperand method = asm.createRegisterTemp("method", CiKind.Word, AMD64.rbx);
             asm.mark(MARK_STATIC_CALL_STUB, XirMark.CALLSITE);
             asm.mov(method, asm.w(0L));
             XirLabel dummy = asm.createOutOfLineLabel("dummy");
@@ -1008,7 +1008,7 @@
 
             asm.bindOutOfLine(replacement);
             XirMark begin = asm.mark(null);
-            asm.mov(arg, asm.createConstant(CiConstant.forObject(null)));
+            asm.mov(arg, asm.createConstant(CiConstant.NULL_OBJECT));
             XirMark end = asm.mark(null);
             // make this piece of data look like an instruction
             asm.rawBytes(new byte[] {(byte) 0xb8, 0, 0, 0x05, 0});
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMExits.java	Mon Nov 15 11:06:38 2010 +0100
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMExits.java	Thu Nov 18 17:27:43 2010 +0100
@@ -51,14 +51,12 @@
 
     RiConstantPool createRiConstantPool(long vmId);
 
-    CiConstant createCiConstantInt(int value);
-
     CiConstant createCiConstantLong(long value);
 
     CiConstant createCiConstantFloat(float value);
 
     CiConstant createCiConstantDouble(double value);
 
-    CiConstant createCiConstantObject(long vmId);
+    CiConstant createCiConstantObject(Object object);
 
 }
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMExitsNative.java	Mon Nov 15 11:06:38 2010 +0100
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMExitsNative.java	Thu Nov 18 17:27:43 2010 +0100
@@ -49,6 +49,7 @@
         C1XOptions.OptInlineSynchronized = false;
         C1XOptions.UseDeopt = false;
         C1XOptions.IRChecking = false;
+        C1XOptions.DetailedAsserts = false;
     }
 
     @Override
@@ -151,7 +152,6 @@
                 }
                 Compiler.getVMEntries().recordBailout(result.bailout().getMessage());
             } else {
-                Logger.log("Compilation result: " + result.targetMethod());
                 HotSpotTargetMethod.installMethod(riMethod, result.targetMethod());
             }
         } catch (Throwable t) {
@@ -235,13 +235,8 @@
     }
 
     @Override
-    public CiConstant createCiConstantInt(int value) {
-        return CiConstant.forInt(value);
-    }
-
-    @Override
     public CiConstant createCiConstantLong(long value) {
-        return CiConstant.forLong(value);
+        return new CiConstant(CiKind.Long, value);
     }
 
     @Override
@@ -255,7 +250,7 @@
     }
 
     @Override
-    public CiConstant createCiConstantObject(long vmId) {
-        return CiConstant.forObject(vmId);
+    public CiConstant createCiConstantObject(Object object) {
+        return CiConstant.forObject(object);
     }
 }
--- a/src/share/vm/c1x/c1x_CodeInstaller.cpp	Mon Nov 15 11:06:38 2010 +0100
+++ b/src/share/vm/c1x/c1x_CodeInstaller.cpp	Thu Nov 18 17:27:43 2010 +0100
@@ -51,17 +51,19 @@
   arrayOop register_map = (arrayOop) CiDebugInfo::registerRefMap(debug_info);
   arrayOop frame_map = (arrayOop) CiDebugInfo::frameRefMap(debug_info);
 
-  assert(register_map->length() == (NUM_CPU_REGS + 7) / 8, "unexpected register_map length");
+  if (register_map != NULL) {
+    assert(register_map->length() == (NUM_CPU_REGS + 7) / 8, "unexpected register_map length");
 
-  for (jint i = 0; i < NUM_CPU_REGS; i++) {
-    unsigned char byte = ((unsigned char*) register_map->base(T_BYTE))[i / 8];
-    bool is_oop = (byte & (1 << (i % 8))) != 0;
-    VMReg reg = get_hotspot_reg(i);
-    if (is_oop) {
-      assert(OOP_ALLOWED[i], "this register may never be an oop, register map misaligned?");
-      map->set_oop(reg);
-    } else {
-      map->set_value(reg);
+    for (jint i = 0; i < NUM_CPU_REGS; i++) {
+      unsigned char byte = ((unsigned char*) register_map->base(T_BYTE))[i / 8];
+      bool is_oop = (byte & (1 << (i % 8))) != 0;
+      VMReg reg = get_hotspot_reg(i);
+      if (is_oop) {
+        assert(OOP_ALLOWED[i], "this register may never be an oop, register map misaligned?");
+        map->set_oop(reg);
+      } else {
+        map->set_value(reg);
+      }
     }
   }
 
@@ -138,34 +140,39 @@
 
 // constructor used to create a method
 CodeInstaller::CodeInstaller(oop target_method) {
-  _env = CURRENT_ENV;
+  ciMethod *ciMethodObject = NULL;
+  {
+    No_Safepoint_Verifier no_safepoint;
+    _env = CURRENT_ENV;
 
-  initialize_fields(target_method);
-  assert(_hotspot_method != NULL && _name == NULL, "installMethod needs NON-NULL method and NULL name");
-  assert(_hotspot_method->is_a(HotSpotMethodResolved::klass()), "installMethod needs a HotSpotMethodResolved");
+    initialize_fields(target_method);
+    assert(_hotspot_method != NULL && _name == NULL, "installMethod needs NON-NULL method and NULL name");
+    assert(_hotspot_method->is_a(HotSpotMethodResolved::klass()), "installMethod needs a HotSpotMethodResolved");
 
-  // TODO: This is a hack.. Produce correct entries.
-  _offsets.set_value(CodeOffsets::Exceptions, 0);
-  _offsets.set_value(CodeOffsets::Deopt, 0);
+    // TODO: This is a hack.. Produce correct entries.
+    _offsets.set_value(CodeOffsets::Exceptions, 0);
+    _offsets.set_value(CodeOffsets::Deopt, 0);
 
-  methodOop method = VmIds::get<methodOop>(HotSpotMethodResolved::vmId(_hotspot_method));
-  ciMethod *ciMethodObject = (ciMethod *) _env->get_object(method);
-  _parameter_count = method->size_of_parameters();
+    methodOop method = VmIds::get<methodOop>(HotSpotMethodResolved::vmId(_hotspot_method));
+    ciMethodObject = (ciMethod *) _env->get_object(method);
+    _parameter_count = method->size_of_parameters();
+  }
 
   // (very) conservative estimate: each site needs a relocation
   CodeBuffer buffer("temp c1x method", _total_size, _sites->length() * relocInfo::length_limit);
   initialize_buffer(buffer);
   process_exception_handlers();
-  {
-    int stack_slots = (_frame_size / HeapWordSize) + 2; // conversion to words, need to add two slots for ret address and frame pointer
-    ThreadToNativeFromVM t((JavaThread*) Thread::current());
-    _env->register_method(ciMethodObject, -1, &_offsets, 0, &buffer, stack_slots, _debug_recorder->_oopmaps, &_exception_handler_table,
-        &_implicit_exception_table, C1XCompiler::instance(), _env->comp_level(), false, false);
-  }
+
+  int stack_slots = (_frame_size / HeapWordSize) + 2; // conversion to words, need to add two slots for ret address and frame pointer
+  ThreadToNativeFromVM t((JavaThread*) Thread::current());
+  _env->register_method(ciMethodObject, -1, &_offsets, 0, &buffer, stack_slots, _debug_recorder->_oopmaps, &_exception_handler_table,
+      &_implicit_exception_table, C1XCompiler::instance(), _env->comp_level(), false, false);
+
 }
 
 // constructor used to create a stub
 CodeInstaller::CodeInstaller(oop target_method, jlong& id) {
+  No_Safepoint_Verifier no_safepoint;
   _env = CURRENT_ENV;
 
   initialize_fields(target_method);
@@ -524,25 +531,28 @@
     }
     case 'a': {
       address operand = Assembler::locate_operand(instruction, Assembler::imm_operand);
-      oop obj = CiConstant::object(constant);
+      Handle obj = CiConstant::object(constant);
 
       if (obj->is_a(HotSpotTypeResolved::klass())) {
         *((jobject*) operand) = JNIHandles::make_local(VmIds::get<klassOop>(HotSpotTypeResolved::vmId(obj)));
         _instructions->relocate(instruction, oop_Relocation::spec_for_immediate(), Assembler::imm_operand);
         TRACE_C1X_3("relocating (HotSpotType) at %016x/%016x", instruction, operand);
       } else {
-        assert(java_lang_boxing_object::is_instance(obj, T_LONG), "unexpected DataPatch object type");
-        jlong id = obj->long_field(java_lang_boxing_object::value_offset_in_bytes(T_LONG));
-
-        assert((id & VmIds::TYPE_MASK) == VmIds::CONSTANT, "unexpected DataPatch type");
+        jobject value;
+        if (java_lang_boxing_object::is_instance(obj(), T_LONG)) {
+          jlong id = obj->long_field(java_lang_boxing_object::value_offset_in_bytes(T_LONG));
 
-        address operand = Assembler::locate_operand(instruction, Assembler::imm_operand);
-
-        if (id == VmIds::DUMMY_CONSTANT) {
-          *((jobject*) operand) = (jobject) Universe::non_oop_word();
+          //assert((id & VmIds::TYPE_MASK) == VmIds::CONSTANT, "unexpected DataPatch type");
+          address operand = Assembler::locate_operand(instruction, Assembler::imm_operand);
+          if (id == VmIds::DUMMY_CONSTANT) {
+            value = (jobject) Universe::non_oop_word();
+          } else {
+            value = JNIHandles::make_local(VmIds::get<oop>(id));
+          }
         } else {
-          *((jobject*) operand) = JNIHandles::make_local(VmIds::get<oop>(id));
+          value = JNIHandles::make_local(obj());
         }
+        *((jobject*) operand) = value;
         _instructions->relocate(instruction, oop_Relocation::spec_for_immediate(), Assembler::imm_operand);
         TRACE_C1X_3("relocating (oop constant) at %016x/%016x", instruction, operand);
       }
--- a/src/share/vm/c1x/c1x_Compiler.cpp	Mon Nov 15 11:06:38 2010 +0100
+++ b/src/share/vm/c1x/c1x_Compiler.cpp	Thu Nov 18 17:27:43 2010 +0100
@@ -116,7 +116,7 @@
   oop obj = instanceKlass::cast(HotSpotTypeResolved::klass())->allocate_instance(CHECK_NULL);
 
   HotSpotTypeResolved::set_vmId(obj, VmIds::add(klass, VmIds::CLASS));
-  HotSpotTypeResolved::set_javaMirrorVmId(obj, VmIds::add(klass->java_mirror(), VmIds::CONSTANT));
+  HotSpotTypeResolved::set_javaMirror(obj, klass->java_mirror());
   HotSpotTypeResolved::set_name(obj, name());
   HotSpotTypeResolved::set_accessFlags(obj, klass->access_flags().as_int());
   HotSpotTypeResolved::set_isInterface(obj, klass->is_interface());
--- a/src/share/vm/c1x/c1x_TargetMethod.hpp	Mon Nov 15 11:06:38 2010 +0100
+++ b/src/share/vm/c1x/c1x_TargetMethod.hpp	Thu Nov 18 17:27:43 2010 +0100
@@ -45,7 +45,7 @@
 #define COMPILER_CLASSES_DO(start_class, end_class, char_field, int_field, boolean_field, long_field, oop_field, static_oop_field)   \
   start_class(HotSpotTypeResolved)                                                      \
     long_field(HotSpotTypeResolved, vmId)                                               \
-    long_field(HotSpotTypeResolved, javaMirrorVmId)                                     \
+    oop_field(HotSpotTypeResolved, javaMirror, "Ljava/lang/Class;")                     \
     oop_field(HotSpotTypeResolved, name, "Ljava/lang/String;")                          \
     int_field(HotSpotTypeResolved, accessFlags)                                         \
     boolean_field(HotSpotTypeResolved, hasFinalizer)                                    \
@@ -58,6 +58,9 @@
     int_field(HotSpotTypeResolved, instanceSize)                                        \
     oop_field(HotSpotTypeResolved, componentType, "Lcom/sun/cri/ri/RiType;")            \
   end_class                                                                             \
+  start_class(HotSpotField)                                                             \
+    oop_field(HotSpotField, constant, "Lcom/sun/cri/ci/CiConstant;")                    \
+  end_class                                                                             \
   start_class(HotSpotMethodResolved)                                                    \
     long_field(HotSpotMethodResolved, vmId)                                             \
   end_class                                                                             \
@@ -130,6 +133,11 @@
   end_class                                                                             \
   start_class(CiKind)                                                                   \
     char_field(CiKind, typeChar)                                                        \
+    static_oop_field(CiKind, Boolean, "Lcom/sun/cri/ci/CiKind;");                       \
+    static_oop_field(CiKind, Byte, "Lcom/sun/cri/ci/CiKind;");                          \
+    static_oop_field(CiKind, Char, "Lcom/sun/cri/ci/CiKind;");                          \
+    static_oop_field(CiKind, Short, "Lcom/sun/cri/ci/CiKind;");                         \
+    static_oop_field(CiKind, Int, "Lcom/sun/cri/ci/CiKind;");                           \
   end_class                                                                             \
   start_class(CiRuntimeCall)                                                            \
     static_oop_field(CiRuntimeCall, UnwindException, "Lcom/sun/cri/ci/CiRuntimeCall;"); \
--- a/src/share/vm/c1x/c1x_VMEntries.cpp	Mon Nov 15 11:06:38 2010 +0100
+++ b/src/share/vm/c1x/c1x_VMEntries.cpp	Thu Nov 18 17:27:43 2010 +0100
@@ -168,7 +168,8 @@
   oop result = NULL;
   constantTag tag = cp->tag_at(index);
   if (tag.is_int()) {
-    result = VMExits::createCiConstantInt(cp->int_at(index), CHECK_0);
+    result = VMExits::createCiConstantLong(cp->int_at(index), CHECK_0);
+    CiValue::set_kind(result, CiKind::Int());
   } else if (tag.is_long()) {
     result = VMExits::createCiConstantLong(cp->long_at(index), CHECK_0);
   } else if (tag.is_float()) {
@@ -188,10 +189,7 @@
         return NULL;
       }
     }
-    jlong id = VmIds::add<oop>(string);
-//    tty->print("\n\nstring: 0x%08x%08x\n", string, id>>32, id);
-//    string->print();
-    result = VMExits::createCiConstantObject(id, CHECK_0);
+    result = VMExits::createCiConstantObject(string, CHECK_0);
   } else if (tag.is_klass() || tag.is_unresolved_klass()) {
     bool ignore;
     ciInstanceKlass* accessor = (ciInstanceKlass*) ciEnv::current()->get_object(cp->pool_holder());
@@ -200,7 +198,7 @@
   } else if (tag.is_object()) {
     oop obj = cp->object_at(index);
     assert(obj->is_instance(), "must be an instance");
-    result = VMExits::createCiConstantObject(VmIds::add<oop>(obj), CHECK_NULL);
+    result = VMExits::createCiConstantObject(obj, CHECK_NULL);
   } else {
     ShouldNotReachHere();
   }
@@ -256,7 +254,57 @@
   ciInstanceKlass* loading_klass = (ciInstanceKlass *) CURRENT_ENV->get_object(cp->pool_holder());
   ciField *field = CURRENT_ENV->get_field_by_index(loading_klass, index);
   Bytecodes::Code code = (Bytecodes::Code)(((int) byteCode) & 0xFF);
-  return JNIHandles::make_local(THREAD, C1XCompiler::get_RiField(field, loading_klass, cp->pool_holder(), code, THREAD));
+  Handle field_handle = C1XCompiler::get_RiField(field, loading_klass, cp->pool_holder(), code, THREAD);
+  if (field->is_constant() && field->is_static()) {
+    ciConstant constant = field->constant_value();
+    oop constant_object = NULL;
+    switch (constant.basic_type()) {
+      case T_OBJECT:
+      case T_ARRAY:
+        {
+          ciObject* obj = constant.as_object();
+          if (obj->is_null_object()) {
+            constant_object = VMExits::createCiConstantObject(NULL, CHECK_0);
+          } else if (obj->can_be_constant()) {
+            constant_object = VMExits::createCiConstantObject(constant.as_object()->get_oop(), CHECK_0);
+          }
+        }
+        break;
+      case T_DOUBLE:
+        constant_object = VMExits::createCiConstantDouble(constant.as_double(), CHECK_0);
+        break;
+      case T_LONG:
+        constant_object = VMExits::createCiConstantLong(constant.as_long(), CHECK_0);
+        break;
+      case T_INT:
+        constant_object = VMExits::createCiConstantLong(constant.as_int(), CHECK_0);
+        CiValue::set_kind(constant_object, CiKind::Int());
+        break;
+      case T_SHORT:
+        constant_object = VMExits::createCiConstantLong(constant.as_int(), CHECK_0);
+        CiValue::set_kind(constant_object, CiKind::Short());
+        break;
+      case T_CHAR:
+        constant_object = VMExits::createCiConstantLong(constant.as_int(), CHECK_0);
+        CiValue::set_kind(constant_object, CiKind::Char());
+        break;
+      case T_BYTE:
+        constant_object = VMExits::createCiConstantLong(constant.as_int(), CHECK_0);
+        CiValue::set_kind(constant_object, CiKind::Byte());
+        break;
+      case T_BOOLEAN:
+        constant_object = VMExits::createCiConstantLong(constant.as_int(), CHECK_0);
+        CiValue::set_kind(constant_object, CiKind::Boolean());
+        break;
+      default:
+        constant.print();
+        fatal("Unhandled constant");
+    }
+    if (constant_object != NULL) {
+      HotSpotField::set_constant(field_handle, constant_object);
+    }
+  }
+  return JNIHandles::make_local(THREAD, field_handle());
 }
 
 // public RiConstantPool RiType_constantPool(long vmId);
--- a/src/share/vm/c1x/c1x_VMExits.cpp	Mon Nov 15 11:06:38 2010 +0100
+++ b/src/share/vm/c1x/c1x_VMExits.cpp	Thu Nov 18 17:27:43 2010 +0100
@@ -174,17 +174,6 @@
   return (oop) result.get_jobject();
 }
 
-oop VMExits::createCiConstantInt(jint value, TRAPS) {
-  JavaValue result(T_OBJECT);
-  JavaCallArguments args;
-  args.push_oop(instance());
-  args.push_int(value);
-  JavaCalls::call_interface(&result, vmExitsKlass(), vmSymbols::createCiConstantInt_name(), vmSymbols::createCiConstantInt_signature(), &args, THREAD);
-  check_pending_exception("Error while calling createCiConstantInt");
-  return (oop) result.get_jobject();
-
-}
-
 oop VMExits::createCiConstantLong(jlong value, TRAPS) {
   JavaValue result(T_OBJECT);
   JavaCallArguments args;
@@ -217,12 +206,12 @@
   return (oop) result.get_jobject();
 }
 
-oop VMExits::createCiConstantObject(jlong vmId, TRAPS) {
+oop VMExits::createCiConstantObject(Handle object, TRAPS) {
   JavaValue result(T_OBJECT);
   JavaCallArguments args;
   args.push_oop(instance());
-  args.push_long(vmId);
-  JavaCalls::call_interface(&result, vmExitsKlass(), vmSymbols::createCiConstantObject_name(), vmSymbols::createCiConstantLong_signature(), &args, THREAD);
+  args.push_oop(object);
+  JavaCalls::call_interface(&result, vmExitsKlass(), vmSymbols::createCiConstantObject_name(), vmSymbols::createCiConstantObject_signature(), &args, THREAD);
   check_pending_exception("Error while calling createCiConstantObject");
   return (oop) result.get_jobject();
 }
--- a/src/share/vm/c1x/c1x_VMExits.hpp	Mon Nov 15 11:06:38 2010 +0100
+++ b/src/share/vm/c1x/c1x_VMExits.hpp	Thu Nov 18 17:27:43 2010 +0100
@@ -63,9 +63,6 @@
   // public abstract RiSignature createRiSignature(String signature);
   static oop createRiSignature(Handle name, TRAPS);
 
-  // public abstract CiConstant createCiConstantInt(int value);
-  static oop createCiConstantInt(jint value, TRAPS);
-
   // public abstract CiConstant createCiConstantLong(long value);
   static oop createCiConstantLong(jlong value, TRAPS);
 
@@ -76,7 +73,7 @@
   static oop createCiConstantDouble(jdouble value, TRAPS);
 
   // public abstract CiConstant createCiConstantObject(long vmId);
-  static oop createCiConstantObject(jlong vmId, TRAPS);
+  static oop createCiConstantObject(Handle object, TRAPS);
 };
 
 inline void check_pending_exception(const char* message) {
--- a/src/share/vm/classfile/systemDictionary.hpp	Mon Nov 15 11:06:38 2010 +0100
+++ b/src/share/vm/classfile/systemDictionary.hpp	Thu Nov 18 17:27:43 2010 +0100
@@ -172,6 +172,7 @@
   template(Long_klass,                   java_lang_Long,                 Pre) \
                                                                               \
   template(HotSpotTypeResolved_klass,    com_sun_hotspot_c1x_HotSpotTypeResolved,                   Opt) \
+  template(HotSpotField_klass,           com_sun_hotspot_c1x_HotSpotField,                          Opt) \
   template(HotSpotMethodResolved_klass,  com_sun_hotspot_c1x_HotSpotMethodResolved,                 Opt) \
   template(HotSpotTargetMethod_klass,    com_sun_hotspot_c1x_HotSpotTargetMethod,                   Opt) \
   template(HotSpotExceptionHandler_klass,com_sun_hotspot_c1x_HotSpotExceptionHandler,               Opt) \
--- a/src/share/vm/classfile/vmSymbols.hpp	Mon Nov 15 11:06:38 2010 +0100
+++ b/src/share/vm/classfile/vmSymbols.hpp	Thu Nov 18 17:27:43 2010 +0100
@@ -248,6 +248,7 @@
   template(com_sun_hotspot_c1x_VMExits,               "com/sun/hotspot/c1x/VMExits")                                    \
   template(com_sun_hotspot_c1x_HotSpotMethodResolved, "com/sun/hotspot/c1x/HotSpotMethodResolved")                      \
   template(com_sun_hotspot_c1x_HotSpotTargetMethod,   "com/sun/hotspot/c1x/HotSpotTargetMethod")                        \
+  template(com_sun_hotspot_c1x_HotSpotField,          "com/sun/hotspot/c1x/HotSpotField")                               \
   template(com_sun_hotspot_c1x_HotSpotTypeResolved,   "com/sun/hotspot/c1x/HotSpotTypeResolved")                        \
   template(com_sun_hotspot_c1x_HotSpotExceptionHandler,"com/sun/hotspot/c1x/HotSpotExceptionHandler")                   \
   template(com_sun_hotspot_c1x_Compiler,              "com/sun/hotspot/c1x/Compiler")                                   \
@@ -293,8 +294,6 @@
   template(createRiTypeUnresolved_signature,          "(Ljava/lang/String;J)Lcom/sun/cri/ri/RiType;")                   \
   template(createRiConstantPool_name,                 "createRiConstantPool")                                           \
   template(createRiConstantPool_signature,            "(J)Lcom/sun/cri/ri/RiConstantPool;")                             \
-  template(createCiConstantInt_name,                  "createCiConstantInt")                                            \
-  template(createCiConstantInt_signature,             "(I)Lcom/sun/cri/ci/CiConstant;")                                 \
   template(createCiConstantLong_name,                 "createCiConstantLong")                                           \
   template(createCiConstantLong_signature,            "(J)Lcom/sun/cri/ci/CiConstant;")                                 \
   template(createCiConstantFloat_name,                "createCiConstantFloat")                                          \
@@ -302,6 +301,7 @@
   template(createCiConstantDouble_name,               "createCiConstantDouble")                                         \
   template(createCiConstantDouble_signature,          "(D)Lcom/sun/cri/ci/CiConstant;")                                 \
   template(createCiConstantObject_name,               "createCiConstantObject")                                         \
+  template(createCiConstantObject_signature,          "(Ljava/lang/Object;)Lcom/sun/cri/ci/CiConstant;")                \
   template(getVMExits_name,                           "getVMExits")                                                     \
   template(getVMExits_signature,                      "()Lcom/sun/hotspot/c1x/VMExits;")                                \
                                                                                                                         \
--- a/src/share/vm/runtime/globals.hpp	Mon Nov 15 11:06:38 2010 +0100
+++ b/src/share/vm/runtime/globals.hpp	Thu Nov 18 17:27:43 2010 +0100
@@ -719,7 +719,7 @@
   diagnostic(bool, TraceNMethodInstalls, false,                             \
              "Trace nmethod intallation")                                   \
                                                                             \
-  diagnostic(intx, ScavengeRootsInCode, 0,                                  \
+  diagnostic(intx, ScavengeRootsInCode, 1,                                  \
              "0: do not allow scavengable oops in the code cache; "         \
              "1: allow scavenging from the code cache; "                    \
              "2: emit as many constants as the compiler can see")           \