# HG changeset patch # User Thomas Wuerthinger # Date 1303491607 -7200 # Node ID 4e5515d093147f6ea85974c086c6cbd01957f73b # Parent 0654ee04b2140f48a60719c458e96b1125438ceb Fixed merge issues. - Accessing static fields from the java.lang.Class object instead of the klassOop (1-line-change) - Fixed issue with RiField object caching (the caching was only taking the offset as a field ID, but need to take offset+is_static) diff -r 0654ee04b214 -r 4e5515d09314 graal/Runtime/src/com/sun/hotspot/c1x/HotSpotConstantPool.java --- a/graal/Runtime/src/com/sun/hotspot/c1x/HotSpotConstantPool.java Fri Apr 22 15:30:53 2011 +0200 +++ b/graal/Runtime/src/com/sun/hotspot/c1x/HotSpotConstantPool.java Fri Apr 22 19:00:07 2011 +0200 @@ -23,6 +23,7 @@ import java.io.*; import java.util.*; +import com.sun.c1x.debug.*; import com.sun.cri.ri.*; /** diff -r 0654ee04b214 -r 4e5515d09314 graal/Runtime/src/com/sun/hotspot/c1x/HotSpotField.java --- a/graal/Runtime/src/com/sun/hotspot/c1x/HotSpotField.java Fri Apr 22 15:30:53 2011 +0200 +++ b/graal/Runtime/src/com/sun/hotspot/c1x/HotSpotField.java Fri Apr 22 19:00:07 2011 +0200 @@ -24,6 +24,7 @@ import java.lang.reflect.*; import com.sun.c1x.*; +import com.sun.c1x.debug.*; import com.sun.cri.ci.CiConstant; import com.sun.cri.ci.CiKind; import com.sun.cri.ri.RiField; @@ -40,20 +41,21 @@ private final String name; private final RiType type; private final int offset; + private final int accessFlags; private CiConstant constant; - public HotSpotField(Compiler compiler, RiType holder, String name, RiType type, int offset) { + public HotSpotField(Compiler compiler, RiType holder, String name, RiType type, int offset, int accessFlags) { super(compiler); this.holder = holder; this.name = name; this.type = type; this.offset = offset; + this.accessFlags = accessFlags; } @Override public int accessFlags() { - // TODO Auto-generated method stub - return 0; + return accessFlags; } @Override diff -r 0654ee04b214 -r 4e5515d09314 graal/Runtime/src/com/sun/hotspot/c1x/HotSpotOptions.java --- a/graal/Runtime/src/com/sun/hotspot/c1x/HotSpotOptions.java Fri Apr 22 15:30:53 2011 +0200 +++ b/graal/Runtime/src/com/sun/hotspot/c1x/HotSpotOptions.java Fri Apr 22 19:00:07 2011 +0200 @@ -46,8 +46,6 @@ String fieldName = null; String valueString = null; - System.out.println(option); - char first = option.charAt(0); if (first == '+' || first == '-') { fieldName = option.substring(1); diff -r 0654ee04b214 -r 4e5515d09314 graal/Runtime/src/com/sun/hotspot/c1x/HotSpotTypeResolved.java --- a/graal/Runtime/src/com/sun/hotspot/c1x/HotSpotTypeResolved.java Fri Apr 22 15:30:53 2011 +0200 +++ b/graal/Runtime/src/com/sun/hotspot/c1x/HotSpotTypeResolved.java Fri Apr 22 19:00:07 2011 +0200 @@ -31,6 +31,6 @@ int instanceSize(); - RiField createRiField(String name, RiType type, int offset); + RiField createRiField(String name, RiType type, int offset, int flags); } \ No newline at end of file diff -r 0654ee04b214 -r 4e5515d09314 graal/Runtime/src/com/sun/hotspot/c1x/HotSpotTypeResolvedImpl.java --- a/graal/Runtime/src/com/sun/hotspot/c1x/HotSpotTypeResolvedImpl.java Fri Apr 22 15:30:53 2011 +0200 +++ b/graal/Runtime/src/com/sun/hotspot/c1x/HotSpotTypeResolvedImpl.java Fri Apr 22 19:00:07 2011 +0200 @@ -45,7 +45,7 @@ private boolean isInterface; private int instanceSize; private RiType componentType; - private HashMap fieldCache; + private HashMap fieldCache; private RiConstantPool pool; private HotSpotTypeResolvedImpl() { @@ -93,7 +93,7 @@ case ObjectHub: return CiConstant.forObject(this); case StaticFields: - return CiConstant.forObject(this); + return CiConstant.forObject(javaClass()); case TypeInfo: return CiConstant.forObject(this); default: @@ -193,19 +193,25 @@ } @Override - public RiField createRiField(String name, RiType type, int offset) { + public RiField createRiField(String name, RiType type, int offset, int flags) { RiField result = null; + long id = offset + ((long) flags << 32); + // (tw) Must cache the fields, because the local load elimination only works if the objects from two field lookups are equal. if (fieldCache == null) { - fieldCache = new HashMap(8); + fieldCache = new HashMap(8); } else { - result = fieldCache.get(offset); + result = fieldCache.get(id); } if (result == null) { - result = new HotSpotField(compiler, this, name, type, offset); - fieldCache.put(offset, result); + result = new HotSpotField(compiler, this, name, type, offset, flags); + fieldCache.put(id, result); + } else { + assert result.type().equals(type); + assert result.name().equals(name); + assert result.accessFlags() == flags; } return result; diff -r 0654ee04b214 -r 4e5515d09314 graal/Runtime/src/com/sun/hotspot/c1x/VMExits.java --- a/graal/Runtime/src/com/sun/hotspot/c1x/VMExits.java Fri Apr 22 15:30:53 2011 +0200 +++ b/graal/Runtime/src/com/sun/hotspot/c1x/VMExits.java Fri Apr 22 19:00:07 2011 +0200 @@ -39,7 +39,7 @@ RiSignature createRiSignature(String signature); - RiField createRiField(RiType holder, String name, RiType type, int offset); + RiField createRiField(RiType holder, String name, RiType type, int offset, int flags); RiType createRiType(long vmId, String name); diff -r 0654ee04b214 -r 4e5515d09314 graal/Runtime/src/com/sun/hotspot/c1x/VMExitsNative.java --- a/graal/Runtime/src/com/sun/hotspot/c1x/VMExitsNative.java Fri Apr 22 15:30:53 2011 +0200 +++ b/graal/Runtime/src/com/sun/hotspot/c1x/VMExitsNative.java Fri Apr 22 19:00:07 2011 +0200 @@ -70,7 +70,6 @@ @Override public void compileMethod(long methodVmId, String name, int entryBCI) throws Throwable { - if (!compileMethods) { return; } @@ -99,7 +98,6 @@ Logger.info(String.format("%-10s %3d %s", type, e.getLineNumber(), current)); } } - System.out.println("BAILOUT:" + result.bailout().getMessage()); String s = result.bailout().getMessage(); if (cause != null) { s = cause.getMessage(); @@ -132,12 +130,12 @@ } @Override - public RiField createRiField(RiType holder, String name, RiType type, int offset) { + public RiField createRiField(RiType holder, String name, RiType type, int offset, int flags) { if (offset != -1) { HotSpotTypeResolved resolved = (HotSpotTypeResolved) holder; - return resolved.createRiField(name, type, offset); + return resolved.createRiField(name, type, offset, flags); } - return new HotSpotField(compiler, holder, name, type, offset); + return new HotSpotField(compiler, holder, name, type, offset, flags); } @Override diff -r 0654ee04b214 -r 4e5515d09314 src/share/vm/c1x/c1x_Compiler.cpp --- a/src/share/vm/c1x/c1x_Compiler.cpp Fri Apr 22 15:30:53 2011 +0200 +++ b/src/share/vm/c1x/c1x_Compiler.cpp Fri Apr 22 19:00:07 2011 +0200 @@ -137,9 +137,8 @@ Handle field_name = VmIds::toString(field->name()->get_symbol(), CHECK_0); Handle field_holder = get_RiType(field->holder(), accessor, CHECK_0); Handle field_type = get_RiType(field->type(), accessor, CHECK_0); - - // TODO: implement caching - return VMExits::createRiField(field_holder, field_name, field_type, offset, THREAD); + int flags = field->flags().as_int(); + return VMExits::createRiField(field_holder, field_name, field_type, offset, flags, THREAD); } oop C1XCompiler::createHotSpotTypeResolved(KlassHandle klass, Handle name, TRAPS) { diff -r 0654ee04b214 -r 4e5515d09314 src/share/vm/c1x/c1x_JavaAccess.hpp --- a/src/share/vm/c1x/c1x_JavaAccess.hpp Fri Apr 22 15:30:53 2011 +0200 +++ b/src/share/vm/c1x/c1x_JavaAccess.hpp Fri Apr 22 19:00:07 2011 +0200 @@ -24,6 +24,8 @@ void c1x_compute_offsets(); +#include "oops/instanceMirrorKlass.hpp" + /* This macro defines the structure of the CiTargetMethod - classes. * It will generate classes with accessors similar to javaClasses.hpp, but with specializations for oops, Handles and jni handles. * @@ -228,11 +230,26 @@ #define BOOLEAN_FIELD(klass, name) FIELD(name, jboolean, bool_field) #define LONG_FIELD(klass, name) FIELD(name, jlong, long_field) #define OOP_FIELD(klass, name, signature) FIELD(name, oop, obj_field) -#define STATIC_OOP_FIELD(klassName, name, signature) \ - static int _##name##_offset; \ - static oop name() { return klassName::klass()->obj_field(_##name##_offset); } \ - static void set_##name(oop x) { klassName::klass()->obj_field_put(_##name##_offset, x); } - +#define STATIC_OOP_FIELD(klassName, name, signature) \ + static int _##name##_offset; \ + static oop name() { \ + instanceKlass* ik = instanceKlass::cast(klassName::klass()); \ + address addr = ik->static_field_addr(_##name##_offset - instanceMirrorKlass::offset_of_static_fields()); \ + if (UseCompressedOops) { \ + return oopDesc::load_decode_heap_oop((narrowOop *)addr); \ + } else { \ + return oopDesc::load_decode_heap_oop((oop*)addr); \ + } \ + } \ + static void set_##name(oop x) { \ + instanceKlass* ik = instanceKlass::cast(klassName::klass()); \ + address addr = ik->static_field_addr(_##name##_offset - instanceMirrorKlass::offset_of_static_fields()); \ + if (UseCompressedOops) { \ + oopDesc::encode_store_heap_oop((narrowOop *)addr, x); \ + } else { \ + oopDesc::encode_store_heap_oop((oop*)addr, x); \ + } \ + } COMPILER_CLASSES_DO(START_CLASS, END_CLASS, CHAR_FIELD, INT_FIELD, BOOLEAN_FIELD, LONG_FIELD, OOP_FIELD, STATIC_OOP_FIELD) #undef START_CLASS #undef END_CLASS diff -r 0654ee04b214 -r 4e5515d09314 src/share/vm/c1x/c1x_VMEntries.cpp --- a/src/share/vm/c1x/c1x_VMEntries.cpp Fri Apr 22 15:30:53 2011 +0200 +++ b/src/share/vm/c1x/c1x_VMEntries.cpp Fri Apr 22 19:00:07 2011 +0200 @@ -295,6 +295,7 @@ 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); Handle field_handle = C1XCompiler::get_RiField(field, loading_klass, cp->pool_holder(), code, THREAD); bool is_constant = field->is_constant(); @@ -369,7 +370,7 @@ if (method == NULL) { if (TraceC1X >= 3) { ResourceMark rm; - tty->print_cr("Could not resolve method %s %s on klass %d", name_symbol->as_C_string(), signature_symbol->as_C_string(), klass->klass_part()->name()->as_C_string()); + tty->print_cr("Could not resolve method %s %s on klass %s", name_symbol->as_C_string(), signature_symbol->as_C_string(), klass->klass_part()->name()->as_C_string()); } return NULL; } @@ -617,7 +618,7 @@ JNIEXPORT void JNICALL Java_com_sun_hotspot_c1x_VMEntries_recordBailout(JNIEnv *jniEnv, jobject message) { if (C1XBailoutIsFatal) { Handle msg = JNIHandles::resolve(message); - if (msg.is_null()) { + if (!msg.is_null()) { java_lang_String::print(msg, tty); } fatal("Bailout in C1X"); diff -r 0654ee04b214 -r 4e5515d09314 src/share/vm/c1x/c1x_VMExits.cpp --- a/src/share/vm/c1x/c1x_VMExits.cpp Fri Apr 22 15:30:53 2011 +0200 +++ b/src/share/vm/c1x/c1x_VMExits.cpp Fri Apr 22 19:00:07 2011 +0200 @@ -136,7 +136,7 @@ return (oop) result.get_jobject(); } -oop VMExits::createRiField(Handle holder, Handle name, Handle type, int index, TRAPS) { +oop VMExits::createRiField(Handle holder, Handle name, Handle type, int index, int flags, TRAPS) { assert(!holder.is_null(), "just checking"); assert(!name.is_null(), "just checking"); assert(!type.is_null(), "just checking"); @@ -147,8 +147,10 @@ args.push_oop(name); args.push_oop(type); args.push_int(index); + args.push_int(flags); JavaCalls::call_interface(&result, vmExitsKlass(), vmSymbols::createRiField_name(), vmSymbols::createRiField_signature(), &args, THREAD); check_pending_exception("Error while calling createRiField"); + assert(result.get_type() == T_OBJECT, "just checking"); return (oop) result.get_jobject(); } diff -r 0654ee04b214 -r 4e5515d09314 src/share/vm/c1x/c1x_VMExits.hpp --- a/src/share/vm/c1x/c1x_VMExits.hpp Fri Apr 22 15:30:53 2011 +0200 +++ b/src/share/vm/c1x/c1x_VMExits.hpp Fri Apr 22 19:00:07 2011 +0200 @@ -52,8 +52,8 @@ // public abstract RiMethod createRiMethodUnresolved(String name, String signature, RiType holder); static oop createRiMethodUnresolved(Handle name, Handle signature, Handle holder, TRAPS); - // public abstract RiField createRiField(RiType holder, String name, RiType type, int offset); - static oop createRiField(Handle holder, Handle name, Handle type, int index, TRAPS); + // public abstract RiField createRiField(RiType holder, String name, RiType type, int flags, int offset); + static oop createRiField(Handle holder, Handle name, Handle type, int index, int flags, TRAPS); // public abstract RiType createRiType(long vmId, String name); static oop createRiType(jlong vmId, Handle name, TRAPS); diff -r 0654ee04b214 -r 4e5515d09314 src/share/vm/classfile/vmSymbols.hpp --- a/src/share/vm/classfile/vmSymbols.hpp Fri Apr 22 15:30:53 2011 +0200 +++ b/src/share/vm/classfile/vmSymbols.hpp Fri Apr 22 19:00:07 2011 +0200 @@ -308,7 +308,7 @@ template(createRiSignature_name, "createRiSignature") \ template(createRiSignature_signature, "(Ljava/lang/String;)Lcom/sun/cri/ri/RiSignature;") \ template(createRiField_name, "createRiField") \ - template(createRiField_signature, "(Lcom/sun/cri/ri/RiType;Ljava/lang/String;Lcom/sun/cri/ri/RiType;I)Lcom/sun/cri/ri/RiField;") \ + template(createRiField_signature, "(Lcom/sun/cri/ri/RiType;Ljava/lang/String;Lcom/sun/cri/ri/RiType;II)Lcom/sun/cri/ri/RiField;") \ template(createRiType_name, "createRiType") \ template(createRiType_signature, "(JLjava/lang/String;)Lcom/sun/cri/ri/RiType;") \ template(createRiTypePrimitive_name, "createRiTypePrimitive") \ diff -r 0654ee04b214 -r 4e5515d09314 src/share/vm/runtime/globals.hpp --- a/src/share/vm/runtime/globals.hpp Fri Apr 22 15:30:53 2011 +0200 +++ b/src/share/vm/runtime/globals.hpp Fri Apr 22 19:00:07 2011 +0200 @@ -3696,7 +3696,7 @@ "Skip assert() and verify() which page-in unwanted shared " \ "objects. ") \ \ - diagnostic(bool, EnableInvokeDynamic, true, \ + diagnostic(bool, EnableInvokeDynamic, false, \ "support JSR 292 (method handles, invokedynamic, " \ "anonymous classes") \ \