annotate src/cpu/x86/vm/assembler_x86_32.cpp @ 71:3d62cb85208d

6662967: Optimize I2D conversion on new x86 Summary: Use CVTDQ2PS and CVTDQ2PD for integer values conversions to float and double values on new AMD cpu. Reviewed-by: sgoldman, never
author kvn
date Wed, 19 Mar 2008 15:33:25 -0700
parents a61af66fc99e
children deadee49286e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 #include "incls/_precompiled.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
26 #include "incls/_assembler_x86_32.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28 // Implementation of AddressLiteral
a61af66fc99e Initial load
duke
parents:
diff changeset
29
a61af66fc99e Initial load
duke
parents:
diff changeset
30 AddressLiteral::AddressLiteral(address target, relocInfo::relocType rtype) {
a61af66fc99e Initial load
duke
parents:
diff changeset
31 _is_lval = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 _target = target;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 switch (rtype) {
a61af66fc99e Initial load
duke
parents:
diff changeset
34 case relocInfo::oop_type:
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // Oops are a special case. Normally they would be their own section
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // but in cases like icBuffer they are literals in the code stream that
a61af66fc99e Initial load
duke
parents:
diff changeset
37 // we don't have a section for. We use none so that we get a literal address
a61af66fc99e Initial load
duke
parents:
diff changeset
38 // which is always patchable.
a61af66fc99e Initial load
duke
parents:
diff changeset
39 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
40 case relocInfo::external_word_type:
a61af66fc99e Initial load
duke
parents:
diff changeset
41 _rspec = external_word_Relocation::spec(target);
a61af66fc99e Initial load
duke
parents:
diff changeset
42 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
43 case relocInfo::internal_word_type:
a61af66fc99e Initial load
duke
parents:
diff changeset
44 _rspec = internal_word_Relocation::spec(target);
a61af66fc99e Initial load
duke
parents:
diff changeset
45 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
46 case relocInfo::opt_virtual_call_type:
a61af66fc99e Initial load
duke
parents:
diff changeset
47 _rspec = opt_virtual_call_Relocation::spec();
a61af66fc99e Initial load
duke
parents:
diff changeset
48 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
49 case relocInfo::static_call_type:
a61af66fc99e Initial load
duke
parents:
diff changeset
50 _rspec = static_call_Relocation::spec();
a61af66fc99e Initial load
duke
parents:
diff changeset
51 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
52 case relocInfo::runtime_call_type:
a61af66fc99e Initial load
duke
parents:
diff changeset
53 _rspec = runtime_call_Relocation::spec();
a61af66fc99e Initial load
duke
parents:
diff changeset
54 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
55 case relocInfo::poll_type:
a61af66fc99e Initial load
duke
parents:
diff changeset
56 case relocInfo::poll_return_type:
a61af66fc99e Initial load
duke
parents:
diff changeset
57 _rspec = Relocation::spec_simple(rtype);
a61af66fc99e Initial load
duke
parents:
diff changeset
58 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
59 case relocInfo::none:
a61af66fc99e Initial load
duke
parents:
diff changeset
60 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
61 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
62 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
63 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
64 }
a61af66fc99e Initial load
duke
parents:
diff changeset
65 }
a61af66fc99e Initial load
duke
parents:
diff changeset
66
a61af66fc99e Initial load
duke
parents:
diff changeset
67 // Implementation of Address
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 Address Address::make_array(ArrayAddress adr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
70 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
71 // Not implementable on 64bit machines
a61af66fc99e Initial load
duke
parents:
diff changeset
72 // Should have been handled higher up the call chain.
a61af66fc99e Initial load
duke
parents:
diff changeset
73 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
74 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
75 AddressLiteral base = adr.base();
a61af66fc99e Initial load
duke
parents:
diff changeset
76 Address index = adr.index();
a61af66fc99e Initial load
duke
parents:
diff changeset
77 assert(index._disp == 0, "must not have disp"); // maybe it can?
a61af66fc99e Initial load
duke
parents:
diff changeset
78 Address array(index._base, index._index, index._scale, (intptr_t) base.target());
a61af66fc99e Initial load
duke
parents:
diff changeset
79 array._rspec = base._rspec;
a61af66fc99e Initial load
duke
parents:
diff changeset
80 return array;
a61af66fc99e Initial load
duke
parents:
diff changeset
81 #endif // _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
82 }
a61af66fc99e Initial load
duke
parents:
diff changeset
83
a61af66fc99e Initial load
duke
parents:
diff changeset
84 #ifndef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86 // exceedingly dangerous constructor
a61af66fc99e Initial load
duke
parents:
diff changeset
87 Address::Address(address loc, RelocationHolder spec) {
a61af66fc99e Initial load
duke
parents:
diff changeset
88 _base = noreg;
a61af66fc99e Initial load
duke
parents:
diff changeset
89 _index = noreg;
a61af66fc99e Initial load
duke
parents:
diff changeset
90 _scale = no_scale;
a61af66fc99e Initial load
duke
parents:
diff changeset
91 _disp = (intptr_t) loc;
a61af66fc99e Initial load
duke
parents:
diff changeset
92 _rspec = spec;
a61af66fc99e Initial load
duke
parents:
diff changeset
93 }
a61af66fc99e Initial load
duke
parents:
diff changeset
94 #endif // _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
95
a61af66fc99e Initial load
duke
parents:
diff changeset
96 // Convert the raw encoding form into the form expected by the constructor for
a61af66fc99e Initial load
duke
parents:
diff changeset
97 // Address. An index of 4 (rsp) corresponds to having no index, so convert
a61af66fc99e Initial load
duke
parents:
diff changeset
98 // that to noreg for the Address constructor.
a61af66fc99e Initial load
duke
parents:
diff changeset
99 Address Address::make_raw(int base, int index, int scale, int disp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
100 bool valid_index = index != rsp->encoding();
a61af66fc99e Initial load
duke
parents:
diff changeset
101 if (valid_index) {
a61af66fc99e Initial load
duke
parents:
diff changeset
102 Address madr(as_Register(base), as_Register(index), (Address::ScaleFactor)scale, in_ByteSize(disp));
a61af66fc99e Initial load
duke
parents:
diff changeset
103 return madr;
a61af66fc99e Initial load
duke
parents:
diff changeset
104 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
105 Address madr(as_Register(base), noreg, Address::no_scale, in_ByteSize(disp));
a61af66fc99e Initial load
duke
parents:
diff changeset
106 return madr;
a61af66fc99e Initial load
duke
parents:
diff changeset
107 }
a61af66fc99e Initial load
duke
parents:
diff changeset
108 }
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110 // Implementation of Assembler
a61af66fc99e Initial load
duke
parents:
diff changeset
111
a61af66fc99e Initial load
duke
parents:
diff changeset
112 int AbstractAssembler::code_fill_byte() {
a61af66fc99e Initial load
duke
parents:
diff changeset
113 return (u_char)'\xF4'; // hlt
a61af66fc99e Initial load
duke
parents:
diff changeset
114 }
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116 // make this go away someday
a61af66fc99e Initial load
duke
parents:
diff changeset
117 void Assembler::emit_data(jint data, relocInfo::relocType rtype, int format) {
a61af66fc99e Initial load
duke
parents:
diff changeset
118 if (rtype == relocInfo::none)
a61af66fc99e Initial load
duke
parents:
diff changeset
119 emit_long(data);
a61af66fc99e Initial load
duke
parents:
diff changeset
120 else emit_data(data, Relocation::spec_simple(rtype), format);
a61af66fc99e Initial load
duke
parents:
diff changeset
121 }
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123
a61af66fc99e Initial load
duke
parents:
diff changeset
124 void Assembler::emit_data(jint data, RelocationHolder const& rspec, int format) {
a61af66fc99e Initial load
duke
parents:
diff changeset
125 assert(imm32_operand == 0, "default format must be imm32 in this file");
a61af66fc99e Initial load
duke
parents:
diff changeset
126 assert(inst_mark() != NULL, "must be inside InstructionMark");
a61af66fc99e Initial load
duke
parents:
diff changeset
127 if (rspec.type() != relocInfo::none) {
a61af66fc99e Initial load
duke
parents:
diff changeset
128 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
129 check_relocation(rspec, format);
a61af66fc99e Initial load
duke
parents:
diff changeset
130 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
131 // Do not use AbstractAssembler::relocate, which is not intended for
a61af66fc99e Initial load
duke
parents:
diff changeset
132 // embedded words. Instead, relocate to the enclosing instruction.
a61af66fc99e Initial load
duke
parents:
diff changeset
133
a61af66fc99e Initial load
duke
parents:
diff changeset
134 // hack. call32 is too wide for mask so use disp32
a61af66fc99e Initial load
duke
parents:
diff changeset
135 if (format == call32_operand)
a61af66fc99e Initial load
duke
parents:
diff changeset
136 code_section()->relocate(inst_mark(), rspec, disp32_operand);
a61af66fc99e Initial load
duke
parents:
diff changeset
137 else
a61af66fc99e Initial load
duke
parents:
diff changeset
138 code_section()->relocate(inst_mark(), rspec, format);
a61af66fc99e Initial load
duke
parents:
diff changeset
139 }
a61af66fc99e Initial load
duke
parents:
diff changeset
140 emit_long(data);
a61af66fc99e Initial load
duke
parents:
diff changeset
141 }
a61af66fc99e Initial load
duke
parents:
diff changeset
142
a61af66fc99e Initial load
duke
parents:
diff changeset
143
a61af66fc99e Initial load
duke
parents:
diff changeset
144 void Assembler::emit_arith_b(int op1, int op2, Register dst, int imm8) {
a61af66fc99e Initial load
duke
parents:
diff changeset
145 assert(dst->has_byte_register(), "must have byte register");
a61af66fc99e Initial load
duke
parents:
diff changeset
146 assert(isByte(op1) && isByte(op2), "wrong opcode");
a61af66fc99e Initial load
duke
parents:
diff changeset
147 assert(isByte(imm8), "not a byte");
a61af66fc99e Initial load
duke
parents:
diff changeset
148 assert((op1 & 0x01) == 0, "should be 8bit operation");
a61af66fc99e Initial load
duke
parents:
diff changeset
149 emit_byte(op1);
a61af66fc99e Initial load
duke
parents:
diff changeset
150 emit_byte(op2 | dst->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
151 emit_byte(imm8);
a61af66fc99e Initial load
duke
parents:
diff changeset
152 }
a61af66fc99e Initial load
duke
parents:
diff changeset
153
a61af66fc99e Initial load
duke
parents:
diff changeset
154
a61af66fc99e Initial load
duke
parents:
diff changeset
155 void Assembler::emit_arith(int op1, int op2, Register dst, int imm32) {
a61af66fc99e Initial load
duke
parents:
diff changeset
156 assert(isByte(op1) && isByte(op2), "wrong opcode");
a61af66fc99e Initial load
duke
parents:
diff changeset
157 assert((op1 & 0x01) == 1, "should be 32bit operation");
a61af66fc99e Initial load
duke
parents:
diff changeset
158 assert((op1 & 0x02) == 0, "sign-extension bit should not be set");
a61af66fc99e Initial load
duke
parents:
diff changeset
159 if (is8bit(imm32)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
160 emit_byte(op1 | 0x02); // set sign bit
a61af66fc99e Initial load
duke
parents:
diff changeset
161 emit_byte(op2 | dst->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
162 emit_byte(imm32 & 0xFF);
a61af66fc99e Initial load
duke
parents:
diff changeset
163 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
164 emit_byte(op1);
a61af66fc99e Initial load
duke
parents:
diff changeset
165 emit_byte(op2 | dst->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
166 emit_long(imm32);
a61af66fc99e Initial load
duke
parents:
diff changeset
167 }
a61af66fc99e Initial load
duke
parents:
diff changeset
168 }
a61af66fc99e Initial load
duke
parents:
diff changeset
169
a61af66fc99e Initial load
duke
parents:
diff changeset
170 // immediate-to-memory forms
a61af66fc99e Initial load
duke
parents:
diff changeset
171 void Assembler::emit_arith_operand(int op1, Register rm, Address adr, int imm32) {
a61af66fc99e Initial load
duke
parents:
diff changeset
172 assert((op1 & 0x01) == 1, "should be 32bit operation");
a61af66fc99e Initial load
duke
parents:
diff changeset
173 assert((op1 & 0x02) == 0, "sign-extension bit should not be set");
a61af66fc99e Initial load
duke
parents:
diff changeset
174 if (is8bit(imm32)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
175 emit_byte(op1 | 0x02); // set sign bit
a61af66fc99e Initial load
duke
parents:
diff changeset
176 emit_operand(rm,adr);
a61af66fc99e Initial load
duke
parents:
diff changeset
177 emit_byte(imm32 & 0xFF);
a61af66fc99e Initial load
duke
parents:
diff changeset
178 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
179 emit_byte(op1);
a61af66fc99e Initial load
duke
parents:
diff changeset
180 emit_operand(rm,adr);
a61af66fc99e Initial load
duke
parents:
diff changeset
181 emit_long(imm32);
a61af66fc99e Initial load
duke
parents:
diff changeset
182 }
a61af66fc99e Initial load
duke
parents:
diff changeset
183 }
a61af66fc99e Initial load
duke
parents:
diff changeset
184
a61af66fc99e Initial load
duke
parents:
diff changeset
185 void Assembler::emit_arith(int op1, int op2, Register dst, jobject obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
186 assert(isByte(op1) && isByte(op2), "wrong opcode");
a61af66fc99e Initial load
duke
parents:
diff changeset
187 assert((op1 & 0x01) == 1, "should be 32bit operation");
a61af66fc99e Initial load
duke
parents:
diff changeset
188 assert((op1 & 0x02) == 0, "sign-extension bit should not be set");
a61af66fc99e Initial load
duke
parents:
diff changeset
189 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
190 emit_byte(op1);
a61af66fc99e Initial load
duke
parents:
diff changeset
191 emit_byte(op2 | dst->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
192 emit_data((int)obj, relocInfo::oop_type, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
193 }
a61af66fc99e Initial load
duke
parents:
diff changeset
194
a61af66fc99e Initial load
duke
parents:
diff changeset
195
a61af66fc99e Initial load
duke
parents:
diff changeset
196 void Assembler::emit_arith(int op1, int op2, Register dst, Register src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
197 assert(isByte(op1) && isByte(op2), "wrong opcode");
a61af66fc99e Initial load
duke
parents:
diff changeset
198 emit_byte(op1);
a61af66fc99e Initial load
duke
parents:
diff changeset
199 emit_byte(op2 | dst->encoding() << 3 | src->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
200 }
a61af66fc99e Initial load
duke
parents:
diff changeset
201
a61af66fc99e Initial load
duke
parents:
diff changeset
202
a61af66fc99e Initial load
duke
parents:
diff changeset
203 void Assembler::emit_operand(Register reg,
a61af66fc99e Initial load
duke
parents:
diff changeset
204 Register base,
a61af66fc99e Initial load
duke
parents:
diff changeset
205 Register index,
a61af66fc99e Initial load
duke
parents:
diff changeset
206 Address::ScaleFactor scale,
a61af66fc99e Initial load
duke
parents:
diff changeset
207 int disp,
a61af66fc99e Initial load
duke
parents:
diff changeset
208 RelocationHolder const& rspec) {
a61af66fc99e Initial load
duke
parents:
diff changeset
209
a61af66fc99e Initial load
duke
parents:
diff changeset
210 relocInfo::relocType rtype = (relocInfo::relocType) rspec.type();
a61af66fc99e Initial load
duke
parents:
diff changeset
211 if (base->is_valid()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
212 if (index->is_valid()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
213 assert(scale != Address::no_scale, "inconsistent address");
a61af66fc99e Initial load
duke
parents:
diff changeset
214 // [base + index*scale + disp]
a61af66fc99e Initial load
duke
parents:
diff changeset
215 if (disp == 0 && rtype == relocInfo::none && base != rbp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
216 // [base + index*scale]
a61af66fc99e Initial load
duke
parents:
diff changeset
217 // [00 reg 100][ss index base]
a61af66fc99e Initial load
duke
parents:
diff changeset
218 assert(index != rsp, "illegal addressing mode");
a61af66fc99e Initial load
duke
parents:
diff changeset
219 emit_byte(0x04 | reg->encoding() << 3);
a61af66fc99e Initial load
duke
parents:
diff changeset
220 emit_byte(scale << 6 | index->encoding() << 3 | base->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
221 } else if (is8bit(disp) && rtype == relocInfo::none) {
a61af66fc99e Initial load
duke
parents:
diff changeset
222 // [base + index*scale + imm8]
a61af66fc99e Initial load
duke
parents:
diff changeset
223 // [01 reg 100][ss index base] imm8
a61af66fc99e Initial load
duke
parents:
diff changeset
224 assert(index != rsp, "illegal addressing mode");
a61af66fc99e Initial load
duke
parents:
diff changeset
225 emit_byte(0x44 | reg->encoding() << 3);
a61af66fc99e Initial load
duke
parents:
diff changeset
226 emit_byte(scale << 6 | index->encoding() << 3 | base->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
227 emit_byte(disp & 0xFF);
a61af66fc99e Initial load
duke
parents:
diff changeset
228 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
229 // [base + index*scale + imm32]
a61af66fc99e Initial load
duke
parents:
diff changeset
230 // [10 reg 100][ss index base] imm32
a61af66fc99e Initial load
duke
parents:
diff changeset
231 assert(index != rsp, "illegal addressing mode");
a61af66fc99e Initial load
duke
parents:
diff changeset
232 emit_byte(0x84 | reg->encoding() << 3);
a61af66fc99e Initial load
duke
parents:
diff changeset
233 emit_byte(scale << 6 | index->encoding() << 3 | base->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
234 emit_data(disp, rspec, disp32_operand);
a61af66fc99e Initial load
duke
parents:
diff changeset
235 }
a61af66fc99e Initial load
duke
parents:
diff changeset
236 } else if (base == rsp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
237 // [esp + disp]
a61af66fc99e Initial load
duke
parents:
diff changeset
238 if (disp == 0 && rtype == relocInfo::none) {
a61af66fc99e Initial load
duke
parents:
diff changeset
239 // [esp]
a61af66fc99e Initial load
duke
parents:
diff changeset
240 // [00 reg 100][00 100 100]
a61af66fc99e Initial load
duke
parents:
diff changeset
241 emit_byte(0x04 | reg->encoding() << 3);
a61af66fc99e Initial load
duke
parents:
diff changeset
242 emit_byte(0x24);
a61af66fc99e Initial load
duke
parents:
diff changeset
243 } else if (is8bit(disp) && rtype == relocInfo::none) {
a61af66fc99e Initial load
duke
parents:
diff changeset
244 // [esp + imm8]
a61af66fc99e Initial load
duke
parents:
diff changeset
245 // [01 reg 100][00 100 100] imm8
a61af66fc99e Initial load
duke
parents:
diff changeset
246 emit_byte(0x44 | reg->encoding() << 3);
a61af66fc99e Initial load
duke
parents:
diff changeset
247 emit_byte(0x24);
a61af66fc99e Initial load
duke
parents:
diff changeset
248 emit_byte(disp & 0xFF);
a61af66fc99e Initial load
duke
parents:
diff changeset
249 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
250 // [esp + imm32]
a61af66fc99e Initial load
duke
parents:
diff changeset
251 // [10 reg 100][00 100 100] imm32
a61af66fc99e Initial load
duke
parents:
diff changeset
252 emit_byte(0x84 | reg->encoding() << 3);
a61af66fc99e Initial load
duke
parents:
diff changeset
253 emit_byte(0x24);
a61af66fc99e Initial load
duke
parents:
diff changeset
254 emit_data(disp, rspec, disp32_operand);
a61af66fc99e Initial load
duke
parents:
diff changeset
255 }
a61af66fc99e Initial load
duke
parents:
diff changeset
256 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
257 // [base + disp]
a61af66fc99e Initial load
duke
parents:
diff changeset
258 assert(base != rsp, "illegal addressing mode");
a61af66fc99e Initial load
duke
parents:
diff changeset
259 if (disp == 0 && rtype == relocInfo::none && base != rbp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
260 // [base]
a61af66fc99e Initial load
duke
parents:
diff changeset
261 // [00 reg base]
a61af66fc99e Initial load
duke
parents:
diff changeset
262 assert(base != rbp, "illegal addressing mode");
a61af66fc99e Initial load
duke
parents:
diff changeset
263 emit_byte(0x00 | reg->encoding() << 3 | base->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
264 } else if (is8bit(disp) && rtype == relocInfo::none) {
a61af66fc99e Initial load
duke
parents:
diff changeset
265 // [base + imm8]
a61af66fc99e Initial load
duke
parents:
diff changeset
266 // [01 reg base] imm8
a61af66fc99e Initial load
duke
parents:
diff changeset
267 emit_byte(0x40 | reg->encoding() << 3 | base->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
268 emit_byte(disp & 0xFF);
a61af66fc99e Initial load
duke
parents:
diff changeset
269 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
270 // [base + imm32]
a61af66fc99e Initial load
duke
parents:
diff changeset
271 // [10 reg base] imm32
a61af66fc99e Initial load
duke
parents:
diff changeset
272 emit_byte(0x80 | reg->encoding() << 3 | base->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
273 emit_data(disp, rspec, disp32_operand);
a61af66fc99e Initial load
duke
parents:
diff changeset
274 }
a61af66fc99e Initial load
duke
parents:
diff changeset
275 }
a61af66fc99e Initial load
duke
parents:
diff changeset
276 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
277 if (index->is_valid()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
278 assert(scale != Address::no_scale, "inconsistent address");
a61af66fc99e Initial load
duke
parents:
diff changeset
279 // [index*scale + disp]
a61af66fc99e Initial load
duke
parents:
diff changeset
280 // [00 reg 100][ss index 101] imm32
a61af66fc99e Initial load
duke
parents:
diff changeset
281 assert(index != rsp, "illegal addressing mode");
a61af66fc99e Initial load
duke
parents:
diff changeset
282 emit_byte(0x04 | reg->encoding() << 3);
a61af66fc99e Initial load
duke
parents:
diff changeset
283 emit_byte(scale << 6 | index->encoding() << 3 | 0x05);
a61af66fc99e Initial load
duke
parents:
diff changeset
284 emit_data(disp, rspec, disp32_operand);
a61af66fc99e Initial load
duke
parents:
diff changeset
285 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
286 // [disp]
a61af66fc99e Initial load
duke
parents:
diff changeset
287 // [00 reg 101] imm32
a61af66fc99e Initial load
duke
parents:
diff changeset
288 emit_byte(0x05 | reg->encoding() << 3);
a61af66fc99e Initial load
duke
parents:
diff changeset
289 emit_data(disp, rspec, disp32_operand);
a61af66fc99e Initial load
duke
parents:
diff changeset
290 }
a61af66fc99e Initial load
duke
parents:
diff changeset
291 }
a61af66fc99e Initial load
duke
parents:
diff changeset
292 }
a61af66fc99e Initial load
duke
parents:
diff changeset
293
a61af66fc99e Initial load
duke
parents:
diff changeset
294 // Secret local extension to Assembler::WhichOperand:
a61af66fc99e Initial load
duke
parents:
diff changeset
295 #define end_pc_operand (_WhichOperand_limit)
a61af66fc99e Initial load
duke
parents:
diff changeset
296
a61af66fc99e Initial load
duke
parents:
diff changeset
297 address Assembler::locate_operand(address inst, WhichOperand which) {
a61af66fc99e Initial load
duke
parents:
diff changeset
298 // Decode the given instruction, and return the address of
a61af66fc99e Initial load
duke
parents:
diff changeset
299 // an embedded 32-bit operand word.
a61af66fc99e Initial load
duke
parents:
diff changeset
300
a61af66fc99e Initial load
duke
parents:
diff changeset
301 // If "which" is disp32_operand, selects the displacement portion
a61af66fc99e Initial load
duke
parents:
diff changeset
302 // of an effective address specifier.
a61af66fc99e Initial load
duke
parents:
diff changeset
303 // If "which" is imm32_operand, selects the trailing immediate constant.
a61af66fc99e Initial load
duke
parents:
diff changeset
304 // If "which" is call32_operand, selects the displacement of a call or jump.
a61af66fc99e Initial load
duke
parents:
diff changeset
305 // Caller is responsible for ensuring that there is such an operand,
a61af66fc99e Initial load
duke
parents:
diff changeset
306 // and that it is 32 bits wide.
a61af66fc99e Initial load
duke
parents:
diff changeset
307
a61af66fc99e Initial load
duke
parents:
diff changeset
308 // If "which" is end_pc_operand, find the end of the instruction.
a61af66fc99e Initial load
duke
parents:
diff changeset
309
a61af66fc99e Initial load
duke
parents:
diff changeset
310 address ip = inst;
a61af66fc99e Initial load
duke
parents:
diff changeset
311
a61af66fc99e Initial load
duke
parents:
diff changeset
312 debug_only(bool has_imm32 = false);
a61af66fc99e Initial load
duke
parents:
diff changeset
313 int tail_size = 0; // other random bytes (#32, #16, etc.) at end of insn
a61af66fc99e Initial load
duke
parents:
diff changeset
314
a61af66fc99e Initial load
duke
parents:
diff changeset
315 again_after_prefix:
a61af66fc99e Initial load
duke
parents:
diff changeset
316 switch (0xFF & *ip++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
317
a61af66fc99e Initial load
duke
parents:
diff changeset
318 // These convenience macros generate groups of "case" labels for the switch.
a61af66fc99e Initial load
duke
parents:
diff changeset
319 #define REP4(x) (x)+0: case (x)+1: case (x)+2: case (x)+3
a61af66fc99e Initial load
duke
parents:
diff changeset
320 #define REP8(x) (x)+0: case (x)+1: case (x)+2: case (x)+3: \
a61af66fc99e Initial load
duke
parents:
diff changeset
321 case (x)+4: case (x)+5: case (x)+6: case (x)+7
a61af66fc99e Initial load
duke
parents:
diff changeset
322 #define REP16(x) REP8((x)+0): \
a61af66fc99e Initial load
duke
parents:
diff changeset
323 case REP8((x)+8)
a61af66fc99e Initial load
duke
parents:
diff changeset
324
a61af66fc99e Initial load
duke
parents:
diff changeset
325 case CS_segment:
a61af66fc99e Initial load
duke
parents:
diff changeset
326 case SS_segment:
a61af66fc99e Initial load
duke
parents:
diff changeset
327 case DS_segment:
a61af66fc99e Initial load
duke
parents:
diff changeset
328 case ES_segment:
a61af66fc99e Initial load
duke
parents:
diff changeset
329 case FS_segment:
a61af66fc99e Initial load
duke
parents:
diff changeset
330 case GS_segment:
a61af66fc99e Initial load
duke
parents:
diff changeset
331 assert(ip == inst+1, "only one prefix allowed");
a61af66fc99e Initial load
duke
parents:
diff changeset
332 goto again_after_prefix;
a61af66fc99e Initial load
duke
parents:
diff changeset
333
a61af66fc99e Initial load
duke
parents:
diff changeset
334 case 0xFF: // pushl a; decl a; incl a; call a; jmp a
a61af66fc99e Initial load
duke
parents:
diff changeset
335 case 0x88: // movb a, r
a61af66fc99e Initial load
duke
parents:
diff changeset
336 case 0x89: // movl a, r
a61af66fc99e Initial load
duke
parents:
diff changeset
337 case 0x8A: // movb r, a
a61af66fc99e Initial load
duke
parents:
diff changeset
338 case 0x8B: // movl r, a
a61af66fc99e Initial load
duke
parents:
diff changeset
339 case 0x8F: // popl a
a61af66fc99e Initial load
duke
parents:
diff changeset
340 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
341
a61af66fc99e Initial load
duke
parents:
diff changeset
342 case 0x68: // pushl #32(oop?)
a61af66fc99e Initial load
duke
parents:
diff changeset
343 if (which == end_pc_operand) return ip + 4;
a61af66fc99e Initial load
duke
parents:
diff changeset
344 assert(which == imm32_operand, "pushl has no disp32");
a61af66fc99e Initial load
duke
parents:
diff changeset
345 return ip; // not produced by emit_operand
a61af66fc99e Initial load
duke
parents:
diff changeset
346
a61af66fc99e Initial load
duke
parents:
diff changeset
347 case 0x66: // movw ... (size prefix)
a61af66fc99e Initial load
duke
parents:
diff changeset
348 switch (0xFF & *ip++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
349 case 0x8B: // movw r, a
a61af66fc99e Initial load
duke
parents:
diff changeset
350 case 0x89: // movw a, r
a61af66fc99e Initial load
duke
parents:
diff changeset
351 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
352 case 0xC7: // movw a, #16
a61af66fc99e Initial load
duke
parents:
diff changeset
353 tail_size = 2; // the imm16
a61af66fc99e Initial load
duke
parents:
diff changeset
354 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
355 case 0x0F: // several SSE/SSE2 variants
a61af66fc99e Initial load
duke
parents:
diff changeset
356 ip--; // reparse the 0x0F
a61af66fc99e Initial load
duke
parents:
diff changeset
357 goto again_after_prefix;
a61af66fc99e Initial load
duke
parents:
diff changeset
358 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
359 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
360 }
a61af66fc99e Initial load
duke
parents:
diff changeset
361 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
362
a61af66fc99e Initial load
duke
parents:
diff changeset
363 case REP8(0xB8): // movl r, #32(oop?)
a61af66fc99e Initial load
duke
parents:
diff changeset
364 if (which == end_pc_operand) return ip + 4;
a61af66fc99e Initial load
duke
parents:
diff changeset
365 assert(which == imm32_operand || which == disp32_operand, "");
a61af66fc99e Initial load
duke
parents:
diff changeset
366 return ip;
a61af66fc99e Initial load
duke
parents:
diff changeset
367
a61af66fc99e Initial load
duke
parents:
diff changeset
368 case 0x69: // imul r, a, #32
a61af66fc99e Initial load
duke
parents:
diff changeset
369 case 0xC7: // movl a, #32(oop?)
a61af66fc99e Initial load
duke
parents:
diff changeset
370 tail_size = 4;
a61af66fc99e Initial load
duke
parents:
diff changeset
371 debug_only(has_imm32 = true); // has both kinds of operands!
a61af66fc99e Initial load
duke
parents:
diff changeset
372 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
373
a61af66fc99e Initial load
duke
parents:
diff changeset
374 case 0x0F: // movx..., etc.
a61af66fc99e Initial load
duke
parents:
diff changeset
375 switch (0xFF & *ip++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
376 case 0x12: // movlps
a61af66fc99e Initial load
duke
parents:
diff changeset
377 case 0x28: // movaps
a61af66fc99e Initial load
duke
parents:
diff changeset
378 case 0x2E: // ucomiss
a61af66fc99e Initial load
duke
parents:
diff changeset
379 case 0x2F: // comiss
a61af66fc99e Initial load
duke
parents:
diff changeset
380 case 0x54: // andps
a61af66fc99e Initial load
duke
parents:
diff changeset
381 case 0x55: // andnps
a61af66fc99e Initial load
duke
parents:
diff changeset
382 case 0x56: // orps
a61af66fc99e Initial load
duke
parents:
diff changeset
383 case 0x57: // xorps
a61af66fc99e Initial load
duke
parents:
diff changeset
384 case 0x6E: // movd
a61af66fc99e Initial load
duke
parents:
diff changeset
385 case 0x7E: // movd
a61af66fc99e Initial load
duke
parents:
diff changeset
386 case 0xAE: // ldmxcsr a
a61af66fc99e Initial load
duke
parents:
diff changeset
387 // amd side says it these have both operands but that doesn't
a61af66fc99e Initial load
duke
parents:
diff changeset
388 // appear to be true.
a61af66fc99e Initial load
duke
parents:
diff changeset
389 // debug_only(has_imm32 = true); // has both kinds of operands!
a61af66fc99e Initial load
duke
parents:
diff changeset
390 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
391
a61af66fc99e Initial load
duke
parents:
diff changeset
392 case 0xAD: // shrd r, a, %cl
a61af66fc99e Initial load
duke
parents:
diff changeset
393 case 0xAF: // imul r, a
a61af66fc99e Initial load
duke
parents:
diff changeset
394 case 0xBE: // movsxb r, a
a61af66fc99e Initial load
duke
parents:
diff changeset
395 case 0xBF: // movsxw r, a
a61af66fc99e Initial load
duke
parents:
diff changeset
396 case 0xB6: // movzxb r, a
a61af66fc99e Initial load
duke
parents:
diff changeset
397 case 0xB7: // movzxw r, a
a61af66fc99e Initial load
duke
parents:
diff changeset
398 case REP16(0x40): // cmovl cc, r, a
a61af66fc99e Initial load
duke
parents:
diff changeset
399 case 0xB0: // cmpxchgb
a61af66fc99e Initial load
duke
parents:
diff changeset
400 case 0xB1: // cmpxchg
a61af66fc99e Initial load
duke
parents:
diff changeset
401 case 0xC1: // xaddl
a61af66fc99e Initial load
duke
parents:
diff changeset
402 case 0xC7: // cmpxchg8
a61af66fc99e Initial load
duke
parents:
diff changeset
403 case REP16(0x90): // setcc a
a61af66fc99e Initial load
duke
parents:
diff changeset
404 // fall out of the switch to decode the address
a61af66fc99e Initial load
duke
parents:
diff changeset
405 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
406 case 0xAC: // shrd r, a, #8
a61af66fc99e Initial load
duke
parents:
diff changeset
407 tail_size = 1; // the imm8
a61af66fc99e Initial load
duke
parents:
diff changeset
408 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
409 case REP16(0x80): // jcc rdisp32
a61af66fc99e Initial load
duke
parents:
diff changeset
410 if (which == end_pc_operand) return ip + 4;
a61af66fc99e Initial load
duke
parents:
diff changeset
411 assert(which == call32_operand, "jcc has no disp32 or imm32");
a61af66fc99e Initial load
duke
parents:
diff changeset
412 return ip;
a61af66fc99e Initial load
duke
parents:
diff changeset
413 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
414 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
415 }
a61af66fc99e Initial load
duke
parents:
diff changeset
416 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
417
a61af66fc99e Initial load
duke
parents:
diff changeset
418 case 0x81: // addl a, #32; addl r, #32
a61af66fc99e Initial load
duke
parents:
diff changeset
419 // also: orl, adcl, sbbl, andl, subl, xorl, cmpl
a61af66fc99e Initial load
duke
parents:
diff changeset
420 // in the case of cmpl, the imm32 might be an oop
a61af66fc99e Initial load
duke
parents:
diff changeset
421 tail_size = 4;
a61af66fc99e Initial load
duke
parents:
diff changeset
422 debug_only(has_imm32 = true); // has both kinds of operands!
a61af66fc99e Initial load
duke
parents:
diff changeset
423 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
424
a61af66fc99e Initial load
duke
parents:
diff changeset
425 case 0x85: // test r/m, r
a61af66fc99e Initial load
duke
parents:
diff changeset
426 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
427
a61af66fc99e Initial load
duke
parents:
diff changeset
428 case 0x83: // addl a, #8; addl r, #8
a61af66fc99e Initial load
duke
parents:
diff changeset
429 // also: orl, adcl, sbbl, andl, subl, xorl, cmpl
a61af66fc99e Initial load
duke
parents:
diff changeset
430 tail_size = 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
431 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
432
a61af66fc99e Initial load
duke
parents:
diff changeset
433 case 0x9B:
a61af66fc99e Initial load
duke
parents:
diff changeset
434 switch (0xFF & *ip++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
435 case 0xD9: // fnstcw a
a61af66fc99e Initial load
duke
parents:
diff changeset
436 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
437 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
438 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
439 }
a61af66fc99e Initial load
duke
parents:
diff changeset
440 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
441
a61af66fc99e Initial load
duke
parents:
diff changeset
442 case REP4(0x00): // addb a, r; addl a, r; addb r, a; addl r, a
a61af66fc99e Initial load
duke
parents:
diff changeset
443 case REP4(0x10): // adc...
a61af66fc99e Initial load
duke
parents:
diff changeset
444 case REP4(0x20): // and...
a61af66fc99e Initial load
duke
parents:
diff changeset
445 case REP4(0x30): // xor...
a61af66fc99e Initial load
duke
parents:
diff changeset
446 case REP4(0x08): // or...
a61af66fc99e Initial load
duke
parents:
diff changeset
447 case REP4(0x18): // sbb...
a61af66fc99e Initial load
duke
parents:
diff changeset
448 case REP4(0x28): // sub...
a61af66fc99e Initial load
duke
parents:
diff changeset
449 case REP4(0x38): // cmp...
a61af66fc99e Initial load
duke
parents:
diff changeset
450 case 0xF7: // mull a
a61af66fc99e Initial load
duke
parents:
diff changeset
451 case 0x8D: // leal r, a
a61af66fc99e Initial load
duke
parents:
diff changeset
452 case 0x87: // xchg r, a
a61af66fc99e Initial load
duke
parents:
diff changeset
453 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
454
a61af66fc99e Initial load
duke
parents:
diff changeset
455 case 0xC1: // sal a, #8; sar a, #8; shl a, #8; shr a, #8
a61af66fc99e Initial load
duke
parents:
diff changeset
456 case 0xC6: // movb a, #8
a61af66fc99e Initial load
duke
parents:
diff changeset
457 case 0x80: // cmpb a, #8
a61af66fc99e Initial load
duke
parents:
diff changeset
458 case 0x6B: // imul r, a, #8
a61af66fc99e Initial load
duke
parents:
diff changeset
459 tail_size = 1; // the imm8
a61af66fc99e Initial load
duke
parents:
diff changeset
460 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
461
a61af66fc99e Initial load
duke
parents:
diff changeset
462 case 0xE8: // call rdisp32
a61af66fc99e Initial load
duke
parents:
diff changeset
463 case 0xE9: // jmp rdisp32
a61af66fc99e Initial load
duke
parents:
diff changeset
464 if (which == end_pc_operand) return ip + 4;
a61af66fc99e Initial load
duke
parents:
diff changeset
465 assert(which == call32_operand, "call has no disp32 or imm32");
a61af66fc99e Initial load
duke
parents:
diff changeset
466 return ip;
a61af66fc99e Initial load
duke
parents:
diff changeset
467
a61af66fc99e Initial load
duke
parents:
diff changeset
468 case 0xD1: // sal a, 1; sar a, 1; shl a, 1; shr a, 1
a61af66fc99e Initial load
duke
parents:
diff changeset
469 case 0xD3: // sal a, %cl; sar a, %cl; shl a, %cl; shr a, %cl
a61af66fc99e Initial load
duke
parents:
diff changeset
470 case 0xD9: // fld_s a; fst_s a; fstp_s a; fldcw a
a61af66fc99e Initial load
duke
parents:
diff changeset
471 case 0xDD: // fld_d a; fst_d a; fstp_d a
a61af66fc99e Initial load
duke
parents:
diff changeset
472 case 0xDB: // fild_s a; fistp_s a; fld_x a; fstp_x a
a61af66fc99e Initial load
duke
parents:
diff changeset
473 case 0xDF: // fild_d a; fistp_d a
a61af66fc99e Initial load
duke
parents:
diff changeset
474 case 0xD8: // fadd_s a; fsubr_s a; fmul_s a; fdivr_s a; fcomp_s a
a61af66fc99e Initial load
duke
parents:
diff changeset
475 case 0xDC: // fadd_d a; fsubr_d a; fmul_d a; fdivr_d a; fcomp_d a
a61af66fc99e Initial load
duke
parents:
diff changeset
476 case 0xDE: // faddp_d a; fsubrp_d a; fmulp_d a; fdivrp_d a; fcompp_d a
a61af66fc99e Initial load
duke
parents:
diff changeset
477 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
478
a61af66fc99e Initial load
duke
parents:
diff changeset
479 case 0xF3: // For SSE
a61af66fc99e Initial load
duke
parents:
diff changeset
480 case 0xF2: // For SSE2
a61af66fc99e Initial load
duke
parents:
diff changeset
481 ip++; ip++;
a61af66fc99e Initial load
duke
parents:
diff changeset
482 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
483
a61af66fc99e Initial load
duke
parents:
diff changeset
484 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
485 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
486
a61af66fc99e Initial load
duke
parents:
diff changeset
487 #undef REP8
a61af66fc99e Initial load
duke
parents:
diff changeset
488 #undef REP16
a61af66fc99e Initial load
duke
parents:
diff changeset
489 }
a61af66fc99e Initial load
duke
parents:
diff changeset
490
a61af66fc99e Initial load
duke
parents:
diff changeset
491 assert(which != call32_operand, "instruction is not a call, jmp, or jcc");
a61af66fc99e Initial load
duke
parents:
diff changeset
492 assert(which != imm32_operand || has_imm32, "instruction has no imm32 field");
a61af66fc99e Initial load
duke
parents:
diff changeset
493
a61af66fc99e Initial load
duke
parents:
diff changeset
494 // parse the output of emit_operand
a61af66fc99e Initial load
duke
parents:
diff changeset
495 int op2 = 0xFF & *ip++;
a61af66fc99e Initial load
duke
parents:
diff changeset
496 int base = op2 & 0x07;
a61af66fc99e Initial load
duke
parents:
diff changeset
497 int op3 = -1;
a61af66fc99e Initial load
duke
parents:
diff changeset
498 const int b100 = 4;
a61af66fc99e Initial load
duke
parents:
diff changeset
499 const int b101 = 5;
a61af66fc99e Initial load
duke
parents:
diff changeset
500 if (base == b100 && (op2 >> 6) != 3) {
a61af66fc99e Initial load
duke
parents:
diff changeset
501 op3 = 0xFF & *ip++;
a61af66fc99e Initial load
duke
parents:
diff changeset
502 base = op3 & 0x07; // refetch the base
a61af66fc99e Initial load
duke
parents:
diff changeset
503 }
a61af66fc99e Initial load
duke
parents:
diff changeset
504 // now ip points at the disp (if any)
a61af66fc99e Initial load
duke
parents:
diff changeset
505
a61af66fc99e Initial load
duke
parents:
diff changeset
506 switch (op2 >> 6) {
a61af66fc99e Initial load
duke
parents:
diff changeset
507 case 0:
a61af66fc99e Initial load
duke
parents:
diff changeset
508 // [00 reg 100][ss index base]
a61af66fc99e Initial load
duke
parents:
diff changeset
509 // [00 reg 100][00 100 rsp]
a61af66fc99e Initial load
duke
parents:
diff changeset
510 // [00 reg base]
a61af66fc99e Initial load
duke
parents:
diff changeset
511 // [00 reg 100][ss index 101][disp32]
a61af66fc99e Initial load
duke
parents:
diff changeset
512 // [00 reg 101] [disp32]
a61af66fc99e Initial load
duke
parents:
diff changeset
513
a61af66fc99e Initial load
duke
parents:
diff changeset
514 if (base == b101) {
a61af66fc99e Initial load
duke
parents:
diff changeset
515 if (which == disp32_operand)
a61af66fc99e Initial load
duke
parents:
diff changeset
516 return ip; // caller wants the disp32
a61af66fc99e Initial load
duke
parents:
diff changeset
517 ip += 4; // skip the disp32
a61af66fc99e Initial load
duke
parents:
diff changeset
518 }
a61af66fc99e Initial load
duke
parents:
diff changeset
519 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
520
a61af66fc99e Initial load
duke
parents:
diff changeset
521 case 1:
a61af66fc99e Initial load
duke
parents:
diff changeset
522 // [01 reg 100][ss index base][disp8]
a61af66fc99e Initial load
duke
parents:
diff changeset
523 // [01 reg 100][00 100 rsp][disp8]
a61af66fc99e Initial load
duke
parents:
diff changeset
524 // [01 reg base] [disp8]
a61af66fc99e Initial load
duke
parents:
diff changeset
525 ip += 1; // skip the disp8
a61af66fc99e Initial load
duke
parents:
diff changeset
526 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
527
a61af66fc99e Initial load
duke
parents:
diff changeset
528 case 2:
a61af66fc99e Initial load
duke
parents:
diff changeset
529 // [10 reg 100][ss index base][disp32]
a61af66fc99e Initial load
duke
parents:
diff changeset
530 // [10 reg 100][00 100 rsp][disp32]
a61af66fc99e Initial load
duke
parents:
diff changeset
531 // [10 reg base] [disp32]
a61af66fc99e Initial load
duke
parents:
diff changeset
532 if (which == disp32_operand)
a61af66fc99e Initial load
duke
parents:
diff changeset
533 return ip; // caller wants the disp32
a61af66fc99e Initial load
duke
parents:
diff changeset
534 ip += 4; // skip the disp32
a61af66fc99e Initial load
duke
parents:
diff changeset
535 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
536
a61af66fc99e Initial load
duke
parents:
diff changeset
537 case 3:
a61af66fc99e Initial load
duke
parents:
diff changeset
538 // [11 reg base] (not a memory addressing mode)
a61af66fc99e Initial load
duke
parents:
diff changeset
539 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
540 }
a61af66fc99e Initial load
duke
parents:
diff changeset
541
a61af66fc99e Initial load
duke
parents:
diff changeset
542 if (which == end_pc_operand) {
a61af66fc99e Initial load
duke
parents:
diff changeset
543 return ip + tail_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
544 }
a61af66fc99e Initial load
duke
parents:
diff changeset
545
a61af66fc99e Initial load
duke
parents:
diff changeset
546 assert(which == imm32_operand, "instruction has only an imm32 field");
a61af66fc99e Initial load
duke
parents:
diff changeset
547 return ip;
a61af66fc99e Initial load
duke
parents:
diff changeset
548 }
a61af66fc99e Initial load
duke
parents:
diff changeset
549
a61af66fc99e Initial load
duke
parents:
diff changeset
550 address Assembler::locate_next_instruction(address inst) {
a61af66fc99e Initial load
duke
parents:
diff changeset
551 // Secretly share code with locate_operand:
a61af66fc99e Initial load
duke
parents:
diff changeset
552 return locate_operand(inst, end_pc_operand);
a61af66fc99e Initial load
duke
parents:
diff changeset
553 }
a61af66fc99e Initial load
duke
parents:
diff changeset
554
a61af66fc99e Initial load
duke
parents:
diff changeset
555
a61af66fc99e Initial load
duke
parents:
diff changeset
556 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
557 void Assembler::check_relocation(RelocationHolder const& rspec, int format) {
a61af66fc99e Initial load
duke
parents:
diff changeset
558 address inst = inst_mark();
a61af66fc99e Initial load
duke
parents:
diff changeset
559 assert(inst != NULL && inst < pc(), "must point to beginning of instruction");
a61af66fc99e Initial load
duke
parents:
diff changeset
560 address opnd;
a61af66fc99e Initial load
duke
parents:
diff changeset
561
a61af66fc99e Initial load
duke
parents:
diff changeset
562 Relocation* r = rspec.reloc();
a61af66fc99e Initial load
duke
parents:
diff changeset
563 if (r->type() == relocInfo::none) {
a61af66fc99e Initial load
duke
parents:
diff changeset
564 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
565 } else if (r->is_call() || format == call32_operand) {
a61af66fc99e Initial load
duke
parents:
diff changeset
566 // assert(format == imm32_operand, "cannot specify a nonzero format");
a61af66fc99e Initial load
duke
parents:
diff changeset
567 opnd = locate_operand(inst, call32_operand);
a61af66fc99e Initial load
duke
parents:
diff changeset
568 } else if (r->is_data()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
569 assert(format == imm32_operand || format == disp32_operand, "format ok");
a61af66fc99e Initial load
duke
parents:
diff changeset
570 opnd = locate_operand(inst, (WhichOperand)format);
a61af66fc99e Initial load
duke
parents:
diff changeset
571 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
572 assert(format == imm32_operand, "cannot specify a format");
a61af66fc99e Initial load
duke
parents:
diff changeset
573 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
574 }
a61af66fc99e Initial load
duke
parents:
diff changeset
575 assert(opnd == pc(), "must put operand where relocs can find it");
a61af66fc99e Initial load
duke
parents:
diff changeset
576 }
a61af66fc99e Initial load
duke
parents:
diff changeset
577 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
578
a61af66fc99e Initial load
duke
parents:
diff changeset
579
a61af66fc99e Initial load
duke
parents:
diff changeset
580
a61af66fc99e Initial load
duke
parents:
diff changeset
581 void Assembler::emit_operand(Register reg, Address adr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
582 emit_operand(reg, adr._base, adr._index, adr._scale, adr._disp, adr._rspec);
a61af66fc99e Initial load
duke
parents:
diff changeset
583 }
a61af66fc99e Initial load
duke
parents:
diff changeset
584
a61af66fc99e Initial load
duke
parents:
diff changeset
585
a61af66fc99e Initial load
duke
parents:
diff changeset
586 void Assembler::emit_farith(int b1, int b2, int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
587 assert(isByte(b1) && isByte(b2), "wrong opcode");
a61af66fc99e Initial load
duke
parents:
diff changeset
588 assert(0 <= i && i < 8, "illegal stack offset");
a61af66fc99e Initial load
duke
parents:
diff changeset
589 emit_byte(b1);
a61af66fc99e Initial load
duke
parents:
diff changeset
590 emit_byte(b2 + i);
a61af66fc99e Initial load
duke
parents:
diff changeset
591 }
a61af66fc99e Initial load
duke
parents:
diff changeset
592
a61af66fc99e Initial load
duke
parents:
diff changeset
593
a61af66fc99e Initial load
duke
parents:
diff changeset
594 void Assembler::pushad() {
a61af66fc99e Initial load
duke
parents:
diff changeset
595 emit_byte(0x60);
a61af66fc99e Initial load
duke
parents:
diff changeset
596 }
a61af66fc99e Initial load
duke
parents:
diff changeset
597
a61af66fc99e Initial load
duke
parents:
diff changeset
598 void Assembler::popad() {
a61af66fc99e Initial load
duke
parents:
diff changeset
599 emit_byte(0x61);
a61af66fc99e Initial load
duke
parents:
diff changeset
600 }
a61af66fc99e Initial load
duke
parents:
diff changeset
601
a61af66fc99e Initial load
duke
parents:
diff changeset
602 void Assembler::pushfd() {
a61af66fc99e Initial load
duke
parents:
diff changeset
603 emit_byte(0x9C);
a61af66fc99e Initial load
duke
parents:
diff changeset
604 }
a61af66fc99e Initial load
duke
parents:
diff changeset
605
a61af66fc99e Initial load
duke
parents:
diff changeset
606 void Assembler::popfd() {
a61af66fc99e Initial load
duke
parents:
diff changeset
607 emit_byte(0x9D);
a61af66fc99e Initial load
duke
parents:
diff changeset
608 }
a61af66fc99e Initial load
duke
parents:
diff changeset
609
a61af66fc99e Initial load
duke
parents:
diff changeset
610 void Assembler::pushl(int imm32) {
a61af66fc99e Initial load
duke
parents:
diff changeset
611 emit_byte(0x68);
a61af66fc99e Initial load
duke
parents:
diff changeset
612 emit_long(imm32);
a61af66fc99e Initial load
duke
parents:
diff changeset
613 }
a61af66fc99e Initial load
duke
parents:
diff changeset
614
a61af66fc99e Initial load
duke
parents:
diff changeset
615 #ifndef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
616 void Assembler::push_literal32(int32_t imm32, RelocationHolder const& rspec) {
a61af66fc99e Initial load
duke
parents:
diff changeset
617 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
618 emit_byte(0x68);
a61af66fc99e Initial load
duke
parents:
diff changeset
619 emit_data(imm32, rspec, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
620 }
a61af66fc99e Initial load
duke
parents:
diff changeset
621 #endif // _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
622
a61af66fc99e Initial load
duke
parents:
diff changeset
623 void Assembler::pushl(Register src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
624 emit_byte(0x50 | src->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
625 }
a61af66fc99e Initial load
duke
parents:
diff changeset
626
a61af66fc99e Initial load
duke
parents:
diff changeset
627
a61af66fc99e Initial load
duke
parents:
diff changeset
628 void Assembler::pushl(Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
629 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
630 emit_byte(0xFF);
a61af66fc99e Initial load
duke
parents:
diff changeset
631 emit_operand(rsi, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
632 }
a61af66fc99e Initial load
duke
parents:
diff changeset
633
a61af66fc99e Initial load
duke
parents:
diff changeset
634 void Assembler::popl(Register dst) {
a61af66fc99e Initial load
duke
parents:
diff changeset
635 emit_byte(0x58 | dst->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
636 }
a61af66fc99e Initial load
duke
parents:
diff changeset
637
a61af66fc99e Initial load
duke
parents:
diff changeset
638
a61af66fc99e Initial load
duke
parents:
diff changeset
639 void Assembler::popl(Address dst) {
a61af66fc99e Initial load
duke
parents:
diff changeset
640 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
641 emit_byte(0x8F);
a61af66fc99e Initial load
duke
parents:
diff changeset
642 emit_operand(rax, dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
643 }
a61af66fc99e Initial load
duke
parents:
diff changeset
644
a61af66fc99e Initial load
duke
parents:
diff changeset
645
a61af66fc99e Initial load
duke
parents:
diff changeset
646 void Assembler::prefix(Prefix p) {
a61af66fc99e Initial load
duke
parents:
diff changeset
647 a_byte(p);
a61af66fc99e Initial load
duke
parents:
diff changeset
648 }
a61af66fc99e Initial load
duke
parents:
diff changeset
649
a61af66fc99e Initial load
duke
parents:
diff changeset
650
a61af66fc99e Initial load
duke
parents:
diff changeset
651 void Assembler::movb(Register dst, Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
652 assert(dst->has_byte_register(), "must have byte register");
a61af66fc99e Initial load
duke
parents:
diff changeset
653 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
654 emit_byte(0x8A);
a61af66fc99e Initial load
duke
parents:
diff changeset
655 emit_operand(dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
656 }
a61af66fc99e Initial load
duke
parents:
diff changeset
657
a61af66fc99e Initial load
duke
parents:
diff changeset
658
a61af66fc99e Initial load
duke
parents:
diff changeset
659 void Assembler::movb(Address dst, int imm8) {
a61af66fc99e Initial load
duke
parents:
diff changeset
660 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
661 emit_byte(0xC6);
a61af66fc99e Initial load
duke
parents:
diff changeset
662 emit_operand(rax, dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
663 emit_byte(imm8);
a61af66fc99e Initial load
duke
parents:
diff changeset
664 }
a61af66fc99e Initial load
duke
parents:
diff changeset
665
a61af66fc99e Initial load
duke
parents:
diff changeset
666
a61af66fc99e Initial load
duke
parents:
diff changeset
667 void Assembler::movb(Address dst, Register src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
668 assert(src->has_byte_register(), "must have byte register");
a61af66fc99e Initial load
duke
parents:
diff changeset
669 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
670 emit_byte(0x88);
a61af66fc99e Initial load
duke
parents:
diff changeset
671 emit_operand(src, dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
672 }
a61af66fc99e Initial load
duke
parents:
diff changeset
673
a61af66fc99e Initial load
duke
parents:
diff changeset
674
a61af66fc99e Initial load
duke
parents:
diff changeset
675 void Assembler::movw(Address dst, int imm16) {
a61af66fc99e Initial load
duke
parents:
diff changeset
676 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
677
a61af66fc99e Initial load
duke
parents:
diff changeset
678 emit_byte(0x66); // switch to 16-bit mode
a61af66fc99e Initial load
duke
parents:
diff changeset
679 emit_byte(0xC7);
a61af66fc99e Initial load
duke
parents:
diff changeset
680 emit_operand(rax, dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
681 emit_word(imm16);
a61af66fc99e Initial load
duke
parents:
diff changeset
682 }
a61af66fc99e Initial load
duke
parents:
diff changeset
683
a61af66fc99e Initial load
duke
parents:
diff changeset
684
a61af66fc99e Initial load
duke
parents:
diff changeset
685 void Assembler::movw(Register dst, Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
686 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
687 emit_byte(0x66);
a61af66fc99e Initial load
duke
parents:
diff changeset
688 emit_byte(0x8B);
a61af66fc99e Initial load
duke
parents:
diff changeset
689 emit_operand(dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
690 }
a61af66fc99e Initial load
duke
parents:
diff changeset
691
a61af66fc99e Initial load
duke
parents:
diff changeset
692
a61af66fc99e Initial load
duke
parents:
diff changeset
693 void Assembler::movw(Address dst, Register src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
694 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
695 emit_byte(0x66);
a61af66fc99e Initial load
duke
parents:
diff changeset
696 emit_byte(0x89);
a61af66fc99e Initial load
duke
parents:
diff changeset
697 emit_operand(src, dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
698 }
a61af66fc99e Initial load
duke
parents:
diff changeset
699
a61af66fc99e Initial load
duke
parents:
diff changeset
700
a61af66fc99e Initial load
duke
parents:
diff changeset
701 void Assembler::movl(Register dst, int imm32) {
a61af66fc99e Initial load
duke
parents:
diff changeset
702 emit_byte(0xB8 | dst->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
703 emit_long(imm32);
a61af66fc99e Initial load
duke
parents:
diff changeset
704 }
a61af66fc99e Initial load
duke
parents:
diff changeset
705
a61af66fc99e Initial load
duke
parents:
diff changeset
706 #ifndef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
707 void Assembler::mov_literal32(Register dst, int32_t imm32, RelocationHolder const& rspec) {
a61af66fc99e Initial load
duke
parents:
diff changeset
708
a61af66fc99e Initial load
duke
parents:
diff changeset
709 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
710 emit_byte(0xB8 | dst->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
711 emit_data((int)imm32, rspec, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
712 }
a61af66fc99e Initial load
duke
parents:
diff changeset
713 #endif // _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
714
a61af66fc99e Initial load
duke
parents:
diff changeset
715 void Assembler::movl(Register dst, Register src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
716 emit_byte(0x8B);
a61af66fc99e Initial load
duke
parents:
diff changeset
717 emit_byte(0xC0 | (dst->encoding() << 3) | src->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
718 }
a61af66fc99e Initial load
duke
parents:
diff changeset
719
a61af66fc99e Initial load
duke
parents:
diff changeset
720
a61af66fc99e Initial load
duke
parents:
diff changeset
721 void Assembler::movl(Register dst, Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
722 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
723 emit_byte(0x8B);
a61af66fc99e Initial load
duke
parents:
diff changeset
724 emit_operand(dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
725 }
a61af66fc99e Initial load
duke
parents:
diff changeset
726
a61af66fc99e Initial load
duke
parents:
diff changeset
727
a61af66fc99e Initial load
duke
parents:
diff changeset
728 void Assembler::movl(Address dst, int imm32) {
a61af66fc99e Initial load
duke
parents:
diff changeset
729 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
730 emit_byte(0xC7);
a61af66fc99e Initial load
duke
parents:
diff changeset
731 emit_operand(rax, dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
732 emit_long(imm32);
a61af66fc99e Initial load
duke
parents:
diff changeset
733 }
a61af66fc99e Initial load
duke
parents:
diff changeset
734
a61af66fc99e Initial load
duke
parents:
diff changeset
735 #ifndef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
736 void Assembler::mov_literal32(Address dst, int32_t imm32, RelocationHolder const& rspec) {
a61af66fc99e Initial load
duke
parents:
diff changeset
737 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
738 emit_byte(0xC7);
a61af66fc99e Initial load
duke
parents:
diff changeset
739 emit_operand(rax, dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
740 emit_data((int)imm32, rspec, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
741 }
a61af66fc99e Initial load
duke
parents:
diff changeset
742 #endif // _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
743
a61af66fc99e Initial load
duke
parents:
diff changeset
744 void Assembler::movl(Address dst, Register src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
745 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
746 emit_byte(0x89);
a61af66fc99e Initial load
duke
parents:
diff changeset
747 emit_operand(src, dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
748 }
a61af66fc99e Initial load
duke
parents:
diff changeset
749
a61af66fc99e Initial load
duke
parents:
diff changeset
750 void Assembler::movsxb(Register dst, Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
751 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
752 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
753 emit_byte(0xBE);
a61af66fc99e Initial load
duke
parents:
diff changeset
754 emit_operand(dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
755 }
a61af66fc99e Initial load
duke
parents:
diff changeset
756
a61af66fc99e Initial load
duke
parents:
diff changeset
757 void Assembler::movsxb(Register dst, Register src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
758 assert(src->has_byte_register(), "must have byte register");
a61af66fc99e Initial load
duke
parents:
diff changeset
759 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
760 emit_byte(0xBE);
a61af66fc99e Initial load
duke
parents:
diff changeset
761 emit_byte(0xC0 | (dst->encoding() << 3) | src->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
762 }
a61af66fc99e Initial load
duke
parents:
diff changeset
763
a61af66fc99e Initial load
duke
parents:
diff changeset
764
a61af66fc99e Initial load
duke
parents:
diff changeset
765 void Assembler::movsxw(Register dst, Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
766 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
767 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
768 emit_byte(0xBF);
a61af66fc99e Initial load
duke
parents:
diff changeset
769 emit_operand(dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
770 }
a61af66fc99e Initial load
duke
parents:
diff changeset
771
a61af66fc99e Initial load
duke
parents:
diff changeset
772
a61af66fc99e Initial load
duke
parents:
diff changeset
773 void Assembler::movsxw(Register dst, Register src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
774 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
775 emit_byte(0xBF);
a61af66fc99e Initial load
duke
parents:
diff changeset
776 emit_byte(0xC0 | (dst->encoding() << 3) | src->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
777 }
a61af66fc99e Initial load
duke
parents:
diff changeset
778
a61af66fc99e Initial load
duke
parents:
diff changeset
779
a61af66fc99e Initial load
duke
parents:
diff changeset
780 void Assembler::movzxb(Register dst, Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
781 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
782 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
783 emit_byte(0xB6);
a61af66fc99e Initial load
duke
parents:
diff changeset
784 emit_operand(dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
785 }
a61af66fc99e Initial load
duke
parents:
diff changeset
786
a61af66fc99e Initial load
duke
parents:
diff changeset
787
a61af66fc99e Initial load
duke
parents:
diff changeset
788 void Assembler::movzxb(Register dst, Register src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
789 assert(src->has_byte_register(), "must have byte register");
a61af66fc99e Initial load
duke
parents:
diff changeset
790 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
791 emit_byte(0xB6);
a61af66fc99e Initial load
duke
parents:
diff changeset
792 emit_byte(0xC0 | (dst->encoding() << 3) | src->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
793 }
a61af66fc99e Initial load
duke
parents:
diff changeset
794
a61af66fc99e Initial load
duke
parents:
diff changeset
795
a61af66fc99e Initial load
duke
parents:
diff changeset
796 void Assembler::movzxw(Register dst, Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
797 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
798 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
799 emit_byte(0xB7);
a61af66fc99e Initial load
duke
parents:
diff changeset
800 emit_operand(dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
801 }
a61af66fc99e Initial load
duke
parents:
diff changeset
802
a61af66fc99e Initial load
duke
parents:
diff changeset
803
a61af66fc99e Initial load
duke
parents:
diff changeset
804 void Assembler::movzxw(Register dst, Register src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
805 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
806 emit_byte(0xB7);
a61af66fc99e Initial load
duke
parents:
diff changeset
807 emit_byte(0xC0 | (dst->encoding() << 3) | src->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
808 }
a61af66fc99e Initial load
duke
parents:
diff changeset
809
a61af66fc99e Initial load
duke
parents:
diff changeset
810
a61af66fc99e Initial load
duke
parents:
diff changeset
811 void Assembler::cmovl(Condition cc, Register dst, Register src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
812 guarantee(VM_Version::supports_cmov(), "illegal instruction");
a61af66fc99e Initial load
duke
parents:
diff changeset
813 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
814 emit_byte(0x40 | cc);
a61af66fc99e Initial load
duke
parents:
diff changeset
815 emit_byte(0xC0 | (dst->encoding() << 3) | src->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
816 }
a61af66fc99e Initial load
duke
parents:
diff changeset
817
a61af66fc99e Initial load
duke
parents:
diff changeset
818
a61af66fc99e Initial load
duke
parents:
diff changeset
819 void Assembler::cmovl(Condition cc, Register dst, Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
820 guarantee(VM_Version::supports_cmov(), "illegal instruction");
a61af66fc99e Initial load
duke
parents:
diff changeset
821 // The code below seems to be wrong - however the manual is inconclusive
a61af66fc99e Initial load
duke
parents:
diff changeset
822 // do not use for now (remember to enable all callers when fixing this)
a61af66fc99e Initial load
duke
parents:
diff changeset
823 Unimplemented();
a61af66fc99e Initial load
duke
parents:
diff changeset
824 // wrong bytes?
a61af66fc99e Initial load
duke
parents:
diff changeset
825 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
826 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
827 emit_byte(0x40 | cc);
a61af66fc99e Initial load
duke
parents:
diff changeset
828 emit_operand(dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
829 }
a61af66fc99e Initial load
duke
parents:
diff changeset
830
a61af66fc99e Initial load
duke
parents:
diff changeset
831
a61af66fc99e Initial load
duke
parents:
diff changeset
832 void Assembler::prefetcht0(Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
833 assert(VM_Version::supports_sse(), "must support");
a61af66fc99e Initial load
duke
parents:
diff changeset
834 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
835 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
836 emit_byte(0x18);
a61af66fc99e Initial load
duke
parents:
diff changeset
837 emit_operand(rcx, src); // 1, src
a61af66fc99e Initial load
duke
parents:
diff changeset
838 }
a61af66fc99e Initial load
duke
parents:
diff changeset
839
a61af66fc99e Initial load
duke
parents:
diff changeset
840
a61af66fc99e Initial load
duke
parents:
diff changeset
841 void Assembler::prefetcht1(Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
842 assert(VM_Version::supports_sse(), "must support");
a61af66fc99e Initial load
duke
parents:
diff changeset
843 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
844 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
845 emit_byte(0x18);
a61af66fc99e Initial load
duke
parents:
diff changeset
846 emit_operand(rdx, src); // 2, src
a61af66fc99e Initial load
duke
parents:
diff changeset
847 }
a61af66fc99e Initial load
duke
parents:
diff changeset
848
a61af66fc99e Initial load
duke
parents:
diff changeset
849
a61af66fc99e Initial load
duke
parents:
diff changeset
850 void Assembler::prefetcht2(Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
851 assert(VM_Version::supports_sse(), "must support");
a61af66fc99e Initial load
duke
parents:
diff changeset
852 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
853 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
854 emit_byte(0x18);
a61af66fc99e Initial load
duke
parents:
diff changeset
855 emit_operand(rbx, src); // 3, src
a61af66fc99e Initial load
duke
parents:
diff changeset
856 }
a61af66fc99e Initial load
duke
parents:
diff changeset
857
a61af66fc99e Initial load
duke
parents:
diff changeset
858
a61af66fc99e Initial load
duke
parents:
diff changeset
859 void Assembler::prefetchnta(Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
860 assert(VM_Version::supports_sse2(), "must support");
a61af66fc99e Initial load
duke
parents:
diff changeset
861 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
862 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
863 emit_byte(0x18);
a61af66fc99e Initial load
duke
parents:
diff changeset
864 emit_operand(rax, src); // 0, src
a61af66fc99e Initial load
duke
parents:
diff changeset
865 }
a61af66fc99e Initial load
duke
parents:
diff changeset
866
a61af66fc99e Initial load
duke
parents:
diff changeset
867
a61af66fc99e Initial load
duke
parents:
diff changeset
868 void Assembler::prefetchw(Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
869 assert(VM_Version::supports_3dnow(), "must support");
a61af66fc99e Initial load
duke
parents:
diff changeset
870 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
871 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
872 emit_byte(0x0D);
a61af66fc99e Initial load
duke
parents:
diff changeset
873 emit_operand(rcx, src); // 1, src
a61af66fc99e Initial load
duke
parents:
diff changeset
874 }
a61af66fc99e Initial load
duke
parents:
diff changeset
875
a61af66fc99e Initial load
duke
parents:
diff changeset
876
a61af66fc99e Initial load
duke
parents:
diff changeset
877 void Assembler::prefetchr(Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
878 assert(VM_Version::supports_3dnow(), "must support");
a61af66fc99e Initial load
duke
parents:
diff changeset
879 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
880 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
881 emit_byte(0x0D);
a61af66fc99e Initial load
duke
parents:
diff changeset
882 emit_operand(rax, src); // 0, src
a61af66fc99e Initial load
duke
parents:
diff changeset
883 }
a61af66fc99e Initial load
duke
parents:
diff changeset
884
a61af66fc99e Initial load
duke
parents:
diff changeset
885
a61af66fc99e Initial load
duke
parents:
diff changeset
886 void Assembler::adcl(Register dst, int imm32) {
a61af66fc99e Initial load
duke
parents:
diff changeset
887 emit_arith(0x81, 0xD0, dst, imm32);
a61af66fc99e Initial load
duke
parents:
diff changeset
888 }
a61af66fc99e Initial load
duke
parents:
diff changeset
889
a61af66fc99e Initial load
duke
parents:
diff changeset
890
a61af66fc99e Initial load
duke
parents:
diff changeset
891 void Assembler::adcl(Register dst, Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
892 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
893 emit_byte(0x13);
a61af66fc99e Initial load
duke
parents:
diff changeset
894 emit_operand(dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
895 }
a61af66fc99e Initial load
duke
parents:
diff changeset
896
a61af66fc99e Initial load
duke
parents:
diff changeset
897
a61af66fc99e Initial load
duke
parents:
diff changeset
898 void Assembler::adcl(Register dst, Register src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
899 emit_arith(0x13, 0xC0, dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
900 }
a61af66fc99e Initial load
duke
parents:
diff changeset
901
a61af66fc99e Initial load
duke
parents:
diff changeset
902
a61af66fc99e Initial load
duke
parents:
diff changeset
903 void Assembler::addl(Address dst, int imm32) {
a61af66fc99e Initial load
duke
parents:
diff changeset
904 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
905 emit_arith_operand(0x81,rax,dst,imm32);
a61af66fc99e Initial load
duke
parents:
diff changeset
906 }
a61af66fc99e Initial load
duke
parents:
diff changeset
907
a61af66fc99e Initial load
duke
parents:
diff changeset
908
a61af66fc99e Initial load
duke
parents:
diff changeset
909 void Assembler::addl(Address dst, Register src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
910 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
911 emit_byte(0x01);
a61af66fc99e Initial load
duke
parents:
diff changeset
912 emit_operand(src, dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
913 }
a61af66fc99e Initial load
duke
parents:
diff changeset
914
a61af66fc99e Initial load
duke
parents:
diff changeset
915
a61af66fc99e Initial load
duke
parents:
diff changeset
916 void Assembler::addl(Register dst, int imm32) {
a61af66fc99e Initial load
duke
parents:
diff changeset
917 emit_arith(0x81, 0xC0, dst, imm32);
a61af66fc99e Initial load
duke
parents:
diff changeset
918 }
a61af66fc99e Initial load
duke
parents:
diff changeset
919
a61af66fc99e Initial load
duke
parents:
diff changeset
920
a61af66fc99e Initial load
duke
parents:
diff changeset
921 void Assembler::addl(Register dst, Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
922 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
923 emit_byte(0x03);
a61af66fc99e Initial load
duke
parents:
diff changeset
924 emit_operand(dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
925 }
a61af66fc99e Initial load
duke
parents:
diff changeset
926
a61af66fc99e Initial load
duke
parents:
diff changeset
927
a61af66fc99e Initial load
duke
parents:
diff changeset
928 void Assembler::addl(Register dst, Register src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
929 emit_arith(0x03, 0xC0, dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
930 }
a61af66fc99e Initial load
duke
parents:
diff changeset
931
a61af66fc99e Initial load
duke
parents:
diff changeset
932
a61af66fc99e Initial load
duke
parents:
diff changeset
933 void Assembler::andl(Register dst, int imm32) {
a61af66fc99e Initial load
duke
parents:
diff changeset
934 emit_arith(0x81, 0xE0, dst, imm32);
a61af66fc99e Initial load
duke
parents:
diff changeset
935 }
a61af66fc99e Initial load
duke
parents:
diff changeset
936
a61af66fc99e Initial load
duke
parents:
diff changeset
937
a61af66fc99e Initial load
duke
parents:
diff changeset
938 void Assembler::andl(Register dst, Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
939 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
940 emit_byte(0x23);
a61af66fc99e Initial load
duke
parents:
diff changeset
941 emit_operand(dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
942 }
a61af66fc99e Initial load
duke
parents:
diff changeset
943
a61af66fc99e Initial load
duke
parents:
diff changeset
944
a61af66fc99e Initial load
duke
parents:
diff changeset
945 void Assembler::andl(Register dst, Register src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
946 emit_arith(0x23, 0xC0, dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
947 }
a61af66fc99e Initial load
duke
parents:
diff changeset
948
a61af66fc99e Initial load
duke
parents:
diff changeset
949
a61af66fc99e Initial load
duke
parents:
diff changeset
950 void Assembler::cmpb(Address dst, int imm8) {
a61af66fc99e Initial load
duke
parents:
diff changeset
951 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
952 emit_byte(0x80);
a61af66fc99e Initial load
duke
parents:
diff changeset
953 emit_operand(rdi, dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
954 emit_byte(imm8);
a61af66fc99e Initial load
duke
parents:
diff changeset
955 }
a61af66fc99e Initial load
duke
parents:
diff changeset
956
a61af66fc99e Initial load
duke
parents:
diff changeset
957 void Assembler::cmpw(Address dst, int imm16) {
a61af66fc99e Initial load
duke
parents:
diff changeset
958 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
959 emit_byte(0x66);
a61af66fc99e Initial load
duke
parents:
diff changeset
960 emit_byte(0x81);
a61af66fc99e Initial load
duke
parents:
diff changeset
961 emit_operand(rdi, dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
962 emit_word(imm16);
a61af66fc99e Initial load
duke
parents:
diff changeset
963 }
a61af66fc99e Initial load
duke
parents:
diff changeset
964
a61af66fc99e Initial load
duke
parents:
diff changeset
965 void Assembler::cmpl(Address dst, int imm32) {
a61af66fc99e Initial load
duke
parents:
diff changeset
966 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
967 emit_byte(0x81);
a61af66fc99e Initial load
duke
parents:
diff changeset
968 emit_operand(rdi, dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
969 emit_long(imm32);
a61af66fc99e Initial load
duke
parents:
diff changeset
970 }
a61af66fc99e Initial load
duke
parents:
diff changeset
971
a61af66fc99e Initial load
duke
parents:
diff changeset
972 #ifndef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
973 void Assembler::cmp_literal32(Register src1, int32_t imm32, RelocationHolder const& rspec) {
a61af66fc99e Initial load
duke
parents:
diff changeset
974 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
975 emit_byte(0x81);
a61af66fc99e Initial load
duke
parents:
diff changeset
976 emit_byte(0xF8 | src1->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
977 emit_data(imm32, rspec, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
978 }
a61af66fc99e Initial load
duke
parents:
diff changeset
979
a61af66fc99e Initial load
duke
parents:
diff changeset
980 void Assembler::cmp_literal32(Address src1, int32_t imm32, RelocationHolder const& rspec) {
a61af66fc99e Initial load
duke
parents:
diff changeset
981 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
982 emit_byte(0x81);
a61af66fc99e Initial load
duke
parents:
diff changeset
983 emit_operand(rdi, src1);
a61af66fc99e Initial load
duke
parents:
diff changeset
984 emit_data(imm32, rspec, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
985 }
a61af66fc99e Initial load
duke
parents:
diff changeset
986 #endif // _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
987
a61af66fc99e Initial load
duke
parents:
diff changeset
988
a61af66fc99e Initial load
duke
parents:
diff changeset
989 void Assembler::cmpl(Register dst, int imm32) {
a61af66fc99e Initial load
duke
parents:
diff changeset
990 emit_arith(0x81, 0xF8, dst, imm32);
a61af66fc99e Initial load
duke
parents:
diff changeset
991 }
a61af66fc99e Initial load
duke
parents:
diff changeset
992
a61af66fc99e Initial load
duke
parents:
diff changeset
993
a61af66fc99e Initial load
duke
parents:
diff changeset
994 void Assembler::cmpl(Register dst, Register src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
995 emit_arith(0x3B, 0xC0, dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
996 }
a61af66fc99e Initial load
duke
parents:
diff changeset
997
a61af66fc99e Initial load
duke
parents:
diff changeset
998
a61af66fc99e Initial load
duke
parents:
diff changeset
999 void Assembler::cmpl(Register dst, Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1000 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1001 emit_byte(0x3B);
a61af66fc99e Initial load
duke
parents:
diff changeset
1002 emit_operand(dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
1003 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1004
a61af66fc99e Initial load
duke
parents:
diff changeset
1005
a61af66fc99e Initial load
duke
parents:
diff changeset
1006 void Assembler::decl(Register dst) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1007 // Don't use it directly. Use MacroAssembler::decrement() instead.
a61af66fc99e Initial load
duke
parents:
diff changeset
1008 emit_byte(0x48 | dst->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
1009 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1010
a61af66fc99e Initial load
duke
parents:
diff changeset
1011
a61af66fc99e Initial load
duke
parents:
diff changeset
1012 void Assembler::decl(Address dst) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1013 // Don't use it directly. Use MacroAssembler::decrement() instead.
a61af66fc99e Initial load
duke
parents:
diff changeset
1014 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1015 emit_byte(0xFF);
a61af66fc99e Initial load
duke
parents:
diff changeset
1016 emit_operand(rcx, dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
1017 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1018
a61af66fc99e Initial load
duke
parents:
diff changeset
1019
a61af66fc99e Initial load
duke
parents:
diff changeset
1020 void Assembler::idivl(Register src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1021 emit_byte(0xF7);
a61af66fc99e Initial load
duke
parents:
diff changeset
1022 emit_byte(0xF8 | src->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
1023 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1024
a61af66fc99e Initial load
duke
parents:
diff changeset
1025
a61af66fc99e Initial load
duke
parents:
diff changeset
1026 void Assembler::cdql() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1027 emit_byte(0x99);
a61af66fc99e Initial load
duke
parents:
diff changeset
1028 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1029
a61af66fc99e Initial load
duke
parents:
diff changeset
1030
a61af66fc99e Initial load
duke
parents:
diff changeset
1031 void Assembler::imull(Register dst, Register src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1032 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
1033 emit_byte(0xAF);
a61af66fc99e Initial load
duke
parents:
diff changeset
1034 emit_byte(0xC0 | dst->encoding() << 3 | src->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
1035 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1036
a61af66fc99e Initial load
duke
parents:
diff changeset
1037
a61af66fc99e Initial load
duke
parents:
diff changeset
1038 void Assembler::imull(Register dst, Register src, int value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1039 if (is8bit(value)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1040 emit_byte(0x6B);
a61af66fc99e Initial load
duke
parents:
diff changeset
1041 emit_byte(0xC0 | dst->encoding() << 3 | src->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
1042 emit_byte(value);
a61af66fc99e Initial load
duke
parents:
diff changeset
1043 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1044 emit_byte(0x69);
a61af66fc99e Initial load
duke
parents:
diff changeset
1045 emit_byte(0xC0 | dst->encoding() << 3 | src->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
1046 emit_long(value);
a61af66fc99e Initial load
duke
parents:
diff changeset
1047 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1048 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1049
a61af66fc99e Initial load
duke
parents:
diff changeset
1050
a61af66fc99e Initial load
duke
parents:
diff changeset
1051 void Assembler::incl(Register dst) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1052 // Don't use it directly. Use MacroAssembler::increment() instead.
a61af66fc99e Initial load
duke
parents:
diff changeset
1053 emit_byte(0x40 | dst->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
1054 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1055
a61af66fc99e Initial load
duke
parents:
diff changeset
1056
a61af66fc99e Initial load
duke
parents:
diff changeset
1057 void Assembler::incl(Address dst) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1058 // Don't use it directly. Use MacroAssembler::increment() instead.
a61af66fc99e Initial load
duke
parents:
diff changeset
1059 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1060 emit_byte(0xFF);
a61af66fc99e Initial load
duke
parents:
diff changeset
1061 emit_operand(rax, dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
1062 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1063
a61af66fc99e Initial load
duke
parents:
diff changeset
1064
a61af66fc99e Initial load
duke
parents:
diff changeset
1065 void Assembler::leal(Register dst, Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1066 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1067 emit_byte(0x8D);
a61af66fc99e Initial load
duke
parents:
diff changeset
1068 emit_operand(dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
1069 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1070
a61af66fc99e Initial load
duke
parents:
diff changeset
1071 void Assembler::mull(Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1072 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1073 emit_byte(0xF7);
a61af66fc99e Initial load
duke
parents:
diff changeset
1074 emit_operand(rsp, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
1075 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1076
a61af66fc99e Initial load
duke
parents:
diff changeset
1077
a61af66fc99e Initial load
duke
parents:
diff changeset
1078 void Assembler::mull(Register src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1079 emit_byte(0xF7);
a61af66fc99e Initial load
duke
parents:
diff changeset
1080 emit_byte(0xE0 | src->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
1081 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1082
a61af66fc99e Initial load
duke
parents:
diff changeset
1083
a61af66fc99e Initial load
duke
parents:
diff changeset
1084 void Assembler::negl(Register dst) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1085 emit_byte(0xF7);
a61af66fc99e Initial load
duke
parents:
diff changeset
1086 emit_byte(0xD8 | dst->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
1087 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1088
a61af66fc99e Initial load
duke
parents:
diff changeset
1089
a61af66fc99e Initial load
duke
parents:
diff changeset
1090 void Assembler::notl(Register dst) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1091 emit_byte(0xF7);
a61af66fc99e Initial load
duke
parents:
diff changeset
1092 emit_byte(0xD0 | dst->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
1093 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1094
a61af66fc99e Initial load
duke
parents:
diff changeset
1095
a61af66fc99e Initial load
duke
parents:
diff changeset
1096 void Assembler::orl(Address dst, int imm32) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1097 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1098 emit_byte(0x81);
a61af66fc99e Initial load
duke
parents:
diff changeset
1099 emit_operand(rcx, dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
1100 emit_long(imm32);
a61af66fc99e Initial load
duke
parents:
diff changeset
1101 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1102
a61af66fc99e Initial load
duke
parents:
diff changeset
1103 void Assembler::orl(Register dst, int imm32) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1104 emit_arith(0x81, 0xC8, dst, imm32);
a61af66fc99e Initial load
duke
parents:
diff changeset
1105 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1106
a61af66fc99e Initial load
duke
parents:
diff changeset
1107
a61af66fc99e Initial load
duke
parents:
diff changeset
1108 void Assembler::orl(Register dst, Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1109 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1110 emit_byte(0x0B);
a61af66fc99e Initial load
duke
parents:
diff changeset
1111 emit_operand(dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
1112 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1113
a61af66fc99e Initial load
duke
parents:
diff changeset
1114
a61af66fc99e Initial load
duke
parents:
diff changeset
1115 void Assembler::orl(Register dst, Register src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1116 emit_arith(0x0B, 0xC0, dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
1117 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1118
a61af66fc99e Initial load
duke
parents:
diff changeset
1119
a61af66fc99e Initial load
duke
parents:
diff changeset
1120 void Assembler::rcll(Register dst, int imm8) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1121 assert(isShiftCount(imm8), "illegal shift count");
a61af66fc99e Initial load
duke
parents:
diff changeset
1122 if (imm8 == 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1123 emit_byte(0xD1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1124 emit_byte(0xD0 | dst->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
1125 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1126 emit_byte(0xC1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1127 emit_byte(0xD0 | dst->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
1128 emit_byte(imm8);
a61af66fc99e Initial load
duke
parents:
diff changeset
1129 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1130 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1131
a61af66fc99e Initial load
duke
parents:
diff changeset
1132
a61af66fc99e Initial load
duke
parents:
diff changeset
1133 void Assembler::sarl(Register dst, int imm8) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1134 assert(isShiftCount(imm8), "illegal shift count");
a61af66fc99e Initial load
duke
parents:
diff changeset
1135 if (imm8 == 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1136 emit_byte(0xD1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1137 emit_byte(0xF8 | dst->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
1138 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1139 emit_byte(0xC1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1140 emit_byte(0xF8 | dst->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
1141 emit_byte(imm8);
a61af66fc99e Initial load
duke
parents:
diff changeset
1142 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1143 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1144
a61af66fc99e Initial load
duke
parents:
diff changeset
1145
a61af66fc99e Initial load
duke
parents:
diff changeset
1146 void Assembler::sarl(Register dst) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1147 emit_byte(0xD3);
a61af66fc99e Initial load
duke
parents:
diff changeset
1148 emit_byte(0xF8 | dst->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
1149 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1150
a61af66fc99e Initial load
duke
parents:
diff changeset
1151
a61af66fc99e Initial load
duke
parents:
diff changeset
1152 void Assembler::sbbl(Address dst, int imm32) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1153 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1154 emit_arith_operand(0x81,rbx,dst,imm32);
a61af66fc99e Initial load
duke
parents:
diff changeset
1155 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1156
a61af66fc99e Initial load
duke
parents:
diff changeset
1157
a61af66fc99e Initial load
duke
parents:
diff changeset
1158 void Assembler::sbbl(Register dst, int imm32) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1159 emit_arith(0x81, 0xD8, dst, imm32);
a61af66fc99e Initial load
duke
parents:
diff changeset
1160 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1161
a61af66fc99e Initial load
duke
parents:
diff changeset
1162
a61af66fc99e Initial load
duke
parents:
diff changeset
1163 void Assembler::sbbl(Register dst, Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1164 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1165 emit_byte(0x1B);
a61af66fc99e Initial load
duke
parents:
diff changeset
1166 emit_operand(dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
1167 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1168
a61af66fc99e Initial load
duke
parents:
diff changeset
1169
a61af66fc99e Initial load
duke
parents:
diff changeset
1170 void Assembler::sbbl(Register dst, Register src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1171 emit_arith(0x1B, 0xC0, dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
1172 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1173
a61af66fc99e Initial load
duke
parents:
diff changeset
1174
a61af66fc99e Initial load
duke
parents:
diff changeset
1175 void Assembler::shldl(Register dst, Register src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1176 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
1177 emit_byte(0xA5);
a61af66fc99e Initial load
duke
parents:
diff changeset
1178 emit_byte(0xC0 | src->encoding() << 3 | dst->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
1179 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1180
a61af66fc99e Initial load
duke
parents:
diff changeset
1181
a61af66fc99e Initial load
duke
parents:
diff changeset
1182 void Assembler::shll(Register dst, int imm8) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1183 assert(isShiftCount(imm8), "illegal shift count");
a61af66fc99e Initial load
duke
parents:
diff changeset
1184 if (imm8 == 1 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1185 emit_byte(0xD1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1186 emit_byte(0xE0 | dst->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
1187 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1188 emit_byte(0xC1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1189 emit_byte(0xE0 | dst->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
1190 emit_byte(imm8);
a61af66fc99e Initial load
duke
parents:
diff changeset
1191 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1192 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1193
a61af66fc99e Initial load
duke
parents:
diff changeset
1194
a61af66fc99e Initial load
duke
parents:
diff changeset
1195 void Assembler::shll(Register dst) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1196 emit_byte(0xD3);
a61af66fc99e Initial load
duke
parents:
diff changeset
1197 emit_byte(0xE0 | dst->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
1198 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1199
a61af66fc99e Initial load
duke
parents:
diff changeset
1200
a61af66fc99e Initial load
duke
parents:
diff changeset
1201 void Assembler::shrdl(Register dst, Register src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1202 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
1203 emit_byte(0xAD);
a61af66fc99e Initial load
duke
parents:
diff changeset
1204 emit_byte(0xC0 | src->encoding() << 3 | dst->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
1205 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1206
a61af66fc99e Initial load
duke
parents:
diff changeset
1207
a61af66fc99e Initial load
duke
parents:
diff changeset
1208 void Assembler::shrl(Register dst, int imm8) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1209 assert(isShiftCount(imm8), "illegal shift count");
a61af66fc99e Initial load
duke
parents:
diff changeset
1210 emit_byte(0xC1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1211 emit_byte(0xE8 | dst->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
1212 emit_byte(imm8);
a61af66fc99e Initial load
duke
parents:
diff changeset
1213 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1214
a61af66fc99e Initial load
duke
parents:
diff changeset
1215
a61af66fc99e Initial load
duke
parents:
diff changeset
1216 void Assembler::shrl(Register dst) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1217 emit_byte(0xD3);
a61af66fc99e Initial load
duke
parents:
diff changeset
1218 emit_byte(0xE8 | dst->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
1219 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1220
a61af66fc99e Initial load
duke
parents:
diff changeset
1221
a61af66fc99e Initial load
duke
parents:
diff changeset
1222 void Assembler::subl(Address dst, int imm32) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1223 if (is8bit(imm32)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1224 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1225 emit_byte(0x83);
a61af66fc99e Initial load
duke
parents:
diff changeset
1226 emit_operand(rbp, dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
1227 emit_byte(imm32 & 0xFF);
a61af66fc99e Initial load
duke
parents:
diff changeset
1228 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1229 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1230 emit_byte(0x81);
a61af66fc99e Initial load
duke
parents:
diff changeset
1231 emit_operand(rbp, dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
1232 emit_long(imm32);
a61af66fc99e Initial load
duke
parents:
diff changeset
1233 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1234 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1235
a61af66fc99e Initial load
duke
parents:
diff changeset
1236
a61af66fc99e Initial load
duke
parents:
diff changeset
1237 void Assembler::subl(Register dst, int imm32) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1238 emit_arith(0x81, 0xE8, dst, imm32);
a61af66fc99e Initial load
duke
parents:
diff changeset
1239 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1240
a61af66fc99e Initial load
duke
parents:
diff changeset
1241
a61af66fc99e Initial load
duke
parents:
diff changeset
1242 void Assembler::subl(Address dst, Register src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1243 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1244 emit_byte(0x29);
a61af66fc99e Initial load
duke
parents:
diff changeset
1245 emit_operand(src, dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
1246 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1247
a61af66fc99e Initial load
duke
parents:
diff changeset
1248
a61af66fc99e Initial load
duke
parents:
diff changeset
1249 void Assembler::subl(Register dst, Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1250 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1251 emit_byte(0x2B);
a61af66fc99e Initial load
duke
parents:
diff changeset
1252 emit_operand(dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
1253 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1254
a61af66fc99e Initial load
duke
parents:
diff changeset
1255
a61af66fc99e Initial load
duke
parents:
diff changeset
1256 void Assembler::subl(Register dst, Register src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1257 emit_arith(0x2B, 0xC0, dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
1258 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1259
a61af66fc99e Initial load
duke
parents:
diff changeset
1260
a61af66fc99e Initial load
duke
parents:
diff changeset
1261 void Assembler::testb(Register dst, int imm8) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1262 assert(dst->has_byte_register(), "must have byte register");
a61af66fc99e Initial load
duke
parents:
diff changeset
1263 emit_arith_b(0xF6, 0xC0, dst, imm8);
a61af66fc99e Initial load
duke
parents:
diff changeset
1264 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1265
a61af66fc99e Initial load
duke
parents:
diff changeset
1266
a61af66fc99e Initial load
duke
parents:
diff changeset
1267 void Assembler::testl(Register dst, int imm32) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1268 // not using emit_arith because test
a61af66fc99e Initial load
duke
parents:
diff changeset
1269 // doesn't support sign-extension of
a61af66fc99e Initial load
duke
parents:
diff changeset
1270 // 8bit operands
a61af66fc99e Initial load
duke
parents:
diff changeset
1271 if (dst->encoding() == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1272 emit_byte(0xA9);
a61af66fc99e Initial load
duke
parents:
diff changeset
1273 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1274 emit_byte(0xF7);
a61af66fc99e Initial load
duke
parents:
diff changeset
1275 emit_byte(0xC0 | dst->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
1276 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1277 emit_long(imm32);
a61af66fc99e Initial load
duke
parents:
diff changeset
1278 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1279
a61af66fc99e Initial load
duke
parents:
diff changeset
1280
a61af66fc99e Initial load
duke
parents:
diff changeset
1281 void Assembler::testl(Register dst, Register src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1282 emit_arith(0x85, 0xC0, dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
1283 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1284
a61af66fc99e Initial load
duke
parents:
diff changeset
1285 void Assembler::testl(Register dst, Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1286 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1287 emit_byte(0x85);
a61af66fc99e Initial load
duke
parents:
diff changeset
1288 emit_operand(dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
1289 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1290
a61af66fc99e Initial load
duke
parents:
diff changeset
1291 void Assembler::xaddl(Address dst, Register src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1292 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1293 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
1294 emit_byte(0xC1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1295 emit_operand(src, dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
1296 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1297
a61af66fc99e Initial load
duke
parents:
diff changeset
1298 void Assembler::xorl(Register dst, int imm32) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1299 emit_arith(0x81, 0xF0, dst, imm32);
a61af66fc99e Initial load
duke
parents:
diff changeset
1300 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1301
a61af66fc99e Initial load
duke
parents:
diff changeset
1302
a61af66fc99e Initial load
duke
parents:
diff changeset
1303 void Assembler::xorl(Register dst, Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1304 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1305 emit_byte(0x33);
a61af66fc99e Initial load
duke
parents:
diff changeset
1306 emit_operand(dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
1307 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1308
a61af66fc99e Initial load
duke
parents:
diff changeset
1309
a61af66fc99e Initial load
duke
parents:
diff changeset
1310 void Assembler::xorl(Register dst, Register src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1311 emit_arith(0x33, 0xC0, dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
1312 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1313
a61af66fc99e Initial load
duke
parents:
diff changeset
1314
a61af66fc99e Initial load
duke
parents:
diff changeset
1315 void Assembler::bswap(Register reg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1316 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
1317 emit_byte(0xC8 | reg->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
1318 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1319
a61af66fc99e Initial load
duke
parents:
diff changeset
1320
a61af66fc99e Initial load
duke
parents:
diff changeset
1321 void Assembler::lock() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1322 if (Atomics & 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1323 // Emit either nothing, a NOP, or a NOP: prefix
a61af66fc99e Initial load
duke
parents:
diff changeset
1324 emit_byte(0x90) ;
a61af66fc99e Initial load
duke
parents:
diff changeset
1325 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1326 emit_byte(0xF0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1327 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1328 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1329
a61af66fc99e Initial load
duke
parents:
diff changeset
1330
a61af66fc99e Initial load
duke
parents:
diff changeset
1331 void Assembler::xchg(Register reg, Address adr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1332 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1333 emit_byte(0x87);
a61af66fc99e Initial load
duke
parents:
diff changeset
1334 emit_operand(reg, adr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1335 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1336
a61af66fc99e Initial load
duke
parents:
diff changeset
1337
a61af66fc99e Initial load
duke
parents:
diff changeset
1338 void Assembler::xchgl(Register dst, Register src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1339 emit_byte(0x87);
a61af66fc99e Initial load
duke
parents:
diff changeset
1340 emit_byte(0xc0 | dst->encoding() << 3 | src->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
1341 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1342
a61af66fc99e Initial load
duke
parents:
diff changeset
1343
a61af66fc99e Initial load
duke
parents:
diff changeset
1344 // The 32-bit cmpxchg compares the value at adr with the contents of rax,
a61af66fc99e Initial load
duke
parents:
diff changeset
1345 // and stores reg into adr if so; otherwise, the value at adr is loaded into rax,.
a61af66fc99e Initial load
duke
parents:
diff changeset
1346 // The ZF is set if the compared values were equal, and cleared otherwise.
a61af66fc99e Initial load
duke
parents:
diff changeset
1347 void Assembler::cmpxchg(Register reg, Address adr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1348 if (Atomics & 2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1349 // caveat: no instructionmark, so this isn't relocatable.
a61af66fc99e Initial load
duke
parents:
diff changeset
1350 // Emit a synthetic, non-atomic, CAS equivalent.
a61af66fc99e Initial load
duke
parents:
diff changeset
1351 // Beware. The synthetic form sets all ICCs, not just ZF.
a61af66fc99e Initial load
duke
parents:
diff changeset
1352 // cmpxchg r,[m] is equivalent to rax, = CAS (m, rax, r)
a61af66fc99e Initial load
duke
parents:
diff changeset
1353 cmpl (rax, adr) ;
a61af66fc99e Initial load
duke
parents:
diff changeset
1354 movl (rax, adr) ;
a61af66fc99e Initial load
duke
parents:
diff changeset
1355 if (reg != rax) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1356 Label L ;
a61af66fc99e Initial load
duke
parents:
diff changeset
1357 jcc (Assembler::notEqual, L) ;
a61af66fc99e Initial load
duke
parents:
diff changeset
1358 movl (adr, reg) ;
a61af66fc99e Initial load
duke
parents:
diff changeset
1359 bind (L) ;
a61af66fc99e Initial load
duke
parents:
diff changeset
1360 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1361 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1362 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1363 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
1364 emit_byte(0xB1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1365 emit_operand(reg, adr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1366 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1367 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1368
a61af66fc99e Initial load
duke
parents:
diff changeset
1369 // The 64-bit cmpxchg compares the value at adr with the contents of rdx:rax,
a61af66fc99e Initial load
duke
parents:
diff changeset
1370 // and stores rcx:rbx into adr if so; otherwise, the value at adr is loaded
a61af66fc99e Initial load
duke
parents:
diff changeset
1371 // into rdx:rax. The ZF is set if the compared values were equal, and cleared otherwise.
a61af66fc99e Initial load
duke
parents:
diff changeset
1372 void Assembler::cmpxchg8(Address adr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1373 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1374 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
1375 emit_byte(0xc7);
a61af66fc99e Initial load
duke
parents:
diff changeset
1376 emit_operand(rcx, adr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1377 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1378
a61af66fc99e Initial load
duke
parents:
diff changeset
1379 void Assembler::hlt() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1380 emit_byte(0xF4);
a61af66fc99e Initial load
duke
parents:
diff changeset
1381 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1382
a61af66fc99e Initial load
duke
parents:
diff changeset
1383
a61af66fc99e Initial load
duke
parents:
diff changeset
1384 void Assembler::addr_nop_4() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1385 // 4 bytes: NOP DWORD PTR [EAX+0]
a61af66fc99e Initial load
duke
parents:
diff changeset
1386 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
1387 emit_byte(0x1F);
a61af66fc99e Initial load
duke
parents:
diff changeset
1388 emit_byte(0x40); // emit_rm(cbuf, 0x1, EAX_enc, EAX_enc);
a61af66fc99e Initial load
duke
parents:
diff changeset
1389 emit_byte(0); // 8-bits offset (1 byte)
a61af66fc99e Initial load
duke
parents:
diff changeset
1390 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1391
a61af66fc99e Initial load
duke
parents:
diff changeset
1392 void Assembler::addr_nop_5() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1393 // 5 bytes: NOP DWORD PTR [EAX+EAX*0+0] 8-bits offset
a61af66fc99e Initial load
duke
parents:
diff changeset
1394 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
1395 emit_byte(0x1F);
a61af66fc99e Initial load
duke
parents:
diff changeset
1396 emit_byte(0x44); // emit_rm(cbuf, 0x1, EAX_enc, 0x4);
a61af66fc99e Initial load
duke
parents:
diff changeset
1397 emit_byte(0x00); // emit_rm(cbuf, 0x0, EAX_enc, EAX_enc);
a61af66fc99e Initial load
duke
parents:
diff changeset
1398 emit_byte(0); // 8-bits offset (1 byte)
a61af66fc99e Initial load
duke
parents:
diff changeset
1399 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1400
a61af66fc99e Initial load
duke
parents:
diff changeset
1401 void Assembler::addr_nop_7() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1402 // 7 bytes: NOP DWORD PTR [EAX+0] 32-bits offset
a61af66fc99e Initial load
duke
parents:
diff changeset
1403 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
1404 emit_byte(0x1F);
a61af66fc99e Initial load
duke
parents:
diff changeset
1405 emit_byte(0x80); // emit_rm(cbuf, 0x2, EAX_enc, EAX_enc);
a61af66fc99e Initial load
duke
parents:
diff changeset
1406 emit_long(0); // 32-bits offset (4 bytes)
a61af66fc99e Initial load
duke
parents:
diff changeset
1407 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1408
a61af66fc99e Initial load
duke
parents:
diff changeset
1409 void Assembler::addr_nop_8() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1410 // 8 bytes: NOP DWORD PTR [EAX+EAX*0+0] 32-bits offset
a61af66fc99e Initial load
duke
parents:
diff changeset
1411 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
1412 emit_byte(0x1F);
a61af66fc99e Initial load
duke
parents:
diff changeset
1413 emit_byte(0x84); // emit_rm(cbuf, 0x2, EAX_enc, 0x4);
a61af66fc99e Initial load
duke
parents:
diff changeset
1414 emit_byte(0x00); // emit_rm(cbuf, 0x0, EAX_enc, EAX_enc);
a61af66fc99e Initial load
duke
parents:
diff changeset
1415 emit_long(0); // 32-bits offset (4 bytes)
a61af66fc99e Initial load
duke
parents:
diff changeset
1416 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1417
a61af66fc99e Initial load
duke
parents:
diff changeset
1418 void Assembler::nop(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1419 assert(i > 0, " ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1420 if (UseAddressNop && VM_Version::is_intel()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1421 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1422 // Using multi-bytes nops "0x0F 0x1F [address]" for Intel
a61af66fc99e Initial load
duke
parents:
diff changeset
1423 // 1: 0x90
a61af66fc99e Initial load
duke
parents:
diff changeset
1424 // 2: 0x66 0x90
a61af66fc99e Initial load
duke
parents:
diff changeset
1425 // 3: 0x66 0x66 0x90 (don't use "0x0F 0x1F 0x00" - need patching safe padding)
a61af66fc99e Initial load
duke
parents:
diff changeset
1426 // 4: 0x0F 0x1F 0x40 0x00
a61af66fc99e Initial load
duke
parents:
diff changeset
1427 // 5: 0x0F 0x1F 0x44 0x00 0x00
a61af66fc99e Initial load
duke
parents:
diff changeset
1428 // 6: 0x66 0x0F 0x1F 0x44 0x00 0x00
a61af66fc99e Initial load
duke
parents:
diff changeset
1429 // 7: 0x0F 0x1F 0x80 0x00 0x00 0x00 0x00
a61af66fc99e Initial load
duke
parents:
diff changeset
1430 // 8: 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00
a61af66fc99e Initial load
duke
parents:
diff changeset
1431 // 9: 0x66 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00
a61af66fc99e Initial load
duke
parents:
diff changeset
1432 // 10: 0x66 0x66 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00
a61af66fc99e Initial load
duke
parents:
diff changeset
1433 // 11: 0x66 0x66 0x66 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00
a61af66fc99e Initial load
duke
parents:
diff changeset
1434
a61af66fc99e Initial load
duke
parents:
diff changeset
1435 // The rest coding is Intel specific - don't use consecutive address nops
a61af66fc99e Initial load
duke
parents:
diff changeset
1436
a61af66fc99e Initial load
duke
parents:
diff changeset
1437 // 12: 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00 0x66 0x66 0x66 0x90
a61af66fc99e Initial load
duke
parents:
diff changeset
1438 // 13: 0x66 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00 0x66 0x66 0x66 0x90
a61af66fc99e Initial load
duke
parents:
diff changeset
1439 // 14: 0x66 0x66 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00 0x66 0x66 0x66 0x90
a61af66fc99e Initial load
duke
parents:
diff changeset
1440 // 15: 0x66 0x66 0x66 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00 0x66 0x66 0x66 0x90
a61af66fc99e Initial load
duke
parents:
diff changeset
1441
a61af66fc99e Initial load
duke
parents:
diff changeset
1442 while(i >= 15) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1443 // For Intel don't generate consecutive addess nops (mix with regular nops)
a61af66fc99e Initial load
duke
parents:
diff changeset
1444 i -= 15;
a61af66fc99e Initial load
duke
parents:
diff changeset
1445 emit_byte(0x66); // size prefix
a61af66fc99e Initial load
duke
parents:
diff changeset
1446 emit_byte(0x66); // size prefix
a61af66fc99e Initial load
duke
parents:
diff changeset
1447 emit_byte(0x66); // size prefix
a61af66fc99e Initial load
duke
parents:
diff changeset
1448 addr_nop_8();
a61af66fc99e Initial load
duke
parents:
diff changeset
1449 emit_byte(0x66); // size prefix
a61af66fc99e Initial load
duke
parents:
diff changeset
1450 emit_byte(0x66); // size prefix
a61af66fc99e Initial load
duke
parents:
diff changeset
1451 emit_byte(0x66); // size prefix
a61af66fc99e Initial load
duke
parents:
diff changeset
1452 emit_byte(0x90); // nop
a61af66fc99e Initial load
duke
parents:
diff changeset
1453 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1454 switch (i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1455 case 14:
a61af66fc99e Initial load
duke
parents:
diff changeset
1456 emit_byte(0x66); // size prefix
a61af66fc99e Initial load
duke
parents:
diff changeset
1457 case 13:
a61af66fc99e Initial load
duke
parents:
diff changeset
1458 emit_byte(0x66); // size prefix
a61af66fc99e Initial load
duke
parents:
diff changeset
1459 case 12:
a61af66fc99e Initial load
duke
parents:
diff changeset
1460 addr_nop_8();
a61af66fc99e Initial load
duke
parents:
diff changeset
1461 emit_byte(0x66); // size prefix
a61af66fc99e Initial load
duke
parents:
diff changeset
1462 emit_byte(0x66); // size prefix
a61af66fc99e Initial load
duke
parents:
diff changeset
1463 emit_byte(0x66); // size prefix
a61af66fc99e Initial load
duke
parents:
diff changeset
1464 emit_byte(0x90); // nop
a61af66fc99e Initial load
duke
parents:
diff changeset
1465 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1466 case 11:
a61af66fc99e Initial load
duke
parents:
diff changeset
1467 emit_byte(0x66); // size prefix
a61af66fc99e Initial load
duke
parents:
diff changeset
1468 case 10:
a61af66fc99e Initial load
duke
parents:
diff changeset
1469 emit_byte(0x66); // size prefix
a61af66fc99e Initial load
duke
parents:
diff changeset
1470 case 9:
a61af66fc99e Initial load
duke
parents:
diff changeset
1471 emit_byte(0x66); // size prefix
a61af66fc99e Initial load
duke
parents:
diff changeset
1472 case 8:
a61af66fc99e Initial load
duke
parents:
diff changeset
1473 addr_nop_8();
a61af66fc99e Initial load
duke
parents:
diff changeset
1474 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1475 case 7:
a61af66fc99e Initial load
duke
parents:
diff changeset
1476 addr_nop_7();
a61af66fc99e Initial load
duke
parents:
diff changeset
1477 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1478 case 6:
a61af66fc99e Initial load
duke
parents:
diff changeset
1479 emit_byte(0x66); // size prefix
a61af66fc99e Initial load
duke
parents:
diff changeset
1480 case 5:
a61af66fc99e Initial load
duke
parents:
diff changeset
1481 addr_nop_5();
a61af66fc99e Initial load
duke
parents:
diff changeset
1482 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1483 case 4:
a61af66fc99e Initial load
duke
parents:
diff changeset
1484 addr_nop_4();
a61af66fc99e Initial load
duke
parents:
diff changeset
1485 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1486 case 3:
a61af66fc99e Initial load
duke
parents:
diff changeset
1487 // Don't use "0x0F 0x1F 0x00" - need patching safe padding
a61af66fc99e Initial load
duke
parents:
diff changeset
1488 emit_byte(0x66); // size prefix
a61af66fc99e Initial load
duke
parents:
diff changeset
1489 case 2:
a61af66fc99e Initial load
duke
parents:
diff changeset
1490 emit_byte(0x66); // size prefix
a61af66fc99e Initial load
duke
parents:
diff changeset
1491 case 1:
a61af66fc99e Initial load
duke
parents:
diff changeset
1492 emit_byte(0x90); // nop
a61af66fc99e Initial load
duke
parents:
diff changeset
1493 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1494 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
1495 assert(i == 0, " ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1496 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1497 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
1498 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1499 if (UseAddressNop && VM_Version::is_amd()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1500 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1501 // Using multi-bytes nops "0x0F 0x1F [address]" for AMD.
a61af66fc99e Initial load
duke
parents:
diff changeset
1502 // 1: 0x90
a61af66fc99e Initial load
duke
parents:
diff changeset
1503 // 2: 0x66 0x90
a61af66fc99e Initial load
duke
parents:
diff changeset
1504 // 3: 0x66 0x66 0x90 (don't use "0x0F 0x1F 0x00" - need patching safe padding)
a61af66fc99e Initial load
duke
parents:
diff changeset
1505 // 4: 0x0F 0x1F 0x40 0x00
a61af66fc99e Initial load
duke
parents:
diff changeset
1506 // 5: 0x0F 0x1F 0x44 0x00 0x00
a61af66fc99e Initial load
duke
parents:
diff changeset
1507 // 6: 0x66 0x0F 0x1F 0x44 0x00 0x00
a61af66fc99e Initial load
duke
parents:
diff changeset
1508 // 7: 0x0F 0x1F 0x80 0x00 0x00 0x00 0x00
a61af66fc99e Initial load
duke
parents:
diff changeset
1509 // 8: 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00
a61af66fc99e Initial load
duke
parents:
diff changeset
1510 // 9: 0x66 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00
a61af66fc99e Initial load
duke
parents:
diff changeset
1511 // 10: 0x66 0x66 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00
a61af66fc99e Initial load
duke
parents:
diff changeset
1512 // 11: 0x66 0x66 0x66 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00
a61af66fc99e Initial load
duke
parents:
diff changeset
1513
a61af66fc99e Initial load
duke
parents:
diff changeset
1514 // The rest coding is AMD specific - use consecutive address nops
a61af66fc99e Initial load
duke
parents:
diff changeset
1515
a61af66fc99e Initial load
duke
parents:
diff changeset
1516 // 12: 0x66 0x0F 0x1F 0x44 0x00 0x00 0x66 0x0F 0x1F 0x44 0x00 0x00
a61af66fc99e Initial load
duke
parents:
diff changeset
1517 // 13: 0x0F 0x1F 0x80 0x00 0x00 0x00 0x00 0x66 0x0F 0x1F 0x44 0x00 0x00
a61af66fc99e Initial load
duke
parents:
diff changeset
1518 // 14: 0x0F 0x1F 0x80 0x00 0x00 0x00 0x00 0x0F 0x1F 0x80 0x00 0x00 0x00 0x00
a61af66fc99e Initial load
duke
parents:
diff changeset
1519 // 15: 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00 0x0F 0x1F 0x80 0x00 0x00 0x00 0x00
a61af66fc99e Initial load
duke
parents:
diff changeset
1520 // 16: 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00
a61af66fc99e Initial load
duke
parents:
diff changeset
1521 // Size prefixes (0x66) are added for larger sizes
a61af66fc99e Initial load
duke
parents:
diff changeset
1522
a61af66fc99e Initial load
duke
parents:
diff changeset
1523 while(i >= 22) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1524 i -= 11;
a61af66fc99e Initial load
duke
parents:
diff changeset
1525 emit_byte(0x66); // size prefix
a61af66fc99e Initial load
duke
parents:
diff changeset
1526 emit_byte(0x66); // size prefix
a61af66fc99e Initial load
duke
parents:
diff changeset
1527 emit_byte(0x66); // size prefix
a61af66fc99e Initial load
duke
parents:
diff changeset
1528 addr_nop_8();
a61af66fc99e Initial load
duke
parents:
diff changeset
1529 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1530 // Generate first nop for size between 21-12
a61af66fc99e Initial load
duke
parents:
diff changeset
1531 switch (i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1532 case 21:
a61af66fc99e Initial load
duke
parents:
diff changeset
1533 i -= 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
1534 emit_byte(0x66); // size prefix
a61af66fc99e Initial load
duke
parents:
diff changeset
1535 case 20:
a61af66fc99e Initial load
duke
parents:
diff changeset
1536 case 19:
a61af66fc99e Initial load
duke
parents:
diff changeset
1537 i -= 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
1538 emit_byte(0x66); // size prefix
a61af66fc99e Initial load
duke
parents:
diff changeset
1539 case 18:
a61af66fc99e Initial load
duke
parents:
diff changeset
1540 case 17:
a61af66fc99e Initial load
duke
parents:
diff changeset
1541 i -= 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
1542 emit_byte(0x66); // size prefix
a61af66fc99e Initial load
duke
parents:
diff changeset
1543 case 16:
a61af66fc99e Initial load
duke
parents:
diff changeset
1544 case 15:
a61af66fc99e Initial load
duke
parents:
diff changeset
1545 i -= 8;
a61af66fc99e Initial load
duke
parents:
diff changeset
1546 addr_nop_8();
a61af66fc99e Initial load
duke
parents:
diff changeset
1547 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1548 case 14:
a61af66fc99e Initial load
duke
parents:
diff changeset
1549 case 13:
a61af66fc99e Initial load
duke
parents:
diff changeset
1550 i -= 7;
a61af66fc99e Initial load
duke
parents:
diff changeset
1551 addr_nop_7();
a61af66fc99e Initial load
duke
parents:
diff changeset
1552 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1553 case 12:
a61af66fc99e Initial load
duke
parents:
diff changeset
1554 i -= 6;
a61af66fc99e Initial load
duke
parents:
diff changeset
1555 emit_byte(0x66); // size prefix
a61af66fc99e Initial load
duke
parents:
diff changeset
1556 addr_nop_5();
a61af66fc99e Initial load
duke
parents:
diff changeset
1557 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1558 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
1559 assert(i < 12, " ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1560 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1561
a61af66fc99e Initial load
duke
parents:
diff changeset
1562 // Generate second nop for size between 11-1
a61af66fc99e Initial load
duke
parents:
diff changeset
1563 switch (i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1564 case 11:
a61af66fc99e Initial load
duke
parents:
diff changeset
1565 emit_byte(0x66); // size prefix
a61af66fc99e Initial load
duke
parents:
diff changeset
1566 case 10:
a61af66fc99e Initial load
duke
parents:
diff changeset
1567 emit_byte(0x66); // size prefix
a61af66fc99e Initial load
duke
parents:
diff changeset
1568 case 9:
a61af66fc99e Initial load
duke
parents:
diff changeset
1569 emit_byte(0x66); // size prefix
a61af66fc99e Initial load
duke
parents:
diff changeset
1570 case 8:
a61af66fc99e Initial load
duke
parents:
diff changeset
1571 addr_nop_8();
a61af66fc99e Initial load
duke
parents:
diff changeset
1572 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1573 case 7:
a61af66fc99e Initial load
duke
parents:
diff changeset
1574 addr_nop_7();
a61af66fc99e Initial load
duke
parents:
diff changeset
1575 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1576 case 6:
a61af66fc99e Initial load
duke
parents:
diff changeset
1577 emit_byte(0x66); // size prefix
a61af66fc99e Initial load
duke
parents:
diff changeset
1578 case 5:
a61af66fc99e Initial load
duke
parents:
diff changeset
1579 addr_nop_5();
a61af66fc99e Initial load
duke
parents:
diff changeset
1580 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1581 case 4:
a61af66fc99e Initial load
duke
parents:
diff changeset
1582 addr_nop_4();
a61af66fc99e Initial load
duke
parents:
diff changeset
1583 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1584 case 3:
a61af66fc99e Initial load
duke
parents:
diff changeset
1585 // Don't use "0x0F 0x1F 0x00" - need patching safe padding
a61af66fc99e Initial load
duke
parents:
diff changeset
1586 emit_byte(0x66); // size prefix
a61af66fc99e Initial load
duke
parents:
diff changeset
1587 case 2:
a61af66fc99e Initial load
duke
parents:
diff changeset
1588 emit_byte(0x66); // size prefix
a61af66fc99e Initial load
duke
parents:
diff changeset
1589 case 1:
a61af66fc99e Initial load
duke
parents:
diff changeset
1590 emit_byte(0x90); // nop
a61af66fc99e Initial load
duke
parents:
diff changeset
1591 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1592 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
1593 assert(i == 0, " ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1594 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1595 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
1596 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1597
a61af66fc99e Initial load
duke
parents:
diff changeset
1598 // Using nops with size prefixes "0x66 0x90".
a61af66fc99e Initial load
duke
parents:
diff changeset
1599 // From AMD Optimization Guide:
a61af66fc99e Initial load
duke
parents:
diff changeset
1600 // 1: 0x90
a61af66fc99e Initial load
duke
parents:
diff changeset
1601 // 2: 0x66 0x90
a61af66fc99e Initial load
duke
parents:
diff changeset
1602 // 3: 0x66 0x66 0x90
a61af66fc99e Initial load
duke
parents:
diff changeset
1603 // 4: 0x66 0x66 0x66 0x90
a61af66fc99e Initial load
duke
parents:
diff changeset
1604 // 5: 0x66 0x66 0x90 0x66 0x90
a61af66fc99e Initial load
duke
parents:
diff changeset
1605 // 6: 0x66 0x66 0x90 0x66 0x66 0x90
a61af66fc99e Initial load
duke
parents:
diff changeset
1606 // 7: 0x66 0x66 0x66 0x90 0x66 0x66 0x90
a61af66fc99e Initial load
duke
parents:
diff changeset
1607 // 8: 0x66 0x66 0x66 0x90 0x66 0x66 0x66 0x90
a61af66fc99e Initial load
duke
parents:
diff changeset
1608 // 9: 0x66 0x66 0x90 0x66 0x66 0x90 0x66 0x66 0x90
a61af66fc99e Initial load
duke
parents:
diff changeset
1609 // 10: 0x66 0x66 0x66 0x90 0x66 0x66 0x90 0x66 0x66 0x90
a61af66fc99e Initial load
duke
parents:
diff changeset
1610 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1611 while(i > 12) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1612 i -= 4;
a61af66fc99e Initial load
duke
parents:
diff changeset
1613 emit_byte(0x66); // size prefix
a61af66fc99e Initial load
duke
parents:
diff changeset
1614 emit_byte(0x66);
a61af66fc99e Initial load
duke
parents:
diff changeset
1615 emit_byte(0x66);
a61af66fc99e Initial load
duke
parents:
diff changeset
1616 emit_byte(0x90); // nop
a61af66fc99e Initial load
duke
parents:
diff changeset
1617 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1618 // 1 - 12 nops
a61af66fc99e Initial load
duke
parents:
diff changeset
1619 if(i > 8) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1620 if(i > 9) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1621 i -= 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
1622 emit_byte(0x66);
a61af66fc99e Initial load
duke
parents:
diff changeset
1623 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1624 i -= 3;
a61af66fc99e Initial load
duke
parents:
diff changeset
1625 emit_byte(0x66);
a61af66fc99e Initial load
duke
parents:
diff changeset
1626 emit_byte(0x66);
a61af66fc99e Initial load
duke
parents:
diff changeset
1627 emit_byte(0x90);
a61af66fc99e Initial load
duke
parents:
diff changeset
1628 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1629 // 1 - 8 nops
a61af66fc99e Initial load
duke
parents:
diff changeset
1630 if(i > 4) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1631 if(i > 6) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1632 i -= 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
1633 emit_byte(0x66);
a61af66fc99e Initial load
duke
parents:
diff changeset
1634 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1635 i -= 3;
a61af66fc99e Initial load
duke
parents:
diff changeset
1636 emit_byte(0x66);
a61af66fc99e Initial load
duke
parents:
diff changeset
1637 emit_byte(0x66);
a61af66fc99e Initial load
duke
parents:
diff changeset
1638 emit_byte(0x90);
a61af66fc99e Initial load
duke
parents:
diff changeset
1639 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1640 switch (i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1641 case 4:
a61af66fc99e Initial load
duke
parents:
diff changeset
1642 emit_byte(0x66);
a61af66fc99e Initial load
duke
parents:
diff changeset
1643 case 3:
a61af66fc99e Initial load
duke
parents:
diff changeset
1644 emit_byte(0x66);
a61af66fc99e Initial load
duke
parents:
diff changeset
1645 case 2:
a61af66fc99e Initial load
duke
parents:
diff changeset
1646 emit_byte(0x66);
a61af66fc99e Initial load
duke
parents:
diff changeset
1647 case 1:
a61af66fc99e Initial load
duke
parents:
diff changeset
1648 emit_byte(0x90);
a61af66fc99e Initial load
duke
parents:
diff changeset
1649 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1650 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
1651 assert(i == 0, " ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1652 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1653 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1654
a61af66fc99e Initial load
duke
parents:
diff changeset
1655 void Assembler::ret(int imm16) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1656 if (imm16 == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1657 emit_byte(0xC3);
a61af66fc99e Initial load
duke
parents:
diff changeset
1658 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1659 emit_byte(0xC2);
a61af66fc99e Initial load
duke
parents:
diff changeset
1660 emit_word(imm16);
a61af66fc99e Initial load
duke
parents:
diff changeset
1661 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1662 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1663
a61af66fc99e Initial load
duke
parents:
diff changeset
1664
a61af66fc99e Initial load
duke
parents:
diff changeset
1665 void Assembler::set_byte_if_not_zero(Register dst) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1666 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
1667 emit_byte(0x95);
a61af66fc99e Initial load
duke
parents:
diff changeset
1668 emit_byte(0xE0 | dst->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
1669 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1670
a61af66fc99e Initial load
duke
parents:
diff changeset
1671
a61af66fc99e Initial load
duke
parents:
diff changeset
1672 // copies a single word from [esi] to [edi]
a61af66fc99e Initial load
duke
parents:
diff changeset
1673 void Assembler::smovl() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1674 emit_byte(0xA5);
a61af66fc99e Initial load
duke
parents:
diff changeset
1675 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1676
a61af66fc99e Initial load
duke
parents:
diff changeset
1677 // copies data from [esi] to [edi] using rcx double words (m32)
a61af66fc99e Initial load
duke
parents:
diff changeset
1678 void Assembler::rep_movl() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1679 emit_byte(0xF3);
a61af66fc99e Initial load
duke
parents:
diff changeset
1680 emit_byte(0xA5);
a61af66fc99e Initial load
duke
parents:
diff changeset
1681 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1682
a61af66fc99e Initial load
duke
parents:
diff changeset
1683
a61af66fc99e Initial load
duke
parents:
diff changeset
1684 // sets rcx double words (m32) with rax, value at [edi]
a61af66fc99e Initial load
duke
parents:
diff changeset
1685 void Assembler::rep_set() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1686 emit_byte(0xF3);
a61af66fc99e Initial load
duke
parents:
diff changeset
1687 emit_byte(0xAB);
a61af66fc99e Initial load
duke
parents:
diff changeset
1688 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1689
a61af66fc99e Initial load
duke
parents:
diff changeset
1690 // scans rcx double words (m32) at [edi] for occurance of rax,
a61af66fc99e Initial load
duke
parents:
diff changeset
1691 void Assembler::repne_scan() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1692 emit_byte(0xF2);
a61af66fc99e Initial load
duke
parents:
diff changeset
1693 emit_byte(0xAF);
a61af66fc99e Initial load
duke
parents:
diff changeset
1694 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1695
a61af66fc99e Initial load
duke
parents:
diff changeset
1696
a61af66fc99e Initial load
duke
parents:
diff changeset
1697 void Assembler::setb(Condition cc, Register dst) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1698 assert(0 <= cc && cc < 16, "illegal cc");
a61af66fc99e Initial load
duke
parents:
diff changeset
1699 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
1700 emit_byte(0x90 | cc);
a61af66fc99e Initial load
duke
parents:
diff changeset
1701 emit_byte(0xC0 | dst->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
1702 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1703
a61af66fc99e Initial load
duke
parents:
diff changeset
1704 void Assembler::cld() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1705 emit_byte(0xfc);
a61af66fc99e Initial load
duke
parents:
diff changeset
1706 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1707
a61af66fc99e Initial load
duke
parents:
diff changeset
1708 void Assembler::std() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1709 emit_byte(0xfd);
a61af66fc99e Initial load
duke
parents:
diff changeset
1710 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1711
a61af66fc99e Initial load
duke
parents:
diff changeset
1712 void Assembler::emit_raw (unsigned char b) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1713 emit_byte (b) ;
a61af66fc99e Initial load
duke
parents:
diff changeset
1714 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1715
a61af66fc99e Initial load
duke
parents:
diff changeset
1716 // Serializes memory.
a61af66fc99e Initial load
duke
parents:
diff changeset
1717 void Assembler::membar() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1718 // Memory barriers are only needed on multiprocessors
a61af66fc99e Initial load
duke
parents:
diff changeset
1719 if (os::is_MP()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1720 if( VM_Version::supports_sse2() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1721 emit_byte( 0x0F ); // MFENCE; faster blows no regs
a61af66fc99e Initial load
duke
parents:
diff changeset
1722 emit_byte( 0xAE );
a61af66fc99e Initial load
duke
parents:
diff changeset
1723 emit_byte( 0xF0 );
a61af66fc99e Initial load
duke
parents:
diff changeset
1724 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1725 // All usable chips support "locked" instructions which suffice
a61af66fc99e Initial load
duke
parents:
diff changeset
1726 // as barriers, and are much faster than the alternative of
a61af66fc99e Initial load
duke
parents:
diff changeset
1727 // using cpuid instruction. We use here a locked add [esp],0.
a61af66fc99e Initial load
duke
parents:
diff changeset
1728 // This is conveniently otherwise a no-op except for blowing
a61af66fc99e Initial load
duke
parents:
diff changeset
1729 // flags (which we save and restore.)
a61af66fc99e Initial load
duke
parents:
diff changeset
1730 pushfd(); // Save eflags register
a61af66fc99e Initial load
duke
parents:
diff changeset
1731 lock();
a61af66fc99e Initial load
duke
parents:
diff changeset
1732 addl(Address(rsp, 0), 0);// Assert the lock# signal here
a61af66fc99e Initial load
duke
parents:
diff changeset
1733 popfd(); // Restore eflags register
a61af66fc99e Initial load
duke
parents:
diff changeset
1734 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1735 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1736 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1737
a61af66fc99e Initial load
duke
parents:
diff changeset
1738 // Identify processor type and features
a61af66fc99e Initial load
duke
parents:
diff changeset
1739 void Assembler::cpuid() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1740 // Note: we can't assert VM_Version::supports_cpuid() here
a61af66fc99e Initial load
duke
parents:
diff changeset
1741 // because this instruction is used in the processor
a61af66fc99e Initial load
duke
parents:
diff changeset
1742 // identification code.
a61af66fc99e Initial load
duke
parents:
diff changeset
1743 emit_byte( 0x0F );
a61af66fc99e Initial load
duke
parents:
diff changeset
1744 emit_byte( 0xA2 );
a61af66fc99e Initial load
duke
parents:
diff changeset
1745 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1746
a61af66fc99e Initial load
duke
parents:
diff changeset
1747 void Assembler::call(Label& L, relocInfo::relocType rtype) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1748 if (L.is_bound()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1749 const int long_size = 5;
a61af66fc99e Initial load
duke
parents:
diff changeset
1750 int offs = target(L) - pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
1751 assert(offs <= 0, "assembler error");
a61af66fc99e Initial load
duke
parents:
diff changeset
1752 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1753 // 1110 1000 #32-bit disp
a61af66fc99e Initial load
duke
parents:
diff changeset
1754 emit_byte(0xE8);
a61af66fc99e Initial load
duke
parents:
diff changeset
1755 emit_data(offs - long_size, rtype, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1756 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1757 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1758 // 1110 1000 #32-bit disp
a61af66fc99e Initial load
duke
parents:
diff changeset
1759 L.add_patch_at(code(), locator());
a61af66fc99e Initial load
duke
parents:
diff changeset
1760 emit_byte(0xE8);
a61af66fc99e Initial load
duke
parents:
diff changeset
1761 emit_data(int(0), rtype, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1762 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1763 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1764
a61af66fc99e Initial load
duke
parents:
diff changeset
1765 void Assembler::call(Register dst) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1766 emit_byte(0xFF);
a61af66fc99e Initial load
duke
parents:
diff changeset
1767 emit_byte(0xD0 | dst->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
1768 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1769
a61af66fc99e Initial load
duke
parents:
diff changeset
1770
a61af66fc99e Initial load
duke
parents:
diff changeset
1771 void Assembler::call(Address adr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1772 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1773 relocInfo::relocType rtype = adr.reloc();
a61af66fc99e Initial load
duke
parents:
diff changeset
1774 if (rtype != relocInfo::runtime_call_type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1775 emit_byte(0xFF);
a61af66fc99e Initial load
duke
parents:
diff changeset
1776 emit_operand(rdx, adr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1777 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1778 assert(false, "ack");
a61af66fc99e Initial load
duke
parents:
diff changeset
1779 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1780
a61af66fc99e Initial load
duke
parents:
diff changeset
1781 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1782
a61af66fc99e Initial load
duke
parents:
diff changeset
1783 void Assembler::call_literal(address dest, RelocationHolder const& rspec) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1784 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1785 emit_byte(0xE8);
a61af66fc99e Initial load
duke
parents:
diff changeset
1786 intptr_t disp = dest - (_code_pos + sizeof(int32_t));
a61af66fc99e Initial load
duke
parents:
diff changeset
1787 assert(dest != NULL, "must have a target");
a61af66fc99e Initial load
duke
parents:
diff changeset
1788 emit_data(disp, rspec, call32_operand);
a61af66fc99e Initial load
duke
parents:
diff changeset
1789
a61af66fc99e Initial load
duke
parents:
diff changeset
1790 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1791
a61af66fc99e Initial load
duke
parents:
diff changeset
1792 void Assembler::jmp(Register entry) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1793 emit_byte(0xFF);
a61af66fc99e Initial load
duke
parents:
diff changeset
1794 emit_byte(0xE0 | entry->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
1795 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1796
a61af66fc99e Initial load
duke
parents:
diff changeset
1797
a61af66fc99e Initial load
duke
parents:
diff changeset
1798 void Assembler::jmp(Address adr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1799 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1800 emit_byte(0xFF);
a61af66fc99e Initial load
duke
parents:
diff changeset
1801 emit_operand(rsp, adr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1802 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1803
a61af66fc99e Initial load
duke
parents:
diff changeset
1804 void Assembler::jmp_literal(address dest, RelocationHolder const& rspec) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1805 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1806 emit_byte(0xE9);
a61af66fc99e Initial load
duke
parents:
diff changeset
1807 assert(dest != NULL, "must have a target");
a61af66fc99e Initial load
duke
parents:
diff changeset
1808 intptr_t disp = dest - (_code_pos + sizeof(int32_t));
a61af66fc99e Initial load
duke
parents:
diff changeset
1809 emit_data(disp, rspec.reloc(), call32_operand);
a61af66fc99e Initial load
duke
parents:
diff changeset
1810 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1811
a61af66fc99e Initial load
duke
parents:
diff changeset
1812 void Assembler::jmp(Label& L, relocInfo::relocType rtype) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1813 if (L.is_bound()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1814 address entry = target(L);
a61af66fc99e Initial load
duke
parents:
diff changeset
1815 assert(entry != NULL, "jmp most probably wrong");
a61af66fc99e Initial load
duke
parents:
diff changeset
1816 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1817 const int short_size = 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
1818 const int long_size = 5;
a61af66fc99e Initial load
duke
parents:
diff changeset
1819 intptr_t offs = entry - _code_pos;
a61af66fc99e Initial load
duke
parents:
diff changeset
1820 if (rtype == relocInfo::none && is8bit(offs - short_size)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1821 emit_byte(0xEB);
a61af66fc99e Initial load
duke
parents:
diff changeset
1822 emit_byte((offs - short_size) & 0xFF);
a61af66fc99e Initial load
duke
parents:
diff changeset
1823 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1824 emit_byte(0xE9);
a61af66fc99e Initial load
duke
parents:
diff changeset
1825 emit_long(offs - long_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
1826 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1827 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1828 // By default, forward jumps are always 32-bit displacements, since
a61af66fc99e Initial load
duke
parents:
diff changeset
1829 // we can't yet know where the label will be bound. If you're sure that
a61af66fc99e Initial load
duke
parents:
diff changeset
1830 // the forward jump will not run beyond 256 bytes, use jmpb to
a61af66fc99e Initial load
duke
parents:
diff changeset
1831 // force an 8-bit displacement.
a61af66fc99e Initial load
duke
parents:
diff changeset
1832 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1833 relocate(rtype);
a61af66fc99e Initial load
duke
parents:
diff changeset
1834 L.add_patch_at(code(), locator());
a61af66fc99e Initial load
duke
parents:
diff changeset
1835 emit_byte(0xE9);
a61af66fc99e Initial load
duke
parents:
diff changeset
1836 emit_long(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1837 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1838 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1839
a61af66fc99e Initial load
duke
parents:
diff changeset
1840 void Assembler::jmpb(Label& L) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1841 if (L.is_bound()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1842 const int short_size = 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
1843 address entry = target(L);
a61af66fc99e Initial load
duke
parents:
diff changeset
1844 assert(is8bit((entry - _code_pos) + short_size),
a61af66fc99e Initial load
duke
parents:
diff changeset
1845 "Dispacement too large for a short jmp");
a61af66fc99e Initial load
duke
parents:
diff changeset
1846 assert(entry != NULL, "jmp most probably wrong");
a61af66fc99e Initial load
duke
parents:
diff changeset
1847 intptr_t offs = entry - _code_pos;
a61af66fc99e Initial load
duke
parents:
diff changeset
1848 emit_byte(0xEB);
a61af66fc99e Initial load
duke
parents:
diff changeset
1849 emit_byte((offs - short_size) & 0xFF);
a61af66fc99e Initial load
duke
parents:
diff changeset
1850 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1851 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1852 L.add_patch_at(code(), locator());
a61af66fc99e Initial load
duke
parents:
diff changeset
1853 emit_byte(0xEB);
a61af66fc99e Initial load
duke
parents:
diff changeset
1854 emit_byte(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1855 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1856 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1857
a61af66fc99e Initial load
duke
parents:
diff changeset
1858 void Assembler::jcc(Condition cc, Label& L, relocInfo::relocType rtype) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1859 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1860 relocate(rtype);
a61af66fc99e Initial load
duke
parents:
diff changeset
1861 assert((0 <= cc) && (cc < 16), "illegal cc");
a61af66fc99e Initial load
duke
parents:
diff changeset
1862 if (L.is_bound()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1863 address dst = target(L);
a61af66fc99e Initial load
duke
parents:
diff changeset
1864 assert(dst != NULL, "jcc most probably wrong");
a61af66fc99e Initial load
duke
parents:
diff changeset
1865
a61af66fc99e Initial load
duke
parents:
diff changeset
1866 const int short_size = 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
1867 const int long_size = 6;
a61af66fc99e Initial load
duke
parents:
diff changeset
1868 int offs = (int)dst - ((int)_code_pos);
a61af66fc99e Initial load
duke
parents:
diff changeset
1869 if (rtype == relocInfo::none && is8bit(offs - short_size)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1870 // 0111 tttn #8-bit disp
a61af66fc99e Initial load
duke
parents:
diff changeset
1871 emit_byte(0x70 | cc);
a61af66fc99e Initial load
duke
parents:
diff changeset
1872 emit_byte((offs - short_size) & 0xFF);
a61af66fc99e Initial load
duke
parents:
diff changeset
1873 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1874 // 0000 1111 1000 tttn #32-bit disp
a61af66fc99e Initial load
duke
parents:
diff changeset
1875 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
1876 emit_byte(0x80 | cc);
a61af66fc99e Initial load
duke
parents:
diff changeset
1877 emit_long(offs - long_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
1878 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1879 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1880 // Note: could eliminate cond. jumps to this jump if condition
a61af66fc99e Initial load
duke
parents:
diff changeset
1881 // is the same however, seems to be rather unlikely case.
a61af66fc99e Initial load
duke
parents:
diff changeset
1882 // Note: use jccb() if label to be bound is very close to get
a61af66fc99e Initial load
duke
parents:
diff changeset
1883 // an 8-bit displacement
a61af66fc99e Initial load
duke
parents:
diff changeset
1884 L.add_patch_at(code(), locator());
a61af66fc99e Initial load
duke
parents:
diff changeset
1885 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
1886 emit_byte(0x80 | cc);
a61af66fc99e Initial load
duke
parents:
diff changeset
1887 emit_long(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1888 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1889 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1890
a61af66fc99e Initial load
duke
parents:
diff changeset
1891 void Assembler::jccb(Condition cc, Label& L) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1892 if (L.is_bound()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1893 const int short_size = 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
1894 address entry = target(L);
a61af66fc99e Initial load
duke
parents:
diff changeset
1895 assert(is8bit((intptr_t)entry - ((intptr_t)_code_pos + short_size)),
a61af66fc99e Initial load
duke
parents:
diff changeset
1896 "Dispacement too large for a short jmp");
a61af66fc99e Initial load
duke
parents:
diff changeset
1897 intptr_t offs = (intptr_t)entry - (intptr_t)_code_pos;
a61af66fc99e Initial load
duke
parents:
diff changeset
1898 // 0111 tttn #8-bit disp
a61af66fc99e Initial load
duke
parents:
diff changeset
1899 emit_byte(0x70 | cc);
a61af66fc99e Initial load
duke
parents:
diff changeset
1900 emit_byte((offs - short_size) & 0xFF);
a61af66fc99e Initial load
duke
parents:
diff changeset
1901 jcc(cc, L);
a61af66fc99e Initial load
duke
parents:
diff changeset
1902 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1903 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1904 L.add_patch_at(code(), locator());
a61af66fc99e Initial load
duke
parents:
diff changeset
1905 emit_byte(0x70 | cc);
a61af66fc99e Initial load
duke
parents:
diff changeset
1906 emit_byte(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1907 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1908 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1909
a61af66fc99e Initial load
duke
parents:
diff changeset
1910 // FPU instructions
a61af66fc99e Initial load
duke
parents:
diff changeset
1911
a61af66fc99e Initial load
duke
parents:
diff changeset
1912 void Assembler::fld1() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1913 emit_byte(0xD9);
a61af66fc99e Initial load
duke
parents:
diff changeset
1914 emit_byte(0xE8);
a61af66fc99e Initial load
duke
parents:
diff changeset
1915 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1916
a61af66fc99e Initial load
duke
parents:
diff changeset
1917
a61af66fc99e Initial load
duke
parents:
diff changeset
1918 void Assembler::fldz() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1919 emit_byte(0xD9);
a61af66fc99e Initial load
duke
parents:
diff changeset
1920 emit_byte(0xEE);
a61af66fc99e Initial load
duke
parents:
diff changeset
1921 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1922
a61af66fc99e Initial load
duke
parents:
diff changeset
1923
a61af66fc99e Initial load
duke
parents:
diff changeset
1924 void Assembler::fld_s(Address adr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1925 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1926 emit_byte(0xD9);
a61af66fc99e Initial load
duke
parents:
diff changeset
1927 emit_operand(rax, adr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1928 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1929
a61af66fc99e Initial load
duke
parents:
diff changeset
1930
a61af66fc99e Initial load
duke
parents:
diff changeset
1931 void Assembler::fld_s (int index) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1932 emit_farith(0xD9, 0xC0, index);
a61af66fc99e Initial load
duke
parents:
diff changeset
1933 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1934
a61af66fc99e Initial load
duke
parents:
diff changeset
1935
a61af66fc99e Initial load
duke
parents:
diff changeset
1936 void Assembler::fld_d(Address adr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1937 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1938 emit_byte(0xDD);
a61af66fc99e Initial load
duke
parents:
diff changeset
1939 emit_operand(rax, adr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1940 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1941
a61af66fc99e Initial load
duke
parents:
diff changeset
1942
a61af66fc99e Initial load
duke
parents:
diff changeset
1943 void Assembler::fld_x(Address adr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1944 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1945 emit_byte(0xDB);
a61af66fc99e Initial load
duke
parents:
diff changeset
1946 emit_operand(rbp, adr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1947 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1948
a61af66fc99e Initial load
duke
parents:
diff changeset
1949
a61af66fc99e Initial load
duke
parents:
diff changeset
1950 void Assembler::fst_s(Address adr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1951 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1952 emit_byte(0xD9);
a61af66fc99e Initial load
duke
parents:
diff changeset
1953 emit_operand(rdx, adr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1954 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1955
a61af66fc99e Initial load
duke
parents:
diff changeset
1956
a61af66fc99e Initial load
duke
parents:
diff changeset
1957 void Assembler::fst_d(Address adr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1958 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1959 emit_byte(0xDD);
a61af66fc99e Initial load
duke
parents:
diff changeset
1960 emit_operand(rdx, adr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1961 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1962
a61af66fc99e Initial load
duke
parents:
diff changeset
1963
a61af66fc99e Initial load
duke
parents:
diff changeset
1964 void Assembler::fstp_s(Address adr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1965 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1966 emit_byte(0xD9);
a61af66fc99e Initial load
duke
parents:
diff changeset
1967 emit_operand(rbx, adr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1968 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1969
a61af66fc99e Initial load
duke
parents:
diff changeset
1970
a61af66fc99e Initial load
duke
parents:
diff changeset
1971 void Assembler::fstp_d(Address adr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1972 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1973 emit_byte(0xDD);
a61af66fc99e Initial load
duke
parents:
diff changeset
1974 emit_operand(rbx, adr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1975 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1976
a61af66fc99e Initial load
duke
parents:
diff changeset
1977
a61af66fc99e Initial load
duke
parents:
diff changeset
1978 void Assembler::fstp_x(Address adr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1979 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1980 emit_byte(0xDB);
a61af66fc99e Initial load
duke
parents:
diff changeset
1981 emit_operand(rdi, adr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1982 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1983
a61af66fc99e Initial load
duke
parents:
diff changeset
1984
a61af66fc99e Initial load
duke
parents:
diff changeset
1985 void Assembler::fstp_d(int index) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1986 emit_farith(0xDD, 0xD8, index);
a61af66fc99e Initial load
duke
parents:
diff changeset
1987 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1988
a61af66fc99e Initial load
duke
parents:
diff changeset
1989
a61af66fc99e Initial load
duke
parents:
diff changeset
1990 void Assembler::fild_s(Address adr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1991 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1992 emit_byte(0xDB);
a61af66fc99e Initial load
duke
parents:
diff changeset
1993 emit_operand(rax, adr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1994 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1995
a61af66fc99e Initial load
duke
parents:
diff changeset
1996
a61af66fc99e Initial load
duke
parents:
diff changeset
1997 void Assembler::fild_d(Address adr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1998 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
1999 emit_byte(0xDF);
a61af66fc99e Initial load
duke
parents:
diff changeset
2000 emit_operand(rbp, adr);
a61af66fc99e Initial load
duke
parents:
diff changeset
2001 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2002
a61af66fc99e Initial load
duke
parents:
diff changeset
2003
a61af66fc99e Initial load
duke
parents:
diff changeset
2004 void Assembler::fistp_s(Address adr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2005 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2006 emit_byte(0xDB);
a61af66fc99e Initial load
duke
parents:
diff changeset
2007 emit_operand(rbx, adr);
a61af66fc99e Initial load
duke
parents:
diff changeset
2008 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2009
a61af66fc99e Initial load
duke
parents:
diff changeset
2010
a61af66fc99e Initial load
duke
parents:
diff changeset
2011 void Assembler::fistp_d(Address adr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2012 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2013 emit_byte(0xDF);
a61af66fc99e Initial load
duke
parents:
diff changeset
2014 emit_operand(rdi, adr);
a61af66fc99e Initial load
duke
parents:
diff changeset
2015 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2016
a61af66fc99e Initial load
duke
parents:
diff changeset
2017
a61af66fc99e Initial load
duke
parents:
diff changeset
2018 void Assembler::fist_s(Address adr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2019 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2020 emit_byte(0xDB);
a61af66fc99e Initial load
duke
parents:
diff changeset
2021 emit_operand(rdx, adr);
a61af66fc99e Initial load
duke
parents:
diff changeset
2022 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2023
a61af66fc99e Initial load
duke
parents:
diff changeset
2024
a61af66fc99e Initial load
duke
parents:
diff changeset
2025 void Assembler::fabs() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2026 emit_byte(0xD9);
a61af66fc99e Initial load
duke
parents:
diff changeset
2027 emit_byte(0xE1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2028 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2029
a61af66fc99e Initial load
duke
parents:
diff changeset
2030
a61af66fc99e Initial load
duke
parents:
diff changeset
2031 void Assembler::fldln2() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2032 emit_byte(0xD9);
a61af66fc99e Initial load
duke
parents:
diff changeset
2033 emit_byte(0xED);
a61af66fc99e Initial load
duke
parents:
diff changeset
2034 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2035
a61af66fc99e Initial load
duke
parents:
diff changeset
2036 void Assembler::fyl2x() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2037 emit_byte(0xD9);
a61af66fc99e Initial load
duke
parents:
diff changeset
2038 emit_byte(0xF1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2039 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2040
a61af66fc99e Initial load
duke
parents:
diff changeset
2041
a61af66fc99e Initial load
duke
parents:
diff changeset
2042 void Assembler::fldlg2() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2043 emit_byte(0xD9);
a61af66fc99e Initial load
duke
parents:
diff changeset
2044 emit_byte(0xEC);
a61af66fc99e Initial load
duke
parents:
diff changeset
2045 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2046
a61af66fc99e Initial load
duke
parents:
diff changeset
2047
a61af66fc99e Initial load
duke
parents:
diff changeset
2048 void Assembler::flog() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2049 fldln2();
a61af66fc99e Initial load
duke
parents:
diff changeset
2050 fxch();
a61af66fc99e Initial load
duke
parents:
diff changeset
2051 fyl2x();
a61af66fc99e Initial load
duke
parents:
diff changeset
2052 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2053
a61af66fc99e Initial load
duke
parents:
diff changeset
2054
a61af66fc99e Initial load
duke
parents:
diff changeset
2055 void Assembler::flog10() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2056 fldlg2();
a61af66fc99e Initial load
duke
parents:
diff changeset
2057 fxch();
a61af66fc99e Initial load
duke
parents:
diff changeset
2058 fyl2x();
a61af66fc99e Initial load
duke
parents:
diff changeset
2059 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2060
a61af66fc99e Initial load
duke
parents:
diff changeset
2061
a61af66fc99e Initial load
duke
parents:
diff changeset
2062 void Assembler::fsin() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2063 emit_byte(0xD9);
a61af66fc99e Initial load
duke
parents:
diff changeset
2064 emit_byte(0xFE);
a61af66fc99e Initial load
duke
parents:
diff changeset
2065 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2066
a61af66fc99e Initial load
duke
parents:
diff changeset
2067
a61af66fc99e Initial load
duke
parents:
diff changeset
2068 void Assembler::fcos() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2069 emit_byte(0xD9);
a61af66fc99e Initial load
duke
parents:
diff changeset
2070 emit_byte(0xFF);
a61af66fc99e Initial load
duke
parents:
diff changeset
2071 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2072
a61af66fc99e Initial load
duke
parents:
diff changeset
2073 void Assembler::ftan() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2074 emit_byte(0xD9);
a61af66fc99e Initial load
duke
parents:
diff changeset
2075 emit_byte(0xF2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2076 emit_byte(0xDD);
a61af66fc99e Initial load
duke
parents:
diff changeset
2077 emit_byte(0xD8);
a61af66fc99e Initial load
duke
parents:
diff changeset
2078 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2079
a61af66fc99e Initial load
duke
parents:
diff changeset
2080 void Assembler::fsqrt() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2081 emit_byte(0xD9);
a61af66fc99e Initial load
duke
parents:
diff changeset
2082 emit_byte(0xFA);
a61af66fc99e Initial load
duke
parents:
diff changeset
2083 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2084
a61af66fc99e Initial load
duke
parents:
diff changeset
2085
a61af66fc99e Initial load
duke
parents:
diff changeset
2086 void Assembler::fchs() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2087 emit_byte(0xD9);
a61af66fc99e Initial load
duke
parents:
diff changeset
2088 emit_byte(0xE0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2089 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2090
a61af66fc99e Initial load
duke
parents:
diff changeset
2091
a61af66fc99e Initial load
duke
parents:
diff changeset
2092 void Assembler::fadd_s(Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2093 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2094 emit_byte(0xD8);
a61af66fc99e Initial load
duke
parents:
diff changeset
2095 emit_operand(rax, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
2096 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2097
a61af66fc99e Initial load
duke
parents:
diff changeset
2098
a61af66fc99e Initial load
duke
parents:
diff changeset
2099 void Assembler::fadd_d(Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2100 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2101 emit_byte(0xDC);
a61af66fc99e Initial load
duke
parents:
diff changeset
2102 emit_operand(rax, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
2103 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2104
a61af66fc99e Initial load
duke
parents:
diff changeset
2105
a61af66fc99e Initial load
duke
parents:
diff changeset
2106 void Assembler::fadd(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2107 emit_farith(0xD8, 0xC0, i);
a61af66fc99e Initial load
duke
parents:
diff changeset
2108 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2109
a61af66fc99e Initial load
duke
parents:
diff changeset
2110
a61af66fc99e Initial load
duke
parents:
diff changeset
2111 void Assembler::fadda(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2112 emit_farith(0xDC, 0xC0, i);
a61af66fc99e Initial load
duke
parents:
diff changeset
2113 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2114
a61af66fc99e Initial load
duke
parents:
diff changeset
2115
a61af66fc99e Initial load
duke
parents:
diff changeset
2116 void Assembler::fsub_d(Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2117 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2118 emit_byte(0xDC);
a61af66fc99e Initial load
duke
parents:
diff changeset
2119 emit_operand(rsp, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
2120 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2121
a61af66fc99e Initial load
duke
parents:
diff changeset
2122
a61af66fc99e Initial load
duke
parents:
diff changeset
2123 void Assembler::fsub_s(Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2124 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2125 emit_byte(0xD8);
a61af66fc99e Initial load
duke
parents:
diff changeset
2126 emit_operand(rsp, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
2127 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2128
a61af66fc99e Initial load
duke
parents:
diff changeset
2129
a61af66fc99e Initial load
duke
parents:
diff changeset
2130 void Assembler::fsubr_s(Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2131 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2132 emit_byte(0xD8);
a61af66fc99e Initial load
duke
parents:
diff changeset
2133 emit_operand(rbp, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
2134 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2135
a61af66fc99e Initial load
duke
parents:
diff changeset
2136
a61af66fc99e Initial load
duke
parents:
diff changeset
2137 void Assembler::fsubr_d(Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2138 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2139 emit_byte(0xDC);
a61af66fc99e Initial load
duke
parents:
diff changeset
2140 emit_operand(rbp, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
2141 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2142
a61af66fc99e Initial load
duke
parents:
diff changeset
2143
a61af66fc99e Initial load
duke
parents:
diff changeset
2144 void Assembler::fmul_s(Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2145 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2146 emit_byte(0xD8);
a61af66fc99e Initial load
duke
parents:
diff changeset
2147 emit_operand(rcx, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
2148 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2149
a61af66fc99e Initial load
duke
parents:
diff changeset
2150
a61af66fc99e Initial load
duke
parents:
diff changeset
2151 void Assembler::fmul_d(Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2152 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2153 emit_byte(0xDC);
a61af66fc99e Initial load
duke
parents:
diff changeset
2154 emit_operand(rcx, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
2155 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2156
a61af66fc99e Initial load
duke
parents:
diff changeset
2157
a61af66fc99e Initial load
duke
parents:
diff changeset
2158 void Assembler::fmul(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2159 emit_farith(0xD8, 0xC8, i);
a61af66fc99e Initial load
duke
parents:
diff changeset
2160 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2161
a61af66fc99e Initial load
duke
parents:
diff changeset
2162
a61af66fc99e Initial load
duke
parents:
diff changeset
2163 void Assembler::fmula(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2164 emit_farith(0xDC, 0xC8, i);
a61af66fc99e Initial load
duke
parents:
diff changeset
2165 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2166
a61af66fc99e Initial load
duke
parents:
diff changeset
2167
a61af66fc99e Initial load
duke
parents:
diff changeset
2168 void Assembler::fdiv_s(Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2169 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2170 emit_byte(0xD8);
a61af66fc99e Initial load
duke
parents:
diff changeset
2171 emit_operand(rsi, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
2172 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2173
a61af66fc99e Initial load
duke
parents:
diff changeset
2174
a61af66fc99e Initial load
duke
parents:
diff changeset
2175 void Assembler::fdiv_d(Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2176 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2177 emit_byte(0xDC);
a61af66fc99e Initial load
duke
parents:
diff changeset
2178 emit_operand(rsi, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
2179 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2180
a61af66fc99e Initial load
duke
parents:
diff changeset
2181
a61af66fc99e Initial load
duke
parents:
diff changeset
2182 void Assembler::fdivr_s(Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2183 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2184 emit_byte(0xD8);
a61af66fc99e Initial load
duke
parents:
diff changeset
2185 emit_operand(rdi, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
2186 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2187
a61af66fc99e Initial load
duke
parents:
diff changeset
2188
a61af66fc99e Initial load
duke
parents:
diff changeset
2189 void Assembler::fdivr_d(Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2190 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2191 emit_byte(0xDC);
a61af66fc99e Initial load
duke
parents:
diff changeset
2192 emit_operand(rdi, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
2193 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2194
a61af66fc99e Initial load
duke
parents:
diff changeset
2195
a61af66fc99e Initial load
duke
parents:
diff changeset
2196 void Assembler::fsub(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2197 emit_farith(0xD8, 0xE0, i);
a61af66fc99e Initial load
duke
parents:
diff changeset
2198 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2199
a61af66fc99e Initial load
duke
parents:
diff changeset
2200
a61af66fc99e Initial load
duke
parents:
diff changeset
2201 void Assembler::fsuba(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2202 emit_farith(0xDC, 0xE8, i);
a61af66fc99e Initial load
duke
parents:
diff changeset
2203 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2204
a61af66fc99e Initial load
duke
parents:
diff changeset
2205
a61af66fc99e Initial load
duke
parents:
diff changeset
2206 void Assembler::fsubr(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2207 emit_farith(0xD8, 0xE8, i);
a61af66fc99e Initial load
duke
parents:
diff changeset
2208 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2209
a61af66fc99e Initial load
duke
parents:
diff changeset
2210
a61af66fc99e Initial load
duke
parents:
diff changeset
2211 void Assembler::fsubra(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2212 emit_farith(0xDC, 0xE0, i);
a61af66fc99e Initial load
duke
parents:
diff changeset
2213 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2214
a61af66fc99e Initial load
duke
parents:
diff changeset
2215
a61af66fc99e Initial load
duke
parents:
diff changeset
2216 void Assembler::fdiv(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2217 emit_farith(0xD8, 0xF0, i);
a61af66fc99e Initial load
duke
parents:
diff changeset
2218 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2219
a61af66fc99e Initial load
duke
parents:
diff changeset
2220
a61af66fc99e Initial load
duke
parents:
diff changeset
2221 void Assembler::fdiva(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2222 emit_farith(0xDC, 0xF8, i);
a61af66fc99e Initial load
duke
parents:
diff changeset
2223 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2224
a61af66fc99e Initial load
duke
parents:
diff changeset
2225
a61af66fc99e Initial load
duke
parents:
diff changeset
2226 void Assembler::fdivr(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2227 emit_farith(0xD8, 0xF8, i);
a61af66fc99e Initial load
duke
parents:
diff changeset
2228 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2229
a61af66fc99e Initial load
duke
parents:
diff changeset
2230
a61af66fc99e Initial load
duke
parents:
diff changeset
2231 void Assembler::fdivra(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2232 emit_farith(0xDC, 0xF0, i);
a61af66fc99e Initial load
duke
parents:
diff changeset
2233 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2234
a61af66fc99e Initial load
duke
parents:
diff changeset
2235
a61af66fc99e Initial load
duke
parents:
diff changeset
2236 // Note: The Intel manual (Pentium Processor User's Manual, Vol.3, 1994)
a61af66fc99e Initial load
duke
parents:
diff changeset
2237 // is erroneous for some of the floating-point instructions below.
a61af66fc99e Initial load
duke
parents:
diff changeset
2238
a61af66fc99e Initial load
duke
parents:
diff changeset
2239 void Assembler::fdivp(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2240 emit_farith(0xDE, 0xF8, i); // ST(0) <- ST(0) / ST(1) and pop (Intel manual wrong)
a61af66fc99e Initial load
duke
parents:
diff changeset
2241 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2242
a61af66fc99e Initial load
duke
parents:
diff changeset
2243
a61af66fc99e Initial load
duke
parents:
diff changeset
2244 void Assembler::fdivrp(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2245 emit_farith(0xDE, 0xF0, i); // ST(0) <- ST(1) / ST(0) and pop (Intel manual wrong)
a61af66fc99e Initial load
duke
parents:
diff changeset
2246 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2247
a61af66fc99e Initial load
duke
parents:
diff changeset
2248
a61af66fc99e Initial load
duke
parents:
diff changeset
2249 void Assembler::fsubp(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2250 emit_farith(0xDE, 0xE8, i); // ST(0) <- ST(0) - ST(1) and pop (Intel manual wrong)
a61af66fc99e Initial load
duke
parents:
diff changeset
2251 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2252
a61af66fc99e Initial load
duke
parents:
diff changeset
2253
a61af66fc99e Initial load
duke
parents:
diff changeset
2254 void Assembler::fsubrp(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2255 emit_farith(0xDE, 0xE0, i); // ST(0) <- ST(1) - ST(0) and pop (Intel manual wrong)
a61af66fc99e Initial load
duke
parents:
diff changeset
2256 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2257
a61af66fc99e Initial load
duke
parents:
diff changeset
2258
a61af66fc99e Initial load
duke
parents:
diff changeset
2259 void Assembler::faddp(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2260 emit_farith(0xDE, 0xC0, i);
a61af66fc99e Initial load
duke
parents:
diff changeset
2261 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2262
a61af66fc99e Initial load
duke
parents:
diff changeset
2263
a61af66fc99e Initial load
duke
parents:
diff changeset
2264 void Assembler::fmulp(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2265 emit_farith(0xDE, 0xC8, i);
a61af66fc99e Initial load
duke
parents:
diff changeset
2266 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2267
a61af66fc99e Initial load
duke
parents:
diff changeset
2268
a61af66fc99e Initial load
duke
parents:
diff changeset
2269 void Assembler::fprem() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2270 emit_byte(0xD9);
a61af66fc99e Initial load
duke
parents:
diff changeset
2271 emit_byte(0xF8);
a61af66fc99e Initial load
duke
parents:
diff changeset
2272 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2273
a61af66fc99e Initial load
duke
parents:
diff changeset
2274
a61af66fc99e Initial load
duke
parents:
diff changeset
2275 void Assembler::fprem1() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2276 emit_byte(0xD9);
a61af66fc99e Initial load
duke
parents:
diff changeset
2277 emit_byte(0xF5);
a61af66fc99e Initial load
duke
parents:
diff changeset
2278 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2279
a61af66fc99e Initial load
duke
parents:
diff changeset
2280
a61af66fc99e Initial load
duke
parents:
diff changeset
2281 void Assembler::fxch(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2282 emit_farith(0xD9, 0xC8, i);
a61af66fc99e Initial load
duke
parents:
diff changeset
2283 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2284
a61af66fc99e Initial load
duke
parents:
diff changeset
2285
a61af66fc99e Initial load
duke
parents:
diff changeset
2286 void Assembler::fincstp() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2287 emit_byte(0xD9);
a61af66fc99e Initial load
duke
parents:
diff changeset
2288 emit_byte(0xF7);
a61af66fc99e Initial load
duke
parents:
diff changeset
2289 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2290
a61af66fc99e Initial load
duke
parents:
diff changeset
2291
a61af66fc99e Initial load
duke
parents:
diff changeset
2292 void Assembler::fdecstp() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2293 emit_byte(0xD9);
a61af66fc99e Initial load
duke
parents:
diff changeset
2294 emit_byte(0xF6);
a61af66fc99e Initial load
duke
parents:
diff changeset
2295 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2296
a61af66fc99e Initial load
duke
parents:
diff changeset
2297
a61af66fc99e Initial load
duke
parents:
diff changeset
2298 void Assembler::ffree(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2299 emit_farith(0xDD, 0xC0, i);
a61af66fc99e Initial load
duke
parents:
diff changeset
2300 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2301
a61af66fc99e Initial load
duke
parents:
diff changeset
2302
a61af66fc99e Initial load
duke
parents:
diff changeset
2303 void Assembler::fcomp_s(Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2304 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2305 emit_byte(0xD8);
a61af66fc99e Initial load
duke
parents:
diff changeset
2306 emit_operand(rbx, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
2307 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2308
a61af66fc99e Initial load
duke
parents:
diff changeset
2309
a61af66fc99e Initial load
duke
parents:
diff changeset
2310 void Assembler::fcomp_d(Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2311 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2312 emit_byte(0xDC);
a61af66fc99e Initial load
duke
parents:
diff changeset
2313 emit_operand(rbx, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
2314 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2315
a61af66fc99e Initial load
duke
parents:
diff changeset
2316
a61af66fc99e Initial load
duke
parents:
diff changeset
2317 void Assembler::fcom(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2318 emit_farith(0xD8, 0xD0, i);
a61af66fc99e Initial load
duke
parents:
diff changeset
2319 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2320
a61af66fc99e Initial load
duke
parents:
diff changeset
2321
a61af66fc99e Initial load
duke
parents:
diff changeset
2322 void Assembler::fcomp(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2323 emit_farith(0xD8, 0xD8, i);
a61af66fc99e Initial load
duke
parents:
diff changeset
2324 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2325
a61af66fc99e Initial load
duke
parents:
diff changeset
2326
a61af66fc99e Initial load
duke
parents:
diff changeset
2327 void Assembler::fcompp() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2328 emit_byte(0xDE);
a61af66fc99e Initial load
duke
parents:
diff changeset
2329 emit_byte(0xD9);
a61af66fc99e Initial load
duke
parents:
diff changeset
2330 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2331
a61af66fc99e Initial load
duke
parents:
diff changeset
2332
a61af66fc99e Initial load
duke
parents:
diff changeset
2333 void Assembler::fucomi(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2334 // make sure the instruction is supported (introduced for P6, together with cmov)
a61af66fc99e Initial load
duke
parents:
diff changeset
2335 guarantee(VM_Version::supports_cmov(), "illegal instruction");
a61af66fc99e Initial load
duke
parents:
diff changeset
2336 emit_farith(0xDB, 0xE8, i);
a61af66fc99e Initial load
duke
parents:
diff changeset
2337 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2338
a61af66fc99e Initial load
duke
parents:
diff changeset
2339
a61af66fc99e Initial load
duke
parents:
diff changeset
2340 void Assembler::fucomip(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2341 // make sure the instruction is supported (introduced for P6, together with cmov)
a61af66fc99e Initial load
duke
parents:
diff changeset
2342 guarantee(VM_Version::supports_cmov(), "illegal instruction");
a61af66fc99e Initial load
duke
parents:
diff changeset
2343 emit_farith(0xDF, 0xE8, i);
a61af66fc99e Initial load
duke
parents:
diff changeset
2344 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2345
a61af66fc99e Initial load
duke
parents:
diff changeset
2346
a61af66fc99e Initial load
duke
parents:
diff changeset
2347 void Assembler::ftst() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2348 emit_byte(0xD9);
a61af66fc99e Initial load
duke
parents:
diff changeset
2349 emit_byte(0xE4);
a61af66fc99e Initial load
duke
parents:
diff changeset
2350 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2351
a61af66fc99e Initial load
duke
parents:
diff changeset
2352
a61af66fc99e Initial load
duke
parents:
diff changeset
2353 void Assembler::fnstsw_ax() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2354 emit_byte(0xdF);
a61af66fc99e Initial load
duke
parents:
diff changeset
2355 emit_byte(0xE0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2356 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2357
a61af66fc99e Initial load
duke
parents:
diff changeset
2358
a61af66fc99e Initial load
duke
parents:
diff changeset
2359 void Assembler::fwait() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2360 emit_byte(0x9B);
a61af66fc99e Initial load
duke
parents:
diff changeset
2361 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2362
a61af66fc99e Initial load
duke
parents:
diff changeset
2363
a61af66fc99e Initial load
duke
parents:
diff changeset
2364 void Assembler::finit() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2365 emit_byte(0x9B);
a61af66fc99e Initial load
duke
parents:
diff changeset
2366 emit_byte(0xDB);
a61af66fc99e Initial load
duke
parents:
diff changeset
2367 emit_byte(0xE3);
a61af66fc99e Initial load
duke
parents:
diff changeset
2368 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2369
a61af66fc99e Initial load
duke
parents:
diff changeset
2370
a61af66fc99e Initial load
duke
parents:
diff changeset
2371 void Assembler::fldcw(Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2372 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2373 emit_byte(0xd9);
a61af66fc99e Initial load
duke
parents:
diff changeset
2374 emit_operand(rbp, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
2375 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2376
a61af66fc99e Initial load
duke
parents:
diff changeset
2377
a61af66fc99e Initial load
duke
parents:
diff changeset
2378 void Assembler::fnstcw(Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2379 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2380 emit_byte(0x9B);
a61af66fc99e Initial load
duke
parents:
diff changeset
2381 emit_byte(0xD9);
a61af66fc99e Initial load
duke
parents:
diff changeset
2382 emit_operand(rdi, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
2383 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2384
a61af66fc99e Initial load
duke
parents:
diff changeset
2385 void Assembler::fnsave(Address dst) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2386 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2387 emit_byte(0xDD);
a61af66fc99e Initial load
duke
parents:
diff changeset
2388 emit_operand(rsi, dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
2389 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2390
a61af66fc99e Initial load
duke
parents:
diff changeset
2391
a61af66fc99e Initial load
duke
parents:
diff changeset
2392 void Assembler::frstor(Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2393 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2394 emit_byte(0xDD);
a61af66fc99e Initial load
duke
parents:
diff changeset
2395 emit_operand(rsp, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
2396 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2397
a61af66fc99e Initial load
duke
parents:
diff changeset
2398
a61af66fc99e Initial load
duke
parents:
diff changeset
2399 void Assembler::fldenv(Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2400 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2401 emit_byte(0xD9);
a61af66fc99e Initial load
duke
parents:
diff changeset
2402 emit_operand(rsp, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
2403 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2404
a61af66fc99e Initial load
duke
parents:
diff changeset
2405
a61af66fc99e Initial load
duke
parents:
diff changeset
2406 void Assembler::sahf() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2407 emit_byte(0x9E);
a61af66fc99e Initial load
duke
parents:
diff changeset
2408 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2409
a61af66fc99e Initial load
duke
parents:
diff changeset
2410 // MMX operations
a61af66fc99e Initial load
duke
parents:
diff changeset
2411 void Assembler::emit_operand(MMXRegister reg, Address adr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2412 emit_operand((Register)reg, adr._base, adr._index, adr._scale, adr._disp, adr._rspec);
a61af66fc99e Initial load
duke
parents:
diff changeset
2413 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2414
a61af66fc99e Initial load
duke
parents:
diff changeset
2415 void Assembler::movq( MMXRegister dst, Address src ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2416 assert( VM_Version::supports_mmx(), "" );
a61af66fc99e Initial load
duke
parents:
diff changeset
2417 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
2418 emit_byte(0x6F);
a61af66fc99e Initial load
duke
parents:
diff changeset
2419 emit_operand(dst,src);
a61af66fc99e Initial load
duke
parents:
diff changeset
2420 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2421
a61af66fc99e Initial load
duke
parents:
diff changeset
2422 void Assembler::movq( Address dst, MMXRegister src ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2423 assert( VM_Version::supports_mmx(), "" );
a61af66fc99e Initial load
duke
parents:
diff changeset
2424 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
2425 emit_byte(0x7F);
a61af66fc99e Initial load
duke
parents:
diff changeset
2426 emit_operand(src,dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
2427 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2428
a61af66fc99e Initial load
duke
parents:
diff changeset
2429 void Assembler::emms() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2430 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
2431 emit_byte(0x77);
a61af66fc99e Initial load
duke
parents:
diff changeset
2432 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2433
a61af66fc99e Initial load
duke
parents:
diff changeset
2434
a61af66fc99e Initial load
duke
parents:
diff changeset
2435
a61af66fc99e Initial load
duke
parents:
diff changeset
2436
a61af66fc99e Initial load
duke
parents:
diff changeset
2437 // SSE and SSE2 instructions
a61af66fc99e Initial load
duke
parents:
diff changeset
2438 inline void Assembler::emit_sse_operand(XMMRegister reg, Address adr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2439 assert(((Register)reg)->encoding() == reg->encoding(), "otherwise typecast is invalid");
a61af66fc99e Initial load
duke
parents:
diff changeset
2440 emit_operand((Register)reg, adr._base, adr._index, adr._scale, adr._disp, adr._rspec);
a61af66fc99e Initial load
duke
parents:
diff changeset
2441 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2442 inline void Assembler::emit_sse_operand(Register reg, Address adr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2443 emit_operand(reg, adr._base, adr._index, adr._scale, adr._disp, adr._rspec);
a61af66fc99e Initial load
duke
parents:
diff changeset
2444 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2445
a61af66fc99e Initial load
duke
parents:
diff changeset
2446 inline void Assembler::emit_sse_operand(XMMRegister dst, XMMRegister src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2447 emit_byte(0xC0 | dst->encoding() << 3 | src->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
2448 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2449 inline void Assembler::emit_sse_operand(XMMRegister dst, Register src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2450 emit_byte(0xC0 | dst->encoding() << 3 | src->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
2451 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2452 inline void Assembler::emit_sse_operand(Register dst, XMMRegister src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2453 emit_byte(0xC0 | dst->encoding() << 3 | src->encoding());
a61af66fc99e Initial load
duke
parents:
diff changeset
2454 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2455
a61af66fc99e Initial load
duke
parents:
diff changeset
2456
a61af66fc99e Initial load
duke
parents:
diff changeset
2457 // Macro for creation of SSE2 instructions
a61af66fc99e Initial load
duke
parents:
diff changeset
2458 // The SSE2 instricution set is highly regular, so this macro saves
a61af66fc99e Initial load
duke
parents:
diff changeset
2459 // a lot of cut&paste
a61af66fc99e Initial load
duke
parents:
diff changeset
2460 // Each macro expansion creates two methods (same name with different
a61af66fc99e Initial load
duke
parents:
diff changeset
2461 // parameter list)
a61af66fc99e Initial load
duke
parents:
diff changeset
2462 //
a61af66fc99e Initial load
duke
parents:
diff changeset
2463 // Macro parameters:
a61af66fc99e Initial load
duke
parents:
diff changeset
2464 // * name: name of the created methods
a61af66fc99e Initial load
duke
parents:
diff changeset
2465 // * sse_version: either sse or sse2 for the assertion if instruction supported by processor
a61af66fc99e Initial load
duke
parents:
diff changeset
2466 // * prefix: first opcode byte of the instruction (or 0 if no prefix byte)
a61af66fc99e Initial load
duke
parents:
diff changeset
2467 // * opcode: last opcode byte of the instruction
a61af66fc99e Initial load
duke
parents:
diff changeset
2468 // * conversion instruction have parameters of type Register instead of XMMRegister,
a61af66fc99e Initial load
duke
parents:
diff changeset
2469 // so this can also configured with macro parameters
a61af66fc99e Initial load
duke
parents:
diff changeset
2470 #define emit_sse_instruction(name, sse_version, prefix, opcode, dst_register_type, src_register_type) \
a61af66fc99e Initial load
duke
parents:
diff changeset
2471 \
a61af66fc99e Initial load
duke
parents:
diff changeset
2472 void Assembler:: name (dst_register_type dst, Address src) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
2473 assert(VM_Version::supports_##sse_version(), ""); \
a61af66fc99e Initial load
duke
parents:
diff changeset
2474 \
a61af66fc99e Initial load
duke
parents:
diff changeset
2475 InstructionMark im(this); \
a61af66fc99e Initial load
duke
parents:
diff changeset
2476 if (prefix != 0) emit_byte(prefix); \
a61af66fc99e Initial load
duke
parents:
diff changeset
2477 emit_byte(0x0F); \
a61af66fc99e Initial load
duke
parents:
diff changeset
2478 emit_byte(opcode); \
a61af66fc99e Initial load
duke
parents:
diff changeset
2479 emit_sse_operand(dst, src); \
a61af66fc99e Initial load
duke
parents:
diff changeset
2480 } \
a61af66fc99e Initial load
duke
parents:
diff changeset
2481 \
a61af66fc99e Initial load
duke
parents:
diff changeset
2482 void Assembler:: name (dst_register_type dst, src_register_type src) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
2483 assert(VM_Version::supports_##sse_version(), ""); \
a61af66fc99e Initial load
duke
parents:
diff changeset
2484 \
a61af66fc99e Initial load
duke
parents:
diff changeset
2485 if (prefix != 0) emit_byte(prefix); \
a61af66fc99e Initial load
duke
parents:
diff changeset
2486 emit_byte(0x0F); \
a61af66fc99e Initial load
duke
parents:
diff changeset
2487 emit_byte(opcode); \
a61af66fc99e Initial load
duke
parents:
diff changeset
2488 emit_sse_operand(dst, src); \
a61af66fc99e Initial load
duke
parents:
diff changeset
2489 } \
a61af66fc99e Initial load
duke
parents:
diff changeset
2490
a61af66fc99e Initial load
duke
parents:
diff changeset
2491 emit_sse_instruction(addss, sse, 0xF3, 0x58, XMMRegister, XMMRegister);
a61af66fc99e Initial load
duke
parents:
diff changeset
2492 emit_sse_instruction(addsd, sse2, 0xF2, 0x58, XMMRegister, XMMRegister)
a61af66fc99e Initial load
duke
parents:
diff changeset
2493 emit_sse_instruction(subss, sse, 0xF3, 0x5C, XMMRegister, XMMRegister)
a61af66fc99e Initial load
duke
parents:
diff changeset
2494 emit_sse_instruction(subsd, sse2, 0xF2, 0x5C, XMMRegister, XMMRegister)
a61af66fc99e Initial load
duke
parents:
diff changeset
2495 emit_sse_instruction(mulss, sse, 0xF3, 0x59, XMMRegister, XMMRegister)
a61af66fc99e Initial load
duke
parents:
diff changeset
2496 emit_sse_instruction(mulsd, sse2, 0xF2, 0x59, XMMRegister, XMMRegister)
a61af66fc99e Initial load
duke
parents:
diff changeset
2497 emit_sse_instruction(divss, sse, 0xF3, 0x5E, XMMRegister, XMMRegister)
a61af66fc99e Initial load
duke
parents:
diff changeset
2498 emit_sse_instruction(divsd, sse2, 0xF2, 0x5E, XMMRegister, XMMRegister)
a61af66fc99e Initial load
duke
parents:
diff changeset
2499 emit_sse_instruction(sqrtss, sse, 0xF3, 0x51, XMMRegister, XMMRegister)
a61af66fc99e Initial load
duke
parents:
diff changeset
2500 emit_sse_instruction(sqrtsd, sse2, 0xF2, 0x51, XMMRegister, XMMRegister)
a61af66fc99e Initial load
duke
parents:
diff changeset
2501
a61af66fc99e Initial load
duke
parents:
diff changeset
2502 emit_sse_instruction(pxor, sse2, 0x66, 0xEF, XMMRegister, XMMRegister)
a61af66fc99e Initial load
duke
parents:
diff changeset
2503
a61af66fc99e Initial load
duke
parents:
diff changeset
2504 emit_sse_instruction(comiss, sse, 0, 0x2F, XMMRegister, XMMRegister)
a61af66fc99e Initial load
duke
parents:
diff changeset
2505 emit_sse_instruction(comisd, sse2, 0x66, 0x2F, XMMRegister, XMMRegister)
a61af66fc99e Initial load
duke
parents:
diff changeset
2506 emit_sse_instruction(ucomiss, sse, 0, 0x2E, XMMRegister, XMMRegister)
a61af66fc99e Initial load
duke
parents:
diff changeset
2507 emit_sse_instruction(ucomisd, sse2, 0x66, 0x2E, XMMRegister, XMMRegister)
a61af66fc99e Initial load
duke
parents:
diff changeset
2508
a61af66fc99e Initial load
duke
parents:
diff changeset
2509 emit_sse_instruction(cvtss2sd, sse2, 0xF3, 0x5A, XMMRegister, XMMRegister);
a61af66fc99e Initial load
duke
parents:
diff changeset
2510 emit_sse_instruction(cvtsd2ss, sse2, 0xF2, 0x5A, XMMRegister, XMMRegister)
a61af66fc99e Initial load
duke
parents:
diff changeset
2511 emit_sse_instruction(cvtsi2ss, sse, 0xF3, 0x2A, XMMRegister, Register);
a61af66fc99e Initial load
duke
parents:
diff changeset
2512 emit_sse_instruction(cvtsi2sd, sse2, 0xF2, 0x2A, XMMRegister, Register)
a61af66fc99e Initial load
duke
parents:
diff changeset
2513 emit_sse_instruction(cvtss2si, sse, 0xF3, 0x2D, Register, XMMRegister);
a61af66fc99e Initial load
duke
parents:
diff changeset
2514 emit_sse_instruction(cvtsd2si, sse2, 0xF2, 0x2D, Register, XMMRegister)
a61af66fc99e Initial load
duke
parents:
diff changeset
2515 emit_sse_instruction(cvttss2si, sse, 0xF3, 0x2C, Register, XMMRegister);
a61af66fc99e Initial load
duke
parents:
diff changeset
2516 emit_sse_instruction(cvttsd2si, sse2, 0xF2, 0x2C, Register, XMMRegister)
a61af66fc99e Initial load
duke
parents:
diff changeset
2517
a61af66fc99e Initial load
duke
parents:
diff changeset
2518 emit_sse_instruction(movss, sse, 0xF3, 0x10, XMMRegister, XMMRegister)
a61af66fc99e Initial load
duke
parents:
diff changeset
2519 emit_sse_instruction(movsd, sse2, 0xF2, 0x10, XMMRegister, XMMRegister)
a61af66fc99e Initial load
duke
parents:
diff changeset
2520
a61af66fc99e Initial load
duke
parents:
diff changeset
2521 emit_sse_instruction(movq, sse2, 0xF3, 0x7E, XMMRegister, XMMRegister);
a61af66fc99e Initial load
duke
parents:
diff changeset
2522 emit_sse_instruction(movd, sse2, 0x66, 0x6E, XMMRegister, Register);
a61af66fc99e Initial load
duke
parents:
diff changeset
2523 emit_sse_instruction(movdqa, sse2, 0x66, 0x6F, XMMRegister, XMMRegister);
a61af66fc99e Initial load
duke
parents:
diff changeset
2524
a61af66fc99e Initial load
duke
parents:
diff changeset
2525 emit_sse_instruction(punpcklbw, sse2, 0x66, 0x60, XMMRegister, XMMRegister);
a61af66fc99e Initial load
duke
parents:
diff changeset
2526
a61af66fc99e Initial load
duke
parents:
diff changeset
2527
a61af66fc99e Initial load
duke
parents:
diff changeset
2528 // Instruction not covered by macro
a61af66fc99e Initial load
duke
parents:
diff changeset
2529 void Assembler::movq(Address dst, XMMRegister src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2530 assert(VM_Version::supports_sse2(), "");
a61af66fc99e Initial load
duke
parents:
diff changeset
2531
a61af66fc99e Initial load
duke
parents:
diff changeset
2532 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2533 emit_byte(0x66);
a61af66fc99e Initial load
duke
parents:
diff changeset
2534 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
2535 emit_byte(0xD6);
a61af66fc99e Initial load
duke
parents:
diff changeset
2536 emit_sse_operand(src, dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
2537 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2538
a61af66fc99e Initial load
duke
parents:
diff changeset
2539 void Assembler::movd(Address dst, XMMRegister src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2540 assert(VM_Version::supports_sse2(), "");
a61af66fc99e Initial load
duke
parents:
diff changeset
2541
a61af66fc99e Initial load
duke
parents:
diff changeset
2542 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2543 emit_byte(0x66);
a61af66fc99e Initial load
duke
parents:
diff changeset
2544 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
2545 emit_byte(0x7E);
a61af66fc99e Initial load
duke
parents:
diff changeset
2546 emit_sse_operand(src, dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
2547 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2548
a61af66fc99e Initial load
duke
parents:
diff changeset
2549 void Assembler::movd(Register dst, XMMRegister src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2550 assert(VM_Version::supports_sse2(), "");
a61af66fc99e Initial load
duke
parents:
diff changeset
2551
a61af66fc99e Initial load
duke
parents:
diff changeset
2552 emit_byte(0x66);
a61af66fc99e Initial load
duke
parents:
diff changeset
2553 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
2554 emit_byte(0x7E);
a61af66fc99e Initial load
duke
parents:
diff changeset
2555 emit_sse_operand(src, dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
2556 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2557
a61af66fc99e Initial load
duke
parents:
diff changeset
2558 void Assembler::movdqa(Address dst, XMMRegister src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2559 assert(VM_Version::supports_sse2(), "");
a61af66fc99e Initial load
duke
parents:
diff changeset
2560
a61af66fc99e Initial load
duke
parents:
diff changeset
2561 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2562 emit_byte(0x66);
a61af66fc99e Initial load
duke
parents:
diff changeset
2563 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
2564 emit_byte(0x7F);
a61af66fc99e Initial load
duke
parents:
diff changeset
2565 emit_sse_operand(src, dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
2566 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2567
a61af66fc99e Initial load
duke
parents:
diff changeset
2568 void Assembler::pshufd(XMMRegister dst, XMMRegister src, int mode) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2569 assert(isByte(mode), "invalid value");
a61af66fc99e Initial load
duke
parents:
diff changeset
2570 assert(VM_Version::supports_sse2(), "");
a61af66fc99e Initial load
duke
parents:
diff changeset
2571
a61af66fc99e Initial load
duke
parents:
diff changeset
2572 emit_byte(0x66);
a61af66fc99e Initial load
duke
parents:
diff changeset
2573 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
2574 emit_byte(0x70);
a61af66fc99e Initial load
duke
parents:
diff changeset
2575 emit_sse_operand(dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
2576 emit_byte(mode & 0xFF);
a61af66fc99e Initial load
duke
parents:
diff changeset
2577 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2578
a61af66fc99e Initial load
duke
parents:
diff changeset
2579 void Assembler::pshufd(XMMRegister dst, Address src, int mode) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2580 assert(isByte(mode), "invalid value");
a61af66fc99e Initial load
duke
parents:
diff changeset
2581 assert(VM_Version::supports_sse2(), "");
a61af66fc99e Initial load
duke
parents:
diff changeset
2582
a61af66fc99e Initial load
duke
parents:
diff changeset
2583 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2584 emit_byte(0x66);
a61af66fc99e Initial load
duke
parents:
diff changeset
2585 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
2586 emit_byte(0x70);
a61af66fc99e Initial load
duke
parents:
diff changeset
2587 emit_sse_operand(dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
2588 emit_byte(mode & 0xFF);
a61af66fc99e Initial load
duke
parents:
diff changeset
2589 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2590
a61af66fc99e Initial load
duke
parents:
diff changeset
2591 void Assembler::pshuflw(XMMRegister dst, XMMRegister src, int mode) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2592 assert(isByte(mode), "invalid value");
a61af66fc99e Initial load
duke
parents:
diff changeset
2593 assert(VM_Version::supports_sse2(), "");
a61af66fc99e Initial load
duke
parents:
diff changeset
2594
a61af66fc99e Initial load
duke
parents:
diff changeset
2595 emit_byte(0xF2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2596 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
2597 emit_byte(0x70);
a61af66fc99e Initial load
duke
parents:
diff changeset
2598 emit_sse_operand(dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
2599 emit_byte(mode & 0xFF);
a61af66fc99e Initial load
duke
parents:
diff changeset
2600 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2601
a61af66fc99e Initial load
duke
parents:
diff changeset
2602 void Assembler::pshuflw(XMMRegister dst, Address src, int mode) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2603 assert(isByte(mode), "invalid value");
a61af66fc99e Initial load
duke
parents:
diff changeset
2604 assert(VM_Version::supports_sse2(), "");
a61af66fc99e Initial load
duke
parents:
diff changeset
2605
a61af66fc99e Initial load
duke
parents:
diff changeset
2606 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2607 emit_byte(0xF2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2608 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
2609 emit_byte(0x70);
a61af66fc99e Initial load
duke
parents:
diff changeset
2610 emit_sse_operand(dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
2611 emit_byte(mode & 0xFF);
a61af66fc99e Initial load
duke
parents:
diff changeset
2612 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2613
a61af66fc99e Initial load
duke
parents:
diff changeset
2614 void Assembler::psrlq(XMMRegister dst, int shift) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2615 assert(VM_Version::supports_sse2(), "");
a61af66fc99e Initial load
duke
parents:
diff changeset
2616
a61af66fc99e Initial load
duke
parents:
diff changeset
2617 emit_byte(0x66);
a61af66fc99e Initial load
duke
parents:
diff changeset
2618 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
2619 emit_byte(0x73);
a61af66fc99e Initial load
duke
parents:
diff changeset
2620 emit_sse_operand(xmm2, dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
2621 emit_byte(shift);
a61af66fc99e Initial load
duke
parents:
diff changeset
2622 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2623
a61af66fc99e Initial load
duke
parents:
diff changeset
2624 void Assembler::movss( Address dst, XMMRegister src ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2625 assert(VM_Version::supports_sse(), "");
a61af66fc99e Initial load
duke
parents:
diff changeset
2626
a61af66fc99e Initial load
duke
parents:
diff changeset
2627 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2628 emit_byte(0xF3); // single
a61af66fc99e Initial load
duke
parents:
diff changeset
2629 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
2630 emit_byte(0x11); // store
a61af66fc99e Initial load
duke
parents:
diff changeset
2631 emit_sse_operand(src, dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
2632 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2633
a61af66fc99e Initial load
duke
parents:
diff changeset
2634 void Assembler::movsd( Address dst, XMMRegister src ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2635 assert(VM_Version::supports_sse2(), "");
a61af66fc99e Initial load
duke
parents:
diff changeset
2636
a61af66fc99e Initial load
duke
parents:
diff changeset
2637 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2638 emit_byte(0xF2); // double
a61af66fc99e Initial load
duke
parents:
diff changeset
2639 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
2640 emit_byte(0x11); // store
a61af66fc99e Initial load
duke
parents:
diff changeset
2641 emit_sse_operand(src,dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
2642 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2643
a61af66fc99e Initial load
duke
parents:
diff changeset
2644 // New cpus require to use movaps and movapd to avoid partial register stall
a61af66fc99e Initial load
duke
parents:
diff changeset
2645 // when moving between registers.
a61af66fc99e Initial load
duke
parents:
diff changeset
2646 void Assembler::movaps(XMMRegister dst, XMMRegister src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2647 assert(VM_Version::supports_sse(), "");
a61af66fc99e Initial load
duke
parents:
diff changeset
2648
a61af66fc99e Initial load
duke
parents:
diff changeset
2649 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
2650 emit_byte(0x28);
a61af66fc99e Initial load
duke
parents:
diff changeset
2651 emit_sse_operand(dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
2652 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2653 void Assembler::movapd(XMMRegister dst, XMMRegister src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2654 assert(VM_Version::supports_sse2(), "");
a61af66fc99e Initial load
duke
parents:
diff changeset
2655
a61af66fc99e Initial load
duke
parents:
diff changeset
2656 emit_byte(0x66);
a61af66fc99e Initial load
duke
parents:
diff changeset
2657 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
2658 emit_byte(0x28);
a61af66fc99e Initial load
duke
parents:
diff changeset
2659 emit_sse_operand(dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
2660 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2661
a61af66fc99e Initial load
duke
parents:
diff changeset
2662 // New cpus require to use movsd and movss to avoid partial register stall
a61af66fc99e Initial load
duke
parents:
diff changeset
2663 // when loading from memory. But for old Opteron use movlpd instead of movsd.
a61af66fc99e Initial load
duke
parents:
diff changeset
2664 // The selection is done in MacroAssembler::movdbl() and movflt().
a61af66fc99e Initial load
duke
parents:
diff changeset
2665 void Assembler::movlpd(XMMRegister dst, Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2666 assert(VM_Version::supports_sse(), "");
a61af66fc99e Initial load
duke
parents:
diff changeset
2667
a61af66fc99e Initial load
duke
parents:
diff changeset
2668 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2669 emit_byte(0x66);
a61af66fc99e Initial load
duke
parents:
diff changeset
2670 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
2671 emit_byte(0x12);
a61af66fc99e Initial load
duke
parents:
diff changeset
2672 emit_sse_operand(dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
2673 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2674
71
3d62cb85208d 6662967: Optimize I2D conversion on new x86
kvn
parents: 0
diff changeset
2675 void Assembler::cvtdq2pd(XMMRegister dst, XMMRegister src) {
3d62cb85208d 6662967: Optimize I2D conversion on new x86
kvn
parents: 0
diff changeset
2676 assert(VM_Version::supports_sse2(), "");
3d62cb85208d 6662967: Optimize I2D conversion on new x86
kvn
parents: 0
diff changeset
2677
3d62cb85208d 6662967: Optimize I2D conversion on new x86
kvn
parents: 0
diff changeset
2678 emit_byte(0xF3);
3d62cb85208d 6662967: Optimize I2D conversion on new x86
kvn
parents: 0
diff changeset
2679 emit_byte(0x0F);
3d62cb85208d 6662967: Optimize I2D conversion on new x86
kvn
parents: 0
diff changeset
2680 emit_byte(0xE6);
3d62cb85208d 6662967: Optimize I2D conversion on new x86
kvn
parents: 0
diff changeset
2681 emit_sse_operand(dst, src);
3d62cb85208d 6662967: Optimize I2D conversion on new x86
kvn
parents: 0
diff changeset
2682 }
3d62cb85208d 6662967: Optimize I2D conversion on new x86
kvn
parents: 0
diff changeset
2683
3d62cb85208d 6662967: Optimize I2D conversion on new x86
kvn
parents: 0
diff changeset
2684 void Assembler::cvtdq2ps(XMMRegister dst, XMMRegister src) {
3d62cb85208d 6662967: Optimize I2D conversion on new x86
kvn
parents: 0
diff changeset
2685 assert(VM_Version::supports_sse2(), "");
3d62cb85208d 6662967: Optimize I2D conversion on new x86
kvn
parents: 0
diff changeset
2686
3d62cb85208d 6662967: Optimize I2D conversion on new x86
kvn
parents: 0
diff changeset
2687 emit_byte(0x0F);
3d62cb85208d 6662967: Optimize I2D conversion on new x86
kvn
parents: 0
diff changeset
2688 emit_byte(0x5B);
3d62cb85208d 6662967: Optimize I2D conversion on new x86
kvn
parents: 0
diff changeset
2689 emit_sse_operand(dst, src);
3d62cb85208d 6662967: Optimize I2D conversion on new x86
kvn
parents: 0
diff changeset
2690 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2691
a61af66fc99e Initial load
duke
parents:
diff changeset
2692 emit_sse_instruction(andps, sse, 0, 0x54, XMMRegister, XMMRegister);
a61af66fc99e Initial load
duke
parents:
diff changeset
2693 emit_sse_instruction(andpd, sse2, 0x66, 0x54, XMMRegister, XMMRegister);
a61af66fc99e Initial load
duke
parents:
diff changeset
2694 emit_sse_instruction(andnps, sse, 0, 0x55, XMMRegister, XMMRegister);
a61af66fc99e Initial load
duke
parents:
diff changeset
2695 emit_sse_instruction(andnpd, sse2, 0x66, 0x55, XMMRegister, XMMRegister);
a61af66fc99e Initial load
duke
parents:
diff changeset
2696 emit_sse_instruction(orps, sse, 0, 0x56, XMMRegister, XMMRegister);
a61af66fc99e Initial load
duke
parents:
diff changeset
2697 emit_sse_instruction(orpd, sse2, 0x66, 0x56, XMMRegister, XMMRegister);
a61af66fc99e Initial load
duke
parents:
diff changeset
2698 emit_sse_instruction(xorps, sse, 0, 0x57, XMMRegister, XMMRegister);
a61af66fc99e Initial load
duke
parents:
diff changeset
2699 emit_sse_instruction(xorpd, sse2, 0x66, 0x57, XMMRegister, XMMRegister);
a61af66fc99e Initial load
duke
parents:
diff changeset
2700
a61af66fc99e Initial load
duke
parents:
diff changeset
2701
a61af66fc99e Initial load
duke
parents:
diff changeset
2702 void Assembler::ldmxcsr( Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2703 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2704 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
2705 emit_byte(0xAE);
a61af66fc99e Initial load
duke
parents:
diff changeset
2706 emit_operand(rdx /* 2 */, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
2707 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2708
a61af66fc99e Initial load
duke
parents:
diff changeset
2709 void Assembler::stmxcsr( Address dst) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2710 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2711 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
2712 emit_byte(0xAE);
a61af66fc99e Initial load
duke
parents:
diff changeset
2713 emit_operand(rbx /* 3 */, dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
2714 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2715
a61af66fc99e Initial load
duke
parents:
diff changeset
2716 // Implementation of MacroAssembler
a61af66fc99e Initial load
duke
parents:
diff changeset
2717
a61af66fc99e Initial load
duke
parents:
diff changeset
2718 Address MacroAssembler::as_Address(AddressLiteral adr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2719 // amd64 always does this as a pc-rel
a61af66fc99e Initial load
duke
parents:
diff changeset
2720 // we can be absolute or disp based on the instruction type
a61af66fc99e Initial load
duke
parents:
diff changeset
2721 // jmp/call are displacements others are absolute
a61af66fc99e Initial load
duke
parents:
diff changeset
2722 assert(!adr.is_lval(), "must be rval");
a61af66fc99e Initial load
duke
parents:
diff changeset
2723
a61af66fc99e Initial load
duke
parents:
diff changeset
2724 return Address(adr.target(), adr.rspec());
a61af66fc99e Initial load
duke
parents:
diff changeset
2725 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2726
a61af66fc99e Initial load
duke
parents:
diff changeset
2727 Address MacroAssembler::as_Address(ArrayAddress adr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2728 return Address::make_array(adr);
a61af66fc99e Initial load
duke
parents:
diff changeset
2729 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2730
a61af66fc99e Initial load
duke
parents:
diff changeset
2731 void MacroAssembler::fat_nop() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2732 // A 5 byte nop that is safe for patching (see patch_verified_entry)
a61af66fc99e Initial load
duke
parents:
diff changeset
2733 emit_byte(0x26); // es:
a61af66fc99e Initial load
duke
parents:
diff changeset
2734 emit_byte(0x2e); // cs:
a61af66fc99e Initial load
duke
parents:
diff changeset
2735 emit_byte(0x64); // fs:
a61af66fc99e Initial load
duke
parents:
diff changeset
2736 emit_byte(0x65); // gs:
a61af66fc99e Initial load
duke
parents:
diff changeset
2737 emit_byte(0x90);
a61af66fc99e Initial load
duke
parents:
diff changeset
2738 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2739
a61af66fc99e Initial load
duke
parents:
diff changeset
2740 // 32bit can do a case table jump in one instruction but we no longer allow the base
a61af66fc99e Initial load
duke
parents:
diff changeset
2741 // to be installed in the Address class
a61af66fc99e Initial load
duke
parents:
diff changeset
2742 void MacroAssembler::jump(ArrayAddress entry) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2743 jmp(as_Address(entry));
a61af66fc99e Initial load
duke
parents:
diff changeset
2744 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2745
a61af66fc99e Initial load
duke
parents:
diff changeset
2746 void MacroAssembler::jump(AddressLiteral dst) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2747 jmp_literal(dst.target(), dst.rspec());
a61af66fc99e Initial load
duke
parents:
diff changeset
2748 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2749
a61af66fc99e Initial load
duke
parents:
diff changeset
2750 void MacroAssembler::jump_cc(Condition cc, AddressLiteral dst) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2751 assert((0 <= cc) && (cc < 16), "illegal cc");
a61af66fc99e Initial load
duke
parents:
diff changeset
2752
a61af66fc99e Initial load
duke
parents:
diff changeset
2753 InstructionMark im(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
2754
a61af66fc99e Initial load
duke
parents:
diff changeset
2755 relocInfo::relocType rtype = dst.reloc();
a61af66fc99e Initial load
duke
parents:
diff changeset
2756 relocate(rtype);
a61af66fc99e Initial load
duke
parents:
diff changeset
2757 const int short_size = 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
2758 const int long_size = 6;
a61af66fc99e Initial load
duke
parents:
diff changeset
2759 int offs = (int)dst.target() - ((int)_code_pos);
a61af66fc99e Initial load
duke
parents:
diff changeset
2760 if (rtype == relocInfo::none && is8bit(offs - short_size)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2761 // 0111 tttn #8-bit disp
a61af66fc99e Initial load
duke
parents:
diff changeset
2762 emit_byte(0x70 | cc);
a61af66fc99e Initial load
duke
parents:
diff changeset
2763 emit_byte((offs - short_size) & 0xFF);
a61af66fc99e Initial load
duke
parents:
diff changeset
2764 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2765 // 0000 1111 1000 tttn #32-bit disp
a61af66fc99e Initial load
duke
parents:
diff changeset
2766 emit_byte(0x0F);
a61af66fc99e Initial load
duke
parents:
diff changeset
2767 emit_byte(0x80 | cc);
a61af66fc99e Initial load
duke
parents:
diff changeset
2768 emit_long(offs - long_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
2769 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2770 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2771
a61af66fc99e Initial load
duke
parents:
diff changeset
2772 // Calls
a61af66fc99e Initial load
duke
parents:
diff changeset
2773 void MacroAssembler::call(Label& L, relocInfo::relocType rtype) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2774 Assembler::call(L, rtype);
a61af66fc99e Initial load
duke
parents:
diff changeset
2775 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2776
a61af66fc99e Initial load
duke
parents:
diff changeset
2777 void MacroAssembler::call(Register entry) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2778 Assembler::call(entry);
a61af66fc99e Initial load
duke
parents:
diff changeset
2779 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2780
a61af66fc99e Initial load
duke
parents:
diff changeset
2781 void MacroAssembler::call(AddressLiteral entry) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2782 Assembler::call_literal(entry.target(), entry.rspec());
a61af66fc99e Initial load
duke
parents:
diff changeset
2783 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2784
a61af66fc99e Initial load
duke
parents:
diff changeset
2785
a61af66fc99e Initial load
duke
parents:
diff changeset
2786 void MacroAssembler::cmp8(AddressLiteral src1, int8_t imm) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2787 Assembler::cmpb(as_Address(src1), imm);
a61af66fc99e Initial load
duke
parents:
diff changeset
2788 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2789
a61af66fc99e Initial load
duke
parents:
diff changeset
2790 void MacroAssembler::cmp32(AddressLiteral src1, int32_t imm) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2791 Assembler::cmpl(as_Address(src1), imm);
a61af66fc99e Initial load
duke
parents:
diff changeset
2792 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2793
a61af66fc99e Initial load
duke
parents:
diff changeset
2794 void MacroAssembler::cmp32(Register src1, AddressLiteral src2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2795 if (src2.is_lval()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2796 cmp_literal32(src1, (int32_t) src2.target(), src2.rspec());
a61af66fc99e Initial load
duke
parents:
diff changeset
2797 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2798 Assembler::cmpl(src1, as_Address(src2));
a61af66fc99e Initial load
duke
parents:
diff changeset
2799 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2800 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2801
a61af66fc99e Initial load
duke
parents:
diff changeset
2802 void MacroAssembler::cmp32(Register src1, int32_t imm) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2803 Assembler::cmpl(src1, imm);
a61af66fc99e Initial load
duke
parents:
diff changeset
2804 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2805
a61af66fc99e Initial load
duke
parents:
diff changeset
2806 void MacroAssembler::cmp32(Register src1, Address src2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2807 Assembler::cmpl(src1, src2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2808 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2809
a61af66fc99e Initial load
duke
parents:
diff changeset
2810 void MacroAssembler::cmpoop(Address src1, jobject obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2811 cmp_literal32(src1, (int32_t)obj, oop_Relocation::spec_for_immediate());
a61af66fc99e Initial load
duke
parents:
diff changeset
2812 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2813
a61af66fc99e Initial load
duke
parents:
diff changeset
2814 void MacroAssembler::cmpoop(Register src1, jobject obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2815 cmp_literal32(src1, (int32_t)obj, oop_Relocation::spec_for_immediate());
a61af66fc99e Initial load
duke
parents:
diff changeset
2816 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2817
a61af66fc99e Initial load
duke
parents:
diff changeset
2818 void MacroAssembler::cmpptr(Register src1, AddressLiteral src2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2819 if (src2.is_lval()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2820 // compare the effect address of src2 to src1
a61af66fc99e Initial load
duke
parents:
diff changeset
2821 cmp_literal32(src1, (int32_t)src2.target(), src2.rspec());
a61af66fc99e Initial load
duke
parents:
diff changeset
2822 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2823 Assembler::cmpl(src1, as_Address(src2));
a61af66fc99e Initial load
duke
parents:
diff changeset
2824 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2825 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2826
a61af66fc99e Initial load
duke
parents:
diff changeset
2827 void MacroAssembler::cmpptr(Address src1, AddressLiteral src2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2828 assert(src2.is_lval(), "not a mem-mem compare");
a61af66fc99e Initial load
duke
parents:
diff changeset
2829 cmp_literal32(src1, (int32_t) src2.target(), src2.rspec());
a61af66fc99e Initial load
duke
parents:
diff changeset
2830 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2831
a61af66fc99e Initial load
duke
parents:
diff changeset
2832
a61af66fc99e Initial load
duke
parents:
diff changeset
2833 void MacroAssembler::cmpxchgptr(Register reg, AddressLiteral adr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2834 cmpxchg(reg, as_Address(adr));
a61af66fc99e Initial load
duke
parents:
diff changeset
2835 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2836
a61af66fc99e Initial load
duke
parents:
diff changeset
2837 void MacroAssembler::increment(AddressLiteral dst) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2838 increment(as_Address(dst));
a61af66fc99e Initial load
duke
parents:
diff changeset
2839 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2840
a61af66fc99e Initial load
duke
parents:
diff changeset
2841 void MacroAssembler::increment(ArrayAddress dst) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2842 increment(as_Address(dst));
a61af66fc99e Initial load
duke
parents:
diff changeset
2843 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2844
a61af66fc99e Initial load
duke
parents:
diff changeset
2845 void MacroAssembler::lea(Register dst, AddressLiteral adr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2846 // leal(dst, as_Address(adr));
a61af66fc99e Initial load
duke
parents:
diff changeset
2847 // see note in movl as to why we musr use a move
a61af66fc99e Initial load
duke
parents:
diff changeset
2848 mov_literal32(dst, (int32_t) adr.target(), adr.rspec());
a61af66fc99e Initial load
duke
parents:
diff changeset
2849 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2850
a61af66fc99e Initial load
duke
parents:
diff changeset
2851 void MacroAssembler::lea(Address dst, AddressLiteral adr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2852 // leal(dst, as_Address(adr));
a61af66fc99e Initial load
duke
parents:
diff changeset
2853 // see note in movl as to why we musr use a move
a61af66fc99e Initial load
duke
parents:
diff changeset
2854 mov_literal32(dst, (int32_t) adr.target(), adr.rspec());
a61af66fc99e Initial load
duke
parents:
diff changeset
2855 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2856
a61af66fc99e Initial load
duke
parents:
diff changeset
2857 void MacroAssembler::mov32(AddressLiteral dst, Register src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2858 Assembler::movl(as_Address(dst), src);
a61af66fc99e Initial load
duke
parents:
diff changeset
2859 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2860
a61af66fc99e Initial load
duke
parents:
diff changeset
2861 void MacroAssembler::mov32(Register dst, AddressLiteral src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2862 Assembler::movl(dst, as_Address(src));
a61af66fc99e Initial load
duke
parents:
diff changeset
2863 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2864
a61af66fc99e Initial load
duke
parents:
diff changeset
2865 void MacroAssembler::movbyte(ArrayAddress dst, int src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2866 movb(as_Address(dst), src);
a61af66fc99e Initial load
duke
parents:
diff changeset
2867 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2868
a61af66fc99e Initial load
duke
parents:
diff changeset
2869 void MacroAssembler::movoop(Address dst, jobject obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2870 mov_literal32(dst, (int32_t)obj, oop_Relocation::spec_for_immediate());
a61af66fc99e Initial load
duke
parents:
diff changeset
2871 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2872
a61af66fc99e Initial load
duke
parents:
diff changeset
2873 void MacroAssembler::movoop(Register dst, jobject obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2874 mov_literal32(dst, (int32_t)obj, oop_Relocation::spec_for_immediate());
a61af66fc99e Initial load
duke
parents:
diff changeset
2875 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2876
a61af66fc99e Initial load
duke
parents:
diff changeset
2877 void MacroAssembler::movptr(Register dst, AddressLiteral src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2878 if (src.is_lval()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2879 // essentially an lea
a61af66fc99e Initial load
duke
parents:
diff changeset
2880 mov_literal32(dst, (int32_t) src.target(), src.rspec());
a61af66fc99e Initial load
duke
parents:
diff changeset
2881 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2882 // mov 32bits from an absolute address
a61af66fc99e Initial load
duke
parents:
diff changeset
2883 movl(dst, as_Address(src));
a61af66fc99e Initial load
duke
parents:
diff changeset
2884 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2885 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2886
a61af66fc99e Initial load
duke
parents:
diff changeset
2887 void MacroAssembler::movptr(ArrayAddress dst, Register src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2888 movl(as_Address(dst), src);
a61af66fc99e Initial load
duke
parents:
diff changeset
2889 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2890
a61af66fc99e Initial load
duke
parents:
diff changeset
2891 void MacroAssembler::movptr(Register dst, ArrayAddress src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2892 movl(dst, as_Address(src));
a61af66fc99e Initial load
duke
parents:
diff changeset
2893 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2894
a61af66fc99e Initial load
duke
parents:
diff changeset
2895 void MacroAssembler::movflt(XMMRegister dst, AddressLiteral src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2896 movss(dst, as_Address(src));
a61af66fc99e Initial load
duke
parents:
diff changeset
2897 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2898
a61af66fc99e Initial load
duke
parents:
diff changeset
2899 void MacroAssembler::movdbl(XMMRegister dst, AddressLiteral src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2900 if (UseXmmLoadAndClearUpper) { movsd (dst, as_Address(src)); return; }
a61af66fc99e Initial load
duke
parents:
diff changeset
2901 else { movlpd(dst, as_Address(src)); return; }
a61af66fc99e Initial load
duke
parents:
diff changeset
2902 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2903
a61af66fc99e Initial load
duke
parents:
diff changeset
2904 void Assembler::pushoop(jobject obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2905 push_literal32((int32_t)obj, oop_Relocation::spec_for_immediate());
a61af66fc99e Initial load
duke
parents:
diff changeset
2906 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2907
a61af66fc99e Initial load
duke
parents:
diff changeset
2908
a61af66fc99e Initial load
duke
parents:
diff changeset
2909 void MacroAssembler::pushptr(AddressLiteral src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2910 if (src.is_lval()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2911 push_literal32((int32_t)src.target(), src.rspec());
a61af66fc99e Initial load
duke
parents:
diff changeset
2912 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2913 pushl(as_Address(src));
a61af66fc99e Initial load
duke
parents:
diff changeset
2914 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2915 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2916
a61af66fc99e Initial load
duke
parents:
diff changeset
2917 void MacroAssembler::test32(Register src1, AddressLiteral src2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2918 // src2 must be rval
a61af66fc99e Initial load
duke
parents:
diff changeset
2919 testl(src1, as_Address(src2));
a61af66fc99e Initial load
duke
parents:
diff changeset
2920 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2921
a61af66fc99e Initial load
duke
parents:
diff changeset
2922 // FPU
a61af66fc99e Initial load
duke
parents:
diff changeset
2923
a61af66fc99e Initial load
duke
parents:
diff changeset
2924 void MacroAssembler::fld_x(AddressLiteral src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2925 Assembler::fld_x(as_Address(src));
a61af66fc99e Initial load
duke
parents:
diff changeset
2926 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2927
a61af66fc99e Initial load
duke
parents:
diff changeset
2928 void MacroAssembler::fld_d(AddressLiteral src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2929 fld_d(as_Address(src));
a61af66fc99e Initial load
duke
parents:
diff changeset
2930 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2931
a61af66fc99e Initial load
duke
parents:
diff changeset
2932 void MacroAssembler::fld_s(AddressLiteral src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2933 fld_s(as_Address(src));
a61af66fc99e Initial load
duke
parents:
diff changeset
2934 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2935
a61af66fc99e Initial load
duke
parents:
diff changeset
2936 void MacroAssembler::fldcw(AddressLiteral src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2937 Assembler::fldcw(as_Address(src));
a61af66fc99e Initial load
duke
parents:
diff changeset
2938 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2939
a61af66fc99e Initial load
duke
parents:
diff changeset
2940 void MacroAssembler::ldmxcsr(AddressLiteral src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2941 Assembler::ldmxcsr(as_Address(src));
a61af66fc99e Initial load
duke
parents:
diff changeset
2942 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2943
a61af66fc99e Initial load
duke
parents:
diff changeset
2944 // SSE
a61af66fc99e Initial load
duke
parents:
diff changeset
2945
a61af66fc99e Initial load
duke
parents:
diff changeset
2946 void MacroAssembler::andpd(XMMRegister dst, AddressLiteral src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2947 andpd(dst, as_Address(src));
a61af66fc99e Initial load
duke
parents:
diff changeset
2948 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2949
a61af66fc99e Initial load
duke
parents:
diff changeset
2950 void MacroAssembler::comisd(XMMRegister dst, AddressLiteral src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2951 comisd(dst, as_Address(src));
a61af66fc99e Initial load
duke
parents:
diff changeset
2952 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2953
a61af66fc99e Initial load
duke
parents:
diff changeset
2954 void MacroAssembler::comiss(XMMRegister dst, AddressLiteral src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2955 comiss(dst, as_Address(src));
a61af66fc99e Initial load
duke
parents:
diff changeset
2956 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2957
a61af66fc99e Initial load
duke
parents:
diff changeset
2958 void MacroAssembler::movsd(XMMRegister dst, AddressLiteral src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2959 movsd(dst, as_Address(src));
a61af66fc99e Initial load
duke
parents:
diff changeset
2960 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2961
a61af66fc99e Initial load
duke
parents:
diff changeset
2962 void MacroAssembler::movss(XMMRegister dst, AddressLiteral src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2963 movss(dst, as_Address(src));
a61af66fc99e Initial load
duke
parents:
diff changeset
2964 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2965
a61af66fc99e Initial load
duke
parents:
diff changeset
2966 void MacroAssembler::xorpd(XMMRegister dst, AddressLiteral src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2967 xorpd(dst, as_Address(src));
a61af66fc99e Initial load
duke
parents:
diff changeset
2968 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2969
a61af66fc99e Initial load
duke
parents:
diff changeset
2970 void MacroAssembler::xorps(XMMRegister dst, AddressLiteral src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2971 xorps(dst, as_Address(src));
a61af66fc99e Initial load
duke
parents:
diff changeset
2972 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2973
a61af66fc99e Initial load
duke
parents:
diff changeset
2974 void MacroAssembler::ucomisd(XMMRegister dst, AddressLiteral src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2975 ucomisd(dst, as_Address(src));
a61af66fc99e Initial load
duke
parents:
diff changeset
2976 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2977
a61af66fc99e Initial load
duke
parents:
diff changeset
2978 void MacroAssembler::ucomiss(XMMRegister dst, AddressLiteral src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2979 ucomiss(dst, as_Address(src));
a61af66fc99e Initial load
duke
parents:
diff changeset
2980 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2981
a61af66fc99e Initial load
duke
parents:
diff changeset
2982 void MacroAssembler::null_check(Register reg, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2983 if (needs_explicit_null_check(offset)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2984 // provoke OS NULL exception if reg = NULL by
a61af66fc99e Initial load
duke
parents:
diff changeset
2985 // accessing M[reg] w/o changing any (non-CC) registers
a61af66fc99e Initial load
duke
parents:
diff changeset
2986 cmpl(rax, Address(reg, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
2987 // Note: should probably use testl(rax, Address(reg, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
2988 // may be shorter code (however, this version of
a61af66fc99e Initial load
duke
parents:
diff changeset
2989 // testl needs to be implemented first)
a61af66fc99e Initial load
duke
parents:
diff changeset
2990 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2991 // nothing to do, (later) access of M[reg + offset]
a61af66fc99e Initial load
duke
parents:
diff changeset
2992 // will provoke OS NULL exception if reg = NULL
a61af66fc99e Initial load
duke
parents:
diff changeset
2993 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2994 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2995
a61af66fc99e Initial load
duke
parents:
diff changeset
2996
a61af66fc99e Initial load
duke
parents:
diff changeset
2997 int MacroAssembler::load_unsigned_byte(Register dst, Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2998 // According to Intel Doc. AP-526, "Zero-Extension of Short", p.16,
a61af66fc99e Initial load
duke
parents:
diff changeset
2999 // and "3.9 Partial Register Penalties", p. 22).
a61af66fc99e Initial load
duke
parents:
diff changeset
3000 int off;
a61af66fc99e Initial load
duke
parents:
diff changeset
3001 if (VM_Version::is_P6() || src.uses(dst)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3002 off = offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
3003 movzxb(dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
3004 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3005 xorl(dst, dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
3006 off = offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
3007 movb(dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
3008 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3009 return off;
a61af66fc99e Initial load
duke
parents:
diff changeset
3010 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3011
a61af66fc99e Initial load
duke
parents:
diff changeset
3012
a61af66fc99e Initial load
duke
parents:
diff changeset
3013 int MacroAssembler::load_unsigned_word(Register dst, Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3014 // According to Intel Doc. AP-526, "Zero-Extension of Short", p.16,
a61af66fc99e Initial load
duke
parents:
diff changeset
3015 // and "3.9 Partial Register Penalties", p. 22).
a61af66fc99e Initial load
duke
parents:
diff changeset
3016 int off;
a61af66fc99e Initial load
duke
parents:
diff changeset
3017 if (VM_Version::is_P6() || src.uses(dst)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3018 off = offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
3019 movzxw(dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
3020 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3021 xorl(dst, dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
3022 off = offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
3023 movw(dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
3024 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3025 return off;
a61af66fc99e Initial load
duke
parents:
diff changeset
3026 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3027
a61af66fc99e Initial load
duke
parents:
diff changeset
3028
a61af66fc99e Initial load
duke
parents:
diff changeset
3029 int MacroAssembler::load_signed_byte(Register dst, Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3030 int off;
a61af66fc99e Initial load
duke
parents:
diff changeset
3031 if (VM_Version::is_P6()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3032 off = offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
3033 movsxb(dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
3034 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3035 off = load_unsigned_byte(dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
3036 shll(dst, 24);
a61af66fc99e Initial load
duke
parents:
diff changeset
3037 sarl(dst, 24);
a61af66fc99e Initial load
duke
parents:
diff changeset
3038 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3039 return off;
a61af66fc99e Initial load
duke
parents:
diff changeset
3040 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3041
a61af66fc99e Initial load
duke
parents:
diff changeset
3042
a61af66fc99e Initial load
duke
parents:
diff changeset
3043 int MacroAssembler::load_signed_word(Register dst, Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3044 int off;
a61af66fc99e Initial load
duke
parents:
diff changeset
3045 if (VM_Version::is_P6()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3046 off = offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
3047 movsxw(dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
3048 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3049 off = load_unsigned_word(dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
3050 shll(dst, 16);
a61af66fc99e Initial load
duke
parents:
diff changeset
3051 sarl(dst, 16);
a61af66fc99e Initial load
duke
parents:
diff changeset
3052 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3053 return off;
a61af66fc99e Initial load
duke
parents:
diff changeset
3054 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3055
a61af66fc99e Initial load
duke
parents:
diff changeset
3056
a61af66fc99e Initial load
duke
parents:
diff changeset
3057 void MacroAssembler::extend_sign(Register hi, Register lo) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3058 // According to Intel Doc. AP-526, "Integer Divide", p.18.
a61af66fc99e Initial load
duke
parents:
diff changeset
3059 if (VM_Version::is_P6() && hi == rdx && lo == rax) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3060 cdql();
a61af66fc99e Initial load
duke
parents:
diff changeset
3061 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3062 movl(hi, lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
3063 sarl(hi, 31);
a61af66fc99e Initial load
duke
parents:
diff changeset
3064 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3065 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3066
a61af66fc99e Initial load
duke
parents:
diff changeset
3067
a61af66fc99e Initial load
duke
parents:
diff changeset
3068 void MacroAssembler::increment(Register reg, int value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3069 if (value == min_jint) {addl(reg, value); return; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3070 if (value < 0) { decrement(reg, -value); return; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3071 if (value == 0) { ; return; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3072 if (value == 1 && UseIncDec) { incl(reg); return; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3073 /* else */ { addl(reg, value) ; return; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3074 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3075
a61af66fc99e Initial load
duke
parents:
diff changeset
3076 void MacroAssembler::increment(Address dst, int value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3077 if (value == min_jint) {addl(dst, value); return; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3078 if (value < 0) { decrement(dst, -value); return; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3079 if (value == 0) { ; return; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3080 if (value == 1 && UseIncDec) { incl(dst); return; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3081 /* else */ { addl(dst, value) ; return; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3082 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3083
a61af66fc99e Initial load
duke
parents:
diff changeset
3084 void MacroAssembler::decrement(Register reg, int value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3085 if (value == min_jint) {subl(reg, value); return; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3086 if (value < 0) { increment(reg, -value); return; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3087 if (value == 0) { ; return; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3088 if (value == 1 && UseIncDec) { decl(reg); return; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3089 /* else */ { subl(reg, value) ; return; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3090 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3091
a61af66fc99e Initial load
duke
parents:
diff changeset
3092 void MacroAssembler::decrement(Address dst, int value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3093 if (value == min_jint) {subl(dst, value); return; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3094 if (value < 0) { increment(dst, -value); return; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3095 if (value == 0) { ; return; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3096 if (value == 1 && UseIncDec) { decl(dst); return; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3097 /* else */ { subl(dst, value) ; return; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3098 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3099
a61af66fc99e Initial load
duke
parents:
diff changeset
3100 void MacroAssembler::align(int modulus) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3101 if (offset() % modulus != 0) nop(modulus - (offset() % modulus));
a61af66fc99e Initial load
duke
parents:
diff changeset
3102 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3103
a61af66fc99e Initial load
duke
parents:
diff changeset
3104
a61af66fc99e Initial load
duke
parents:
diff changeset
3105 void MacroAssembler::enter() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3106 pushl(rbp);
a61af66fc99e Initial load
duke
parents:
diff changeset
3107 movl(rbp, rsp);
a61af66fc99e Initial load
duke
parents:
diff changeset
3108 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3109
a61af66fc99e Initial load
duke
parents:
diff changeset
3110
a61af66fc99e Initial load
duke
parents:
diff changeset
3111 void MacroAssembler::leave() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3112 movl(rsp, rbp);
a61af66fc99e Initial load
duke
parents:
diff changeset
3113 popl(rbp);
a61af66fc99e Initial load
duke
parents:
diff changeset
3114 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3115
a61af66fc99e Initial load
duke
parents:
diff changeset
3116 void MacroAssembler::set_last_Java_frame(Register java_thread,
a61af66fc99e Initial load
duke
parents:
diff changeset
3117 Register last_java_sp,
a61af66fc99e Initial load
duke
parents:
diff changeset
3118 Register last_java_fp,
a61af66fc99e Initial load
duke
parents:
diff changeset
3119 address last_java_pc) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3120 // determine java_thread register
a61af66fc99e Initial load
duke
parents:
diff changeset
3121 if (!java_thread->is_valid()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3122 java_thread = rdi;
a61af66fc99e Initial load
duke
parents:
diff changeset
3123 get_thread(java_thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
3124 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3125 // determine last_java_sp register
a61af66fc99e Initial load
duke
parents:
diff changeset
3126 if (!last_java_sp->is_valid()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3127 last_java_sp = rsp;
a61af66fc99e Initial load
duke
parents:
diff changeset
3128 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3129
a61af66fc99e Initial load
duke
parents:
diff changeset
3130 // last_java_fp is optional
a61af66fc99e Initial load
duke
parents:
diff changeset
3131
a61af66fc99e Initial load
duke
parents:
diff changeset
3132 if (last_java_fp->is_valid()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3133 movl(Address(java_thread, JavaThread::last_Java_fp_offset()), last_java_fp);
a61af66fc99e Initial load
duke
parents:
diff changeset
3134 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3135
a61af66fc99e Initial load
duke
parents:
diff changeset
3136 // last_java_pc is optional
a61af66fc99e Initial load
duke
parents:
diff changeset
3137
a61af66fc99e Initial load
duke
parents:
diff changeset
3138 if (last_java_pc != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3139 lea(Address(java_thread,
a61af66fc99e Initial load
duke
parents:
diff changeset
3140 JavaThread::frame_anchor_offset() + JavaFrameAnchor::last_Java_pc_offset()),
a61af66fc99e Initial load
duke
parents:
diff changeset
3141 InternalAddress(last_java_pc));
a61af66fc99e Initial load
duke
parents:
diff changeset
3142
a61af66fc99e Initial load
duke
parents:
diff changeset
3143 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3144 movl(Address(java_thread, JavaThread::last_Java_sp_offset()), last_java_sp);
a61af66fc99e Initial load
duke
parents:
diff changeset
3145 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3146
a61af66fc99e Initial load
duke
parents:
diff changeset
3147 void MacroAssembler::reset_last_Java_frame(Register java_thread, bool clear_fp, bool clear_pc) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3148 // determine java_thread register
a61af66fc99e Initial load
duke
parents:
diff changeset
3149 if (!java_thread->is_valid()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3150 java_thread = rdi;
a61af66fc99e Initial load
duke
parents:
diff changeset
3151 get_thread(java_thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
3152 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3153 // we must set sp to zero to clear frame
a61af66fc99e Initial load
duke
parents:
diff changeset
3154 movl(Address(java_thread, JavaThread::last_Java_sp_offset()), 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
3155 if (clear_fp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3156 movl(Address(java_thread, JavaThread::last_Java_fp_offset()), 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
3157 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3158
a61af66fc99e Initial load
duke
parents:
diff changeset
3159 if (clear_pc)
a61af66fc99e Initial load
duke
parents:
diff changeset
3160 movl(Address(java_thread, JavaThread::last_Java_pc_offset()), 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
3161
a61af66fc99e Initial load
duke
parents:
diff changeset
3162 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3163
a61af66fc99e Initial load
duke
parents:
diff changeset
3164
a61af66fc99e Initial load
duke
parents:
diff changeset
3165
a61af66fc99e Initial load
duke
parents:
diff changeset
3166 // Implementation of call_VM versions
a61af66fc99e Initial load
duke
parents:
diff changeset
3167
a61af66fc99e Initial load
duke
parents:
diff changeset
3168 void MacroAssembler::call_VM_leaf_base(
a61af66fc99e Initial load
duke
parents:
diff changeset
3169 address entry_point,
a61af66fc99e Initial load
duke
parents:
diff changeset
3170 int number_of_arguments
a61af66fc99e Initial load
duke
parents:
diff changeset
3171 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3172 call(RuntimeAddress(entry_point));
a61af66fc99e Initial load
duke
parents:
diff changeset
3173 increment(rsp, number_of_arguments * wordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
3174 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3175
a61af66fc99e Initial load
duke
parents:
diff changeset
3176
a61af66fc99e Initial load
duke
parents:
diff changeset
3177 void MacroAssembler::call_VM_base(
a61af66fc99e Initial load
duke
parents:
diff changeset
3178 Register oop_result,
a61af66fc99e Initial load
duke
parents:
diff changeset
3179 Register java_thread,
a61af66fc99e Initial load
duke
parents:
diff changeset
3180 Register last_java_sp,
a61af66fc99e Initial load
duke
parents:
diff changeset
3181 address entry_point,
a61af66fc99e Initial load
duke
parents:
diff changeset
3182 int number_of_arguments,
a61af66fc99e Initial load
duke
parents:
diff changeset
3183 bool check_exceptions
a61af66fc99e Initial load
duke
parents:
diff changeset
3184 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3185 // determine java_thread register
a61af66fc99e Initial load
duke
parents:
diff changeset
3186 if (!java_thread->is_valid()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3187 java_thread = rdi;
a61af66fc99e Initial load
duke
parents:
diff changeset
3188 get_thread(java_thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
3189 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3190 // determine last_java_sp register
a61af66fc99e Initial load
duke
parents:
diff changeset
3191 if (!last_java_sp->is_valid()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3192 last_java_sp = rsp;
a61af66fc99e Initial load
duke
parents:
diff changeset
3193 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3194 // debugging support
a61af66fc99e Initial load
duke
parents:
diff changeset
3195 assert(number_of_arguments >= 0 , "cannot have negative number of arguments");
a61af66fc99e Initial load
duke
parents:
diff changeset
3196 assert(java_thread != oop_result , "cannot use the same register for java_thread & oop_result");
a61af66fc99e Initial load
duke
parents:
diff changeset
3197 assert(java_thread != last_java_sp, "cannot use the same register for java_thread & last_java_sp");
a61af66fc99e Initial load
duke
parents:
diff changeset
3198 // push java thread (becomes first argument of C function)
a61af66fc99e Initial load
duke
parents:
diff changeset
3199 pushl(java_thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
3200 // set last Java frame before call
a61af66fc99e Initial load
duke
parents:
diff changeset
3201 assert(last_java_sp != rbp, "this code doesn't work for last_java_sp == rbp, which currently can't portably work anyway since C2 doesn't save rbp,");
a61af66fc99e Initial load
duke
parents:
diff changeset
3202 // Only interpreter should have to set fp
a61af66fc99e Initial load
duke
parents:
diff changeset
3203 set_last_Java_frame(java_thread, last_java_sp, rbp, NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
3204 // do the call
a61af66fc99e Initial load
duke
parents:
diff changeset
3205 call(RuntimeAddress(entry_point));
a61af66fc99e Initial load
duke
parents:
diff changeset
3206 // restore the thread (cannot use the pushed argument since arguments
a61af66fc99e Initial load
duke
parents:
diff changeset
3207 // may be overwritten by C code generated by an optimizing compiler);
a61af66fc99e Initial load
duke
parents:
diff changeset
3208 // however can use the register value directly if it is callee saved.
a61af66fc99e Initial load
duke
parents:
diff changeset
3209 if (java_thread == rdi || java_thread == rsi) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3210 // rdi & rsi are callee saved -> nothing to do
a61af66fc99e Initial load
duke
parents:
diff changeset
3211 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
3212 guarantee(java_thread != rax, "change this code");
a61af66fc99e Initial load
duke
parents:
diff changeset
3213 pushl(rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
3214 { Label L;
a61af66fc99e Initial load
duke
parents:
diff changeset
3215 get_thread(rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
3216 cmpl(java_thread, rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
3217 jcc(Assembler::equal, L);
a61af66fc99e Initial load
duke
parents:
diff changeset
3218 stop("MacroAssembler::call_VM_base: rdi not callee saved?");
a61af66fc99e Initial load
duke
parents:
diff changeset
3219 bind(L);
a61af66fc99e Initial load
duke
parents:
diff changeset
3220 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3221 popl(rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
3222 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
3223 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3224 get_thread(java_thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
3225 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3226 // reset last Java frame
a61af66fc99e Initial load
duke
parents:
diff changeset
3227 // Only interpreter should have to clear fp
a61af66fc99e Initial load
duke
parents:
diff changeset
3228 reset_last_Java_frame(java_thread, true, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
3229 // discard thread and arguments
a61af66fc99e Initial load
duke
parents:
diff changeset
3230 addl(rsp, (1 + number_of_arguments)*wordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
3231
a61af66fc99e Initial load
duke
parents:
diff changeset
3232 #ifndef CC_INTERP
a61af66fc99e Initial load
duke
parents:
diff changeset
3233 // C++ interp handles this in the interpreter
a61af66fc99e Initial load
duke
parents:
diff changeset
3234 check_and_handle_popframe(java_thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
3235 check_and_handle_earlyret(java_thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
3236 #endif /* CC_INTERP */
a61af66fc99e Initial load
duke
parents:
diff changeset
3237
a61af66fc99e Initial load
duke
parents:
diff changeset
3238 if (check_exceptions) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3239 // check for pending exceptions (java_thread is set upon return)
a61af66fc99e Initial load
duke
parents:
diff changeset
3240 cmpl(Address(java_thread, Thread::pending_exception_offset()), NULL_WORD);
a61af66fc99e Initial load
duke
parents:
diff changeset
3241 jump_cc(Assembler::notEqual,
a61af66fc99e Initial load
duke
parents:
diff changeset
3242 RuntimeAddress(StubRoutines::forward_exception_entry()));
a61af66fc99e Initial load
duke
parents:
diff changeset
3243 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3244
a61af66fc99e Initial load
duke
parents:
diff changeset
3245 // get oop result if there is one and reset the value in the thread
a61af66fc99e Initial load
duke
parents:
diff changeset
3246 if (oop_result->is_valid()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3247 movl(oop_result, Address(java_thread, JavaThread::vm_result_offset()));
a61af66fc99e Initial load
duke
parents:
diff changeset
3248 movl(Address(java_thread, JavaThread::vm_result_offset()), NULL_WORD);
a61af66fc99e Initial load
duke
parents:
diff changeset
3249 verify_oop(oop_result);
a61af66fc99e Initial load
duke
parents:
diff changeset
3250 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3251 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3252
a61af66fc99e Initial load
duke
parents:
diff changeset
3253
a61af66fc99e Initial load
duke
parents:
diff changeset
3254 void MacroAssembler::check_and_handle_popframe(Register java_thread) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3255 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3256
a61af66fc99e Initial load
duke
parents:
diff changeset
3257 void MacroAssembler::check_and_handle_earlyret(Register java_thread) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3258 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3259
a61af66fc99e Initial load
duke
parents:
diff changeset
3260 void MacroAssembler::call_VM_helper(Register oop_result, address entry_point, int number_of_arguments, bool check_exceptions) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3261 leal(rax, Address(rsp, (1 + number_of_arguments) * wordSize));
a61af66fc99e Initial load
duke
parents:
diff changeset
3262 call_VM_base(oop_result, noreg, rax, entry_point, number_of_arguments, check_exceptions);
a61af66fc99e Initial load
duke
parents:
diff changeset
3263 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3264
a61af66fc99e Initial load
duke
parents:
diff changeset
3265
a61af66fc99e Initial load
duke
parents:
diff changeset
3266 void MacroAssembler::call_VM(Register oop_result, address entry_point, bool check_exceptions) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3267 Label C, E;
a61af66fc99e Initial load
duke
parents:
diff changeset
3268 call(C, relocInfo::none);
a61af66fc99e Initial load
duke
parents:
diff changeset
3269 jmp(E);
a61af66fc99e Initial load
duke
parents:
diff changeset
3270
a61af66fc99e Initial load
duke
parents:
diff changeset
3271 bind(C);
a61af66fc99e Initial load
duke
parents:
diff changeset
3272 call_VM_helper(oop_result, entry_point, 0, check_exceptions);
a61af66fc99e Initial load
duke
parents:
diff changeset
3273 ret(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
3274
a61af66fc99e Initial load
duke
parents:
diff changeset
3275 bind(E);
a61af66fc99e Initial load
duke
parents:
diff changeset
3276 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3277
a61af66fc99e Initial load
duke
parents:
diff changeset
3278
a61af66fc99e Initial load
duke
parents:
diff changeset
3279 void MacroAssembler::call_VM(Register oop_result, address entry_point, Register arg_1, bool check_exceptions) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3280 Label C, E;
a61af66fc99e Initial load
duke
parents:
diff changeset
3281 call(C, relocInfo::none);
a61af66fc99e Initial load
duke
parents:
diff changeset
3282 jmp(E);
a61af66fc99e Initial load
duke
parents:
diff changeset
3283
a61af66fc99e Initial load
duke
parents:
diff changeset
3284 bind(C);
a61af66fc99e Initial load
duke
parents:
diff changeset
3285 pushl(arg_1);
a61af66fc99e Initial load
duke
parents:
diff changeset
3286 call_VM_helper(oop_result, entry_point, 1, check_exceptions);
a61af66fc99e Initial load
duke
parents:
diff changeset
3287 ret(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
3288
a61af66fc99e Initial load
duke
parents:
diff changeset
3289 bind(E);
a61af66fc99e Initial load
duke
parents:
diff changeset
3290 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3291
a61af66fc99e Initial load
duke
parents:
diff changeset
3292
a61af66fc99e Initial load
duke
parents:
diff changeset
3293 void MacroAssembler::call_VM(Register oop_result, address entry_point, Register arg_1, Register arg_2, bool check_exceptions) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3294 Label C, E;
a61af66fc99e Initial load
duke
parents:
diff changeset
3295 call(C, relocInfo::none);
a61af66fc99e Initial load
duke
parents:
diff changeset
3296 jmp(E);
a61af66fc99e Initial load
duke
parents:
diff changeset
3297
a61af66fc99e Initial load
duke
parents:
diff changeset
3298 bind(C);
a61af66fc99e Initial load
duke
parents:
diff changeset
3299 pushl(arg_2);
a61af66fc99e Initial load
duke
parents:
diff changeset
3300 pushl(arg_1);
a61af66fc99e Initial load
duke
parents:
diff changeset
3301 call_VM_helper(oop_result, entry_point, 2, check_exceptions);
a61af66fc99e Initial load
duke
parents:
diff changeset
3302 ret(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
3303
a61af66fc99e Initial load
duke
parents:
diff changeset
3304 bind(E);
a61af66fc99e Initial load
duke
parents:
diff changeset
3305 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3306
a61af66fc99e Initial load
duke
parents:
diff changeset
3307
a61af66fc99e Initial load
duke
parents:
diff changeset
3308 void MacroAssembler::call_VM(Register oop_result, address entry_point, Register arg_1, Register arg_2, Register arg_3, bool check_exceptions) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3309 Label C, E;
a61af66fc99e Initial load
duke
parents:
diff changeset
3310 call(C, relocInfo::none);
a61af66fc99e Initial load
duke
parents:
diff changeset
3311 jmp(E);
a61af66fc99e Initial load
duke
parents:
diff changeset
3312
a61af66fc99e Initial load
duke
parents:
diff changeset
3313 bind(C);
a61af66fc99e Initial load
duke
parents:
diff changeset
3314 pushl(arg_3);
a61af66fc99e Initial load
duke
parents:
diff changeset
3315 pushl(arg_2);
a61af66fc99e Initial load
duke
parents:
diff changeset
3316 pushl(arg_1);
a61af66fc99e Initial load
duke
parents:
diff changeset
3317 call_VM_helper(oop_result, entry_point, 3, check_exceptions);
a61af66fc99e Initial load
duke
parents:
diff changeset
3318 ret(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
3319
a61af66fc99e Initial load
duke
parents:
diff changeset
3320 bind(E);
a61af66fc99e Initial load
duke
parents:
diff changeset
3321 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3322
a61af66fc99e Initial load
duke
parents:
diff changeset
3323
a61af66fc99e Initial load
duke
parents:
diff changeset
3324 void MacroAssembler::call_VM(Register oop_result, Register last_java_sp, address entry_point, int number_of_arguments, bool check_exceptions) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3325 call_VM_base(oop_result, noreg, last_java_sp, entry_point, number_of_arguments, check_exceptions);
a61af66fc99e Initial load
duke
parents:
diff changeset
3326 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3327
a61af66fc99e Initial load
duke
parents:
diff changeset
3328
a61af66fc99e Initial load
duke
parents:
diff changeset
3329 void MacroAssembler::call_VM(Register oop_result, Register last_java_sp, address entry_point, Register arg_1, bool check_exceptions) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3330 pushl(arg_1);
a61af66fc99e Initial load
duke
parents:
diff changeset
3331 call_VM(oop_result, last_java_sp, entry_point, 1, check_exceptions);
a61af66fc99e Initial load
duke
parents:
diff changeset
3332 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3333
a61af66fc99e Initial load
duke
parents:
diff changeset
3334
a61af66fc99e Initial load
duke
parents:
diff changeset
3335 void MacroAssembler::call_VM(Register oop_result, Register last_java_sp, address entry_point, Register arg_1, Register arg_2, bool check_exceptions) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3336 pushl(arg_2);
a61af66fc99e Initial load
duke
parents:
diff changeset
3337 pushl(arg_1);
a61af66fc99e Initial load
duke
parents:
diff changeset
3338 call_VM(oop_result, last_java_sp, entry_point, 2, check_exceptions);
a61af66fc99e Initial load
duke
parents:
diff changeset
3339 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3340
a61af66fc99e Initial load
duke
parents:
diff changeset
3341
a61af66fc99e Initial load
duke
parents:
diff changeset
3342 void MacroAssembler::call_VM(Register oop_result, Register last_java_sp, address entry_point, Register arg_1, Register arg_2, Register arg_3, bool check_exceptions) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3343 pushl(arg_3);
a61af66fc99e Initial load
duke
parents:
diff changeset
3344 pushl(arg_2);
a61af66fc99e Initial load
duke
parents:
diff changeset
3345 pushl(arg_1);
a61af66fc99e Initial load
duke
parents:
diff changeset
3346 call_VM(oop_result, last_java_sp, entry_point, 3, check_exceptions);
a61af66fc99e Initial load
duke
parents:
diff changeset
3347 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3348
a61af66fc99e Initial load
duke
parents:
diff changeset
3349
a61af66fc99e Initial load
duke
parents:
diff changeset
3350 void MacroAssembler::call_VM_leaf(address entry_point, int number_of_arguments) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3351 call_VM_leaf_base(entry_point, number_of_arguments);
a61af66fc99e Initial load
duke
parents:
diff changeset
3352 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3353
a61af66fc99e Initial load
duke
parents:
diff changeset
3354
a61af66fc99e Initial load
duke
parents:
diff changeset
3355 void MacroAssembler::call_VM_leaf(address entry_point, Register arg_1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3356 pushl(arg_1);
a61af66fc99e Initial load
duke
parents:
diff changeset
3357 call_VM_leaf(entry_point, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
3358 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3359
a61af66fc99e Initial load
duke
parents:
diff changeset
3360
a61af66fc99e Initial load
duke
parents:
diff changeset
3361 void MacroAssembler::call_VM_leaf(address entry_point, Register arg_1, Register arg_2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3362 pushl(arg_2);
a61af66fc99e Initial load
duke
parents:
diff changeset
3363 pushl(arg_1);
a61af66fc99e Initial load
duke
parents:
diff changeset
3364 call_VM_leaf(entry_point, 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
3365 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3366
a61af66fc99e Initial load
duke
parents:
diff changeset
3367
a61af66fc99e Initial load
duke
parents:
diff changeset
3368 void MacroAssembler::call_VM_leaf(address entry_point, Register arg_1, Register arg_2, Register arg_3) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3369 pushl(arg_3);
a61af66fc99e Initial load
duke
parents:
diff changeset
3370 pushl(arg_2);
a61af66fc99e Initial load
duke
parents:
diff changeset
3371 pushl(arg_1);
a61af66fc99e Initial load
duke
parents:
diff changeset
3372 call_VM_leaf(entry_point, 3);
a61af66fc99e Initial load
duke
parents:
diff changeset
3373 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3374
a61af66fc99e Initial load
duke
parents:
diff changeset
3375
a61af66fc99e Initial load
duke
parents:
diff changeset
3376 // Calls to C land
a61af66fc99e Initial load
duke
parents:
diff changeset
3377 //
a61af66fc99e Initial load
duke
parents:
diff changeset
3378 // When entering C land, the rbp, & rsp of the last Java frame have to be recorded
a61af66fc99e Initial load
duke
parents:
diff changeset
3379 // in the (thread-local) JavaThread object. When leaving C land, the last Java fp
a61af66fc99e Initial load
duke
parents:
diff changeset
3380 // has to be reset to 0. This is required to allow proper stack traversal.
a61af66fc99e Initial load
duke
parents:
diff changeset
3381
a61af66fc99e Initial load
duke
parents:
diff changeset
3382 void MacroAssembler::store_check(Register obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3383 // Does a store check for the oop in register obj. The content of
a61af66fc99e Initial load
duke
parents:
diff changeset
3384 // register obj is destroyed afterwards.
a61af66fc99e Initial load
duke
parents:
diff changeset
3385 store_check_part_1(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
3386 store_check_part_2(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
3387 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3388
a61af66fc99e Initial load
duke
parents:
diff changeset
3389
a61af66fc99e Initial load
duke
parents:
diff changeset
3390 void MacroAssembler::store_check(Register obj, Address dst) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3391 store_check(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
3392 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3393
a61af66fc99e Initial load
duke
parents:
diff changeset
3394
a61af66fc99e Initial load
duke
parents:
diff changeset
3395 // split the store check operation so that other instructions can be scheduled inbetween
a61af66fc99e Initial load
duke
parents:
diff changeset
3396 void MacroAssembler::store_check_part_1(Register obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3397 BarrierSet* bs = Universe::heap()->barrier_set();
a61af66fc99e Initial load
duke
parents:
diff changeset
3398 assert(bs->kind() == BarrierSet::CardTableModRef, "Wrong barrier set kind");
a61af66fc99e Initial load
duke
parents:
diff changeset
3399 shrl(obj, CardTableModRefBS::card_shift);
a61af66fc99e Initial load
duke
parents:
diff changeset
3400 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3401
a61af66fc99e Initial load
duke
parents:
diff changeset
3402
a61af66fc99e Initial load
duke
parents:
diff changeset
3403 void MacroAssembler::store_check_part_2(Register obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3404 BarrierSet* bs = Universe::heap()->barrier_set();
a61af66fc99e Initial load
duke
parents:
diff changeset
3405 assert(bs->kind() == BarrierSet::CardTableModRef, "Wrong barrier set kind");
a61af66fc99e Initial load
duke
parents:
diff changeset
3406 CardTableModRefBS* ct = (CardTableModRefBS*)bs;
a61af66fc99e Initial load
duke
parents:
diff changeset
3407 assert(sizeof(*ct->byte_map_base) == sizeof(jbyte), "adjust this code");
a61af66fc99e Initial load
duke
parents:
diff changeset
3408 ExternalAddress cardtable((address)ct->byte_map_base);
a61af66fc99e Initial load
duke
parents:
diff changeset
3409 Address index(noreg, obj, Address::times_1);
a61af66fc99e Initial load
duke
parents:
diff changeset
3410
a61af66fc99e Initial load
duke
parents:
diff changeset
3411 movb(as_Address(ArrayAddress(cardtable, index)), 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
3412 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3413
a61af66fc99e Initial load
duke
parents:
diff changeset
3414
a61af66fc99e Initial load
duke
parents:
diff changeset
3415 void MacroAssembler::c2bool(Register x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3416 // implements x == 0 ? 0 : 1
a61af66fc99e Initial load
duke
parents:
diff changeset
3417 // note: must only look at least-significant byte of x
a61af66fc99e Initial load
duke
parents:
diff changeset
3418 // since C-style booleans are stored in one byte
a61af66fc99e Initial load
duke
parents:
diff changeset
3419 // only! (was bug)
a61af66fc99e Initial load
duke
parents:
diff changeset
3420 andl(x, 0xFF);
a61af66fc99e Initial load
duke
parents:
diff changeset
3421 setb(Assembler::notZero, x);
a61af66fc99e Initial load
duke
parents:
diff changeset
3422 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3423
a61af66fc99e Initial load
duke
parents:
diff changeset
3424
a61af66fc99e Initial load
duke
parents:
diff changeset
3425 int MacroAssembler::corrected_idivl(Register reg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3426 // Full implementation of Java idiv and irem; checks for
a61af66fc99e Initial load
duke
parents:
diff changeset
3427 // special case as described in JVM spec., p.243 & p.271.
a61af66fc99e Initial load
duke
parents:
diff changeset
3428 // The function returns the (pc) offset of the idivl
a61af66fc99e Initial load
duke
parents:
diff changeset
3429 // instruction - may be needed for implicit exceptions.
a61af66fc99e Initial load
duke
parents:
diff changeset
3430 //
a61af66fc99e Initial load
duke
parents:
diff changeset
3431 // normal case special case
a61af66fc99e Initial load
duke
parents:
diff changeset
3432 //
a61af66fc99e Initial load
duke
parents:
diff changeset
3433 // input : rax,: dividend min_int
a61af66fc99e Initial load
duke
parents:
diff changeset
3434 // reg: divisor (may not be rax,/rdx) -1
a61af66fc99e Initial load
duke
parents:
diff changeset
3435 //
a61af66fc99e Initial load
duke
parents:
diff changeset
3436 // output: rax,: quotient (= rax, idiv reg) min_int
a61af66fc99e Initial load
duke
parents:
diff changeset
3437 // rdx: remainder (= rax, irem reg) 0
a61af66fc99e Initial load
duke
parents:
diff changeset
3438 assert(reg != rax && reg != rdx, "reg cannot be rax, or rdx register");
a61af66fc99e Initial load
duke
parents:
diff changeset
3439 const int min_int = 0x80000000;
a61af66fc99e Initial load
duke
parents:
diff changeset
3440 Label normal_case, special_case;
a61af66fc99e Initial load
duke
parents:
diff changeset
3441
a61af66fc99e Initial load
duke
parents:
diff changeset
3442 // check for special case
a61af66fc99e Initial load
duke
parents:
diff changeset
3443 cmpl(rax, min_int);
a61af66fc99e Initial load
duke
parents:
diff changeset
3444 jcc(Assembler::notEqual, normal_case);
a61af66fc99e Initial load
duke
parents:
diff changeset
3445 xorl(rdx, rdx); // prepare rdx for possible special case (where remainder = 0)
a61af66fc99e Initial load
duke
parents:
diff changeset
3446 cmpl(reg, -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
3447 jcc(Assembler::equal, special_case);
a61af66fc99e Initial load
duke
parents:
diff changeset
3448
a61af66fc99e Initial load
duke
parents:
diff changeset
3449 // handle normal case
a61af66fc99e Initial load
duke
parents:
diff changeset
3450 bind(normal_case);
a61af66fc99e Initial load
duke
parents:
diff changeset
3451 cdql();
a61af66fc99e Initial load
duke
parents:
diff changeset
3452 int idivl_offset = offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
3453 idivl(reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
3454
a61af66fc99e Initial load
duke
parents:
diff changeset
3455 // normal and special case exit
a61af66fc99e Initial load
duke
parents:
diff changeset
3456 bind(special_case);
a61af66fc99e Initial load
duke
parents:
diff changeset
3457
a61af66fc99e Initial load
duke
parents:
diff changeset
3458 return idivl_offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
3459 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3460
a61af66fc99e Initial load
duke
parents:
diff changeset
3461
a61af66fc99e Initial load
duke
parents:
diff changeset
3462 void MacroAssembler::lneg(Register hi, Register lo) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3463 negl(lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
3464 adcl(hi, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
3465 negl(hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
3466 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3467
a61af66fc99e Initial load
duke
parents:
diff changeset
3468
a61af66fc99e Initial load
duke
parents:
diff changeset
3469 void MacroAssembler::lmul(int x_rsp_offset, int y_rsp_offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3470 // Multiplication of two Java long values stored on the stack
a61af66fc99e Initial load
duke
parents:
diff changeset
3471 // as illustrated below. Result is in rdx:rax.
a61af66fc99e Initial load
duke
parents:
diff changeset
3472 //
a61af66fc99e Initial load
duke
parents:
diff changeset
3473 // rsp ---> [ ?? ] \ \
a61af66fc99e Initial load
duke
parents:
diff changeset
3474 // .... | y_rsp_offset |
a61af66fc99e Initial load
duke
parents:
diff changeset
3475 // [ y_lo ] / (in bytes) | x_rsp_offset
a61af66fc99e Initial load
duke
parents:
diff changeset
3476 // [ y_hi ] | (in bytes)
a61af66fc99e Initial load
duke
parents:
diff changeset
3477 // .... |
a61af66fc99e Initial load
duke
parents:
diff changeset
3478 // [ x_lo ] /
a61af66fc99e Initial load
duke
parents:
diff changeset
3479 // [ x_hi ]
a61af66fc99e Initial load
duke
parents:
diff changeset
3480 // ....
a61af66fc99e Initial load
duke
parents:
diff changeset
3481 //
a61af66fc99e Initial load
duke
parents:
diff changeset
3482 // Basic idea: lo(result) = lo(x_lo * y_lo)
a61af66fc99e Initial load
duke
parents:
diff changeset
3483 // hi(result) = hi(x_lo * y_lo) + lo(x_hi * y_lo) + lo(x_lo * y_hi)
a61af66fc99e Initial load
duke
parents:
diff changeset
3484 Address x_hi(rsp, x_rsp_offset + wordSize); Address x_lo(rsp, x_rsp_offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3485 Address y_hi(rsp, y_rsp_offset + wordSize); Address y_lo(rsp, y_rsp_offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3486 Label quick;
a61af66fc99e Initial load
duke
parents:
diff changeset
3487 // load x_hi, y_hi and check if quick
a61af66fc99e Initial load
duke
parents:
diff changeset
3488 // multiplication is possible
a61af66fc99e Initial load
duke
parents:
diff changeset
3489 movl(rbx, x_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
3490 movl(rcx, y_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
3491 movl(rax, rbx);
a61af66fc99e Initial load
duke
parents:
diff changeset
3492 orl(rbx, rcx); // rbx, = 0 <=> x_hi = 0 and y_hi = 0
a61af66fc99e Initial load
duke
parents:
diff changeset
3493 jcc(Assembler::zero, quick); // if rbx, = 0 do quick multiply
a61af66fc99e Initial load
duke
parents:
diff changeset
3494 // do full multiplication
a61af66fc99e Initial load
duke
parents:
diff changeset
3495 // 1st step
a61af66fc99e Initial load
duke
parents:
diff changeset
3496 mull(y_lo); // x_hi * y_lo
a61af66fc99e Initial load
duke
parents:
diff changeset
3497 movl(rbx, rax); // save lo(x_hi * y_lo) in rbx,
a61af66fc99e Initial load
duke
parents:
diff changeset
3498 // 2nd step
a61af66fc99e Initial load
duke
parents:
diff changeset
3499 movl(rax, x_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
3500 mull(rcx); // x_lo * y_hi
a61af66fc99e Initial load
duke
parents:
diff changeset
3501 addl(rbx, rax); // add lo(x_lo * y_hi) to rbx,
a61af66fc99e Initial load
duke
parents:
diff changeset
3502 // 3rd step
a61af66fc99e Initial load
duke
parents:
diff changeset
3503 bind(quick); // note: rbx, = 0 if quick multiply!
a61af66fc99e Initial load
duke
parents:
diff changeset
3504 movl(rax, x_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
3505 mull(y_lo); // x_lo * y_lo
a61af66fc99e Initial load
duke
parents:
diff changeset
3506 addl(rdx, rbx); // correct hi(x_lo * y_lo)
a61af66fc99e Initial load
duke
parents:
diff changeset
3507 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3508
a61af66fc99e Initial load
duke
parents:
diff changeset
3509
a61af66fc99e Initial load
duke
parents:
diff changeset
3510 void MacroAssembler::lshl(Register hi, Register lo) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3511 // Java shift left long support (semantics as described in JVM spec., p.305)
a61af66fc99e Initial load
duke
parents:
diff changeset
3512 // (basic idea for shift counts s >= n: x << s == (x << n) << (s - n))
a61af66fc99e Initial load
duke
parents:
diff changeset
3513 // shift value is in rcx !
a61af66fc99e Initial load
duke
parents:
diff changeset
3514 assert(hi != rcx, "must not use rcx");
a61af66fc99e Initial load
duke
parents:
diff changeset
3515 assert(lo != rcx, "must not use rcx");
a61af66fc99e Initial load
duke
parents:
diff changeset
3516 const Register s = rcx; // shift count
a61af66fc99e Initial load
duke
parents:
diff changeset
3517 const int n = BitsPerWord;
a61af66fc99e Initial load
duke
parents:
diff changeset
3518 Label L;
a61af66fc99e Initial load
duke
parents:
diff changeset
3519 andl(s, 0x3f); // s := s & 0x3f (s < 0x40)
a61af66fc99e Initial load
duke
parents:
diff changeset
3520 cmpl(s, n); // if (s < n)
a61af66fc99e Initial load
duke
parents:
diff changeset
3521 jcc(Assembler::less, L); // else (s >= n)
a61af66fc99e Initial load
duke
parents:
diff changeset
3522 movl(hi, lo); // x := x << n
a61af66fc99e Initial load
duke
parents:
diff changeset
3523 xorl(lo, lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
3524 // Note: subl(s, n) is not needed since the Intel shift instructions work rcx mod n!
a61af66fc99e Initial load
duke
parents:
diff changeset
3525 bind(L); // s (mod n) < n
a61af66fc99e Initial load
duke
parents:
diff changeset
3526 shldl(hi, lo); // x := x << s
a61af66fc99e Initial load
duke
parents:
diff changeset
3527 shll(lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
3528 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3529
a61af66fc99e Initial load
duke
parents:
diff changeset
3530
a61af66fc99e Initial load
duke
parents:
diff changeset
3531 void MacroAssembler::lshr(Register hi, Register lo, bool sign_extension) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3532 // Java shift right long support (semantics as described in JVM spec., p.306 & p.310)
a61af66fc99e Initial load
duke
parents:
diff changeset
3533 // (basic idea for shift counts s >= n: x >> s == (x >> n) >> (s - n))
a61af66fc99e Initial load
duke
parents:
diff changeset
3534 assert(hi != rcx, "must not use rcx");
a61af66fc99e Initial load
duke
parents:
diff changeset
3535 assert(lo != rcx, "must not use rcx");
a61af66fc99e Initial load
duke
parents:
diff changeset
3536 const Register s = rcx; // shift count
a61af66fc99e Initial load
duke
parents:
diff changeset
3537 const int n = BitsPerWord;
a61af66fc99e Initial load
duke
parents:
diff changeset
3538 Label L;
a61af66fc99e Initial load
duke
parents:
diff changeset
3539 andl(s, 0x3f); // s := s & 0x3f (s < 0x40)
a61af66fc99e Initial load
duke
parents:
diff changeset
3540 cmpl(s, n); // if (s < n)
a61af66fc99e Initial load
duke
parents:
diff changeset
3541 jcc(Assembler::less, L); // else (s >= n)
a61af66fc99e Initial load
duke
parents:
diff changeset
3542 movl(lo, hi); // x := x >> n
a61af66fc99e Initial load
duke
parents:
diff changeset
3543 if (sign_extension) sarl(hi, 31);
a61af66fc99e Initial load
duke
parents:
diff changeset
3544 else xorl(hi, hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
3545 // Note: subl(s, n) is not needed since the Intel shift instructions work rcx mod n!
a61af66fc99e Initial load
duke
parents:
diff changeset
3546 bind(L); // s (mod n) < n
a61af66fc99e Initial load
duke
parents:
diff changeset
3547 shrdl(lo, hi); // x := x >> s
a61af66fc99e Initial load
duke
parents:
diff changeset
3548 if (sign_extension) sarl(hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
3549 else shrl(hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
3550 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3551
a61af66fc99e Initial load
duke
parents:
diff changeset
3552
a61af66fc99e Initial load
duke
parents:
diff changeset
3553 // Note: y_lo will be destroyed
a61af66fc99e Initial load
duke
parents:
diff changeset
3554 void MacroAssembler::lcmp2int(Register x_hi, Register x_lo, Register y_hi, Register y_lo) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3555 // Long compare for Java (semantics as described in JVM spec.)
a61af66fc99e Initial load
duke
parents:
diff changeset
3556 Label high, low, done;
a61af66fc99e Initial load
duke
parents:
diff changeset
3557
a61af66fc99e Initial load
duke
parents:
diff changeset
3558 cmpl(x_hi, y_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
3559 jcc(Assembler::less, low);
a61af66fc99e Initial load
duke
parents:
diff changeset
3560 jcc(Assembler::greater, high);
a61af66fc99e Initial load
duke
parents:
diff changeset
3561 // x_hi is the return register
a61af66fc99e Initial load
duke
parents:
diff changeset
3562 xorl(x_hi, x_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
3563 cmpl(x_lo, y_lo);
a61af66fc99e Initial load
duke
parents:
diff changeset
3564 jcc(Assembler::below, low);
a61af66fc99e Initial load
duke
parents:
diff changeset
3565 jcc(Assembler::equal, done);
a61af66fc99e Initial load
duke
parents:
diff changeset
3566
a61af66fc99e Initial load
duke
parents:
diff changeset
3567 bind(high);
a61af66fc99e Initial load
duke
parents:
diff changeset
3568 xorl(x_hi, x_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
3569 increment(x_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
3570 jmp(done);
a61af66fc99e Initial load
duke
parents:
diff changeset
3571
a61af66fc99e Initial load
duke
parents:
diff changeset
3572 bind(low);
a61af66fc99e Initial load
duke
parents:
diff changeset
3573 xorl(x_hi, x_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
3574 decrement(x_hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
3575
a61af66fc99e Initial load
duke
parents:
diff changeset
3576 bind(done);
a61af66fc99e Initial load
duke
parents:
diff changeset
3577 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3578
a61af66fc99e Initial load
duke
parents:
diff changeset
3579
a61af66fc99e Initial load
duke
parents:
diff changeset
3580 void MacroAssembler::save_rax(Register tmp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3581 if (tmp == noreg) pushl(rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
3582 else if (tmp != rax) movl(tmp, rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
3583 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3584
a61af66fc99e Initial load
duke
parents:
diff changeset
3585
a61af66fc99e Initial load
duke
parents:
diff changeset
3586 void MacroAssembler::restore_rax(Register tmp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3587 if (tmp == noreg) popl(rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
3588 else if (tmp != rax) movl(rax, tmp);
a61af66fc99e Initial load
duke
parents:
diff changeset
3589 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3590
a61af66fc99e Initial load
duke
parents:
diff changeset
3591
a61af66fc99e Initial load
duke
parents:
diff changeset
3592 void MacroAssembler::fremr(Register tmp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3593 save_rax(tmp);
a61af66fc99e Initial load
duke
parents:
diff changeset
3594 { Label L;
a61af66fc99e Initial load
duke
parents:
diff changeset
3595 bind(L);
a61af66fc99e Initial load
duke
parents:
diff changeset
3596 fprem();
a61af66fc99e Initial load
duke
parents:
diff changeset
3597 fwait(); fnstsw_ax();
a61af66fc99e Initial load
duke
parents:
diff changeset
3598 sahf();
a61af66fc99e Initial load
duke
parents:
diff changeset
3599 jcc(Assembler::parity, L);
a61af66fc99e Initial load
duke
parents:
diff changeset
3600 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3601 restore_rax(tmp);
a61af66fc99e Initial load
duke
parents:
diff changeset
3602 // Result is in ST0.
a61af66fc99e Initial load
duke
parents:
diff changeset
3603 // Note: fxch & fpop to get rid of ST1
a61af66fc99e Initial load
duke
parents:
diff changeset
3604 // (otherwise FPU stack could overflow eventually)
a61af66fc99e Initial load
duke
parents:
diff changeset
3605 fxch(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
3606 fpop();
a61af66fc99e Initial load
duke
parents:
diff changeset
3607 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3608
a61af66fc99e Initial load
duke
parents:
diff changeset
3609
a61af66fc99e Initial load
duke
parents:
diff changeset
3610 static const double pi_4 = 0.7853981633974483;
a61af66fc99e Initial load
duke
parents:
diff changeset
3611
a61af66fc99e Initial load
duke
parents:
diff changeset
3612 void MacroAssembler::trigfunc(char trig, int num_fpu_regs_in_use) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3613 // A hand-coded argument reduction for values in fabs(pi/4, pi/2)
a61af66fc99e Initial load
duke
parents:
diff changeset
3614 // was attempted in this code; unfortunately it appears that the
a61af66fc99e Initial load
duke
parents:
diff changeset
3615 // switch to 80-bit precision and back causes this to be
a61af66fc99e Initial load
duke
parents:
diff changeset
3616 // unprofitable compared with simply performing a runtime call if
a61af66fc99e Initial load
duke
parents:
diff changeset
3617 // the argument is out of the (-pi/4, pi/4) range.
a61af66fc99e Initial load
duke
parents:
diff changeset
3618
a61af66fc99e Initial load
duke
parents:
diff changeset
3619 Register tmp = noreg;
a61af66fc99e Initial load
duke
parents:
diff changeset
3620 if (!VM_Version::supports_cmov()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3621 // fcmp needs a temporary so preserve rbx,
a61af66fc99e Initial load
duke
parents:
diff changeset
3622 tmp = rbx;
a61af66fc99e Initial load
duke
parents:
diff changeset
3623 pushl(tmp);
a61af66fc99e Initial load
duke
parents:
diff changeset
3624 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3625
a61af66fc99e Initial load
duke
parents:
diff changeset
3626 Label slow_case, done;
a61af66fc99e Initial load
duke
parents:
diff changeset
3627
a61af66fc99e Initial load
duke
parents:
diff changeset
3628 // x ?<= pi/4
a61af66fc99e Initial load
duke
parents:
diff changeset
3629 fld_d(ExternalAddress((address)&pi_4));
a61af66fc99e Initial load
duke
parents:
diff changeset
3630 fld_s(1); // Stack: X PI/4 X
a61af66fc99e Initial load
duke
parents:
diff changeset
3631 fabs(); // Stack: |X| PI/4 X
a61af66fc99e Initial load
duke
parents:
diff changeset
3632 fcmp(tmp);
a61af66fc99e Initial load
duke
parents:
diff changeset
3633 jcc(Assembler::above, slow_case);
a61af66fc99e Initial load
duke
parents:
diff changeset
3634
a61af66fc99e Initial load
duke
parents:
diff changeset
3635 // fastest case: -pi/4 <= x <= pi/4
a61af66fc99e Initial load
duke
parents:
diff changeset
3636 switch(trig) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3637 case 's':
a61af66fc99e Initial load
duke
parents:
diff changeset
3638 fsin();
a61af66fc99e Initial load
duke
parents:
diff changeset
3639 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
3640 case 'c':
a61af66fc99e Initial load
duke
parents:
diff changeset
3641 fcos();
a61af66fc99e Initial load
duke
parents:
diff changeset
3642 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
3643 case 't':
a61af66fc99e Initial load
duke
parents:
diff changeset
3644 ftan();
a61af66fc99e Initial load
duke
parents:
diff changeset
3645 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
3646 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
3647 assert(false, "bad intrinsic");
a61af66fc99e Initial load
duke
parents:
diff changeset
3648 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
3649 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3650 jmp(done);
a61af66fc99e Initial load
duke
parents:
diff changeset
3651
a61af66fc99e Initial load
duke
parents:
diff changeset
3652 // slow case: runtime call
a61af66fc99e Initial load
duke
parents:
diff changeset
3653 bind(slow_case);
a61af66fc99e Initial load
duke
parents:
diff changeset
3654 // Preserve registers across runtime call
a61af66fc99e Initial load
duke
parents:
diff changeset
3655 pushad();
a61af66fc99e Initial load
duke
parents:
diff changeset
3656 int incoming_argument_and_return_value_offset = -1;
a61af66fc99e Initial load
duke
parents:
diff changeset
3657 if (num_fpu_regs_in_use > 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3658 // Must preserve all other FPU regs (could alternatively convert
a61af66fc99e Initial load
duke
parents:
diff changeset
3659 // SharedRuntime::dsin and dcos into assembly routines known not to trash
a61af66fc99e Initial load
duke
parents:
diff changeset
3660 // FPU state, but can not trust C compiler)
a61af66fc99e Initial load
duke
parents:
diff changeset
3661 NEEDS_CLEANUP;
a61af66fc99e Initial load
duke
parents:
diff changeset
3662 // NOTE that in this case we also push the incoming argument to
a61af66fc99e Initial load
duke
parents:
diff changeset
3663 // the stack and restore it later; we also use this stack slot to
a61af66fc99e Initial load
duke
parents:
diff changeset
3664 // hold the return value from dsin or dcos.
a61af66fc99e Initial load
duke
parents:
diff changeset
3665 for (int i = 0; i < num_fpu_regs_in_use; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3666 subl(rsp, wordSize*2);
a61af66fc99e Initial load
duke
parents:
diff changeset
3667 fstp_d(Address(rsp, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
3668 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3669 incoming_argument_and_return_value_offset = 2*wordSize*(num_fpu_regs_in_use-1);
a61af66fc99e Initial load
duke
parents:
diff changeset
3670 fld_d(Address(rsp, incoming_argument_and_return_value_offset));
a61af66fc99e Initial load
duke
parents:
diff changeset
3671 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3672 subl(rsp, wordSize*2);
a61af66fc99e Initial load
duke
parents:
diff changeset
3673 fstp_d(Address(rsp, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
3674 // NOTE: we must not use call_VM_leaf here because that requires a
a61af66fc99e Initial load
duke
parents:
diff changeset
3675 // complete interpreter frame in debug mode -- same bug as 4387334
a61af66fc99e Initial load
duke
parents:
diff changeset
3676 NEEDS_CLEANUP;
a61af66fc99e Initial load
duke
parents:
diff changeset
3677 // Need to add stack banging before this runtime call if it needs to
a61af66fc99e Initial load
duke
parents:
diff changeset
3678 // be taken; however, there is no generic stack banging routine at
a61af66fc99e Initial load
duke
parents:
diff changeset
3679 // the MacroAssembler level
a61af66fc99e Initial load
duke
parents:
diff changeset
3680 switch(trig) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3681 case 's':
a61af66fc99e Initial load
duke
parents:
diff changeset
3682 {
a61af66fc99e Initial load
duke
parents:
diff changeset
3683 call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dsin)));
a61af66fc99e Initial load
duke
parents:
diff changeset
3684 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3685 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
3686 case 'c':
a61af66fc99e Initial load
duke
parents:
diff changeset
3687 {
a61af66fc99e Initial load
duke
parents:
diff changeset
3688 call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dcos)));
a61af66fc99e Initial load
duke
parents:
diff changeset
3689 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3690 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
3691 case 't':
a61af66fc99e Initial load
duke
parents:
diff changeset
3692 {
a61af66fc99e Initial load
duke
parents:
diff changeset
3693 call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dtan)));
a61af66fc99e Initial load
duke
parents:
diff changeset
3694 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3695 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
3696 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
3697 assert(false, "bad intrinsic");
a61af66fc99e Initial load
duke
parents:
diff changeset
3698 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
3699 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3700 addl(rsp, wordSize * 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
3701 if (num_fpu_regs_in_use > 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3702 // Must save return value to stack and then restore entire FPU stack
a61af66fc99e Initial load
duke
parents:
diff changeset
3703 fstp_d(Address(rsp, incoming_argument_and_return_value_offset));
a61af66fc99e Initial load
duke
parents:
diff changeset
3704 for (int i = 0; i < num_fpu_regs_in_use; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3705 fld_d(Address(rsp, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
3706 addl(rsp, wordSize*2);
a61af66fc99e Initial load
duke
parents:
diff changeset
3707 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3708 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3709 popad();
a61af66fc99e Initial load
duke
parents:
diff changeset
3710
a61af66fc99e Initial load
duke
parents:
diff changeset
3711 // Come here with result in F-TOS
a61af66fc99e Initial load
duke
parents:
diff changeset
3712 bind(done);
a61af66fc99e Initial load
duke
parents:
diff changeset
3713
a61af66fc99e Initial load
duke
parents:
diff changeset
3714 if (tmp != noreg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3715 popl(tmp);
a61af66fc99e Initial load
duke
parents:
diff changeset
3716 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3717 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3718
a61af66fc99e Initial load
duke
parents:
diff changeset
3719 void MacroAssembler::jC2(Register tmp, Label& L) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3720 // set parity bit if FPU flag C2 is set (via rax)
a61af66fc99e Initial load
duke
parents:
diff changeset
3721 save_rax(tmp);
a61af66fc99e Initial load
duke
parents:
diff changeset
3722 fwait(); fnstsw_ax();
a61af66fc99e Initial load
duke
parents:
diff changeset
3723 sahf();
a61af66fc99e Initial load
duke
parents:
diff changeset
3724 restore_rax(tmp);
a61af66fc99e Initial load
duke
parents:
diff changeset
3725 // branch
a61af66fc99e Initial load
duke
parents:
diff changeset
3726 jcc(Assembler::parity, L);
a61af66fc99e Initial load
duke
parents:
diff changeset
3727 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3728
a61af66fc99e Initial load
duke
parents:
diff changeset
3729
a61af66fc99e Initial load
duke
parents:
diff changeset
3730 void MacroAssembler::jnC2(Register tmp, Label& L) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3731 // set parity bit if FPU flag C2 is set (via rax)
a61af66fc99e Initial load
duke
parents:
diff changeset
3732 save_rax(tmp);
a61af66fc99e Initial load
duke
parents:
diff changeset
3733 fwait(); fnstsw_ax();
a61af66fc99e Initial load
duke
parents:
diff changeset
3734 sahf();
a61af66fc99e Initial load
duke
parents:
diff changeset
3735 restore_rax(tmp);
a61af66fc99e Initial load
duke
parents:
diff changeset
3736 // branch
a61af66fc99e Initial load
duke
parents:
diff changeset
3737 jcc(Assembler::noParity, L);
a61af66fc99e Initial load
duke
parents:
diff changeset
3738 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3739
a61af66fc99e Initial load
duke
parents:
diff changeset
3740
a61af66fc99e Initial load
duke
parents:
diff changeset
3741 void MacroAssembler::fcmp(Register tmp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3742 fcmp(tmp, 1, true, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
3743 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3744
a61af66fc99e Initial load
duke
parents:
diff changeset
3745
a61af66fc99e Initial load
duke
parents:
diff changeset
3746 void MacroAssembler::fcmp(Register tmp, int index, bool pop_left, bool pop_right) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3747 assert(!pop_right || pop_left, "usage error");
a61af66fc99e Initial load
duke
parents:
diff changeset
3748 if (VM_Version::supports_cmov()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3749 assert(tmp == noreg, "unneeded temp");
a61af66fc99e Initial load
duke
parents:
diff changeset
3750 if (pop_left) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3751 fucomip(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
3752 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3753 fucomi(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
3754 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3755 if (pop_right) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3756 fpop();
a61af66fc99e Initial load
duke
parents:
diff changeset
3757 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3758 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3759 assert(tmp != noreg, "need temp");
a61af66fc99e Initial load
duke
parents:
diff changeset
3760 if (pop_left) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3761 if (pop_right) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3762 fcompp();
a61af66fc99e Initial load
duke
parents:
diff changeset
3763 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3764 fcomp(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
3765 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3766 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3767 fcom(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
3768 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3769 // convert FPU condition into eflags condition via rax,
a61af66fc99e Initial load
duke
parents:
diff changeset
3770 save_rax(tmp);
a61af66fc99e Initial load
duke
parents:
diff changeset
3771 fwait(); fnstsw_ax();
a61af66fc99e Initial load
duke
parents:
diff changeset
3772 sahf();
a61af66fc99e Initial load
duke
parents:
diff changeset
3773 restore_rax(tmp);
a61af66fc99e Initial load
duke
parents:
diff changeset
3774 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3775 // condition codes set as follows:
a61af66fc99e Initial load
duke
parents:
diff changeset
3776 //
a61af66fc99e Initial load
duke
parents:
diff changeset
3777 // CF (corresponds to C0) if x < y
a61af66fc99e Initial load
duke
parents:
diff changeset
3778 // PF (corresponds to C2) if unordered
a61af66fc99e Initial load
duke
parents:
diff changeset
3779 // ZF (corresponds to C3) if x = y
a61af66fc99e Initial load
duke
parents:
diff changeset
3780 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3781
a61af66fc99e Initial load
duke
parents:
diff changeset
3782
a61af66fc99e Initial load
duke
parents:
diff changeset
3783 void MacroAssembler::fcmp2int(Register dst, bool unordered_is_less) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3784 fcmp2int(dst, unordered_is_less, 1, true, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
3785 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3786
a61af66fc99e Initial load
duke
parents:
diff changeset
3787
a61af66fc99e Initial load
duke
parents:
diff changeset
3788 void MacroAssembler::fcmp2int(Register dst, bool unordered_is_less, int index, bool pop_left, bool pop_right) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3789 fcmp(VM_Version::supports_cmov() ? noreg : dst, index, pop_left, pop_right);
a61af66fc99e Initial load
duke
parents:
diff changeset
3790 Label L;
a61af66fc99e Initial load
duke
parents:
diff changeset
3791 if (unordered_is_less) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3792 movl(dst, -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
3793 jcc(Assembler::parity, L);
a61af66fc99e Initial load
duke
parents:
diff changeset
3794 jcc(Assembler::below , L);
a61af66fc99e Initial load
duke
parents:
diff changeset
3795 movl(dst, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
3796 jcc(Assembler::equal , L);
a61af66fc99e Initial load
duke
parents:
diff changeset
3797 increment(dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
3798 } else { // unordered is greater
a61af66fc99e Initial load
duke
parents:
diff changeset
3799 movl(dst, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
3800 jcc(Assembler::parity, L);
a61af66fc99e Initial load
duke
parents:
diff changeset
3801 jcc(Assembler::above , L);
a61af66fc99e Initial load
duke
parents:
diff changeset
3802 movl(dst, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
3803 jcc(Assembler::equal , L);
a61af66fc99e Initial load
duke
parents:
diff changeset
3804 decrement(dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
3805 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3806 bind(L);
a61af66fc99e Initial load
duke
parents:
diff changeset
3807 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3808
a61af66fc99e Initial load
duke
parents:
diff changeset
3809 void MacroAssembler::cmpss2int(XMMRegister opr1, XMMRegister opr2, Register dst, bool unordered_is_less) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3810 ucomiss(opr1, opr2);
a61af66fc99e Initial load
duke
parents:
diff changeset
3811
a61af66fc99e Initial load
duke
parents:
diff changeset
3812 Label L;
a61af66fc99e Initial load
duke
parents:
diff changeset
3813 if (unordered_is_less) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3814 movl(dst, -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
3815 jcc(Assembler::parity, L);
a61af66fc99e Initial load
duke
parents:
diff changeset
3816 jcc(Assembler::below , L);
a61af66fc99e Initial load
duke
parents:
diff changeset
3817 movl(dst, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
3818 jcc(Assembler::equal , L);
a61af66fc99e Initial load
duke
parents:
diff changeset
3819 increment(dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
3820 } else { // unordered is greater
a61af66fc99e Initial load
duke
parents:
diff changeset
3821 movl(dst, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
3822 jcc(Assembler::parity, L);
a61af66fc99e Initial load
duke
parents:
diff changeset
3823 jcc(Assembler::above , L);
a61af66fc99e Initial load
duke
parents:
diff changeset
3824 movl(dst, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
3825 jcc(Assembler::equal , L);
a61af66fc99e Initial load
duke
parents:
diff changeset
3826 decrement(dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
3827 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3828 bind(L);
a61af66fc99e Initial load
duke
parents:
diff changeset
3829 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3830
a61af66fc99e Initial load
duke
parents:
diff changeset
3831 void MacroAssembler::cmpsd2int(XMMRegister opr1, XMMRegister opr2, Register dst, bool unordered_is_less) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3832 ucomisd(opr1, opr2);
a61af66fc99e Initial load
duke
parents:
diff changeset
3833
a61af66fc99e Initial load
duke
parents:
diff changeset
3834 Label L;
a61af66fc99e Initial load
duke
parents:
diff changeset
3835 if (unordered_is_less) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3836 movl(dst, -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
3837 jcc(Assembler::parity, L);
a61af66fc99e Initial load
duke
parents:
diff changeset
3838 jcc(Assembler::below , L);
a61af66fc99e Initial load
duke
parents:
diff changeset
3839 movl(dst, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
3840 jcc(Assembler::equal , L);
a61af66fc99e Initial load
duke
parents:
diff changeset
3841 increment(dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
3842 } else { // unordered is greater
a61af66fc99e Initial load
duke
parents:
diff changeset
3843 movl(dst, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
3844 jcc(Assembler::parity, L);
a61af66fc99e Initial load
duke
parents:
diff changeset
3845 jcc(Assembler::above , L);
a61af66fc99e Initial load
duke
parents:
diff changeset
3846 movl(dst, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
3847 jcc(Assembler::equal , L);
a61af66fc99e Initial load
duke
parents:
diff changeset
3848 decrement(dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
3849 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3850 bind(L);
a61af66fc99e Initial load
duke
parents:
diff changeset
3851 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3852
a61af66fc99e Initial load
duke
parents:
diff changeset
3853
a61af66fc99e Initial load
duke
parents:
diff changeset
3854
a61af66fc99e Initial load
duke
parents:
diff changeset
3855 void MacroAssembler::fpop() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3856 ffree();
a61af66fc99e Initial load
duke
parents:
diff changeset
3857 fincstp();
a61af66fc99e Initial load
duke
parents:
diff changeset
3858 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3859
a61af66fc99e Initial load
duke
parents:
diff changeset
3860
a61af66fc99e Initial load
duke
parents:
diff changeset
3861 void MacroAssembler::sign_extend_short(Register reg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3862 if (VM_Version::is_P6()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3863 movsxw(reg, reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
3864 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3865 shll(reg, 16);
a61af66fc99e Initial load
duke
parents:
diff changeset
3866 sarl(reg, 16);
a61af66fc99e Initial load
duke
parents:
diff changeset
3867 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3868 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3869
a61af66fc99e Initial load
duke
parents:
diff changeset
3870
a61af66fc99e Initial load
duke
parents:
diff changeset
3871 void MacroAssembler::sign_extend_byte(Register reg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3872 if (VM_Version::is_P6() && reg->has_byte_register()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3873 movsxb(reg, reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
3874 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3875 shll(reg, 24);
a61af66fc99e Initial load
duke
parents:
diff changeset
3876 sarl(reg, 24);
a61af66fc99e Initial load
duke
parents:
diff changeset
3877 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3878 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3879
a61af66fc99e Initial load
duke
parents:
diff changeset
3880
a61af66fc99e Initial load
duke
parents:
diff changeset
3881 void MacroAssembler::division_with_shift (Register reg, int shift_value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3882 assert (shift_value > 0, "illegal shift value");
a61af66fc99e Initial load
duke
parents:
diff changeset
3883 Label _is_positive;
a61af66fc99e Initial load
duke
parents:
diff changeset
3884 testl (reg, reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
3885 jcc (Assembler::positive, _is_positive);
a61af66fc99e Initial load
duke
parents:
diff changeset
3886 int offset = (1 << shift_value) - 1 ;
a61af66fc99e Initial load
duke
parents:
diff changeset
3887
a61af66fc99e Initial load
duke
parents:
diff changeset
3888 increment(reg, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3889
a61af66fc99e Initial load
duke
parents:
diff changeset
3890 bind (_is_positive);
a61af66fc99e Initial load
duke
parents:
diff changeset
3891 sarl(reg, shift_value);
a61af66fc99e Initial load
duke
parents:
diff changeset
3892 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3893
a61af66fc99e Initial load
duke
parents:
diff changeset
3894
a61af66fc99e Initial load
duke
parents:
diff changeset
3895 void MacroAssembler::round_to(Register reg, int modulus) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3896 addl(reg, modulus - 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
3897 andl(reg, -modulus);
a61af66fc99e Initial load
duke
parents:
diff changeset
3898 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3899
a61af66fc99e Initial load
duke
parents:
diff changeset
3900 // C++ bool manipulation
a61af66fc99e Initial load
duke
parents:
diff changeset
3901
a61af66fc99e Initial load
duke
parents:
diff changeset
3902 void MacroAssembler::movbool(Register dst, Address src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3903 if(sizeof(bool) == 1)
a61af66fc99e Initial load
duke
parents:
diff changeset
3904 movb(dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
3905 else if(sizeof(bool) == 2)
a61af66fc99e Initial load
duke
parents:
diff changeset
3906 movw(dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
3907 else if(sizeof(bool) == 4)
a61af66fc99e Initial load
duke
parents:
diff changeset
3908 movl(dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
3909 else
a61af66fc99e Initial load
duke
parents:
diff changeset
3910 // unsupported
a61af66fc99e Initial load
duke
parents:
diff changeset
3911 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
3912 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3913
a61af66fc99e Initial load
duke
parents:
diff changeset
3914 void MacroAssembler::movbool(Address dst, bool boolconst) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3915 if(sizeof(bool) == 1)
a61af66fc99e Initial load
duke
parents:
diff changeset
3916 movb(dst, (int) boolconst);
a61af66fc99e Initial load
duke
parents:
diff changeset
3917 else if(sizeof(bool) == 2)
a61af66fc99e Initial load
duke
parents:
diff changeset
3918 movw(dst, (int) boolconst);
a61af66fc99e Initial load
duke
parents:
diff changeset
3919 else if(sizeof(bool) == 4)
a61af66fc99e Initial load
duke
parents:
diff changeset
3920 movl(dst, (int) boolconst);
a61af66fc99e Initial load
duke
parents:
diff changeset
3921 else
a61af66fc99e Initial load
duke
parents:
diff changeset
3922 // unsupported
a61af66fc99e Initial load
duke
parents:
diff changeset
3923 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
3924 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3925
a61af66fc99e Initial load
duke
parents:
diff changeset
3926 void MacroAssembler::movbool(Address dst, Register src) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3927 if(sizeof(bool) == 1)
a61af66fc99e Initial load
duke
parents:
diff changeset
3928 movb(dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
3929 else if(sizeof(bool) == 2)
a61af66fc99e Initial load
duke
parents:
diff changeset
3930 movw(dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
3931 else if(sizeof(bool) == 4)
a61af66fc99e Initial load
duke
parents:
diff changeset
3932 movl(dst, src);
a61af66fc99e Initial load
duke
parents:
diff changeset
3933 else
a61af66fc99e Initial load
duke
parents:
diff changeset
3934 // unsupported
a61af66fc99e Initial load
duke
parents:
diff changeset
3935 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
3936 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3937
a61af66fc99e Initial load
duke
parents:
diff changeset
3938 void MacroAssembler::testbool(Register dst) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3939 if(sizeof(bool) == 1)
a61af66fc99e Initial load
duke
parents:
diff changeset
3940 testb(dst, (int) 0xff);
a61af66fc99e Initial load
duke
parents:
diff changeset
3941 else if(sizeof(bool) == 2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3942 // testw implementation needed for two byte bools
a61af66fc99e Initial load
duke
parents:
diff changeset
3943 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
3944 } else if(sizeof(bool) == 4)
a61af66fc99e Initial load
duke
parents:
diff changeset
3945 testl(dst, dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
3946 else
a61af66fc99e Initial load
duke
parents:
diff changeset
3947 // unsupported
a61af66fc99e Initial load
duke
parents:
diff changeset
3948 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
3949 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3950
a61af66fc99e Initial load
duke
parents:
diff changeset
3951 void MacroAssembler::verify_oop(Register reg, const char* s) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3952 if (!VerifyOops) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
3953 // Pass register number to verify_oop_subroutine
a61af66fc99e Initial load
duke
parents:
diff changeset
3954 char* b = new char[strlen(s) + 50];
a61af66fc99e Initial load
duke
parents:
diff changeset
3955 sprintf(b, "verify_oop: %s: %s", reg->name(), s);
a61af66fc99e Initial load
duke
parents:
diff changeset
3956 pushl(rax); // save rax,
a61af66fc99e Initial load
duke
parents:
diff changeset
3957 pushl(reg); // pass register argument
a61af66fc99e Initial load
duke
parents:
diff changeset
3958 ExternalAddress buffer((address) b);
a61af66fc99e Initial load
duke
parents:
diff changeset
3959 pushptr(buffer.addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
3960 // call indirectly to solve generation ordering problem
a61af66fc99e Initial load
duke
parents:
diff changeset
3961 movptr(rax, ExternalAddress(StubRoutines::verify_oop_subroutine_entry_address()));
a61af66fc99e Initial load
duke
parents:
diff changeset
3962 call(rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
3963 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3964
a61af66fc99e Initial load
duke
parents:
diff changeset
3965
a61af66fc99e Initial load
duke
parents:
diff changeset
3966 void MacroAssembler::verify_oop_addr(Address addr, const char* s) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3967 if (!VerifyOops) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
3968 // QQQ fix this
a61af66fc99e Initial load
duke
parents:
diff changeset
3969 // Address adjust(addr.base(), addr.index(), addr.scale(), addr.disp() + BytesPerWord);
a61af66fc99e Initial load
duke
parents:
diff changeset
3970 // Pass register number to verify_oop_subroutine
a61af66fc99e Initial load
duke
parents:
diff changeset
3971 char* b = new char[strlen(s) + 50];
a61af66fc99e Initial load
duke
parents:
diff changeset
3972 sprintf(b, "verify_oop_addr: %s", s);
a61af66fc99e Initial load
duke
parents:
diff changeset
3973 pushl(rax); // save rax,
a61af66fc99e Initial load
duke
parents:
diff changeset
3974 // addr may contain rsp so we will have to adjust it based on the push
a61af66fc99e Initial load
duke
parents:
diff changeset
3975 // we just did
a61af66fc99e Initial load
duke
parents:
diff changeset
3976 if (addr.uses(rsp)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3977 leal(rax, addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
3978 pushl(Address(rax, BytesPerWord));
a61af66fc99e Initial load
duke
parents:
diff changeset
3979 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3980 pushl(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
3981 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3982 ExternalAddress buffer((address) b);
a61af66fc99e Initial load
duke
parents:
diff changeset
3983 // pass msg argument
a61af66fc99e Initial load
duke
parents:
diff changeset
3984 pushptr(buffer.addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
3985 // call indirectly to solve generation ordering problem
a61af66fc99e Initial load
duke
parents:
diff changeset
3986 movptr(rax, ExternalAddress(StubRoutines::verify_oop_subroutine_entry_address()));
a61af66fc99e Initial load
duke
parents:
diff changeset
3987 call(rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
3988 // Caller pops the arguments and restores rax, from the stack
a61af66fc99e Initial load
duke
parents:
diff changeset
3989 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3990
a61af66fc99e Initial load
duke
parents:
diff changeset
3991
a61af66fc99e Initial load
duke
parents:
diff changeset
3992 void MacroAssembler::stop(const char* msg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3993 ExternalAddress message((address)msg);
a61af66fc99e Initial load
duke
parents:
diff changeset
3994 // push address of message
a61af66fc99e Initial load
duke
parents:
diff changeset
3995 pushptr(message.addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
3996 { Label L; call(L, relocInfo::none); bind(L); } // push eip
a61af66fc99e Initial load
duke
parents:
diff changeset
3997 pushad(); // push registers
a61af66fc99e Initial load
duke
parents:
diff changeset
3998 call(RuntimeAddress(CAST_FROM_FN_PTR(address, MacroAssembler::debug)));
a61af66fc99e Initial load
duke
parents:
diff changeset
3999 hlt();
a61af66fc99e Initial load
duke
parents:
diff changeset
4000 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4001
a61af66fc99e Initial load
duke
parents:
diff changeset
4002
a61af66fc99e Initial load
duke
parents:
diff changeset
4003 void MacroAssembler::warn(const char* msg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4004 push_CPU_state();
a61af66fc99e Initial load
duke
parents:
diff changeset
4005
a61af66fc99e Initial load
duke
parents:
diff changeset
4006 ExternalAddress message((address) msg);
a61af66fc99e Initial load
duke
parents:
diff changeset
4007 // push address of message
a61af66fc99e Initial load
duke
parents:
diff changeset
4008 pushptr(message.addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
4009
a61af66fc99e Initial load
duke
parents:
diff changeset
4010 call(RuntimeAddress(CAST_FROM_FN_PTR(address, warning)));
a61af66fc99e Initial load
duke
parents:
diff changeset
4011 addl(rsp, wordSize); // discard argument
a61af66fc99e Initial load
duke
parents:
diff changeset
4012 pop_CPU_state();
a61af66fc99e Initial load
duke
parents:
diff changeset
4013 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4014
a61af66fc99e Initial load
duke
parents:
diff changeset
4015
a61af66fc99e Initial load
duke
parents:
diff changeset
4016 void MacroAssembler::debug(int rdi, int rsi, int rbp, int rsp, int rbx, int rdx, int rcx, int rax, int eip, char* msg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4017 // In order to get locks to work, we need to fake a in_VM state
a61af66fc99e Initial load
duke
parents:
diff changeset
4018 JavaThread* thread = JavaThread::current();
a61af66fc99e Initial load
duke
parents:
diff changeset
4019 JavaThreadState saved_state = thread->thread_state();
a61af66fc99e Initial load
duke
parents:
diff changeset
4020 thread->set_thread_state(_thread_in_vm);
a61af66fc99e Initial load
duke
parents:
diff changeset
4021 if (ShowMessageBoxOnError) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4022 JavaThread* thread = JavaThread::current();
a61af66fc99e Initial load
duke
parents:
diff changeset
4023 JavaThreadState saved_state = thread->thread_state();
a61af66fc99e Initial load
duke
parents:
diff changeset
4024 thread->set_thread_state(_thread_in_vm);
a61af66fc99e Initial load
duke
parents:
diff changeset
4025 ttyLocker ttyl;
a61af66fc99e Initial load
duke
parents:
diff changeset
4026 if (CountBytecodes || TraceBytecodes || StopInterpreterAt) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4027 BytecodeCounter::print();
a61af66fc99e Initial load
duke
parents:
diff changeset
4028 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4029 // To see where a verify_oop failed, get $ebx+40/X for this frame.
a61af66fc99e Initial load
duke
parents:
diff changeset
4030 // This is the value of eip which points to where verify_oop will return.
a61af66fc99e Initial load
duke
parents:
diff changeset
4031 if (os::message_box(msg, "Execution stopped, print registers?")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4032 tty->print_cr("eip = 0x%08x", eip);
a61af66fc99e Initial load
duke
parents:
diff changeset
4033 tty->print_cr("rax, = 0x%08x", rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
4034 tty->print_cr("rbx, = 0x%08x", rbx);
a61af66fc99e Initial load
duke
parents:
diff changeset
4035 tty->print_cr("rcx = 0x%08x", rcx);
a61af66fc99e Initial load
duke
parents:
diff changeset
4036 tty->print_cr("rdx = 0x%08x", rdx);
a61af66fc99e Initial load
duke
parents:
diff changeset
4037 tty->print_cr("rdi = 0x%08x", rdi);
a61af66fc99e Initial load
duke
parents:
diff changeset
4038 tty->print_cr("rsi = 0x%08x", rsi);
a61af66fc99e Initial load
duke
parents:
diff changeset
4039 tty->print_cr("rbp, = 0x%08x", rbp);
a61af66fc99e Initial load
duke
parents:
diff changeset
4040 tty->print_cr("rsp = 0x%08x", rsp);
a61af66fc99e Initial load
duke
parents:
diff changeset
4041 BREAKPOINT;
a61af66fc99e Initial load
duke
parents:
diff changeset
4042 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4043 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
4044 ::tty->print_cr("=============== DEBUG MESSAGE: %s ================\n", msg);
a61af66fc99e Initial load
duke
parents:
diff changeset
4045 assert(false, "DEBUG MESSAGE");
a61af66fc99e Initial load
duke
parents:
diff changeset
4046 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4047 ThreadStateTransition::transition(thread, _thread_in_vm, saved_state);
a61af66fc99e Initial load
duke
parents:
diff changeset
4048 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4049
a61af66fc99e Initial load
duke
parents:
diff changeset
4050
a61af66fc99e Initial load
duke
parents:
diff changeset
4051
a61af66fc99e Initial load
duke
parents:
diff changeset
4052 void MacroAssembler::os_breakpoint() {
a61af66fc99e Initial load
duke
parents:
diff changeset
4053 // instead of directly emitting a breakpoint, call os:breakpoint for better debugability
a61af66fc99e Initial load
duke
parents:
diff changeset
4054 // (e.g., MSVC can't call ps() otherwise)
a61af66fc99e Initial load
duke
parents:
diff changeset
4055 call(RuntimeAddress(CAST_FROM_FN_PTR(address, os::breakpoint)));
a61af66fc99e Initial load
duke
parents:
diff changeset
4056 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4057
a61af66fc99e Initial load
duke
parents:
diff changeset
4058
a61af66fc99e Initial load
duke
parents:
diff changeset
4059 void MacroAssembler::push_fTOS() {
a61af66fc99e Initial load
duke
parents:
diff changeset
4060 subl(rsp, 2 * wordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
4061 fstp_d(Address(rsp, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
4062 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4063
a61af66fc99e Initial load
duke
parents:
diff changeset
4064
a61af66fc99e Initial load
duke
parents:
diff changeset
4065 void MacroAssembler::pop_fTOS() {
a61af66fc99e Initial load
duke
parents:
diff changeset
4066 fld_d(Address(rsp, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
4067 addl(rsp, 2 * wordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
4068 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4069
a61af66fc99e Initial load
duke
parents:
diff changeset
4070
a61af66fc99e Initial load
duke
parents:
diff changeset
4071 void MacroAssembler::empty_FPU_stack() {
a61af66fc99e Initial load
duke
parents:
diff changeset
4072 if (VM_Version::supports_mmx()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4073 emms();
a61af66fc99e Initial load
duke
parents:
diff changeset
4074 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
4075 for (int i = 8; i-- > 0; ) ffree(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
4076 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4077 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4078
a61af66fc99e Initial load
duke
parents:
diff changeset
4079
a61af66fc99e Initial load
duke
parents:
diff changeset
4080 class ControlWord {
a61af66fc99e Initial load
duke
parents:
diff changeset
4081 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
4082 int32_t _value;
a61af66fc99e Initial load
duke
parents:
diff changeset
4083
a61af66fc99e Initial load
duke
parents:
diff changeset
4084 int rounding_control() const { return (_value >> 10) & 3 ; }
a61af66fc99e Initial load
duke
parents:
diff changeset
4085 int precision_control() const { return (_value >> 8) & 3 ; }
a61af66fc99e Initial load
duke
parents:
diff changeset
4086 bool precision() const { return ((_value >> 5) & 1) != 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
4087 bool underflow() const { return ((_value >> 4) & 1) != 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
4088 bool overflow() const { return ((_value >> 3) & 1) != 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
4089 bool zero_divide() const { return ((_value >> 2) & 1) != 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
4090 bool denormalized() const { return ((_value >> 1) & 1) != 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
4091 bool invalid() const { return ((_value >> 0) & 1) != 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
4092
a61af66fc99e Initial load
duke
parents:
diff changeset
4093 void print() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
4094 // rounding control
a61af66fc99e Initial load
duke
parents:
diff changeset
4095 const char* rc;
a61af66fc99e Initial load
duke
parents:
diff changeset
4096 switch (rounding_control()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4097 case 0: rc = "round near"; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
4098 case 1: rc = "round down"; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
4099 case 2: rc = "round up "; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
4100 case 3: rc = "chop "; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
4101 };
a61af66fc99e Initial load
duke
parents:
diff changeset
4102 // precision control
a61af66fc99e Initial load
duke
parents:
diff changeset
4103 const char* pc;
a61af66fc99e Initial load
duke
parents:
diff changeset
4104 switch (precision_control()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4105 case 0: pc = "24 bits "; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
4106 case 1: pc = "reserved"; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
4107 case 2: pc = "53 bits "; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
4108 case 3: pc = "64 bits "; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
4109 };
a61af66fc99e Initial load
duke
parents:
diff changeset
4110 // flags
a61af66fc99e Initial load
duke
parents:
diff changeset
4111 char f[9];
a61af66fc99e Initial load
duke
parents:
diff changeset
4112 f[0] = ' ';
a61af66fc99e Initial load
duke
parents:
diff changeset
4113 f[1] = ' ';
a61af66fc99e Initial load
duke
parents:
diff changeset
4114 f[2] = (precision ()) ? 'P' : 'p';
a61af66fc99e Initial load
duke
parents:
diff changeset
4115 f[3] = (underflow ()) ? 'U' : 'u';
a61af66fc99e Initial load
duke
parents:
diff changeset
4116 f[4] = (overflow ()) ? 'O' : 'o';
a61af66fc99e Initial load
duke
parents:
diff changeset
4117 f[5] = (zero_divide ()) ? 'Z' : 'z';
a61af66fc99e Initial load
duke
parents:
diff changeset
4118 f[6] = (denormalized()) ? 'D' : 'd';
a61af66fc99e Initial load
duke
parents:
diff changeset
4119 f[7] = (invalid ()) ? 'I' : 'i';
a61af66fc99e Initial load
duke
parents:
diff changeset
4120 f[8] = '\x0';
a61af66fc99e Initial load
duke
parents:
diff changeset
4121 // output
a61af66fc99e Initial load
duke
parents:
diff changeset
4122 printf("%04x masks = %s, %s, %s", _value & 0xFFFF, f, rc, pc);
a61af66fc99e Initial load
duke
parents:
diff changeset
4123 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4124
a61af66fc99e Initial load
duke
parents:
diff changeset
4125 };
a61af66fc99e Initial load
duke
parents:
diff changeset
4126
a61af66fc99e Initial load
duke
parents:
diff changeset
4127
a61af66fc99e Initial load
duke
parents:
diff changeset
4128 class StatusWord {
a61af66fc99e Initial load
duke
parents:
diff changeset
4129 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
4130 int32_t _value;
a61af66fc99e Initial load
duke
parents:
diff changeset
4131
a61af66fc99e Initial load
duke
parents:
diff changeset
4132 bool busy() const { return ((_value >> 15) & 1) != 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
4133 bool C3() const { return ((_value >> 14) & 1) != 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
4134 bool C2() const { return ((_value >> 10) & 1) != 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
4135 bool C1() const { return ((_value >> 9) & 1) != 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
4136 bool C0() const { return ((_value >> 8) & 1) != 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
4137 int top() const { return (_value >> 11) & 7 ; }
a61af66fc99e Initial load
duke
parents:
diff changeset
4138 bool error_status() const { return ((_value >> 7) & 1) != 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
4139 bool stack_fault() const { return ((_value >> 6) & 1) != 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
4140 bool precision() const { return ((_value >> 5) & 1) != 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
4141 bool underflow() const { return ((_value >> 4) & 1) != 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
4142 bool overflow() const { return ((_value >> 3) & 1) != 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
4143 bool zero_divide() const { return ((_value >> 2) & 1) != 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
4144 bool denormalized() const { return ((_value >> 1) & 1) != 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
4145 bool invalid() const { return ((_value >> 0) & 1) != 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
4146
a61af66fc99e Initial load
duke
parents:
diff changeset
4147 void print() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
4148 // condition codes
a61af66fc99e Initial load
duke
parents:
diff changeset
4149 char c[5];
a61af66fc99e Initial load
duke
parents:
diff changeset
4150 c[0] = (C3()) ? '3' : '-';
a61af66fc99e Initial load
duke
parents:
diff changeset
4151 c[1] = (C2()) ? '2' : '-';
a61af66fc99e Initial load
duke
parents:
diff changeset
4152 c[2] = (C1()) ? '1' : '-';
a61af66fc99e Initial load
duke
parents:
diff changeset
4153 c[3] = (C0()) ? '0' : '-';
a61af66fc99e Initial load
duke
parents:
diff changeset
4154 c[4] = '\x0';
a61af66fc99e Initial load
duke
parents:
diff changeset
4155 // flags
a61af66fc99e Initial load
duke
parents:
diff changeset
4156 char f[9];
a61af66fc99e Initial load
duke
parents:
diff changeset
4157 f[0] = (error_status()) ? 'E' : '-';
a61af66fc99e Initial load
duke
parents:
diff changeset
4158 f[1] = (stack_fault ()) ? 'S' : '-';
a61af66fc99e Initial load
duke
parents:
diff changeset
4159 f[2] = (precision ()) ? 'P' : '-';
a61af66fc99e Initial load
duke
parents:
diff changeset
4160 f[3] = (underflow ()) ? 'U' : '-';
a61af66fc99e Initial load
duke
parents:
diff changeset
4161 f[4] = (overflow ()) ? 'O' : '-';
a61af66fc99e Initial load
duke
parents:
diff changeset
4162 f[5] = (zero_divide ()) ? 'Z' : '-';
a61af66fc99e Initial load
duke
parents:
diff changeset
4163 f[6] = (denormalized()) ? 'D' : '-';
a61af66fc99e Initial load
duke
parents:
diff changeset
4164 f[7] = (invalid ()) ? 'I' : '-';
a61af66fc99e Initial load
duke
parents:
diff changeset
4165 f[8] = '\x0';
a61af66fc99e Initial load
duke
parents:
diff changeset
4166 // output
a61af66fc99e Initial load
duke
parents:
diff changeset
4167 printf("%04x flags = %s, cc = %s, top = %d", _value & 0xFFFF, f, c, top());
a61af66fc99e Initial load
duke
parents:
diff changeset
4168 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4169
a61af66fc99e Initial load
duke
parents:
diff changeset
4170 };
a61af66fc99e Initial load
duke
parents:
diff changeset
4171
a61af66fc99e Initial load
duke
parents:
diff changeset
4172
a61af66fc99e Initial load
duke
parents:
diff changeset
4173 class TagWord {
a61af66fc99e Initial load
duke
parents:
diff changeset
4174 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
4175 int32_t _value;
a61af66fc99e Initial load
duke
parents:
diff changeset
4176
a61af66fc99e Initial load
duke
parents:
diff changeset
4177 int tag_at(int i) const { return (_value >> (i*2)) & 3; }
a61af66fc99e Initial load
duke
parents:
diff changeset
4178
a61af66fc99e Initial load
duke
parents:
diff changeset
4179 void print() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
4180 printf("%04x", _value & 0xFFFF);
a61af66fc99e Initial load
duke
parents:
diff changeset
4181 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4182
a61af66fc99e Initial load
duke
parents:
diff changeset
4183 };
a61af66fc99e Initial load
duke
parents:
diff changeset
4184
a61af66fc99e Initial load
duke
parents:
diff changeset
4185
a61af66fc99e Initial load
duke
parents:
diff changeset
4186 class FPU_Register {
a61af66fc99e Initial load
duke
parents:
diff changeset
4187 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
4188 int32_t _m0;
a61af66fc99e Initial load
duke
parents:
diff changeset
4189 int32_t _m1;
a61af66fc99e Initial load
duke
parents:
diff changeset
4190 int16_t _ex;
a61af66fc99e Initial load
duke
parents:
diff changeset
4191
a61af66fc99e Initial load
duke
parents:
diff changeset
4192 bool is_indefinite() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
4193 return _ex == -1 && _m1 == (int32_t)0xC0000000 && _m0 == 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
4194 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4195
a61af66fc99e Initial load
duke
parents:
diff changeset
4196 void print() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
4197 char sign = (_ex < 0) ? '-' : '+';
a61af66fc99e Initial load
duke
parents:
diff changeset
4198 const char* kind = (_ex == 0x7FFF || _ex == (int16_t)-1) ? "NaN" : " ";
a61af66fc99e Initial load
duke
parents:
diff changeset
4199 printf("%c%04hx.%08x%08x %s", sign, _ex, _m1, _m0, kind);
a61af66fc99e Initial load
duke
parents:
diff changeset
4200 };
a61af66fc99e Initial load
duke
parents:
diff changeset
4201
a61af66fc99e Initial load
duke
parents:
diff changeset
4202 };
a61af66fc99e Initial load
duke
parents:
diff changeset
4203
a61af66fc99e Initial load
duke
parents:
diff changeset
4204
a61af66fc99e Initial load
duke
parents:
diff changeset
4205 class FPU_State {
a61af66fc99e Initial load
duke
parents:
diff changeset
4206 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
4207 enum {
a61af66fc99e Initial load
duke
parents:
diff changeset
4208 register_size = 10,
a61af66fc99e Initial load
duke
parents:
diff changeset
4209 number_of_registers = 8,
a61af66fc99e Initial load
duke
parents:
diff changeset
4210 register_mask = 7
a61af66fc99e Initial load
duke
parents:
diff changeset
4211 };
a61af66fc99e Initial load
duke
parents:
diff changeset
4212
a61af66fc99e Initial load
duke
parents:
diff changeset
4213 ControlWord _control_word;
a61af66fc99e Initial load
duke
parents:
diff changeset
4214 StatusWord _status_word;
a61af66fc99e Initial load
duke
parents:
diff changeset
4215 TagWord _tag_word;
a61af66fc99e Initial load
duke
parents:
diff changeset
4216 int32_t _error_offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
4217 int32_t _error_selector;
a61af66fc99e Initial load
duke
parents:
diff changeset
4218 int32_t _data_offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
4219 int32_t _data_selector;
a61af66fc99e Initial load
duke
parents:
diff changeset
4220 int8_t _register[register_size * number_of_registers];
a61af66fc99e Initial load
duke
parents:
diff changeset
4221
a61af66fc99e Initial load
duke
parents:
diff changeset
4222 int tag_for_st(int i) const { return _tag_word.tag_at((_status_word.top() + i) & register_mask); }
a61af66fc99e Initial load
duke
parents:
diff changeset
4223 FPU_Register* st(int i) const { return (FPU_Register*)&_register[register_size * i]; }
a61af66fc99e Initial load
duke
parents:
diff changeset
4224
a61af66fc99e Initial load
duke
parents:
diff changeset
4225 const char* tag_as_string(int tag) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
4226 switch (tag) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4227 case 0: return "valid";
a61af66fc99e Initial load
duke
parents:
diff changeset
4228 case 1: return "zero";
a61af66fc99e Initial load
duke
parents:
diff changeset
4229 case 2: return "special";
a61af66fc99e Initial load
duke
parents:
diff changeset
4230 case 3: return "empty";
a61af66fc99e Initial load
duke
parents:
diff changeset
4231 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4232 ShouldNotReachHere()
a61af66fc99e Initial load
duke
parents:
diff changeset
4233 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
4234 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4235
a61af66fc99e Initial load
duke
parents:
diff changeset
4236 void print() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
4237 // print computation registers
a61af66fc99e Initial load
duke
parents:
diff changeset
4238 { int t = _status_word.top();
a61af66fc99e Initial load
duke
parents:
diff changeset
4239 for (int i = 0; i < number_of_registers; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4240 int j = (i - t) & register_mask;
a61af66fc99e Initial load
duke
parents:
diff changeset
4241 printf("%c r%d = ST%d = ", (j == 0 ? '*' : ' '), i, j);
a61af66fc99e Initial load
duke
parents:
diff changeset
4242 st(j)->print();
a61af66fc99e Initial load
duke
parents:
diff changeset
4243 printf(" %s\n", tag_as_string(_tag_word.tag_at(i)));
a61af66fc99e Initial load
duke
parents:
diff changeset
4244 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4245 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4246 printf("\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
4247 // print control registers
a61af66fc99e Initial load
duke
parents:
diff changeset
4248 printf("ctrl = "); _control_word.print(); printf("\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
4249 printf("stat = "); _status_word .print(); printf("\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
4250 printf("tags = "); _tag_word .print(); printf("\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
4251 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4252
a61af66fc99e Initial load
duke
parents:
diff changeset
4253 };
a61af66fc99e Initial load
duke
parents:
diff changeset
4254
a61af66fc99e Initial load
duke
parents:
diff changeset
4255
a61af66fc99e Initial load
duke
parents:
diff changeset
4256 class Flag_Register {
a61af66fc99e Initial load
duke
parents:
diff changeset
4257 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
4258 int32_t _value;
a61af66fc99e Initial load
duke
parents:
diff changeset
4259
a61af66fc99e Initial load
duke
parents:
diff changeset
4260 bool overflow() const { return ((_value >> 11) & 1) != 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
4261 bool direction() const { return ((_value >> 10) & 1) != 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
4262 bool sign() const { return ((_value >> 7) & 1) != 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
4263 bool zero() const { return ((_value >> 6) & 1) != 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
4264 bool auxiliary_carry() const { return ((_value >> 4) & 1) != 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
4265 bool parity() const { return ((_value >> 2) & 1) != 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
4266 bool carry() const { return ((_value >> 0) & 1) != 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
4267
a61af66fc99e Initial load
duke
parents:
diff changeset
4268 void print() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
4269 // flags
a61af66fc99e Initial load
duke
parents:
diff changeset
4270 char f[8];
a61af66fc99e Initial load
duke
parents:
diff changeset
4271 f[0] = (overflow ()) ? 'O' : '-';
a61af66fc99e Initial load
duke
parents:
diff changeset
4272 f[1] = (direction ()) ? 'D' : '-';
a61af66fc99e Initial load
duke
parents:
diff changeset
4273 f[2] = (sign ()) ? 'S' : '-';
a61af66fc99e Initial load
duke
parents:
diff changeset
4274 f[3] = (zero ()) ? 'Z' : '-';
a61af66fc99e Initial load
duke
parents:
diff changeset
4275 f[4] = (auxiliary_carry()) ? 'A' : '-';
a61af66fc99e Initial load
duke
parents:
diff changeset
4276 f[5] = (parity ()) ? 'P' : '-';
a61af66fc99e Initial load
duke
parents:
diff changeset
4277 f[6] = (carry ()) ? 'C' : '-';
a61af66fc99e Initial load
duke
parents:
diff changeset
4278 f[7] = '\x0';
a61af66fc99e Initial load
duke
parents:
diff changeset
4279 // output
a61af66fc99e Initial load
duke
parents:
diff changeset
4280 printf("%08x flags = %s", _value, f);
a61af66fc99e Initial load
duke
parents:
diff changeset
4281 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4282
a61af66fc99e Initial load
duke
parents:
diff changeset
4283 };
a61af66fc99e Initial load
duke
parents:
diff changeset
4284
a61af66fc99e Initial load
duke
parents:
diff changeset
4285
a61af66fc99e Initial load
duke
parents:
diff changeset
4286 class IU_Register {
a61af66fc99e Initial load
duke
parents:
diff changeset
4287 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
4288 int32_t _value;
a61af66fc99e Initial load
duke
parents:
diff changeset
4289
a61af66fc99e Initial load
duke
parents:
diff changeset
4290 void print() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
4291 printf("%08x %11d", _value, _value);
a61af66fc99e Initial load
duke
parents:
diff changeset
4292 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4293
a61af66fc99e Initial load
duke
parents:
diff changeset
4294 };
a61af66fc99e Initial load
duke
parents:
diff changeset
4295
a61af66fc99e Initial load
duke
parents:
diff changeset
4296
a61af66fc99e Initial load
duke
parents:
diff changeset
4297 class IU_State {
a61af66fc99e Initial load
duke
parents:
diff changeset
4298 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
4299 Flag_Register _eflags;
a61af66fc99e Initial load
duke
parents:
diff changeset
4300 IU_Register _rdi;
a61af66fc99e Initial load
duke
parents:
diff changeset
4301 IU_Register _rsi;
a61af66fc99e Initial load
duke
parents:
diff changeset
4302 IU_Register _rbp;
a61af66fc99e Initial load
duke
parents:
diff changeset
4303 IU_Register _rsp;
a61af66fc99e Initial load
duke
parents:
diff changeset
4304 IU_Register _rbx;
a61af66fc99e Initial load
duke
parents:
diff changeset
4305 IU_Register _rdx;
a61af66fc99e Initial load
duke
parents:
diff changeset
4306 IU_Register _rcx;
a61af66fc99e Initial load
duke
parents:
diff changeset
4307 IU_Register _rax;
a61af66fc99e Initial load
duke
parents:
diff changeset
4308
a61af66fc99e Initial load
duke
parents:
diff changeset
4309 void print() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
4310 // computation registers
a61af66fc99e Initial load
duke
parents:
diff changeset
4311 printf("rax, = "); _rax.print(); printf("\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
4312 printf("rbx, = "); _rbx.print(); printf("\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
4313 printf("rcx = "); _rcx.print(); printf("\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
4314 printf("rdx = "); _rdx.print(); printf("\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
4315 printf("rdi = "); _rdi.print(); printf("\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
4316 printf("rsi = "); _rsi.print(); printf("\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
4317 printf("rbp, = "); _rbp.print(); printf("\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
4318 printf("rsp = "); _rsp.print(); printf("\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
4319 printf("\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
4320 // control registers
a61af66fc99e Initial load
duke
parents:
diff changeset
4321 printf("flgs = "); _eflags.print(); printf("\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
4322 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4323 };
a61af66fc99e Initial load
duke
parents:
diff changeset
4324
a61af66fc99e Initial load
duke
parents:
diff changeset
4325
a61af66fc99e Initial load
duke
parents:
diff changeset
4326 class CPU_State {
a61af66fc99e Initial load
duke
parents:
diff changeset
4327 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
4328 FPU_State _fpu_state;
a61af66fc99e Initial load
duke
parents:
diff changeset
4329 IU_State _iu_state;
a61af66fc99e Initial load
duke
parents:
diff changeset
4330
a61af66fc99e Initial load
duke
parents:
diff changeset
4331 void print() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
4332 printf("--------------------------------------------------\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
4333 _iu_state .print();
a61af66fc99e Initial load
duke
parents:
diff changeset
4334 printf("\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
4335 _fpu_state.print();
a61af66fc99e Initial load
duke
parents:
diff changeset
4336 printf("--------------------------------------------------\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
4337 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4338
a61af66fc99e Initial load
duke
parents:
diff changeset
4339 };
a61af66fc99e Initial load
duke
parents:
diff changeset
4340
a61af66fc99e Initial load
duke
parents:
diff changeset
4341
a61af66fc99e Initial load
duke
parents:
diff changeset
4342 static void _print_CPU_state(CPU_State* state) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4343 state->print();
a61af66fc99e Initial load
duke
parents:
diff changeset
4344 };
a61af66fc99e Initial load
duke
parents:
diff changeset
4345
a61af66fc99e Initial load
duke
parents:
diff changeset
4346
a61af66fc99e Initial load
duke
parents:
diff changeset
4347 void MacroAssembler::print_CPU_state() {
a61af66fc99e Initial load
duke
parents:
diff changeset
4348 push_CPU_state();
a61af66fc99e Initial load
duke
parents:
diff changeset
4349 pushl(rsp); // pass CPU state
a61af66fc99e Initial load
duke
parents:
diff changeset
4350 call(RuntimeAddress(CAST_FROM_FN_PTR(address, _print_CPU_state)));
a61af66fc99e Initial load
duke
parents:
diff changeset
4351 addl(rsp, wordSize); // discard argument
a61af66fc99e Initial load
duke
parents:
diff changeset
4352 pop_CPU_state();
a61af66fc99e Initial load
duke
parents:
diff changeset
4353 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4354
a61af66fc99e Initial load
duke
parents:
diff changeset
4355
a61af66fc99e Initial load
duke
parents:
diff changeset
4356 static bool _verify_FPU(int stack_depth, char* s, CPU_State* state) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4357 static int counter = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
4358 FPU_State* fs = &state->_fpu_state;
a61af66fc99e Initial load
duke
parents:
diff changeset
4359 counter++;
a61af66fc99e Initial load
duke
parents:
diff changeset
4360 // For leaf calls, only verify that the top few elements remain empty.
a61af66fc99e Initial load
duke
parents:
diff changeset
4361 // We only need 1 empty at the top for C2 code.
a61af66fc99e Initial load
duke
parents:
diff changeset
4362 if( stack_depth < 0 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4363 if( fs->tag_for_st(7) != 3 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4364 printf("FPR7 not empty\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
4365 state->print();
a61af66fc99e Initial load
duke
parents:
diff changeset
4366 assert(false, "error");
a61af66fc99e Initial load
duke
parents:
diff changeset
4367 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
4368 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4369 return true; // All other stack states do not matter
a61af66fc99e Initial load
duke
parents:
diff changeset
4370 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4371
a61af66fc99e Initial load
duke
parents:
diff changeset
4372 assert((fs->_control_word._value & 0xffff) == StubRoutines::_fpu_cntrl_wrd_std,
a61af66fc99e Initial load
duke
parents:
diff changeset
4373 "bad FPU control word");
a61af66fc99e Initial load
duke
parents:
diff changeset
4374
a61af66fc99e Initial load
duke
parents:
diff changeset
4375 // compute stack depth
a61af66fc99e Initial load
duke
parents:
diff changeset
4376 int i = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
4377 while (i < FPU_State::number_of_registers && fs->tag_for_st(i) < 3) i++;
a61af66fc99e Initial load
duke
parents:
diff changeset
4378 int d = i;
a61af66fc99e Initial load
duke
parents:
diff changeset
4379 while (i < FPU_State::number_of_registers && fs->tag_for_st(i) == 3) i++;
a61af66fc99e Initial load
duke
parents:
diff changeset
4380 // verify findings
a61af66fc99e Initial load
duke
parents:
diff changeset
4381 if (i != FPU_State::number_of_registers) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4382 // stack not contiguous
a61af66fc99e Initial load
duke
parents:
diff changeset
4383 printf("%s: stack not contiguous at ST%d\n", s, i);
a61af66fc99e Initial load
duke
parents:
diff changeset
4384 state->print();
a61af66fc99e Initial load
duke
parents:
diff changeset
4385 assert(false, "error");
a61af66fc99e Initial load
duke
parents:
diff changeset
4386 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
4387 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4388 // check if computed stack depth corresponds to expected stack depth
a61af66fc99e Initial load
duke
parents:
diff changeset
4389 if (stack_depth < 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4390 // expected stack depth is -stack_depth or less
a61af66fc99e Initial load
duke
parents:
diff changeset
4391 if (d > -stack_depth) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4392 // too many elements on the stack
a61af66fc99e Initial load
duke
parents:
diff changeset
4393 printf("%s: <= %d stack elements expected but found %d\n", s, -stack_depth, d);
a61af66fc99e Initial load
duke
parents:
diff changeset
4394 state->print();
a61af66fc99e Initial load
duke
parents:
diff changeset
4395 assert(false, "error");
a61af66fc99e Initial load
duke
parents:
diff changeset
4396 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
4397 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4398 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
4399 // expected stack depth is stack_depth
a61af66fc99e Initial load
duke
parents:
diff changeset
4400 if (d != stack_depth) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4401 // wrong stack depth
a61af66fc99e Initial load
duke
parents:
diff changeset
4402 printf("%s: %d stack elements expected but found %d\n", s, stack_depth, d);
a61af66fc99e Initial load
duke
parents:
diff changeset
4403 state->print();
a61af66fc99e Initial load
duke
parents:
diff changeset
4404 assert(false, "error");
a61af66fc99e Initial load
duke
parents:
diff changeset
4405 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
4406 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4407 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4408 // everything is cool
a61af66fc99e Initial load
duke
parents:
diff changeset
4409 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
4410 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4411
a61af66fc99e Initial load
duke
parents:
diff changeset
4412
a61af66fc99e Initial load
duke
parents:
diff changeset
4413 void MacroAssembler::verify_FPU(int stack_depth, const char* s) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4414 if (!VerifyFPU) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
4415 push_CPU_state();
a61af66fc99e Initial load
duke
parents:
diff changeset
4416 pushl(rsp); // pass CPU state
a61af66fc99e Initial load
duke
parents:
diff changeset
4417 ExternalAddress msg((address) s);
a61af66fc99e Initial load
duke
parents:
diff changeset
4418 // pass message string s
a61af66fc99e Initial load
duke
parents:
diff changeset
4419 pushptr(msg.addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
4420 pushl(stack_depth); // pass stack depth
a61af66fc99e Initial load
duke
parents:
diff changeset
4421 call(RuntimeAddress(CAST_FROM_FN_PTR(address, _verify_FPU)));
a61af66fc99e Initial load
duke
parents:
diff changeset
4422 addl(rsp, 3 * wordSize); // discard arguments
a61af66fc99e Initial load
duke
parents:
diff changeset
4423 // check for error
a61af66fc99e Initial load
duke
parents:
diff changeset
4424 { Label L;
a61af66fc99e Initial load
duke
parents:
diff changeset
4425 testl(rax, rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
4426 jcc(Assembler::notZero, L);
a61af66fc99e Initial load
duke
parents:
diff changeset
4427 int3(); // break if error condition
a61af66fc99e Initial load
duke
parents:
diff changeset
4428 bind(L);
a61af66fc99e Initial load
duke
parents:
diff changeset
4429 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4430 pop_CPU_state();
a61af66fc99e Initial load
duke
parents:
diff changeset
4431 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4432
a61af66fc99e Initial load
duke
parents:
diff changeset
4433
a61af66fc99e Initial load
duke
parents:
diff changeset
4434 void MacroAssembler::push_IU_state() {
a61af66fc99e Initial load
duke
parents:
diff changeset
4435 pushad();
a61af66fc99e Initial load
duke
parents:
diff changeset
4436 pushfd();
a61af66fc99e Initial load
duke
parents:
diff changeset
4437 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4438
a61af66fc99e Initial load
duke
parents:
diff changeset
4439
a61af66fc99e Initial load
duke
parents:
diff changeset
4440 void MacroAssembler::pop_IU_state() {
a61af66fc99e Initial load
duke
parents:
diff changeset
4441 popfd();
a61af66fc99e Initial load
duke
parents:
diff changeset
4442 popad();
a61af66fc99e Initial load
duke
parents:
diff changeset
4443 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4444
a61af66fc99e Initial load
duke
parents:
diff changeset
4445
a61af66fc99e Initial load
duke
parents:
diff changeset
4446 void MacroAssembler::push_FPU_state() {
a61af66fc99e Initial load
duke
parents:
diff changeset
4447 subl(rsp, FPUStateSizeInWords * wordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
4448 fnsave(Address(rsp, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
4449 fwait();
a61af66fc99e Initial load
duke
parents:
diff changeset
4450 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4451
a61af66fc99e Initial load
duke
parents:
diff changeset
4452
a61af66fc99e Initial load
duke
parents:
diff changeset
4453 void MacroAssembler::pop_FPU_state() {
a61af66fc99e Initial load
duke
parents:
diff changeset
4454 frstor(Address(rsp, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
4455 addl(rsp, FPUStateSizeInWords * wordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
4456 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4457
a61af66fc99e Initial load
duke
parents:
diff changeset
4458
a61af66fc99e Initial load
duke
parents:
diff changeset
4459 void MacroAssembler::push_CPU_state() {
a61af66fc99e Initial load
duke
parents:
diff changeset
4460 push_IU_state();
a61af66fc99e Initial load
duke
parents:
diff changeset
4461 push_FPU_state();
a61af66fc99e Initial load
duke
parents:
diff changeset
4462 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4463
a61af66fc99e Initial load
duke
parents:
diff changeset
4464
a61af66fc99e Initial load
duke
parents:
diff changeset
4465 void MacroAssembler::pop_CPU_state() {
a61af66fc99e Initial load
duke
parents:
diff changeset
4466 pop_FPU_state();
a61af66fc99e Initial load
duke
parents:
diff changeset
4467 pop_IU_state();
a61af66fc99e Initial load
duke
parents:
diff changeset
4468 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4469
a61af66fc99e Initial load
duke
parents:
diff changeset
4470
a61af66fc99e Initial load
duke
parents:
diff changeset
4471 void MacroAssembler::push_callee_saved_registers() {
a61af66fc99e Initial load
duke
parents:
diff changeset
4472 pushl(rsi);
a61af66fc99e Initial load
duke
parents:
diff changeset
4473 pushl(rdi);
a61af66fc99e Initial load
duke
parents:
diff changeset
4474 pushl(rdx);
a61af66fc99e Initial load
duke
parents:
diff changeset
4475 pushl(rcx);
a61af66fc99e Initial load
duke
parents:
diff changeset
4476 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4477
a61af66fc99e Initial load
duke
parents:
diff changeset
4478
a61af66fc99e Initial load
duke
parents:
diff changeset
4479 void MacroAssembler::pop_callee_saved_registers() {
a61af66fc99e Initial load
duke
parents:
diff changeset
4480 popl(rcx);
a61af66fc99e Initial load
duke
parents:
diff changeset
4481 popl(rdx);
a61af66fc99e Initial load
duke
parents:
diff changeset
4482 popl(rdi);
a61af66fc99e Initial load
duke
parents:
diff changeset
4483 popl(rsi);
a61af66fc99e Initial load
duke
parents:
diff changeset
4484 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4485
a61af66fc99e Initial load
duke
parents:
diff changeset
4486
a61af66fc99e Initial load
duke
parents:
diff changeset
4487 void MacroAssembler::set_word_if_not_zero(Register dst) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4488 xorl(dst, dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
4489 set_byte_if_not_zero(dst);
a61af66fc99e Initial load
duke
parents:
diff changeset
4490 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4491
a61af66fc99e Initial load
duke
parents:
diff changeset
4492 // Write serialization page so VM thread can do a pseudo remote membar.
a61af66fc99e Initial load
duke
parents:
diff changeset
4493 // We use the current thread pointer to calculate a thread specific
a61af66fc99e Initial load
duke
parents:
diff changeset
4494 // offset to write to within the page. This minimizes bus traffic
a61af66fc99e Initial load
duke
parents:
diff changeset
4495 // due to cache line collision.
a61af66fc99e Initial load
duke
parents:
diff changeset
4496 void MacroAssembler::serialize_memory(Register thread, Register tmp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4497 movl(tmp, thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
4498 shrl(tmp, os::get_serialize_page_shift_count());
a61af66fc99e Initial load
duke
parents:
diff changeset
4499 andl(tmp, (os::vm_page_size() - sizeof(int)));
a61af66fc99e Initial load
duke
parents:
diff changeset
4500
a61af66fc99e Initial load
duke
parents:
diff changeset
4501 Address index(noreg, tmp, Address::times_1);
a61af66fc99e Initial load
duke
parents:
diff changeset
4502 ExternalAddress page(os::get_memory_serialize_page());
a61af66fc99e Initial load
duke
parents:
diff changeset
4503
a61af66fc99e Initial load
duke
parents:
diff changeset
4504 movptr(ArrayAddress(page, index), tmp);
a61af66fc99e Initial load
duke
parents:
diff changeset
4505 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4506
a61af66fc99e Initial load
duke
parents:
diff changeset
4507
a61af66fc99e Initial load
duke
parents:
diff changeset
4508 void MacroAssembler::verify_tlab() {
a61af66fc99e Initial load
duke
parents:
diff changeset
4509 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
4510 if (UseTLAB && VerifyOops) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4511 Label next, ok;
a61af66fc99e Initial load
duke
parents:
diff changeset
4512 Register t1 = rsi;
a61af66fc99e Initial load
duke
parents:
diff changeset
4513 Register thread_reg = rbx;
a61af66fc99e Initial load
duke
parents:
diff changeset
4514
a61af66fc99e Initial load
duke
parents:
diff changeset
4515 pushl(t1);
a61af66fc99e Initial load
duke
parents:
diff changeset
4516 pushl(thread_reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
4517 get_thread(thread_reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
4518
a61af66fc99e Initial load
duke
parents:
diff changeset
4519 movl(t1, Address(thread_reg, in_bytes(JavaThread::tlab_top_offset())));
a61af66fc99e Initial load
duke
parents:
diff changeset
4520 cmpl(t1, Address(thread_reg, in_bytes(JavaThread::tlab_start_offset())));
a61af66fc99e Initial load
duke
parents:
diff changeset
4521 jcc(Assembler::aboveEqual, next);
a61af66fc99e Initial load
duke
parents:
diff changeset
4522 stop("assert(top >= start)");
a61af66fc99e Initial load
duke
parents:
diff changeset
4523 should_not_reach_here();
a61af66fc99e Initial load
duke
parents:
diff changeset
4524
a61af66fc99e Initial load
duke
parents:
diff changeset
4525 bind(next);
a61af66fc99e Initial load
duke
parents:
diff changeset
4526 movl(t1, Address(thread_reg, in_bytes(JavaThread::tlab_end_offset())));
a61af66fc99e Initial load
duke
parents:
diff changeset
4527 cmpl(t1, Address(thread_reg, in_bytes(JavaThread::tlab_top_offset())));
a61af66fc99e Initial load
duke
parents:
diff changeset
4528 jcc(Assembler::aboveEqual, ok);
a61af66fc99e Initial load
duke
parents:
diff changeset
4529 stop("assert(top <= end)");
a61af66fc99e Initial load
duke
parents:
diff changeset
4530 should_not_reach_here();
a61af66fc99e Initial load
duke
parents:
diff changeset
4531
a61af66fc99e Initial load
duke
parents:
diff changeset
4532 bind(ok);
a61af66fc99e Initial load
duke
parents:
diff changeset
4533 popl(thread_reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
4534 popl(t1);
a61af66fc99e Initial load
duke
parents:
diff changeset
4535 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4536 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
4537 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4538
a61af66fc99e Initial load
duke
parents:
diff changeset
4539
a61af66fc99e Initial load
duke
parents:
diff changeset
4540 // Defines obj, preserves var_size_in_bytes
a61af66fc99e Initial load
duke
parents:
diff changeset
4541 void MacroAssembler::eden_allocate(Register obj, Register var_size_in_bytes, int con_size_in_bytes,
a61af66fc99e Initial load
duke
parents:
diff changeset
4542 Register t1, Label& slow_case) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4543 assert(obj == rax, "obj must be in rax, for cmpxchg");
a61af66fc99e Initial load
duke
parents:
diff changeset
4544 assert_different_registers(obj, var_size_in_bytes, t1);
a61af66fc99e Initial load
duke
parents:
diff changeset
4545 Register end = t1;
a61af66fc99e Initial load
duke
parents:
diff changeset
4546 Label retry;
a61af66fc99e Initial load
duke
parents:
diff changeset
4547 bind(retry);
a61af66fc99e Initial load
duke
parents:
diff changeset
4548 ExternalAddress heap_top((address) Universe::heap()->top_addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
4549 movptr(obj, heap_top);
a61af66fc99e Initial load
duke
parents:
diff changeset
4550 if (var_size_in_bytes == noreg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4551 leal(end, Address(obj, con_size_in_bytes));
a61af66fc99e Initial load
duke
parents:
diff changeset
4552 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
4553 leal(end, Address(obj, var_size_in_bytes, Address::times_1));
a61af66fc99e Initial load
duke
parents:
diff changeset
4554 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4555 // if end < obj then we wrapped around => object too long => slow case
a61af66fc99e Initial load
duke
parents:
diff changeset
4556 cmpl(end, obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
4557 jcc(Assembler::below, slow_case);
a61af66fc99e Initial load
duke
parents:
diff changeset
4558 cmpptr(end, ExternalAddress((address) Universe::heap()->end_addr()));
a61af66fc99e Initial load
duke
parents:
diff changeset
4559 jcc(Assembler::above, slow_case);
a61af66fc99e Initial load
duke
parents:
diff changeset
4560 // Compare obj with the top addr, and if still equal, store the new top addr in
a61af66fc99e Initial load
duke
parents:
diff changeset
4561 // end at the address of the top addr pointer. Sets ZF if was equal, and clears
a61af66fc99e Initial load
duke
parents:
diff changeset
4562 // it otherwise. Use lock prefix for atomicity on MPs.
a61af66fc99e Initial load
duke
parents:
diff changeset
4563 if (os::is_MP()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4564 lock();
a61af66fc99e Initial load
duke
parents:
diff changeset
4565 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4566 cmpxchgptr(end, heap_top);
a61af66fc99e Initial load
duke
parents:
diff changeset
4567 jcc(Assembler::notEqual, retry);
a61af66fc99e Initial load
duke
parents:
diff changeset
4568 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4569
a61af66fc99e Initial load
duke
parents:
diff changeset
4570
a61af66fc99e Initial load
duke
parents:
diff changeset
4571 // Defines obj, preserves var_size_in_bytes, okay for t2 == var_size_in_bytes.
a61af66fc99e Initial load
duke
parents:
diff changeset
4572 void MacroAssembler::tlab_allocate(Register obj, Register var_size_in_bytes, int con_size_in_bytes,
a61af66fc99e Initial load
duke
parents:
diff changeset
4573 Register t1, Register t2, Label& slow_case) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4574 assert_different_registers(obj, t1, t2);
a61af66fc99e Initial load
duke
parents:
diff changeset
4575 assert_different_registers(obj, var_size_in_bytes, t1);
a61af66fc99e Initial load
duke
parents:
diff changeset
4576 Register end = t2;
a61af66fc99e Initial load
duke
parents:
diff changeset
4577 Register thread = t1;
a61af66fc99e Initial load
duke
parents:
diff changeset
4578
a61af66fc99e Initial load
duke
parents:
diff changeset
4579 verify_tlab();
a61af66fc99e Initial load
duke
parents:
diff changeset
4580
a61af66fc99e Initial load
duke
parents:
diff changeset
4581 get_thread(thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
4582
a61af66fc99e Initial load
duke
parents:
diff changeset
4583 movl(obj, Address(thread, JavaThread::tlab_top_offset()));
a61af66fc99e Initial load
duke
parents:
diff changeset
4584 if (var_size_in_bytes == noreg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4585 leal(end, Address(obj, con_size_in_bytes));
a61af66fc99e Initial load
duke
parents:
diff changeset
4586 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
4587 leal(end, Address(obj, var_size_in_bytes, Address::times_1));
a61af66fc99e Initial load
duke
parents:
diff changeset
4588 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4589 cmpl(end, Address(thread, JavaThread::tlab_end_offset()));
a61af66fc99e Initial load
duke
parents:
diff changeset
4590 jcc(Assembler::above, slow_case);
a61af66fc99e Initial load
duke
parents:
diff changeset
4591
a61af66fc99e Initial load
duke
parents:
diff changeset
4592 // update the tlab top pointer
a61af66fc99e Initial load
duke
parents:
diff changeset
4593 movl(Address(thread, JavaThread::tlab_top_offset()), end);
a61af66fc99e Initial load
duke
parents:
diff changeset
4594
a61af66fc99e Initial load
duke
parents:
diff changeset
4595 // recover var_size_in_bytes if necessary
a61af66fc99e Initial load
duke
parents:
diff changeset
4596 if (var_size_in_bytes == end) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4597 subl(var_size_in_bytes, obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
4598 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4599 verify_tlab();
a61af66fc99e Initial load
duke
parents:
diff changeset
4600 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4601
a61af66fc99e Initial load
duke
parents:
diff changeset
4602 // Preserves rbx, and rdx.
a61af66fc99e Initial load
duke
parents:
diff changeset
4603 void MacroAssembler::tlab_refill(Label& retry, Label& try_eden, Label& slow_case) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4604 Register top = rax;
a61af66fc99e Initial load
duke
parents:
diff changeset
4605 Register t1 = rcx;
a61af66fc99e Initial load
duke
parents:
diff changeset
4606 Register t2 = rsi;
a61af66fc99e Initial load
duke
parents:
diff changeset
4607 Register thread_reg = rdi;
a61af66fc99e Initial load
duke
parents:
diff changeset
4608 assert_different_registers(top, thread_reg, t1, t2, /* preserve: */ rbx, rdx);
a61af66fc99e Initial load
duke
parents:
diff changeset
4609 Label do_refill, discard_tlab;
a61af66fc99e Initial load
duke
parents:
diff changeset
4610
a61af66fc99e Initial load
duke
parents:
diff changeset
4611 if (CMSIncrementalMode || !Universe::heap()->supports_inline_contig_alloc()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4612 // No allocation in the shared eden.
a61af66fc99e Initial load
duke
parents:
diff changeset
4613 jmp(slow_case);
a61af66fc99e Initial load
duke
parents:
diff changeset
4614 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4615
a61af66fc99e Initial load
duke
parents:
diff changeset
4616 get_thread(thread_reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
4617
a61af66fc99e Initial load
duke
parents:
diff changeset
4618 movl(top, Address(thread_reg, in_bytes(JavaThread::tlab_top_offset())));
a61af66fc99e Initial load
duke
parents:
diff changeset
4619 movl(t1, Address(thread_reg, in_bytes(JavaThread::tlab_end_offset())));
a61af66fc99e Initial load
duke
parents:
diff changeset
4620
a61af66fc99e Initial load
duke
parents:
diff changeset
4621 // calculate amount of free space
a61af66fc99e Initial load
duke
parents:
diff changeset
4622 subl(t1, top);
a61af66fc99e Initial load
duke
parents:
diff changeset
4623 shrl(t1, LogHeapWordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
4624
a61af66fc99e Initial load
duke
parents:
diff changeset
4625 // Retain tlab and allocate object in shared space if
a61af66fc99e Initial load
duke
parents:
diff changeset
4626 // the amount free in the tlab is too large to discard.
a61af66fc99e Initial load
duke
parents:
diff changeset
4627 cmpl(t1, Address(thread_reg, in_bytes(JavaThread::tlab_refill_waste_limit_offset())));
a61af66fc99e Initial load
duke
parents:
diff changeset
4628 jcc(Assembler::lessEqual, discard_tlab);
a61af66fc99e Initial load
duke
parents:
diff changeset
4629
a61af66fc99e Initial load
duke
parents:
diff changeset
4630 // Retain
a61af66fc99e Initial load
duke
parents:
diff changeset
4631 movl(t2, ThreadLocalAllocBuffer::refill_waste_limit_increment());
a61af66fc99e Initial load
duke
parents:
diff changeset
4632 addl(Address(thread_reg, in_bytes(JavaThread::tlab_refill_waste_limit_offset())), t2);
a61af66fc99e Initial load
duke
parents:
diff changeset
4633 if (TLABStats) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4634 // increment number of slow_allocations
a61af66fc99e Initial load
duke
parents:
diff changeset
4635 addl(Address(thread_reg, in_bytes(JavaThread::tlab_slow_allocations_offset())), 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
4636 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4637 jmp(try_eden);
a61af66fc99e Initial load
duke
parents:
diff changeset
4638
a61af66fc99e Initial load
duke
parents:
diff changeset
4639 bind(discard_tlab);
a61af66fc99e Initial load
duke
parents:
diff changeset
4640 if (TLABStats) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4641 // increment number of refills
a61af66fc99e Initial load
duke
parents:
diff changeset
4642 addl(Address(thread_reg, in_bytes(JavaThread::tlab_number_of_refills_offset())), 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
4643 // accumulate wastage -- t1 is amount free in tlab
a61af66fc99e Initial load
duke
parents:
diff changeset
4644 addl(Address(thread_reg, in_bytes(JavaThread::tlab_fast_refill_waste_offset())), t1);
a61af66fc99e Initial load
duke
parents:
diff changeset
4645 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4646
a61af66fc99e Initial load
duke
parents:
diff changeset
4647 // if tlab is currently allocated (top or end != null) then
a61af66fc99e Initial load
duke
parents:
diff changeset
4648 // fill [top, end + alignment_reserve) with array object
a61af66fc99e Initial load
duke
parents:
diff changeset
4649 testl (top, top);
a61af66fc99e Initial load
duke
parents:
diff changeset
4650 jcc(Assembler::zero, do_refill);
a61af66fc99e Initial load
duke
parents:
diff changeset
4651
a61af66fc99e Initial load
duke
parents:
diff changeset
4652 // set up the mark word
a61af66fc99e Initial load
duke
parents:
diff changeset
4653 movl(Address(top, oopDesc::mark_offset_in_bytes()), (int)markOopDesc::prototype()->copy_set_hash(0x2));
a61af66fc99e Initial load
duke
parents:
diff changeset
4654 // set the length to the remaining space
a61af66fc99e Initial load
duke
parents:
diff changeset
4655 subl(t1, typeArrayOopDesc::header_size(T_INT));
a61af66fc99e Initial load
duke
parents:
diff changeset
4656 addl(t1, ThreadLocalAllocBuffer::alignment_reserve());
a61af66fc99e Initial load
duke
parents:
diff changeset
4657 shll(t1, log2_intptr(HeapWordSize/sizeof(jint)));
a61af66fc99e Initial load
duke
parents:
diff changeset
4658 movl(Address(top, arrayOopDesc::length_offset_in_bytes()), t1);
a61af66fc99e Initial load
duke
parents:
diff changeset
4659 // set klass to intArrayKlass
a61af66fc99e Initial load
duke
parents:
diff changeset
4660 // dubious reloc why not an oop reloc?
a61af66fc99e Initial load
duke
parents:
diff changeset
4661 movptr(t1, ExternalAddress((address) Universe::intArrayKlassObj_addr()));
a61af66fc99e Initial load
duke
parents:
diff changeset
4662 movl(Address(top, oopDesc::klass_offset_in_bytes()), t1);
a61af66fc99e Initial load
duke
parents:
diff changeset
4663
a61af66fc99e Initial load
duke
parents:
diff changeset
4664 // refill the tlab with an eden allocation
a61af66fc99e Initial load
duke
parents:
diff changeset
4665 bind(do_refill);
a61af66fc99e Initial load
duke
parents:
diff changeset
4666 movl(t1, Address(thread_reg, in_bytes(JavaThread::tlab_size_offset())));
a61af66fc99e Initial load
duke
parents:
diff changeset
4667 shll(t1, LogHeapWordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
4668 // add object_size ??
a61af66fc99e Initial load
duke
parents:
diff changeset
4669 eden_allocate(top, t1, 0, t2, slow_case);
a61af66fc99e Initial load
duke
parents:
diff changeset
4670
a61af66fc99e Initial load
duke
parents:
diff changeset
4671 // Check that t1 was preserved in eden_allocate.
a61af66fc99e Initial load
duke
parents:
diff changeset
4672 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
4673 if (UseTLAB) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4674 Label ok;
a61af66fc99e Initial load
duke
parents:
diff changeset
4675 Register tsize = rsi;
a61af66fc99e Initial load
duke
parents:
diff changeset
4676 assert_different_registers(tsize, thread_reg, t1);
a61af66fc99e Initial load
duke
parents:
diff changeset
4677 pushl(tsize);
a61af66fc99e Initial load
duke
parents:
diff changeset
4678 movl(tsize, Address(thread_reg, in_bytes(JavaThread::tlab_size_offset())));
a61af66fc99e Initial load
duke
parents:
diff changeset
4679 shll(tsize, LogHeapWordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
4680 cmpl(t1, tsize);
a61af66fc99e Initial load
duke
parents:
diff changeset
4681 jcc(Assembler::equal, ok);
a61af66fc99e Initial load
duke
parents:
diff changeset
4682 stop("assert(t1 != tlab size)");
a61af66fc99e Initial load
duke
parents:
diff changeset
4683 should_not_reach_here();
a61af66fc99e Initial load
duke
parents:
diff changeset
4684
a61af66fc99e Initial load
duke
parents:
diff changeset
4685 bind(ok);
a61af66fc99e Initial load
duke
parents:
diff changeset
4686 popl(tsize);
a61af66fc99e Initial load
duke
parents:
diff changeset
4687 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4688 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
4689 movl(Address(thread_reg, in_bytes(JavaThread::tlab_start_offset())), top);
a61af66fc99e Initial load
duke
parents:
diff changeset
4690 movl(Address(thread_reg, in_bytes(JavaThread::tlab_top_offset())), top);
a61af66fc99e Initial load
duke
parents:
diff changeset
4691 addl(top, t1);
a61af66fc99e Initial load
duke
parents:
diff changeset
4692 subl(top, ThreadLocalAllocBuffer::alignment_reserve_in_bytes());
a61af66fc99e Initial load
duke
parents:
diff changeset
4693 movl(Address(thread_reg, in_bytes(JavaThread::tlab_end_offset())), top);
a61af66fc99e Initial load
duke
parents:
diff changeset
4694 verify_tlab();
a61af66fc99e Initial load
duke
parents:
diff changeset
4695 jmp(retry);
a61af66fc99e Initial load
duke
parents:
diff changeset
4696 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4697
a61af66fc99e Initial load
duke
parents:
diff changeset
4698
a61af66fc99e Initial load
duke
parents:
diff changeset
4699 int MacroAssembler::biased_locking_enter(Register lock_reg, Register obj_reg, Register swap_reg, Register tmp_reg,
a61af66fc99e Initial load
duke
parents:
diff changeset
4700 bool swap_reg_contains_mark,
a61af66fc99e Initial load
duke
parents:
diff changeset
4701 Label& done, Label* slow_case,
a61af66fc99e Initial load
duke
parents:
diff changeset
4702 BiasedLockingCounters* counters) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4703 assert(UseBiasedLocking, "why call this otherwise?");
a61af66fc99e Initial load
duke
parents:
diff changeset
4704 assert(swap_reg == rax, "swap_reg must be rax, for cmpxchg");
a61af66fc99e Initial load
duke
parents:
diff changeset
4705 assert_different_registers(lock_reg, obj_reg, swap_reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
4706
a61af66fc99e Initial load
duke
parents:
diff changeset
4707 if (PrintBiasedLockingStatistics && counters == NULL)
a61af66fc99e Initial load
duke
parents:
diff changeset
4708 counters = BiasedLocking::counters();
a61af66fc99e Initial load
duke
parents:
diff changeset
4709
a61af66fc99e Initial load
duke
parents:
diff changeset
4710 bool need_tmp_reg = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
4711 if (tmp_reg == noreg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4712 need_tmp_reg = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
4713 tmp_reg = lock_reg;
a61af66fc99e Initial load
duke
parents:
diff changeset
4714 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
4715 assert_different_registers(lock_reg, obj_reg, swap_reg, tmp_reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
4716 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4717 assert(markOopDesc::age_shift == markOopDesc::lock_bits + markOopDesc::biased_lock_bits, "biased locking makes assumptions about bit layout");
a61af66fc99e Initial load
duke
parents:
diff changeset
4718 Address mark_addr (obj_reg, oopDesc::mark_offset_in_bytes());
a61af66fc99e Initial load
duke
parents:
diff changeset
4719 Address klass_addr (obj_reg, oopDesc::klass_offset_in_bytes());
a61af66fc99e Initial load
duke
parents:
diff changeset
4720 Address saved_mark_addr(lock_reg, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
4721
a61af66fc99e Initial load
duke
parents:
diff changeset
4722 // Biased locking
a61af66fc99e Initial load
duke
parents:
diff changeset
4723 // See whether the lock is currently biased toward our thread and
a61af66fc99e Initial load
duke
parents:
diff changeset
4724 // whether the epoch is still valid
a61af66fc99e Initial load
duke
parents:
diff changeset
4725 // Note that the runtime guarantees sufficient alignment of JavaThread
a61af66fc99e Initial load
duke
parents:
diff changeset
4726 // pointers to allow age to be placed into low bits
a61af66fc99e Initial load
duke
parents:
diff changeset
4727 // First check to see whether biasing is even enabled for this object
a61af66fc99e Initial load
duke
parents:
diff changeset
4728 Label cas_label;
a61af66fc99e Initial load
duke
parents:
diff changeset
4729 int null_check_offset = -1;
a61af66fc99e Initial load
duke
parents:
diff changeset
4730 if (!swap_reg_contains_mark) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4731 null_check_offset = offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
4732 movl(swap_reg, mark_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
4733 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4734 if (need_tmp_reg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4735 pushl(tmp_reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
4736 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4737 movl(tmp_reg, swap_reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
4738 andl(tmp_reg, markOopDesc::biased_lock_mask_in_place);
a61af66fc99e Initial load
duke
parents:
diff changeset
4739 cmpl(tmp_reg, markOopDesc::biased_lock_pattern);
a61af66fc99e Initial load
duke
parents:
diff changeset
4740 if (need_tmp_reg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4741 popl(tmp_reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
4742 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4743 jcc(Assembler::notEqual, cas_label);
a61af66fc99e Initial load
duke
parents:
diff changeset
4744 // The bias pattern is present in the object's header. Need to check
a61af66fc99e Initial load
duke
parents:
diff changeset
4745 // whether the bias owner and the epoch are both still current.
a61af66fc99e Initial load
duke
parents:
diff changeset
4746 // Note that because there is no current thread register on x86 we
a61af66fc99e Initial load
duke
parents:
diff changeset
4747 // need to store off the mark word we read out of the object to
a61af66fc99e Initial load
duke
parents:
diff changeset
4748 // avoid reloading it and needing to recheck invariants below. This
a61af66fc99e Initial load
duke
parents:
diff changeset
4749 // store is unfortunate but it makes the overall code shorter and
a61af66fc99e Initial load
duke
parents:
diff changeset
4750 // simpler.
a61af66fc99e Initial load
duke
parents:
diff changeset
4751 movl(saved_mark_addr, swap_reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
4752 if (need_tmp_reg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4753 pushl(tmp_reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
4754 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4755 get_thread(tmp_reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
4756 xorl(swap_reg, tmp_reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
4757 if (swap_reg_contains_mark) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4758 null_check_offset = offset();
a61af66fc99e Initial load
duke
parents:
diff changeset
4759 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4760 movl(tmp_reg, klass_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
4761 xorl(swap_reg, Address(tmp_reg, Klass::prototype_header_offset_in_bytes() + klassOopDesc::klass_part_offset_in_bytes()));
a61af66fc99e Initial load
duke
parents:
diff changeset
4762 andl(swap_reg, ~((int) markOopDesc::age_mask_in_place));
a61af66fc99e Initial load
duke
parents:
diff changeset
4763 if (need_tmp_reg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4764 popl(tmp_reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
4765 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4766 if (counters != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4767 cond_inc32(Assembler::zero,
a61af66fc99e Initial load
duke
parents:
diff changeset
4768 ExternalAddress((address)counters->biased_lock_entry_count_addr()));
a61af66fc99e Initial load
duke
parents:
diff changeset
4769 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4770 jcc(Assembler::equal, done);
a61af66fc99e Initial load
duke
parents:
diff changeset
4771
a61af66fc99e Initial load
duke
parents:
diff changeset
4772 Label try_revoke_bias;
a61af66fc99e Initial load
duke
parents:
diff changeset
4773 Label try_rebias;
a61af66fc99e Initial load
duke
parents:
diff changeset
4774
a61af66fc99e Initial load
duke
parents:
diff changeset
4775 // At this point we know that the header has the bias pattern and
a61af66fc99e Initial load
duke
parents:
diff changeset
4776 // that we are not the bias owner in the current epoch. We need to
a61af66fc99e Initial load
duke
parents:
diff changeset
4777 // figure out more details about the state of the header in order to
a61af66fc99e Initial load
duke
parents:
diff changeset
4778 // know what operations can be legally performed on the object's
a61af66fc99e Initial load
duke
parents:
diff changeset
4779 // header.
a61af66fc99e Initial load
duke
parents:
diff changeset
4780
a61af66fc99e Initial load
duke
parents:
diff changeset
4781 // If the low three bits in the xor result aren't clear, that means
a61af66fc99e Initial load
duke
parents:
diff changeset
4782 // the prototype header is no longer biased and we have to revoke
a61af66fc99e Initial load
duke
parents:
diff changeset
4783 // the bias on this object.
a61af66fc99e Initial load
duke
parents:
diff changeset
4784 testl(swap_reg, markOopDesc::biased_lock_mask_in_place);
a61af66fc99e Initial load
duke
parents:
diff changeset
4785 jcc(Assembler::notZero, try_revoke_bias);
a61af66fc99e Initial load
duke
parents:
diff changeset
4786
a61af66fc99e Initial load
duke
parents:
diff changeset
4787 // Biasing is still enabled for this data type. See whether the
a61af66fc99e Initial load
duke
parents:
diff changeset
4788 // epoch of the current bias is still valid, meaning that the epoch
a61af66fc99e Initial load
duke
parents:
diff changeset
4789 // bits of the mark word are equal to the epoch bits of the
a61af66fc99e Initial load
duke
parents:
diff changeset
4790 // prototype header. (Note that the prototype header's epoch bits
a61af66fc99e Initial load
duke
parents:
diff changeset
4791 // only change at a safepoint.) If not, attempt to rebias the object
a61af66fc99e Initial load
duke
parents:
diff changeset
4792 // toward the current thread. Note that we must be absolutely sure
a61af66fc99e Initial load
duke
parents:
diff changeset
4793 // that the current epoch is invalid in order to do this because
a61af66fc99e Initial load
duke
parents:
diff changeset
4794 // otherwise the manipulations it performs on the mark word are
a61af66fc99e Initial load
duke
parents:
diff changeset
4795 // illegal.
a61af66fc99e Initial load
duke
parents:
diff changeset
4796 testl(swap_reg, markOopDesc::epoch_mask_in_place);
a61af66fc99e Initial load
duke
parents:
diff changeset
4797 jcc(Assembler::notZero, try_rebias);
a61af66fc99e Initial load
duke
parents:
diff changeset
4798
a61af66fc99e Initial load
duke
parents:
diff changeset
4799 // The epoch of the current bias is still valid but we know nothing
a61af66fc99e Initial load
duke
parents:
diff changeset
4800 // about the owner; it might be set or it might be clear. Try to
a61af66fc99e Initial load
duke
parents:
diff changeset
4801 // acquire the bias of the object using an atomic operation. If this
a61af66fc99e Initial load
duke
parents:
diff changeset
4802 // fails we will go in to the runtime to revoke the object's bias.
a61af66fc99e Initial load
duke
parents:
diff changeset
4803 // Note that we first construct the presumed unbiased header so we
a61af66fc99e Initial load
duke
parents:
diff changeset
4804 // don't accidentally blow away another thread's valid bias.
a61af66fc99e Initial load
duke
parents:
diff changeset
4805 movl(swap_reg, saved_mark_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
4806 andl(swap_reg,
a61af66fc99e Initial load
duke
parents:
diff changeset
4807 markOopDesc::biased_lock_mask_in_place | markOopDesc::age_mask_in_place | markOopDesc::epoch_mask_in_place);
a61af66fc99e Initial load
duke
parents:
diff changeset
4808 if (need_tmp_reg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4809 pushl(tmp_reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
4810 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4811 get_thread(tmp_reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
4812 orl(tmp_reg, swap_reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
4813 if (os::is_MP()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4814 lock();
a61af66fc99e Initial load
duke
parents:
diff changeset
4815 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4816 cmpxchg(tmp_reg, Address(obj_reg, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
4817 if (need_tmp_reg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4818 popl(tmp_reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
4819 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4820 // If the biasing toward our thread failed, this means that
a61af66fc99e Initial load
duke
parents:
diff changeset
4821 // another thread succeeded in biasing it toward itself and we
a61af66fc99e Initial load
duke
parents:
diff changeset
4822 // need to revoke that bias. The revocation will occur in the
a61af66fc99e Initial load
duke
parents:
diff changeset
4823 // interpreter runtime in the slow case.
a61af66fc99e Initial load
duke
parents:
diff changeset
4824 if (counters != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4825 cond_inc32(Assembler::zero,
a61af66fc99e Initial load
duke
parents:
diff changeset
4826 ExternalAddress((address)counters->anonymously_biased_lock_entry_count_addr()));
a61af66fc99e Initial load
duke
parents:
diff changeset
4827 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4828 if (slow_case != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4829 jcc(Assembler::notZero, *slow_case);
a61af66fc99e Initial load
duke
parents:
diff changeset
4830 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4831 jmp(done);
a61af66fc99e Initial load
duke
parents:
diff changeset
4832
a61af66fc99e Initial load
duke
parents:
diff changeset
4833 bind(try_rebias);
a61af66fc99e Initial load
duke
parents:
diff changeset
4834 // At this point we know the epoch has expired, meaning that the
a61af66fc99e Initial load
duke
parents:
diff changeset
4835 // current "bias owner", if any, is actually invalid. Under these
a61af66fc99e Initial load
duke
parents:
diff changeset
4836 // circumstances _only_, we are allowed to use the current header's
a61af66fc99e Initial load
duke
parents:
diff changeset
4837 // value as the comparison value when doing the cas to acquire the
a61af66fc99e Initial load
duke
parents:
diff changeset
4838 // bias in the current epoch. In other words, we allow transfer of
a61af66fc99e Initial load
duke
parents:
diff changeset
4839 // the bias from one thread to another directly in this situation.
a61af66fc99e Initial load
duke
parents:
diff changeset
4840 //
a61af66fc99e Initial load
duke
parents:
diff changeset
4841 // FIXME: due to a lack of registers we currently blow away the age
a61af66fc99e Initial load
duke
parents:
diff changeset
4842 // bits in this situation. Should attempt to preserve them.
a61af66fc99e Initial load
duke
parents:
diff changeset
4843 if (need_tmp_reg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4844 pushl(tmp_reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
4845 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4846 get_thread(tmp_reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
4847 movl(swap_reg, klass_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
4848 orl(tmp_reg, Address(swap_reg, Klass::prototype_header_offset_in_bytes() + klassOopDesc::klass_part_offset_in_bytes()));
a61af66fc99e Initial load
duke
parents:
diff changeset
4849 movl(swap_reg, saved_mark_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
4850 if (os::is_MP()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4851 lock();
a61af66fc99e Initial load
duke
parents:
diff changeset
4852 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4853 cmpxchg(tmp_reg, Address(obj_reg, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
4854 if (need_tmp_reg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4855 popl(tmp_reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
4856 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4857 // If the biasing toward our thread failed, then another thread
a61af66fc99e Initial load
duke
parents:
diff changeset
4858 // succeeded in biasing it toward itself and we need to revoke that
a61af66fc99e Initial load
duke
parents:
diff changeset
4859 // bias. The revocation will occur in the runtime in the slow case.
a61af66fc99e Initial load
duke
parents:
diff changeset
4860 if (counters != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4861 cond_inc32(Assembler::zero,
a61af66fc99e Initial load
duke
parents:
diff changeset
4862 ExternalAddress((address)counters->rebiased_lock_entry_count_addr()));
a61af66fc99e Initial load
duke
parents:
diff changeset
4863 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4864 if (slow_case != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4865 jcc(Assembler::notZero, *slow_case);
a61af66fc99e Initial load
duke
parents:
diff changeset
4866 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4867 jmp(done);
a61af66fc99e Initial load
duke
parents:
diff changeset
4868
a61af66fc99e Initial load
duke
parents:
diff changeset
4869 bind(try_revoke_bias);
a61af66fc99e Initial load
duke
parents:
diff changeset
4870 // The prototype mark in the klass doesn't have the bias bit set any
a61af66fc99e Initial load
duke
parents:
diff changeset
4871 // more, indicating that objects of this data type are not supposed
a61af66fc99e Initial load
duke
parents:
diff changeset
4872 // to be biased any more. We are going to try to reset the mark of
a61af66fc99e Initial load
duke
parents:
diff changeset
4873 // this object to the prototype value and fall through to the
a61af66fc99e Initial load
duke
parents:
diff changeset
4874 // CAS-based locking scheme. Note that if our CAS fails, it means
a61af66fc99e Initial load
duke
parents:
diff changeset
4875 // that another thread raced us for the privilege of revoking the
a61af66fc99e Initial load
duke
parents:
diff changeset
4876 // bias of this particular object, so it's okay to continue in the
a61af66fc99e Initial load
duke
parents:
diff changeset
4877 // normal locking code.
a61af66fc99e Initial load
duke
parents:
diff changeset
4878 //
a61af66fc99e Initial load
duke
parents:
diff changeset
4879 // FIXME: due to a lack of registers we currently blow away the age
a61af66fc99e Initial load
duke
parents:
diff changeset
4880 // bits in this situation. Should attempt to preserve them.
a61af66fc99e Initial load
duke
parents:
diff changeset
4881 movl(swap_reg, saved_mark_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
4882 if (need_tmp_reg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4883 pushl(tmp_reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
4884 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4885 movl(tmp_reg, klass_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
4886 movl(tmp_reg, Address(tmp_reg, Klass::prototype_header_offset_in_bytes() + klassOopDesc::klass_part_offset_in_bytes()));
a61af66fc99e Initial load
duke
parents:
diff changeset
4887 if (os::is_MP()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4888 lock();
a61af66fc99e Initial load
duke
parents:
diff changeset
4889 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4890 cmpxchg(tmp_reg, Address(obj_reg, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
4891 if (need_tmp_reg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4892 popl(tmp_reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
4893 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4894 // Fall through to the normal CAS-based lock, because no matter what
a61af66fc99e Initial load
duke
parents:
diff changeset
4895 // the result of the above CAS, some thread must have succeeded in
a61af66fc99e Initial load
duke
parents:
diff changeset
4896 // removing the bias bit from the object's header.
a61af66fc99e Initial load
duke
parents:
diff changeset
4897 if (counters != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4898 cond_inc32(Assembler::zero,
a61af66fc99e Initial load
duke
parents:
diff changeset
4899 ExternalAddress((address)counters->revoked_lock_entry_count_addr()));
a61af66fc99e Initial load
duke
parents:
diff changeset
4900 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4901
a61af66fc99e Initial load
duke
parents:
diff changeset
4902 bind(cas_label);
a61af66fc99e Initial load
duke
parents:
diff changeset
4903
a61af66fc99e Initial load
duke
parents:
diff changeset
4904 return null_check_offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
4905 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4906
a61af66fc99e Initial load
duke
parents:
diff changeset
4907
a61af66fc99e Initial load
duke
parents:
diff changeset
4908 void MacroAssembler::biased_locking_exit(Register obj_reg, Register temp_reg, Label& done) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4909 assert(UseBiasedLocking, "why call this otherwise?");
a61af66fc99e Initial load
duke
parents:
diff changeset
4910
a61af66fc99e Initial load
duke
parents:
diff changeset
4911 // Check for biased locking unlock case, which is a no-op
a61af66fc99e Initial load
duke
parents:
diff changeset
4912 // Note: we do not have to check the thread ID for two reasons.
a61af66fc99e Initial load
duke
parents:
diff changeset
4913 // First, the interpreter checks for IllegalMonitorStateException at
a61af66fc99e Initial load
duke
parents:
diff changeset
4914 // a higher level. Second, if the bias was revoked while we held the
a61af66fc99e Initial load
duke
parents:
diff changeset
4915 // lock, the object could not be rebiased toward another thread, so
a61af66fc99e Initial load
duke
parents:
diff changeset
4916 // the bias bit would be clear.
a61af66fc99e Initial load
duke
parents:
diff changeset
4917 movl(temp_reg, Address(obj_reg, oopDesc::mark_offset_in_bytes()));
a61af66fc99e Initial load
duke
parents:
diff changeset
4918 andl(temp_reg, markOopDesc::biased_lock_mask_in_place);
a61af66fc99e Initial load
duke
parents:
diff changeset
4919 cmpl(temp_reg, markOopDesc::biased_lock_pattern);
a61af66fc99e Initial load
duke
parents:
diff changeset
4920 jcc(Assembler::equal, done);
a61af66fc99e Initial load
duke
parents:
diff changeset
4921 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4922
a61af66fc99e Initial load
duke
parents:
diff changeset
4923
a61af66fc99e Initial load
duke
parents:
diff changeset
4924 Assembler::Condition MacroAssembler::negate_condition(Assembler::Condition cond) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4925 switch (cond) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4926 // Note some conditions are synonyms for others
a61af66fc99e Initial load
duke
parents:
diff changeset
4927 case Assembler::zero: return Assembler::notZero;
a61af66fc99e Initial load
duke
parents:
diff changeset
4928 case Assembler::notZero: return Assembler::zero;
a61af66fc99e Initial load
duke
parents:
diff changeset
4929 case Assembler::less: return Assembler::greaterEqual;
a61af66fc99e Initial load
duke
parents:
diff changeset
4930 case Assembler::lessEqual: return Assembler::greater;
a61af66fc99e Initial load
duke
parents:
diff changeset
4931 case Assembler::greater: return Assembler::lessEqual;
a61af66fc99e Initial load
duke
parents:
diff changeset
4932 case Assembler::greaterEqual: return Assembler::less;
a61af66fc99e Initial load
duke
parents:
diff changeset
4933 case Assembler::below: return Assembler::aboveEqual;
a61af66fc99e Initial load
duke
parents:
diff changeset
4934 case Assembler::belowEqual: return Assembler::above;
a61af66fc99e Initial load
duke
parents:
diff changeset
4935 case Assembler::above: return Assembler::belowEqual;
a61af66fc99e Initial load
duke
parents:
diff changeset
4936 case Assembler::aboveEqual: return Assembler::below;
a61af66fc99e Initial load
duke
parents:
diff changeset
4937 case Assembler::overflow: return Assembler::noOverflow;
a61af66fc99e Initial load
duke
parents:
diff changeset
4938 case Assembler::noOverflow: return Assembler::overflow;
a61af66fc99e Initial load
duke
parents:
diff changeset
4939 case Assembler::negative: return Assembler::positive;
a61af66fc99e Initial load
duke
parents:
diff changeset
4940 case Assembler::positive: return Assembler::negative;
a61af66fc99e Initial load
duke
parents:
diff changeset
4941 case Assembler::parity: return Assembler::noParity;
a61af66fc99e Initial load
duke
parents:
diff changeset
4942 case Assembler::noParity: return Assembler::parity;
a61af66fc99e Initial load
duke
parents:
diff changeset
4943 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4944 ShouldNotReachHere(); return Assembler::overflow;
a61af66fc99e Initial load
duke
parents:
diff changeset
4945 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4946
a61af66fc99e Initial load
duke
parents:
diff changeset
4947
a61af66fc99e Initial load
duke
parents:
diff changeset
4948 void MacroAssembler::cond_inc32(Condition cond, AddressLiteral counter_addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4949 Condition negated_cond = negate_condition(cond);
a61af66fc99e Initial load
duke
parents:
diff changeset
4950 Label L;
a61af66fc99e Initial load
duke
parents:
diff changeset
4951 jcc(negated_cond, L);
a61af66fc99e Initial load
duke
parents:
diff changeset
4952 atomic_incl(counter_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
4953 bind(L);
a61af66fc99e Initial load
duke
parents:
diff changeset
4954 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4955
a61af66fc99e Initial load
duke
parents:
diff changeset
4956 void MacroAssembler::atomic_incl(AddressLiteral counter_addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4957 pushfd();
a61af66fc99e Initial load
duke
parents:
diff changeset
4958 if (os::is_MP())
a61af66fc99e Initial load
duke
parents:
diff changeset
4959 lock();
a61af66fc99e Initial load
duke
parents:
diff changeset
4960 increment(counter_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
4961 popfd();
a61af66fc99e Initial load
duke
parents:
diff changeset
4962 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4963
a61af66fc99e Initial load
duke
parents:
diff changeset
4964 SkipIfEqual::SkipIfEqual(
a61af66fc99e Initial load
duke
parents:
diff changeset
4965 MacroAssembler* masm, const bool* flag_addr, bool value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4966 _masm = masm;
a61af66fc99e Initial load
duke
parents:
diff changeset
4967 _masm->cmp8(ExternalAddress((address)flag_addr), value);
a61af66fc99e Initial load
duke
parents:
diff changeset
4968 _masm->jcc(Assembler::equal, _label);
a61af66fc99e Initial load
duke
parents:
diff changeset
4969 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4970
a61af66fc99e Initial load
duke
parents:
diff changeset
4971 SkipIfEqual::~SkipIfEqual() {
a61af66fc99e Initial load
duke
parents:
diff changeset
4972 _masm->bind(_label);
a61af66fc99e Initial load
duke
parents:
diff changeset
4973 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4974
a61af66fc99e Initial load
duke
parents:
diff changeset
4975
a61af66fc99e Initial load
duke
parents:
diff changeset
4976 // Writes to stack successive pages until offset reached to check for
a61af66fc99e Initial load
duke
parents:
diff changeset
4977 // stack overflow + shadow pages. This clobbers tmp.
a61af66fc99e Initial load
duke
parents:
diff changeset
4978 void MacroAssembler::bang_stack_size(Register size, Register tmp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4979 movl(tmp, rsp);
a61af66fc99e Initial load
duke
parents:
diff changeset
4980 // Bang stack for total size given plus shadow page size.
a61af66fc99e Initial load
duke
parents:
diff changeset
4981 // Bang one page at a time because large size can bang beyond yellow and
a61af66fc99e Initial load
duke
parents:
diff changeset
4982 // red zones.
a61af66fc99e Initial load
duke
parents:
diff changeset
4983 Label loop;
a61af66fc99e Initial load
duke
parents:
diff changeset
4984 bind(loop);
a61af66fc99e Initial load
duke
parents:
diff changeset
4985 movl(Address(tmp, (-os::vm_page_size())), size );
a61af66fc99e Initial load
duke
parents:
diff changeset
4986 subl(tmp, os::vm_page_size());
a61af66fc99e Initial load
duke
parents:
diff changeset
4987 subl(size, os::vm_page_size());
a61af66fc99e Initial load
duke
parents:
diff changeset
4988 jcc(Assembler::greater, loop);
a61af66fc99e Initial load
duke
parents:
diff changeset
4989
a61af66fc99e Initial load
duke
parents:
diff changeset
4990 // Bang down shadow pages too.
a61af66fc99e Initial load
duke
parents:
diff changeset
4991 // The -1 because we already subtracted 1 page.
a61af66fc99e Initial load
duke
parents:
diff changeset
4992 for (int i = 0; i< StackShadowPages-1; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
4993 movl(Address(tmp, (-i*os::vm_page_size())), size );
a61af66fc99e Initial load
duke
parents:
diff changeset
4994 }
a61af66fc99e Initial load
duke
parents:
diff changeset
4995 }