annotate src/cpu/x86/vm/c1_CodeStubs_x86.cpp @ 1295:3cf667df43ef

6919934: JSR 292 needs to support x86 C1 Summary: This implements JSR 292 support for C1 x86. Reviewed-by: never, jrose, kvn
author twisti
date Tue, 09 Mar 2010 20:16:19 +0100
parents eb28cf662f56
children c18cbe5936b8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1295
3cf667df43ef 6919934: JSR 292 needs to support x86 C1
twisti
parents: 380
diff changeset
2 * Copyright 1999-2010 Sun Microsystems, Inc. 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 *
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_CodeStubs_x86.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28
a61af66fc99e Initial load
duke
parents:
diff changeset
29 #define __ ce->masm()->
a61af66fc99e Initial load
duke
parents:
diff changeset
30
a61af66fc99e Initial load
duke
parents:
diff changeset
31 float ConversionStub::float_zero = 0.0;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 double ConversionStub::double_zero = 0.0;
a61af66fc99e Initial load
duke
parents:
diff changeset
33
a61af66fc99e Initial load
duke
parents:
diff changeset
34 void ConversionStub::emit_code(LIR_Assembler* ce) {
a61af66fc99e Initial load
duke
parents:
diff changeset
35 __ bind(_entry);
a61af66fc99e Initial load
duke
parents:
diff changeset
36 assert(bytecode() == Bytecodes::_f2i || bytecode() == Bytecodes::_d2i, "other conversions do not require stub");
a61af66fc99e Initial load
duke
parents:
diff changeset
37
a61af66fc99e Initial load
duke
parents:
diff changeset
38
a61af66fc99e Initial load
duke
parents:
diff changeset
39 if (input()->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
40 __ comiss(input()->as_xmm_float_reg(),
a61af66fc99e Initial load
duke
parents:
diff changeset
41 ExternalAddress((address)&float_zero));
a61af66fc99e Initial load
duke
parents:
diff changeset
42 } else if (input()->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
43 __ comisd(input()->as_xmm_double_reg(),
a61af66fc99e Initial load
duke
parents:
diff changeset
44 ExternalAddress((address)&double_zero));
a61af66fc99e Initial load
duke
parents:
diff changeset
45 } else {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
46 LP64_ONLY(ShouldNotReachHere());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
47 __ push(rax);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
48 __ ftst();
a61af66fc99e Initial load
duke
parents:
diff changeset
49 __ fnstsw_ax();
a61af66fc99e Initial load
duke
parents:
diff changeset
50 __ sahf();
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
51 __ pop(rax);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
52 }
a61af66fc99e Initial load
duke
parents:
diff changeset
53
a61af66fc99e Initial load
duke
parents:
diff changeset
54 Label NaN, do_return;
a61af66fc99e Initial load
duke
parents:
diff changeset
55 __ jccb(Assembler::parity, NaN);
a61af66fc99e Initial load
duke
parents:
diff changeset
56 __ jccb(Assembler::below, do_return);
a61af66fc99e Initial load
duke
parents:
diff changeset
57
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // input is > 0 -> return maxInt
a61af66fc99e Initial load
duke
parents:
diff changeset
59 // result register already contains 0x80000000, so subtracting 1 gives 0x7fffffff
a61af66fc99e Initial load
duke
parents:
diff changeset
60 __ decrement(result()->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
61 __ jmpb(do_return);
a61af66fc99e Initial load
duke
parents:
diff changeset
62
a61af66fc99e Initial load
duke
parents:
diff changeset
63 // input is NaN -> return 0
a61af66fc99e Initial load
duke
parents:
diff changeset
64 __ bind(NaN);
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
65 __ xorptr(result()->as_register(), result()->as_register());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
66
a61af66fc99e Initial load
duke
parents:
diff changeset
67 __ bind(do_return);
a61af66fc99e Initial load
duke
parents:
diff changeset
68 __ jmp(_continuation);
a61af66fc99e Initial load
duke
parents:
diff changeset
69 }
a61af66fc99e Initial load
duke
parents:
diff changeset
70
a61af66fc99e Initial load
duke
parents:
diff changeset
71 #ifdef TIERED
a61af66fc99e Initial load
duke
parents:
diff changeset
72 void CounterOverflowStub::emit_code(LIR_Assembler* ce) {
a61af66fc99e Initial load
duke
parents:
diff changeset
73 __ bind(_entry);
a61af66fc99e Initial load
duke
parents:
diff changeset
74 ce->store_parameter(_bci, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
75 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::counter_overflow_id)));
a61af66fc99e Initial load
duke
parents:
diff changeset
76 ce->add_call_info_here(_info);
a61af66fc99e Initial load
duke
parents:
diff changeset
77 ce->verify_oop_map(_info);
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 __ jmp(_continuation);
a61af66fc99e Initial load
duke
parents:
diff changeset
80 }
a61af66fc99e Initial load
duke
parents:
diff changeset
81 #endif // TIERED
a61af66fc99e Initial load
duke
parents:
diff changeset
82
a61af66fc99e Initial load
duke
parents:
diff changeset
83
a61af66fc99e Initial load
duke
parents:
diff changeset
84
a61af66fc99e Initial load
duke
parents:
diff changeset
85 RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index,
a61af66fc99e Initial load
duke
parents:
diff changeset
86 bool throw_index_out_of_bounds_exception)
a61af66fc99e Initial load
duke
parents:
diff changeset
87 : _throw_index_out_of_bounds_exception(throw_index_out_of_bounds_exception)
a61af66fc99e Initial load
duke
parents:
diff changeset
88 , _index(index)
a61af66fc99e Initial load
duke
parents:
diff changeset
89 {
a61af66fc99e Initial load
duke
parents:
diff changeset
90 _info = info == NULL ? NULL : new CodeEmitInfo(info);
a61af66fc99e Initial load
duke
parents:
diff changeset
91 }
a61af66fc99e Initial load
duke
parents:
diff changeset
92
a61af66fc99e Initial load
duke
parents:
diff changeset
93
a61af66fc99e Initial load
duke
parents:
diff changeset
94 void RangeCheckStub::emit_code(LIR_Assembler* ce) {
a61af66fc99e Initial load
duke
parents:
diff changeset
95 __ bind(_entry);
a61af66fc99e Initial load
duke
parents:
diff changeset
96 // pass the array index on stack because all registers must be preserved
a61af66fc99e Initial load
duke
parents:
diff changeset
97 if (_index->is_cpu_register()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
98 ce->store_parameter(_index->as_register(), 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
99 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
100 ce->store_parameter(_index->as_jint(), 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
101 }
a61af66fc99e Initial load
duke
parents:
diff changeset
102 Runtime1::StubID stub_id;
a61af66fc99e Initial load
duke
parents:
diff changeset
103 if (_throw_index_out_of_bounds_exception) {
a61af66fc99e Initial load
duke
parents:
diff changeset
104 stub_id = Runtime1::throw_index_exception_id;
a61af66fc99e Initial load
duke
parents:
diff changeset
105 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
106 stub_id = Runtime1::throw_range_check_failed_id;
a61af66fc99e Initial load
duke
parents:
diff changeset
107 }
a61af66fc99e Initial load
duke
parents:
diff changeset
108 __ call(RuntimeAddress(Runtime1::entry_for(stub_id)));
a61af66fc99e Initial load
duke
parents:
diff changeset
109 ce->add_call_info_here(_info);
a61af66fc99e Initial load
duke
parents:
diff changeset
110 debug_only(__ should_not_reach_here());
a61af66fc99e Initial load
duke
parents:
diff changeset
111 }
a61af66fc99e Initial load
duke
parents:
diff changeset
112
a61af66fc99e Initial load
duke
parents:
diff changeset
113
a61af66fc99e Initial load
duke
parents:
diff changeset
114 void DivByZeroStub::emit_code(LIR_Assembler* ce) {
a61af66fc99e Initial load
duke
parents:
diff changeset
115 if (_offset != -1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
116 ce->compilation()->implicit_exception_table()->append(_offset, __ offset());
a61af66fc99e Initial load
duke
parents:
diff changeset
117 }
a61af66fc99e Initial load
duke
parents:
diff changeset
118 __ bind(_entry);
a61af66fc99e Initial load
duke
parents:
diff changeset
119 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::throw_div0_exception_id)));
a61af66fc99e Initial load
duke
parents:
diff changeset
120 ce->add_call_info_here(_info);
a61af66fc99e Initial load
duke
parents:
diff changeset
121 debug_only(__ should_not_reach_here());
a61af66fc99e Initial load
duke
parents:
diff changeset
122 }
a61af66fc99e Initial load
duke
parents:
diff changeset
123
a61af66fc99e Initial load
duke
parents:
diff changeset
124
a61af66fc99e Initial load
duke
parents:
diff changeset
125 // Implementation of NewInstanceStub
a61af66fc99e Initial load
duke
parents:
diff changeset
126
a61af66fc99e Initial load
duke
parents:
diff changeset
127 NewInstanceStub::NewInstanceStub(LIR_Opr klass_reg, LIR_Opr result, ciInstanceKlass* klass, CodeEmitInfo* info, Runtime1::StubID stub_id) {
a61af66fc99e Initial load
duke
parents:
diff changeset
128 _result = result;
a61af66fc99e Initial load
duke
parents:
diff changeset
129 _klass = klass;
a61af66fc99e Initial load
duke
parents:
diff changeset
130 _klass_reg = klass_reg;
a61af66fc99e Initial load
duke
parents:
diff changeset
131 _info = new CodeEmitInfo(info);
a61af66fc99e Initial load
duke
parents:
diff changeset
132 assert(stub_id == Runtime1::new_instance_id ||
a61af66fc99e Initial load
duke
parents:
diff changeset
133 stub_id == Runtime1::fast_new_instance_id ||
a61af66fc99e Initial load
duke
parents:
diff changeset
134 stub_id == Runtime1::fast_new_instance_init_check_id,
a61af66fc99e Initial load
duke
parents:
diff changeset
135 "need new_instance id");
a61af66fc99e Initial load
duke
parents:
diff changeset
136 _stub_id = stub_id;
a61af66fc99e Initial load
duke
parents:
diff changeset
137 }
a61af66fc99e Initial load
duke
parents:
diff changeset
138
a61af66fc99e Initial load
duke
parents:
diff changeset
139
a61af66fc99e Initial load
duke
parents:
diff changeset
140 void NewInstanceStub::emit_code(LIR_Assembler* ce) {
a61af66fc99e Initial load
duke
parents:
diff changeset
141 assert(__ rsp_offset() == 0, "frame size should be fixed");
a61af66fc99e Initial load
duke
parents:
diff changeset
142 __ bind(_entry);
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
143 __ movptr(rdx, _klass_reg->as_register());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
144 __ call(RuntimeAddress(Runtime1::entry_for(_stub_id)));
a61af66fc99e Initial load
duke
parents:
diff changeset
145 ce->add_call_info_here(_info);
a61af66fc99e Initial load
duke
parents:
diff changeset
146 ce->verify_oop_map(_info);
a61af66fc99e Initial load
duke
parents:
diff changeset
147 assert(_result->as_register() == rax, "result must in rax,");
a61af66fc99e Initial load
duke
parents:
diff changeset
148 __ jmp(_continuation);
a61af66fc99e Initial load
duke
parents:
diff changeset
149 }
a61af66fc99e Initial load
duke
parents:
diff changeset
150
a61af66fc99e Initial load
duke
parents:
diff changeset
151
a61af66fc99e Initial load
duke
parents:
diff changeset
152 // Implementation of NewTypeArrayStub
a61af66fc99e Initial load
duke
parents:
diff changeset
153
a61af66fc99e Initial load
duke
parents:
diff changeset
154 NewTypeArrayStub::NewTypeArrayStub(LIR_Opr klass_reg, LIR_Opr length, LIR_Opr result, CodeEmitInfo* info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
155 _klass_reg = klass_reg;
a61af66fc99e Initial load
duke
parents:
diff changeset
156 _length = length;
a61af66fc99e Initial load
duke
parents:
diff changeset
157 _result = result;
a61af66fc99e Initial load
duke
parents:
diff changeset
158 _info = new CodeEmitInfo(info);
a61af66fc99e Initial load
duke
parents:
diff changeset
159 }
a61af66fc99e Initial load
duke
parents:
diff changeset
160
a61af66fc99e Initial load
duke
parents:
diff changeset
161
a61af66fc99e Initial load
duke
parents:
diff changeset
162 void NewTypeArrayStub::emit_code(LIR_Assembler* ce) {
a61af66fc99e Initial load
duke
parents:
diff changeset
163 assert(__ rsp_offset() == 0, "frame size should be fixed");
a61af66fc99e Initial load
duke
parents:
diff changeset
164 __ bind(_entry);
a61af66fc99e Initial load
duke
parents:
diff changeset
165 assert(_length->as_register() == rbx, "length must in rbx,");
a61af66fc99e Initial load
duke
parents:
diff changeset
166 assert(_klass_reg->as_register() == rdx, "klass_reg must in rdx");
a61af66fc99e Initial load
duke
parents:
diff changeset
167 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::new_type_array_id)));
a61af66fc99e Initial load
duke
parents:
diff changeset
168 ce->add_call_info_here(_info);
a61af66fc99e Initial load
duke
parents:
diff changeset
169 ce->verify_oop_map(_info);
a61af66fc99e Initial load
duke
parents:
diff changeset
170 assert(_result->as_register() == rax, "result must in rax,");
a61af66fc99e Initial load
duke
parents:
diff changeset
171 __ jmp(_continuation);
a61af66fc99e Initial load
duke
parents:
diff changeset
172 }
a61af66fc99e Initial load
duke
parents:
diff changeset
173
a61af66fc99e Initial load
duke
parents:
diff changeset
174
a61af66fc99e Initial load
duke
parents:
diff changeset
175 // Implementation of NewObjectArrayStub
a61af66fc99e Initial load
duke
parents:
diff changeset
176
a61af66fc99e Initial load
duke
parents:
diff changeset
177 NewObjectArrayStub::NewObjectArrayStub(LIR_Opr klass_reg, LIR_Opr length, LIR_Opr result, CodeEmitInfo* info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
178 _klass_reg = klass_reg;
a61af66fc99e Initial load
duke
parents:
diff changeset
179 _result = result;
a61af66fc99e Initial load
duke
parents:
diff changeset
180 _length = length;
a61af66fc99e Initial load
duke
parents:
diff changeset
181 _info = new CodeEmitInfo(info);
a61af66fc99e Initial load
duke
parents:
diff changeset
182 }
a61af66fc99e Initial load
duke
parents:
diff changeset
183
a61af66fc99e Initial load
duke
parents:
diff changeset
184
a61af66fc99e Initial load
duke
parents:
diff changeset
185 void NewObjectArrayStub::emit_code(LIR_Assembler* ce) {
a61af66fc99e Initial load
duke
parents:
diff changeset
186 assert(__ rsp_offset() == 0, "frame size should be fixed");
a61af66fc99e Initial load
duke
parents:
diff changeset
187 __ bind(_entry);
a61af66fc99e Initial load
duke
parents:
diff changeset
188 assert(_length->as_register() == rbx, "length must in rbx,");
a61af66fc99e Initial load
duke
parents:
diff changeset
189 assert(_klass_reg->as_register() == rdx, "klass_reg must in rdx");
a61af66fc99e Initial load
duke
parents:
diff changeset
190 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::new_object_array_id)));
a61af66fc99e Initial load
duke
parents:
diff changeset
191 ce->add_call_info_here(_info);
a61af66fc99e Initial load
duke
parents:
diff changeset
192 ce->verify_oop_map(_info);
a61af66fc99e Initial load
duke
parents:
diff changeset
193 assert(_result->as_register() == rax, "result must in rax,");
a61af66fc99e Initial load
duke
parents:
diff changeset
194 __ jmp(_continuation);
a61af66fc99e Initial load
duke
parents:
diff changeset
195 }
a61af66fc99e Initial load
duke
parents:
diff changeset
196
a61af66fc99e Initial load
duke
parents:
diff changeset
197
a61af66fc99e Initial load
duke
parents:
diff changeset
198 // Implementation of MonitorAccessStubs
a61af66fc99e Initial load
duke
parents:
diff changeset
199
a61af66fc99e Initial load
duke
parents:
diff changeset
200 MonitorEnterStub::MonitorEnterStub(LIR_Opr obj_reg, LIR_Opr lock_reg, CodeEmitInfo* info)
a61af66fc99e Initial load
duke
parents:
diff changeset
201 : MonitorAccessStub(obj_reg, lock_reg)
a61af66fc99e Initial load
duke
parents:
diff changeset
202 {
a61af66fc99e Initial load
duke
parents:
diff changeset
203 _info = new CodeEmitInfo(info);
a61af66fc99e Initial load
duke
parents:
diff changeset
204 }
a61af66fc99e Initial load
duke
parents:
diff changeset
205
a61af66fc99e Initial load
duke
parents:
diff changeset
206
a61af66fc99e Initial load
duke
parents:
diff changeset
207 void MonitorEnterStub::emit_code(LIR_Assembler* ce) {
a61af66fc99e Initial load
duke
parents:
diff changeset
208 assert(__ rsp_offset() == 0, "frame size should be fixed");
a61af66fc99e Initial load
duke
parents:
diff changeset
209 __ bind(_entry);
a61af66fc99e Initial load
duke
parents:
diff changeset
210 ce->store_parameter(_obj_reg->as_register(), 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
211 ce->store_parameter(_lock_reg->as_register(), 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
212 Runtime1::StubID enter_id;
a61af66fc99e Initial load
duke
parents:
diff changeset
213 if (ce->compilation()->has_fpu_code()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
214 enter_id = Runtime1::monitorenter_id;
a61af66fc99e Initial load
duke
parents:
diff changeset
215 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
216 enter_id = Runtime1::monitorenter_nofpu_id;
a61af66fc99e Initial load
duke
parents:
diff changeset
217 }
a61af66fc99e Initial load
duke
parents:
diff changeset
218 __ call(RuntimeAddress(Runtime1::entry_for(enter_id)));
a61af66fc99e Initial load
duke
parents:
diff changeset
219 ce->add_call_info_here(_info);
a61af66fc99e Initial load
duke
parents:
diff changeset
220 ce->verify_oop_map(_info);
a61af66fc99e Initial load
duke
parents:
diff changeset
221 __ jmp(_continuation);
a61af66fc99e Initial load
duke
parents:
diff changeset
222 }
a61af66fc99e Initial load
duke
parents:
diff changeset
223
a61af66fc99e Initial load
duke
parents:
diff changeset
224
a61af66fc99e Initial load
duke
parents:
diff changeset
225 void MonitorExitStub::emit_code(LIR_Assembler* ce) {
a61af66fc99e Initial load
duke
parents:
diff changeset
226 __ bind(_entry);
a61af66fc99e Initial load
duke
parents:
diff changeset
227 if (_compute_lock) {
a61af66fc99e Initial load
duke
parents:
diff changeset
228 // lock_reg was destroyed by fast unlocking attempt => recompute it
a61af66fc99e Initial load
duke
parents:
diff changeset
229 ce->monitor_address(_monitor_ix, _lock_reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
230 }
a61af66fc99e Initial load
duke
parents:
diff changeset
231 ce->store_parameter(_lock_reg->as_register(), 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
232 // note: non-blocking leaf routine => no call info needed
a61af66fc99e Initial load
duke
parents:
diff changeset
233 Runtime1::StubID exit_id;
a61af66fc99e Initial load
duke
parents:
diff changeset
234 if (ce->compilation()->has_fpu_code()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
235 exit_id = Runtime1::monitorexit_id;
a61af66fc99e Initial load
duke
parents:
diff changeset
236 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
237 exit_id = Runtime1::monitorexit_nofpu_id;
a61af66fc99e Initial load
duke
parents:
diff changeset
238 }
a61af66fc99e Initial load
duke
parents:
diff changeset
239 __ call(RuntimeAddress(Runtime1::entry_for(exit_id)));
a61af66fc99e Initial load
duke
parents:
diff changeset
240 __ jmp(_continuation);
a61af66fc99e Initial load
duke
parents:
diff changeset
241 }
a61af66fc99e Initial load
duke
parents:
diff changeset
242
a61af66fc99e Initial load
duke
parents:
diff changeset
243
a61af66fc99e Initial load
duke
parents:
diff changeset
244 // Implementation of patching:
a61af66fc99e Initial load
duke
parents:
diff changeset
245 // - Copy the code at given offset to an inlined buffer (first the bytes, then the number of bytes)
a61af66fc99e Initial load
duke
parents:
diff changeset
246 // - Replace original code with a call to the stub
a61af66fc99e Initial load
duke
parents:
diff changeset
247 // At Runtime:
a61af66fc99e Initial load
duke
parents:
diff changeset
248 // - call to stub, jump to runtime
a61af66fc99e Initial load
duke
parents:
diff changeset
249 // - in runtime: preserve all registers (rspecially objects, i.e., source and destination object)
a61af66fc99e Initial load
duke
parents:
diff changeset
250 // - in runtime: after initializing class, restore original code, reexecute instruction
a61af66fc99e Initial load
duke
parents:
diff changeset
251
a61af66fc99e Initial load
duke
parents:
diff changeset
252 int PatchingStub::_patch_info_offset = -NativeGeneralJump::instruction_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
253
a61af66fc99e Initial load
duke
parents:
diff changeset
254 void PatchingStub::align_patch_site(MacroAssembler* masm) {
a61af66fc99e Initial load
duke
parents:
diff changeset
255 // We're patching a 5-7 byte instruction on intel and we need to
a61af66fc99e Initial load
duke
parents:
diff changeset
256 // make sure that we don't see a piece of the instruction. It
a61af66fc99e Initial load
duke
parents:
diff changeset
257 // appears mostly impossible on Intel to simply invalidate other
a61af66fc99e Initial load
duke
parents:
diff changeset
258 // processors caches and since they may do aggressive prefetch it's
a61af66fc99e Initial load
duke
parents:
diff changeset
259 // very hard to make a guess about what code might be in the icache.
a61af66fc99e Initial load
duke
parents:
diff changeset
260 // Force the instruction to be double word aligned so that it
a61af66fc99e Initial load
duke
parents:
diff changeset
261 // doesn't span a cache line.
a61af66fc99e Initial load
duke
parents:
diff changeset
262 masm->align(round_to(NativeGeneralJump::instruction_size, wordSize));
a61af66fc99e Initial load
duke
parents:
diff changeset
263 }
a61af66fc99e Initial load
duke
parents:
diff changeset
264
a61af66fc99e Initial load
duke
parents:
diff changeset
265 void PatchingStub::emit_code(LIR_Assembler* ce) {
a61af66fc99e Initial load
duke
parents:
diff changeset
266 assert(NativeCall::instruction_size <= _bytes_to_copy && _bytes_to_copy <= 0xFF, "not enough room for call");
a61af66fc99e Initial load
duke
parents:
diff changeset
267
a61af66fc99e Initial load
duke
parents:
diff changeset
268 Label call_patch;
a61af66fc99e Initial load
duke
parents:
diff changeset
269
a61af66fc99e Initial load
duke
parents:
diff changeset
270 // static field accesses have special semantics while the class
a61af66fc99e Initial load
duke
parents:
diff changeset
271 // initializer is being run so we emit a test which can be used to
a61af66fc99e Initial load
duke
parents:
diff changeset
272 // check that this code is being executed by the initializing
a61af66fc99e Initial load
duke
parents:
diff changeset
273 // thread.
a61af66fc99e Initial load
duke
parents:
diff changeset
274 address being_initialized_entry = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
275 if (CommentedAssembly) {
a61af66fc99e Initial load
duke
parents:
diff changeset
276 __ block_comment(" patch template");
a61af66fc99e Initial load
duke
parents:
diff changeset
277 }
a61af66fc99e Initial load
duke
parents:
diff changeset
278 if (_id == load_klass_id) {
a61af66fc99e Initial load
duke
parents:
diff changeset
279 // produce a copy of the load klass instruction for use by the being initialized case
a61af66fc99e Initial load
duke
parents:
diff changeset
280 address start = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
281 jobject o = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
282 __ movoop(_obj, o);
a61af66fc99e Initial load
duke
parents:
diff changeset
283 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
284 for (int i = 0; i < _bytes_to_copy; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
285 address ptr = (address)(_pc_start + i);
a61af66fc99e Initial load
duke
parents:
diff changeset
286 int a_byte = (*ptr) & 0xFF;
a61af66fc99e Initial load
duke
parents:
diff changeset
287 assert(a_byte == *start++, "should be the same code");
a61af66fc99e Initial load
duke
parents:
diff changeset
288 }
a61af66fc99e Initial load
duke
parents:
diff changeset
289 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
290 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
291 // make a copy the code which is going to be patched.
a61af66fc99e Initial load
duke
parents:
diff changeset
292 for ( int i = 0; i < _bytes_to_copy; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
293 address ptr = (address)(_pc_start + i);
a61af66fc99e Initial load
duke
parents:
diff changeset
294 int a_byte = (*ptr) & 0xFF;
a61af66fc99e Initial load
duke
parents:
diff changeset
295 __ a_byte (a_byte);
a61af66fc99e Initial load
duke
parents:
diff changeset
296 *ptr = 0x90; // make the site look like a nop
a61af66fc99e Initial load
duke
parents:
diff changeset
297 }
a61af66fc99e Initial load
duke
parents:
diff changeset
298 }
a61af66fc99e Initial load
duke
parents:
diff changeset
299
a61af66fc99e Initial load
duke
parents:
diff changeset
300 address end_of_patch = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
301 int bytes_to_skip = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
302 if (_id == load_klass_id) {
a61af66fc99e Initial load
duke
parents:
diff changeset
303 int offset = __ offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
304 if (CommentedAssembly) {
a61af66fc99e Initial load
duke
parents:
diff changeset
305 __ block_comment(" being_initialized check");
a61af66fc99e Initial load
duke
parents:
diff changeset
306 }
a61af66fc99e Initial load
duke
parents:
diff changeset
307 assert(_obj != noreg, "must be a valid register");
a61af66fc99e Initial load
duke
parents:
diff changeset
308 Register tmp = rax;
a61af66fc99e Initial load
duke
parents:
diff changeset
309 if (_obj == tmp) tmp = rbx;
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
310 __ push(tmp);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
311 __ get_thread(tmp);
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
312 __ cmpptr(tmp, Address(_obj, instanceKlass::init_thread_offset_in_bytes() + sizeof(klassOopDesc)));
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
313 __ pop(tmp);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
314 __ jcc(Assembler::notEqual, call_patch);
a61af66fc99e Initial load
duke
parents:
diff changeset
315
a61af66fc99e Initial load
duke
parents:
diff changeset
316 // access_field patches may execute the patched code before it's
a61af66fc99e Initial load
duke
parents:
diff changeset
317 // copied back into place so we need to jump back into the main
a61af66fc99e Initial load
duke
parents:
diff changeset
318 // code of the nmethod to continue execution.
a61af66fc99e Initial load
duke
parents:
diff changeset
319 __ jmp(_patch_site_continuation);
a61af66fc99e Initial load
duke
parents:
diff changeset
320
a61af66fc99e Initial load
duke
parents:
diff changeset
321 // make sure this extra code gets skipped
a61af66fc99e Initial load
duke
parents:
diff changeset
322 bytes_to_skip += __ offset() - offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
323 }
a61af66fc99e Initial load
duke
parents:
diff changeset
324 if (CommentedAssembly) {
a61af66fc99e Initial load
duke
parents:
diff changeset
325 __ block_comment("patch data encoded as movl");
a61af66fc99e Initial load
duke
parents:
diff changeset
326 }
a61af66fc99e Initial load
duke
parents:
diff changeset
327 // Now emit the patch record telling the runtime how to find the
a61af66fc99e Initial load
duke
parents:
diff changeset
328 // pieces of the patch. We only need 3 bytes but for readability of
a61af66fc99e Initial load
duke
parents:
diff changeset
329 // the disassembly we make the data look like a movl reg, imm32,
a61af66fc99e Initial load
duke
parents:
diff changeset
330 // which requires 5 bytes
a61af66fc99e Initial load
duke
parents:
diff changeset
331 int sizeof_patch_record = 5;
a61af66fc99e Initial load
duke
parents:
diff changeset
332 bytes_to_skip += sizeof_patch_record;
a61af66fc99e Initial load
duke
parents:
diff changeset
333
a61af66fc99e Initial load
duke
parents:
diff changeset
334 // emit the offsets needed to find the code to patch
a61af66fc99e Initial load
duke
parents:
diff changeset
335 int being_initialized_entry_offset = __ pc() - being_initialized_entry + sizeof_patch_record;
a61af66fc99e Initial load
duke
parents:
diff changeset
336
a61af66fc99e Initial load
duke
parents:
diff changeset
337 __ a_byte(0xB8);
a61af66fc99e Initial load
duke
parents:
diff changeset
338 __ a_byte(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
339 __ a_byte(being_initialized_entry_offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
340 __ a_byte(bytes_to_skip);
a61af66fc99e Initial load
duke
parents:
diff changeset
341 __ a_byte(_bytes_to_copy);
a61af66fc99e Initial load
duke
parents:
diff changeset
342 address patch_info_pc = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
343 assert(patch_info_pc - end_of_patch == bytes_to_skip, "incorrect patch info");
a61af66fc99e Initial load
duke
parents:
diff changeset
344
a61af66fc99e Initial load
duke
parents:
diff changeset
345 address entry = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
346 NativeGeneralJump::insert_unconditional((address)_pc_start, entry);
a61af66fc99e Initial load
duke
parents:
diff changeset
347 address target = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
348 switch (_id) {
a61af66fc99e Initial load
duke
parents:
diff changeset
349 case access_field_id: target = Runtime1::entry_for(Runtime1::access_field_patching_id); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
350 case load_klass_id: target = Runtime1::entry_for(Runtime1::load_klass_patching_id); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
351 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
352 }
a61af66fc99e Initial load
duke
parents:
diff changeset
353 __ bind(call_patch);
a61af66fc99e Initial load
duke
parents:
diff changeset
354
a61af66fc99e Initial load
duke
parents:
diff changeset
355 if (CommentedAssembly) {
a61af66fc99e Initial load
duke
parents:
diff changeset
356 __ block_comment("patch entry point");
a61af66fc99e Initial load
duke
parents:
diff changeset
357 }
a61af66fc99e Initial load
duke
parents:
diff changeset
358 __ call(RuntimeAddress(target));
a61af66fc99e Initial load
duke
parents:
diff changeset
359 assert(_patch_info_offset == (patch_info_pc - __ pc()), "must not change");
a61af66fc99e Initial load
duke
parents:
diff changeset
360 ce->add_call_info_here(_info);
a61af66fc99e Initial load
duke
parents:
diff changeset
361 int jmp_off = __ offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
362 __ jmp(_patch_site_entry);
a61af66fc99e Initial load
duke
parents:
diff changeset
363 // Add enough nops so deoptimization can overwrite the jmp above with a call
a61af66fc99e Initial load
duke
parents:
diff changeset
364 // and not destroy the world.
a61af66fc99e Initial load
duke
parents:
diff changeset
365 for (int j = __ offset() ; j < jmp_off + 5 ; j++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
366 __ nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
367 }
a61af66fc99e Initial load
duke
parents:
diff changeset
368 if (_id == load_klass_id) {
a61af66fc99e Initial load
duke
parents:
diff changeset
369 CodeSection* cs = __ code_section();
a61af66fc99e Initial load
duke
parents:
diff changeset
370 RelocIterator iter(cs, (address)_pc_start, (address)(_pc_start + 1));
a61af66fc99e Initial load
duke
parents:
diff changeset
371 relocInfo::change_reloc_info_for_address(&iter, (address) _pc_start, relocInfo::oop_type, relocInfo::none);
a61af66fc99e Initial load
duke
parents:
diff changeset
372 }
a61af66fc99e Initial load
duke
parents:
diff changeset
373 }
a61af66fc99e Initial load
duke
parents:
diff changeset
374
a61af66fc99e Initial load
duke
parents:
diff changeset
375
1295
3cf667df43ef 6919934: JSR 292 needs to support x86 C1
twisti
parents: 380
diff changeset
376 void DeoptimizeStub::emit_code(LIR_Assembler* ce) {
3cf667df43ef 6919934: JSR 292 needs to support x86 C1
twisti
parents: 380
diff changeset
377 __ bind(_entry);
3cf667df43ef 6919934: JSR 292 needs to support x86 C1
twisti
parents: 380
diff changeset
378 __ call(RuntimeAddress(SharedRuntime::deopt_blob()->unpack_with_reexecution()));
3cf667df43ef 6919934: JSR 292 needs to support x86 C1
twisti
parents: 380
diff changeset
379 ce->add_call_info_here(_info);
3cf667df43ef 6919934: JSR 292 needs to support x86 C1
twisti
parents: 380
diff changeset
380 debug_only(__ should_not_reach_here());
3cf667df43ef 6919934: JSR 292 needs to support x86 C1
twisti
parents: 380
diff changeset
381 }
3cf667df43ef 6919934: JSR 292 needs to support x86 C1
twisti
parents: 380
diff changeset
382
3cf667df43ef 6919934: JSR 292 needs to support x86 C1
twisti
parents: 380
diff changeset
383
0
a61af66fc99e Initial load
duke
parents:
diff changeset
384 void ImplicitNullCheckStub::emit_code(LIR_Assembler* ce) {
a61af66fc99e Initial load
duke
parents:
diff changeset
385 ce->compilation()->implicit_exception_table()->append(_offset, __ offset());
a61af66fc99e Initial load
duke
parents:
diff changeset
386 __ bind(_entry);
a61af66fc99e Initial load
duke
parents:
diff changeset
387 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::throw_null_pointer_exception_id)));
a61af66fc99e Initial load
duke
parents:
diff changeset
388 ce->add_call_info_here(_info);
a61af66fc99e Initial load
duke
parents:
diff changeset
389 debug_only(__ should_not_reach_here());
a61af66fc99e Initial load
duke
parents:
diff changeset
390 }
a61af66fc99e Initial load
duke
parents:
diff changeset
391
a61af66fc99e Initial load
duke
parents:
diff changeset
392
a61af66fc99e Initial load
duke
parents:
diff changeset
393 void SimpleExceptionStub::emit_code(LIR_Assembler* ce) {
a61af66fc99e Initial load
duke
parents:
diff changeset
394 assert(__ rsp_offset() == 0, "frame size should be fixed");
a61af66fc99e Initial load
duke
parents:
diff changeset
395
a61af66fc99e Initial load
duke
parents:
diff changeset
396 __ bind(_entry);
a61af66fc99e Initial load
duke
parents:
diff changeset
397 // pass the object on stack because all registers must be preserved
a61af66fc99e Initial load
duke
parents:
diff changeset
398 if (_obj->is_cpu_register()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
399 ce->store_parameter(_obj->as_register(), 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
400 }
a61af66fc99e Initial load
duke
parents:
diff changeset
401 __ call(RuntimeAddress(Runtime1::entry_for(_stub)));
a61af66fc99e Initial load
duke
parents:
diff changeset
402 ce->add_call_info_here(_info);
a61af66fc99e Initial load
duke
parents:
diff changeset
403 debug_only(__ should_not_reach_here());
a61af66fc99e Initial load
duke
parents:
diff changeset
404 }
a61af66fc99e Initial load
duke
parents:
diff changeset
405
a61af66fc99e Initial load
duke
parents:
diff changeset
406
a61af66fc99e Initial load
duke
parents:
diff changeset
407 ArrayStoreExceptionStub::ArrayStoreExceptionStub(CodeEmitInfo* info):
a61af66fc99e Initial load
duke
parents:
diff changeset
408 _info(info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
409 }
a61af66fc99e Initial load
duke
parents:
diff changeset
410
a61af66fc99e Initial load
duke
parents:
diff changeset
411
a61af66fc99e Initial load
duke
parents:
diff changeset
412 void ArrayStoreExceptionStub::emit_code(LIR_Assembler* ce) {
a61af66fc99e Initial load
duke
parents:
diff changeset
413 assert(__ rsp_offset() == 0, "frame size should be fixed");
a61af66fc99e Initial load
duke
parents:
diff changeset
414 __ bind(_entry);
a61af66fc99e Initial load
duke
parents:
diff changeset
415 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::throw_array_store_exception_id)));
a61af66fc99e Initial load
duke
parents:
diff changeset
416 ce->add_call_info_here(_info);
a61af66fc99e Initial load
duke
parents:
diff changeset
417 debug_only(__ should_not_reach_here());
a61af66fc99e Initial load
duke
parents:
diff changeset
418 }
a61af66fc99e Initial load
duke
parents:
diff changeset
419
a61af66fc99e Initial load
duke
parents:
diff changeset
420
a61af66fc99e Initial load
duke
parents:
diff changeset
421 void ArrayCopyStub::emit_code(LIR_Assembler* ce) {
a61af66fc99e Initial load
duke
parents:
diff changeset
422 //---------------slow case: call to native-----------------
a61af66fc99e Initial load
duke
parents:
diff changeset
423 __ bind(_entry);
a61af66fc99e Initial load
duke
parents:
diff changeset
424 // Figure out where the args should go
a61af66fc99e Initial load
duke
parents:
diff changeset
425 // This should really convert the IntrinsicID to the methodOop and signature
a61af66fc99e Initial load
duke
parents:
diff changeset
426 // but I don't know how to do that.
a61af66fc99e Initial load
duke
parents:
diff changeset
427 //
a61af66fc99e Initial load
duke
parents:
diff changeset
428 VMRegPair args[5];
a61af66fc99e Initial load
duke
parents:
diff changeset
429 BasicType signature[5] = { T_OBJECT, T_INT, T_OBJECT, T_INT, T_INT};
a61af66fc99e Initial load
duke
parents:
diff changeset
430 SharedRuntime::java_calling_convention(signature, args, 5, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
431
a61af66fc99e Initial load
duke
parents:
diff changeset
432 // push parameters
a61af66fc99e Initial load
duke
parents:
diff changeset
433 // (src, src_pos, dest, destPos, length)
a61af66fc99e Initial load
duke
parents:
diff changeset
434 Register r[5];
a61af66fc99e Initial load
duke
parents:
diff changeset
435 r[0] = src()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
436 r[1] = src_pos()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
437 r[2] = dst()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
438 r[3] = dst_pos()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
439 r[4] = length()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
440
a61af66fc99e Initial load
duke
parents:
diff changeset
441 // next registers will get stored on the stack
a61af66fc99e Initial load
duke
parents:
diff changeset
442 for (int i = 0; i < 5 ; i++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
443 VMReg r_1 = args[i].first();
a61af66fc99e Initial load
duke
parents:
diff changeset
444 if (r_1->is_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
445 int st_off = r_1->reg2stack() * wordSize;
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
446 __ movptr (Address(rsp, st_off), r[i]);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
447 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
448 assert(r[i] == args[i].first()->as_Register(), "Wrong register for arg ");
a61af66fc99e Initial load
duke
parents:
diff changeset
449 }
a61af66fc99e Initial load
duke
parents:
diff changeset
450 }
a61af66fc99e Initial load
duke
parents:
diff changeset
451
a61af66fc99e Initial load
duke
parents:
diff changeset
452 ce->align_call(lir_static_call);
a61af66fc99e Initial load
duke
parents:
diff changeset
453
a61af66fc99e Initial load
duke
parents:
diff changeset
454 ce->emit_static_call_stub();
a61af66fc99e Initial load
duke
parents:
diff changeset
455 AddressLiteral resolve(SharedRuntime::get_resolve_static_call_stub(),
a61af66fc99e Initial load
duke
parents:
diff changeset
456 relocInfo::static_call_type);
a61af66fc99e Initial load
duke
parents:
diff changeset
457 __ call(resolve);
a61af66fc99e Initial load
duke
parents:
diff changeset
458 ce->add_call_info_here(info());
a61af66fc99e Initial load
duke
parents:
diff changeset
459
a61af66fc99e Initial load
duke
parents:
diff changeset
460 #ifndef PRODUCT
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
461 __ incrementl(ExternalAddress((address)&Runtime1::_arraycopy_slowcase_cnt));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
462 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
463
a61af66fc99e Initial load
duke
parents:
diff changeset
464 __ jmp(_continuation);
a61af66fc99e Initial load
duke
parents:
diff changeset
465 }
a61af66fc99e Initial load
duke
parents:
diff changeset
466
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
467 /////////////////////////////////////////////////////////////////////////////
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
468 #ifndef SERIALGC
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
469
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
470 void G1PreBarrierStub::emit_code(LIR_Assembler* ce) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
471
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
472 // At this point we know that marking is in progress
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
473
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
474 __ bind(_entry);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
475 assert(pre_val()->is_register(), "Precondition.");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
476
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
477 Register pre_val_reg = pre_val()->as_register();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
478
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
479 ce->mem2reg(addr(), pre_val(), T_OBJECT, patch_code(), info(), false);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
480
362
apetrusenko
parents: 304 342
diff changeset
481 __ cmpptr(pre_val_reg, (int32_t) NULL_WORD);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
482 __ jcc(Assembler::equal, _continuation);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
483 ce->store_parameter(pre_val()->as_register(), 0);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
484 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::g1_pre_barrier_slow_id)));
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
485 __ jmp(_continuation);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
486
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
487 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
488
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
489 jbyte* G1PostBarrierStub::_byte_map_base = NULL;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
490
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
491 jbyte* G1PostBarrierStub::byte_map_base_slow() {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
492 BarrierSet* bs = Universe::heap()->barrier_set();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
493 assert(bs->is_a(BarrierSet::G1SATBCTLogging),
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
494 "Must be if we're using this.");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
495 return ((G1SATBCardTableModRefBS*)bs)->byte_map_base;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
496 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
497
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
498 void G1PostBarrierStub::emit_code(LIR_Assembler* ce) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
499 __ bind(_entry);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
500 assert(addr()->is_register(), "Precondition.");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
501 assert(new_val()->is_register(), "Precondition.");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
502 Register new_val_reg = new_val()->as_register();
362
apetrusenko
parents: 304 342
diff changeset
503 __ cmpptr(new_val_reg, (int32_t) NULL_WORD);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
504 __ jcc(Assembler::equal, _continuation);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
505 ce->store_parameter(addr()->as_register(), 0);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
506 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::g1_post_barrier_slow_id)));
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
507 __ jmp(_continuation);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
508 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
509
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
510 #endif // SERIALGC
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
511 /////////////////////////////////////////////////////////////////////////////
0
a61af66fc99e Initial load
duke
parents:
diff changeset
512
a61af66fc99e Initial load
duke
parents:
diff changeset
513 #undef __