src/cpu/sparc/vm/runtime_sparc.cpp

Wed, 27 Apr 2016 01:25:04 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:25:04 +0800
changeset 0
f90c822e73f8
child 6876
710a3c8b516e
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/
changeset: 6782:28b50d07f6f8
tag: jdk8u25-b17

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@0 25 #include "precompiled.hpp"
aoqi@0 26 #ifdef COMPILER2
aoqi@0 27 #include "asm/macroAssembler.inline.hpp"
aoqi@0 28 #include "classfile/systemDictionary.hpp"
aoqi@0 29 #include "code/vmreg.hpp"
aoqi@0 30 #include "interpreter/interpreter.hpp"
aoqi@0 31 #include "nativeInst_sparc.hpp"
aoqi@0 32 #include "opto/runtime.hpp"
aoqi@0 33 #include "runtime/interfaceSupport.hpp"
aoqi@0 34 #include "runtime/sharedRuntime.hpp"
aoqi@0 35 #include "runtime/stubRoutines.hpp"
aoqi@0 36 #include "runtime/vframeArray.hpp"
aoqi@0 37 #include "utilities/globalDefinitions.hpp"
aoqi@0 38 #include "vmreg_sparc.inline.hpp"
aoqi@0 39 #endif
aoqi@0 40
aoqi@0 41
aoqi@0 42 #define __ masm->
aoqi@0 43
aoqi@0 44 //------------------------------ generate_exception_blob ---------------------------
aoqi@0 45 // creates exception blob at the end
aoqi@0 46 // Using exception blob, this code is jumped from a compiled method.
aoqi@0 47 // (see emit_exception_handler in sparc.ad file)
aoqi@0 48 //
aoqi@0 49 // Given an exception pc at a call we call into the runtime for the
aoqi@0 50 // handler in this method. This handler might merely restore state
aoqi@0 51 // (i.e. callee save registers) unwind the frame and jump to the
aoqi@0 52 // exception handler for the nmethod if there is no Java level handler
aoqi@0 53 // for the nmethod.
aoqi@0 54 //
aoqi@0 55 // This code is entered with a jmp.
aoqi@0 56 //
aoqi@0 57 // Arguments:
aoqi@0 58 // O0: exception oop
aoqi@0 59 // O1: exception pc
aoqi@0 60 //
aoqi@0 61 // Results:
aoqi@0 62 // O0: exception oop
aoqi@0 63 // O1: exception pc in caller or ???
aoqi@0 64 // destination: exception handler of caller
aoqi@0 65 //
aoqi@0 66 // Note: the exception pc MUST be at a call (precise debug information)
aoqi@0 67 //
aoqi@0 68 void OptoRuntime::generate_exception_blob() {
aoqi@0 69 // allocate space for code
aoqi@0 70 ResourceMark rm;
aoqi@0 71 int pad = VerifyThread ? 256 : 0;// Extra slop space for more verify code
aoqi@0 72
aoqi@0 73 // setup code generation tools
aoqi@0 74 // Measured 8/7/03 at 256 in 32bit debug build (no VerifyThread)
aoqi@0 75 // Measured 8/7/03 at 528 in 32bit debug build (VerifyThread)
aoqi@0 76 CodeBuffer buffer("exception_blob", 600+pad, 512);
aoqi@0 77 MacroAssembler* masm = new MacroAssembler(&buffer);
aoqi@0 78
aoqi@0 79 int framesize_in_bytes = __ total_frame_size_in_bytes(0);
aoqi@0 80 int framesize_in_words = framesize_in_bytes / wordSize;
aoqi@0 81 int framesize_in_slots = framesize_in_bytes / sizeof(jint);
aoqi@0 82
aoqi@0 83 Label L;
aoqi@0 84
aoqi@0 85 int start = __ offset();
aoqi@0 86
aoqi@0 87 __ verify_thread();
aoqi@0 88 __ st_ptr(Oexception, G2_thread, JavaThread::exception_oop_offset());
aoqi@0 89 __ st_ptr(Oissuing_pc, G2_thread, JavaThread::exception_pc_offset());
aoqi@0 90
aoqi@0 91 // This call does all the hard work. It checks if an exception catch
aoqi@0 92 // exists in the method.
aoqi@0 93 // If so, it returns the handler address.
aoqi@0 94 // If the nmethod has been deoptimized and it had a handler the handler
aoqi@0 95 // address is the deopt blob unpack_with_exception entry.
aoqi@0 96 //
aoqi@0 97 // If no handler exists it prepares for stack-unwinding, restoring the callee-save
aoqi@0 98 // registers of the frame being removed.
aoqi@0 99 //
aoqi@0 100 __ save_frame(0);
aoqi@0 101
aoqi@0 102 __ mov(G2_thread, O0);
aoqi@0 103 __ set_last_Java_frame(SP, noreg);
aoqi@0 104 __ save_thread(L7_thread_cache);
aoqi@0 105
aoqi@0 106 // This call can block at exit and nmethod can be deoptimized at that
aoqi@0 107 // point. If the nmethod had a catch point we would jump to the
aoqi@0 108 // now deoptimized catch point and fall thru the vanilla deopt
aoqi@0 109 // path and lose the exception
aoqi@0 110 // Sure would be simpler if this call didn't block!
aoqi@0 111 __ call(CAST_FROM_FN_PTR(address, OptoRuntime::handle_exception_C), relocInfo::runtime_call_type);
aoqi@0 112 __ delayed()->mov(L7_thread_cache, O0);
aoqi@0 113
aoqi@0 114 // Set an oopmap for the call site. This oopmap will only be used if we
aoqi@0 115 // are unwinding the stack. Hence, all locations will be dead.
aoqi@0 116 // Callee-saved registers will be the same as the frame above (i.e.,
aoqi@0 117 // handle_exception_stub), since they were restored when we got the
aoqi@0 118 // exception.
aoqi@0 119
aoqi@0 120 OopMapSet *oop_maps = new OopMapSet();
aoqi@0 121 oop_maps->add_gc_map( __ offset()-start, new OopMap(framesize_in_slots, 0));
aoqi@0 122
aoqi@0 123 __ bind(L);
aoqi@0 124 __ restore_thread(L7_thread_cache);
aoqi@0 125 __ reset_last_Java_frame();
aoqi@0 126
aoqi@0 127 __ mov(O0, G3_scratch); // Move handler address to temp
aoqi@0 128 __ restore();
aoqi@0 129
aoqi@0 130 // Restore SP from L7 if the exception PC is a MethodHandle call site.
aoqi@0 131 __ lduw(Address(G2_thread, JavaThread::is_method_handle_return_offset()), O7);
aoqi@0 132 __ tst(O7);
aoqi@0 133 __ movcc(Assembler::notZero, false, Assembler::icc, L7_mh_SP_save, SP);
aoqi@0 134
aoqi@0 135 // G3_scratch contains handler address
aoqi@0 136 // Since this may be the deopt blob we must set O7 to look like we returned
aoqi@0 137 // from the original pc that threw the exception
aoqi@0 138
aoqi@0 139 __ ld_ptr(G2_thread, JavaThread::exception_pc_offset(), O7);
aoqi@0 140 __ sub(O7, frame::pc_return_offset, O7);
aoqi@0 141
aoqi@0 142
aoqi@0 143 assert(Assembler::is_simm13(in_bytes(JavaThread::exception_oop_offset())), "exception offset overflows simm13, following ld instruction cannot be in delay slot");
aoqi@0 144 __ ld_ptr(G2_thread, JavaThread::exception_oop_offset(), Oexception); // O0
aoqi@0 145 #ifdef ASSERT
aoqi@0 146 __ st_ptr(G0, G2_thread, JavaThread::exception_handler_pc_offset());
aoqi@0 147 __ st_ptr(G0, G2_thread, JavaThread::exception_pc_offset());
aoqi@0 148 #endif
aoqi@0 149 __ JMP(G3_scratch, 0);
aoqi@0 150 // Clear the exception oop so GC no longer processes it as a root.
aoqi@0 151 __ delayed()->st_ptr(G0, G2_thread, JavaThread::exception_oop_offset());
aoqi@0 152
aoqi@0 153 // -------------
aoqi@0 154 // make sure all code is generated
aoqi@0 155 masm->flush();
aoqi@0 156
aoqi@0 157 _exception_blob = ExceptionBlob::create(&buffer, oop_maps, framesize_in_words);
aoqi@0 158 }

mercurial