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 10 matching lines...) Expand all Loading... |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #include <stdlib.h> | 28 #include <stdlib.h> |
29 | 29 |
30 #include "v8.h" | 30 #include "v8.h" |
31 #include "stub-cache.h" | |
32 | 31 |
33 #include "debug.h" | 32 #include "debug.h" |
34 #include "disasm.h" | 33 #include "disasm.h" |
35 #include "disassembler.h" | 34 #include "disassembler.h" |
36 #include "macro-assembler.h" | 35 #include "macro-assembler.h" |
37 #include "serialize.h" | 36 #include "serialize.h" |
| 37 #include "stub-cache.h" |
38 #include "cctest.h" | 38 #include "cctest.h" |
39 | 39 |
40 using namespace v8::internal; | 40 using namespace v8::internal; |
41 | 41 |
42 | 42 |
43 #define __ assm. | 43 #define __ assm. |
44 | 44 |
45 | 45 |
46 static void DummyStaticFunction(Object* result) { | 46 static void DummyStaticFunction(Object* result) { |
47 } | 47 } |
48 | 48 |
49 | 49 |
50 TEST(DisasmIa320) { | 50 TEST(DisasmIa320) { |
51 CcTest::InitializeVM(); | 51 CcTest::InitializeVM(); |
52 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::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 __ adc(eax, 12345678); | 59 __ adc(eax, 12345678); |
60 __ add(eax, Immediate(12345678)); | 60 __ add(eax, Immediate(12345678)); |
61 __ or_(eax, 12345678); | 61 __ or_(eax, 12345678); |
62 __ sub(eax, Immediate(12345678)); | 62 __ sub(eax, Immediate(12345678)); |
63 __ xor_(eax, 12345678); | 63 __ xor_(eax, 12345678); |
64 __ and_(eax, 12345678); | 64 __ and_(eax, 12345678); |
65 Handle<FixedArray> foo = isolate->factory()->NewFixedArray(10, TENURED); | 65 Handle<FixedArray> foo = isolate->factory()->NewFixedArray(10, TENURED); |
66 __ cmp(eax, foo); | 66 __ cmp(eax, foo); |
67 | 67 |
68 // ---- This one caused crash | 68 // ---- This one caused crash |
69 __ mov(ebx, Operand(esp, ecx, times_2, 0)); // [esp+ecx*4] | 69 __ mov(ebx, Operand(esp, ecx, times_2, 0)); // [esp+ecx*4] |
70 | 70 |
71 // ---- All instructions that I can think of | 71 // ---- All instructions that I can think of |
72 __ add(edx, ebx); | 72 __ add(edx, ebx); |
73 __ add(edx, Operand(12, RelocInfo::NONE32)); | 73 __ add(edx, Operand(12, RelocInfo::NONE32)); |
74 __ add(edx, Operand(ebx, 0)); | 74 __ add(edx, Operand(ebx, 0)); |
75 __ add(edx, Operand(ebx, 16)); | 75 __ add(edx, Operand(ebx, 16)); |
76 __ add(edx, Operand(ebx, 1999)); | 76 __ add(edx, Operand(ebx, 1999)); |
| 77 __ add(edx, Operand(ebx, -4)); |
| 78 __ add(edx, Operand(ebx, -1999)); |
77 __ add(edx, Operand(esp, 0)); | 79 __ add(edx, Operand(esp, 0)); |
78 __ add(edx, Operand(esp, 16)); | 80 __ add(edx, Operand(esp, 16)); |
79 __ add(edx, Operand(esp, 1999)); | 81 __ add(edx, Operand(esp, 1999)); |
| 82 __ add(edx, Operand(esp, -4)); |
| 83 __ add(edx, Operand(esp, -1999)); |
| 84 __ nop(); |
| 85 __ add(esi, Operand(ecx, times_4, 0)); |
| 86 __ add(esi, Operand(ecx, times_4, 24)); |
| 87 __ add(esi, Operand(ecx, times_4, -4)); |
| 88 __ add(esi, Operand(ecx, times_4, -1999)); |
80 __ nop(); | 89 __ nop(); |
81 __ add(edi, Operand(ebp, ecx, times_4, 0)); | 90 __ add(edi, Operand(ebp, ecx, times_4, 0)); |
82 __ add(edi, Operand(ebp, ecx, times_4, 12)); | 91 __ add(edi, Operand(ebp, ecx, times_4, 12)); |
| 92 __ add(edi, Operand(ebp, ecx, times_4, -8)); |
| 93 __ add(edi, Operand(ebp, ecx, times_4, -3999)); |
83 __ add(Operand(ebp, ecx, times_4, 12), Immediate(12)); | 94 __ add(Operand(ebp, ecx, times_4, 12), Immediate(12)); |
84 | 95 |
85 __ nop(); | 96 __ nop(); |
86 __ add(ebx, Immediate(12)); | 97 __ add(ebx, Immediate(12)); |
87 __ nop(); | 98 __ nop(); |
88 __ adc(ecx, 12); | 99 __ adc(ecx, 12); |
89 __ adc(ecx, 1000); | 100 __ adc(ecx, 1000); |
90 __ nop(); | 101 __ nop(); |
91 __ and_(edx, 3); | 102 __ and_(edx, 3); |
92 __ and_(edx, Operand(esp, 4)); | 103 __ and_(edx, Operand(esp, 4)); |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 CHECK(code->IsCode()); | 469 CHECK(code->IsCode()); |
459 #ifdef OBJECT_PRINT | 470 #ifdef OBJECT_PRINT |
460 Code::cast(code)->Print(); | 471 Code::cast(code)->Print(); |
461 byte* begin = Code::cast(code)->instruction_start(); | 472 byte* begin = Code::cast(code)->instruction_start(); |
462 byte* end = begin + Code::cast(code)->instruction_size(); | 473 byte* end = begin + Code::cast(code)->instruction_size(); |
463 disasm::Disassembler::Disassemble(stdout, begin, end); | 474 disasm::Disassembler::Disassemble(stdout, begin, end); |
464 #endif | 475 #endif |
465 } | 476 } |
466 | 477 |
467 #undef __ | 478 #undef __ |
OLD | NEW |