annotate src/cpu/x86/vm/runtime_x86_32.cpp @ 2007:5ddfcf4b079e

7003554: (tiered) assert(is_null_object() || handle() != NULL) failed: cannot embed null pointer Summary: C1 with profiling doesn't check whether the MDO has been really allocated, which can silently fail if the perm gen is full. The solution is to check if the allocation failed and bailout out of inlining or compilation. Reviewed-by: kvn, never
author iveresov
date Thu, 02 Dec 2010 17:21:12 -0800
parents f95d63e2154a
children f7d55ea6ee56
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1579
jrose
parents: 1552 1567
diff changeset
2 * Copyright (c) 1998, 2010, 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: 1368
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1368
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: 1368
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
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
27 #include "asm/assembler.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
28 #include "assembler_x86.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
29 #include "classfile/systemDictionary.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
30 #include "code/vmreg.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
31 #include "interpreter/interpreter.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
32 #include "nativeInst_x86.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
33 #include "opto/runtime.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
34 #include "runtime/interfaceSupport.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
35 #include "runtime/sharedRuntime.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
36 #include "runtime/stubRoutines.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
37 #include "runtime/vframeArray.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
38 #include "utilities/globalDefinitions.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
39 #include "vmreg_x86.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
40 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
41
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 #define __ masm->
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45 ExceptionBlob* OptoRuntime::_exception_blob;
a61af66fc99e Initial load
duke
parents:
diff changeset
46
a61af66fc99e Initial load
duke
parents:
diff changeset
47 //------------------------------generate_exception_blob---------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
48 // creates exception blob at the end
a61af66fc99e Initial load
duke
parents:
diff changeset
49 // Using exception blob, this code is jumped from a compiled method.
a61af66fc99e Initial load
duke
parents:
diff changeset
50 //
a61af66fc99e Initial load
duke
parents:
diff changeset
51 // Given an exception pc at a call we call into the runtime for the
a61af66fc99e Initial load
duke
parents:
diff changeset
52 // handler in this method. This handler might merely restore state
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // (i.e. callee save registers) unwind the frame and jump to the
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // exception handler for the nmethod if there is no Java level handler
a61af66fc99e Initial load
duke
parents:
diff changeset
55 // for the nmethod.
a61af66fc99e Initial load
duke
parents:
diff changeset
56 //
a61af66fc99e Initial load
duke
parents:
diff changeset
57 // This code is entered with a jmp.
a61af66fc99e Initial load
duke
parents:
diff changeset
58 //
a61af66fc99e Initial load
duke
parents:
diff changeset
59 // Arguments:
1135
e66fd840cb6b 6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents: 579
diff changeset
60 // rax: exception oop
0
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // rdx: exception pc
a61af66fc99e Initial load
duke
parents:
diff changeset
62 //
a61af66fc99e Initial load
duke
parents:
diff changeset
63 // Results:
1135
e66fd840cb6b 6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents: 579
diff changeset
64 // rax: exception oop
0
a61af66fc99e Initial load
duke
parents:
diff changeset
65 // rdx: exception pc in caller or ???
a61af66fc99e Initial load
duke
parents:
diff changeset
66 // destination: exception handler of caller
a61af66fc99e Initial load
duke
parents:
diff changeset
67 //
a61af66fc99e Initial load
duke
parents:
diff changeset
68 // Note: the exception pc MUST be at a call (precise debug information)
a61af66fc99e Initial load
duke
parents:
diff changeset
69 // Only register rax, rdx, rcx are not callee saved.
a61af66fc99e Initial load
duke
parents:
diff changeset
70 //
a61af66fc99e Initial load
duke
parents:
diff changeset
71
a61af66fc99e Initial load
duke
parents:
diff changeset
72 void OptoRuntime::generate_exception_blob() {
a61af66fc99e Initial load
duke
parents:
diff changeset
73
a61af66fc99e Initial load
duke
parents:
diff changeset
74 // Capture info about frame layout
a61af66fc99e Initial load
duke
parents:
diff changeset
75 enum layout {
a61af66fc99e Initial load
duke
parents:
diff changeset
76 thread_off, // last_java_sp
a61af66fc99e Initial load
duke
parents:
diff changeset
77 // The frame sender code expects that rbp will be in the "natural" place and
a61af66fc99e Initial load
duke
parents:
diff changeset
78 // will override any oopMap setting for it. We must therefore force the layout
a61af66fc99e Initial load
duke
parents:
diff changeset
79 // so that it agrees with the frame sender code.
a61af66fc99e Initial load
duke
parents:
diff changeset
80 rbp_off,
a61af66fc99e Initial load
duke
parents:
diff changeset
81 return_off, // slot for return address
a61af66fc99e Initial load
duke
parents:
diff changeset
82 framesize
a61af66fc99e Initial load
duke
parents:
diff changeset
83 };
a61af66fc99e Initial load
duke
parents:
diff changeset
84
a61af66fc99e Initial load
duke
parents:
diff changeset
85 // allocate space for the code
a61af66fc99e Initial load
duke
parents:
diff changeset
86 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // setup code generation tools
a61af66fc99e Initial load
duke
parents:
diff changeset
88 CodeBuffer buffer("exception_blob", 512, 512);
a61af66fc99e Initial load
duke
parents:
diff changeset
89 MacroAssembler* masm = new MacroAssembler(&buffer);
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91 OopMapSet *oop_maps = new OopMapSet();
a61af66fc99e Initial load
duke
parents:
diff changeset
92
a61af66fc99e Initial load
duke
parents:
diff changeset
93 address start = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
94
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
95 __ push(rdx);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
96 __ subptr(rsp, return_off * wordSize); // Prolog!
0
a61af66fc99e Initial load
duke
parents:
diff changeset
97
a61af66fc99e Initial load
duke
parents:
diff changeset
98 // rbp, location is implicitly known
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
99 __ movptr(Address(rsp,rbp_off *wordSize), rbp);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
100
a61af66fc99e Initial load
duke
parents:
diff changeset
101 // Store exception in Thread object. We cannot pass any arguments to the
a61af66fc99e Initial load
duke
parents:
diff changeset
102 // handle_exception call, since we do not want to make any assumption
a61af66fc99e Initial load
duke
parents:
diff changeset
103 // about the size of the frame where the exception happened in.
a61af66fc99e Initial load
duke
parents:
diff changeset
104 __ get_thread(rcx);
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
105 __ movptr(Address(rcx, JavaThread::exception_oop_offset()), rax);
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
106 __ movptr(Address(rcx, JavaThread::exception_pc_offset()), rdx);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
107
a61af66fc99e Initial load
duke
parents:
diff changeset
108 // This call does all the hard work. It checks if an exception handler
a61af66fc99e Initial load
duke
parents:
diff changeset
109 // exists in the method.
a61af66fc99e Initial load
duke
parents:
diff changeset
110 // If so, it returns the handler address.
a61af66fc99e Initial load
duke
parents:
diff changeset
111 // If not, it prepares for stack-unwinding, restoring the callee-save
a61af66fc99e Initial load
duke
parents:
diff changeset
112 // registers of the frame being removed.
a61af66fc99e Initial load
duke
parents:
diff changeset
113 //
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
114 __ movptr(Address(rsp, thread_off * wordSize), rcx); // Thread is first argument
0
a61af66fc99e Initial load
duke
parents:
diff changeset
115 __ set_last_Java_frame(rcx, noreg, noreg, NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
116
a61af66fc99e Initial load
duke
parents:
diff changeset
117 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, OptoRuntime::handle_exception_C)));
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 // No registers to map, rbp is known implicitly
a61af66fc99e Initial load
duke
parents:
diff changeset
120 oop_maps->add_gc_map( __ pc() - start, new OopMap( framesize, 0 ));
a61af66fc99e Initial load
duke
parents:
diff changeset
121 __ get_thread(rcx);
a61af66fc99e Initial load
duke
parents:
diff changeset
122 __ reset_last_Java_frame(rcx, false, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
123
a61af66fc99e Initial load
duke
parents:
diff changeset
124 // Restore callee-saved registers
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
125 __ movptr(rbp, Address(rsp, rbp_off * wordSize));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
126
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
127 __ addptr(rsp, return_off * wordSize); // Epilog!
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
128 __ pop(rdx); // Exception pc
0
a61af66fc99e Initial load
duke
parents:
diff changeset
129
1135
e66fd840cb6b 6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents: 579
diff changeset
130 // rax: exception handler for given <exception oop/exception pc>
0
a61af66fc99e Initial load
duke
parents:
diff changeset
131
1368
93767e6a2dfd 6941529: SharedRuntime::raw_exception_handler_for_return_address must reset thread MethodHandle flag
twisti
parents: 1135
diff changeset
132 // Restore SP from BP if the exception PC is a MethodHandle call site.
93767e6a2dfd 6941529: SharedRuntime::raw_exception_handler_for_return_address must reset thread MethodHandle flag
twisti
parents: 1135
diff changeset
133 __ cmpl(Address(rcx, JavaThread::is_method_handle_return_offset()), 0);
1567
110501f54a99 6934104: JSR 292 needs to support SPARC C2
twisti
parents: 1368
diff changeset
134 __ cmovptr(Assembler::notEqual, rsp, rbp_mh_SP_save);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
135
a61af66fc99e Initial load
duke
parents:
diff changeset
136 // We have a handler in rax, (could be deopt blob)
a61af66fc99e Initial load
duke
parents:
diff changeset
137 // rdx - throwing pc, deopt blob will need it.
a61af66fc99e Initial load
duke
parents:
diff changeset
138
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
139 __ push(rax);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
140
a61af66fc99e Initial load
duke
parents:
diff changeset
141 // Get the exception
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
142 __ movptr(rax, Address(rcx, JavaThread::exception_oop_offset()));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
143 // Get the exception pc in case we are deoptimized
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
144 __ movptr(rdx, Address(rcx, JavaThread::exception_pc_offset()));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
145 #ifdef ASSERT
512
db4caa99ef11 6787106: Hotspot 32 bit build fails on platforms having different definitions for intptr_t & int32_t
xlu
parents: 337
diff changeset
146 __ movptr(Address(rcx, JavaThread::exception_handler_pc_offset()), NULL_WORD);
db4caa99ef11 6787106: Hotspot 32 bit build fails on platforms having different definitions for intptr_t & int32_t
xlu
parents: 337
diff changeset
147 __ movptr(Address(rcx, JavaThread::exception_pc_offset()), NULL_WORD);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
148 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
149 // Clear the exception oop so GC no longer processes it as a root.
512
db4caa99ef11 6787106: Hotspot 32 bit build fails on platforms having different definitions for intptr_t & int32_t
xlu
parents: 337
diff changeset
150 __ movptr(Address(rcx, JavaThread::exception_oop_offset()), NULL_WORD);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
151
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
152 __ pop(rcx);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
153
1135
e66fd840cb6b 6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents: 579
diff changeset
154 // rax: exception oop
0
a61af66fc99e Initial load
duke
parents:
diff changeset
155 // rcx: exception handler
a61af66fc99e Initial load
duke
parents:
diff changeset
156 // rdx: exception pc
a61af66fc99e Initial load
duke
parents:
diff changeset
157 __ jmp (rcx);
a61af66fc99e Initial load
duke
parents:
diff changeset
158
a61af66fc99e Initial load
duke
parents:
diff changeset
159 // -------------
a61af66fc99e Initial load
duke
parents:
diff changeset
160 // make sure all code is generated
a61af66fc99e Initial load
duke
parents:
diff changeset
161 masm->flush();
a61af66fc99e Initial load
duke
parents:
diff changeset
162
a61af66fc99e Initial load
duke
parents:
diff changeset
163 _exception_blob = ExceptionBlob::create(&buffer, oop_maps, framesize);
a61af66fc99e Initial load
duke
parents:
diff changeset
164 }