# HG changeset patch # User Doug Simon # Date 1367347580 -7200 # Node ID 3e7d22d31f7eb28f6ca12f49559505451023c8cd # Parent 21ccdce289b2ca37175e213bf37ee2bcafd8b2e1 replaced stub_printf assembler stub with a compiled stub (GRAAL-81) diff -r 21ccdce289b2 -r 3e7d22d31f7e graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java Tue Apr 30 20:28:33 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java Tue Apr 30 20:46:20 2013 +0200 @@ -368,7 +368,6 @@ public long logPrimitiveStub; public long logObjectStub; public long logPrintfStub; - public long stubPrintfStub; public int deoptReasonNone; public long identityHashCodeStub; public long aescryptEncryptBlockStub; @@ -381,6 +380,7 @@ public long newMultiArrayAddress; public long registerFinalizerAddress; public long threadIsInterruptedAddress; + public long stubPrintfAddress; public int deoptReasonNullCheck; public int deoptReasonRangeCheck; diff -r 21ccdce289b2 -r 3e7d22d31f7e graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Tue Apr 30 20:28:33 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Tue Apr 30 20:46:20 2013 +0200 @@ -309,13 +309,12 @@ /* arg2: value */ Kind.Long, /* arg3: value */ Kind.Long)); - addRuntimeCall(STUB_PRINTF, config.stubPrintfStub, - /* temps */ null, + addCRuntimeCall(STUB_PRINTF_C, config.stubPrintfAddress, /* ret */ ret(Kind.Void), - /* arg0: format */ javaCallingConvention(Kind.Long, - /* arg1: value */ Kind.Long, - /* arg2: value */ Kind.Long, - /* arg3: value */ Kind.Long)); + /* arg0: format */ nativeCallingConvention(Kind.Long, + /* arg1: value */ Kind.Long, + /* arg2: value */ Kind.Long, + /* arg3: value */ Kind.Long)); addRuntimeCall(LOG_OBJECT, config.logObjectStub, /* temps */ null, diff -r 21ccdce289b2 -r 3e7d22d31f7e graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java Tue Apr 30 20:28:33 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java Tue Apr 30 20:46:20 2013 +0200 @@ -50,7 +50,6 @@ import com.oracle.graal.hotspot.nodes.*; import com.oracle.graal.java.*; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.phases.*; import com.oracle.graal.phases.PhasePlan.PhasePosition; @@ -254,27 +253,29 @@ } } - public static final Descriptor STUB_PRINTF = new Descriptor("stubPrintf", false, void.class, Word.class, long.class, long.class, long.class); + public static final Descriptor STUB_PRINTF_C = descriptorFor(Stub.class, "printfC", false); - @NodeIntrinsic(RuntimeCallNode.class) - private static native void printf(@ConstantNodeParameter Descriptor stubPrintf, Word format, long v1, long v2, long v3); + @NodeIntrinsic(CRuntimeCall.class) + private static native void printfC(@ConstantNodeParameter Descriptor stubPrintf, Word format, long v1, long v2, long v3); /** - * Prints a formatted string to the log stream. + * Prints a formatted string to the log stream. This differs from {@link Log#LOG_PRINTF} in that + * the format string is a C string in the C heap which avoids having an embedded oop in a + * RuntimeStub. * * @param format a C style printf format value that can contain at most one conversion specifier * (i.e., a sequence of characters starting with '%'). * @param value the value associated with the conversion specifier */ public static void printf(String format, long value) { - printf(STUB_PRINTF, cstring(format), value, 0L, 0L); + printfC(STUB_PRINTF_C, cstring(format), value, 0L, 0L); } public static void printf(String format, long v1, long v2) { - printf(STUB_PRINTF, cstring(format), v1, v2, 0L); + printfC(STUB_PRINTF_C, cstring(format), v1, v2, 0L); } public static void printf(String format, long v1, long v2, long v3) { - printf(STUB_PRINTF, cstring(format), v1, v2, v3); + printfC(STUB_PRINTF_C, cstring(format), v1, v2, v3); } } diff -r 21ccdce289b2 -r 3e7d22d31f7e src/cpu/x86/vm/graalRuntime_x86.cpp --- a/src/cpu/x86/vm/graalRuntime_x86.cpp Tue Apr 30 20:28:33 2013 +0200 +++ b/src/cpu/x86/vm/graalRuntime_x86.cpp Tue Apr 30 20:46:20 2013 +0200 @@ -889,18 +889,6 @@ break; } - case stub_printf_id: { - __ enter(); - oop_maps = new OopMapSet(); - OopMap* oop_map = save_live_registers(sasm, 4); - int call_offset = __ call_RT(noreg, noreg, (address)stub_printf, j_rarg0, j_rarg1, j_rarg2, j_rarg3); - oop_maps->add_gc_map(call_offset, oop_map); - restore_live_registers(sasm); - __ leave(); - __ ret(0); - break; - } - case log_primitive_id: { __ enter(); oop_maps = new OopMapSet(); diff -r 21ccdce289b2 -r 3e7d22d31f7e src/share/vm/graal/graalCompilerToVM.cpp --- a/src/share/vm/graal/graalCompilerToVM.cpp Tue Apr 30 20:28:33 2013 +0200 +++ b/src/share/vm/graal/graalCompilerToVM.cpp Tue Apr 30 20:46:20 2013 +0200 @@ -776,7 +776,6 @@ set_address("logPrimitiveStub", GraalRuntime::entry_for(GraalRuntime::log_primitive_id)); set_address("logObjectStub", GraalRuntime::entry_for(GraalRuntime::log_object_id)); set_address("logPrintfStub", GraalRuntime::entry_for(GraalRuntime::log_printf_id)); - set_address("stubPrintfStub", GraalRuntime::entry_for(GraalRuntime::stub_printf_id)); set_address("aescryptEncryptBlockStub", StubRoutines::aescrypt_encryptBlock()); set_address("aescryptDecryptBlockStub", StubRoutines::aescrypt_decryptBlock()); set_address("cipherBlockChainingEncryptAESCryptStub", StubRoutines::cipherBlockChaining_encryptAESCrypt()); @@ -788,6 +787,7 @@ set_address("registerFinalizerAddress", SharedRuntime::register_finalizer); set_address("threadIsInterruptedAddress", GraalRuntime::thread_is_interrupted); set_address("uncommonTrapStub", SharedRuntime::deopt_blob()->uncommon_trap()); + set_address("stubPrintfAddress", GraalRuntime::stub_printf); set_int("deoptReasonNone", Deoptimization::Reason_none); set_int("deoptReasonNullCheck", Deoptimization::Reason_null_check); diff -r 21ccdce289b2 -r 3e7d22d31f7e src/share/vm/graal/graalRuntime.cpp --- a/src/share/vm/graal/graalRuntime.cpp Tue Apr 30 20:28:33 2013 +0200 +++ b/src/share/vm/graal/graalRuntime.cpp Tue Apr 30 20:46:20 2013 +0200 @@ -570,7 +570,7 @@ tty->print(buf, v1, v2, v3); JRT_END -JRT_LEAF(void, GraalRuntime::stub_printf(JavaThread* thread, jlong format, jlong v1, jlong v2, jlong v3)) +JRT_LEAF(void, GraalRuntime::stub_printf(jlong format, jlong v1, jlong v2, jlong v3)) ResourceMark rm; char *buf = (char*) (address) format; tty->print(buf, v1, v2, v3); diff -r 21ccdce289b2 -r 3e7d22d31f7e src/share/vm/graal/graalRuntime.hpp --- a/src/share/vm/graal/graalRuntime.hpp Tue Apr 30 20:28:33 2013 +0200 +++ b/src/share/vm/graal/graalRuntime.hpp Tue Apr 30 20:46:20 2013 +0200 @@ -94,7 +94,6 @@ stub(create_out_of_bounds_exception) \ stub(log_object) \ stub(log_printf) \ - stub(stub_printf) \ stub(log_primitive) \ stub(identity_hash_code) \ stub(wb_pre_call) \ @@ -138,7 +137,6 @@ static void monitorexit (JavaThread* thread, oopDesc* obj, BasicLock* lock); static void vm_error(JavaThread* thread, oop where, oop format, jlong value); static void log_printf(JavaThread* thread, oop format, jlong v1, jlong v2, jlong v3); - static void stub_printf(JavaThread* thread, jlong format, jlong v1, jlong v2, jlong v3); static void log_primitive(JavaThread* thread, jchar typeChar, jlong value, jboolean newline); static void wb_pre_call(JavaThread* thread, oopDesc* obj); static void wb_post_call(JavaThread* thread, oopDesc* obj, void* card); @@ -158,6 +156,7 @@ static void new_array(JavaThread* thread, Klass* klass, jint length); static void new_multi_array(JavaThread* thread, Klass* klass, int rank, jint* dims); static jboolean thread_is_interrupted(JavaThread* thread, oopDesc* obj, jboolean clear_interrupte); + static void stub_printf(jlong format, jlong v1, jlong v2, jlong v3); // initialization static void initialize(BufferBlob* blob);