erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1 | // Copyright 2011 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 | |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 41 | |
| 42 | #define __ assm. |
| 43 | |
| 44 | |
| 45 | static void DummyStaticFunction(Object* result) { |
| 46 | } |
| 47 | |
| 48 | |
| 49 | TEST(DisasmIa320) { |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 50 | CcTest::InitializeVM(); |
| 51 | Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 52 | HandleScope scope(isolate); |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 53 | v8::internal::byte buffer[2048]; |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 54 | Assembler assm(isolate, buffer, sizeof buffer); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 55 | DummyStaticFunction(NULL); // just bloody use it (DELETE; debugging) |
| 56 | |
| 57 | // Short immediate instructions |
| 58 | __ adc(eax, 12345678); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 59 | __ add(eax, Immediate(12345678)); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 60 | __ or_(eax, 12345678); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 61 | __ sub(eax, Immediate(12345678)); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 62 | __ xor_(eax, 12345678); |
| 63 | __ and_(eax, 12345678); |
verwaest@chromium.org | d4be0f0 | 2013-06-05 13:39:03 +0000 | [diff] [blame] | 64 | Handle<FixedArray> foo = isolate->factory()->NewFixedArray(10, TENURED); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 65 | __ cmp(eax, foo); |
| 66 | |
| 67 | // ---- This one caused crash |
| 68 | __ mov(ebx, Operand(esp, ecx, times_2, 0)); // [esp+ecx*4] |
| 69 | |
| 70 | // ---- All instructions that I can think of |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 71 | __ add(edx, ebx); |
jkummerow@chromium.org | 59297c7 | 2013-01-09 16:32:23 +0000 | [diff] [blame] | 72 | __ add(edx, Operand(12, RelocInfo::NONE32)); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 73 | __ add(edx, Operand(ebx, 0)); |
| 74 | __ add(edx, Operand(ebx, 16)); |
| 75 | __ add(edx, Operand(ebx, 1999)); |
| 76 | __ add(edx, Operand(esp, 0)); |
| 77 | __ add(edx, Operand(esp, 16)); |
| 78 | __ add(edx, Operand(esp, 1999)); |
| 79 | __ nop(); |
| 80 | __ add(edi, Operand(ebp, ecx, times_4, 0)); |
| 81 | __ add(edi, Operand(ebp, ecx, times_4, 12)); |
| 82 | __ add(Operand(ebp, ecx, times_4, 12), Immediate(12)); |
| 83 | |
| 84 | __ nop(); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 85 | __ add(ebx, Immediate(12)); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 86 | __ nop(); |
| 87 | __ adc(ecx, 12); |
| 88 | __ adc(ecx, 1000); |
| 89 | __ nop(); |
| 90 | __ and_(edx, 3); |
| 91 | __ and_(edx, Operand(esp, 4)); |
| 92 | __ cmp(edx, 3); |
| 93 | __ cmp(edx, Operand(esp, 4)); |
| 94 | __ cmp(Operand(ebp, ecx, times_4, 0), Immediate(1000)); |
verwaest@chromium.org | d4be0f0 | 2013-06-05 13:39:03 +0000 | [diff] [blame] | 95 | Handle<FixedArray> foo2 = isolate->factory()->NewFixedArray(10, TENURED); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 96 | __ cmp(ebx, foo2); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 97 | __ cmpb(ebx, Operand(ebp, ecx, times_2, 0)); |
| 98 | __ cmpb(Operand(ebp, ecx, times_2, 0), ebx); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 99 | __ or_(edx, 3); |
| 100 | __ xor_(edx, 3); |
| 101 | __ nop(); |
jkummerow@chromium.org | 1e8da74 | 2013-08-26 17:13:35 +0000 | [diff] [blame] | 102 | __ cpuid(); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 103 | __ movsx_b(edx, ecx); |
| 104 | __ movsx_w(edx, ecx); |
| 105 | __ movzx_b(edx, ecx); |
| 106 | __ movzx_w(edx, ecx); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 107 | |
| 108 | __ nop(); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 109 | __ imul(edx, ecx); |
| 110 | __ shld(edx, ecx); |
| 111 | __ shrd(edx, ecx); |
| 112 | __ bts(edx, ecx); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 113 | __ bts(Operand(ebx, ecx, times_4, 0), ecx); |
| 114 | __ nop(); |
| 115 | __ pushad(); |
| 116 | __ popad(); |
| 117 | __ pushfd(); |
| 118 | __ popfd(); |
| 119 | __ push(Immediate(12)); |
| 120 | __ push(Immediate(23456)); |
| 121 | __ push(ecx); |
| 122 | __ push(esi); |
| 123 | __ push(Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
| 124 | __ push(Operand(ebx, ecx, times_4, 0)); |
| 125 | __ push(Operand(ebx, ecx, times_4, 0)); |
| 126 | __ push(Operand(ebx, ecx, times_4, 10000)); |
| 127 | __ pop(edx); |
| 128 | __ pop(eax); |
| 129 | __ pop(Operand(ebx, ecx, times_4, 0)); |
| 130 | __ nop(); |
| 131 | |
| 132 | __ add(edx, Operand(esp, 16)); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 133 | __ add(edx, ecx); |
| 134 | __ mov_b(edx, ecx); |
| 135 | __ mov_b(ecx, 6); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 136 | __ mov_b(Operand(ebx, ecx, times_4, 10000), 6); |
| 137 | __ mov_b(Operand(esp, 16), edx); |
| 138 | __ mov_w(edx, Operand(esp, 16)); |
| 139 | __ mov_w(Operand(esp, 16), edx); |
| 140 | __ nop(); |
| 141 | __ movsx_w(edx, Operand(esp, 12)); |
| 142 | __ movsx_b(edx, Operand(esp, 12)); |
| 143 | __ movzx_w(edx, Operand(esp, 12)); |
| 144 | __ movzx_b(edx, Operand(esp, 12)); |
| 145 | __ nop(); |
| 146 | __ mov(edx, 1234567); |
| 147 | __ mov(edx, Operand(esp, 12)); |
| 148 | __ mov(Operand(ebx, ecx, times_4, 10000), Immediate(12345)); |
| 149 | __ mov(Operand(ebx, ecx, times_4, 10000), edx); |
| 150 | __ nop(); |
| 151 | __ dec_b(edx); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 152 | __ dec_b(Operand(eax, 10)); |
| 153 | __ dec_b(Operand(ebx, ecx, times_4, 10000)); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 154 | __ dec(edx); |
| 155 | __ cdq(); |
| 156 | |
| 157 | __ nop(); |
| 158 | __ idiv(edx); |
| 159 | __ mul(edx); |
| 160 | __ neg(edx); |
| 161 | __ not_(edx); |
| 162 | __ test(Operand(ebx, ecx, times_4, 10000), Immediate(123456)); |
| 163 | |
| 164 | __ imul(edx, Operand(ebx, ecx, times_4, 10000)); |
| 165 | __ imul(edx, ecx, 12); |
| 166 | __ imul(edx, ecx, 1000); |
| 167 | |
| 168 | __ inc(edx); |
| 169 | __ inc(Operand(ebx, ecx, times_4, 10000)); |
| 170 | __ push(Operand(ebx, ecx, times_4, 10000)); |
| 171 | __ pop(Operand(ebx, ecx, times_4, 10000)); |
| 172 | __ call(Operand(ebx, ecx, times_4, 10000)); |
| 173 | __ jmp(Operand(ebx, ecx, times_4, 10000)); |
| 174 | |
| 175 | __ lea(edx, Operand(ebx, ecx, times_4, 10000)); |
| 176 | __ or_(edx, 12345); |
| 177 | __ or_(edx, Operand(ebx, ecx, times_4, 10000)); |
| 178 | |
| 179 | __ nop(); |
| 180 | |
| 181 | __ rcl(edx, 1); |
| 182 | __ rcl(edx, 7); |
ager@chromium.org | ea4f62e | 2010-08-16 16:28:43 +0000 | [diff] [blame] | 183 | __ rcr(edx, 1); |
| 184 | __ rcr(edx, 7); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 185 | __ sar(edx, 1); |
| 186 | __ sar(edx, 6); |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 187 | __ sar_cl(edx); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 188 | __ sbb(edx, Operand(ebx, ecx, times_4, 10000)); |
| 189 | __ shld(edx, Operand(ebx, ecx, times_4, 10000)); |
| 190 | __ shl(edx, 1); |
| 191 | __ shl(edx, 6); |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 192 | __ shl_cl(edx); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 193 | __ shrd(edx, Operand(ebx, ecx, times_4, 10000)); |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 194 | __ shr(edx, 1); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 195 | __ shr(edx, 7); |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 196 | __ shr_cl(edx); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 197 | |
| 198 | |
| 199 | // Immediates |
| 200 | |
| 201 | __ adc(edx, 12345); |
| 202 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 203 | __ add(ebx, Immediate(12)); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 204 | __ add(Operand(edx, ecx, times_4, 10000), Immediate(12)); |
| 205 | |
| 206 | __ and_(ebx, 12345); |
| 207 | |
| 208 | __ cmp(ebx, 12345); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 209 | __ cmp(ebx, Immediate(12)); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 210 | __ cmp(Operand(edx, ecx, times_4, 10000), Immediate(12)); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 211 | __ cmpb(eax, 100); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 212 | |
| 213 | __ or_(ebx, 12345); |
| 214 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 215 | __ sub(ebx, Immediate(12)); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 216 | __ sub(Operand(edx, ecx, times_4, 10000), Immediate(12)); |
| 217 | |
| 218 | __ xor_(ebx, 12345); |
| 219 | |
| 220 | __ imul(edx, ecx, 12); |
| 221 | __ imul(edx, ecx, 1000); |
| 222 | |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 223 | __ cld(); |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 224 | __ rep_movs(); |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 225 | __ rep_stos(); |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 226 | __ stos(); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 227 | |
| 228 | __ sub(edx, Operand(ebx, ecx, times_4, 10000)); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 229 | __ sub(edx, ebx); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 230 | |
| 231 | __ test(edx, Immediate(12345)); |
| 232 | __ test(edx, Operand(ebx, ecx, times_8, 10000)); |
vegorov@chromium.org | 2356e6f | 2010-06-09 09:38:56 +0000 | [diff] [blame] | 233 | __ test(Operand(esi, edi, times_1, -20000000), Immediate(300000000)); |
| 234 | __ test_b(edx, Operand(ecx, ebx, times_2, 1000)); |
| 235 | __ test_b(Operand(eax, -20), 0x9A); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 236 | __ nop(); |
| 237 | |
| 238 | __ xor_(edx, 12345); |
| 239 | __ xor_(edx, Operand(ebx, ecx, times_8, 10000)); |
| 240 | __ bts(Operand(ebx, ecx, times_8, 10000), edx); |
| 241 | __ hlt(); |
| 242 | __ int3(); |
| 243 | __ ret(0); |
| 244 | __ ret(8); |
| 245 | |
| 246 | // Calls |
| 247 | |
| 248 | Label L1, L2; |
| 249 | __ bind(&L1); |
| 250 | __ nop(); |
| 251 | __ call(&L1); |
| 252 | __ call(&L2); |
| 253 | __ nop(); |
| 254 | __ bind(&L2); |
| 255 | __ call(Operand(ebx, ecx, times_4, 10000)); |
| 256 | __ nop(); |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 257 | Handle<Code> ic(isolate->builtins()->builtin(Builtins::kLoadIC_Initialize)); |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 258 | __ call(ic, RelocInfo::CODE_TARGET); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 259 | __ nop(); |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 260 | __ call(FUNCTION_ADDR(DummyStaticFunction), RelocInfo::RUNTIME_ENTRY); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 261 | __ nop(); |
| 262 | |
| 263 | __ jmp(&L1); |
| 264 | __ jmp(Operand(ebx, ecx, times_4, 10000)); |
ricow@chromium.org | 5ad5ace | 2010-06-23 09:06:43 +0000 | [diff] [blame] | 265 | #ifdef ENABLE_DEBUGGER_SUPPORT |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 266 | ExternalReference after_break_target = |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 267 | ExternalReference(Debug_Address::AfterBreakTarget(), isolate); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 268 | __ jmp(Operand::StaticVariable(after_break_target)); |
ricow@chromium.org | 5ad5ace | 2010-06-23 09:06:43 +0000 | [diff] [blame] | 269 | #endif // ENABLE_DEBUGGER_SUPPORT |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 270 | __ jmp(ic, RelocInfo::CODE_TARGET); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 271 | __ nop(); |
| 272 | |
| 273 | |
| 274 | Label Ljcc; |
| 275 | __ nop(); |
| 276 | // long jumps |
| 277 | __ j(overflow, &Ljcc); |
| 278 | __ j(no_overflow, &Ljcc); |
| 279 | __ j(below, &Ljcc); |
| 280 | __ j(above_equal, &Ljcc); |
| 281 | __ j(equal, &Ljcc); |
| 282 | __ j(not_equal, &Ljcc); |
| 283 | __ j(below_equal, &Ljcc); |
| 284 | __ j(above, &Ljcc); |
| 285 | __ j(sign, &Ljcc); |
| 286 | __ j(not_sign, &Ljcc); |
| 287 | __ j(parity_even, &Ljcc); |
| 288 | __ j(parity_odd, &Ljcc); |
| 289 | __ j(less, &Ljcc); |
| 290 | __ j(greater_equal, &Ljcc); |
| 291 | __ j(less_equal, &Ljcc); |
| 292 | __ j(greater, &Ljcc); |
| 293 | __ nop(); |
| 294 | __ bind(&Ljcc); |
| 295 | // short jumps |
| 296 | __ j(overflow, &Ljcc); |
| 297 | __ j(no_overflow, &Ljcc); |
| 298 | __ j(below, &Ljcc); |
| 299 | __ j(above_equal, &Ljcc); |
| 300 | __ j(equal, &Ljcc); |
| 301 | __ j(not_equal, &Ljcc); |
| 302 | __ j(below_equal, &Ljcc); |
| 303 | __ j(above, &Ljcc); |
| 304 | __ j(sign, &Ljcc); |
| 305 | __ j(not_sign, &Ljcc); |
| 306 | __ j(parity_even, &Ljcc); |
| 307 | __ j(parity_odd, &Ljcc); |
| 308 | __ j(less, &Ljcc); |
| 309 | __ j(greater_equal, &Ljcc); |
| 310 | __ j(less_equal, &Ljcc); |
| 311 | __ j(greater, &Ljcc); |
| 312 | |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 313 | // 0xD9 instructions |
| 314 | __ nop(); |
| 315 | |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 316 | __ fld(1); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 317 | __ fld1(); |
| 318 | __ fldz(); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 319 | __ fldpi(); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 320 | __ fabs(); |
| 321 | __ fchs(); |
| 322 | __ fprem(); |
| 323 | __ fprem1(); |
| 324 | __ fincstp(); |
| 325 | __ ftst(); |
| 326 | __ fxch(3); |
| 327 | __ fld_s(Operand(ebx, ecx, times_4, 10000)); |
| 328 | __ fstp_s(Operand(ebx, ecx, times_4, 10000)); |
| 329 | __ ffree(3); |
| 330 | __ fld_d(Operand(ebx, ecx, times_4, 10000)); |
| 331 | __ fstp_d(Operand(ebx, ecx, times_4, 10000)); |
| 332 | __ nop(); |
| 333 | |
| 334 | __ fild_s(Operand(ebx, ecx, times_4, 10000)); |
| 335 | __ fistp_s(Operand(ebx, ecx, times_4, 10000)); |
| 336 | __ fild_d(Operand(ebx, ecx, times_4, 10000)); |
| 337 | __ fistp_d(Operand(ebx, ecx, times_4, 10000)); |
| 338 | __ fnstsw_ax(); |
| 339 | __ nop(); |
| 340 | __ fadd(3); |
| 341 | __ fsub(3); |
| 342 | __ fmul(3); |
| 343 | __ fdiv(3); |
| 344 | |
| 345 | __ faddp(3); |
| 346 | __ fsubp(3); |
| 347 | __ fmulp(3); |
| 348 | __ fdivp(3); |
| 349 | __ fcompp(); |
| 350 | __ fwait(); |
| 351 | __ nop(); |
| 352 | { |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 353 | if (CpuFeatures::IsSupported(SSE2)) { |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 354 | CpuFeatureScope fscope(&assm, SSE2); |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 355 | __ cvttss2si(edx, Operand(ebx, ecx, times_4, 10000)); |
| 356 | __ cvtsi2sd(xmm1, Operand(ebx, ecx, times_4, 10000)); |
bmeurer@chromium.org | 0fdb2a6 | 2013-10-21 07:19:36 +0000 | [diff] [blame] | 357 | __ movsd(xmm1, Operand(ebx, ecx, times_4, 10000)); |
| 358 | __ movsd(Operand(ebx, ecx, times_4, 10000), xmm1); |
jkummerow@chromium.org | ef33a54 | 2013-10-28 18:03:37 +0000 | [diff] [blame] | 359 | __ movaps(xmm0, xmm1); |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 360 | // 128 bit move instructions. |
| 361 | __ movdqa(xmm0, Operand(ebx, ecx, times_4, 10000)); |
| 362 | __ movdqa(Operand(ebx, ecx, times_4, 10000), xmm0); |
| 363 | __ movdqu(xmm0, Operand(ebx, ecx, times_4, 10000)); |
| 364 | __ movdqu(Operand(ebx, ecx, times_4, 10000), xmm0); |
jkummerow@chromium.org | ef33a54 | 2013-10-28 18:03:37 +0000 | [diff] [blame] | 365 | |
| 366 | __ addsd(xmm1, xmm0); |
| 367 | __ mulsd(xmm1, xmm0); |
| 368 | __ subsd(xmm1, xmm0); |
| 369 | __ divsd(xmm1, xmm0); |
| 370 | __ ucomisd(xmm0, xmm1); |
| 371 | __ cmpltsd(xmm0, xmm1); |
| 372 | |
| 373 | __ andps(xmm0, xmm1); |
verwaest@chromium.org | 057bd50 | 2013-11-06 12:03:29 +0000 | [diff] [blame] | 374 | __ orps(xmm0, xmm1); |
jkummerow@chromium.org | ef33a54 | 2013-10-28 18:03:37 +0000 | [diff] [blame] | 375 | __ andpd(xmm0, xmm1); |
| 376 | __ psllq(xmm0, 17); |
| 377 | __ psllq(xmm0, xmm1); |
| 378 | __ psrlq(xmm0, 17); |
| 379 | __ psrlq(xmm0, xmm1); |
| 380 | __ por(xmm0, xmm1); |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 381 | } |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 382 | } |
christian.plesner.hansen@gmail.com | 9d58c2b | 2009-10-16 11:48:38 +0000 | [diff] [blame] | 383 | |
| 384 | // cmov. |
| 385 | { |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 386 | if (CpuFeatures::IsSupported(CMOV)) { |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 387 | CpuFeatureScope use_cmov(&assm, CMOV); |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 388 | __ cmov(overflow, eax, Operand(eax, 0)); |
| 389 | __ cmov(no_overflow, eax, Operand(eax, 1)); |
| 390 | __ cmov(below, eax, Operand(eax, 2)); |
| 391 | __ cmov(above_equal, eax, Operand(eax, 3)); |
| 392 | __ cmov(equal, eax, Operand(ebx, 0)); |
| 393 | __ cmov(not_equal, eax, Operand(ebx, 1)); |
| 394 | __ cmov(below_equal, eax, Operand(ebx, 2)); |
| 395 | __ cmov(above, eax, Operand(ebx, 3)); |
| 396 | __ cmov(sign, eax, Operand(ecx, 0)); |
| 397 | __ cmov(not_sign, eax, Operand(ecx, 1)); |
| 398 | __ cmov(parity_even, eax, Operand(ecx, 2)); |
| 399 | __ cmov(parity_odd, eax, Operand(ecx, 3)); |
| 400 | __ cmov(less, eax, Operand(edx, 0)); |
| 401 | __ cmov(greater_equal, eax, Operand(edx, 1)); |
| 402 | __ cmov(less_equal, eax, Operand(edx, 2)); |
| 403 | __ cmov(greater, eax, Operand(edx, 3)); |
| 404 | } |
christian.plesner.hansen@gmail.com | 9d58c2b | 2009-10-16 11:48:38 +0000 | [diff] [blame] | 405 | } |
| 406 | |
erik.corry@gmail.com | d91075f | 2011-02-10 07:45:38 +0000 | [diff] [blame] | 407 | { |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 408 | if (CpuFeatures::IsSupported(SSE2) && |
| 409 | CpuFeatures::IsSupported(SSE4_1)) { |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 410 | CpuFeatureScope scope(&assm, SSE4_1); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 411 | __ pextrd(eax, xmm0, 1); |
| 412 | __ pinsrd(xmm1, eax, 0); |
mstarzinger@chromium.org | b4968be | 2013-10-16 09:00:56 +0000 | [diff] [blame] | 413 | __ extractps(eax, xmm1, 0); |
erik.corry@gmail.com | d91075f | 2011-02-10 07:45:38 +0000 | [diff] [blame] | 414 | } |
| 415 | } |
| 416 | |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 417 | // Nop instructions |
| 418 | for (int i = 0; i < 16; i++) { |
| 419 | __ Nop(i); |
| 420 | } |
| 421 | |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 422 | __ ret(0); |
| 423 | |
| 424 | CodeDesc desc; |
| 425 | assm.GetCode(&desc); |
ulan@chromium.org | 09d7ab5 | 2013-02-25 15:50:35 +0000 | [diff] [blame] | 426 | Object* code = isolate->heap()->CreateCode( |
lrn@chromium.org | 303ada7 | 2010-10-27 09:33:13 +0000 | [diff] [blame] | 427 | desc, |
| 428 | Code::ComputeFlags(Code::STUB), |
ulan@chromium.org | 09d7ab5 | 2013-02-25 15:50:35 +0000 | [diff] [blame] | 429 | Handle<Code>())->ToObjectChecked(); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 430 | CHECK(code->IsCode()); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 431 | #ifdef OBJECT_PRINT |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 432 | Code::cast(code)->Print(); |
| 433 | byte* begin = Code::cast(code)->instruction_start(); |
| 434 | byte* end = begin + Code::cast(code)->instruction_size(); |
| 435 | disasm::Disassembler::Disassemble(stdout, begin, end); |
| 436 | #endif |
| 437 | } |
| 438 | |
| 439 | #undef __ |