| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 TEST(DisasmX64) { | 50 TEST(DisasmX64) { |
| 51 CcTest::InitializeVM(); | 51 CcTest::InitializeVM(); |
| 52 Isolate* isolate = CcTest::i_isolate(); | 52 Isolate* isolate = CcTest::i_isolate(); |
| 53 HandleScope scope(isolate); | 53 HandleScope scope(isolate); |
| 54 v8::internal::byte buffer[2048]; | 54 v8::internal::byte buffer[2048]; |
| 55 Assembler assm(isolate, buffer, sizeof buffer); | 55 Assembler assm(isolate, buffer, sizeof buffer); |
| 56 DummyStaticFunction(NULL); // just bloody use it (DELETE; debugging) | 56 DummyStaticFunction(NULL); // just bloody use it (DELETE; debugging) |
| 57 | 57 |
| 58 // Short immediate instructions | 58 // Short immediate instructions |
| 59 __ addq(rax, Immediate(12345678)); | 59 __ addq(rax, Immediate(12345678)); |
| 60 __ or_(rax, Immediate(12345678)); | 60 __ orq(rax, Immediate(12345678)); |
| 61 __ subq(rax, Immediate(12345678)); | 61 __ subq(rax, Immediate(12345678)); |
| 62 __ xor_(rax, Immediate(12345678)); | 62 __ xorq(rax, Immediate(12345678)); |
| 63 __ and_(rax, Immediate(12345678)); | 63 __ andq(rax, Immediate(12345678)); |
| 64 | 64 |
| 65 // ---- This one caused crash | 65 // ---- This one caused crash |
| 66 __ movq(rbx, Operand(rsp, rcx, times_2, 0)); // [rsp+rcx*4] | 66 __ movq(rbx, Operand(rsp, rcx, times_2, 0)); // [rsp+rcx*4] |
| 67 | 67 |
| 68 // ---- All instructions that I can think of | 68 // ---- All instructions that I can think of |
| 69 __ addq(rdx, rbx); | 69 __ addq(rdx, rbx); |
| 70 __ addq(rdx, Operand(rbx, 0)); | 70 __ addq(rdx, Operand(rbx, 0)); |
| 71 __ addq(rdx, Operand(rbx, 16)); | 71 __ addq(rdx, Operand(rbx, 16)); |
| 72 __ addq(rdx, Operand(rbx, 1999)); | 72 __ addq(rdx, Operand(rbx, 1999)); |
| 73 __ addq(rdx, Operand(rbx, -4)); | 73 __ addq(rdx, Operand(rbx, -4)); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 86 __ addq(rdi, Operand(rbp, rcx, times_4, 0)); | 86 __ addq(rdi, Operand(rbp, rcx, times_4, 0)); |
| 87 __ addq(rdi, Operand(rbp, rcx, times_4, 12)); | 87 __ addq(rdi, Operand(rbp, rcx, times_4, 12)); |
| 88 __ addq(rdi, Operand(rbp, rcx, times_4, -8)); | 88 __ addq(rdi, Operand(rbp, rcx, times_4, -8)); |
| 89 __ addq(rdi, Operand(rbp, rcx, times_4, -3999)); | 89 __ addq(rdi, Operand(rbp, rcx, times_4, -3999)); |
| 90 __ addq(Operand(rbp, rcx, times_4, 12), Immediate(12)); | 90 __ addq(Operand(rbp, rcx, times_4, 12), Immediate(12)); |
| 91 | 91 |
| 92 __ nop(); | 92 __ nop(); |
| 93 __ addq(rbx, Immediate(12)); | 93 __ addq(rbx, Immediate(12)); |
| 94 __ nop(); | 94 __ nop(); |
| 95 __ nop(); | 95 __ nop(); |
| 96 __ and_(rdx, Immediate(3)); | 96 __ andq(rdx, Immediate(3)); |
| 97 __ and_(rdx, Operand(rsp, 4)); | 97 __ andq(rdx, Operand(rsp, 4)); |
| 98 __ cmpq(rdx, Immediate(3)); | 98 __ cmpq(rdx, Immediate(3)); |
| 99 __ cmpq(rdx, Operand(rsp, 4)); | 99 __ cmpq(rdx, Operand(rsp, 4)); |
| 100 __ cmpq(Operand(rbp, rcx, times_4, 0), Immediate(1000)); | 100 __ cmpq(Operand(rbp, rcx, times_4, 0), Immediate(1000)); |
| 101 __ cmpb(rbx, Operand(rbp, rcx, times_2, 0)); | 101 __ cmpb(rbx, Operand(rbp, rcx, times_2, 0)); |
| 102 __ cmpb(Operand(rbp, rcx, times_2, 0), rbx); | 102 __ cmpb(Operand(rbp, rcx, times_2, 0), rbx); |
| 103 __ or_(rdx, Immediate(3)); | 103 __ orq(rdx, Immediate(3)); |
| 104 __ xor_(rdx, Immediate(3)); | 104 __ xorq(rdx, Immediate(3)); |
| 105 __ nop(); | 105 __ nop(); |
| 106 __ cpuid(); | 106 __ cpuid(); |
| 107 __ movsxbq(rdx, Operand(rcx, 0)); | 107 __ movsxbq(rdx, Operand(rcx, 0)); |
| 108 __ movsxwq(rdx, Operand(rcx, 0)); | 108 __ movsxwq(rdx, Operand(rcx, 0)); |
| 109 __ movzxbl(rdx, Operand(rcx, 0)); | 109 __ movzxbl(rdx, Operand(rcx, 0)); |
| 110 __ movzxwl(rdx, Operand(rcx, 0)); | 110 __ movzxwl(rdx, Operand(rcx, 0)); |
| 111 __ movzxbq(rdx, Operand(rcx, 0)); | 111 __ movzxbq(rdx, Operand(rcx, 0)); |
| 112 __ movzxwq(rdx, Operand(rcx, 0)); | 112 __ movzxwq(rdx, Operand(rcx, 0)); |
| 113 | 113 |
| 114 __ nop(); | 114 __ nop(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 __ decb(rdx); | 152 __ decb(rdx); |
| 153 __ decb(Operand(rax, 10)); | 153 __ decb(Operand(rax, 10)); |
| 154 __ decb(Operand(rbx, rcx, times_4, 10000)); | 154 __ decb(Operand(rbx, rcx, times_4, 10000)); |
| 155 __ decq(rdx); | 155 __ decq(rdx); |
| 156 __ cdq(); | 156 __ cdq(); |
| 157 | 157 |
| 158 __ nop(); | 158 __ nop(); |
| 159 __ idivq(rdx); | 159 __ idivq(rdx); |
| 160 __ mul(rdx); | 160 __ mul(rdx); |
| 161 __ negq(rdx); | 161 __ negq(rdx); |
| 162 __ not_(rdx); | 162 __ notq(rdx); |
| 163 __ testq(Operand(rbx, rcx, times_4, 10000), rdx); | 163 __ testq(Operand(rbx, rcx, times_4, 10000), rdx); |
| 164 | 164 |
| 165 __ imulq(rdx, Operand(rbx, rcx, times_4, 10000)); | 165 __ imulq(rdx, Operand(rbx, rcx, times_4, 10000)); |
| 166 __ imulq(rdx, rcx, Immediate(12)); | 166 __ imulq(rdx, rcx, Immediate(12)); |
| 167 __ imulq(rdx, rcx, Immediate(1000)); | 167 __ imulq(rdx, rcx, Immediate(1000)); |
| 168 | 168 |
| 169 __ incq(rdx); | 169 __ incq(rdx); |
| 170 __ incq(Operand(rbx, rcx, times_4, 10000)); | 170 __ incq(Operand(rbx, rcx, times_4, 10000)); |
| 171 __ pushq(Operand(rbx, rcx, times_4, 10000)); | 171 __ pushq(Operand(rbx, rcx, times_4, 10000)); |
| 172 __ popq(Operand(rbx, rcx, times_4, 10000)); | 172 __ popq(Operand(rbx, rcx, times_4, 10000)); |
| 173 // TODO(mstarzinger): The following is protected. | 173 // TODO(mstarzinger): The following is protected. |
| 174 // __ jmp(Operand(rbx, rcx, times_4, 10000)); | 174 // __ jmp(Operand(rbx, rcx, times_4, 10000)); |
| 175 | 175 |
| 176 __ leaq(rdx, Operand(rbx, rcx, times_4, 10000)); | 176 __ leaq(rdx, Operand(rbx, rcx, times_4, 10000)); |
| 177 __ or_(rdx, Immediate(12345)); | 177 __ orq(rdx, Immediate(12345)); |
| 178 __ or_(rdx, Operand(rbx, rcx, times_4, 10000)); | 178 __ orq(rdx, Operand(rbx, rcx, times_4, 10000)); |
| 179 | 179 |
| 180 __ nop(); | 180 __ nop(); |
| 181 | 181 |
| 182 __ rcl(rdx, Immediate(1)); | 182 __ rcl(rdx, Immediate(1)); |
| 183 __ rcl(rdx, Immediate(7)); | 183 __ rcl(rdx, Immediate(7)); |
| 184 __ rcr(rdx, Immediate(1)); | 184 __ rcr(rdx, Immediate(1)); |
| 185 __ rcr(rdx, Immediate(7)); | 185 __ rcr(rdx, Immediate(7)); |
| 186 __ sar(rdx, Immediate(1)); | 186 __ sar(rdx, Immediate(1)); |
| 187 __ sar(rdx, Immediate(6)); | 187 __ sar(rdx, Immediate(6)); |
| 188 __ sar_cl(rdx); | 188 __ sar_cl(rdx); |
| 189 __ sbbq(rdx, rbx); | 189 __ sbbq(rdx, rbx); |
| 190 __ shld(rdx, rbx); | 190 __ shld(rdx, rbx); |
| 191 __ shl(rdx, Immediate(1)); | 191 __ shl(rdx, Immediate(1)); |
| 192 __ shl(rdx, Immediate(6)); | 192 __ shl(rdx, Immediate(6)); |
| 193 __ shl_cl(rdx); | 193 __ shl_cl(rdx); |
| 194 __ shrd(rdx, rbx); | 194 __ shrd(rdx, rbx); |
| 195 __ shr(rdx, Immediate(1)); | 195 __ shr(rdx, Immediate(1)); |
| 196 __ shr(rdx, Immediate(7)); | 196 __ shr(rdx, Immediate(7)); |
| 197 __ shr_cl(rdx); | 197 __ shr_cl(rdx); |
| 198 | 198 |
| 199 | 199 |
| 200 // Immediates | 200 // Immediates |
| 201 | 201 |
| 202 __ addq(rbx, Immediate(12)); | 202 __ addq(rbx, Immediate(12)); |
| 203 __ addq(Operand(rdx, rcx, times_4, 10000), Immediate(12)); | 203 __ addq(Operand(rdx, rcx, times_4, 10000), Immediate(12)); |
| 204 | 204 |
| 205 __ and_(rbx, Immediate(12345)); | 205 __ andq(rbx, Immediate(12345)); |
| 206 | 206 |
| 207 __ cmpq(rbx, Immediate(12345)); | 207 __ cmpq(rbx, Immediate(12345)); |
| 208 __ cmpq(rbx, Immediate(12)); | 208 __ cmpq(rbx, Immediate(12)); |
| 209 __ cmpq(Operand(rdx, rcx, times_4, 10000), Immediate(12)); | 209 __ cmpq(Operand(rdx, rcx, times_4, 10000), Immediate(12)); |
| 210 __ cmpb(rax, Immediate(100)); | 210 __ cmpb(rax, Immediate(100)); |
| 211 | 211 |
| 212 __ or_(rbx, Immediate(12345)); | 212 __ orq(rbx, Immediate(12345)); |
| 213 | 213 |
| 214 __ subq(rbx, Immediate(12)); | 214 __ subq(rbx, Immediate(12)); |
| 215 __ subq(Operand(rdx, rcx, times_4, 10000), Immediate(12)); | 215 __ subq(Operand(rdx, rcx, times_4, 10000), Immediate(12)); |
| 216 | 216 |
| 217 __ xor_(rbx, Immediate(12345)); | 217 __ xorq(rbx, Immediate(12345)); |
| 218 | 218 |
| 219 __ imulq(rdx, rcx, Immediate(12)); | 219 __ imulq(rdx, rcx, Immediate(12)); |
| 220 __ imulq(rdx, rcx, Immediate(1000)); | 220 __ imulq(rdx, rcx, Immediate(1000)); |
| 221 | 221 |
| 222 __ cld(); | 222 __ cld(); |
| 223 | 223 |
| 224 __ subq(rdx, Operand(rbx, rcx, times_4, 10000)); | 224 __ subq(rdx, Operand(rbx, rcx, times_4, 10000)); |
| 225 __ subq(rdx, rbx); | 225 __ subq(rdx, rbx); |
| 226 | 226 |
| 227 __ testq(rdx, Immediate(12345)); | 227 __ testq(rdx, Immediate(12345)); |
| 228 __ testq(Operand(rbx, rcx, times_8, 10000), rdx); | 228 __ testq(Operand(rbx, rcx, times_8, 10000), rdx); |
| 229 __ testb(Operand(rcx, rbx, times_2, 1000), rdx); | 229 __ testb(Operand(rcx, rbx, times_2, 1000), rdx); |
| 230 __ testb(Operand(rax, -20), Immediate(0x9A)); | 230 __ testb(Operand(rax, -20), Immediate(0x9A)); |
| 231 __ nop(); | 231 __ nop(); |
| 232 | 232 |
| 233 __ xor_(rdx, Immediate(12345)); | 233 __ xorq(rdx, Immediate(12345)); |
| 234 __ xor_(rdx, Operand(rbx, rcx, times_8, 10000)); | 234 __ xorq(rdx, Operand(rbx, rcx, times_8, 10000)); |
| 235 __ bts(Operand(rbx, rcx, times_8, 10000), rdx); | 235 __ bts(Operand(rbx, rcx, times_8, 10000), rdx); |
| 236 __ hlt(); | 236 __ hlt(); |
| 237 __ int3(); | 237 __ int3(); |
| 238 __ ret(0); | 238 __ ret(0); |
| 239 __ ret(8); | 239 __ ret(8); |
| 240 | 240 |
| 241 // Calls | 241 // Calls |
| 242 | 242 |
| 243 Label L1, L2; | 243 Label L1, L2; |
| 244 __ bind(&L1); | 244 __ bind(&L1); |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 CHECK(code->IsCode()); | 436 CHECK(code->IsCode()); |
| 437 #ifdef OBJECT_PRINT | 437 #ifdef OBJECT_PRINT |
| 438 Code::cast(code)->Print(); | 438 Code::cast(code)->Print(); |
| 439 byte* begin = Code::cast(code)->instruction_start(); | 439 byte* begin = Code::cast(code)->instruction_start(); |
| 440 byte* end = begin + Code::cast(code)->instruction_size(); | 440 byte* end = begin + Code::cast(code)->instruction_size(); |
| 441 disasm::Disassembler::Disassemble(stdout, begin, end); | 441 disasm::Disassembler::Disassemble(stdout, begin, end); |
| 442 #endif | 442 #endif |
| 443 } | 443 } |
| 444 | 444 |
| 445 #undef __ | 445 #undef __ |
| OLD | NEW |