annotate src/cpu/x86/vm/c1_CodeStubs_x86.cpp @ 4582:b24386206122

Made all vm builds go into subdirectories, even product builds to simplify building the various types of VMs (server, client and graal). Made HotSpot build jobs use the number of CPUs on the host machine.
author Doug Simon <doug.simon@oracle.com>
date Mon, 13 Feb 2012 23:13:37 +0100
parents cec1757a0134
children 069ab3f976d3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
2168
e4fee0bdaa85 7008809: should report the class in ArrayStoreExceptions from compiled code
never
parents: 2002
diff changeset
2 * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1295
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1295
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1295
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1873
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1873
diff changeset
26 #include "c1/c1_CodeStubs.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1873
diff changeset
27 #include "c1/c1_FrameMap.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1873
diff changeset
28 #include "c1/c1_LIRAssembler.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1873
diff changeset
29 #include "c1/c1_MacroAssembler.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1873
diff changeset
30 #include "c1/c1_Runtime1.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1873
diff changeset
31 #include "nativeInst_x86.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1873
diff changeset
32 #include "runtime/sharedRuntime.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1873
diff changeset
33 #include "vmreg_x86.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1873
diff changeset
34 #ifndef SERIALGC
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1873
diff changeset
35 #include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1873
diff changeset
36 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
37
a61af66fc99e Initial load
duke
parents:
diff changeset
38
a61af66fc99e Initial load
duke
parents:
diff changeset
39 #define __ ce->masm()->
a61af66fc99e Initial load
duke
parents:
diff changeset
40
a61af66fc99e Initial load
duke
parents:
diff changeset
41 float ConversionStub::float_zero = 0.0;
a61af66fc99e Initial load
duke
parents:
diff changeset
42 double ConversionStub::double_zero = 0.0;
a61af66fc99e Initial load
duke
parents:
diff changeset
43
a61af66fc99e Initial load
duke
parents:
diff changeset
44 void ConversionStub::emit_code(LIR_Assembler* ce) {
a61af66fc99e Initial load
duke
parents:
diff changeset
45 __ bind(_entry);
a61af66fc99e Initial load
duke
parents:
diff changeset
46 assert(bytecode() == Bytecodes::_f2i || bytecode() == Bytecodes::_d2i, "other conversions do not require stub");
a61af66fc99e Initial load
duke
parents:
diff changeset
47
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49 if (input()->is_single_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
50 __ comiss(input()->as_xmm_float_reg(),
a61af66fc99e Initial load
duke
parents:
diff changeset
51 ExternalAddress((address)&float_zero));
a61af66fc99e Initial load
duke
parents:
diff changeset
52 } else if (input()->is_double_xmm()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
53 __ comisd(input()->as_xmm_double_reg(),
a61af66fc99e Initial load
duke
parents:
diff changeset
54 ExternalAddress((address)&double_zero));
a61af66fc99e Initial load
duke
parents:
diff changeset
55 } else {
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
56 LP64_ONLY(ShouldNotReachHere());
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
57 __ push(rax);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
58 __ ftst();
a61af66fc99e Initial load
duke
parents:
diff changeset
59 __ fnstsw_ax();
a61af66fc99e Initial load
duke
parents:
diff changeset
60 __ sahf();
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
61 __ pop(rax);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
62 }
a61af66fc99e Initial load
duke
parents:
diff changeset
63
a61af66fc99e Initial load
duke
parents:
diff changeset
64 Label NaN, do_return;
a61af66fc99e Initial load
duke
parents:
diff changeset
65 __ jccb(Assembler::parity, NaN);
a61af66fc99e Initial load
duke
parents:
diff changeset
66 __ jccb(Assembler::below, do_return);
a61af66fc99e Initial load
duke
parents:
diff changeset
67
a61af66fc99e Initial load
duke
parents:
diff changeset
68 // input is > 0 -> return maxInt
a61af66fc99e Initial load
duke
parents:
diff changeset
69 // result register already contains 0x80000000, so subtracting 1 gives 0x7fffffff
a61af66fc99e Initial load
duke
parents:
diff changeset
70 __ decrement(result()->as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
71 __ jmpb(do_return);
a61af66fc99e Initial load
duke
parents:
diff changeset
72
a61af66fc99e Initial load
duke
parents:
diff changeset
73 // input is NaN -> return 0
a61af66fc99e Initial load
duke
parents:
diff changeset
74 __ bind(NaN);
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
75 __ xorptr(result()->as_register(), result()->as_register());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77 __ bind(do_return);
a61af66fc99e Initial load
duke
parents:
diff changeset
78 __ jmp(_continuation);
a61af66fc99e Initial load
duke
parents:
diff changeset
79 }
a61af66fc99e Initial load
duke
parents:
diff changeset
80
a61af66fc99e Initial load
duke
parents:
diff changeset
81 void CounterOverflowStub::emit_code(LIR_Assembler* ce) {
a61af66fc99e Initial load
duke
parents:
diff changeset
82 __ bind(_entry);
1783
d5d065957597 6953144: Tiered compilation
iveresov
parents: 1552
diff changeset
83 ce->store_parameter(_method->as_register(), 1);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
84 ce->store_parameter(_bci, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
85 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::counter_overflow_id)));
a61af66fc99e Initial load
duke
parents:
diff changeset
86 ce->add_call_info_here(_info);
a61af66fc99e Initial load
duke
parents:
diff changeset
87 ce->verify_oop_map(_info);
a61af66fc99e Initial load
duke
parents:
diff changeset
88 __ jmp(_continuation);
a61af66fc99e Initial load
duke
parents:
diff changeset
89 }
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91 RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index,
a61af66fc99e Initial load
duke
parents:
diff changeset
92 bool throw_index_out_of_bounds_exception)
a61af66fc99e Initial load
duke
parents:
diff changeset
93 : _throw_index_out_of_bounds_exception(throw_index_out_of_bounds_exception)
a61af66fc99e Initial load
duke
parents:
diff changeset
94 , _index(index)
a61af66fc99e Initial load
duke
parents:
diff changeset
95 {
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1783
diff changeset
96 assert(info != NULL, "must have info");
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1783
diff changeset
97 _info = new CodeEmitInfo(info);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
98 }
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100
a61af66fc99e Initial load
duke
parents:
diff changeset
101 void RangeCheckStub::emit_code(LIR_Assembler* ce) {
a61af66fc99e Initial load
duke
parents:
diff changeset
102 __ bind(_entry);
a61af66fc99e Initial load
duke
parents:
diff changeset
103 // pass the array index on stack because all registers must be preserved
a61af66fc99e Initial load
duke
parents:
diff changeset
104 if (_index->is_cpu_register()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
105 ce->store_parameter(_index->as_register(), 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
106 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
107 ce->store_parameter(_index->as_jint(), 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
108 }
a61af66fc99e Initial load
duke
parents:
diff changeset
109 Runtime1::StubID stub_id;
a61af66fc99e Initial load
duke
parents:
diff changeset
110 if (_throw_index_out_of_bounds_exception) {
a61af66fc99e Initial load
duke
parents:
diff changeset
111 stub_id = Runtime1::throw_index_exception_id;
a61af66fc99e Initial load
duke
parents:
diff changeset
112 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
113 stub_id = Runtime1::throw_range_check_failed_id;
a61af66fc99e Initial load
duke
parents:
diff changeset
114 }
a61af66fc99e Initial load
duke
parents:
diff changeset
115 __ call(RuntimeAddress(Runtime1::entry_for(stub_id)));
a61af66fc99e Initial load
duke
parents:
diff changeset
116 ce->add_call_info_here(_info);
a61af66fc99e Initial load
duke
parents:
diff changeset
117 debug_only(__ should_not_reach_here());
a61af66fc99e Initial load
duke
parents:
diff changeset
118 }
a61af66fc99e Initial load
duke
parents:
diff changeset
119
a61af66fc99e Initial load
duke
parents:
diff changeset
120
a61af66fc99e Initial load
duke
parents:
diff changeset
121 void DivByZeroStub::emit_code(LIR_Assembler* ce) {
a61af66fc99e Initial load
duke
parents:
diff changeset
122 if (_offset != -1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
123 ce->compilation()->implicit_exception_table()->append(_offset, __ offset());
a61af66fc99e Initial load
duke
parents:
diff changeset
124 }
a61af66fc99e Initial load
duke
parents:
diff changeset
125 __ bind(_entry);
a61af66fc99e Initial load
duke
parents:
diff changeset
126 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::throw_div0_exception_id)));
a61af66fc99e Initial load
duke
parents:
diff changeset
127 ce->add_call_info_here(_info);
a61af66fc99e Initial load
duke
parents:
diff changeset
128 debug_only(__ should_not_reach_here());
a61af66fc99e Initial load
duke
parents:
diff changeset
129 }
a61af66fc99e Initial load
duke
parents:
diff changeset
130
a61af66fc99e Initial load
duke
parents:
diff changeset
131
a61af66fc99e Initial load
duke
parents:
diff changeset
132 // Implementation of NewInstanceStub
a61af66fc99e Initial load
duke
parents:
diff changeset
133
a61af66fc99e Initial load
duke
parents:
diff changeset
134 NewInstanceStub::NewInstanceStub(LIR_Opr klass_reg, LIR_Opr result, ciInstanceKlass* klass, CodeEmitInfo* info, Runtime1::StubID stub_id) {
a61af66fc99e Initial load
duke
parents:
diff changeset
135 _result = result;
a61af66fc99e Initial load
duke
parents:
diff changeset
136 _klass = klass;
a61af66fc99e Initial load
duke
parents:
diff changeset
137 _klass_reg = klass_reg;
a61af66fc99e Initial load
duke
parents:
diff changeset
138 _info = new CodeEmitInfo(info);
a61af66fc99e Initial load
duke
parents:
diff changeset
139 assert(stub_id == Runtime1::new_instance_id ||
a61af66fc99e Initial load
duke
parents:
diff changeset
140 stub_id == Runtime1::fast_new_instance_id ||
a61af66fc99e Initial load
duke
parents:
diff changeset
141 stub_id == Runtime1::fast_new_instance_init_check_id,
a61af66fc99e Initial load
duke
parents:
diff changeset
142 "need new_instance id");
a61af66fc99e Initial load
duke
parents:
diff changeset
143 _stub_id = stub_id;
a61af66fc99e Initial load
duke
parents:
diff changeset
144 }
a61af66fc99e Initial load
duke
parents:
diff changeset
145
a61af66fc99e Initial load
duke
parents:
diff changeset
146
a61af66fc99e Initial load
duke
parents:
diff changeset
147 void NewInstanceStub::emit_code(LIR_Assembler* ce) {
a61af66fc99e Initial load
duke
parents:
diff changeset
148 assert(__ rsp_offset() == 0, "frame size should be fixed");
a61af66fc99e Initial load
duke
parents:
diff changeset
149 __ bind(_entry);
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
150 __ movptr(rdx, _klass_reg->as_register());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
151 __ call(RuntimeAddress(Runtime1::entry_for(_stub_id)));
a61af66fc99e Initial load
duke
parents:
diff changeset
152 ce->add_call_info_here(_info);
a61af66fc99e Initial load
duke
parents:
diff changeset
153 ce->verify_oop_map(_info);
a61af66fc99e Initial load
duke
parents:
diff changeset
154 assert(_result->as_register() == rax, "result must in rax,");
a61af66fc99e Initial load
duke
parents:
diff changeset
155 __ jmp(_continuation);
a61af66fc99e Initial load
duke
parents:
diff changeset
156 }
a61af66fc99e Initial load
duke
parents:
diff changeset
157
a61af66fc99e Initial load
duke
parents:
diff changeset
158
a61af66fc99e Initial load
duke
parents:
diff changeset
159 // Implementation of NewTypeArrayStub
a61af66fc99e Initial load
duke
parents:
diff changeset
160
a61af66fc99e Initial load
duke
parents:
diff changeset
161 NewTypeArrayStub::NewTypeArrayStub(LIR_Opr klass_reg, LIR_Opr length, LIR_Opr result, CodeEmitInfo* info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
162 _klass_reg = klass_reg;
a61af66fc99e Initial load
duke
parents:
diff changeset
163 _length = length;
a61af66fc99e Initial load
duke
parents:
diff changeset
164 _result = result;
a61af66fc99e Initial load
duke
parents:
diff changeset
165 _info = new CodeEmitInfo(info);
a61af66fc99e Initial load
duke
parents:
diff changeset
166 }
a61af66fc99e Initial load
duke
parents:
diff changeset
167
a61af66fc99e Initial load
duke
parents:
diff changeset
168
a61af66fc99e Initial load
duke
parents:
diff changeset
169 void NewTypeArrayStub::emit_code(LIR_Assembler* ce) {
a61af66fc99e Initial load
duke
parents:
diff changeset
170 assert(__ rsp_offset() == 0, "frame size should be fixed");
a61af66fc99e Initial load
duke
parents:
diff changeset
171 __ bind(_entry);
a61af66fc99e Initial load
duke
parents:
diff changeset
172 assert(_length->as_register() == rbx, "length must in rbx,");
a61af66fc99e Initial load
duke
parents:
diff changeset
173 assert(_klass_reg->as_register() == rdx, "klass_reg must in rdx");
a61af66fc99e Initial load
duke
parents:
diff changeset
174 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::new_type_array_id)));
a61af66fc99e Initial load
duke
parents:
diff changeset
175 ce->add_call_info_here(_info);
a61af66fc99e Initial load
duke
parents:
diff changeset
176 ce->verify_oop_map(_info);
a61af66fc99e Initial load
duke
parents:
diff changeset
177 assert(_result->as_register() == rax, "result must in rax,");
a61af66fc99e Initial load
duke
parents:
diff changeset
178 __ jmp(_continuation);
a61af66fc99e Initial load
duke
parents:
diff changeset
179 }
a61af66fc99e Initial load
duke
parents:
diff changeset
180
a61af66fc99e Initial load
duke
parents:
diff changeset
181
a61af66fc99e Initial load
duke
parents:
diff changeset
182 // Implementation of NewObjectArrayStub
a61af66fc99e Initial load
duke
parents:
diff changeset
183
a61af66fc99e Initial load
duke
parents:
diff changeset
184 NewObjectArrayStub::NewObjectArrayStub(LIR_Opr klass_reg, LIR_Opr length, LIR_Opr result, CodeEmitInfo* info) {
a61af66fc99e Initial load
duke
parents:
diff changeset
185 _klass_reg = klass_reg;
a61af66fc99e Initial load
duke
parents:
diff changeset
186 _result = result;
a61af66fc99e Initial load
duke
parents:
diff changeset
187 _length = length;
a61af66fc99e Initial load
duke
parents:
diff changeset
188 _info = new CodeEmitInfo(info);
a61af66fc99e Initial load
duke
parents:
diff changeset
189 }
a61af66fc99e Initial load
duke
parents:
diff changeset
190
a61af66fc99e Initial load
duke
parents:
diff changeset
191
a61af66fc99e Initial load
duke
parents:
diff changeset
192 void NewObjectArrayStub::emit_code(LIR_Assembler* ce) {
a61af66fc99e Initial load
duke
parents:
diff changeset
193 assert(__ rsp_offset() == 0, "frame size should be fixed");
a61af66fc99e Initial load
duke
parents:
diff changeset
194 __ bind(_entry);
a61af66fc99e Initial load
duke
parents:
diff changeset
195 assert(_length->as_register() == rbx, "length must in rbx,");
a61af66fc99e Initial load
duke
parents:
diff changeset
196 assert(_klass_reg->as_register() == rdx, "klass_reg must in rdx");
a61af66fc99e Initial load
duke
parents:
diff changeset
197 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::new_object_array_id)));
a61af66fc99e Initial load
duke
parents:
diff changeset
198 ce->add_call_info_here(_info);
a61af66fc99e Initial load
duke
parents:
diff changeset
199 ce->verify_oop_map(_info);
a61af66fc99e Initial load
duke
parents:
diff changeset
200 assert(_result->as_register() == rax, "result must in rax,");
a61af66fc99e Initial load
duke
parents:
diff changeset
201 __ jmp(_continuation);
a61af66fc99e Initial load
duke
parents:
diff changeset
202 }
a61af66fc99e Initial load
duke
parents:
diff changeset
203
a61af66fc99e Initial load
duke
parents:
diff changeset
204
a61af66fc99e Initial load
duke
parents:
diff changeset
205 // Implementation of MonitorAccessStubs
a61af66fc99e Initial load
duke
parents:
diff changeset
206
a61af66fc99e Initial load
duke
parents:
diff changeset
207 MonitorEnterStub::MonitorEnterStub(LIR_Opr obj_reg, LIR_Opr lock_reg, CodeEmitInfo* info)
a61af66fc99e Initial load
duke
parents:
diff changeset
208 : MonitorAccessStub(obj_reg, lock_reg)
a61af66fc99e Initial load
duke
parents:
diff changeset
209 {
a61af66fc99e Initial load
duke
parents:
diff changeset
210 _info = new CodeEmitInfo(info);
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 void MonitorEnterStub::emit_code(LIR_Assembler* ce) {
a61af66fc99e Initial load
duke
parents:
diff changeset
215 assert(__ rsp_offset() == 0, "frame size should be fixed");
a61af66fc99e Initial load
duke
parents:
diff changeset
216 __ bind(_entry);
a61af66fc99e Initial load
duke
parents:
diff changeset
217 ce->store_parameter(_obj_reg->as_register(), 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
218 ce->store_parameter(_lock_reg->as_register(), 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
219 Runtime1::StubID enter_id;
a61af66fc99e Initial load
duke
parents:
diff changeset
220 if (ce->compilation()->has_fpu_code()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
221 enter_id = Runtime1::monitorenter_id;
a61af66fc99e Initial load
duke
parents:
diff changeset
222 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
223 enter_id = Runtime1::monitorenter_nofpu_id;
a61af66fc99e Initial load
duke
parents:
diff changeset
224 }
a61af66fc99e Initial load
duke
parents:
diff changeset
225 __ call(RuntimeAddress(Runtime1::entry_for(enter_id)));
a61af66fc99e Initial load
duke
parents:
diff changeset
226 ce->add_call_info_here(_info);
a61af66fc99e Initial load
duke
parents:
diff changeset
227 ce->verify_oop_map(_info);
a61af66fc99e Initial load
duke
parents:
diff changeset
228 __ jmp(_continuation);
a61af66fc99e Initial load
duke
parents:
diff changeset
229 }
a61af66fc99e Initial load
duke
parents:
diff changeset
230
a61af66fc99e Initial load
duke
parents:
diff changeset
231
a61af66fc99e Initial load
duke
parents:
diff changeset
232 void MonitorExitStub::emit_code(LIR_Assembler* ce) {
a61af66fc99e Initial load
duke
parents:
diff changeset
233 __ bind(_entry);
a61af66fc99e Initial load
duke
parents:
diff changeset
234 if (_compute_lock) {
a61af66fc99e Initial load
duke
parents:
diff changeset
235 // lock_reg was destroyed by fast unlocking attempt => recompute it
a61af66fc99e Initial load
duke
parents:
diff changeset
236 ce->monitor_address(_monitor_ix, _lock_reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
237 }
a61af66fc99e Initial load
duke
parents:
diff changeset
238 ce->store_parameter(_lock_reg->as_register(), 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
239 // note: non-blocking leaf routine => no call info needed
a61af66fc99e Initial load
duke
parents:
diff changeset
240 Runtime1::StubID exit_id;
a61af66fc99e Initial load
duke
parents:
diff changeset
241 if (ce->compilation()->has_fpu_code()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
242 exit_id = Runtime1::monitorexit_id;
a61af66fc99e Initial load
duke
parents:
diff changeset
243 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
244 exit_id = Runtime1::monitorexit_nofpu_id;
a61af66fc99e Initial load
duke
parents:
diff changeset
245 }
a61af66fc99e Initial load
duke
parents:
diff changeset
246 __ call(RuntimeAddress(Runtime1::entry_for(exit_id)));
a61af66fc99e Initial load
duke
parents:
diff changeset
247 __ jmp(_continuation);
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 // Implementation of patching:
a61af66fc99e Initial load
duke
parents:
diff changeset
252 // - 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
253 // - Replace original code with a call to the stub
a61af66fc99e Initial load
duke
parents:
diff changeset
254 // At Runtime:
a61af66fc99e Initial load
duke
parents:
diff changeset
255 // - call to stub, jump to runtime
a61af66fc99e Initial load
duke
parents:
diff changeset
256 // - in runtime: preserve all registers (rspecially objects, i.e., source and destination object)
a61af66fc99e Initial load
duke
parents:
diff changeset
257 // - in runtime: after initializing class, restore original code, reexecute instruction
a61af66fc99e Initial load
duke
parents:
diff changeset
258
a61af66fc99e Initial load
duke
parents:
diff changeset
259 int PatchingStub::_patch_info_offset = -NativeGeneralJump::instruction_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
260
a61af66fc99e Initial load
duke
parents:
diff changeset
261 void PatchingStub::align_patch_site(MacroAssembler* masm) {
a61af66fc99e Initial load
duke
parents:
diff changeset
262 // We're patching a 5-7 byte instruction on intel and we need to
a61af66fc99e Initial load
duke
parents:
diff changeset
263 // make sure that we don't see a piece of the instruction. It
a61af66fc99e Initial load
duke
parents:
diff changeset
264 // appears mostly impossible on Intel to simply invalidate other
a61af66fc99e Initial load
duke
parents:
diff changeset
265 // processors caches and since they may do aggressive prefetch it's
a61af66fc99e Initial load
duke
parents:
diff changeset
266 // very hard to make a guess about what code might be in the icache.
a61af66fc99e Initial load
duke
parents:
diff changeset
267 // Force the instruction to be double word aligned so that it
a61af66fc99e Initial load
duke
parents:
diff changeset
268 // doesn't span a cache line.
a61af66fc99e Initial load
duke
parents:
diff changeset
269 masm->align(round_to(NativeGeneralJump::instruction_size, wordSize));
a61af66fc99e Initial load
duke
parents:
diff changeset
270 }
a61af66fc99e Initial load
duke
parents:
diff changeset
271
a61af66fc99e Initial load
duke
parents:
diff changeset
272 void PatchingStub::emit_code(LIR_Assembler* ce) {
a61af66fc99e Initial load
duke
parents:
diff changeset
273 assert(NativeCall::instruction_size <= _bytes_to_copy && _bytes_to_copy <= 0xFF, "not enough room for call");
a61af66fc99e Initial load
duke
parents:
diff changeset
274
a61af66fc99e Initial load
duke
parents:
diff changeset
275 Label call_patch;
a61af66fc99e Initial load
duke
parents:
diff changeset
276
a61af66fc99e Initial load
duke
parents:
diff changeset
277 // static field accesses have special semantics while the class
a61af66fc99e Initial load
duke
parents:
diff changeset
278 // initializer is being run so we emit a test which can be used to
a61af66fc99e Initial load
duke
parents:
diff changeset
279 // check that this code is being executed by the initializing
a61af66fc99e Initial load
duke
parents:
diff changeset
280 // thread.
a61af66fc99e Initial load
duke
parents:
diff changeset
281 address being_initialized_entry = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
282 if (CommentedAssembly) {
a61af66fc99e Initial load
duke
parents:
diff changeset
283 __ block_comment(" patch template");
a61af66fc99e Initial load
duke
parents:
diff changeset
284 }
a61af66fc99e Initial load
duke
parents:
diff changeset
285 if (_id == load_klass_id) {
a61af66fc99e Initial load
duke
parents:
diff changeset
286 // produce a copy of the load klass instruction for use by the being initialized case
a61af66fc99e Initial load
duke
parents:
diff changeset
287 address start = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
288 jobject o = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
289 __ movoop(_obj, o);
a61af66fc99e Initial load
duke
parents:
diff changeset
290 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
291 for (int i = 0; i < _bytes_to_copy; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
292 address ptr = (address)(_pc_start + i);
a61af66fc99e Initial load
duke
parents:
diff changeset
293 int a_byte = (*ptr) & 0xFF;
a61af66fc99e Initial load
duke
parents:
diff changeset
294 assert(a_byte == *start++, "should be the same code");
a61af66fc99e Initial load
duke
parents:
diff changeset
295 }
a61af66fc99e Initial load
duke
parents:
diff changeset
296 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
297 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
298 // make a copy the code which is going to be patched.
a61af66fc99e Initial load
duke
parents:
diff changeset
299 for ( int i = 0; i < _bytes_to_copy; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
300 address ptr = (address)(_pc_start + i);
a61af66fc99e Initial load
duke
parents:
diff changeset
301 int a_byte = (*ptr) & 0xFF;
a61af66fc99e Initial load
duke
parents:
diff changeset
302 __ a_byte (a_byte);
a61af66fc99e Initial load
duke
parents:
diff changeset
303 *ptr = 0x90; // make the site look like a nop
a61af66fc99e Initial load
duke
parents:
diff changeset
304 }
a61af66fc99e Initial load
duke
parents:
diff changeset
305 }
a61af66fc99e Initial load
duke
parents:
diff changeset
306
a61af66fc99e Initial load
duke
parents:
diff changeset
307 address end_of_patch = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
308 int bytes_to_skip = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
309 if (_id == load_klass_id) {
a61af66fc99e Initial load
duke
parents:
diff changeset
310 int offset = __ offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
311 if (CommentedAssembly) {
a61af66fc99e Initial load
duke
parents:
diff changeset
312 __ block_comment(" being_initialized check");
a61af66fc99e Initial load
duke
parents:
diff changeset
313 }
a61af66fc99e Initial load
duke
parents:
diff changeset
314 assert(_obj != noreg, "must be a valid register");
a61af66fc99e Initial load
duke
parents:
diff changeset
315 Register tmp = rax;
2376
c7f3d0b4570f 7017732: move static fields into Class to prepare for perm gen removal
never
parents: 2168
diff changeset
316 Register tmp2 = rbx;
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
317 __ push(tmp);
2376
c7f3d0b4570f 7017732: move static fields into Class to prepare for perm gen removal
never
parents: 2168
diff changeset
318 __ push(tmp2);
2464
d86923d96dca 7034967: C1: assert(false) failed: error (assembler_sparc.cpp:2043)
iveresov
parents: 2380
diff changeset
319 // Load without verification to keep code size small. We need it because
d86923d96dca 7034967: C1: assert(false) failed: error (assembler_sparc.cpp:2043)
iveresov
parents: 2380
diff changeset
320 // begin_initialized_entry_offset has to fit in a byte. Also, we know it's not null.
d86923d96dca 7034967: C1: assert(false) failed: error (assembler_sparc.cpp:2043)
iveresov
parents: 2380
diff changeset
321 __ load_heap_oop_not_null(tmp2, Address(_obj, java_lang_Class::klass_offset_in_bytes()));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
322 __ get_thread(tmp);
2376
c7f3d0b4570f 7017732: move static fields into Class to prepare for perm gen removal
never
parents: 2168
diff changeset
323 __ cmpptr(tmp, Address(tmp2, instanceKlass::init_thread_offset_in_bytes() + sizeof(klassOopDesc)));
c7f3d0b4570f 7017732: move static fields into Class to prepare for perm gen removal
never
parents: 2168
diff changeset
324 __ pop(tmp2);
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
325 __ pop(tmp);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
326 __ jcc(Assembler::notEqual, call_patch);
a61af66fc99e Initial load
duke
parents:
diff changeset
327
a61af66fc99e Initial load
duke
parents:
diff changeset
328 // access_field patches may execute the patched code before it's
a61af66fc99e Initial load
duke
parents:
diff changeset
329 // copied back into place so we need to jump back into the main
a61af66fc99e Initial load
duke
parents:
diff changeset
330 // code of the nmethod to continue execution.
a61af66fc99e Initial load
duke
parents:
diff changeset
331 __ jmp(_patch_site_continuation);
a61af66fc99e Initial load
duke
parents:
diff changeset
332
a61af66fc99e Initial load
duke
parents:
diff changeset
333 // make sure this extra code gets skipped
a61af66fc99e Initial load
duke
parents:
diff changeset
334 bytes_to_skip += __ offset() - offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
335 }
a61af66fc99e Initial load
duke
parents:
diff changeset
336 if (CommentedAssembly) {
a61af66fc99e Initial load
duke
parents:
diff changeset
337 __ block_comment("patch data encoded as movl");
a61af66fc99e Initial load
duke
parents:
diff changeset
338 }
a61af66fc99e Initial load
duke
parents:
diff changeset
339 // Now emit the patch record telling the runtime how to find the
a61af66fc99e Initial load
duke
parents:
diff changeset
340 // pieces of the patch. We only need 3 bytes but for readability of
a61af66fc99e Initial load
duke
parents:
diff changeset
341 // the disassembly we make the data look like a movl reg, imm32,
a61af66fc99e Initial load
duke
parents:
diff changeset
342 // which requires 5 bytes
a61af66fc99e Initial load
duke
parents:
diff changeset
343 int sizeof_patch_record = 5;
a61af66fc99e Initial load
duke
parents:
diff changeset
344 bytes_to_skip += sizeof_patch_record;
a61af66fc99e Initial load
duke
parents:
diff changeset
345
a61af66fc99e Initial load
duke
parents:
diff changeset
346 // emit the offsets needed to find the code to patch
a61af66fc99e Initial load
duke
parents:
diff changeset
347 int being_initialized_entry_offset = __ pc() - being_initialized_entry + sizeof_patch_record;
a61af66fc99e Initial load
duke
parents:
diff changeset
348
a61af66fc99e Initial load
duke
parents:
diff changeset
349 __ a_byte(0xB8);
a61af66fc99e Initial load
duke
parents:
diff changeset
350 __ a_byte(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
351 __ a_byte(being_initialized_entry_offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
352 __ a_byte(bytes_to_skip);
a61af66fc99e Initial load
duke
parents:
diff changeset
353 __ a_byte(_bytes_to_copy);
a61af66fc99e Initial load
duke
parents:
diff changeset
354 address patch_info_pc = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
355 assert(patch_info_pc - end_of_patch == bytes_to_skip, "incorrect patch info");
a61af66fc99e Initial load
duke
parents:
diff changeset
356
a61af66fc99e Initial load
duke
parents:
diff changeset
357 address entry = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
358 NativeGeneralJump::insert_unconditional((address)_pc_start, entry);
a61af66fc99e Initial load
duke
parents:
diff changeset
359 address target = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
360 switch (_id) {
a61af66fc99e Initial load
duke
parents:
diff changeset
361 case access_field_id: target = Runtime1::entry_for(Runtime1::access_field_patching_id); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
362 case load_klass_id: target = Runtime1::entry_for(Runtime1::load_klass_patching_id); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
363 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
364 }
a61af66fc99e Initial load
duke
parents:
diff changeset
365 __ bind(call_patch);
a61af66fc99e Initial load
duke
parents:
diff changeset
366
a61af66fc99e Initial load
duke
parents:
diff changeset
367 if (CommentedAssembly) {
a61af66fc99e Initial load
duke
parents:
diff changeset
368 __ block_comment("patch entry point");
a61af66fc99e Initial load
duke
parents:
diff changeset
369 }
a61af66fc99e Initial load
duke
parents:
diff changeset
370 __ call(RuntimeAddress(target));
a61af66fc99e Initial load
duke
parents:
diff changeset
371 assert(_patch_info_offset == (patch_info_pc - __ pc()), "must not change");
a61af66fc99e Initial load
duke
parents:
diff changeset
372 ce->add_call_info_here(_info);
a61af66fc99e Initial load
duke
parents:
diff changeset
373 int jmp_off = __ offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
374 __ jmp(_patch_site_entry);
a61af66fc99e Initial load
duke
parents:
diff changeset
375 // Add enough nops so deoptimization can overwrite the jmp above with a call
a61af66fc99e Initial load
duke
parents:
diff changeset
376 // and not destroy the world.
a61af66fc99e Initial load
duke
parents:
diff changeset
377 for (int j = __ offset() ; j < jmp_off + 5 ; j++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
378 __ nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
379 }
a61af66fc99e Initial load
duke
parents:
diff changeset
380 if (_id == load_klass_id) {
a61af66fc99e Initial load
duke
parents:
diff changeset
381 CodeSection* cs = __ code_section();
a61af66fc99e Initial load
duke
parents:
diff changeset
382 RelocIterator iter(cs, (address)_pc_start, (address)(_pc_start + 1));
a61af66fc99e Initial load
duke
parents:
diff changeset
383 relocInfo::change_reloc_info_for_address(&iter, (address) _pc_start, relocInfo::oop_type, relocInfo::none);
a61af66fc99e Initial load
duke
parents:
diff changeset
384 }
a61af66fc99e Initial load
duke
parents:
diff changeset
385 }
a61af66fc99e Initial load
duke
parents:
diff changeset
386
a61af66fc99e Initial load
duke
parents:
diff changeset
387
1295
3cf667df43ef 6919934: JSR 292 needs to support x86 C1
twisti
parents: 380
diff changeset
388 void DeoptimizeStub::emit_code(LIR_Assembler* ce) {
3cf667df43ef 6919934: JSR 292 needs to support x86 C1
twisti
parents: 380
diff changeset
389 __ bind(_entry);
4048
cec1757a0134 7102657: JSR 292: C1 deoptimizes unlinked invokedynamic call sites infinitely
twisti
parents: 3260
diff changeset
390 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::deoptimize_id)));
1295
3cf667df43ef 6919934: JSR 292 needs to support x86 C1
twisti
parents: 380
diff changeset
391 ce->add_call_info_here(_info);
4048
cec1757a0134 7102657: JSR 292: C1 deoptimizes unlinked invokedynamic call sites infinitely
twisti
parents: 3260
diff changeset
392 DEBUG_ONLY(__ should_not_reach_here());
1295
3cf667df43ef 6919934: JSR 292 needs to support x86 C1
twisti
parents: 380
diff changeset
393 }
3cf667df43ef 6919934: JSR 292 needs to support x86 C1
twisti
parents: 380
diff changeset
394
3cf667df43ef 6919934: JSR 292 needs to support x86 C1
twisti
parents: 380
diff changeset
395
0
a61af66fc99e Initial load
duke
parents:
diff changeset
396 void ImplicitNullCheckStub::emit_code(LIR_Assembler* ce) {
a61af66fc99e Initial load
duke
parents:
diff changeset
397 ce->compilation()->implicit_exception_table()->append(_offset, __ offset());
a61af66fc99e Initial load
duke
parents:
diff changeset
398 __ bind(_entry);
a61af66fc99e Initial load
duke
parents:
diff changeset
399 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::throw_null_pointer_exception_id)));
a61af66fc99e Initial load
duke
parents:
diff changeset
400 ce->add_call_info_here(_info);
a61af66fc99e Initial load
duke
parents:
diff changeset
401 debug_only(__ should_not_reach_here());
a61af66fc99e Initial load
duke
parents:
diff changeset
402 }
a61af66fc99e Initial load
duke
parents:
diff changeset
403
a61af66fc99e Initial load
duke
parents:
diff changeset
404
a61af66fc99e Initial load
duke
parents:
diff changeset
405 void SimpleExceptionStub::emit_code(LIR_Assembler* ce) {
a61af66fc99e Initial load
duke
parents:
diff changeset
406 assert(__ rsp_offset() == 0, "frame size should be fixed");
a61af66fc99e Initial load
duke
parents:
diff changeset
407
a61af66fc99e Initial load
duke
parents:
diff changeset
408 __ bind(_entry);
a61af66fc99e Initial load
duke
parents:
diff changeset
409 // pass the object on stack because all registers must be preserved
a61af66fc99e Initial load
duke
parents:
diff changeset
410 if (_obj->is_cpu_register()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
411 ce->store_parameter(_obj->as_register(), 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
412 }
a61af66fc99e Initial load
duke
parents:
diff changeset
413 __ call(RuntimeAddress(Runtime1::entry_for(_stub)));
a61af66fc99e Initial load
duke
parents:
diff changeset
414 ce->add_call_info_here(_info);
a61af66fc99e Initial load
duke
parents:
diff changeset
415 debug_only(__ should_not_reach_here());
a61af66fc99e Initial load
duke
parents:
diff changeset
416 }
a61af66fc99e Initial load
duke
parents:
diff changeset
417
a61af66fc99e Initial load
duke
parents:
diff changeset
418
a61af66fc99e Initial load
duke
parents:
diff changeset
419 void ArrayCopyStub::emit_code(LIR_Assembler* ce) {
a61af66fc99e Initial load
duke
parents:
diff changeset
420 //---------------slow case: call to native-----------------
a61af66fc99e Initial load
duke
parents:
diff changeset
421 __ bind(_entry);
a61af66fc99e Initial load
duke
parents:
diff changeset
422 // Figure out where the args should go
a61af66fc99e Initial load
duke
parents:
diff changeset
423 // This should really convert the IntrinsicID to the methodOop and signature
a61af66fc99e Initial load
duke
parents:
diff changeset
424 // but I don't know how to do that.
a61af66fc99e Initial load
duke
parents:
diff changeset
425 //
a61af66fc99e Initial load
duke
parents:
diff changeset
426 VMRegPair args[5];
a61af66fc99e Initial load
duke
parents:
diff changeset
427 BasicType signature[5] = { T_OBJECT, T_INT, T_OBJECT, T_INT, T_INT};
a61af66fc99e Initial load
duke
parents:
diff changeset
428 SharedRuntime::java_calling_convention(signature, args, 5, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
429
a61af66fc99e Initial load
duke
parents:
diff changeset
430 // push parameters
a61af66fc99e Initial load
duke
parents:
diff changeset
431 // (src, src_pos, dest, destPos, length)
a61af66fc99e Initial load
duke
parents:
diff changeset
432 Register r[5];
a61af66fc99e Initial load
duke
parents:
diff changeset
433 r[0] = src()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
434 r[1] = src_pos()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
435 r[2] = dst()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
436 r[3] = dst_pos()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
437 r[4] = length()->as_register();
a61af66fc99e Initial load
duke
parents:
diff changeset
438
a61af66fc99e Initial load
duke
parents:
diff changeset
439 // next registers will get stored on the stack
a61af66fc99e Initial load
duke
parents:
diff changeset
440 for (int i = 0; i < 5 ; i++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
441 VMReg r_1 = args[i].first();
a61af66fc99e Initial load
duke
parents:
diff changeset
442 if (r_1->is_stack()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
443 int st_off = r_1->reg2stack() * wordSize;
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
444 __ movptr (Address(rsp, st_off), r[i]);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
445 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
446 assert(r[i] == args[i].first()->as_Register(), "Wrong register for arg ");
a61af66fc99e Initial load
duke
parents:
diff changeset
447 }
a61af66fc99e Initial load
duke
parents:
diff changeset
448 }
a61af66fc99e Initial load
duke
parents:
diff changeset
449
a61af66fc99e Initial load
duke
parents:
diff changeset
450 ce->align_call(lir_static_call);
a61af66fc99e Initial load
duke
parents:
diff changeset
451
a61af66fc99e Initial load
duke
parents:
diff changeset
452 ce->emit_static_call_stub();
a61af66fc99e Initial load
duke
parents:
diff changeset
453 AddressLiteral resolve(SharedRuntime::get_resolve_static_call_stub(),
a61af66fc99e Initial load
duke
parents:
diff changeset
454 relocInfo::static_call_type);
a61af66fc99e Initial load
duke
parents:
diff changeset
455 __ call(resolve);
a61af66fc99e Initial load
duke
parents:
diff changeset
456 ce->add_call_info_here(info());
a61af66fc99e Initial load
duke
parents:
diff changeset
457
a61af66fc99e Initial load
duke
parents:
diff changeset
458 #ifndef PRODUCT
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
459 __ incrementl(ExternalAddress((address)&Runtime1::_arraycopy_slowcase_cnt));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
460 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
461
a61af66fc99e Initial load
duke
parents:
diff changeset
462 __ jmp(_continuation);
a61af66fc99e Initial load
duke
parents:
diff changeset
463 }
a61af66fc99e Initial load
duke
parents:
diff changeset
464
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
465 /////////////////////////////////////////////////////////////////////////////
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
466 #ifndef SERIALGC
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 void G1PreBarrierStub::emit_code(LIR_Assembler* ce) {
3249
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
469 // At this point we know that marking is in progress.
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
470 // If do_load() is true then we have to emit the
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
471 // load of the previous value; otherwise it has already
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
472 // been loaded into _pre_val.
342
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
3249
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
479 if (do_load()) {
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
480 ce->mem2reg(addr(), pre_val(), T_OBJECT, patch_code(), info(), false /*wide*/, false /*unaligned*/);
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
481 }
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
482
362
apetrusenko
parents: 304 342
diff changeset
483 __ cmpptr(pre_val_reg, (int32_t) NULL_WORD);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
484 __ jcc(Assembler::equal, _continuation);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
485 ce->store_parameter(pre_val()->as_register(), 0);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
486 __ 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
487 __ jmp(_continuation);
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 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
490
3249
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
491 void G1UnsafeGetObjSATBBarrierStub::emit_code(LIR_Assembler* ce) {
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
492 // At this point we know that offset == referent_offset.
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
493 //
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
494 // So we might have to emit:
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
495 // if (src == null) goto continuation.
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
496 //
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
497 // and we definitely have to emit:
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
498 // if (klass(src).reference_type == REF_NONE) goto continuation
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
499 // if (!marking_active) goto continuation
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
500 // if (pre_val == null) goto continuation
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
501 // call pre_barrier(pre_val)
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
502 // goto continuation
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
503 //
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
504 __ bind(_entry);
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
505
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
506 assert(src()->is_register(), "sanity");
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
507 Register src_reg = src()->as_register();
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
508
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
509 if (gen_src_check()) {
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
510 // The original src operand was not a constant.
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
511 // Generate src == null?
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
512 __ cmpptr(src_reg, (int32_t) NULL_WORD);
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
513 __ jcc(Assembler::equal, _continuation);
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
514 }
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
515
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
516 // Generate src->_klass->_reference_type == REF_NONE)?
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
517 assert(tmp()->is_register(), "sanity");
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
518 Register tmp_reg = tmp()->as_register();
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
519
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
520 __ load_klass(tmp_reg, src_reg);
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
521
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
522 Address ref_type_adr(tmp_reg, instanceKlass::reference_type_offset_in_bytes() + sizeof(oopDesc));
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
523 __ cmpl(ref_type_adr, REF_NONE);
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
524 __ jcc(Assembler::equal, _continuation);
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
525
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
526 // Is marking active?
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
527 assert(thread()->is_register(), "precondition");
3260
527b586edf24 7036706: G1: Use LIR_OprDesc::as_pointer_register in code changes for 7035117
johnc
parents: 3255
diff changeset
528 Register thread_reg = thread()->as_pointer_register();
3249
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
529
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
530 Address in_progress(thread_reg, in_bytes(JavaThread::satb_mark_queue_offset() +
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
531 PtrQueue::byte_offset_of_active()));
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
532
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
533 if (in_bytes(PtrQueue::byte_width_of_active()) == 4) {
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
534 __ cmpl(in_progress, 0);
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
535 } else {
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
536 assert(in_bytes(PtrQueue::byte_width_of_active()) == 1, "Assumption");
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
537 __ cmpb(in_progress, 0);
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
538 }
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
539 __ jcc(Assembler::equal, _continuation);
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
540
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
541 // val == null?
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
542 assert(val()->is_register(), "Precondition.");
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
543 Register val_reg = val()->as_register();
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
544
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
545 __ cmpptr(val_reg, (int32_t) NULL_WORD);
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
546 __ jcc(Assembler::equal, _continuation);
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
547
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
548 ce->store_parameter(val()->as_register(), 0);
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
549 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::g1_pre_barrier_slow_id)));
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
550 __ jmp(_continuation);
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
551 }
e1162778c1c8 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 2380
diff changeset
552
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
553 jbyte* G1PostBarrierStub::_byte_map_base = NULL;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
554
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
555 jbyte* G1PostBarrierStub::byte_map_base_slow() {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
556 BarrierSet* bs = Universe::heap()->barrier_set();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
557 assert(bs->is_a(BarrierSet::G1SATBCTLogging),
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
558 "Must be if we're using this.");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
559 return ((G1SATBCardTableModRefBS*)bs)->byte_map_base;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
560 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
561
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
562 void G1PostBarrierStub::emit_code(LIR_Assembler* ce) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
563 __ bind(_entry);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
564 assert(addr()->is_register(), "Precondition.");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
565 assert(new_val()->is_register(), "Precondition.");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
566 Register new_val_reg = new_val()->as_register();
362
apetrusenko
parents: 304 342
diff changeset
567 __ cmpptr(new_val_reg, (int32_t) NULL_WORD);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
568 __ jcc(Assembler::equal, _continuation);
1873
07a218de38cb 6992477: fix for 6991512 broke sparc barriers
never
parents: 1819
diff changeset
569 ce->store_parameter(addr()->as_pointer_register(), 0);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
570 __ 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
571 __ jmp(_continuation);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
572 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
573
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
574 #endif // SERIALGC
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
575 /////////////////////////////////////////////////////////////////////////////
0
a61af66fc99e Initial load
duke
parents:
diff changeset
576
a61af66fc99e Initial load
duke
parents:
diff changeset
577 #undef __