OLD | NEW |
1 // Copyright 2007-2008 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 |
11 // with the distribution. | 11 // with the distribution. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 | 56 |
57 TEST(DisasmIa320) { | 57 TEST(DisasmIa320) { |
58 InitializeVM(); | 58 InitializeVM(); |
59 v8::HandleScope scope; | 59 v8::HandleScope scope; |
60 v8::internal::byte buffer[2048]; | 60 v8::internal::byte buffer[2048]; |
61 Assembler assm(Isolate::Current(), buffer, sizeof buffer); | 61 Assembler assm(Isolate::Current(), buffer, sizeof buffer); |
62 DummyStaticFunction(NULL); // just bloody use it (DELETE; debugging) | 62 DummyStaticFunction(NULL); // just bloody use it (DELETE; debugging) |
63 | 63 |
64 // Short immediate instructions | 64 // Short immediate instructions |
65 __ adc(eax, 12345678); | 65 __ adc(eax, 12345678); |
66 __ add(Operand(eax), Immediate(12345678)); | 66 __ add(eax, Immediate(12345678)); |
67 __ or_(eax, 12345678); | 67 __ or_(eax, 12345678); |
68 __ sub(Operand(eax), Immediate(12345678)); | 68 __ sub(eax, Immediate(12345678)); |
69 __ xor_(eax, 12345678); | 69 __ xor_(eax, 12345678); |
70 __ and_(eax, 12345678); | 70 __ and_(eax, 12345678); |
71 Handle<FixedArray> foo = FACTORY->NewFixedArray(10, TENURED); | 71 Handle<FixedArray> foo = FACTORY->NewFixedArray(10, TENURED); |
72 __ cmp(eax, foo); | 72 __ cmp(eax, foo); |
73 | 73 |
74 // ---- This one caused crash | 74 // ---- This one caused crash |
75 __ mov(ebx, Operand(esp, ecx, times_2, 0)); // [esp+ecx*4] | 75 __ mov(ebx, Operand(esp, ecx, times_2, 0)); // [esp+ecx*4] |
76 | 76 |
77 // ---- All instructions that I can think of | 77 // ---- All instructions that I can think of |
78 __ add(edx, Operand(ebx)); | 78 __ add(edx, ebx); |
79 __ add(edx, Operand(12, RelocInfo::NONE)); | 79 __ add(edx, Operand(12, RelocInfo::NONE)); |
80 __ add(edx, Operand(ebx, 0)); | 80 __ add(edx, Operand(ebx, 0)); |
81 __ add(edx, Operand(ebx, 16)); | 81 __ add(edx, Operand(ebx, 16)); |
82 __ add(edx, Operand(ebx, 1999)); | 82 __ add(edx, Operand(ebx, 1999)); |
83 __ add(edx, Operand(esp, 0)); | 83 __ add(edx, Operand(esp, 0)); |
84 __ add(edx, Operand(esp, 16)); | 84 __ add(edx, Operand(esp, 16)); |
85 __ add(edx, Operand(esp, 1999)); | 85 __ add(edx, Operand(esp, 1999)); |
86 __ nop(); | 86 __ nop(); |
87 __ add(edi, Operand(ebp, ecx, times_4, 0)); | 87 __ add(edi, Operand(ebp, ecx, times_4, 0)); |
88 __ add(edi, Operand(ebp, ecx, times_4, 12)); | 88 __ add(edi, Operand(ebp, ecx, times_4, 12)); |
89 __ add(Operand(ebp, ecx, times_4, 12), Immediate(12)); | 89 __ add(Operand(ebp, ecx, times_4, 12), Immediate(12)); |
90 | 90 |
91 __ nop(); | 91 __ nop(); |
92 __ add(Operand(ebx), Immediate(12)); | 92 __ add(ebx, Immediate(12)); |
93 __ nop(); | 93 __ nop(); |
94 __ adc(ecx, 12); | 94 __ adc(ecx, 12); |
95 __ adc(ecx, 1000); | 95 __ adc(ecx, 1000); |
96 __ nop(); | 96 __ nop(); |
97 __ and_(edx, 3); | 97 __ and_(edx, 3); |
98 __ and_(edx, Operand(esp, 4)); | 98 __ and_(edx, Operand(esp, 4)); |
99 __ cmp(edx, 3); | 99 __ cmp(edx, 3); |
100 __ cmp(edx, Operand(esp, 4)); | 100 __ cmp(edx, Operand(esp, 4)); |
101 __ cmp(Operand(ebp, ecx, times_4, 0), Immediate(1000)); | 101 __ cmp(Operand(ebp, ecx, times_4, 0), Immediate(1000)); |
102 Handle<FixedArray> foo2 = FACTORY->NewFixedArray(10, TENURED); | 102 Handle<FixedArray> foo2 = FACTORY->NewFixedArray(10, TENURED); |
103 __ cmp(ebx, foo2); | 103 __ cmp(ebx, foo2); |
104 __ cmpb(ebx, Operand(ebp, ecx, times_2, 0)); | 104 __ cmpb(ebx, Operand(ebp, ecx, times_2, 0)); |
105 __ cmpb(Operand(ebp, ecx, times_2, 0), ebx); | 105 __ cmpb(Operand(ebp, ecx, times_2, 0), ebx); |
106 __ or_(edx, 3); | 106 __ or_(edx, 3); |
107 __ xor_(edx, 3); | 107 __ xor_(edx, 3); |
108 __ nop(); | 108 __ nop(); |
109 { | 109 { |
110 CHECK(CpuFeatures::IsSupported(CPUID)); | 110 CHECK(CpuFeatures::IsSupported(CPUID)); |
111 CpuFeatures::Scope fscope(CPUID); | 111 CpuFeatures::Scope fscope(CPUID); |
112 __ cpuid(); | 112 __ cpuid(); |
113 } | 113 } |
114 { | 114 { |
115 CHECK(CpuFeatures::IsSupported(RDTSC)); | 115 CHECK(CpuFeatures::IsSupported(RDTSC)); |
116 CpuFeatures::Scope fscope(RDTSC); | 116 CpuFeatures::Scope fscope(RDTSC); |
117 __ rdtsc(); | 117 __ rdtsc(); |
118 } | 118 } |
119 __ movsx_b(edx, Operand(ecx)); | 119 __ movsx_b(edx, ecx); |
120 __ movsx_w(edx, Operand(ecx)); | 120 __ movsx_w(edx, ecx); |
121 __ movzx_b(edx, Operand(ecx)); | 121 __ movzx_b(edx, ecx); |
122 __ movzx_w(edx, Operand(ecx)); | 122 __ movzx_w(edx, ecx); |
123 | 123 |
124 __ nop(); | 124 __ nop(); |
125 __ imul(edx, Operand(ecx)); | 125 __ imul(edx, ecx); |
126 __ shld(edx, Operand(ecx)); | 126 __ shld(edx, ecx); |
127 __ shrd(edx, Operand(ecx)); | 127 __ shrd(edx, ecx); |
128 __ bts(Operand(edx), ecx); | 128 __ bts(edx, ecx); |
129 __ bts(Operand(ebx, ecx, times_4, 0), ecx); | 129 __ bts(Operand(ebx, ecx, times_4, 0), ecx); |
130 __ nop(); | 130 __ nop(); |
131 __ pushad(); | 131 __ pushad(); |
132 __ popad(); | 132 __ popad(); |
133 __ pushfd(); | 133 __ pushfd(); |
134 __ popfd(); | 134 __ popfd(); |
135 __ push(Immediate(12)); | 135 __ push(Immediate(12)); |
136 __ push(Immediate(23456)); | 136 __ push(Immediate(23456)); |
137 __ push(ecx); | 137 __ push(ecx); |
138 __ push(esi); | 138 __ push(esi); |
139 __ push(Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | 139 __ push(Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
140 __ push(Operand(ebx, ecx, times_4, 0)); | 140 __ push(Operand(ebx, ecx, times_4, 0)); |
141 __ push(Operand(ebx, ecx, times_4, 0)); | 141 __ push(Operand(ebx, ecx, times_4, 0)); |
142 __ push(Operand(ebx, ecx, times_4, 10000)); | 142 __ push(Operand(ebx, ecx, times_4, 10000)); |
143 __ pop(edx); | 143 __ pop(edx); |
144 __ pop(eax); | 144 __ pop(eax); |
145 __ pop(Operand(ebx, ecx, times_4, 0)); | 145 __ pop(Operand(ebx, ecx, times_4, 0)); |
146 __ nop(); | 146 __ nop(); |
147 | 147 |
148 __ add(edx, Operand(esp, 16)); | 148 __ add(edx, Operand(esp, 16)); |
149 __ add(edx, Operand(ecx)); | 149 __ add(edx, ecx); |
150 __ mov_b(edx, Operand(ecx)); | 150 __ mov_b(edx, ecx); |
151 __ mov_b(Operand(ecx), 6); | 151 __ mov_b(ecx, 6); |
152 __ mov_b(Operand(ebx, ecx, times_4, 10000), 6); | 152 __ mov_b(Operand(ebx, ecx, times_4, 10000), 6); |
153 __ mov_b(Operand(esp, 16), edx); | 153 __ mov_b(Operand(esp, 16), edx); |
154 __ mov_w(edx, Operand(esp, 16)); | 154 __ mov_w(edx, Operand(esp, 16)); |
155 __ mov_w(Operand(esp, 16), edx); | 155 __ mov_w(Operand(esp, 16), edx); |
156 __ nop(); | 156 __ nop(); |
157 __ movsx_w(edx, Operand(esp, 12)); | 157 __ movsx_w(edx, Operand(esp, 12)); |
158 __ movsx_b(edx, Operand(esp, 12)); | 158 __ movsx_b(edx, Operand(esp, 12)); |
159 __ movzx_w(edx, Operand(esp, 12)); | 159 __ movzx_w(edx, Operand(esp, 12)); |
160 __ movzx_b(edx, Operand(esp, 12)); | 160 __ movzx_b(edx, Operand(esp, 12)); |
161 __ nop(); | 161 __ nop(); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 __ shrd(edx, Operand(ebx, ecx, times_4, 10000)); | 209 __ shrd(edx, Operand(ebx, ecx, times_4, 10000)); |
210 __ shr(edx, 1); | 210 __ shr(edx, 1); |
211 __ shr(edx, 7); | 211 __ shr(edx, 7); |
212 __ shr_cl(edx); | 212 __ shr_cl(edx); |
213 | 213 |
214 | 214 |
215 // Immediates | 215 // Immediates |
216 | 216 |
217 __ adc(edx, 12345); | 217 __ adc(edx, 12345); |
218 | 218 |
219 __ add(Operand(ebx), Immediate(12)); | 219 __ add(ebx, Immediate(12)); |
220 __ add(Operand(edx, ecx, times_4, 10000), Immediate(12)); | 220 __ add(Operand(edx, ecx, times_4, 10000), Immediate(12)); |
221 | 221 |
222 __ and_(ebx, 12345); | 222 __ and_(ebx, 12345); |
223 | 223 |
224 __ cmp(ebx, 12345); | 224 __ cmp(ebx, 12345); |
225 __ cmp(Operand(ebx), Immediate(12)); | 225 __ cmp(ebx, Immediate(12)); |
226 __ cmp(Operand(edx, ecx, times_4, 10000), Immediate(12)); | 226 __ cmp(Operand(edx, ecx, times_4, 10000), Immediate(12)); |
227 __ cmpb(Operand(eax), 100); | 227 __ cmpb(eax, 100); |
228 | 228 |
229 __ or_(ebx, 12345); | 229 __ or_(ebx, 12345); |
230 | 230 |
231 __ sub(Operand(ebx), Immediate(12)); | 231 __ sub(ebx, Immediate(12)); |
232 __ sub(Operand(edx, ecx, times_4, 10000), Immediate(12)); | 232 __ sub(Operand(edx, ecx, times_4, 10000), Immediate(12)); |
233 | 233 |
234 __ xor_(ebx, 12345); | 234 __ xor_(ebx, 12345); |
235 | 235 |
236 __ imul(edx, ecx, 12); | 236 __ imul(edx, ecx, 12); |
237 __ imul(edx, ecx, 1000); | 237 __ imul(edx, ecx, 1000); |
238 | 238 |
239 __ cld(); | 239 __ cld(); |
240 __ rep_movs(); | 240 __ rep_movs(); |
241 __ rep_stos(); | 241 __ rep_stos(); |
242 __ stos(); | 242 __ stos(); |
243 | 243 |
244 __ sub(edx, Operand(ebx, ecx, times_4, 10000)); | 244 __ sub(edx, Operand(ebx, ecx, times_4, 10000)); |
245 __ sub(edx, Operand(ebx)); | 245 __ sub(edx, ebx); |
246 | 246 |
247 __ test(edx, Immediate(12345)); | 247 __ test(edx, Immediate(12345)); |
248 __ test(edx, Operand(ebx, ecx, times_8, 10000)); | 248 __ test(edx, Operand(ebx, ecx, times_8, 10000)); |
249 __ test(Operand(esi, edi, times_1, -20000000), Immediate(300000000)); | 249 __ test(Operand(esi, edi, times_1, -20000000), Immediate(300000000)); |
250 __ test_b(edx, Operand(ecx, ebx, times_2, 1000)); | 250 __ test_b(edx, Operand(ecx, ebx, times_2, 1000)); |
251 __ test_b(Operand(eax, -20), 0x9A); | 251 __ test_b(Operand(eax, -20), 0x9A); |
252 __ nop(); | 252 __ nop(); |
253 | 253 |
254 __ xor_(edx, 12345); | 254 __ xor_(edx, 12345); |
255 __ xor_(edx, Operand(ebx, ecx, times_8, 10000)); | 255 __ xor_(edx, Operand(ebx, ecx, times_8, 10000)); |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 __ psrlq(xmm1, xmm2); | 437 __ psrlq(xmm1, xmm2); |
438 | 438 |
439 __ por(xmm0, xmm1); | 439 __ por(xmm0, xmm1); |
440 __ por(xmm1, xmm2); | 440 __ por(xmm1, xmm2); |
441 } | 441 } |
442 } | 442 } |
443 | 443 |
444 { | 444 { |
445 if (CpuFeatures::IsSupported(SSE4_1)) { | 445 if (CpuFeatures::IsSupported(SSE4_1)) { |
446 CpuFeatures::Scope scope(SSE4_1); | 446 CpuFeatures::Scope scope(SSE4_1); |
447 __ pextrd(Operand(eax), xmm0, 1); | 447 __ pextrd(eax, xmm0, 1); |
448 __ pinsrd(xmm1, Operand(eax), 0); | 448 __ pinsrd(xmm1, eax, 0); |
449 } | 449 } |
450 } | 450 } |
451 | 451 |
452 __ ret(0); | 452 __ ret(0); |
453 | 453 |
454 CodeDesc desc; | 454 CodeDesc desc; |
455 assm.GetCode(&desc); | 455 assm.GetCode(&desc); |
456 Object* code = HEAP->CreateCode( | 456 Object* code = HEAP->CreateCode( |
457 desc, | 457 desc, |
458 Code::ComputeFlags(Code::STUB), | 458 Code::ComputeFlags(Code::STUB), |
459 Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); | 459 Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); |
460 CHECK(code->IsCode()); | 460 CHECK(code->IsCode()); |
461 #ifdef OBJECT_PRINT | 461 #ifdef OBJECT_PRINT |
462 Code::cast(code)->Print(); | 462 Code::cast(code)->Print(); |
463 byte* begin = Code::cast(code)->instruction_start(); | 463 byte* begin = Code::cast(code)->instruction_start(); |
464 byte* end = begin + Code::cast(code)->instruction_size(); | 464 byte* end = begin + Code::cast(code)->instruction_size(); |
465 disasm::Disassembler::Disassemble(stdout, begin, end); | 465 disasm::Disassembler::Disassemble(stdout, begin, end); |
466 #endif | 466 #endif |
467 } | 467 } |
468 | 468 |
469 #undef __ | 469 #undef __ |
OLD | NEW |