annotate src/cpu/sparc/vm/c1_MacroAssembler_sparc.cpp @ 17524:89152779163c

Merge with jdk8-b132
author Gilles Duboscq <duboscq@ssw.jku.at>
date Wed, 15 Oct 2014 11:59:32 +0200
parents 4ca6dc0799b6
children 52b4284cb496
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
17524
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14909
diff changeset
2 * Copyright (c) 1999, 2013, 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: 1552
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #include "c1/c1_MacroAssembler.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27 #include "c1/c1_Runtime1.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "classfile/systemDictionary.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "gc_interface/collectedHeap.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "interpreter/interpreter.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31 #include "oops/arrayOop.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
32 #include "oops/markOop.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
33 #include "runtime/basicLock.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
34 #include "runtime/biasedLocking.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
35 #include "runtime/os.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
36 #include "runtime/stubRoutines.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
37
a61af66fc99e Initial load
duke
parents:
diff changeset
38 void C1_MacroAssembler::inline_cache_check(Register receiver, Register iCache) {
a61af66fc99e Initial load
duke
parents:
diff changeset
39 Label L;
a61af66fc99e Initial load
duke
parents:
diff changeset
40 const Register temp_reg = G3_scratch;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 // Note: needs more testing of out-of-line vs. inline slow case
a61af66fc99e Initial load
duke
parents:
diff changeset
42 verify_oop(receiver);
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
43 load_klass(receiver, temp_reg);
3839
3d42f82cd811 7063628: Use cbcond on T4
kvn
parents: 2468
diff changeset
44 cmp_and_brx_short(temp_reg, iCache, Assembler::equal, Assembler::pt, L);
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 196
diff changeset
45 AddressLiteral ic_miss(SharedRuntime::get_ic_miss_stub());
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 196
diff changeset
46 jump_to(ic_miss, temp_reg);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
47 delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
48 align(CodeEntryAlignment);
a61af66fc99e Initial load
duke
parents:
diff changeset
49 bind(L);
a61af66fc99e Initial load
duke
parents:
diff changeset
50 }
a61af66fc99e Initial load
duke
parents:
diff changeset
51
a61af66fc99e Initial load
duke
parents:
diff changeset
52
a61af66fc99e Initial load
duke
parents:
diff changeset
53 void C1_MacroAssembler::explicit_null_check(Register base) {
a61af66fc99e Initial load
duke
parents:
diff changeset
54 Unimplemented();
a61af66fc99e Initial load
duke
parents:
diff changeset
55 }
a61af66fc99e Initial load
duke
parents:
diff changeset
56
a61af66fc99e Initial load
duke
parents:
diff changeset
57
a61af66fc99e Initial load
duke
parents:
diff changeset
58 void C1_MacroAssembler::build_frame(int frame_size_in_bytes) {
a61af66fc99e Initial load
duke
parents:
diff changeset
59
a61af66fc99e Initial load
duke
parents:
diff changeset
60 generate_stack_overflow_check(frame_size_in_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // Create the frame.
a61af66fc99e Initial load
duke
parents:
diff changeset
62 save_frame_c1(frame_size_in_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
63 }
a61af66fc99e Initial load
duke
parents:
diff changeset
64
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 void C1_MacroAssembler::unverified_entry(Register receiver, Register ic_klass) {
a61af66fc99e Initial load
duke
parents:
diff changeset
67 if (C1Breakpoint) breakpoint_trap();
a61af66fc99e Initial load
duke
parents:
diff changeset
68 inline_cache_check(receiver, ic_klass);
a61af66fc99e Initial load
duke
parents:
diff changeset
69 }
a61af66fc99e Initial load
duke
parents:
diff changeset
70
a61af66fc99e Initial load
duke
parents:
diff changeset
71
a61af66fc99e Initial load
duke
parents:
diff changeset
72 void C1_MacroAssembler::verified_entry() {
a61af66fc99e Initial load
duke
parents:
diff changeset
73 if (C1Breakpoint) breakpoint_trap();
a61af66fc99e Initial load
duke
parents:
diff changeset
74 // build frame
a61af66fc99e Initial load
duke
parents:
diff changeset
75 verify_FPU(0, "method_entry");
a61af66fc99e Initial load
duke
parents:
diff changeset
76 }
a61af66fc99e Initial load
duke
parents:
diff changeset
77
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 void C1_MacroAssembler::lock_object(Register Rmark, Register Roop, Register Rbox, Register Rscratch, Label& slow_case) {
a61af66fc99e Initial load
duke
parents:
diff changeset
80 assert_different_registers(Rmark, Roop, Rbox, Rscratch);
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82 Label done;
a61af66fc99e Initial load
duke
parents:
diff changeset
83
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 196
diff changeset
84 Address mark_addr(Roop, oopDesc::mark_offset_in_bytes());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86 // The following move must be the first instruction of emitted since debug
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // information may be generated for it.
a61af66fc99e Initial load
duke
parents:
diff changeset
88 // Load object header
a61af66fc99e Initial load
duke
parents:
diff changeset
89 ld_ptr(mark_addr, Rmark);
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91 verify_oop(Roop);
a61af66fc99e Initial load
duke
parents:
diff changeset
92
a61af66fc99e Initial load
duke
parents:
diff changeset
93 // save object being locked into the BasicObjectLock
a61af66fc99e Initial load
duke
parents:
diff changeset
94 st_ptr(Roop, Rbox, BasicObjectLock::obj_offset_in_bytes());
a61af66fc99e Initial load
duke
parents:
diff changeset
95
a61af66fc99e Initial load
duke
parents:
diff changeset
96 if (UseBiasedLocking) {
a61af66fc99e Initial load
duke
parents:
diff changeset
97 biased_locking_enter(Roop, Rmark, Rscratch, done, &slow_case);
a61af66fc99e Initial load
duke
parents:
diff changeset
98 }
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 // Save Rbox in Rscratch to be used for the cas operation
a61af66fc99e Initial load
duke
parents:
diff changeset
101 mov(Rbox, Rscratch);
a61af66fc99e Initial load
duke
parents:
diff changeset
102
a61af66fc99e Initial load
duke
parents:
diff changeset
103 // and mark it unlocked
a61af66fc99e Initial load
duke
parents:
diff changeset
104 or3(Rmark, markOopDesc::unlocked_value, Rmark);
a61af66fc99e Initial load
duke
parents:
diff changeset
105
a61af66fc99e Initial load
duke
parents:
diff changeset
106 // save unlocked object header into the displaced header location on the stack
a61af66fc99e Initial load
duke
parents:
diff changeset
107 st_ptr(Rmark, Rbox, BasicLock::displaced_header_offset_in_bytes());
a61af66fc99e Initial load
duke
parents:
diff changeset
108
a61af66fc99e Initial load
duke
parents:
diff changeset
109 // compare object markOop with Rmark and if equal exchange Rscratch with object markOop
a61af66fc99e Initial load
duke
parents:
diff changeset
110 assert(mark_addr.disp() == 0, "cas must take a zero displacement");
10997
46c544b8fbfc 8008407: remove SPARC V8 support
morris
parents: 6848
diff changeset
111 cas_ptr(mark_addr.base(), Rmark, Rscratch);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
112 // if compare/exchange succeeded we found an unlocked object and we now have locked it
a61af66fc99e Initial load
duke
parents:
diff changeset
113 // hence we are done
a61af66fc99e Initial load
duke
parents:
diff changeset
114 cmp(Rmark, Rscratch);
a61af66fc99e Initial load
duke
parents:
diff changeset
115 brx(Assembler::equal, false, Assembler::pt, done);
a61af66fc99e Initial load
duke
parents:
diff changeset
116 delayed()->sub(Rscratch, SP, Rscratch); //pull next instruction into delay slot
a61af66fc99e Initial load
duke
parents:
diff changeset
117 // we did not find an unlocked object so see if this is a recursive case
a61af66fc99e Initial load
duke
parents:
diff changeset
118 // sub(Rscratch, SP, Rscratch);
a61af66fc99e Initial load
duke
parents:
diff changeset
119 assert(os::vm_page_size() > 0xfff, "page size too small - change the constant");
a61af66fc99e Initial load
duke
parents:
diff changeset
120 andcc(Rscratch, 0xfffff003, Rscratch);
a61af66fc99e Initial load
duke
parents:
diff changeset
121 brx(Assembler::notZero, false, Assembler::pn, slow_case);
a61af66fc99e Initial load
duke
parents:
diff changeset
122 delayed()->st_ptr(Rscratch, Rbox, BasicLock::displaced_header_offset_in_bytes());
a61af66fc99e Initial load
duke
parents:
diff changeset
123 bind(done);
a61af66fc99e Initial load
duke
parents:
diff changeset
124 }
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126
a61af66fc99e Initial load
duke
parents:
diff changeset
127 void C1_MacroAssembler::unlock_object(Register Rmark, Register Roop, Register Rbox, Label& slow_case) {
a61af66fc99e Initial load
duke
parents:
diff changeset
128 assert_different_registers(Rmark, Roop, Rbox);
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130 Label done;
a61af66fc99e Initial load
duke
parents:
diff changeset
131
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 196
diff changeset
132 Address mark_addr(Roop, oopDesc::mark_offset_in_bytes());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
133 assert(mark_addr.disp() == 0, "cas must take a zero displacement");
a61af66fc99e Initial load
duke
parents:
diff changeset
134
a61af66fc99e Initial load
duke
parents:
diff changeset
135 if (UseBiasedLocking) {
a61af66fc99e Initial load
duke
parents:
diff changeset
136 // load the object out of the BasicObjectLock
a61af66fc99e Initial load
duke
parents:
diff changeset
137 ld_ptr(Rbox, BasicObjectLock::obj_offset_in_bytes(), Roop);
a61af66fc99e Initial load
duke
parents:
diff changeset
138 verify_oop(Roop);
a61af66fc99e Initial load
duke
parents:
diff changeset
139 biased_locking_exit(mark_addr, Rmark, done);
a61af66fc99e Initial load
duke
parents:
diff changeset
140 }
a61af66fc99e Initial load
duke
parents:
diff changeset
141 // Test first it it is a fast recursive unlock
a61af66fc99e Initial load
duke
parents:
diff changeset
142 ld_ptr(Rbox, BasicLock::displaced_header_offset_in_bytes(), Rmark);
3839
3d42f82cd811 7063628: Use cbcond on T4
kvn
parents: 2468
diff changeset
143 br_null_short(Rmark, Assembler::pt, done);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
144 if (!UseBiasedLocking) {
a61af66fc99e Initial load
duke
parents:
diff changeset
145 // load object
a61af66fc99e Initial load
duke
parents:
diff changeset
146 ld_ptr(Rbox, BasicObjectLock::obj_offset_in_bytes(), Roop);
a61af66fc99e Initial load
duke
parents:
diff changeset
147 verify_oop(Roop);
a61af66fc99e Initial load
duke
parents:
diff changeset
148 }
a61af66fc99e Initial load
duke
parents:
diff changeset
149
a61af66fc99e Initial load
duke
parents:
diff changeset
150 // Check if it is still a light weight lock, this is is true if we see
a61af66fc99e Initial load
duke
parents:
diff changeset
151 // the stack address of the basicLock in the markOop of the object
10997
46c544b8fbfc 8008407: remove SPARC V8 support
morris
parents: 6848
diff changeset
152 cas_ptr(mark_addr.base(), Rbox, Rmark);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
153 cmp(Rbox, Rmark);
a61af66fc99e Initial load
duke
parents:
diff changeset
154
a61af66fc99e Initial load
duke
parents:
diff changeset
155 brx(Assembler::notEqual, false, Assembler::pn, slow_case);
a61af66fc99e Initial load
duke
parents:
diff changeset
156 delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
157 // Done
a61af66fc99e Initial load
duke
parents:
diff changeset
158 bind(done);
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 C1_MacroAssembler::try_allocate(
a61af66fc99e Initial load
duke
parents:
diff changeset
163 Register obj, // result: pointer to object after successful allocation
a61af66fc99e Initial load
duke
parents:
diff changeset
164 Register var_size_in_bytes, // object size in bytes if unknown at compile time; invalid otherwise
a61af66fc99e Initial load
duke
parents:
diff changeset
165 int con_size_in_bytes, // object size in bytes if known at compile time
2100
b1a2afa37ec4 7003271: Hotspot should track cumulative Java heap bytes allocated on a per-thread basis
phh
parents: 2002
diff changeset
166 Register t1, // temp register, must be global register for incr_allocated_bytes
0
a61af66fc99e Initial load
duke
parents:
diff changeset
167 Register t2, // temp register
a61af66fc99e Initial load
duke
parents:
diff changeset
168 Label& slow_case // continuation point if fast allocation fails
a61af66fc99e Initial load
duke
parents:
diff changeset
169 ) {
2127
5577848f5923 7011463: Sparc MacroAssembler::incr_allocated_bytes() needs a RegisterOrConstant argument
phh
parents: 2100
diff changeset
170 RegisterOrConstant size_in_bytes = var_size_in_bytes->is_valid()
5577848f5923 7011463: Sparc MacroAssembler::incr_allocated_bytes() needs a RegisterOrConstant argument
phh
parents: 2100
diff changeset
171 ? RegisterOrConstant(var_size_in_bytes) : RegisterOrConstant(con_size_in_bytes);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
172 if (UseTLAB) {
a61af66fc99e Initial load
duke
parents:
diff changeset
173 tlab_allocate(obj, var_size_in_bytes, con_size_in_bytes, t1, slow_case);
a61af66fc99e Initial load
duke
parents:
diff changeset
174 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
175 eden_allocate(obj, var_size_in_bytes, con_size_in_bytes, t1, t2, slow_case);
2127
5577848f5923 7011463: Sparc MacroAssembler::incr_allocated_bytes() needs a RegisterOrConstant argument
phh
parents: 2100
diff changeset
176 incr_allocated_bytes(size_in_bytes, t1, t2);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
177 }
a61af66fc99e Initial load
duke
parents:
diff changeset
178 }
a61af66fc99e Initial load
duke
parents:
diff changeset
179
a61af66fc99e Initial load
duke
parents:
diff changeset
180
a61af66fc99e Initial load
duke
parents:
diff changeset
181 void C1_MacroAssembler::initialize_header(Register obj, Register klass, Register len, Register t1, Register t2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
182 assert_different_registers(obj, klass, len, t1, t2);
a61af66fc99e Initial load
duke
parents:
diff changeset
183 if (UseBiasedLocking && !len->is_valid()) {
4762
069ab3f976d3 7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents: 3839
diff changeset
184 ld_ptr(klass, in_bytes(Klass::prototype_header_offset()), t1);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
185 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
186 set((intx)markOopDesc::prototype(), t1);
a61af66fc99e Initial load
duke
parents:
diff changeset
187 }
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
188 st_ptr(t1, obj, oopDesc::mark_offset_in_bytes());
12226
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 10997
diff changeset
189 if (UseCompressedClassPointers) {
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
190 // Save klass
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
191 mov(klass, t1);
6848
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6725
diff changeset
192 encode_klass_not_null(t1);
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
193 stw(t1, obj, oopDesc::klass_offset_in_bytes());
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
194 } else {
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
195 st_ptr(klass, obj, oopDesc::klass_offset_in_bytes());
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
196 }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 4762
diff changeset
197 if (len->is_valid()) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 4762
diff changeset
198 st(len, obj, arrayOopDesc::length_offset_in_bytes());
12226
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 10997
diff changeset
199 } else if (UseCompressedClassPointers) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 4762
diff changeset
200 // otherwise length is in the class gap
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
201 store_klass_gap(G0, obj);
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
202 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
203 }
a61af66fc99e Initial load
duke
parents:
diff changeset
204
a61af66fc99e Initial load
duke
parents:
diff changeset
205
a61af66fc99e Initial load
duke
parents:
diff changeset
206 void C1_MacroAssembler::initialize_body(Register base, Register index) {
a61af66fc99e Initial load
duke
parents:
diff changeset
207 assert_different_registers(base, index);
a61af66fc99e Initial load
duke
parents:
diff changeset
208 Label loop;
a61af66fc99e Initial load
duke
parents:
diff changeset
209 bind(loop);
a61af66fc99e Initial load
duke
parents:
diff changeset
210 subcc(index, HeapWordSize, index);
a61af66fc99e Initial load
duke
parents:
diff changeset
211 brx(Assembler::greaterEqual, true, Assembler::pt, loop);
a61af66fc99e Initial load
duke
parents:
diff changeset
212 delayed()->st_ptr(G0, base, index);
a61af66fc99e Initial load
duke
parents:
diff changeset
213 }
a61af66fc99e Initial load
duke
parents:
diff changeset
214
a61af66fc99e Initial load
duke
parents:
diff changeset
215
a61af66fc99e Initial load
duke
parents:
diff changeset
216 void C1_MacroAssembler::allocate_object(
a61af66fc99e Initial load
duke
parents:
diff changeset
217 Register obj, // result: pointer to object after successful allocation
a61af66fc99e Initial load
duke
parents:
diff changeset
218 Register t1, // temp register
2100
b1a2afa37ec4 7003271: Hotspot should track cumulative Java heap bytes allocated on a per-thread basis
phh
parents: 2002
diff changeset
219 Register t2, // temp register, must be a global register for try_allocate
0
a61af66fc99e Initial load
duke
parents:
diff changeset
220 Register t3, // temp register
a61af66fc99e Initial load
duke
parents:
diff changeset
221 int hdr_size, // object header size in words
a61af66fc99e Initial load
duke
parents:
diff changeset
222 int obj_size, // object size in words
a61af66fc99e Initial load
duke
parents:
diff changeset
223 Register klass, // object klass
a61af66fc99e Initial load
duke
parents:
diff changeset
224 Label& slow_case // continuation point if fast allocation fails
a61af66fc99e Initial load
duke
parents:
diff changeset
225 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
226 assert_different_registers(obj, t1, t2, t3, klass);
a61af66fc99e Initial load
duke
parents:
diff changeset
227 assert(klass == G5, "must be G5");
a61af66fc99e Initial load
duke
parents:
diff changeset
228
a61af66fc99e Initial load
duke
parents:
diff changeset
229 // allocate space & initialize header
a61af66fc99e Initial load
duke
parents:
diff changeset
230 if (!is_simm13(obj_size * wordSize)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
231 // would need to use extra register to load
a61af66fc99e Initial load
duke
parents:
diff changeset
232 // object size => go the slow case for now
3839
3d42f82cd811 7063628: Use cbcond on T4
kvn
parents: 2468
diff changeset
233 ba(slow_case);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
234 delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
235 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
236 }
a61af66fc99e Initial load
duke
parents:
diff changeset
237 try_allocate(obj, noreg, obj_size * wordSize, t2, t3, slow_case);
a61af66fc99e Initial load
duke
parents:
diff changeset
238
a61af66fc99e Initial load
duke
parents:
diff changeset
239 initialize_object(obj, klass, noreg, obj_size * HeapWordSize, t1, t2);
a61af66fc99e Initial load
duke
parents:
diff changeset
240 }
a61af66fc99e Initial load
duke
parents:
diff changeset
241
a61af66fc99e Initial load
duke
parents:
diff changeset
242 void C1_MacroAssembler::initialize_object(
a61af66fc99e Initial load
duke
parents:
diff changeset
243 Register obj, // result: pointer to object after successful allocation
a61af66fc99e Initial load
duke
parents:
diff changeset
244 Register klass, // object klass
a61af66fc99e Initial load
duke
parents:
diff changeset
245 Register var_size_in_bytes, // object size in bytes if unknown at compile time; invalid otherwise
a61af66fc99e Initial load
duke
parents:
diff changeset
246 int con_size_in_bytes, // object size in bytes if known at compile time
a61af66fc99e Initial load
duke
parents:
diff changeset
247 Register t1, // temp register
a61af66fc99e Initial load
duke
parents:
diff changeset
248 Register t2 // temp register
a61af66fc99e Initial load
duke
parents:
diff changeset
249 ) {
2002
ac637b7220d1 6985015: C1 needs to support compressed oops
iveresov
parents: 1972
diff changeset
250 const int hdr_size_in_bytes = instanceOopDesc::header_size() * HeapWordSize;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
251
a61af66fc99e Initial load
duke
parents:
diff changeset
252 initialize_header(obj, klass, noreg, t1, t2);
a61af66fc99e Initial load
duke
parents:
diff changeset
253
a61af66fc99e Initial load
duke
parents:
diff changeset
254 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
255 {
a61af66fc99e Initial load
duke
parents:
diff changeset
256 Label ok;
4762
069ab3f976d3 7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents: 3839
diff changeset
257 ld(klass, in_bytes(Klass::layout_helper_offset()), t1);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
258 if (var_size_in_bytes != noreg) {
3839
3d42f82cd811 7063628: Use cbcond on T4
kvn
parents: 2468
diff changeset
259 cmp_and_brx_short(t1, var_size_in_bytes, Assembler::equal, Assembler::pt, ok);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
260 } else {
3839
3d42f82cd811 7063628: Use cbcond on T4
kvn
parents: 2468
diff changeset
261 cmp_and_brx_short(t1, con_size_in_bytes, Assembler::equal, Assembler::pt, ok);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
262 }
a61af66fc99e Initial load
duke
parents:
diff changeset
263 stop("bad size in initialize_object");
a61af66fc99e Initial load
duke
parents:
diff changeset
264 should_not_reach_here();
a61af66fc99e Initial load
duke
parents:
diff changeset
265
a61af66fc99e Initial load
duke
parents:
diff changeset
266 bind(ok);
a61af66fc99e Initial load
duke
parents:
diff changeset
267 }
a61af66fc99e Initial load
duke
parents:
diff changeset
268
a61af66fc99e Initial load
duke
parents:
diff changeset
269 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
270
a61af66fc99e Initial load
duke
parents:
diff changeset
271 // initialize body
a61af66fc99e Initial load
duke
parents:
diff changeset
272 const int threshold = 5 * HeapWordSize; // approximate break even point for code size
a61af66fc99e Initial load
duke
parents:
diff changeset
273 if (var_size_in_bytes != noreg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
274 // use a loop
a61af66fc99e Initial load
duke
parents:
diff changeset
275 add(obj, hdr_size_in_bytes, t1); // compute address of first element
a61af66fc99e Initial load
duke
parents:
diff changeset
276 sub(var_size_in_bytes, hdr_size_in_bytes, t2); // compute size of body
a61af66fc99e Initial load
duke
parents:
diff changeset
277 initialize_body(t1, t2);
a61af66fc99e Initial load
duke
parents:
diff changeset
278 #ifndef _LP64
10997
46c544b8fbfc 8008407: remove SPARC V8 support
morris
parents: 6848
diff changeset
279 } else if (con_size_in_bytes < threshold * 2) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
280 // on v9 we can do double word stores to fill twice as much space.
a61af66fc99e Initial load
duke
parents:
diff changeset
281 assert(hdr_size_in_bytes % 8 == 0, "double word aligned");
a61af66fc99e Initial load
duke
parents:
diff changeset
282 assert(con_size_in_bytes % 8 == 0, "double word aligned");
a61af66fc99e Initial load
duke
parents:
diff changeset
283 for (int i = hdr_size_in_bytes; i < con_size_in_bytes; i += 2 * HeapWordSize) stx(G0, obj, i);
a61af66fc99e Initial load
duke
parents:
diff changeset
284 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
285 } else if (con_size_in_bytes <= threshold) {
a61af66fc99e Initial load
duke
parents:
diff changeset
286 // use explicit NULL stores
a61af66fc99e Initial load
duke
parents:
diff changeset
287 for (int i = hdr_size_in_bytes; i < con_size_in_bytes; i += HeapWordSize) st_ptr(G0, obj, i);
a61af66fc99e Initial load
duke
parents:
diff changeset
288 } else if (con_size_in_bytes > hdr_size_in_bytes) {
a61af66fc99e Initial load
duke
parents:
diff changeset
289 // use a loop
a61af66fc99e Initial load
duke
parents:
diff changeset
290 const Register base = t1;
a61af66fc99e Initial load
duke
parents:
diff changeset
291 const Register index = t2;
a61af66fc99e Initial load
duke
parents:
diff changeset
292 add(obj, hdr_size_in_bytes, base); // compute address of first element
a61af66fc99e Initial load
duke
parents:
diff changeset
293 // compute index = number of words to clear
a61af66fc99e Initial load
duke
parents:
diff changeset
294 set(con_size_in_bytes - hdr_size_in_bytes, index);
a61af66fc99e Initial load
duke
parents:
diff changeset
295 initialize_body(base, index);
a61af66fc99e Initial load
duke
parents:
diff changeset
296 }
a61af66fc99e Initial load
duke
parents:
diff changeset
297
780
c96bf21b756f 6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents: 727
diff changeset
298 if (CURRENT_ENV->dtrace_alloc_probes()) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
299 assert(obj == O0, "must be");
a61af66fc99e Initial load
duke
parents:
diff changeset
300 call(CAST_FROM_FN_PTR(address, Runtime1::entry_for(Runtime1::dtrace_object_alloc_id)),
a61af66fc99e Initial load
duke
parents:
diff changeset
301 relocInfo::runtime_call_type);
a61af66fc99e Initial load
duke
parents:
diff changeset
302 delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
303 }
a61af66fc99e Initial load
duke
parents:
diff changeset
304
a61af66fc99e Initial load
duke
parents:
diff changeset
305 verify_oop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
306 }
a61af66fc99e Initial load
duke
parents:
diff changeset
307
a61af66fc99e Initial load
duke
parents:
diff changeset
308
a61af66fc99e Initial load
duke
parents:
diff changeset
309 void C1_MacroAssembler::allocate_array(
a61af66fc99e Initial load
duke
parents:
diff changeset
310 Register obj, // result: pointer to array after successful allocation
a61af66fc99e Initial load
duke
parents:
diff changeset
311 Register len, // array length
a61af66fc99e Initial load
duke
parents:
diff changeset
312 Register t1, // temp register
a61af66fc99e Initial load
duke
parents:
diff changeset
313 Register t2, // temp register
a61af66fc99e Initial load
duke
parents:
diff changeset
314 Register t3, // temp register
a61af66fc99e Initial load
duke
parents:
diff changeset
315 int hdr_size, // object header size in words
a61af66fc99e Initial load
duke
parents:
diff changeset
316 int elt_size, // element size in bytes
a61af66fc99e Initial load
duke
parents:
diff changeset
317 Register klass, // object klass
a61af66fc99e Initial load
duke
parents:
diff changeset
318 Label& slow_case // continuation point if fast allocation fails
a61af66fc99e Initial load
duke
parents:
diff changeset
319 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
320 assert_different_registers(obj, len, t1, t2, t3, klass);
a61af66fc99e Initial load
duke
parents:
diff changeset
321 assert(klass == G5, "must be G5");
a61af66fc99e Initial load
duke
parents:
diff changeset
322 assert(t1 == G1, "must be G1");
a61af66fc99e Initial load
duke
parents:
diff changeset
323
a61af66fc99e Initial load
duke
parents:
diff changeset
324 // determine alignment mask
a61af66fc99e Initial load
duke
parents:
diff changeset
325 assert(!(BytesPerWord & 1), "must be a multiple of 2 for masking code to work");
a61af66fc99e Initial load
duke
parents:
diff changeset
326
a61af66fc99e Initial load
duke
parents:
diff changeset
327 // check for negative or excessive length
a61af66fc99e Initial load
duke
parents:
diff changeset
328 // note: the maximum length allowed is chosen so that arrays of any
a61af66fc99e Initial load
duke
parents:
diff changeset
329 // element size with this length are always smaller or equal
a61af66fc99e Initial load
duke
parents:
diff changeset
330 // to the largest integer (i.e., array size computation will
a61af66fc99e Initial load
duke
parents:
diff changeset
331 // not overflow)
a61af66fc99e Initial load
duke
parents:
diff changeset
332 set(max_array_allocation_length, t1);
a61af66fc99e Initial load
duke
parents:
diff changeset
333 cmp(len, t1);
a61af66fc99e Initial load
duke
parents:
diff changeset
334 br(Assembler::greaterUnsigned, false, Assembler::pn, slow_case);
a61af66fc99e Initial load
duke
parents:
diff changeset
335
a61af66fc99e Initial load
duke
parents:
diff changeset
336 // compute array size
a61af66fc99e Initial load
duke
parents:
diff changeset
337 // note: if 0 <= len <= max_length, len*elt_size + header + alignment is
a61af66fc99e Initial load
duke
parents:
diff changeset
338 // smaller or equal to the largest integer; also, since top is always
a61af66fc99e Initial load
duke
parents:
diff changeset
339 // aligned, we can do the alignment here instead of at the end address
a61af66fc99e Initial load
duke
parents:
diff changeset
340 // computation
a61af66fc99e Initial load
duke
parents:
diff changeset
341 const Register arr_size = t1;
a61af66fc99e Initial load
duke
parents:
diff changeset
342 switch (elt_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
343 case 1: delayed()->mov(len, arr_size); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
344 case 2: delayed()->sll(len, 1, arr_size); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
345 case 4: delayed()->sll(len, 2, arr_size); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
346 case 8: delayed()->sll(len, 3, arr_size); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
347 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
348 }
a61af66fc99e Initial load
duke
parents:
diff changeset
349 add(arr_size, hdr_size * wordSize + MinObjAlignmentInBytesMask, arr_size); // add space for header & alignment
a61af66fc99e Initial load
duke
parents:
diff changeset
350 and3(arr_size, ~MinObjAlignmentInBytesMask, arr_size); // align array size
a61af66fc99e Initial load
duke
parents:
diff changeset
351
a61af66fc99e Initial load
duke
parents:
diff changeset
352 // allocate space & initialize header
a61af66fc99e Initial load
duke
parents:
diff changeset
353 if (UseTLAB) {
a61af66fc99e Initial load
duke
parents:
diff changeset
354 tlab_allocate(obj, arr_size, 0, t2, slow_case);
a61af66fc99e Initial load
duke
parents:
diff changeset
355 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
356 eden_allocate(obj, arr_size, 0, t2, t3, slow_case);
a61af66fc99e Initial load
duke
parents:
diff changeset
357 }
a61af66fc99e Initial load
duke
parents:
diff changeset
358 initialize_header(obj, klass, len, t2, t3);
a61af66fc99e Initial load
duke
parents:
diff changeset
359
a61af66fc99e Initial load
duke
parents:
diff changeset
360 // initialize body
a61af66fc99e Initial load
duke
parents:
diff changeset
361 const Register base = t2;
a61af66fc99e Initial load
duke
parents:
diff changeset
362 const Register index = t3;
a61af66fc99e Initial load
duke
parents:
diff changeset
363 add(obj, hdr_size * wordSize, base); // compute address of first element
a61af66fc99e Initial load
duke
parents:
diff changeset
364 sub(arr_size, hdr_size * wordSize, index); // compute index = number of words to clear
a61af66fc99e Initial load
duke
parents:
diff changeset
365 initialize_body(base, index);
a61af66fc99e Initial load
duke
parents:
diff changeset
366
780
c96bf21b756f 6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents: 727
diff changeset
367 if (CURRENT_ENV->dtrace_alloc_probes()) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
368 assert(obj == O0, "must be");
a61af66fc99e Initial load
duke
parents:
diff changeset
369 call(CAST_FROM_FN_PTR(address, Runtime1::entry_for(Runtime1::dtrace_object_alloc_id)),
a61af66fc99e Initial load
duke
parents:
diff changeset
370 relocInfo::runtime_call_type);
a61af66fc99e Initial load
duke
parents:
diff changeset
371 delayed()->nop();
a61af66fc99e Initial load
duke
parents:
diff changeset
372 }
a61af66fc99e Initial load
duke
parents:
diff changeset
373
a61af66fc99e Initial load
duke
parents:
diff changeset
374 verify_oop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
375 }
a61af66fc99e Initial load
duke
parents:
diff changeset
376
a61af66fc99e Initial load
duke
parents:
diff changeset
377
a61af66fc99e Initial load
duke
parents:
diff changeset
378 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
379
a61af66fc99e Initial load
duke
parents:
diff changeset
380 void C1_MacroAssembler::verify_stack_oop(int stack_offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
381 if (!VerifyOops) return;
727
6b2273dd6fa9 6822110: Add AddressLiteral class on SPARC
twisti
parents: 196
diff changeset
382 verify_oop_addr(Address(SP, stack_offset + STACK_BIAS));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
383 }
a61af66fc99e Initial load
duke
parents:
diff changeset
384
a61af66fc99e Initial load
duke
parents:
diff changeset
385 void C1_MacroAssembler::verify_not_null_oop(Register r) {
a61af66fc99e Initial load
duke
parents:
diff changeset
386 Label not_null;
3839
3d42f82cd811 7063628: Use cbcond on T4
kvn
parents: 2468
diff changeset
387 br_notnull_short(r, Assembler::pt, not_null);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
388 stop("non-null oop required");
a61af66fc99e Initial load
duke
parents:
diff changeset
389 bind(not_null);
a61af66fc99e Initial load
duke
parents:
diff changeset
390 if (!VerifyOops) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
391 verify_oop(r);
a61af66fc99e Initial load
duke
parents:
diff changeset
392 }
a61af66fc99e Initial load
duke
parents:
diff changeset
393
a61af66fc99e Initial load
duke
parents:
diff changeset
394 void C1_MacroAssembler::invalidate_registers(bool iregisters, bool lregisters, bool oregisters,
a61af66fc99e Initial load
duke
parents:
diff changeset
395 Register preserve1, Register preserve2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
396 if (iregisters) {
a61af66fc99e Initial load
duke
parents:
diff changeset
397 for (int i = 0; i < 6; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
398 Register r = as_iRegister(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
399 if (r != preserve1 && r != preserve2) set(0xdead, r);
a61af66fc99e Initial load
duke
parents:
diff changeset
400 }
a61af66fc99e Initial load
duke
parents:
diff changeset
401 }
a61af66fc99e Initial load
duke
parents:
diff changeset
402 if (oregisters) {
a61af66fc99e Initial load
duke
parents:
diff changeset
403 for (int i = 0; i < 6; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
404 Register r = as_oRegister(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
405 if (r != preserve1 && r != preserve2) set(0xdead, r);
a61af66fc99e Initial load
duke
parents:
diff changeset
406 }
a61af66fc99e Initial load
duke
parents:
diff changeset
407 }
a61af66fc99e Initial load
duke
parents:
diff changeset
408 if (lregisters) {
a61af66fc99e Initial load
duke
parents:
diff changeset
409 for (int i = 0; i < 8; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
410 Register r = as_lRegister(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
411 if (r != preserve1 && r != preserve2) set(0xdead, r);
a61af66fc99e Initial load
duke
parents:
diff changeset
412 }
a61af66fc99e Initial load
duke
parents:
diff changeset
413 }
a61af66fc99e Initial load
duke
parents:
diff changeset
414 }
a61af66fc99e Initial load
duke
parents:
diff changeset
415
a61af66fc99e Initial load
duke
parents:
diff changeset
416
a61af66fc99e Initial load
duke
parents:
diff changeset
417 #endif