ager@chromium.org | 9258b6b | 2008-09-11 09:11:10 +0000 | [diff] [blame] | 1 | // Copyright 2007-2008 the V8 project authors. All rights reserved. |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 2 | // Redistribution and use in source and binary forms, with or without |
| 3 | // modification, are permitted provided that the following conditions are |
| 4 | // met: |
| 5 | // |
| 6 | // * Redistributions of source code must retain the above copyright |
| 7 | // notice, this list of conditions and the following disclaimer. |
| 8 | // * Redistributions in binary form must reproduce the above |
| 9 | // copyright notice, this list of conditions and the following |
| 10 | // disclaimer in the documentation and/or other materials provided |
| 11 | // with the distribution. |
| 12 | // * Neither the name of Google Inc. nor the names of its |
| 13 | // contributors may be used to endorse or promote products derived |
| 14 | // from this software without specific prior written permission. |
| 15 | // |
| 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | |
| 28 | #include <stdlib.h> |
| 29 | |
| 30 | #include "v8.h" |
| 31 | |
| 32 | #include "debug.h" |
| 33 | #include "disasm.h" |
| 34 | #include "disassembler.h" |
| 35 | #include "macro-assembler.h" |
| 36 | #include "serialize.h" |
| 37 | #include "cctest.h" |
| 38 | |
| 39 | using namespace v8::internal; |
| 40 | |
| 41 | static v8::Persistent<v8::Context> env; |
| 42 | |
| 43 | static void InitializeVM() { |
| 44 | if (env.IsEmpty()) { |
| 45 | env = v8::Context::New(); |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | |
| 50 | #define __ assm. |
| 51 | |
| 52 | |
| 53 | static void DummyStaticFunction(Object* result) { |
| 54 | } |
| 55 | |
| 56 | |
| 57 | TEST(DisasmIa320) { |
| 58 | InitializeVM(); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 59 | v8::HandleScope scope; |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 60 | v8::internal::byte buffer[2048]; |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 61 | Assembler assm(Isolate::Current(), buffer, sizeof buffer); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 62 | DummyStaticFunction(NULL); // just bloody use it (DELETE; debugging) |
| 63 | |
| 64 | // Short immediate instructions |
| 65 | __ adc(eax, 12345678); |
| 66 | __ add(Operand(eax), Immediate(12345678)); |
| 67 | __ or_(eax, 12345678); |
| 68 | __ sub(Operand(eax), Immediate(12345678)); |
| 69 | __ xor_(eax, 12345678); |
| 70 | __ and_(eax, 12345678); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 71 | Handle<FixedArray> foo = FACTORY->NewFixedArray(10, TENURED); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 72 | __ cmp(eax, foo); |
| 73 | |
| 74 | // ---- This one caused crash |
| 75 | __ mov(ebx, Operand(esp, ecx, times_2, 0)); // [esp+ecx*4] |
| 76 | |
| 77 | // ---- All instructions that I can think of |
| 78 | __ add(edx, Operand(ebx)); |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 79 | __ add(edx, Operand(12, RelocInfo::NONE)); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 80 | __ add(edx, Operand(ebx, 0)); |
| 81 | __ add(edx, Operand(ebx, 16)); |
| 82 | __ add(edx, Operand(ebx, 1999)); |
| 83 | __ add(edx, Operand(esp, 0)); |
| 84 | __ add(edx, Operand(esp, 16)); |
| 85 | __ add(edx, Operand(esp, 1999)); |
| 86 | __ nop(); |
| 87 | __ add(edi, Operand(ebp, ecx, times_4, 0)); |
| 88 | __ add(edi, Operand(ebp, ecx, times_4, 12)); |
| 89 | __ add(Operand(ebp, ecx, times_4, 12), Immediate(12)); |
| 90 | |
| 91 | __ nop(); |
| 92 | __ add(Operand(ebx), Immediate(12)); |
| 93 | __ nop(); |
| 94 | __ adc(ecx, 12); |
| 95 | __ adc(ecx, 1000); |
| 96 | __ nop(); |
| 97 | __ and_(edx, 3); |
| 98 | __ and_(edx, Operand(esp, 4)); |
| 99 | __ cmp(edx, 3); |
| 100 | __ cmp(edx, Operand(esp, 4)); |
| 101 | __ cmp(Operand(ebp, ecx, times_4, 0), Immediate(1000)); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 102 | Handle<FixedArray> foo2 = FACTORY->NewFixedArray(10, TENURED); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 103 | __ cmp(ebx, foo2); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 104 | __ cmpb(ebx, Operand(ebp, ecx, times_2, 0)); |
| 105 | __ cmpb(Operand(ebp, ecx, times_2, 0), ebx); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 106 | __ or_(edx, 3); |
| 107 | __ xor_(edx, 3); |
| 108 | __ nop(); |
| 109 | { |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 110 | CHECK(CpuFeatures::IsSupported(CPUID)); |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 111 | CpuFeatures::Scope fscope(CPUID); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 112 | __ cpuid(); |
| 113 | } |
| 114 | { |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 115 | CHECK(CpuFeatures::IsSupported(RDTSC)); |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 116 | CpuFeatures::Scope fscope(RDTSC); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 117 | __ rdtsc(); |
| 118 | } |
| 119 | __ movsx_b(edx, Operand(ecx)); |
| 120 | __ movsx_w(edx, Operand(ecx)); |
| 121 | __ movzx_b(edx, Operand(ecx)); |
| 122 | __ movzx_w(edx, Operand(ecx)); |
| 123 | |
| 124 | __ nop(); |
| 125 | __ imul(edx, Operand(ecx)); |
| 126 | __ shld(edx, Operand(ecx)); |
| 127 | __ shrd(edx, Operand(ecx)); |
| 128 | __ bts(Operand(edx), ecx); |
| 129 | __ bts(Operand(ebx, ecx, times_4, 0), ecx); |
| 130 | __ nop(); |
| 131 | __ pushad(); |
| 132 | __ popad(); |
| 133 | __ pushfd(); |
| 134 | __ popfd(); |
| 135 | __ push(Immediate(12)); |
| 136 | __ push(Immediate(23456)); |
| 137 | __ push(ecx); |
| 138 | __ push(esi); |
| 139 | __ push(Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
| 140 | __ push(Operand(ebx, ecx, times_4, 0)); |
| 141 | __ push(Operand(ebx, ecx, times_4, 0)); |
| 142 | __ push(Operand(ebx, ecx, times_4, 10000)); |
| 143 | __ pop(edx); |
| 144 | __ pop(eax); |
| 145 | __ pop(Operand(ebx, ecx, times_4, 0)); |
| 146 | __ nop(); |
| 147 | |
| 148 | __ add(edx, Operand(esp, 16)); |
| 149 | __ add(edx, Operand(ecx)); |
| 150 | __ mov_b(edx, Operand(ecx)); |
| 151 | __ mov_b(Operand(ecx), 6); |
| 152 | __ mov_b(Operand(ebx, ecx, times_4, 10000), 6); |
| 153 | __ mov_b(Operand(esp, 16), edx); |
| 154 | __ mov_w(edx, Operand(esp, 16)); |
| 155 | __ mov_w(Operand(esp, 16), edx); |
| 156 | __ nop(); |
| 157 | __ movsx_w(edx, Operand(esp, 12)); |
| 158 | __ movsx_b(edx, Operand(esp, 12)); |
| 159 | __ movzx_w(edx, Operand(esp, 12)); |
| 160 | __ movzx_b(edx, Operand(esp, 12)); |
| 161 | __ nop(); |
| 162 | __ mov(edx, 1234567); |
| 163 | __ mov(edx, Operand(esp, 12)); |
| 164 | __ mov(Operand(ebx, ecx, times_4, 10000), Immediate(12345)); |
| 165 | __ mov(Operand(ebx, ecx, times_4, 10000), edx); |
| 166 | __ nop(); |
| 167 | __ dec_b(edx); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 168 | __ dec_b(Operand(eax, 10)); |
| 169 | __ dec_b(Operand(ebx, ecx, times_4, 10000)); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 170 | __ dec(edx); |
| 171 | __ cdq(); |
| 172 | |
| 173 | __ nop(); |
| 174 | __ idiv(edx); |
| 175 | __ mul(edx); |
| 176 | __ neg(edx); |
| 177 | __ not_(edx); |
| 178 | __ test(Operand(ebx, ecx, times_4, 10000), Immediate(123456)); |
| 179 | |
| 180 | __ imul(edx, Operand(ebx, ecx, times_4, 10000)); |
| 181 | __ imul(edx, ecx, 12); |
| 182 | __ imul(edx, ecx, 1000); |
| 183 | |
| 184 | __ inc(edx); |
| 185 | __ inc(Operand(ebx, ecx, times_4, 10000)); |
| 186 | __ push(Operand(ebx, ecx, times_4, 10000)); |
| 187 | __ pop(Operand(ebx, ecx, times_4, 10000)); |
| 188 | __ call(Operand(ebx, ecx, times_4, 10000)); |
| 189 | __ jmp(Operand(ebx, ecx, times_4, 10000)); |
| 190 | |
| 191 | __ lea(edx, Operand(ebx, ecx, times_4, 10000)); |
| 192 | __ or_(edx, 12345); |
| 193 | __ or_(edx, Operand(ebx, ecx, times_4, 10000)); |
| 194 | |
| 195 | __ nop(); |
| 196 | |
| 197 | __ rcl(edx, 1); |
| 198 | __ rcl(edx, 7); |
ager@chromium.org | ea4f62e | 2010-08-16 16:28:43 +0000 | [diff] [blame] | 199 | __ rcr(edx, 1); |
| 200 | __ rcr(edx, 7); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 201 | __ sar(edx, 1); |
| 202 | __ sar(edx, 6); |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 203 | __ sar_cl(edx); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 204 | __ sbb(edx, Operand(ebx, ecx, times_4, 10000)); |
| 205 | __ shld(edx, Operand(ebx, ecx, times_4, 10000)); |
| 206 | __ shl(edx, 1); |
| 207 | __ shl(edx, 6); |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 208 | __ shl_cl(edx); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 209 | __ shrd(edx, Operand(ebx, ecx, times_4, 10000)); |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 210 | __ shr(edx, 1); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 211 | __ shr(edx, 7); |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 212 | __ shr_cl(edx); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 213 | |
| 214 | |
| 215 | // Immediates |
| 216 | |
| 217 | __ adc(edx, 12345); |
| 218 | |
| 219 | __ add(Operand(ebx), Immediate(12)); |
| 220 | __ add(Operand(edx, ecx, times_4, 10000), Immediate(12)); |
| 221 | |
| 222 | __ and_(ebx, 12345); |
| 223 | |
| 224 | __ cmp(ebx, 12345); |
| 225 | __ cmp(Operand(ebx), Immediate(12)); |
| 226 | __ cmp(Operand(edx, ecx, times_4, 10000), Immediate(12)); |
| 227 | |
| 228 | __ or_(ebx, 12345); |
| 229 | |
| 230 | __ sub(Operand(ebx), Immediate(12)); |
| 231 | __ sub(Operand(edx, ecx, times_4, 10000), Immediate(12)); |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 232 | __ subb(Operand(edx, ecx, times_4, 10000), 100); |
| 233 | __ subb(Operand(eax), 100); |
| 234 | __ subb(eax, Operand(edx, ecx, times_4, 10000)); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 235 | |
| 236 | __ xor_(ebx, 12345); |
| 237 | |
| 238 | __ imul(edx, ecx, 12); |
| 239 | __ imul(edx, ecx, 1000); |
| 240 | |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 241 | __ cld(); |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 242 | __ rep_movs(); |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 243 | __ rep_stos(); |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 244 | __ stos(); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 245 | |
| 246 | __ sub(edx, Operand(ebx, ecx, times_4, 10000)); |
| 247 | __ sub(edx, Operand(ebx)); |
| 248 | |
| 249 | __ test(edx, Immediate(12345)); |
| 250 | __ test(edx, Operand(ebx, ecx, times_8, 10000)); |
vegorov@chromium.org | 2356e6f | 2010-06-09 09:38:56 +0000 | [diff] [blame] | 251 | __ test(Operand(esi, edi, times_1, -20000000), Immediate(300000000)); |
| 252 | __ test_b(edx, Operand(ecx, ebx, times_2, 1000)); |
| 253 | __ test_b(Operand(eax, -20), 0x9A); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 254 | __ nop(); |
| 255 | |
| 256 | __ xor_(edx, 12345); |
| 257 | __ xor_(edx, Operand(ebx, ecx, times_8, 10000)); |
| 258 | __ bts(Operand(ebx, ecx, times_8, 10000), edx); |
| 259 | __ hlt(); |
| 260 | __ int3(); |
| 261 | __ ret(0); |
| 262 | __ ret(8); |
| 263 | |
| 264 | // Calls |
| 265 | |
| 266 | Label L1, L2; |
| 267 | __ bind(&L1); |
| 268 | __ nop(); |
| 269 | __ call(&L1); |
| 270 | __ call(&L2); |
| 271 | __ nop(); |
| 272 | __ bind(&L2); |
| 273 | __ call(Operand(ebx, ecx, times_4, 10000)); |
| 274 | __ nop(); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 275 | Handle<Code> ic(Isolate::Current()->builtins()->builtin( |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 276 | Builtins::kLoadIC_Initialize)); |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 277 | __ call(ic, RelocInfo::CODE_TARGET); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 278 | __ nop(); |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 279 | __ call(FUNCTION_ADDR(DummyStaticFunction), RelocInfo::RUNTIME_ENTRY); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 280 | __ nop(); |
| 281 | |
| 282 | __ jmp(&L1); |
| 283 | __ jmp(Operand(ebx, ecx, times_4, 10000)); |
ricow@chromium.org | 5ad5ace | 2010-06-23 09:06:43 +0000 | [diff] [blame] | 284 | #ifdef ENABLE_DEBUGGER_SUPPORT |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 285 | ExternalReference after_break_target = |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 286 | ExternalReference(Debug_Address::AfterBreakTarget(), |
| 287 | assm.isolate()); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 288 | __ jmp(Operand::StaticVariable(after_break_target)); |
ricow@chromium.org | 5ad5ace | 2010-06-23 09:06:43 +0000 | [diff] [blame] | 289 | #endif // ENABLE_DEBUGGER_SUPPORT |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 290 | __ jmp(ic, RelocInfo::CODE_TARGET); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 291 | __ nop(); |
| 292 | |
| 293 | |
| 294 | Label Ljcc; |
| 295 | __ nop(); |
| 296 | // long jumps |
| 297 | __ j(overflow, &Ljcc); |
| 298 | __ j(no_overflow, &Ljcc); |
| 299 | __ j(below, &Ljcc); |
| 300 | __ j(above_equal, &Ljcc); |
| 301 | __ j(equal, &Ljcc); |
| 302 | __ j(not_equal, &Ljcc); |
| 303 | __ j(below_equal, &Ljcc); |
| 304 | __ j(above, &Ljcc); |
| 305 | __ j(sign, &Ljcc); |
| 306 | __ j(not_sign, &Ljcc); |
| 307 | __ j(parity_even, &Ljcc); |
| 308 | __ j(parity_odd, &Ljcc); |
| 309 | __ j(less, &Ljcc); |
| 310 | __ j(greater_equal, &Ljcc); |
| 311 | __ j(less_equal, &Ljcc); |
| 312 | __ j(greater, &Ljcc); |
| 313 | __ nop(); |
| 314 | __ bind(&Ljcc); |
| 315 | // short jumps |
| 316 | __ j(overflow, &Ljcc); |
| 317 | __ j(no_overflow, &Ljcc); |
| 318 | __ j(below, &Ljcc); |
| 319 | __ j(above_equal, &Ljcc); |
| 320 | __ j(equal, &Ljcc); |
| 321 | __ j(not_equal, &Ljcc); |
| 322 | __ j(below_equal, &Ljcc); |
| 323 | __ j(above, &Ljcc); |
| 324 | __ j(sign, &Ljcc); |
| 325 | __ j(not_sign, &Ljcc); |
| 326 | __ j(parity_even, &Ljcc); |
| 327 | __ j(parity_odd, &Ljcc); |
| 328 | __ j(less, &Ljcc); |
| 329 | __ j(greater_equal, &Ljcc); |
| 330 | __ j(less_equal, &Ljcc); |
| 331 | __ j(greater, &Ljcc); |
| 332 | |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 333 | // 0xD9 instructions |
| 334 | __ nop(); |
| 335 | |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 336 | __ fld(1); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 337 | __ fld1(); |
| 338 | __ fldz(); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 339 | __ fldpi(); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 340 | __ fabs(); |
| 341 | __ fchs(); |
| 342 | __ fprem(); |
| 343 | __ fprem1(); |
| 344 | __ fincstp(); |
| 345 | __ ftst(); |
| 346 | __ fxch(3); |
| 347 | __ fld_s(Operand(ebx, ecx, times_4, 10000)); |
| 348 | __ fstp_s(Operand(ebx, ecx, times_4, 10000)); |
| 349 | __ ffree(3); |
| 350 | __ fld_d(Operand(ebx, ecx, times_4, 10000)); |
| 351 | __ fstp_d(Operand(ebx, ecx, times_4, 10000)); |
| 352 | __ nop(); |
| 353 | |
| 354 | __ fild_s(Operand(ebx, ecx, times_4, 10000)); |
| 355 | __ fistp_s(Operand(ebx, ecx, times_4, 10000)); |
| 356 | __ fild_d(Operand(ebx, ecx, times_4, 10000)); |
| 357 | __ fistp_d(Operand(ebx, ecx, times_4, 10000)); |
| 358 | __ fnstsw_ax(); |
| 359 | __ nop(); |
| 360 | __ fadd(3); |
| 361 | __ fsub(3); |
| 362 | __ fmul(3); |
| 363 | __ fdiv(3); |
| 364 | |
| 365 | __ faddp(3); |
| 366 | __ fsubp(3); |
| 367 | __ fmulp(3); |
| 368 | __ fdivp(3); |
| 369 | __ fcompp(); |
| 370 | __ fwait(); |
| 371 | __ nop(); |
| 372 | { |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 373 | if (CpuFeatures::IsSupported(SSE2)) { |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 374 | CpuFeatures::Scope fscope(SSE2); |
| 375 | __ cvttss2si(edx, Operand(ebx, ecx, times_4, 10000)); |
| 376 | __ cvtsi2sd(xmm1, Operand(ebx, ecx, times_4, 10000)); |
| 377 | __ addsd(xmm1, xmm0); |
| 378 | __ mulsd(xmm1, xmm0); |
| 379 | __ subsd(xmm1, xmm0); |
| 380 | __ divsd(xmm1, xmm0); |
| 381 | __ movdbl(xmm1, Operand(ebx, ecx, times_4, 10000)); |
| 382 | __ movdbl(Operand(ebx, ecx, times_4, 10000), xmm1); |
ricow@chromium.org | 5ad5ace | 2010-06-23 09:06:43 +0000 | [diff] [blame] | 383 | __ ucomisd(xmm0, xmm1); |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 384 | |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 385 | // 128 bit move instructions. |
| 386 | __ movdqa(xmm0, Operand(ebx, ecx, times_4, 10000)); |
| 387 | __ movdqa(Operand(ebx, ecx, times_4, 10000), xmm0); |
| 388 | __ movdqu(xmm0, Operand(ebx, ecx, times_4, 10000)); |
| 389 | __ movdqu(Operand(ebx, ecx, times_4, 10000), xmm0); |
| 390 | } |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 391 | } |
christian.plesner.hansen@gmail.com | 9d58c2b | 2009-10-16 11:48:38 +0000 | [diff] [blame] | 392 | |
| 393 | // cmov. |
| 394 | { |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 395 | if (CpuFeatures::IsSupported(CMOV)) { |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 396 | CpuFeatures::Scope use_cmov(CMOV); |
| 397 | __ cmov(overflow, eax, Operand(eax, 0)); |
| 398 | __ cmov(no_overflow, eax, Operand(eax, 1)); |
| 399 | __ cmov(below, eax, Operand(eax, 2)); |
| 400 | __ cmov(above_equal, eax, Operand(eax, 3)); |
| 401 | __ cmov(equal, eax, Operand(ebx, 0)); |
| 402 | __ cmov(not_equal, eax, Operand(ebx, 1)); |
| 403 | __ cmov(below_equal, eax, Operand(ebx, 2)); |
| 404 | __ cmov(above, eax, Operand(ebx, 3)); |
| 405 | __ cmov(sign, eax, Operand(ecx, 0)); |
| 406 | __ cmov(not_sign, eax, Operand(ecx, 1)); |
| 407 | __ cmov(parity_even, eax, Operand(ecx, 2)); |
| 408 | __ cmov(parity_odd, eax, Operand(ecx, 3)); |
| 409 | __ cmov(less, eax, Operand(edx, 0)); |
| 410 | __ cmov(greater_equal, eax, Operand(edx, 1)); |
| 411 | __ cmov(less_equal, eax, Operand(edx, 2)); |
| 412 | __ cmov(greater, eax, Operand(edx, 3)); |
| 413 | } |
christian.plesner.hansen@gmail.com | 9d58c2b | 2009-10-16 11:48:38 +0000 | [diff] [blame] | 414 | } |
| 415 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 416 | // andpd, cmpltsd, movaps, psllq, psrlq, por. |
fschneider@chromium.org | c20610a | 2010-09-22 09:44:58 +0000 | [diff] [blame] | 417 | { |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 418 | if (CpuFeatures::IsSupported(SSE2)) { |
fschneider@chromium.org | c20610a | 2010-09-22 09:44:58 +0000 | [diff] [blame] | 419 | CpuFeatures::Scope fscope(SSE2); |
| 420 | __ andpd(xmm0, xmm1); |
| 421 | __ andpd(xmm1, xmm2); |
| 422 | |
| 423 | __ cmpltsd(xmm0, xmm1); |
| 424 | __ cmpltsd(xmm1, xmm2); |
| 425 | |
| 426 | __ movaps(xmm0, xmm1); |
| 427 | __ movaps(xmm1, xmm2); |
| 428 | |
| 429 | __ psllq(xmm0, 17); |
| 430 | __ psllq(xmm1, 42); |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 431 | |
| 432 | __ psllq(xmm0, xmm1); |
| 433 | __ psllq(xmm1, xmm2); |
| 434 | |
| 435 | __ psrlq(xmm0, 17); |
| 436 | __ psrlq(xmm1, 42); |
| 437 | |
| 438 | __ psrlq(xmm0, xmm1); |
| 439 | __ psrlq(xmm1, xmm2); |
| 440 | |
| 441 | __ por(xmm0, xmm1); |
| 442 | __ por(xmm1, xmm2); |
fschneider@chromium.org | c20610a | 2010-09-22 09:44:58 +0000 | [diff] [blame] | 443 | } |
| 444 | } |
| 445 | |
erik.corry@gmail.com | d91075f | 2011-02-10 07:45:38 +0000 | [diff] [blame] | 446 | { |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 447 | if (CpuFeatures::IsSupported(SSE4_1)) { |
erik.corry@gmail.com | d91075f | 2011-02-10 07:45:38 +0000 | [diff] [blame] | 448 | CpuFeatures::Scope scope(SSE4_1); |
| 449 | __ pextrd(Operand(eax), xmm0, 1); |
| 450 | __ pinsrd(xmm1, Operand(eax), 0); |
| 451 | } |
| 452 | } |
| 453 | |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 454 | __ ret(0); |
| 455 | |
| 456 | CodeDesc desc; |
| 457 | assm.GetCode(&desc); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 458 | Object* code = HEAP->CreateCode( |
lrn@chromium.org | 303ada7 | 2010-10-27 09:33:13 +0000 | [diff] [blame] | 459 | desc, |
| 460 | Code::ComputeFlags(Code::STUB), |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 461 | Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 462 | CHECK(code->IsCode()); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 463 | #ifdef OBJECT_PRINT |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 464 | Code::cast(code)->Print(); |
| 465 | byte* begin = Code::cast(code)->instruction_start(); |
| 466 | byte* end = begin + Code::cast(code)->instruction_size(); |
| 467 | disasm::Disassembler::Disassemble(stdout, begin, end); |
| 468 | #endif |
| 469 | } |
| 470 | |
| 471 | #undef __ |