annotate src/cpu/sparc/vm/c1_Runtime1_sparc.cpp @ 196:d1605aabd0a1 jdk7-b30

6719955: Update copyright year Summary: Update copyright year for files that have been modified in 2008 Reviewed-by: ohair, tbell
author xdono
date Wed, 02 Jul 2008 12:55:16 -0700
parents a61af66fc99e
children 37f87013dfd8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 1999-2007 Sun Microsystems, Inc. All Rights Reserved.
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 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 #include "incls/_precompiled.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
26 #include "incls/_c1_Runtime1_sparc.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28 // Implementation of StubAssembler
a61af66fc99e Initial load
duke
parents:
diff changeset
29
a61af66fc99e Initial load
duke
parents:
diff changeset
30 int StubAssembler::call_RT(Register oop_result1, Register oop_result2, address entry_point, int number_of_arguments) {
a61af66fc99e Initial load
duke
parents:
diff changeset
31 // for sparc changing the number of arguments doesn't change
a61af66fc99e Initial load
duke
parents:
diff changeset
32 // anything about the frame size so we'll always lie and claim that
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // we are only passing 1 argument.
a61af66fc99e Initial load
duke
parents:
diff changeset
34 set_num_rt_args(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
35
a61af66fc99e Initial load
duke
parents:
diff changeset
36 assert_not_delayed();
a61af66fc99e Initial load
duke
parents:
diff changeset
37 // bang stack before going to runtime
a61af66fc99e Initial load
duke
parents:
diff changeset
38 set(-os::vm_page_size() + STACK_BIAS, G3_scratch);
a61af66fc99e Initial load
duke
parents:
diff changeset
39 st(G0, SP, G3_scratch);
a61af66fc99e Initial load
duke
parents:
diff changeset
40
a61af66fc99e Initial load
duke
parents:
diff changeset
41 // debugging support
a61af66fc99e Initial load
duke
parents:
diff changeset
42 assert(number_of_arguments >= 0 , "cannot have negative number of arguments");
a61af66fc99e Initial load
duke
parents:
diff changeset
43
a61af66fc99e Initial load
duke
parents:
diff changeset
44 set_last_Java_frame(SP, noreg);
a61af66fc99e Initial load
duke
parents:
diff changeset
45 if (VerifyThread) mov(G2_thread, O0); // about to be smashed; pass early
a61af66fc99e Initial load
duke
parents:
diff changeset
46 save_thread(L7_thread_cache);
a61af66fc99e Initial load
duke
parents:
diff changeset
47 // do the call
a61af66fc99e Initial load
duke
parents:
diff changeset
48 call(entry_point, relocInfo::runtime_call_type);
a61af66fc99e Initial load
duke
parents:
diff changeset
49 if (!VerifyThread) {
a61af66fc99e Initial load
duke
parents:
diff changeset
50 delayed()->mov(G2_thread, O0); // pass thread as first argument
a61af66fc99e Initial load
duke
parents:
diff changeset
51 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
52 delayed()->nop(); // (thread already passed)
a61af66fc99e Initial load
duke
parents:
diff changeset
53 }
a61af66fc99e Initial load
duke
parents:
diff changeset
54 int call_offset = offset(); // offset of return address
a61af66fc99e Initial load
duke
parents:
diff changeset
55 restore_thread(L7_thread_cache);
a61af66fc99e Initial load
duke
parents:
diff changeset
56 reset_last_Java_frame();
a61af66fc99e Initial load
duke
parents:
diff changeset
57
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // check for pending exceptions
a61af66fc99e Initial load
duke
parents:
diff changeset
59 { Label L;
a61af66fc99e Initial load
duke
parents:
diff changeset
60 Address exception_addr(G2_thread, 0, in_bytes(Thread::pending_exception_offset()));
a61af66fc99e Initial load
duke
parents:
diff changeset
61 ld_ptr(exception_addr, Gtemp);
a61af66fc99e Initial load
duke
parents:
diff changeset
62 br_null(Gtemp, false, pt, L);
a61af66fc99e Initial load
duke
parents:
diff changeset
63 delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
64 Address vm_result_addr(G2_thread, 0, in_bytes(JavaThread::vm_result_offset()));
a61af66fc99e Initial load
duke
parents:
diff changeset
65 st_ptr(G0, vm_result_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
66 Address vm_result_addr_2(G2_thread, 0, in_bytes(JavaThread::vm_result_2_offset()));
a61af66fc99e Initial load
duke
parents:
diff changeset
67 st_ptr(G0, vm_result_addr_2);
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 if (frame_size() == no_frame_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
70 // we use O7 linkage so that forward_exception_entry has the issuing PC
a61af66fc99e Initial load
duke
parents:
diff changeset
71 call(StubRoutines::forward_exception_entry(), relocInfo::runtime_call_type);
a61af66fc99e Initial load
duke
parents:
diff changeset
72 delayed()->restore();
a61af66fc99e Initial load
duke
parents:
diff changeset
73 } else if (_stub_id == Runtime1::forward_exception_id) {
a61af66fc99e Initial load
duke
parents:
diff changeset
74 should_not_reach_here();
a61af66fc99e Initial load
duke
parents:
diff changeset
75 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
76 Address exc(G4, Runtime1::entry_for(Runtime1::forward_exception_id));
a61af66fc99e Initial load
duke
parents:
diff changeset
77 jump_to(exc, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
78 delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
79 }
a61af66fc99e Initial load
duke
parents:
diff changeset
80 bind(L);
a61af66fc99e Initial load
duke
parents:
diff changeset
81 }
a61af66fc99e Initial load
duke
parents:
diff changeset
82
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // get oop result if there is one and reset the value in the thread
a61af66fc99e Initial load
duke
parents:
diff changeset
84 if (oop_result1->is_valid()) { // get oop result if there is one and reset it in the thread
a61af66fc99e Initial load
duke
parents:
diff changeset
85 get_vm_result (oop_result1);
a61af66fc99e Initial load
duke
parents:
diff changeset
86 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // be a little paranoid and clear the result
a61af66fc99e Initial load
duke
parents:
diff changeset
88 Address vm_result_addr(G2_thread, 0, in_bytes(JavaThread::vm_result_offset()));
a61af66fc99e Initial load
duke
parents:
diff changeset
89 st_ptr(G0, vm_result_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
90 }
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 if (oop_result2->is_valid()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
93 get_vm_result_2(oop_result2);
a61af66fc99e Initial load
duke
parents:
diff changeset
94 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
95 // be a little paranoid and clear the result
a61af66fc99e Initial load
duke
parents:
diff changeset
96 Address vm_result_addr_2(G2_thread, 0, in_bytes(JavaThread::vm_result_2_offset()));
a61af66fc99e Initial load
duke
parents:
diff changeset
97 st_ptr(G0, vm_result_addr_2);
a61af66fc99e Initial load
duke
parents:
diff changeset
98 }
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 return call_offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
101 }
a61af66fc99e Initial load
duke
parents:
diff changeset
102
a61af66fc99e Initial load
duke
parents:
diff changeset
103
a61af66fc99e Initial load
duke
parents:
diff changeset
104 int StubAssembler::call_RT(Register oop_result1, Register oop_result2, address entry, Register arg1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
105 // O0 is reserved for the thread
a61af66fc99e Initial load
duke
parents:
diff changeset
106 mov(arg1, O1);
a61af66fc99e Initial load
duke
parents:
diff changeset
107 return call_RT(oop_result1, oop_result2, entry, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
108 }
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110
a61af66fc99e Initial load
duke
parents:
diff changeset
111 int StubAssembler::call_RT(Register oop_result1, Register oop_result2, address entry, Register arg1, Register arg2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
112 // O0 is reserved for the thread
a61af66fc99e Initial load
duke
parents:
diff changeset
113 mov(arg1, O1);
a61af66fc99e Initial load
duke
parents:
diff changeset
114 mov(arg2, O2); assert(arg2 != O1, "smashed argument");
a61af66fc99e Initial load
duke
parents:
diff changeset
115 return call_RT(oop_result1, oop_result2, entry, 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
116 }
a61af66fc99e Initial load
duke
parents:
diff changeset
117
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 int StubAssembler::call_RT(Register oop_result1, Register oop_result2, address entry, Register arg1, Register arg2, Register arg3) {
a61af66fc99e Initial load
duke
parents:
diff changeset
120 // O0 is reserved for the thread
a61af66fc99e Initial load
duke
parents:
diff changeset
121 mov(arg1, O1);
a61af66fc99e Initial load
duke
parents:
diff changeset
122 mov(arg2, O2); assert(arg2 != O1, "smashed argument");
a61af66fc99e Initial load
duke
parents:
diff changeset
123 mov(arg3, O3); assert(arg3 != O1 && arg3 != O2, "smashed argument");
a61af66fc99e Initial load
duke
parents:
diff changeset
124 return call_RT(oop_result1, oop_result2, entry, 3);
a61af66fc99e Initial load
duke
parents:
diff changeset
125 }
a61af66fc99e Initial load
duke
parents:
diff changeset
126
a61af66fc99e Initial load
duke
parents:
diff changeset
127
a61af66fc99e Initial load
duke
parents:
diff changeset
128 // Implementation of Runtime1
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130 #define __ sasm->
a61af66fc99e Initial load
duke
parents:
diff changeset
131
a61af66fc99e Initial load
duke
parents:
diff changeset
132 static int cpu_reg_save_offsets[FrameMap::nof_cpu_regs];
a61af66fc99e Initial load
duke
parents:
diff changeset
133 static int fpu_reg_save_offsets[FrameMap::nof_fpu_regs];
a61af66fc99e Initial load
duke
parents:
diff changeset
134 static int reg_save_size_in_words;
a61af66fc99e Initial load
duke
parents:
diff changeset
135 static int frame_size_in_bytes = -1;
a61af66fc99e Initial load
duke
parents:
diff changeset
136
a61af66fc99e Initial load
duke
parents:
diff changeset
137 static OopMap* generate_oop_map(StubAssembler* sasm, bool save_fpu_registers) {
a61af66fc99e Initial load
duke
parents:
diff changeset
138 assert(frame_size_in_bytes == __ total_frame_size_in_bytes(reg_save_size_in_words),
a61af66fc99e Initial load
duke
parents:
diff changeset
139 " mismatch in calculation");
a61af66fc99e Initial load
duke
parents:
diff changeset
140 sasm->set_frame_size(frame_size_in_bytes / BytesPerWord);
a61af66fc99e Initial load
duke
parents:
diff changeset
141 int frame_size_in_slots = frame_size_in_bytes / sizeof(jint);
a61af66fc99e Initial load
duke
parents:
diff changeset
142 OopMap* oop_map = new OopMap(frame_size_in_slots, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
143
a61af66fc99e Initial load
duke
parents:
diff changeset
144 int i;
a61af66fc99e Initial load
duke
parents:
diff changeset
145 for (i = 0; i < FrameMap::nof_cpu_regs; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
146 Register r = as_Register(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
147 if (r == G1 || r == G3 || r == G4 || r == G5) {
a61af66fc99e Initial load
duke
parents:
diff changeset
148 int sp_offset = cpu_reg_save_offsets[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
149 oop_map->set_callee_saved(VMRegImpl::stack2reg(sp_offset),
a61af66fc99e Initial load
duke
parents:
diff changeset
150 r->as_VMReg());
a61af66fc99e Initial load
duke
parents:
diff changeset
151 }
a61af66fc99e Initial load
duke
parents:
diff changeset
152 }
a61af66fc99e Initial load
duke
parents:
diff changeset
153
a61af66fc99e Initial load
duke
parents:
diff changeset
154 if (save_fpu_registers) {
a61af66fc99e Initial load
duke
parents:
diff changeset
155 for (i = 0; i < FrameMap::nof_fpu_regs; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
156 FloatRegister r = as_FloatRegister(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
157 int sp_offset = fpu_reg_save_offsets[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
158 oop_map->set_callee_saved(VMRegImpl::stack2reg(sp_offset),
a61af66fc99e Initial load
duke
parents:
diff changeset
159 r->as_VMReg());
a61af66fc99e Initial load
duke
parents:
diff changeset
160 }
a61af66fc99e Initial load
duke
parents:
diff changeset
161 }
a61af66fc99e Initial load
duke
parents:
diff changeset
162 return oop_map;
a61af66fc99e Initial load
duke
parents:
diff changeset
163 }
a61af66fc99e Initial load
duke
parents:
diff changeset
164
a61af66fc99e Initial load
duke
parents:
diff changeset
165 static OopMap* save_live_registers(StubAssembler* sasm, bool save_fpu_registers = true) {
a61af66fc99e Initial load
duke
parents:
diff changeset
166 assert(frame_size_in_bytes == __ total_frame_size_in_bytes(reg_save_size_in_words),
a61af66fc99e Initial load
duke
parents:
diff changeset
167 " mismatch in calculation");
a61af66fc99e Initial load
duke
parents:
diff changeset
168 __ save_frame_c1(frame_size_in_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
169 sasm->set_frame_size(frame_size_in_bytes / BytesPerWord);
a61af66fc99e Initial load
duke
parents:
diff changeset
170
a61af66fc99e Initial load
duke
parents:
diff changeset
171 // Record volatile registers as callee-save values in an OopMap so their save locations will be
a61af66fc99e Initial load
duke
parents:
diff changeset
172 // propagated to the caller frame's RegisterMap during StackFrameStream construction (needed for
a61af66fc99e Initial load
duke
parents:
diff changeset
173 // deoptimization; see compiledVFrame::create_stack_value). The caller's I, L and O registers
a61af66fc99e Initial load
duke
parents:
diff changeset
174 // are saved in register windows - I's and L's in the caller's frame and O's in the stub frame
a61af66fc99e Initial load
duke
parents:
diff changeset
175 // (as the stub's I's) when the runtime routine called by the stub creates its frame.
a61af66fc99e Initial load
duke
parents:
diff changeset
176 // OopMap frame sizes are in c2 stack slot sizes (sizeof(jint))
a61af66fc99e Initial load
duke
parents:
diff changeset
177
a61af66fc99e Initial load
duke
parents:
diff changeset
178 int i;
a61af66fc99e Initial load
duke
parents:
diff changeset
179 for (i = 0; i < FrameMap::nof_cpu_regs; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
180 Register r = as_Register(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
181 if (r == G1 || r == G3 || r == G4 || r == G5) {
a61af66fc99e Initial load
duke
parents:
diff changeset
182 int sp_offset = cpu_reg_save_offsets[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
183 __ st_ptr(r, SP, (sp_offset * BytesPerWord) + STACK_BIAS);
a61af66fc99e Initial load
duke
parents:
diff changeset
184 }
a61af66fc99e Initial load
duke
parents:
diff changeset
185 }
a61af66fc99e Initial load
duke
parents:
diff changeset
186
a61af66fc99e Initial load
duke
parents:
diff changeset
187 if (save_fpu_registers) {
a61af66fc99e Initial load
duke
parents:
diff changeset
188 for (i = 0; i < FrameMap::nof_fpu_regs; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
189 FloatRegister r = as_FloatRegister(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
190 int sp_offset = fpu_reg_save_offsets[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
191 __ stf(FloatRegisterImpl::S, r, SP, (sp_offset * BytesPerWord) + STACK_BIAS);
a61af66fc99e Initial load
duke
parents:
diff changeset
192 }
a61af66fc99e Initial load
duke
parents:
diff changeset
193 }
a61af66fc99e Initial load
duke
parents:
diff changeset
194
a61af66fc99e Initial load
duke
parents:
diff changeset
195 return generate_oop_map(sasm, save_fpu_registers);
a61af66fc99e Initial load
duke
parents:
diff changeset
196 }
a61af66fc99e Initial load
duke
parents:
diff changeset
197
a61af66fc99e Initial load
duke
parents:
diff changeset
198 static void restore_live_registers(StubAssembler* sasm, bool restore_fpu_registers = true) {
a61af66fc99e Initial load
duke
parents:
diff changeset
199 for (int i = 0; i < FrameMap::nof_cpu_regs; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
200 Register r = as_Register(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
201 if (r == G1 || r == G3 || r == G4 || r == G5) {
a61af66fc99e Initial load
duke
parents:
diff changeset
202 __ ld_ptr(SP, (cpu_reg_save_offsets[i] * BytesPerWord) + STACK_BIAS, r);
a61af66fc99e Initial load
duke
parents:
diff changeset
203 }
a61af66fc99e Initial load
duke
parents:
diff changeset
204 }
a61af66fc99e Initial load
duke
parents:
diff changeset
205
a61af66fc99e Initial load
duke
parents:
diff changeset
206 if (restore_fpu_registers) {
a61af66fc99e Initial load
duke
parents:
diff changeset
207 for (int i = 0; i < FrameMap::nof_fpu_regs; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
208 FloatRegister r = as_FloatRegister(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
209 __ ldf(FloatRegisterImpl::S, SP, (fpu_reg_save_offsets[i] * BytesPerWord) + STACK_BIAS, r);
a61af66fc99e Initial load
duke
parents:
diff changeset
210 }
a61af66fc99e Initial load
duke
parents:
diff changeset
211 }
a61af66fc99e Initial load
duke
parents:
diff changeset
212 }
a61af66fc99e Initial load
duke
parents:
diff changeset
213
a61af66fc99e Initial load
duke
parents:
diff changeset
214
a61af66fc99e Initial load
duke
parents:
diff changeset
215 void Runtime1::initialize_pd() {
a61af66fc99e Initial load
duke
parents:
diff changeset
216 // compute word offsets from SP at which live (non-windowed) registers are captured by stub routines
a61af66fc99e Initial load
duke
parents:
diff changeset
217 //
a61af66fc99e Initial load
duke
parents:
diff changeset
218 // A stub routine will have a frame that is at least large enough to hold
a61af66fc99e Initial load
duke
parents:
diff changeset
219 // a register window save area (obviously) and the volatile g registers
a61af66fc99e Initial load
duke
parents:
diff changeset
220 // and floating registers. A user of save_live_registers can have a frame
a61af66fc99e Initial load
duke
parents:
diff changeset
221 // that has more scratch area in it (although typically they will use L-regs).
a61af66fc99e Initial load
duke
parents:
diff changeset
222 // in that case the frame will look like this (stack growing down)
a61af66fc99e Initial load
duke
parents:
diff changeset
223 //
a61af66fc99e Initial load
duke
parents:
diff changeset
224 // FP -> | |
a61af66fc99e Initial load
duke
parents:
diff changeset
225 // | scratch mem |
a61af66fc99e Initial load
duke
parents:
diff changeset
226 // | " " |
a61af66fc99e Initial load
duke
parents:
diff changeset
227 // --------------
a61af66fc99e Initial load
duke
parents:
diff changeset
228 // | float regs |
a61af66fc99e Initial load
duke
parents:
diff changeset
229 // | " " |
a61af66fc99e Initial load
duke
parents:
diff changeset
230 // ---------------
a61af66fc99e Initial load
duke
parents:
diff changeset
231 // | G regs |
a61af66fc99e Initial load
duke
parents:
diff changeset
232 // | " " |
a61af66fc99e Initial load
duke
parents:
diff changeset
233 // ---------------
a61af66fc99e Initial load
duke
parents:
diff changeset
234 // | abi reg. |
a61af66fc99e Initial load
duke
parents:
diff changeset
235 // | window save |
a61af66fc99e Initial load
duke
parents:
diff changeset
236 // | area |
a61af66fc99e Initial load
duke
parents:
diff changeset
237 // SP -> ---------------
a61af66fc99e Initial load
duke
parents:
diff changeset
238 //
a61af66fc99e Initial load
duke
parents:
diff changeset
239 int i;
a61af66fc99e Initial load
duke
parents:
diff changeset
240 int sp_offset = round_to(frame::register_save_words, 2); // start doubleword aligned
a61af66fc99e Initial load
duke
parents:
diff changeset
241
a61af66fc99e Initial load
duke
parents:
diff changeset
242 // only G int registers are saved explicitly; others are found in register windows
a61af66fc99e Initial load
duke
parents:
diff changeset
243 for (i = 0; i < FrameMap::nof_cpu_regs; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
244 Register r = as_Register(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
245 if (r == G1 || r == G3 || r == G4 || r == G5) {
a61af66fc99e Initial load
duke
parents:
diff changeset
246 cpu_reg_save_offsets[i] = sp_offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
247 sp_offset++;
a61af66fc99e Initial load
duke
parents:
diff changeset
248 }
a61af66fc99e Initial load
duke
parents:
diff changeset
249 }
a61af66fc99e Initial load
duke
parents:
diff changeset
250
a61af66fc99e Initial load
duke
parents:
diff changeset
251 // all float registers are saved explicitly
a61af66fc99e Initial load
duke
parents:
diff changeset
252 assert(FrameMap::nof_fpu_regs == 32, "double registers not handled here");
a61af66fc99e Initial load
duke
parents:
diff changeset
253 for (i = 0; i < FrameMap::nof_fpu_regs; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
254 fpu_reg_save_offsets[i] = sp_offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
255 sp_offset++;
a61af66fc99e Initial load
duke
parents:
diff changeset
256 }
a61af66fc99e Initial load
duke
parents:
diff changeset
257 reg_save_size_in_words = sp_offset - frame::memory_parameter_word_sp_offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
258 // this should match assembler::total_frame_size_in_bytes, which
a61af66fc99e Initial load
duke
parents:
diff changeset
259 // isn't callable from this context. It's checked by an assert when
a61af66fc99e Initial load
duke
parents:
diff changeset
260 // it's used though.
a61af66fc99e Initial load
duke
parents:
diff changeset
261 frame_size_in_bytes = align_size_up(sp_offset * wordSize, 8);
a61af66fc99e Initial load
duke
parents:
diff changeset
262 }
a61af66fc99e Initial load
duke
parents:
diff changeset
263
a61af66fc99e Initial load
duke
parents:
diff changeset
264
a61af66fc99e Initial load
duke
parents:
diff changeset
265 OopMapSet* Runtime1::generate_exception_throw(StubAssembler* sasm, address target, bool has_argument) {
a61af66fc99e Initial load
duke
parents:
diff changeset
266 // make a frame and preserve the caller's caller-save registers
a61af66fc99e Initial load
duke
parents:
diff changeset
267 OopMap* oop_map = save_live_registers(sasm);
a61af66fc99e Initial load
duke
parents:
diff changeset
268 int call_offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
269 if (!has_argument) {
a61af66fc99e Initial load
duke
parents:
diff changeset
270 call_offset = __ call_RT(noreg, noreg, target);
a61af66fc99e Initial load
duke
parents:
diff changeset
271 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
272 call_offset = __ call_RT(noreg, noreg, target, G4);
a61af66fc99e Initial load
duke
parents:
diff changeset
273 }
a61af66fc99e Initial load
duke
parents:
diff changeset
274 OopMapSet* oop_maps = new OopMapSet();
a61af66fc99e Initial load
duke
parents:
diff changeset
275 oop_maps->add_gc_map(call_offset, oop_map);
a61af66fc99e Initial load
duke
parents:
diff changeset
276
a61af66fc99e Initial load
duke
parents:
diff changeset
277 __ should_not_reach_here();
a61af66fc99e Initial load
duke
parents:
diff changeset
278 return oop_maps;
a61af66fc99e Initial load
duke
parents:
diff changeset
279 }
a61af66fc99e Initial load
duke
parents:
diff changeset
280
a61af66fc99e Initial load
duke
parents:
diff changeset
281
a61af66fc99e Initial load
duke
parents:
diff changeset
282 OopMapSet* Runtime1::generate_stub_call(StubAssembler* sasm, Register result, address target,
a61af66fc99e Initial load
duke
parents:
diff changeset
283 Register arg1, Register arg2, Register arg3) {
a61af66fc99e Initial load
duke
parents:
diff changeset
284 // make a frame and preserve the caller's caller-save registers
a61af66fc99e Initial load
duke
parents:
diff changeset
285 OopMap* oop_map = save_live_registers(sasm);
a61af66fc99e Initial load
duke
parents:
diff changeset
286
a61af66fc99e Initial load
duke
parents:
diff changeset
287 int call_offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
288 if (arg1 == noreg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
289 call_offset = __ call_RT(result, noreg, target);
a61af66fc99e Initial load
duke
parents:
diff changeset
290 } else if (arg2 == noreg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
291 call_offset = __ call_RT(result, noreg, target, arg1);
a61af66fc99e Initial load
duke
parents:
diff changeset
292 } else if (arg3 == noreg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
293 call_offset = __ call_RT(result, noreg, target, arg1, arg2);
a61af66fc99e Initial load
duke
parents:
diff changeset
294 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
295 call_offset = __ call_RT(result, noreg, target, arg1, arg2, arg3);
a61af66fc99e Initial load
duke
parents:
diff changeset
296 }
a61af66fc99e Initial load
duke
parents:
diff changeset
297 OopMapSet* oop_maps = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
298
a61af66fc99e Initial load
duke
parents:
diff changeset
299 oop_maps = new OopMapSet();
a61af66fc99e Initial load
duke
parents:
diff changeset
300 oop_maps->add_gc_map(call_offset, oop_map);
a61af66fc99e Initial load
duke
parents:
diff changeset
301 restore_live_registers(sasm);
a61af66fc99e Initial load
duke
parents:
diff changeset
302
a61af66fc99e Initial load
duke
parents:
diff changeset
303 __ ret();
a61af66fc99e Initial load
duke
parents:
diff changeset
304 __ delayed()->restore();
a61af66fc99e Initial load
duke
parents:
diff changeset
305
a61af66fc99e Initial load
duke
parents:
diff changeset
306 return oop_maps;
a61af66fc99e Initial load
duke
parents:
diff changeset
307 }
a61af66fc99e Initial load
duke
parents:
diff changeset
308
a61af66fc99e Initial load
duke
parents:
diff changeset
309
a61af66fc99e Initial load
duke
parents:
diff changeset
310 OopMapSet* Runtime1::generate_patching(StubAssembler* sasm, address target) {
a61af66fc99e Initial load
duke
parents:
diff changeset
311 // make a frame and preserve the caller's caller-save registers
a61af66fc99e Initial load
duke
parents:
diff changeset
312 OopMap* oop_map = save_live_registers(sasm);
a61af66fc99e Initial load
duke
parents:
diff changeset
313
a61af66fc99e Initial load
duke
parents:
diff changeset
314 // call the runtime patching routine, returns non-zero if nmethod got deopted.
a61af66fc99e Initial load
duke
parents:
diff changeset
315 int call_offset = __ call_RT(noreg, noreg, target);
a61af66fc99e Initial load
duke
parents:
diff changeset
316 OopMapSet* oop_maps = new OopMapSet();
a61af66fc99e Initial load
duke
parents:
diff changeset
317 oop_maps->add_gc_map(call_offset, oop_map);
a61af66fc99e Initial load
duke
parents:
diff changeset
318
a61af66fc99e Initial load
duke
parents:
diff changeset
319 // re-execute the patched instruction or, if the nmethod was deoptmized, return to the
a61af66fc99e Initial load
duke
parents:
diff changeset
320 // deoptimization handler entry that will cause re-execution of the current bytecode
a61af66fc99e Initial load
duke
parents:
diff changeset
321 DeoptimizationBlob* deopt_blob = SharedRuntime::deopt_blob();
a61af66fc99e Initial load
duke
parents:
diff changeset
322 assert(deopt_blob != NULL, "deoptimization blob must have been created");
a61af66fc99e Initial load
duke
parents:
diff changeset
323
a61af66fc99e Initial load
duke
parents:
diff changeset
324 Label no_deopt;
a61af66fc99e Initial load
duke
parents:
diff changeset
325 __ tst(O0);
a61af66fc99e Initial load
duke
parents:
diff changeset
326 __ brx(Assembler::equal, false, Assembler::pt, no_deopt);
a61af66fc99e Initial load
duke
parents:
diff changeset
327 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
328
a61af66fc99e Initial load
duke
parents:
diff changeset
329 // return to the deoptimization handler entry for unpacking and rexecute
a61af66fc99e Initial load
duke
parents:
diff changeset
330 // if we simply returned the we'd deopt as if any call we patched had just
a61af66fc99e Initial load
duke
parents:
diff changeset
331 // returned.
a61af66fc99e Initial load
duke
parents:
diff changeset
332
a61af66fc99e Initial load
duke
parents:
diff changeset
333 restore_live_registers(sasm);
a61af66fc99e Initial load
duke
parents:
diff changeset
334 __ restore();
a61af66fc99e Initial load
duke
parents:
diff changeset
335 __ br(Assembler::always, false, Assembler::pt, deopt_blob->unpack_with_reexecution(), relocInfo::runtime_call_type);
a61af66fc99e Initial load
duke
parents:
diff changeset
336 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
337
a61af66fc99e Initial load
duke
parents:
diff changeset
338 __ bind(no_deopt);
a61af66fc99e Initial load
duke
parents:
diff changeset
339 restore_live_registers(sasm);
a61af66fc99e Initial load
duke
parents:
diff changeset
340 __ ret();
a61af66fc99e Initial load
duke
parents:
diff changeset
341 __ delayed()->restore();
a61af66fc99e Initial load
duke
parents:
diff changeset
342
a61af66fc99e Initial load
duke
parents:
diff changeset
343 return oop_maps;
a61af66fc99e Initial load
duke
parents:
diff changeset
344 }
a61af66fc99e Initial load
duke
parents:
diff changeset
345
a61af66fc99e Initial load
duke
parents:
diff changeset
346 OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) {
a61af66fc99e Initial load
duke
parents:
diff changeset
347
a61af66fc99e Initial load
duke
parents:
diff changeset
348 OopMapSet* oop_maps = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
349 // for better readability
a61af66fc99e Initial load
duke
parents:
diff changeset
350 const bool must_gc_arguments = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
351 const bool dont_gc_arguments = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
352
a61af66fc99e Initial load
duke
parents:
diff changeset
353 // stub code & info for the different stubs
a61af66fc99e Initial load
duke
parents:
diff changeset
354 switch (id) {
a61af66fc99e Initial load
duke
parents:
diff changeset
355 case forward_exception_id:
a61af66fc99e Initial load
duke
parents:
diff changeset
356 {
a61af66fc99e Initial load
duke
parents:
diff changeset
357 // we're handling an exception in the context of a compiled
a61af66fc99e Initial load
duke
parents:
diff changeset
358 // frame. The registers have been saved in the standard
a61af66fc99e Initial load
duke
parents:
diff changeset
359 // places. Perform an exception lookup in the caller and
a61af66fc99e Initial load
duke
parents:
diff changeset
360 // dispatch to the handler if found. Otherwise unwind and
a61af66fc99e Initial load
duke
parents:
diff changeset
361 // dispatch to the callers exception handler.
a61af66fc99e Initial load
duke
parents:
diff changeset
362
a61af66fc99e Initial load
duke
parents:
diff changeset
363 oop_maps = new OopMapSet();
a61af66fc99e Initial load
duke
parents:
diff changeset
364 OopMap* oop_map = generate_oop_map(sasm, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
365
a61af66fc99e Initial load
duke
parents:
diff changeset
366 // transfer the pending exception to the exception_oop
a61af66fc99e Initial load
duke
parents:
diff changeset
367 __ ld_ptr(G2_thread, in_bytes(JavaThread::pending_exception_offset()), Oexception);
a61af66fc99e Initial load
duke
parents:
diff changeset
368 __ ld_ptr(Oexception, 0, G0);
a61af66fc99e Initial load
duke
parents:
diff changeset
369 __ st_ptr(G0, G2_thread, in_bytes(JavaThread::pending_exception_offset()));
a61af66fc99e Initial load
duke
parents:
diff changeset
370 __ add(I7, frame::pc_return_offset, Oissuing_pc);
a61af66fc99e Initial load
duke
parents:
diff changeset
371
a61af66fc99e Initial load
duke
parents:
diff changeset
372 generate_handle_exception(sasm, oop_maps, oop_map);
a61af66fc99e Initial load
duke
parents:
diff changeset
373 __ should_not_reach_here();
a61af66fc99e Initial load
duke
parents:
diff changeset
374 }
a61af66fc99e Initial load
duke
parents:
diff changeset
375 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
376
a61af66fc99e Initial load
duke
parents:
diff changeset
377 case new_instance_id:
a61af66fc99e Initial load
duke
parents:
diff changeset
378 case fast_new_instance_id:
a61af66fc99e Initial load
duke
parents:
diff changeset
379 case fast_new_instance_init_check_id:
a61af66fc99e Initial load
duke
parents:
diff changeset
380 {
a61af66fc99e Initial load
duke
parents:
diff changeset
381 Register G5_klass = G5; // Incoming
a61af66fc99e Initial load
duke
parents:
diff changeset
382 Register O0_obj = O0; // Outgoing
a61af66fc99e Initial load
duke
parents:
diff changeset
383
a61af66fc99e Initial load
duke
parents:
diff changeset
384 if (id == new_instance_id) {
a61af66fc99e Initial load
duke
parents:
diff changeset
385 __ set_info("new_instance", dont_gc_arguments);
a61af66fc99e Initial load
duke
parents:
diff changeset
386 } else if (id == fast_new_instance_id) {
a61af66fc99e Initial load
duke
parents:
diff changeset
387 __ set_info("fast new_instance", dont_gc_arguments);
a61af66fc99e Initial load
duke
parents:
diff changeset
388 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
389 assert(id == fast_new_instance_init_check_id, "bad StubID");
a61af66fc99e Initial load
duke
parents:
diff changeset
390 __ set_info("fast new_instance init check", dont_gc_arguments);
a61af66fc99e Initial load
duke
parents:
diff changeset
391 }
a61af66fc99e Initial load
duke
parents:
diff changeset
392
a61af66fc99e Initial load
duke
parents:
diff changeset
393 if ((id == fast_new_instance_id || id == fast_new_instance_init_check_id) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
394 UseTLAB && FastTLABRefill) {
a61af66fc99e Initial load
duke
parents:
diff changeset
395 Label slow_path;
a61af66fc99e Initial load
duke
parents:
diff changeset
396 Register G1_obj_size = G1;
a61af66fc99e Initial load
duke
parents:
diff changeset
397 Register G3_t1 = G3;
a61af66fc99e Initial load
duke
parents:
diff changeset
398 Register G4_t2 = G4;
a61af66fc99e Initial load
duke
parents:
diff changeset
399 assert_different_registers(G5_klass, G1_obj_size, G3_t1, G4_t2);
a61af66fc99e Initial load
duke
parents:
diff changeset
400
a61af66fc99e Initial load
duke
parents:
diff changeset
401 // Push a frame since we may do dtrace notification for the
a61af66fc99e Initial load
duke
parents:
diff changeset
402 // allocation which requires calling out and we don't want
a61af66fc99e Initial load
duke
parents:
diff changeset
403 // to stomp the real return address.
a61af66fc99e Initial load
duke
parents:
diff changeset
404 __ save_frame(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
405
a61af66fc99e Initial load
duke
parents:
diff changeset
406 if (id == fast_new_instance_init_check_id) {
a61af66fc99e Initial load
duke
parents:
diff changeset
407 // make sure the klass is initialized
a61af66fc99e Initial load
duke
parents:
diff changeset
408 __ ld(G5_klass, instanceKlass::init_state_offset_in_bytes() + sizeof(oopDesc), G3_t1);
a61af66fc99e Initial load
duke
parents:
diff changeset
409 __ cmp(G3_t1, instanceKlass::fully_initialized);
a61af66fc99e Initial load
duke
parents:
diff changeset
410 __ br(Assembler::notEqual, false, Assembler::pn, slow_path);
a61af66fc99e Initial load
duke
parents:
diff changeset
411 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
412 }
a61af66fc99e Initial load
duke
parents:
diff changeset
413 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
414 // assert object can be fast path allocated
a61af66fc99e Initial load
duke
parents:
diff changeset
415 {
a61af66fc99e Initial load
duke
parents:
diff changeset
416 Label ok, not_ok;
a61af66fc99e Initial load
duke
parents:
diff changeset
417 __ ld(G5_klass, Klass::layout_helper_offset_in_bytes() + sizeof(oopDesc), G1_obj_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
418 __ cmp(G1_obj_size, 0); // make sure it's an instance (LH > 0)
a61af66fc99e Initial load
duke
parents:
diff changeset
419 __ br(Assembler::lessEqual, false, Assembler::pn, not_ok);
a61af66fc99e Initial load
duke
parents:
diff changeset
420 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
421 __ btst(Klass::_lh_instance_slow_path_bit, G1_obj_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
422 __ br(Assembler::zero, false, Assembler::pn, ok);
a61af66fc99e Initial load
duke
parents:
diff changeset
423 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
424 __ bind(not_ok);
a61af66fc99e Initial load
duke
parents:
diff changeset
425 __ stop("assert(can be fast path allocated)");
a61af66fc99e Initial load
duke
parents:
diff changeset
426 __ should_not_reach_here();
a61af66fc99e Initial load
duke
parents:
diff changeset
427 __ bind(ok);
a61af66fc99e Initial load
duke
parents:
diff changeset
428 }
a61af66fc99e Initial load
duke
parents:
diff changeset
429 #endif // ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
430 // if we got here then the TLAB allocation failed, so try
a61af66fc99e Initial load
duke
parents:
diff changeset
431 // refilling the TLAB or allocating directly from eden.
a61af66fc99e Initial load
duke
parents:
diff changeset
432 Label retry_tlab, try_eden;
a61af66fc99e Initial load
duke
parents:
diff changeset
433 __ tlab_refill(retry_tlab, try_eden, slow_path); // preserves G5_klass
a61af66fc99e Initial load
duke
parents:
diff changeset
434
a61af66fc99e Initial load
duke
parents:
diff changeset
435 __ bind(retry_tlab);
a61af66fc99e Initial load
duke
parents:
diff changeset
436
a61af66fc99e Initial load
duke
parents:
diff changeset
437 // get the instance size
a61af66fc99e Initial load
duke
parents:
diff changeset
438 __ ld(G5_klass, klassOopDesc::header_size() * HeapWordSize + Klass::layout_helper_offset_in_bytes(), G1_obj_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
439 __ tlab_allocate(O0_obj, G1_obj_size, 0, G3_t1, slow_path);
a61af66fc99e Initial load
duke
parents:
diff changeset
440 __ initialize_object(O0_obj, G5_klass, G1_obj_size, 0, G3_t1, G4_t2);
a61af66fc99e Initial load
duke
parents:
diff changeset
441 __ verify_oop(O0_obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
442 __ mov(O0, I0);
a61af66fc99e Initial load
duke
parents:
diff changeset
443 __ ret();
a61af66fc99e Initial load
duke
parents:
diff changeset
444 __ delayed()->restore();
a61af66fc99e Initial load
duke
parents:
diff changeset
445
a61af66fc99e Initial load
duke
parents:
diff changeset
446 __ bind(try_eden);
a61af66fc99e Initial load
duke
parents:
diff changeset
447 // get the instance size
a61af66fc99e Initial load
duke
parents:
diff changeset
448 __ ld(G5_klass, klassOopDesc::header_size() * HeapWordSize + Klass::layout_helper_offset_in_bytes(), G1_obj_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
449 __ eden_allocate(O0_obj, G1_obj_size, 0, G3_t1, G4_t2, slow_path);
a61af66fc99e Initial load
duke
parents:
diff changeset
450 __ initialize_object(O0_obj, G5_klass, G1_obj_size, 0, G3_t1, G4_t2);
a61af66fc99e Initial load
duke
parents:
diff changeset
451 __ verify_oop(O0_obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
452 __ mov(O0, I0);
a61af66fc99e Initial load
duke
parents:
diff changeset
453 __ ret();
a61af66fc99e Initial load
duke
parents:
diff changeset
454 __ delayed()->restore();
a61af66fc99e Initial load
duke
parents:
diff changeset
455
a61af66fc99e Initial load
duke
parents:
diff changeset
456 __ bind(slow_path);
a61af66fc99e Initial load
duke
parents:
diff changeset
457
a61af66fc99e Initial load
duke
parents:
diff changeset
458 // pop this frame so generate_stub_call can push it's own
a61af66fc99e Initial load
duke
parents:
diff changeset
459 __ restore();
a61af66fc99e Initial load
duke
parents:
diff changeset
460 }
a61af66fc99e Initial load
duke
parents:
diff changeset
461
a61af66fc99e Initial load
duke
parents:
diff changeset
462 oop_maps = generate_stub_call(sasm, I0, CAST_FROM_FN_PTR(address, new_instance), G5_klass);
a61af66fc99e Initial load
duke
parents:
diff changeset
463 // I0->O0: new instance
a61af66fc99e Initial load
duke
parents:
diff changeset
464 }
a61af66fc99e Initial load
duke
parents:
diff changeset
465
a61af66fc99e Initial load
duke
parents:
diff changeset
466 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
467
a61af66fc99e Initial load
duke
parents:
diff changeset
468 #ifdef TIERED
a61af66fc99e Initial load
duke
parents:
diff changeset
469 case counter_overflow_id:
a61af66fc99e Initial load
duke
parents:
diff changeset
470 // G4 contains bci
a61af66fc99e Initial load
duke
parents:
diff changeset
471 oop_maps = generate_stub_call(sasm, noreg, CAST_FROM_FN_PTR(address, counter_overflow), G4);
a61af66fc99e Initial load
duke
parents:
diff changeset
472 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
473 #endif // TIERED
a61af66fc99e Initial load
duke
parents:
diff changeset
474
a61af66fc99e Initial load
duke
parents:
diff changeset
475 case new_type_array_id:
a61af66fc99e Initial load
duke
parents:
diff changeset
476 case new_object_array_id:
a61af66fc99e Initial load
duke
parents:
diff changeset
477 {
a61af66fc99e Initial load
duke
parents:
diff changeset
478 Register G5_klass = G5; // Incoming
a61af66fc99e Initial load
duke
parents:
diff changeset
479 Register G4_length = G4; // Incoming
a61af66fc99e Initial load
duke
parents:
diff changeset
480 Register O0_obj = O0; // Outgoing
a61af66fc99e Initial load
duke
parents:
diff changeset
481
a61af66fc99e Initial load
duke
parents:
diff changeset
482 Address klass_lh(G5_klass, 0, ((klassOopDesc::header_size() * HeapWordSize)
a61af66fc99e Initial load
duke
parents:
diff changeset
483 + Klass::layout_helper_offset_in_bytes()));
a61af66fc99e Initial load
duke
parents:
diff changeset
484 assert(Klass::_lh_header_size_shift % BitsPerByte == 0, "bytewise");
a61af66fc99e Initial load
duke
parents:
diff changeset
485 assert(Klass::_lh_header_size_mask == 0xFF, "bytewise");
a61af66fc99e Initial load
duke
parents:
diff changeset
486 // Use this offset to pick out an individual byte of the layout_helper:
a61af66fc99e Initial load
duke
parents:
diff changeset
487 const int klass_lh_header_size_offset = ((BytesPerInt - 1) // 3 - 2 selects byte {0,1,0,0}
a61af66fc99e Initial load
duke
parents:
diff changeset
488 - Klass::_lh_header_size_shift / BitsPerByte);
a61af66fc99e Initial load
duke
parents:
diff changeset
489
a61af66fc99e Initial load
duke
parents:
diff changeset
490 if (id == new_type_array_id) {
a61af66fc99e Initial load
duke
parents:
diff changeset
491 __ set_info("new_type_array", dont_gc_arguments);
a61af66fc99e Initial load
duke
parents:
diff changeset
492 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
493 __ set_info("new_object_array", dont_gc_arguments);
a61af66fc99e Initial load
duke
parents:
diff changeset
494 }
a61af66fc99e Initial load
duke
parents:
diff changeset
495
a61af66fc99e Initial load
duke
parents:
diff changeset
496 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
497 // assert object type is really an array of the proper kind
a61af66fc99e Initial load
duke
parents:
diff changeset
498 {
a61af66fc99e Initial load
duke
parents:
diff changeset
499 Label ok;
a61af66fc99e Initial load
duke
parents:
diff changeset
500 Register G3_t1 = G3;
a61af66fc99e Initial load
duke
parents:
diff changeset
501 __ ld(klass_lh, G3_t1);
a61af66fc99e Initial load
duke
parents:
diff changeset
502 __ sra(G3_t1, Klass::_lh_array_tag_shift, G3_t1);
a61af66fc99e Initial load
duke
parents:
diff changeset
503 int tag = ((id == new_type_array_id)
a61af66fc99e Initial load
duke
parents:
diff changeset
504 ? Klass::_lh_array_tag_type_value
a61af66fc99e Initial load
duke
parents:
diff changeset
505 : Klass::_lh_array_tag_obj_value);
a61af66fc99e Initial load
duke
parents:
diff changeset
506 __ cmp(G3_t1, tag);
a61af66fc99e Initial load
duke
parents:
diff changeset
507 __ brx(Assembler::equal, false, Assembler::pt, ok);
a61af66fc99e Initial load
duke
parents:
diff changeset
508 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
509 __ stop("assert(is an array klass)");
a61af66fc99e Initial load
duke
parents:
diff changeset
510 __ should_not_reach_here();
a61af66fc99e Initial load
duke
parents:
diff changeset
511 __ bind(ok);
a61af66fc99e Initial load
duke
parents:
diff changeset
512 }
a61af66fc99e Initial load
duke
parents:
diff changeset
513 #endif // ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
514
a61af66fc99e Initial load
duke
parents:
diff changeset
515 if (UseTLAB && FastTLABRefill) {
a61af66fc99e Initial load
duke
parents:
diff changeset
516 Label slow_path;
a61af66fc99e Initial load
duke
parents:
diff changeset
517 Register G1_arr_size = G1;
a61af66fc99e Initial load
duke
parents:
diff changeset
518 Register G3_t1 = G3;
a61af66fc99e Initial load
duke
parents:
diff changeset
519 Register O1_t2 = O1;
a61af66fc99e Initial load
duke
parents:
diff changeset
520 assert_different_registers(G5_klass, G4_length, G1_arr_size, G3_t1, O1_t2);
a61af66fc99e Initial load
duke
parents:
diff changeset
521
a61af66fc99e Initial load
duke
parents:
diff changeset
522 // check that array length is small enough for fast path
a61af66fc99e Initial load
duke
parents:
diff changeset
523 __ set(C1_MacroAssembler::max_array_allocation_length, G3_t1);
a61af66fc99e Initial load
duke
parents:
diff changeset
524 __ cmp(G4_length, G3_t1);
a61af66fc99e Initial load
duke
parents:
diff changeset
525 __ br(Assembler::greaterUnsigned, false, Assembler::pn, slow_path);
a61af66fc99e Initial load
duke
parents:
diff changeset
526 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
527
a61af66fc99e Initial load
duke
parents:
diff changeset
528 // if we got here then the TLAB allocation failed, so try
a61af66fc99e Initial load
duke
parents:
diff changeset
529 // refilling the TLAB or allocating directly from eden.
a61af66fc99e Initial load
duke
parents:
diff changeset
530 Label retry_tlab, try_eden;
a61af66fc99e Initial load
duke
parents:
diff changeset
531 __ tlab_refill(retry_tlab, try_eden, slow_path); // preserves G4_length and G5_klass
a61af66fc99e Initial load
duke
parents:
diff changeset
532
a61af66fc99e Initial load
duke
parents:
diff changeset
533 __ bind(retry_tlab);
a61af66fc99e Initial load
duke
parents:
diff changeset
534
a61af66fc99e Initial load
duke
parents:
diff changeset
535 // get the allocation size: (length << (layout_helper & 0x1F)) + header_size
a61af66fc99e Initial load
duke
parents:
diff changeset
536 __ ld(klass_lh, G3_t1);
a61af66fc99e Initial load
duke
parents:
diff changeset
537 __ sll(G4_length, G3_t1, G1_arr_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
538 __ srl(G3_t1, Klass::_lh_header_size_shift, G3_t1);
a61af66fc99e Initial load
duke
parents:
diff changeset
539 __ and3(G3_t1, Klass::_lh_header_size_mask, G3_t1);
a61af66fc99e Initial load
duke
parents:
diff changeset
540 __ add(G1_arr_size, G3_t1, G1_arr_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
541 __ add(G1_arr_size, MinObjAlignmentInBytesMask, G1_arr_size); // align up
a61af66fc99e Initial load
duke
parents:
diff changeset
542 __ and3(G1_arr_size, ~MinObjAlignmentInBytesMask, G1_arr_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
543
a61af66fc99e Initial load
duke
parents:
diff changeset
544 __ tlab_allocate(O0_obj, G1_arr_size, 0, G3_t1, slow_path); // preserves G1_arr_size
a61af66fc99e Initial load
duke
parents:
diff changeset
545
a61af66fc99e Initial load
duke
parents:
diff changeset
546 __ initialize_header(O0_obj, G5_klass, G4_length, G3_t1, O1_t2);
a61af66fc99e Initial load
duke
parents:
diff changeset
547 __ ldub(klass_lh, G3_t1, klass_lh_header_size_offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
548 __ sub(G1_arr_size, G3_t1, O1_t2); // body length
a61af66fc99e Initial load
duke
parents:
diff changeset
549 __ add(O0_obj, G3_t1, G3_t1); // body start
a61af66fc99e Initial load
duke
parents:
diff changeset
550 __ initialize_body(G3_t1, O1_t2);
a61af66fc99e Initial load
duke
parents:
diff changeset
551 __ verify_oop(O0_obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
552 __ retl();
a61af66fc99e Initial load
duke
parents:
diff changeset
553 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
554
a61af66fc99e Initial load
duke
parents:
diff changeset
555 __ bind(try_eden);
a61af66fc99e Initial load
duke
parents:
diff changeset
556 // get the allocation size: (length << (layout_helper & 0x1F)) + header_size
a61af66fc99e Initial load
duke
parents:
diff changeset
557 __ ld(klass_lh, G3_t1);
a61af66fc99e Initial load
duke
parents:
diff changeset
558 __ sll(G4_length, G3_t1, G1_arr_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
559 __ srl(G3_t1, Klass::_lh_header_size_shift, G3_t1);
a61af66fc99e Initial load
duke
parents:
diff changeset
560 __ and3(G3_t1, Klass::_lh_header_size_mask, G3_t1);
a61af66fc99e Initial load
duke
parents:
diff changeset
561 __ add(G1_arr_size, G3_t1, G1_arr_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
562 __ add(G1_arr_size, MinObjAlignmentInBytesMask, G1_arr_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
563 __ and3(G1_arr_size, ~MinObjAlignmentInBytesMask, G1_arr_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
564
a61af66fc99e Initial load
duke
parents:
diff changeset
565 __ eden_allocate(O0_obj, G1_arr_size, 0, G3_t1, O1_t2, slow_path); // preserves G1_arr_size
a61af66fc99e Initial load
duke
parents:
diff changeset
566
a61af66fc99e Initial load
duke
parents:
diff changeset
567 __ initialize_header(O0_obj, G5_klass, G4_length, G3_t1, O1_t2);
a61af66fc99e Initial load
duke
parents:
diff changeset
568 __ ldub(klass_lh, G3_t1, klass_lh_header_size_offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
569 __ sub(G1_arr_size, G3_t1, O1_t2); // body length
a61af66fc99e Initial load
duke
parents:
diff changeset
570 __ add(O0_obj, G3_t1, G3_t1); // body start
a61af66fc99e Initial load
duke
parents:
diff changeset
571 __ initialize_body(G3_t1, O1_t2);
a61af66fc99e Initial load
duke
parents:
diff changeset
572 __ verify_oop(O0_obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
573 __ retl();
a61af66fc99e Initial load
duke
parents:
diff changeset
574 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
575
a61af66fc99e Initial load
duke
parents:
diff changeset
576 __ bind(slow_path);
a61af66fc99e Initial load
duke
parents:
diff changeset
577 }
a61af66fc99e Initial load
duke
parents:
diff changeset
578
a61af66fc99e Initial load
duke
parents:
diff changeset
579 if (id == new_type_array_id) {
a61af66fc99e Initial load
duke
parents:
diff changeset
580 oop_maps = generate_stub_call(sasm, I0, CAST_FROM_FN_PTR(address, new_type_array), G5_klass, G4_length);
a61af66fc99e Initial load
duke
parents:
diff changeset
581 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
582 oop_maps = generate_stub_call(sasm, I0, CAST_FROM_FN_PTR(address, new_object_array), G5_klass, G4_length);
a61af66fc99e Initial load
duke
parents:
diff changeset
583 }
a61af66fc99e Initial load
duke
parents:
diff changeset
584 // I0 -> O0: new array
a61af66fc99e Initial load
duke
parents:
diff changeset
585 }
a61af66fc99e Initial load
duke
parents:
diff changeset
586 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
587
a61af66fc99e Initial load
duke
parents:
diff changeset
588 case new_multi_array_id:
a61af66fc99e Initial load
duke
parents:
diff changeset
589 { // O0: klass
a61af66fc99e Initial load
duke
parents:
diff changeset
590 // O1: rank
a61af66fc99e Initial load
duke
parents:
diff changeset
591 // O2: address of 1st dimension
a61af66fc99e Initial load
duke
parents:
diff changeset
592 __ set_info("new_multi_array", dont_gc_arguments);
a61af66fc99e Initial load
duke
parents:
diff changeset
593 oop_maps = generate_stub_call(sasm, I0, CAST_FROM_FN_PTR(address, new_multi_array), I0, I1, I2);
a61af66fc99e Initial load
duke
parents:
diff changeset
594 // I0 -> O0: new multi array
a61af66fc99e Initial load
duke
parents:
diff changeset
595 }
a61af66fc99e Initial load
duke
parents:
diff changeset
596 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
597
a61af66fc99e Initial load
duke
parents:
diff changeset
598 case register_finalizer_id:
a61af66fc99e Initial load
duke
parents:
diff changeset
599 {
a61af66fc99e Initial load
duke
parents:
diff changeset
600 __ set_info("register_finalizer", dont_gc_arguments);
a61af66fc99e Initial load
duke
parents:
diff changeset
601
a61af66fc99e Initial load
duke
parents:
diff changeset
602 // load the klass and check the has finalizer flag
a61af66fc99e Initial load
duke
parents:
diff changeset
603 Label register_finalizer;
a61af66fc99e Initial load
duke
parents:
diff changeset
604 Register t = O1;
a61af66fc99e Initial load
duke
parents:
diff changeset
605 __ ld_ptr(O0, oopDesc::klass_offset_in_bytes(), t);
a61af66fc99e Initial load
duke
parents:
diff changeset
606 __ ld(t, Klass::access_flags_offset_in_bytes() + sizeof(oopDesc), t);
a61af66fc99e Initial load
duke
parents:
diff changeset
607 __ set(JVM_ACC_HAS_FINALIZER, G3);
a61af66fc99e Initial load
duke
parents:
diff changeset
608 __ andcc(G3, t, G0);
a61af66fc99e Initial load
duke
parents:
diff changeset
609 __ br(Assembler::notZero, false, Assembler::pt, register_finalizer);
a61af66fc99e Initial load
duke
parents:
diff changeset
610 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
611
a61af66fc99e Initial load
duke
parents:
diff changeset
612 // do a leaf return
a61af66fc99e Initial load
duke
parents:
diff changeset
613 __ retl();
a61af66fc99e Initial load
duke
parents:
diff changeset
614 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
615
a61af66fc99e Initial load
duke
parents:
diff changeset
616 __ bind(register_finalizer);
a61af66fc99e Initial load
duke
parents:
diff changeset
617 OopMap* oop_map = save_live_registers(sasm);
a61af66fc99e Initial load
duke
parents:
diff changeset
618 int call_offset = __ call_RT(noreg, noreg,
a61af66fc99e Initial load
duke
parents:
diff changeset
619 CAST_FROM_FN_PTR(address, SharedRuntime::register_finalizer), I0);
a61af66fc99e Initial load
duke
parents:
diff changeset
620 oop_maps = new OopMapSet();
a61af66fc99e Initial load
duke
parents:
diff changeset
621 oop_maps->add_gc_map(call_offset, oop_map);
a61af66fc99e Initial load
duke
parents:
diff changeset
622
a61af66fc99e Initial load
duke
parents:
diff changeset
623 // Now restore all the live registers
a61af66fc99e Initial load
duke
parents:
diff changeset
624 restore_live_registers(sasm);
a61af66fc99e Initial load
duke
parents:
diff changeset
625
a61af66fc99e Initial load
duke
parents:
diff changeset
626 __ ret();
a61af66fc99e Initial load
duke
parents:
diff changeset
627 __ delayed()->restore();
a61af66fc99e Initial load
duke
parents:
diff changeset
628 }
a61af66fc99e Initial load
duke
parents:
diff changeset
629 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
630
a61af66fc99e Initial load
duke
parents:
diff changeset
631 case throw_range_check_failed_id:
a61af66fc99e Initial load
duke
parents:
diff changeset
632 { __ set_info("range_check_failed", dont_gc_arguments); // arguments will be discarded
a61af66fc99e Initial load
duke
parents:
diff changeset
633 // G4: index
a61af66fc99e Initial load
duke
parents:
diff changeset
634 oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_range_check_exception), true);
a61af66fc99e Initial load
duke
parents:
diff changeset
635 }
a61af66fc99e Initial load
duke
parents:
diff changeset
636 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
637
a61af66fc99e Initial load
duke
parents:
diff changeset
638 case throw_index_exception_id:
a61af66fc99e Initial load
duke
parents:
diff changeset
639 { __ set_info("index_range_check_failed", dont_gc_arguments); // arguments will be discarded
a61af66fc99e Initial load
duke
parents:
diff changeset
640 // G4: index
a61af66fc99e Initial load
duke
parents:
diff changeset
641 oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_index_exception), true);
a61af66fc99e Initial load
duke
parents:
diff changeset
642 }
a61af66fc99e Initial load
duke
parents:
diff changeset
643 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
644
a61af66fc99e Initial load
duke
parents:
diff changeset
645 case throw_div0_exception_id:
a61af66fc99e Initial load
duke
parents:
diff changeset
646 { __ set_info("throw_div0_exception", dont_gc_arguments);
a61af66fc99e Initial load
duke
parents:
diff changeset
647 oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_div0_exception), false);
a61af66fc99e Initial load
duke
parents:
diff changeset
648 }
a61af66fc99e Initial load
duke
parents:
diff changeset
649 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
650
a61af66fc99e Initial load
duke
parents:
diff changeset
651 case throw_null_pointer_exception_id:
a61af66fc99e Initial load
duke
parents:
diff changeset
652 { __ set_info("throw_null_pointer_exception", dont_gc_arguments);
a61af66fc99e Initial load
duke
parents:
diff changeset
653 oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_null_pointer_exception), false);
a61af66fc99e Initial load
duke
parents:
diff changeset
654 }
a61af66fc99e Initial load
duke
parents:
diff changeset
655 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
656
a61af66fc99e Initial load
duke
parents:
diff changeset
657 case handle_exception_id:
a61af66fc99e Initial load
duke
parents:
diff changeset
658 {
a61af66fc99e Initial load
duke
parents:
diff changeset
659 __ set_info("handle_exception", dont_gc_arguments);
a61af66fc99e Initial load
duke
parents:
diff changeset
660 // make a frame and preserve the caller's caller-save registers
a61af66fc99e Initial load
duke
parents:
diff changeset
661
a61af66fc99e Initial load
duke
parents:
diff changeset
662 oop_maps = new OopMapSet();
a61af66fc99e Initial load
duke
parents:
diff changeset
663 OopMap* oop_map = save_live_registers(sasm);
a61af66fc99e Initial load
duke
parents:
diff changeset
664 __ mov(Oexception->after_save(), Oexception);
a61af66fc99e Initial load
duke
parents:
diff changeset
665 __ mov(Oissuing_pc->after_save(), Oissuing_pc);
a61af66fc99e Initial load
duke
parents:
diff changeset
666 generate_handle_exception(sasm, oop_maps, oop_map);
a61af66fc99e Initial load
duke
parents:
diff changeset
667 }
a61af66fc99e Initial load
duke
parents:
diff changeset
668 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
669
a61af66fc99e Initial load
duke
parents:
diff changeset
670 case unwind_exception_id:
a61af66fc99e Initial load
duke
parents:
diff changeset
671 {
a61af66fc99e Initial load
duke
parents:
diff changeset
672 // O0: exception
a61af66fc99e Initial load
duke
parents:
diff changeset
673 // I7: address of call to this method
a61af66fc99e Initial load
duke
parents:
diff changeset
674
a61af66fc99e Initial load
duke
parents:
diff changeset
675 __ set_info("unwind_exception", dont_gc_arguments);
a61af66fc99e Initial load
duke
parents:
diff changeset
676 __ mov(Oexception, Oexception->after_save());
a61af66fc99e Initial load
duke
parents:
diff changeset
677 __ add(I7, frame::pc_return_offset, Oissuing_pc->after_save());
a61af66fc99e Initial load
duke
parents:
diff changeset
678
a61af66fc99e Initial load
duke
parents:
diff changeset
679 __ call_VM_leaf(L7_thread_cache, CAST_FROM_FN_PTR(address, SharedRuntime::exception_handler_for_return_address),
a61af66fc99e Initial load
duke
parents:
diff changeset
680 Oissuing_pc->after_save());
a61af66fc99e Initial load
duke
parents:
diff changeset
681 __ verify_not_null_oop(Oexception->after_save());
a61af66fc99e Initial load
duke
parents:
diff changeset
682 __ jmp(O0, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
683 __ delayed()->restore();
a61af66fc99e Initial load
duke
parents:
diff changeset
684 }
a61af66fc99e Initial load
duke
parents:
diff changeset
685 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
686
a61af66fc99e Initial load
duke
parents:
diff changeset
687 case throw_array_store_exception_id:
a61af66fc99e Initial load
duke
parents:
diff changeset
688 {
a61af66fc99e Initial load
duke
parents:
diff changeset
689 __ set_info("throw_array_store_exception", dont_gc_arguments);
a61af66fc99e Initial load
duke
parents:
diff changeset
690 oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_array_store_exception), false);
a61af66fc99e Initial load
duke
parents:
diff changeset
691 }
a61af66fc99e Initial load
duke
parents:
diff changeset
692 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
693
a61af66fc99e Initial load
duke
parents:
diff changeset
694 case throw_class_cast_exception_id:
a61af66fc99e Initial load
duke
parents:
diff changeset
695 {
a61af66fc99e Initial load
duke
parents:
diff changeset
696 // G4: object
a61af66fc99e Initial load
duke
parents:
diff changeset
697 __ set_info("throw_class_cast_exception", dont_gc_arguments);
a61af66fc99e Initial load
duke
parents:
diff changeset
698 oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_class_cast_exception), true);
a61af66fc99e Initial load
duke
parents:
diff changeset
699 }
a61af66fc99e Initial load
duke
parents:
diff changeset
700 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
701
a61af66fc99e Initial load
duke
parents:
diff changeset
702 case throw_incompatible_class_change_error_id:
a61af66fc99e Initial load
duke
parents:
diff changeset
703 {
a61af66fc99e Initial load
duke
parents:
diff changeset
704 __ set_info("throw_incompatible_class_cast_exception", dont_gc_arguments);
a61af66fc99e Initial load
duke
parents:
diff changeset
705 oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_incompatible_class_change_error), false);
a61af66fc99e Initial load
duke
parents:
diff changeset
706 }
a61af66fc99e Initial load
duke
parents:
diff changeset
707 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
708
a61af66fc99e Initial load
duke
parents:
diff changeset
709 case slow_subtype_check_id:
a61af66fc99e Initial load
duke
parents:
diff changeset
710 { // Support for uint StubRoutine::partial_subtype_check( Klass sub, Klass super );
a61af66fc99e Initial load
duke
parents:
diff changeset
711 // Arguments :
a61af66fc99e Initial load
duke
parents:
diff changeset
712 //
a61af66fc99e Initial load
duke
parents:
diff changeset
713 // ret : G3
a61af66fc99e Initial load
duke
parents:
diff changeset
714 // sub : G3, argument, destroyed
a61af66fc99e Initial load
duke
parents:
diff changeset
715 // super: G1, argument, not changed
a61af66fc99e Initial load
duke
parents:
diff changeset
716 // raddr: O7, blown by call
a61af66fc99e Initial load
duke
parents:
diff changeset
717 Label loop, miss;
a61af66fc99e Initial load
duke
parents:
diff changeset
718
a61af66fc99e Initial load
duke
parents:
diff changeset
719 __ save_frame(0); // Blow no registers!
a61af66fc99e Initial load
duke
parents:
diff changeset
720
a61af66fc99e Initial load
duke
parents:
diff changeset
721 __ ld_ptr( G3, sizeof(oopDesc) + Klass::secondary_supers_offset_in_bytes(), L3 );
a61af66fc99e Initial load
duke
parents:
diff changeset
722 __ lduw(L3,arrayOopDesc::length_offset_in_bytes(),L0); // length in l0
a61af66fc99e Initial load
duke
parents:
diff changeset
723 __ add(L3,arrayOopDesc::base_offset_in_bytes(T_OBJECT),L1); // ptr into array
a61af66fc99e Initial load
duke
parents:
diff changeset
724 __ clr(L4); // Index
a61af66fc99e Initial load
duke
parents:
diff changeset
725 // Load a little early; will load 1 off the end of the array.
a61af66fc99e Initial load
duke
parents:
diff changeset
726 // Ok for now; revisit if we have other uses of this routine.
a61af66fc99e Initial load
duke
parents:
diff changeset
727 __ ld_ptr(L1,0,L2); // Will load a little early
a61af66fc99e Initial load
duke
parents:
diff changeset
728
a61af66fc99e Initial load
duke
parents:
diff changeset
729 // The scan loop
a61af66fc99e Initial load
duke
parents:
diff changeset
730 __ bind(loop);
a61af66fc99e Initial load
duke
parents:
diff changeset
731 __ add(L1,wordSize,L1); // Bump by OOP size
a61af66fc99e Initial load
duke
parents:
diff changeset
732 __ cmp(L4,L0);
a61af66fc99e Initial load
duke
parents:
diff changeset
733 __ br(Assembler::equal,false,Assembler::pn,miss);
a61af66fc99e Initial load
duke
parents:
diff changeset
734 __ delayed()->inc(L4); // Bump index
a61af66fc99e Initial load
duke
parents:
diff changeset
735 __ subcc(L2,G1,L3); // Check for match; zero in L3 for a hit
a61af66fc99e Initial load
duke
parents:
diff changeset
736 __ brx( Assembler::notEqual, false, Assembler::pt, loop );
a61af66fc99e Initial load
duke
parents:
diff changeset
737 __ delayed()->ld_ptr(L1,0,L2); // Will load a little early
a61af66fc99e Initial load
duke
parents:
diff changeset
738
a61af66fc99e Initial load
duke
parents:
diff changeset
739 // Got a hit; report success; set cache
a61af66fc99e Initial load
duke
parents:
diff changeset
740 __ st_ptr( G1, G3, sizeof(oopDesc) + Klass::secondary_super_cache_offset_in_bytes() );
a61af66fc99e Initial load
duke
parents:
diff changeset
741
a61af66fc99e Initial load
duke
parents:
diff changeset
742 __ mov(1, G3);
a61af66fc99e Initial load
duke
parents:
diff changeset
743 __ ret(); // Result in G5 is ok; flags set
a61af66fc99e Initial load
duke
parents:
diff changeset
744 __ delayed()->restore(); // free copy or add can go here
a61af66fc99e Initial load
duke
parents:
diff changeset
745
a61af66fc99e Initial load
duke
parents:
diff changeset
746 __ bind(miss);
a61af66fc99e Initial load
duke
parents:
diff changeset
747 __ mov(0, G3);
a61af66fc99e Initial load
duke
parents:
diff changeset
748 __ ret(); // Result in G5 is ok; flags set
a61af66fc99e Initial load
duke
parents:
diff changeset
749 __ delayed()->restore(); // free copy or add can go here
a61af66fc99e Initial load
duke
parents:
diff changeset
750 }
a61af66fc99e Initial load
duke
parents:
diff changeset
751
a61af66fc99e Initial load
duke
parents:
diff changeset
752 case monitorenter_nofpu_id:
a61af66fc99e Initial load
duke
parents:
diff changeset
753 case monitorenter_id:
a61af66fc99e Initial load
duke
parents:
diff changeset
754 { // G4: object
a61af66fc99e Initial load
duke
parents:
diff changeset
755 // G5: lock address
a61af66fc99e Initial load
duke
parents:
diff changeset
756 __ set_info("monitorenter", dont_gc_arguments);
a61af66fc99e Initial load
duke
parents:
diff changeset
757
a61af66fc99e Initial load
duke
parents:
diff changeset
758 int save_fpu_registers = (id == monitorenter_id);
a61af66fc99e Initial load
duke
parents:
diff changeset
759 // make a frame and preserve the caller's caller-save registers
a61af66fc99e Initial load
duke
parents:
diff changeset
760 OopMap* oop_map = save_live_registers(sasm, save_fpu_registers);
a61af66fc99e Initial load
duke
parents:
diff changeset
761
a61af66fc99e Initial load
duke
parents:
diff changeset
762 int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, monitorenter), G4, G5);
a61af66fc99e Initial load
duke
parents:
diff changeset
763
a61af66fc99e Initial load
duke
parents:
diff changeset
764 oop_maps = new OopMapSet();
a61af66fc99e Initial load
duke
parents:
diff changeset
765 oop_maps->add_gc_map(call_offset, oop_map);
a61af66fc99e Initial load
duke
parents:
diff changeset
766 restore_live_registers(sasm, save_fpu_registers);
a61af66fc99e Initial load
duke
parents:
diff changeset
767
a61af66fc99e Initial load
duke
parents:
diff changeset
768 __ ret();
a61af66fc99e Initial load
duke
parents:
diff changeset
769 __ delayed()->restore();
a61af66fc99e Initial load
duke
parents:
diff changeset
770 }
a61af66fc99e Initial load
duke
parents:
diff changeset
771 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
772
a61af66fc99e Initial load
duke
parents:
diff changeset
773 case monitorexit_nofpu_id:
a61af66fc99e Initial load
duke
parents:
diff changeset
774 case monitorexit_id:
a61af66fc99e Initial load
duke
parents:
diff changeset
775 { // G4: lock address
a61af66fc99e Initial load
duke
parents:
diff changeset
776 // note: really a leaf routine but must setup last java sp
a61af66fc99e Initial load
duke
parents:
diff changeset
777 // => use call_RT for now (speed can be improved by
a61af66fc99e Initial load
duke
parents:
diff changeset
778 // doing last java sp setup manually)
a61af66fc99e Initial load
duke
parents:
diff changeset
779 __ set_info("monitorexit", dont_gc_arguments);
a61af66fc99e Initial load
duke
parents:
diff changeset
780
a61af66fc99e Initial load
duke
parents:
diff changeset
781 int save_fpu_registers = (id == monitorexit_id);
a61af66fc99e Initial load
duke
parents:
diff changeset
782 // make a frame and preserve the caller's caller-save registers
a61af66fc99e Initial load
duke
parents:
diff changeset
783 OopMap* oop_map = save_live_registers(sasm, save_fpu_registers);
a61af66fc99e Initial load
duke
parents:
diff changeset
784
a61af66fc99e Initial load
duke
parents:
diff changeset
785 int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, monitorexit), G4);
a61af66fc99e Initial load
duke
parents:
diff changeset
786
a61af66fc99e Initial load
duke
parents:
diff changeset
787 oop_maps = new OopMapSet();
a61af66fc99e Initial load
duke
parents:
diff changeset
788 oop_maps->add_gc_map(call_offset, oop_map);
a61af66fc99e Initial load
duke
parents:
diff changeset
789 restore_live_registers(sasm, save_fpu_registers);
a61af66fc99e Initial load
duke
parents:
diff changeset
790
a61af66fc99e Initial load
duke
parents:
diff changeset
791 __ ret();
a61af66fc99e Initial load
duke
parents:
diff changeset
792 __ delayed()->restore();
a61af66fc99e Initial load
duke
parents:
diff changeset
793
a61af66fc99e Initial load
duke
parents:
diff changeset
794 }
a61af66fc99e Initial load
duke
parents:
diff changeset
795 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
796
a61af66fc99e Initial load
duke
parents:
diff changeset
797 case access_field_patching_id:
a61af66fc99e Initial load
duke
parents:
diff changeset
798 { __ set_info("access_field_patching", dont_gc_arguments);
a61af66fc99e Initial load
duke
parents:
diff changeset
799 oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, access_field_patching));
a61af66fc99e Initial load
duke
parents:
diff changeset
800 }
a61af66fc99e Initial load
duke
parents:
diff changeset
801 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
802
a61af66fc99e Initial load
duke
parents:
diff changeset
803 case load_klass_patching_id:
a61af66fc99e Initial load
duke
parents:
diff changeset
804 { __ set_info("load_klass_patching", dont_gc_arguments);
a61af66fc99e Initial load
duke
parents:
diff changeset
805 oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, move_klass_patching));
a61af66fc99e Initial load
duke
parents:
diff changeset
806 }
a61af66fc99e Initial load
duke
parents:
diff changeset
807 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
808
a61af66fc99e Initial load
duke
parents:
diff changeset
809 case jvmti_exception_throw_id:
a61af66fc99e Initial load
duke
parents:
diff changeset
810 { // Oexception : exception
a61af66fc99e Initial load
duke
parents:
diff changeset
811 __ set_info("jvmti_exception_throw", dont_gc_arguments);
a61af66fc99e Initial load
duke
parents:
diff changeset
812 oop_maps = generate_stub_call(sasm, noreg, CAST_FROM_FN_PTR(address, Runtime1::post_jvmti_exception_throw), I0);
a61af66fc99e Initial load
duke
parents:
diff changeset
813 }
a61af66fc99e Initial load
duke
parents:
diff changeset
814 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
815
a61af66fc99e Initial load
duke
parents:
diff changeset
816 case dtrace_object_alloc_id:
a61af66fc99e Initial load
duke
parents:
diff changeset
817 { // O0: object
a61af66fc99e Initial load
duke
parents:
diff changeset
818 __ set_info("dtrace_object_alloc", dont_gc_arguments);
a61af66fc99e Initial load
duke
parents:
diff changeset
819 // we can't gc here so skip the oopmap but make sure that all
a61af66fc99e Initial load
duke
parents:
diff changeset
820 // the live registers get saved.
a61af66fc99e Initial load
duke
parents:
diff changeset
821 save_live_registers(sasm);
a61af66fc99e Initial load
duke
parents:
diff changeset
822
a61af66fc99e Initial load
duke
parents:
diff changeset
823 __ save_thread(L7_thread_cache);
a61af66fc99e Initial load
duke
parents:
diff changeset
824 __ call(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_object_alloc),
a61af66fc99e Initial load
duke
parents:
diff changeset
825 relocInfo::runtime_call_type);
a61af66fc99e Initial load
duke
parents:
diff changeset
826 __ delayed()->mov(I0, O0);
a61af66fc99e Initial load
duke
parents:
diff changeset
827 __ restore_thread(L7_thread_cache);
a61af66fc99e Initial load
duke
parents:
diff changeset
828
a61af66fc99e Initial load
duke
parents:
diff changeset
829 restore_live_registers(sasm);
a61af66fc99e Initial load
duke
parents:
diff changeset
830 __ ret();
a61af66fc99e Initial load
duke
parents:
diff changeset
831 __ delayed()->restore();
a61af66fc99e Initial load
duke
parents:
diff changeset
832 }
a61af66fc99e Initial load
duke
parents:
diff changeset
833 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
834
a61af66fc99e Initial load
duke
parents:
diff changeset
835 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
836 { __ set_info("unimplemented entry", dont_gc_arguments);
a61af66fc99e Initial load
duke
parents:
diff changeset
837 __ save_frame(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
838 __ set((int)id, O1);
a61af66fc99e Initial load
duke
parents:
diff changeset
839 __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, unimplemented_entry), O1);
a61af66fc99e Initial load
duke
parents:
diff changeset
840 __ should_not_reach_here();
a61af66fc99e Initial load
duke
parents:
diff changeset
841 }
a61af66fc99e Initial load
duke
parents:
diff changeset
842 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
843 }
a61af66fc99e Initial load
duke
parents:
diff changeset
844 return oop_maps;
a61af66fc99e Initial load
duke
parents:
diff changeset
845 }
a61af66fc99e Initial load
duke
parents:
diff changeset
846
a61af66fc99e Initial load
duke
parents:
diff changeset
847
a61af66fc99e Initial load
duke
parents:
diff changeset
848 void Runtime1::generate_handle_exception(StubAssembler* sasm, OopMapSet* oop_maps, OopMap* oop_map, bool) {
a61af66fc99e Initial load
duke
parents:
diff changeset
849 Label no_deopt;
a61af66fc99e Initial load
duke
parents:
diff changeset
850 Label no_handler;
a61af66fc99e Initial load
duke
parents:
diff changeset
851
a61af66fc99e Initial load
duke
parents:
diff changeset
852 __ verify_not_null_oop(Oexception);
a61af66fc99e Initial load
duke
parents:
diff changeset
853
a61af66fc99e Initial load
duke
parents:
diff changeset
854 // save the exception and issuing pc in the thread
a61af66fc99e Initial load
duke
parents:
diff changeset
855 __ st_ptr(Oexception, G2_thread, in_bytes(JavaThread::exception_oop_offset()));
a61af66fc99e Initial load
duke
parents:
diff changeset
856 __ st_ptr(Oissuing_pc, G2_thread, in_bytes(JavaThread::exception_pc_offset()));
a61af66fc99e Initial load
duke
parents:
diff changeset
857
a61af66fc99e Initial load
duke
parents:
diff changeset
858 // save the real return address and use the throwing pc as the return address to lookup (has bci & oop map)
a61af66fc99e Initial load
duke
parents:
diff changeset
859 __ mov(I7, L0);
a61af66fc99e Initial load
duke
parents:
diff changeset
860 __ mov(Oissuing_pc, I7);
a61af66fc99e Initial load
duke
parents:
diff changeset
861 __ sub(I7, frame::pc_return_offset, I7);
a61af66fc99e Initial load
duke
parents:
diff changeset
862 int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, exception_handler_for_pc));
a61af66fc99e Initial load
duke
parents:
diff changeset
863
a61af66fc99e Initial load
duke
parents:
diff changeset
864 // Note: if nmethod has been deoptimized then regardless of
a61af66fc99e Initial load
duke
parents:
diff changeset
865 // whether it had a handler or not we will deoptimize
a61af66fc99e Initial load
duke
parents:
diff changeset
866 // by entering the deopt blob with a pending exception.
a61af66fc99e Initial load
duke
parents:
diff changeset
867
a61af66fc99e Initial load
duke
parents:
diff changeset
868 __ tst(O0);
a61af66fc99e Initial load
duke
parents:
diff changeset
869 __ br(Assembler::zero, false, Assembler::pn, no_handler);
a61af66fc99e Initial load
duke
parents:
diff changeset
870 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
871
a61af66fc99e Initial load
duke
parents:
diff changeset
872 // restore the registers that were saved at the beginning and jump to the exception handler.
a61af66fc99e Initial load
duke
parents:
diff changeset
873 restore_live_registers(sasm);
a61af66fc99e Initial load
duke
parents:
diff changeset
874
a61af66fc99e Initial load
duke
parents:
diff changeset
875 __ jmp(O0, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
876 __ delayed()->restore();
a61af66fc99e Initial load
duke
parents:
diff changeset
877
a61af66fc99e Initial load
duke
parents:
diff changeset
878 __ bind(no_handler);
a61af66fc99e Initial load
duke
parents:
diff changeset
879 __ mov(L0, I7); // restore return address
a61af66fc99e Initial load
duke
parents:
diff changeset
880
a61af66fc99e Initial load
duke
parents:
diff changeset
881 // restore exception oop
a61af66fc99e Initial load
duke
parents:
diff changeset
882 __ ld_ptr(G2_thread, in_bytes(JavaThread::exception_oop_offset()), Oexception->after_save());
a61af66fc99e Initial load
duke
parents:
diff changeset
883 __ st_ptr(G0, G2_thread, in_bytes(JavaThread::exception_oop_offset()));
a61af66fc99e Initial load
duke
parents:
diff changeset
884
a61af66fc99e Initial load
duke
parents:
diff changeset
885 __ restore();
a61af66fc99e Initial load
duke
parents:
diff changeset
886
a61af66fc99e Initial load
duke
parents:
diff changeset
887 Address exc(G4, Runtime1::entry_for(Runtime1::unwind_exception_id));
a61af66fc99e Initial load
duke
parents:
diff changeset
888 __ jump_to(exc, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
889 __ delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
890
a61af66fc99e Initial load
duke
parents:
diff changeset
891
a61af66fc99e Initial load
duke
parents:
diff changeset
892 oop_maps->add_gc_map(call_offset, oop_map);
a61af66fc99e Initial load
duke
parents:
diff changeset
893 }
a61af66fc99e Initial load
duke
parents:
diff changeset
894
a61af66fc99e Initial load
duke
parents:
diff changeset
895
a61af66fc99e Initial load
duke
parents:
diff changeset
896 #undef __
a61af66fc99e Initial load
duke
parents:
diff changeset
897
a61af66fc99e Initial load
duke
parents:
diff changeset
898 #define __ masm->