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