Mercurial > hg > truffle
changeset 1425:98fffb304868
tlab-allocated "new instance", invokespecial, support for static fields in COMPILER_CLASSES_DO
author | Lukas Stadler <lukas.stadler@oracle.com> |
---|---|
date | Tue, 17 Aug 2010 17:34:25 -0700 |
parents | 1ea65e9d943c |
children | ed6bd46ad55e |
files | c1x4hotspotsrc/HotSpotTest/src/jttTests.java c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotRegisterConfig.java c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotTypeResolved.java c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotVMConfig.java c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotXirGenerator.java c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMEntries.java c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMEntriesNative.java src/share/vm/c1x/c1x_Compiler.cpp src/share/vm/c1x/c1x_Compiler.hpp src/share/vm/c1x/c1x_VMEntries.cpp |
diffstat | 10 files changed, 203 insertions(+), 42 deletions(-) [+] |
line wrap: on
line diff
--- a/c1x4hotspotsrc/HotSpotTest/src/jttTests.java Mon Aug 16 20:00:59 2010 -0700 +++ b/c1x4hotspotsrc/HotSpotTest/src/jttTests.java Tue Aug 17 17:34:25 2010 -0700 @@ -4,7 +4,7 @@ public class jttTests { public static void main(String[] args) { - runTests(128, 128); + runTests(182, 182); Logger.info("total: " + executed + " tests executed, " + passed + " passed, " + failed + " failed"); } @@ -730,7 +730,7 @@ jtt_optimize_Inline02(); break; case 226: - jtt_optimize_List_reorder_bug(); + //jtt_optimize_List_reorder_bug(); break; case 227: jtt_optimize_NCE_01();
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotRegisterConfig.java Mon Aug 16 20:00:59 2010 -0700 +++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotRegisterConfig.java Tue Aug 17 17:34:25 2010 -0700 @@ -146,6 +146,7 @@ case Int: case Long: case Object: + case Word: return AMD64.rax; case Float: case Double:
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotTypeResolved.java Mon Aug 16 20:00:59 2010 -0700 +++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotTypeResolved.java Tue Aug 17 17:34:25 2010 -0700 @@ -35,6 +35,7 @@ private Boolean isArrayClass; private Boolean isInstanceClass; private Boolean isInterface; + private long instanceSize; public HotSpotTypeResolved(long vmId, String name) { this.vmId = vmId; @@ -172,4 +173,11 @@ return vmId; } + public long instanceSize() { + if (instanceSize == 0) { + instanceSize = Compiler.getVMEntries().RiType_instanceSize(vmId); + } + return instanceSize; + } + }
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotVMConfig.java Mon Aug 16 20:00:59 2010 -0700 +++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotVMConfig.java Tue Aug 17 17:34:25 2010 -0700 @@ -37,11 +37,15 @@ public int arrayLengthOffset; public int[] arrayOffsets; public int arrayClassElementOffset; + public int threadTlabTopOffset; + public int threadTlabEndOffset; + public int instanceHeaderPrototypeOffset; // runtime stubs public long instanceofStub; public long debugStub; public long resolveStaticCallStub; + public long newInstanceStub; public void check() { assert vmPageSize >= 16;
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotXirGenerator.java Mon Aug 16 20:00:59 2010 -0700 +++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotXirGenerator.java Tue Aug 17 17:34:25 2010 -0700 @@ -26,6 +26,7 @@ import com.sun.cri.ri.*; import com.sun.cri.ri.RiType.Representation; import com.sun.cri.xir.*; +import com.sun.cri.xir.CiXirAssembler.XirOperand; import com.sun.cri.xir.CiXirAssembler.*; /** @@ -54,6 +55,8 @@ private XirTemplate arrayLengthTemplate; private XirTemplate exceptionObjectTemplate; private XirTemplate invokeStaticTemplate; + private XirTemplate invokeSpecialTemplate; + private XirTemplate newInstanceTemplate; static class XirPair { @@ -105,6 +108,11 @@ } // templates.add(emptyTemplates[index]); } + + asm.restart(); + XirOperand result = asm.createTemp("result", CiKind.Word); + emptyTemplates[CiKind.Word.ordinal()] = asm.finishTemplate(result, "empty-Word"); + prologueTemplate = buildPrologue(false); staticPrologueTemplate = buildPrologue(true); epilogueTemplate = buildEpilogue(); @@ -113,13 +121,46 @@ instanceofTemplate = buildInstanceof(false); instanceofTemplateNonnull = buildInstanceof(true); invokeStaticTemplate = buildInvokeStatic(); + invokeSpecialTemplate = buildInvokeSpecial(); + newInstanceTemplate = buildNewInstance(); return templates; } + private XirTemplate buildNewInstance() { + XirOperand result = asm.restart(CiKind.Word); + XirOperand type = asm.createInputParameter("type", CiKind.Object); + XirOperand instanceSize = asm.createConstantInputParameter("instance size", CiKind.Word); + + XirOperand thread = asm.createRegister("thread", CiKind.Word, AMD64.r15); + XirOperand temp1 = asm.createTemp("temp1", CiKind.Word); + XirOperand temp2 = asm.createTemp("temp2", CiKind.Word); + XirLabel tlabFull = asm.createOutOfLineLabel("tlab full"); + XirLabel resume = asm.createInlineLabel("resume"); + + asm.pload(CiKind.Word, result, thread, asm.i(config.threadTlabTopOffset), false); + asm.add(temp1, result, instanceSize); + asm.pload(CiKind.Word, temp2, thread, asm.i(config.threadTlabEndOffset), false); + + asm.jgt(tlabFull, temp1, temp2); + asm.pstore(CiKind.Word, thread, asm.i(config.threadTlabTopOffset), temp1, false); + asm.bindInline(resume); + + asm.pload(CiKind.Word, temp1, type, asm.i(config.instanceHeaderPrototypeOffset), false); + asm.pstore(CiKind.Word, result, temp1, false); + asm.pstore(CiKind.Object, result, asm.i(config.hubOffset), type, false); + + asm.bindOutOfLine(tlabFull); + XirOperand arg = asm.createRegister("runtime call argument", CiKind.Object, AMD64.rdx); + asm.mov(arg, type); + asm.callRuntime(config.newInstanceStub, result); + asm.jmp(resume); + + return asm.finishTemplate("new instance"); + } + private XirTemplate buildPrologue(boolean staticMethod) { asm.restart(CiKind.Void); - XirOperand sp = asm.createRegister("stack pointer", CiKind.Word, registerConfig.getStackPointerRegister()); XirOperand temp = asm.createRegister("temp (rax)", CiKind.Int, AMD64.rax); XirOperand frame_pointer = asm.createRegister("frame pointer", CiKind.Word, AMD64.rbp); @@ -372,6 +413,23 @@ return asm.finishTemplate(addr, "invokestatic"); } + private XirTemplate buildInvokeSpecial() { + asm.restart(); + XirParameter addr = asm.createConstantInputParameter("addr", CiKind.Word); + + XirLabel stub = asm.createOutOfLineLabel("specialCallStub"); + + asm.bindOutOfLine(stub); + XirOperand method = asm.createRegister("method", CiKind.Word, AMD64.rbx); + asm.mark(MARK_STATIC_CALL_STUB, XirMark.CALLSITE); + asm.mov(method, asm.w(0l)); + XirLabel dummy = asm.createOutOfLineLabel("dummy"); + asm.jmp(dummy); + asm.bindOutOfLine(dummy); + + return asm.finishTemplate(addr, "invokespecial"); + } + @Override public XirSnippet genArrayLength(XirSite site, XirArgument array) { return new XirSnippet(arrayLengthTemplate, array); @@ -462,7 +520,7 @@ @Override public XirSnippet genInvokeSpecial(XirSite site, XirArgument receiver, RiMethod method) { - return new XirSnippet(emptyTemplates[CiKind.Word.ordinal()]); + return new XirSnippet(invokeSpecialTemplate, XirArgument.forWord(0)); } @Override @@ -492,7 +550,9 @@ @Override public XirSnippet genNewInstance(XirSite site, RiType type) { - return new XirSnippet(emptyTemplates[CiKind.Object.ordinal()]); + assert type instanceof HotSpotTypeResolved; + HotSpotTypeResolved resolved = (HotSpotTypeResolved) type; + return new XirSnippet(newInstanceTemplate, XirArgument.forObject(type), XirArgument.forWord(resolved.instanceSize())); } @Override
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMEntries.java Mon Aug 16 20:00:59 2010 -0700 +++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMEntries.java Tue Aug 17 17:34:25 2010 -0700 @@ -58,6 +58,8 @@ public boolean RiType_isInterface(long vmId); + public long RiType_instanceSize(long vmId); + public RiConstantPool RiType_constantPool(long vmId); public void installMethod(HotSpotTargetMethod targetMethod);
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMEntriesNative.java Mon Aug 16 20:00:59 2010 -0700 +++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMEntriesNative.java Tue Aug 17 17:34:25 2010 -0700 @@ -74,6 +74,9 @@ public native boolean RiType_isInterface(long vmId); @Override + public native long RiType_instanceSize(long vmId); + + @Override public native RiConstantPool RiType_constantPool(long vmId); @Override
--- a/src/share/vm/c1x/c1x_Compiler.cpp Mon Aug 16 20:00:59 2010 -0700 +++ b/src/share/vm/c1x/c1x_Compiler.cpp Tue Aug 17 17:34:25 2010 -0700 @@ -148,7 +148,7 @@ } -static void compute_offset(int &dest_offset, klassOop klass_oop, const char* name, const char* signature) { +static void compute_offset(int &dest_offset, klassOop klass_oop, const char* name, const char* signature, bool static_field) { symbolOop name_symbol = SymbolTable::probe(name, strlen(name)); symbolOop signature_symbol = SymbolTable::probe(signature, strlen(signature)); assert(name_symbol != NULL, "symbol not found - class layout changed?"); @@ -161,6 +161,7 @@ tty->print_cr("Invalid layout of %s at %s", ik->external_name(), name_symbol->as_C_string()); fatal("Invalid layout of preloaded class"); } + assert(fd.is_static() == static_field, "static/instance mismatch"); dest_offset = fd.offset(); } @@ -169,15 +170,16 @@ #define END_CLASS } -#define FIELD(klass, name, signature) compute_offset(klass::_##name##_offset, k, #name, signature); -#define CHAR_FIELD(klass, name) FIELD(klass, name, "C") -#define INT_FIELD(klass, name) FIELD(klass, name, "I") -#define LONG_FIELD(klass, name) FIELD(klass, name, "J") -#define OOP_FIELD(klass, name, signature) FIELD(klass, name, signature) +#define FIELD(klass, name, signature, static_field) compute_offset(klass::_##name##_offset, k, #name, signature, static_field); +#define CHAR_FIELD(klass, name) FIELD(klass, name, "C", false) +#define INT_FIELD(klass, name) FIELD(klass, name, "I", false) +#define LONG_FIELD(klass, name) FIELD(klass, name, "J", false) +#define OOP_FIELD(klass, name, signature) FIELD(klass, name, signature, false) +#define STATIC_OOP_FIELD(klass, name, signature) FIELD(klass, name, signature, true) void C1XCompiler::compute_offsets() { - COMPILER_CLASSES_DO(START_CLASS, END_CLASS, CHAR_FIELD, INT_FIELD, LONG_FIELD, OOP_FIELD) + COMPILER_CLASSES_DO(START_CLASS, END_CLASS, CHAR_FIELD, INT_FIELD, LONG_FIELD, OOP_FIELD, STATIC_OOP_FIELD) } #define EMPTY0 @@ -186,7 +188,7 @@ #define FIELD2(klass, name) int klass::_##name##_offset = 0; #define FIELD3(klass, name, sig) FIELD2(klass, name) -COMPILER_CLASSES_DO(EMPTY1, EMPTY0, FIELD2, FIELD2, FIELD2, FIELD3) +COMPILER_CLASSES_DO(EMPTY1, EMPTY0, FIELD2, FIELD2, FIELD2, FIELD3, FIELD3)
--- a/src/share/vm/c1x/c1x_Compiler.hpp Mon Aug 16 20:00:59 2010 -0700 +++ b/src/share/vm/c1x/c1x_Compiler.hpp Tue Aug 17 17:34:25 2010 -0700 @@ -188,7 +188,7 @@ // defines the structure of the CiTargetMethod - classes // this will generate classes with accessors similar to javaClasses.hpp -#define COMPILER_CLASSES_DO(start_class, end_class, char_field, int_field, long_field, oop_field) \ +#define COMPILER_CLASSES_DO(start_class, end_class, char_field, int_field, long_field, oop_field, static_oop_field) \ start_class(HotSpotTypeResolved) \ long_field(HotSpotTypeResolved, vmId) \ end_class \ @@ -261,6 +261,7 @@ char_field(CiKind, typeChar) \ end_class \ start_class(CiRuntimeCall) \ + static_oop_field(CiRuntimeCall, Debug, "Lcom/sun/cri/ci/CiRuntimeCall;"); \ end_class \ start_class(RiMethod) \ end_class \ @@ -292,8 +293,12 @@ #define INT_FIELD(klass, name) FIELD(name, jint, int_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); } -COMPILER_CLASSES_DO(START_CLASS, END_CLASS, CHAR_FIELD, INT_FIELD, LONG_FIELD, OOP_FIELD) +COMPILER_CLASSES_DO(START_CLASS, END_CLASS, CHAR_FIELD, INT_FIELD, LONG_FIELD, OOP_FIELD, STATIC_OOP_FIELD) #undef START_CLASS #undef END_CLASS #undef FIELD @@ -301,5 +306,6 @@ #undef INT_FIELD #undef LONG_FIELD #undef OOP_FIELD +#undef STATIC_OOP_FIELD
--- a/src/share/vm/c1x/c1x_VMEntries.cpp Mon Aug 16 20:00:59 2010 -0700 +++ b/src/share/vm/c1x/c1x_VMEntries.cpp Tue Aug 17 17:34:25 2010 -0700 @@ -29,7 +29,7 @@ -// public byte[] RiMethod_code(HotSpotProxy method); +// public byte[] RiMethod_code(long vmId); JNIEXPORT jbyteArray JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1code(JNIEnv *env, jobject, jlong vmId) { methodOop method = C1XObjects::get<methodOop>(vmId); int code_size = method->code_size(); @@ -38,17 +38,17 @@ return result; } -// public int RiMethod_maxStackSize(HotSpotProxy method); +// public int RiMethod_maxStackSize(long vmId); JNIEXPORT jint JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1maxStackSize(JNIEnv *, jobject, jlong vmId) { return C1XObjects::get<methodOop>(vmId)->max_stack(); } -// public int RiMethod_maxLocals(HotSpotProxy method); +// public int RiMethod_maxLocals(long vmId); JNIEXPORT jint JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1maxLocals(JNIEnv *, jobject, jlong vmId) { return C1XObjects::get<methodOop>(vmId)->max_locals(); } -// public RiType RiMethod_holder(HotSpotProxy method); +// public RiType RiMethod_holder(long vmId); JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1holder(JNIEnv *, jobject, jlong vmId) { VM_ENTRY_MARK klassOop klass = C1XObjects::get<methodOop>(vmId)->method_holder(); @@ -58,19 +58,19 @@ return JNIHandles::make_local(THREAD, holder); } -// public String RiMethod_signature(HotSpotProxy method); +// public String RiMethod_signature(long vmId); JNIEXPORT jstring JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1signature(JNIEnv *env, jobject, jlong vmId) { VM_ENTRY_MARK methodOop method = C1XObjects::get<methodOop>(vmId); return C1XObjects::toString<jstring>(method->signature(), THREAD); } -// public int RiMethod_accessFlags(HotSpotProxy method); +// public int RiMethod_accessFlags(long vmId); JNIEXPORT jint JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1accessFlags(JNIEnv *, jobject, jlong vmId) { return C1XObjects::get<methodOop>(vmId)->access_flags().as_int(); } -// public RiType RiSignature_lookupType(String returnType, HotSpotProxy accessingClass); +// public RiType RiSignature_lookupType(String returnType, long accessingClassVmId); JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiSignature_1lookupType(JNIEnv *, jobject, jstring jname, jlong accessingClassVmId) { VM_ENTRY_MARK; @@ -112,7 +112,7 @@ return JNIHandles::make_local(THREAD, result); } -// public Object RiConstantPool_lookupConstant(HotSpotProxy constantPool, int cpi); +// public Object RiConstantPool_lookupConstant(long vmId, int cpi); JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupConstant(JNIEnv *env, jobject, jlong vmId, jint index) { VM_ENTRY_MARK; @@ -168,7 +168,7 @@ return JNIHandles::make_local(THREAD, result); } -// public RiMethod RiConstantPool_lookupMethod(HotSpotProxy constantPool, int cpi, byte byteCode +// public RiMethod RiConstantPool_lookupMethod(long vmId, int cpi, byte byteCode); JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupMethod(JNIEnv *env, jobject, jlong vmId, jint index, jbyte byteCode) { VM_ENTRY_MARK; @@ -182,13 +182,13 @@ return JNIHandles::make_local(THREAD, VMExits::createRiMethod(C1XObjects::add<methodOop>(method), name, THREAD)); } -// public RiSignature RiConstantPool_lookupSignature(HotSpotProxy constantPool, int cpi); +// public RiSignature RiConstantPool_lookupSignature(long vmId, int cpi); JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupSignature(JNIEnv *env, jobject, jlong vmId, jint index) { fatal("currently unsupported"); return NULL; } -// public RiType RiConstantPool_lookupType(HotSpotProxy constantPool, int cpi); +// public RiType RiConstantPool_lookupType(long vmId, int cpi); JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupType(JNIEnv *env, jobject, jlong vmId, jint index) { VM_ENTRY_MARK; @@ -201,7 +201,7 @@ } -// public RiField RiConstantPool_lookupField(HotSpotProxy constantPool, int cpi); +// public RiField RiConstantPool_lookupField(long vmId, int cpi); JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupField(JNIEnv *env, jobject, jlong vmId, jint index) { VM_ENTRY_MARK; @@ -212,7 +212,7 @@ return JNIHandles::make_local(THREAD, C1XCompiler::get_RiField(field, THREAD)); } -// public RiConstantPool RiType_constantPool(HotSpotProxy type); +// public RiConstantPool RiType_constantPool(long vmId); JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiType_1constantPool(JNIEnv *, jobject, jlong vmId) { VM_ENTRY_MARK; @@ -220,21 +220,26 @@ return JNIHandles::make_local(VMExits::createRiConstantPool(C1XObjects::add<constantPoolOop>(constantPool), THREAD)); } -// public boolean RiType_isArrayClass(HotSpotProxy klass); +// public boolean RiType_isArrayClass(long vmId); JNIEXPORT jboolean JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiType_1isArrayClass(JNIEnv *, jobject, jlong vmId) { return C1XObjects::get<klassOop>(vmId)->klass_part()->oop_is_javaArray(); } -// public boolean RiType_isInstanceClass(HotSpotProxy klass); +// public boolean RiType_isInstanceClass(long vmId); JNIEXPORT jboolean JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiType_1isInstanceClass(JNIEnv *, jobject, jlong vmId) { return C1XObjects::get<klassOop>(vmId)->klass_part()->oop_is_instance(); } -// public boolean RiType_isInterface(HotSpotProxy klass); +// public boolean RiType_isInterface(long vmId); JNIEXPORT jboolean JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiType_1isInterface(JNIEnv *, jobject, jlong vmId) { return C1XObjects::get<klassOop>(vmId)->klass_part()->is_interface(); } +// public long RiType_instanceSize(long vmId); +JNIEXPORT jlong JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiType_1instanceSize(JNIEnv *, jobject, jlong vmId) { + return align_object_size(instanceKlass::cast(C1XObjects::get<klassOop>(vmId))->size_helper() * HeapWordSize); +} + // helpers used to set fields in the HotSpotVMConfig object jfieldID getFieldID(JNIEnv* env, jobject obj, const char* name, const char* sig) { @@ -278,10 +283,15 @@ set_int(env, config, "stackShadowPages", StackShadowPages); set_int(env, config, "hubOffset", oopDesc::klass_offset_in_bytes()); set_int(env, config, "arrayLengthOffset", arrayOopDesc::length_offset_in_bytes()); + set_int(env, config, "threadTlabTopOffset", in_bytes(JavaThread::tlab_top_offset())); + set_int(env, config, "threadTlabEndOffset", in_bytes(JavaThread::tlab_end_offset())); + set_int(env, config, "instanceHeaderPrototypeOffset", Klass::prototype_header_offset_in_bytes() + klassOopDesc::klass_part_offset_in_bytes()); set_long(env, config, "instanceofStub", C1XObjects::addStub(Runtime1::entry_for(Runtime1::slow_subtype_check_id))); set_long(env, config, "debugStub", C1XObjects::addStub((address)warning)); set_long(env, config, "resolveStaticCallStub", C1XObjects::addStub(SharedRuntime::get_resolve_static_call_stub())); + set_long(env, config, "newInstanceStub", C1XObjects::addStub(Runtime1::entry_for(Runtime1::fast_new_instance_id))); + jintArray arrayOffsets = env->NewIntArray(basicTypeCount); for (int i=0; i<basicTypeCount; i++) { jint offset = arrayOopDesc::base_offset_in_bytes(basicTypes[i]); @@ -510,19 +520,34 @@ assert((runtime_call ? 1 : 0) + (hotspot_method ? 1 : 0) + (symbol ? 1 : 0) + (global_stub ? 1 : 0) == 1, "Call site needs exactly one type"); + address instruction = _instructions->start() + pc_offset; + address operand = Assembler::locate_operand(instruction, Assembler::call32_operand); + address next_instruction = Assembler::locate_next_instruction(instruction); + if (runtime_call != NULL) { + if (runtime_call == CiRuntimeCall::Debug()) { + tty->print_cr("CiRuntimeCall::Debug()"); + } else { + runtime_call->print(); + } tty->print_cr("runtime_call"); } else if (global_stub != NULL) { - tty->print_cr("global_stub_id"); + assert(java_lang_boxing_object::is_instance(global_stub, T_LONG), "global_stub needs to be of type Long"); + + jlong stub_id = global_stub->long_field(java_lang_boxing_object::value_offset_in_bytes(T_LONG)); + address dest = C1XObjects::getStub(stub_id); + long disp = dest - next_instruction; + assert(disp == (jint) disp, "disp doesn't fit in 32 bits"); + *((jint*)operand) = (jint)disp; + + _instructions->relocate(instruction, runtime_call_Relocation::spec(), Assembler::call32_operand); + tty->print_cr("relocating (stub) %016x/%016x", instruction, operand); } else if (symbol != NULL) { tty->print_cr("symbol"); } else { // method != NULL assert(hotspot_method->is_a(SystemDictionary::HotSpotMethod_klass()), "unexpected RiMethod subclass"); methodOop method = C1XObjects::get<methodOop>(HotSpotMethod::vmId(hotspot_method)); - address instruction = _instructions->start() + pc_offset; - address operand = Assembler::locate_operand(instruction, Assembler::call32_operand); - address next_instruction = Assembler::locate_next_instruction(instruction); jint next_pc_offset = next_instruction - _instructions->start(); assert(debug_info != NULL, "debug info expected"); @@ -534,7 +559,6 @@ if (method->is_static()) { tty->print_cr("static method"); - address dest = SharedRuntime::get_resolve_static_call_stub(); long disp = dest - next_instruction; assert(disp == (jint) disp, "disp doesn't fit in 32 bits"); @@ -544,7 +568,14 @@ tty->print_cr("relocating (Long) %016x/%016x", instruction, operand); } else { tty->print_cr("non-static method"); - ShouldNotReachHere(); + + address dest = SharedRuntime::get_resolve_opt_virtual_call_stub(); + long disp = dest - next_instruction; + assert(disp == (jint) disp, "disp doesn't fit in 32 bits"); + *((jint*)operand) = (jint)disp; + + _instructions->relocate(instruction, relocInfo::opt_virtual_call_type, Assembler::call32_operand); + tty->print_cr("relocating (Long) %016x/%016x", instruction, operand); } _debug_recorder->end_safepoint(pc_offset); @@ -556,8 +587,6 @@ oop kind = CiConstant::kind(constant); address instruction = _instructions->start() + pc_offset; - address operand = Assembler::locate_operand(instruction, Assembler::disp32_operand); - address next_instruction = Assembler::locate_next_instruction(instruction); switch(CiKind::typeChar(kind)) { case 'z': @@ -570,6 +599,8 @@ case 'f': case 'l': case 'd': { + address operand = Assembler::locate_operand(instruction, Assembler::disp32_operand); + address next_instruction = Assembler::locate_next_instruction(instruction); // we don't care if this is a long/double/etc., the primitive field contains the right bits address dest = _constants->end(); *(jlong*)dest = CiConstant::primitive(constant); @@ -583,10 +614,53 @@ tty->print_cr("relocating (Float/Long/Double) at %016x/%016x", instruction, operand); break; } - case 'a': - CiConstant::object(constant)->print(); - tty->print_cr("DataPatch of object type"); + case 'a': { + address operand = Assembler::locate_operand(instruction, Assembler::imm_operand); + oop obj = CiConstant::object(constant); + + if (obj->is_a(HotSpotTypeResolved::klass())) { + *((jobject*)operand) = JNIHandles::make_local(C1XObjects::get<klassOop>(HotSpotTypeResolved::vmId(obj))); + _instructions->relocate(instruction, oop_Relocation::spec_for_immediate(), Assembler::imm_operand); + tty->print_cr("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 & C1XObjects::TYPE_MASK) == C1XObjects::CONSTANT, "unexpected DataPatch type"); + + address operand = Assembler::locate_operand(instruction, Assembler::imm_operand); + + *((jobject*)operand) = JNIHandles::make_local(C1XObjects::get<oop>(id)); + _instructions->relocate(instruction, oop_Relocation::spec_for_immediate(), Assembler::imm_operand); + tty->print_cr("relocating (oop constant) at %016x/%016x", instruction, operand); + } + + /* + jlong id = com_sun_hotspot_c1x_HotSpotProxy::get_id(obj); + switch (id & C1XObjects::TYPE_MASK) { + case C1XObjects::CONSTANT: { + address operand = Assembler::locate_operand(inst, Assembler::imm_operand); + + *((jobject*)operand) = JNIHandles::make_local(C1XObjects::get<oop>(id)); + instructions->relocate(inst, oop_Relocation::spec_for_immediate(), Assembler::imm_operand); + tty->print_cr("relocating (HotSpotType) %02x at %016x/%016x", inst_byte, inst, operand); + break; + } + case C1XObjects::STUB: { + address operand = Assembler::locate_operand(inst, Assembler::call32_operand); + + long dest = (long)C1XObjects::getStub(id); + long disp = dest - (long)(operand + 4); + assert(disp == (int) disp, "disp doesn't fit in 32 bits"); + *((int*)operand) = (int)disp; + + instructions->relocate(inst, runtime_call_Relocation::spec(), Assembler::call32_operand); + tty->print_cr("relocating (Long) %02x at %016x/%016x", inst_byte, inst, operand); + break; + } + }*/ break; + } default: fatal("unexpected CiKind in DataPatch"); break; @@ -790,6 +864,7 @@ {CC"RiType_isArrayClass", CC"("PROXY")Z", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiType_1isArrayClass)}, {CC"RiType_isInstanceClass", CC"("PROXY")Z", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiType_1isInstanceClass)}, {CC"RiType_isInterface", CC"("PROXY")Z", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiType_1isInterface)}, + {CC"RiType_instanceSize", CC"("PROXY")J", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiType_1instanceSize)}, {CC"getConfiguration", CC"()"CONFIG, FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_getConfiguration)}, {CC"installMethod", CC"("TARGET_METHOD")V", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_installMethod)}, {CC"installStub", CC"("TARGET_METHOD")"PROXY, FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_installStub)}