# HG changeset patch # User Doug Simon # Date 1367276013 -7200 # Node ID a14fef4fca7d4a40d226022dfe807d7da40efa4b # Parent 20dc10bb82d1251685392a4d1eba5ff1cb4de814 replaced identity_hash_code assembler stub with a compiled stub (GRAAL-81) diff -r 20dc10bb82d1 -r a14fef4fca7d graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRuntime.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRuntime.java Tue Apr 30 00:34:07 2013 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRuntime.java Tue Apr 30 00:53:33 2013 +0200 @@ -27,7 +27,6 @@ import static com.oracle.graal.hotspot.amd64.AMD64DeoptimizeOp.*; import static com.oracle.graal.hotspot.amd64.AMD64HotSpotBackend.*; import static com.oracle.graal.hotspot.amd64.AMD64HotSpotUnwindOp.*; -import static com.oracle.graal.hotspot.nodes.IdentityHashCodeStubCall.*; import static com.oracle.graal.hotspot.nodes.MonitorEnterStubCall.*; import static com.oracle.graal.hotspot.nodes.MonitorExitStubCall.*; import static com.oracle.graal.hotspot.nodes.VMErrorNode.*; @@ -112,11 +111,6 @@ /* arg1: format */ Kind.Object, /* arg2: value */ Kind.Long)); - addRuntimeCall(IDENTITY_HASHCODE, config.identityHashCodeStub, - /* temps */ null, - /* ret */ rax.asValue(Kind.Int), - /* arg0: obj */ javaCallingConvention(Kind.Object)); - addRuntimeCall(ENCRYPT_BLOCK, config.aescryptEncryptBlockStub, /* temps */ null, /* ret */ ret(Kind.Void), diff -r 20dc10bb82d1 -r a14fef4fca7d 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 00:34:07 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java Tue Apr 30 00:53:33 2013 +0200 @@ -370,7 +370,6 @@ public long logPrintfStub; public long stubPrintfStub; public int deoptReasonNone; - public long identityHashCodeStub; public long aescryptEncryptBlockStub; public long aescryptDecryptBlockStub; public long cipherBlockChainingEncryptAESCryptStub; @@ -381,6 +380,7 @@ public long newMultiArrayAddress; public long registerFinalizerAddress; public long threadIsInterruptedAddress; + public long identityHashCodeAddress; public int deoptReasonNullCheck; public int deoptReasonRangeCheck; diff -r 20dc10bb82d1 -r a14fef4fca7d 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 00:34:07 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Tue Apr 30 00:53:33 2013 +0200 @@ -30,15 +30,18 @@ import static com.oracle.graal.api.meta.Value.*; import static com.oracle.graal.graph.UnsafeAccess.*; import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; +import static com.oracle.graal.hotspot.nodes.IdentityHashCodeStubCall.*; import static com.oracle.graal.hotspot.nodes.NewArrayStubCall.*; import static com.oracle.graal.hotspot.nodes.NewInstanceStubCall.*; import static com.oracle.graal.hotspot.nodes.NewMultiArrayStubCall.*; import static com.oracle.graal.hotspot.nodes.ThreadIsInterruptedStubCall.*; import static com.oracle.graal.hotspot.replacements.SystemSubstitutions.*; +import static com.oracle.graal.hotspot.stubs.IdentityHashCodeStub.*; import static com.oracle.graal.hotspot.stubs.NewArrayStub.*; import static com.oracle.graal.hotspot.stubs.NewInstanceStub.*; import static com.oracle.graal.hotspot.stubs.NewMultiArrayStub.*; import static com.oracle.graal.hotspot.stubs.RegisterFinalizerStub.*; +import static com.oracle.graal.hotspot.stubs.Stub.*; import static com.oracle.graal.hotspot.stubs.ThreadIsInterruptedStub.*; import static com.oracle.graal.java.GraphBuilderPhase.RuntimeCalls.*; import static com.oracle.graal.nodes.java.RegisterFinalizerNode.*; @@ -332,6 +335,15 @@ /* arg1: receiverThread */ Kind.Object, /* arg1: clearInterrupted */ Kind.Boolean)); + addStubCall(IDENTITY_HASHCODE, + /* ret */ ret(Kind.Int), + /* arg0: obj */ javaCallingConvention(Kind.Object)); + + addCRuntimeCall(IDENTITY_HASH_CODE_C, config.identityHashCodeAddress, + /* ret */ ret(Kind.Int), + /* arg0: thread */ nativeCallingConvention(word, + /* arg1: object */ Kind.Object)); + // @formatter:on } @@ -429,6 +441,7 @@ registerStub(new NewMultiArrayStub(this, replacements, graalRuntime.getTarget(), runtimeCalls.get(NEW_MULTI_ARRAY))); registerStub(new RegisterFinalizerStub(this, replacements, graalRuntime.getTarget(), runtimeCalls.get(REGISTER_FINALIZER))); registerStub(new ThreadIsInterruptedStub(this, replacements, graalRuntime.getTarget(), runtimeCalls.get(THREAD_IS_INTERRUPTED))); + registerStub(new IdentityHashCodeStub(this, replacements, graalRuntime.getTarget(), runtimeCalls.get(IDENTITY_HASHCODE))); } private void registerStub(Stub stub) { diff -r 20dc10bb82d1 -r a14fef4fca7d graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/IdentityHashCodeStubCall.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/IdentityHashCodeStubCall.java Tue Apr 30 00:34:07 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/IdentityHashCodeStubCall.java Tue Apr 30 00:53:33 2013 +0200 @@ -27,12 +27,13 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.gen.*; import com.oracle.graal.compiler.target.*; +import com.oracle.graal.hotspot.stubs.*; import com.oracle.graal.lir.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.type.*; /** - * Node implementing a call to HotSpot's {@code graal_identityhashcode} stub. + * Node implementing a call to {@link IdentityHashCodeStub}. */ public class IdentityHashCodeStubCall extends DeoptimizingStubCall implements LIRGenLowerable { diff -r 20dc10bb82d1 -r a14fef4fca7d graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/IdentityHashCodeStub.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/IdentityHashCodeStub.java Tue Apr 30 00:53:33 2013 +0200 @@ -0,0 +1,59 @@ +/* + * 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.HotSpotSnippetUtils.*; + +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 IdentityHashCodeStubCall}. + */ +public class IdentityHashCodeStub extends CRuntimeStub { + + public IdentityHashCodeStub(final HotSpotRuntime runtime, Replacements replacements, TargetDescription target, HotSpotRuntimeCallTarget linkage) { + super(runtime, replacements, target, linkage); + } + + @Snippet + private static int identityHashCode(Object object) { + printf("Calling identityHashCode\n", 0); + int result = identityHashCodeC(IDENTITY_HASH_CODE_C, thread(), object); + handlePendingException(false); + return result; + } + + public static final Descriptor IDENTITY_HASH_CODE_C = descriptorFor(IdentityHashCodeStub.class, "identityHashCodeC", false); + + @NodeIntrinsic(CRuntimeCall.class) + public static native int identityHashCodeC(@ConstantNodeParameter Descriptor identityHashCodeC, Word thread, Object object); +} diff -r 20dc10bb82d1 -r a14fef4fca7d src/cpu/x86/vm/graalRuntime_x86.cpp --- a/src/cpu/x86/vm/graalRuntime_x86.cpp Tue Apr 30 00:34:07 2013 +0200 +++ b/src/cpu/x86/vm/graalRuntime_x86.cpp Tue Apr 30 00:53:33 2013 +0200 @@ -1050,20 +1050,6 @@ break; } - case identity_hash_code_id: { - Register obj = j_rarg0; // Incoming - __ set_info("identity_hash_code", dont_gc_arguments); - __ enter(); - OopMap* map = save_live_registers(sasm, 1); - int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, identity_hash_code), obj); - oop_maps = new OopMapSet(); - oop_maps->add_gc_map(call_offset, map); - restore_live_registers_except_rax(sasm); - __ leave(); - __ ret(0); - break; - } - default: { GraalStubFrame f(sasm, "unimplemented entry", dont_gc_arguments); __ movptr(rax, (int)id); diff -r 20dc10bb82d1 -r a14fef4fca7d src/share/vm/graal/graalCompilerToVM.cpp --- a/src/share/vm/graal/graalCompilerToVM.cpp Tue Apr 30 00:34:07 2013 +0200 +++ b/src/share/vm/graal/graalCompilerToVM.cpp Tue Apr 30 00:53:33 2013 +0200 @@ -754,7 +754,6 @@ set_address("wbPreCallStub", GraalRuntime::entry_for(GraalRuntime::wb_pre_call_id)); set_address("wbPostCallStub", GraalRuntime::entry_for(GraalRuntime::wb_post_call_id)); - set_address("identityHashCodeStub", GraalRuntime::entry_for(GraalRuntime::identity_hash_code_id)); set_address("inlineCacheMissStub", SharedRuntime::get_ic_miss_stub()); set_address("handleExceptionStub", GraalRuntime::entry_for(GraalRuntime::handle_exception_nofpu_id)); set_address("handleDeoptStub", SharedRuntime::deopt_blob()->unpack()); @@ -788,6 +787,7 @@ set_address("newMultiArrayAddress", GraalRuntime::new_multi_array); set_address("registerFinalizerAddress", SharedRuntime::register_finalizer); set_address("threadIsInterruptedAddress", GraalRuntime::thread_is_interrupted); + set_address("identityHashCodeAddress", GraalRuntime::identity_hash_code); set_int("deoptReasonNone", Deoptimization::Reason_none); set_int("deoptReasonNullCheck", Deoptimization::Reason_null_check); diff -r 20dc10bb82d1 -r a14fef4fca7d src/share/vm/graal/graalRuntime.hpp --- a/src/share/vm/graal/graalRuntime.hpp Tue Apr 30 00:34:07 2013 +0200 +++ b/src/share/vm/graal/graalRuntime.hpp Tue Apr 30 00:53:33 2013 +0200 @@ -96,7 +96,6 @@ stub(log_printf) \ stub(stub_printf) \ stub(log_primitive) \ - stub(identity_hash_code) \ stub(wb_pre_call) \ stub(wb_post_call) \ last_entry(number_of_ids) @@ -143,7 +142,6 @@ static void wb_pre_call(JavaThread* thread, oopDesc* obj); static void wb_post_call(JavaThread* thread, oopDesc* obj, void* card); - static jint identity_hash_code(JavaThread* thread, oopDesc* objd); // Note: Must be kept in sync with constants in com.oracle.graal.replacements.Log enum { @@ -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 jint identity_hash_code(JavaThread* thread, oopDesc* objd); // initialization static void initialize(BufferBlob* blob);