# HG changeset patch # User Doug Simon # Date 1367878825 -7200 # Node ID a3b4bcc22313cf55f60ae0fa56bd0d8262f38190 # Parent efb8c1918ea5562f4d27ccfb31eb9776b39270d0 replaced log_* assembler stubs with compiled stubs (GRAAL-81) diff -r efb8c1918ea5 -r a3b4bcc22313 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 Mon May 06 23:43:01 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java Tue May 07 00:20:25 2013 +0200 @@ -380,9 +380,6 @@ public long arithmeticSinStub; public long arithmeticCosStub; public long arithmeticTanStub; - public long logPrimitiveStub; - public long logObjectStub; - public long logPrintfStub; public int deoptReasonNone; public long aescryptEncryptBlockStub; public long aescryptDecryptBlockStub; @@ -403,6 +400,9 @@ public long monitorexitAddress; public long createNullPointerExceptionAddress; public long createOutOfBoundsExceptionAddress; + public long logPrimitiveAddress; + public long logObjectAddress; + public long logPrintfAddress; public int deoptReasonNullCheck; public int deoptReasonRangeCheck; diff -r efb8c1918ea5 -r a3b4bcc22313 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 Mon May 06 23:43:01 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Tue May 07 00:20:25 2013 +0200 @@ -43,6 +43,9 @@ import static com.oracle.graal.hotspot.stubs.CreateOutOfBoundsExceptionStub.*; import static com.oracle.graal.hotspot.stubs.ExceptionHandlerStub.*; import static com.oracle.graal.hotspot.stubs.IdentityHashCodeStub.*; +import static com.oracle.graal.hotspot.stubs.LogObjectStub.*; +import static com.oracle.graal.hotspot.stubs.LogPrimitiveStub.*; +import static com.oracle.graal.hotspot.stubs.LogPrintfStub.*; import static com.oracle.graal.hotspot.stubs.MonitorEnterStub.*; import static com.oracle.graal.hotspot.stubs.MonitorExitStub.*; import static com.oracle.graal.hotspot.stubs.NewArrayStub.*; @@ -318,21 +321,34 @@ /* ret */ ret(Kind.Double), /* arg0: index */ javaCallingConvention(Kind.Double)); - addRuntimeCall(LOG_PRIMITIVE, config.logPrimitiveStub, - /* temps */ null, + addStubCall(LOG_PRIMITIVE, /* ret */ ret(Kind.Void), /* arg0: typeChar */ javaCallingConvention(Kind.Int, /* arg1: value */ Kind.Long, /* arg2: newline */ Kind.Boolean)); - addRuntimeCall(LOG_PRINTF, config.logPrintfStub, - /* temps */ null, + addCRuntimeCall(LOG_PRIMITIVE_C, config.logPrimitiveAddress, + /* ret */ ret(Kind.Void), + /* arg0: thread */ nativeCallingConvention(word, + /* arg1: typeChar */ Kind.Char, + /* arg2: value */ Kind.Long, + /* arg3: newline */ Kind.Boolean)); + + addStubCall(LOG_PRINTF, /* ret */ ret(Kind.Void), /* arg0: format */ javaCallingConvention(Kind.Object, /* arg1: value */ Kind.Long, /* arg2: value */ Kind.Long, /* arg3: value */ Kind.Long)); + addCRuntimeCall(LOG_PRINTF_C, config.logObjectAddress, + /* ret */ ret(Kind.Void), + /* arg0: thread */ nativeCallingConvention(word, + /* arg1: format */ Kind.Object, + /* arg2: v1 */ Kind.Long, + /* arg3: v2 */ Kind.Long, + /* arg4: v3 */ Kind.Long)); + addCRuntimeCall(VM_MESSAGE_C, config.vmMessageAddress, /* ret */ ret(Kind.Void), /* arg0: vmError */ nativeCallingConvention(Kind.Boolean, @@ -341,12 +357,17 @@ /* arg3: value */ Kind.Long, /* arg4: value */ Kind.Long)); - addRuntimeCall(LOG_OBJECT, config.logObjectStub, - /* temps */ null, + addStubCall(LOG_OBJECT, /* ret */ ret(Kind.Void), /* arg0: object */ javaCallingConvention(Kind.Object, /* arg1: flags */ Kind.Int)); + addCRuntimeCall(LOG_OBJECT_C, config.logObjectAddress, + /* ret */ ret(Kind.Void), + /* arg0: thread */ nativeCallingConvention(word, + /* arg1: object */ Kind.Object, + /* arg2: flags */ Kind.Int)); + addStubCall(THREAD_IS_INTERRUPTED, /* ret */ ret(Kind.Boolean), /* arg0: thread */ javaCallingConvention(Kind.Object, @@ -537,6 +558,9 @@ registerStub(new MonitorExitStub(this, replacements, graalRuntime.getTarget(), runtimeCalls.get(MONITOREXIT))); registerStub(new CreateNullPointerExceptionStub(this, replacements, graalRuntime.getTarget(), runtimeCalls.get(CREATE_NULL_POINTER_EXCEPTION))); registerStub(new CreateOutOfBoundsExceptionStub(this, replacements, graalRuntime.getTarget(), runtimeCalls.get(CREATE_OUT_OF_BOUNDS_EXCEPTION))); + registerStub(new LogPrimitiveStub(this, replacements, graalRuntime.getTarget(), runtimeCalls.get(Log.LOG_PRIMITIVE))); + registerStub(new LogObjectStub(this, replacements, graalRuntime.getTarget(), runtimeCalls.get(Log.LOG_OBJECT))); + registerStub(new LogPrintfStub(this, replacements, graalRuntime.getTarget(), runtimeCalls.get(Log.LOG_PRINTF))); } private void registerStub(Stub stub) { diff -r efb8c1918ea5 -r a3b4bcc22313 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/LogObjectStub.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/LogObjectStub.java Tue May 07 00:20:25 2013 +0200 @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspot.stubs; + +import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*; + +import com.oracle.graal.api.code.RuntimeCallTarget.Descriptor; +import com.oracle.graal.api.code.*; +import com.oracle.graal.graph.Node.ConstantNodeParameter; +import com.oracle.graal.graph.Node.NodeIntrinsic; +import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.hotspot.nodes.*; +import com.oracle.graal.nodes.spi.*; +import com.oracle.graal.replacements.*; +import com.oracle.graal.word.*; + +/** + * Stub called from {@link Log}. + */ +public class LogObjectStub extends CRuntimeStub { + + public LogObjectStub(final HotSpotRuntime runtime, Replacements replacements, TargetDescription target, HotSpotRuntimeCallTarget linkage) { + super(runtime, replacements, target, linkage); + } + + @Snippet + private static void logObject(Object object, int flags) { + logObjectC(LOG_OBJECT_C, thread(), object, flags); + } + + public static final Descriptor LOG_OBJECT_C = descriptorFor(LogObjectStub.class, "logObjectC", false); + + @NodeIntrinsic(CRuntimeCall.class) + public static native void logObjectC(@ConstantNodeParameter Descriptor logObjectC, Word thread, Object object, int flags); +} diff -r efb8c1918ea5 -r a3b4bcc22313 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/LogPrimitiveStub.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/LogPrimitiveStub.java Tue May 07 00:20:25 2013 +0200 @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspot.stubs; + +import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*; + +import com.oracle.graal.api.code.RuntimeCallTarget.Descriptor; +import com.oracle.graal.api.code.*; +import com.oracle.graal.graph.Node.ConstantNodeParameter; +import com.oracle.graal.graph.Node.NodeIntrinsic; +import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.hotspot.nodes.*; +import com.oracle.graal.nodes.spi.*; +import com.oracle.graal.replacements.*; +import com.oracle.graal.word.*; + +/** + * Stub called from {@link Log}. + */ +public class LogPrimitiveStub extends CRuntimeStub { + + public LogPrimitiveStub(final HotSpotRuntime runtime, Replacements replacements, TargetDescription target, HotSpotRuntimeCallTarget linkage) { + super(runtime, replacements, target, linkage); + } + + @Snippet + private static void logPrimitive(char typeChar, long value, boolean newline) { + logPrimitivefC(LOG_PRIMITIVE_C, thread(), typeChar, value, newline); + } + + public static final Descriptor LOG_PRIMITIVE_C = descriptorFor(LogPrimitiveStub.class, "logPrimitivefC", false); + + @NodeIntrinsic(CRuntimeCall.class) + public static native void logPrimitivefC(@ConstantNodeParameter Descriptor logPrimitivefC, Word thread, char typeChar, long value, boolean newline); +} diff -r efb8c1918ea5 -r a3b4bcc22313 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/LogPrintfStub.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/LogPrintfStub.java Tue May 07 00:20:25 2013 +0200 @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspot.stubs; + +import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*; + +import com.oracle.graal.api.code.RuntimeCallTarget.Descriptor; +import com.oracle.graal.api.code.*; +import com.oracle.graal.graph.Node.ConstantNodeParameter; +import com.oracle.graal.graph.Node.NodeIntrinsic; +import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.hotspot.nodes.*; +import com.oracle.graal.nodes.spi.*; +import com.oracle.graal.replacements.*; +import com.oracle.graal.word.*; + +/** + * Stub called from {@link Log}. + */ +public class LogPrintfStub extends CRuntimeStub { + + public LogPrintfStub(final HotSpotRuntime runtime, Replacements replacements, TargetDescription target, HotSpotRuntimeCallTarget linkage) { + super(runtime, replacements, target, linkage); + } + + @Snippet + private static void logPrintf(String format, long v1, long v2, long v3) { + logPrintfC(LOG_PRINTF_C, thread(), format, v1, v2, v3); + } + + public static final Descriptor LOG_PRINTF_C = descriptorFor(LogPrintfStub.class, "logPrintfC", false); + + @NodeIntrinsic(CRuntimeCall.class) + public static native void logPrintfC(@ConstantNodeParameter Descriptor logPrintfC, Word thread, String format, long v1, long v2, long v3); +} diff -r efb8c1918ea5 -r a3b4bcc22313 src/cpu/x86/vm/graalRuntime_x86.cpp --- a/src/cpu/x86/vm/graalRuntime_x86.cpp Mon May 06 23:43:01 2013 +0200 +++ b/src/cpu/x86/vm/graalRuntime_x86.cpp Tue May 07 00:20:25 2013 +0200 @@ -600,42 +600,6 @@ break; } - case log_printf_id: { - __ enter(); - oop_maps = new OopMapSet(); - OopMap* oop_map = save_live_registers(sasm, 4); - int call_offset = __ call_RT(noreg, noreg, (address)log_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(); - OopMap* oop_map = save_live_registers(sasm, 3); - int call_offset = __ call_RT(noreg, noreg, (address)log_primitive, j_rarg0, j_rarg1, j_rarg2); - oop_maps->add_gc_map(call_offset, oop_map); - restore_live_registers(sasm); - __ leave(); - __ ret(0); - break; - } - - case log_object_id: { - __ enter(); - oop_maps = new OopMapSet(); - OopMap* oop_map = save_live_registers(sasm, 2); - int call_offset = __ call_RT(noreg, noreg, (address)log_object, j_rarg0, j_rarg1); - oop_maps->add_gc_map(call_offset, oop_map); - restore_live_registers(sasm); - __ leave(); - __ ret(0); - break; - } - case wb_pre_call_id: { Register obj = j_rarg0; { diff -r efb8c1918ea5 -r a3b4bcc22313 src/share/vm/graal/graalCompilerToVM.cpp --- a/src/share/vm/graal/graalCompilerToVM.cpp Mon May 06 23:43:01 2013 +0200 +++ b/src/share/vm/graal/graalCompilerToVM.cpp Tue May 07 00:20:25 2013 +0200 @@ -768,9 +768,6 @@ set_address("arithmeticSinStub", CAST_FROM_FN_PTR(address, SharedRuntime::dsin)); set_address("arithmeticCosStub", CAST_FROM_FN_PTR(address, SharedRuntime::dcos)); set_address("arithmeticTanStub", CAST_FROM_FN_PTR(address, SharedRuntime::dtan)); - 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("aescryptEncryptBlockStub", StubRoutines::aescrypt_encryptBlock()); set_address("aescryptDecryptBlockStub", StubRoutines::aescrypt_decryptBlock()); set_address("cipherBlockChainingEncryptAESCryptStub", StubRoutines::cipherBlockChaining_encryptAESCrypt()); @@ -791,6 +788,9 @@ set_address("monitorexitAddress", GraalRuntime::monitorexit); set_address("createNullPointerExceptionAddress", GraalRuntime::create_null_exception); set_address("createOutOfBoundsExceptionAddress", GraalRuntime::create_out_of_bounds_exception); + set_address("logPrimitiveAddress", GraalRuntime::log_primitive); + set_address("logObjectAddress", GraalRuntime::log_object); + set_address("logPrintfAddress", GraalRuntime::log_printf); set_int("deoptReasonNone", Deoptimization::Reason_none); set_int("deoptReasonNullCheck", Deoptimization::Reason_null_check); diff -r efb8c1918ea5 -r a3b4bcc22313 src/share/vm/graal/graalRuntime.hpp --- a/src/share/vm/graal/graalRuntime.hpp Mon May 06 23:43:01 2013 +0200 +++ b/src/share/vm/graal/graalRuntime.hpp Tue May 07 00:20:25 2013 +0200 @@ -79,9 +79,6 @@ // by Graal. #define GRAAL_STUBS(stub, last_entry) \ stub(vm_error) \ - stub(log_object) \ - stub(log_printf) \ - stub(log_primitive) \ stub(wb_pre_call) \ stub(wb_post_call) \ last_entry(number_of_ids) @@ -114,14 +111,6 @@ // runtime entry points static void unimplemented_entry(JavaThread* thread, StubID id); - // Note: Must be kept in sync with constants in com.oracle.graal.replacements.Log - enum { - LOG_OBJECT_NEWLINE = 0x01, - LOG_OBJECT_STRING = 0x02, - LOG_OBJECT_ADDRESS = 0x04 - }; - static void log_object(JavaThread* thread, oop msg, jint flags); - public: static void new_instance(JavaThread* thread, Klass* klass); static void new_array(JavaThread* thread, Klass* klass, jint length); @@ -137,6 +126,13 @@ 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 log_primitive(JavaThread* thread, jchar typeChar, jlong value, jboolean newline); + // Note: Must be kept in sync with constants in com.oracle.graal.replacements.Log + enum { + LOG_OBJECT_NEWLINE = 0x01, + LOG_OBJECT_STRING = 0x02, + LOG_OBJECT_ADDRESS = 0x04 + }; + static void log_object(JavaThread* thread, oop msg, jint flags); static void wb_pre_call(JavaThread* thread, oopDesc* obj); static void wb_post_call(JavaThread* thread, oopDesc* obj, void* card);