# HG changeset patch # User Christian Wimmer # Date 1365720108 25200 # Node ID 80aee92588cd8d3d7b5132f6ada1a3121e4b46e3 # Parent 0524e6e34ad80096cc93951b6de4f3ad13170273# Parent 3b0ec709827c6fc988f3d3abd0fae27a7b855973 Merge diff -r 0524e6e34ad8 -r 80aee92588cd graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotReplacementsImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotReplacementsImpl.java Thu Apr 11 15:40:27 2013 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotReplacementsImpl.java Thu Apr 11 15:41:48 2013 -0700 @@ -28,6 +28,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.hotspot.replacements.*; +import com.oracle.graal.nodes.*; import com.oracle.graal.replacements.*; /** @@ -62,4 +63,24 @@ } return super.registerMethodSubstitution(originalMethod, substituteMethod); } + + @Override + public Class getMacroSubstitution(ResolvedJavaMethod method) { + HotSpotResolvedJavaMethod hsMethod = (HotSpotResolvedJavaMethod) method; + int intrinsicId = hsMethod.intrinsicId(); + if (intrinsicId != 0) { + if (intrinsicId == config.vmIntrinsicInvokeBasic) { + return MethodHandleInvokeBasicNode.class; + } else if (intrinsicId == config.vmIntrinsicLinkToInterface) { + return MethodHandleLinkToInterfaceNode.class; + } else if (intrinsicId == config.vmIntrinsicLinkToSpecial) { + return MethodHandleLinkToSpecialNode.class; + } else if (intrinsicId == config.vmIntrinsicLinkToStatic) { + return MethodHandleLinkToStaticNode.class; + } else if (intrinsicId == config.vmIntrinsicLinkToVirtual) { + return MethodHandleLinkToVirtualNode.class; + } + } + return super.getMacroSubstitution(method); + } } diff -r 0524e6e34ad8 -r 80aee92588cd 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 Thu Apr 11 15:40:27 2013 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java Thu Apr 11 15:41:48 2013 -0700 @@ -187,6 +187,11 @@ public int methodAccessFlagsOffset; /** + * Offset of _intrinsic_id in a metaspace Method object. + */ + public int methodIntrinsicIdOffset; + + /** * Offset of _max_locals in a metaspace Method object. */ public int methodMaxLocalsOffset; @@ -378,6 +383,12 @@ public int deoptActionMakeNotEntrant; public int deoptActionMakeNotCompilable; + public int vmIntrinsicInvokeBasic; + public int vmIntrinsicLinkToVirtual; + public int vmIntrinsicLinkToStatic; + public int vmIntrinsicLinkToSpecial; + public int vmIntrinsicLinkToInterface; + public void check() { assert codeEntryAlignment > 0; assert stackShadowPages > 0; diff -r 0524e6e34ad8 -r 80aee92588cd graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java Thu Apr 11 15:40:27 2013 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java Thu Apr 11 15:41:48 2013 -0700 @@ -362,4 +362,9 @@ } return speculationLog; } + + public int intrinsicId() { + HotSpotVMConfig config = HotSpotGraalRuntime.getInstance().getConfig(); + return unsafe.getByte(metaspaceMethod + config.methodIntrinsicIdOffset) & 0xff; + } } diff -r 0524e6e34ad8 -r 80aee92588cd graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MethodHandleInvokeBasicNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MethodHandleInvokeBasicNode.java Thu Apr 11 15:41:48 2013 -0700 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2013, 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.replacements; + +import java.lang.invoke.*; + +import com.oracle.graal.nodes.*; +import com.oracle.graal.nodes.spi.*; +import com.oracle.graal.replacements.nodes.*; + +/** + * Macro node for {@link MethodHandle}{@code .invokeBasic(Object...)}. + */ +public class MethodHandleInvokeBasicNode extends MacroNode { + + public MethodHandleInvokeBasicNode(Invoke invoke) { + super(invoke); + } + + @Override + protected StructuredGraph getSnippetGraph(LoweringTool tool) { + return super.getSnippetGraph(tool); + } +} diff -r 0524e6e34ad8 -r 80aee92588cd graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MethodHandleLinkToInterfaceNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MethodHandleLinkToInterfaceNode.java Thu Apr 11 15:41:48 2013 -0700 @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2013, 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.replacements; + +import java.lang.invoke.*; + +import com.oracle.graal.nodes.*; +import com.oracle.graal.replacements.nodes.*; + +/** + * Macro node for {@link MethodHandle}{@code .linkToInterface(Object...)}. + */ +public class MethodHandleLinkToInterfaceNode extends MacroNode { + + public MethodHandleLinkToInterfaceNode(Invoke invoke) { + super(invoke); + } +} diff -r 0524e6e34ad8 -r 80aee92588cd graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MethodHandleLinkToSpecialNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MethodHandleLinkToSpecialNode.java Thu Apr 11 15:41:48 2013 -0700 @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2013, 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.replacements; + +import java.lang.invoke.*; + +import com.oracle.graal.nodes.*; +import com.oracle.graal.replacements.nodes.*; + +/** + * Macro node for {@link MethodHandle}{@code .linkToSpecial(Object...)}. + */ +public class MethodHandleLinkToSpecialNode extends MacroNode { + + public MethodHandleLinkToSpecialNode(Invoke invoke) { + super(invoke); + } +} diff -r 0524e6e34ad8 -r 80aee92588cd graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MethodHandleLinkToStaticNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MethodHandleLinkToStaticNode.java Thu Apr 11 15:41:48 2013 -0700 @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2013, 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.replacements; + +import java.lang.invoke.*; + +import com.oracle.graal.nodes.*; +import com.oracle.graal.replacements.nodes.*; + +/** + * Macro node for {@link MethodHandle}{@code .linkToStatic(Object...)}. + */ +public class MethodHandleLinkToStaticNode extends MacroNode { + + public MethodHandleLinkToStaticNode(Invoke invoke) { + super(invoke); + } +} diff -r 0524e6e34ad8 -r 80aee92588cd graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MethodHandleLinkToVirtualNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MethodHandleLinkToVirtualNode.java Thu Apr 11 15:41:48 2013 -0700 @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2013, 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.replacements; + +import java.lang.invoke.*; + +import com.oracle.graal.nodes.*; +import com.oracle.graal.replacements.nodes.*; + +/** + * Macro node for {@link MethodHandle}{@code .linkToVirtual(Object...)}. + */ +public class MethodHandleLinkToVirtualNode extends MacroNode { + + public MethodHandleLinkToVirtualNode(Invoke invoke) { + super(invoke); + } +} diff -r 0524e6e34ad8 -r 80aee92588cd src/share/vm/graal/graalCompilerToVM.cpp --- a/src/share/vm/graal/graalCompilerToVM.cpp Thu Apr 11 15:40:27 2013 -0700 +++ b/src/share/vm/graal/graalCompilerToVM.cpp Thu Apr 11 15:41:48 2013 -0700 @@ -657,6 +657,7 @@ set_int("constMethodMaxStackOffset", in_bytes(ConstMethod::max_stack_offset())); set_int("extraStackEntries", Method::extra_stack_entries()); set_int("methodAccessFlagsOffset", in_bytes(Method::access_flags_offset())); + set_int("methodIntrinsicIdOffset", Method::intrinsic_id_offset_in_bytes()); set_int("klassHasFinalizerFlag", JVM_ACC_HAS_FINALIZER); set_int("threadExceptionOopOffset", in_bytes(JavaThread::exception_oop_offset())); set_int("threadExceptionPcOffset", in_bytes(JavaThread::exception_pc_offset())); @@ -780,6 +781,13 @@ set_int("deoptActionReinterpret", Deoptimization::Action_reinterpret); set_int("deoptActionMakeNotEntrant", Deoptimization::Action_make_not_entrant); set_int("deoptActionMakeNotCompilable", Deoptimization::Action_make_not_compilable); + + set_int("vmIntrinsicInvokeBasic", vmIntrinsics::_invokeBasic); + set_int("vmIntrinsicLinkToVirtual", vmIntrinsics::_linkToVirtual); + set_int("vmIntrinsicLinkToStatic", vmIntrinsics::_linkToStatic); + set_int("vmIntrinsicLinkToSpecial", vmIntrinsics::_linkToSpecial); + set_int("vmIntrinsicLinkToInterface", vmIntrinsics::_linkToInterface); + set_int("g1CardQueueIndexOffset", in_bytes(JavaThread::dirty_card_queue_offset() + PtrQueue::byte_offset_of_index())); set_int("g1CardQueueBufferOffset", in_bytes(JavaThread::dirty_card_queue_offset() + PtrQueue::byte_offset_of_buf())); set_int("logOfHRGrainBytes", HeapRegion::LogOfHRGrainBytes);