changeset 4316:b4b16e4e043f

Fix eager resolving for class constants
author Peter Hofer <peter.hofer@jku.at>
date Mon, 23 Jan 2012 14:35:29 +0100
parents 4c223446c28e
children e3374bccaa5f
files graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/GraphBuilderPhase.java src/share/vm/graal/graalCompilerToVM.cpp
diffstat 2 files changed, 17 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/GraphBuilderPhase.java	Mon Jan 23 12:21:06 2012 +0100
+++ b/graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/GraphBuilderPhase.java	Mon Jan 23 14:35:29 2012 +0100
@@ -383,14 +383,11 @@
     }
 
     private void genLoadConstant(int cpi, int opcode) {
-        Object con = constantPool.lookupConstant(cpi);
+        Object con = lookupConstant(cpi, opcode);
 
         if (con instanceof RiType) {
             // this is a load of class constant which might be unresolved
             RiType riType = (RiType) con;
-            if (config.eagerResolving() && !(riType instanceof RiResolvedType)) {
-                riType = lookupType(cpi, opcode);
-            }
             if (riType instanceof RiResolvedType) {
                 frameState.push(CiKind.Object, append(ConstantNode.forCiConstant(((RiResolvedType) riType).getEncoding(Representation.JavaClass), runtime, currentGraph)));
             } else {
@@ -674,6 +671,19 @@
         return result;
     }
 
+    private Object lookupConstant(int cpi, int opcode) {
+        eagerResolving(cpi, opcode);
+        Object result = constantPool.lookupConstant(cpi);
+        assert !config.eagerResolving() || !(result instanceof RiType) || (result instanceof RiResolvedType);
+        return result;
+    }
+
+    private void eagerResolving(int cpi, int bytecode) {
+        if (config.eagerResolving()) {
+            constantPool.loadReferencedType(cpi, bytecode);
+        }
+    }
+
     private void eagerResolvingForSnippets(int cpi, int bytecode) {
         if (config.eagerResolvingForSnippets()) {
             constantPool.loadReferencedType(cpi, bytecode);
--- a/src/share/vm/graal/graalCompilerToVM.cpp	Mon Jan 23 12:21:06 2012 +0100
+++ b/src/share/vm/graal/graalCompilerToVM.cpp	Mon Jan 23 14:35:29 2012 +0100
@@ -506,7 +506,9 @@
   
   constantPoolOop cp = instanceKlass::cast(java_lang_Class::as_klassOop(HotSpotTypeResolved::javaMirror(type)))->constants();
   int byteCode = (op & 0xFF);
-  if (byteCode != Bytecodes::_checkcast && byteCode != Bytecodes::_instanceof && byteCode != Bytecodes::_new && byteCode != Bytecodes::_anewarray && byteCode != Bytecodes::_multianewarray) {
+  if (byteCode != Bytecodes::_checkcast && byteCode != Bytecodes::_instanceof && byteCode != Bytecodes::_new && byteCode != Bytecodes::_anewarray
+      && byteCode != Bytecodes::_multianewarray && byteCode != Bytecodes::_ldc && byteCode != Bytecodes::_ldc_w && byteCode != Bytecodes::_ldc2_w)
+  {
     index = cp->remap_instruction_operand_from_cache(GraalCompiler::to_cp_index_u2(index));
   }
   constantTag tag = cp->tag_at(index);