# HG changeset patch # User Doug Simon # Date 1367876537 -7200 # Node ID 0381c7937e7a1c8a0eccf17869c39c9d4b39969a # Parent 5f9c41cd3b1ea8cf17c47b73ec465827a5441306 replaced create_null_pointer_exception assembler stub with compiled stub (GRAAL-81) diff -r 5f9c41cd3b1e -r 0381c7937e7a 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 22:37:00 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java Mon May 06 23:42:17 2013 +0200 @@ -375,7 +375,7 @@ public long vmErrorStub; public long uncommonTrapStub; public long unwindExceptionStub; - public long createNullPointerExceptionStub; + public long createNullPointerExceptionAddress; public long createOutOfBoundsExceptionStub; public long javaTimeMillisStub; public long javaTimeNanosStub; diff -r 5f9c41cd3b1e -r 0381c7937e7a 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 22:37:00 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Mon May 06 23:42:17 2013 +0200 @@ -39,6 +39,7 @@ import static com.oracle.graal.hotspot.nodes.ThreadIsInterruptedStubCall.*; import static com.oracle.graal.hotspot.nodes.VerifyOopStubCall.*; import static com.oracle.graal.hotspot.replacements.SystemSubstitutions.*; +import static com.oracle.graal.hotspot.stubs.CreateNullPointerExceptionStub.*; import static com.oracle.graal.hotspot.stubs.ExceptionHandlerStub.*; import static com.oracle.graal.hotspot.stubs.IdentityHashCodeStub.*; import static com.oracle.graal.hotspot.stubs.MonitorEnterStub.*; @@ -293,10 +294,6 @@ /* arg2: rank */ Kind.Int, /* arg3: dims */ word)); - addRuntimeCall(CREATE_NULL_POINTER_EXCEPTION, config.createNullPointerExceptionStub, - /* temps */ null, - /* ret */ ret(Kind.Object)); - addRuntimeCall(CREATE_OUT_OF_BOUNDS_EXCEPTION, config.createOutOfBoundsExceptionStub, /* temps */ null, /* ret */ ret(Kind.Object), @@ -404,6 +401,13 @@ /* arg1: object */ Kind.Object, /* arg1: lock */ word)); + addStubCall(CREATE_NULL_POINTER_EXCEPTION, + /* ret */ ret(Kind.Object)); + + addCRuntimeCall(CREATE_NULL_POINTER_EXCEPTION_C, config.createNullPointerExceptionAddress, + /* ret */ ret(Kind.Void), + /* arg0: thread */ nativeCallingConvention(word)); + // @formatter:on } @@ -436,6 +440,8 @@ * @param args where arguments are passed to the call */ protected RuntimeCallTarget addCRuntimeCall(Descriptor descriptor, long address, AllocatableValue ret, AllocatableValue... args) { + assert descriptor.getResultType().isPrimitive() || Word.class.isAssignableFrom(descriptor.getResultType()) : "C runtime call cannot have Object return type - objects must be returned via thread local storage: " + + descriptor; return addRuntimeCall(descriptor, address, true, null, ret, args); } @@ -525,6 +531,7 @@ registerStub(new OSRMigrationEndStub(this, replacements, graalRuntime.getTarget(), runtimeCalls.get(OSR_MIGRATION_END))); registerStub(new MonitorEnterStub(this, replacements, graalRuntime.getTarget(), runtimeCalls.get(MONITORENTER))); registerStub(new MonitorExitStub(this, replacements, graalRuntime.getTarget(), runtimeCalls.get(MONITOREXIT))); + registerStub(new CreateNullPointerExceptionStub(this, replacements, graalRuntime.getTarget(), runtimeCalls.get(CREATE_NULL_POINTER_EXCEPTION))); } private void registerStub(Stub stub) { diff -r 5f9c41cd3b1e -r 0381c7937e7a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/CreateNullPointerExceptionStub.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/CreateNullPointerExceptionStub.java Mon May 06 23:42:17 2013 +0200 @@ -0,0 +1,58 @@ +/* + * 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.*; +import com.oracle.graal.api.code.RuntimeCallTarget.*; +import com.oracle.graal.graph.Node.*; +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 to create a {@link NullPointerException}. + */ +public class CreateNullPointerExceptionStub extends CRuntimeStub { + + public CreateNullPointerExceptionStub(final HotSpotRuntime runtime, Replacements replacements, TargetDescription target, HotSpotRuntimeCallTarget linkage) { + super(runtime, replacements, target, linkage); + } + + @Snippet + private static Object createNullPointerException() { + createNullPointerExceptionC(CREATE_NULL_POINTER_EXCEPTION_C, thread()); + handlePendingException(true); + return verifyObject(getAndClearObjectResult(thread())); + } + + public static final Descriptor CREATE_NULL_POINTER_EXCEPTION_C = descriptorFor(CreateNullPointerExceptionStub.class, "createNullPointerExceptionC", false); + + @NodeIntrinsic(CRuntimeCall.class) + public static native void createNullPointerExceptionC(@ConstantNodeParameter Descriptor createNullPointerExceptionC, Word thread); + +} diff -r 5f9c41cd3b1e -r 0381c7937e7a src/cpu/x86/vm/graalRuntime_x86.cpp --- a/src/cpu/x86/vm/graalRuntime_x86.cpp Mon May 06 22:37:00 2013 +0200 +++ b/src/cpu/x86/vm/graalRuntime_x86.cpp Mon May 06 23:42:17 2013 +0200 @@ -625,18 +625,6 @@ OopMapSet* oop_maps = NULL; switch (id) { - case create_null_pointer_exception_id: { - __ enter(); - oop_maps = new OopMapSet(); - OopMap* oop_map = save_live_registers(sasm, 0); - int call_offset = __ call_RT(rax, noreg, (address)create_null_exception, 0); - oop_maps->add_gc_map(call_offset, oop_map); - restore_live_registers_except_rax(sasm); - __ leave(); - __ ret(0); - break; - } - case create_out_of_bounds_exception_id: { __ enter(); oop_maps = new OopMapSet(); diff -r 5f9c41cd3b1e -r 0381c7937e7a src/share/vm/graal/graalCompilerToVM.cpp --- a/src/share/vm/graal/graalCompilerToVM.cpp Mon May 06 22:37:00 2013 +0200 +++ b/src/share/vm/graal/graalCompilerToVM.cpp Mon May 06 23:42:17 2013 +0200 @@ -763,7 +763,6 @@ set_address("inlineCacheMissStub", SharedRuntime::get_ic_miss_stub()); set_address("handleDeoptStub", SharedRuntime::deopt_blob()->unpack()); set_address("vmErrorStub", GraalRuntime::entry_for(GraalRuntime::vm_error_id)); - set_address("createNullPointerExceptionStub", GraalRuntime::entry_for(GraalRuntime::create_null_pointer_exception_id)); set_address("createOutOfBoundsExceptionStub", GraalRuntime::entry_for(GraalRuntime::create_out_of_bounds_exception_id)); set_address("javaTimeMillisStub", CAST_FROM_FN_PTR(address, os::javaTimeMillis)); set_address("javaTimeNanosStub", CAST_FROM_FN_PTR(address, os::javaTimeNanos)); @@ -791,6 +790,7 @@ set_address("osrMigrationEndAddress", SharedRuntime::OSR_migration_end); set_address("monitorenterAddress", GraalRuntime::monitorenter); set_address("monitorexitAddress", GraalRuntime::monitorexit); + set_address("createNullPointerExceptionAddress", GraalRuntime::create_null_exception); set_int("deoptReasonNone", Deoptimization::Reason_none); set_int("deoptReasonNullCheck", Deoptimization::Reason_null_check); diff -r 5f9c41cd3b1e -r 0381c7937e7a src/share/vm/graal/graalRuntime.hpp --- a/src/share/vm/graal/graalRuntime.hpp Mon May 06 22:37:00 2013 +0200 +++ b/src/share/vm/graal/graalRuntime.hpp Mon May 06 23:42:17 2013 +0200 @@ -79,7 +79,6 @@ // by Graal. #define GRAAL_STUBS(stub, last_entry) \ stub(vm_error) \ - stub(create_null_pointer_exception) \ stub(create_out_of_bounds_exception) \ stub(log_object) \ stub(log_printf) \ @@ -116,7 +115,6 @@ // runtime entry points static void unimplemented_entry(JavaThread* thread, StubID id); - static void create_null_exception(JavaThread* thread); static void create_out_of_bounds_exception(JavaThread* thread, jint index); 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); @@ -143,6 +141,7 @@ static address exception_handler_for_pc(JavaThread* thread); static void monitorenter(JavaThread* thread, oopDesc* obj, BasicLock* lock); static void monitorexit (JavaThread* thread, oopDesc* obj, BasicLock* lock); + static void create_null_exception(JavaThread* thread); // initialization static void initialize(BufferBlob* blob);