annotate src/cpu/sparc/vm/runtime_sparc.cpp @ 21559:be896a1983c0

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