author | erikj |
Tue, 12 Sep 2017 19:03:39 +0200 | |
changeset 47216 | 71c04702a3d5 |
parent 40644 | hotspot/src/cpu/x86/vm/runtime_x86_32.cpp@39e631ed7145 |
child 49449 | ef5d5d343e2a |
permissions | -rw-r--r-- |
1 | 1 |
/* |
37248 | 2 |
* Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. |
1 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5252
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5252
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5252
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
26 |
#ifdef COMPILER2 |
|
14626
0cf4eccf130f
8003240: x86: move MacroAssembler into separate file
twisti
parents:
9976
diff
changeset
|
27 |
#include "asm/macroAssembler.hpp" |
0cf4eccf130f
8003240: x86: move MacroAssembler into separate file
twisti
parents:
9976
diff
changeset
|
28 |
#include "asm/macroAssembler.inline.hpp" |
7397 | 29 |
#include "classfile/systemDictionary.hpp" |
30 |
#include "code/vmreg.hpp" |
|
31 |
#include "interpreter/interpreter.hpp" |
|
37248 | 32 |
#include "memory/resourceArea.hpp" |
7397 | 33 |
#include "opto/runtime.hpp" |
34 |
#include "runtime/interfaceSupport.hpp" |
|
35 |
#include "runtime/sharedRuntime.hpp" |
|
36 |
#include "runtime/stubRoutines.hpp" |
|
37 |
#include "runtime/vframeArray.hpp" |
|
38 |
#include "utilities/globalDefinitions.hpp" |
|
39 |
#include "vmreg_x86.inline.hpp" |
|
40 |
#endif |
|
1 | 41 |
|
42 |
||
43 |
#define __ masm-> |
|
44 |
||
45 |
//------------------------------generate_exception_blob--------------------------- |
|
46 |
// creates exception blob at the end |
|
47 |
// Using exception blob, this code is jumped from a compiled method. |
|
48 |
// |
|
49 |
// Given an exception pc at a call we call into the runtime for the |
|
50 |
// handler in this method. This handler might merely restore state |
|
51 |
// (i.e. callee save registers) unwind the frame and jump to the |
|
52 |
// exception handler for the nmethod if there is no Java level handler |
|
53 |
// for the nmethod. |
|
54 |
// |
|
55 |
// This code is entered with a jmp. |
|
56 |
// |
|
57 |
// Arguments: |
|
4564
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
2105
diff
changeset
|
58 |
// rax: exception oop |
1 | 59 |
// rdx: exception pc |
60 |
// |
|
61 |
// Results: |
|
4564
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
2105
diff
changeset
|
62 |
// rax: exception oop |
1 | 63 |
// rdx: exception pc in caller or ??? |
64 |
// destination: exception handler of caller |
|
65 |
// |
|
66 |
// Note: the exception pc MUST be at a call (precise debug information) |
|
67 |
// Only register rax, rdx, rcx are not callee saved. |
|
68 |
// |
|
69 |
||
70 |
void OptoRuntime::generate_exception_blob() { |
|
71 |
||
72 |
// Capture info about frame layout |
|
73 |
enum layout { |
|
74 |
thread_off, // last_java_sp |
|
75 |
// The frame sender code expects that rbp will be in the "natural" place and |
|
76 |
// will override any oopMap setting for it. We must therefore force the layout |
|
77 |
// so that it agrees with the frame sender code. |
|
78 |
rbp_off, |
|
79 |
return_off, // slot for return address |
|
80 |
framesize |
|
81 |
}; |
|
82 |
||
83 |
// allocate space for the code |
|
84 |
ResourceMark rm; |
|
85 |
// setup code generation tools |
|
86 |
CodeBuffer buffer("exception_blob", 512, 512); |
|
87 |
MacroAssembler* masm = new MacroAssembler(&buffer); |
|
88 |
||
89 |
OopMapSet *oop_maps = new OopMapSet(); |
|
90 |
||
91 |
address start = __ pc(); |
|
92 |
||
1066 | 93 |
__ push(rdx); |
94 |
__ subptr(rsp, return_off * wordSize); // Prolog! |
|
1 | 95 |
|
96 |
// rbp, location is implicitly known |
|
1066 | 97 |
__ movptr(Address(rsp,rbp_off *wordSize), rbp); |
1 | 98 |
|
99 |
// Store exception in Thread object. We cannot pass any arguments to the |
|
100 |
// handle_exception call, since we do not want to make any assumption |
|
101 |
// about the size of the frame where the exception happened in. |
|
102 |
__ get_thread(rcx); |
|
1066 | 103 |
__ movptr(Address(rcx, JavaThread::exception_oop_offset()), rax); |
104 |
__ movptr(Address(rcx, JavaThread::exception_pc_offset()), rdx); |
|
1 | 105 |
|
106 |
// This call does all the hard work. It checks if an exception handler |
|
107 |
// exists in the method. |
|
108 |
// If so, it returns the handler address. |
|
109 |
// If not, it prepares for stack-unwinding, restoring the callee-save |
|
110 |
// registers of the frame being removed. |
|
111 |
// |
|
1066 | 112 |
__ movptr(Address(rsp, thread_off * wordSize), rcx); // Thread is first argument |
1 | 113 |
__ set_last_Java_frame(rcx, noreg, noreg, NULL); |
114 |
||
115 |
__ call(RuntimeAddress(CAST_FROM_FN_PTR(address, OptoRuntime::handle_exception_C))); |
|
116 |
||
117 |
// No registers to map, rbp is known implicitly |
|
118 |
oop_maps->add_gc_map( __ pc() - start, new OopMap( framesize, 0 )); |
|
119 |
__ get_thread(rcx); |
|
40644
39e631ed7145
8161598: Kitchensink fails: assert(nm->insts_contains(original_pc)) failed: original PC must be in nmethod/CompiledMethod
dlong
parents:
37248
diff
changeset
|
120 |
__ reset_last_Java_frame(rcx, false); |
1 | 121 |
|
122 |
// Restore callee-saved registers |
|
1066 | 123 |
__ movptr(rbp, Address(rsp, rbp_off * wordSize)); |
1 | 124 |
|
1066 | 125 |
__ addptr(rsp, return_off * wordSize); // Epilog! |
126 |
__ pop(rdx); // Exception pc |
|
1 | 127 |
|
4564
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
2105
diff
changeset
|
128 |
// rax: exception handler for given <exception oop/exception pc> |
1 | 129 |
|
130 |
// We have a handler in rax, (could be deopt blob) |
|
131 |
// rdx - throwing pc, deopt blob will need it. |
|
132 |
||
1066 | 133 |
__ push(rax); |
1 | 134 |
|
135 |
// Get the exception |
|
1066 | 136 |
__ movptr(rax, Address(rcx, JavaThread::exception_oop_offset())); |
1 | 137 |
// Get the exception pc in case we are deoptimized |
1066 | 138 |
__ movptr(rdx, Address(rcx, JavaThread::exception_pc_offset())); |
1 | 139 |
#ifdef ASSERT |
1888
bbf498fb4354
6787106: Hotspot 32 bit build fails on platforms having different definitions for intptr_t & int32_t
xlu
parents:
1217
diff
changeset
|
140 |
__ movptr(Address(rcx, JavaThread::exception_handler_pc_offset()), NULL_WORD); |
bbf498fb4354
6787106: Hotspot 32 bit build fails on platforms having different definitions for intptr_t & int32_t
xlu
parents:
1217
diff
changeset
|
141 |
__ movptr(Address(rcx, JavaThread::exception_pc_offset()), NULL_WORD); |
1 | 142 |
#endif |
143 |
// Clear the exception oop so GC no longer processes it as a root. |
|
1888
bbf498fb4354
6787106: Hotspot 32 bit build fails on platforms having different definitions for intptr_t & int32_t
xlu
parents:
1217
diff
changeset
|
144 |
__ movptr(Address(rcx, JavaThread::exception_oop_offset()), NULL_WORD); |
1 | 145 |
|
1066 | 146 |
__ pop(rcx); |
1 | 147 |
|
4564
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
2105
diff
changeset
|
148 |
// rax: exception oop |
1 | 149 |
// rcx: exception handler |
150 |
// rdx: exception pc |
|
151 |
__ jmp (rcx); |
|
152 |
||
153 |
// ------------- |
|
154 |
// make sure all code is generated |
|
155 |
masm->flush(); |
|
156 |
||
157 |
_exception_blob = ExceptionBlob::create(&buffer, oop_maps, framesize); |
|
158 |
} |