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 22 matching lines...) Expand all Loading... |
33 #include "debug.h" | 33 #include "debug.h" |
34 #include "disasm.h" | 34 #include "disasm.h" |
35 #include "disassembler.h" | 35 #include "disassembler.h" |
36 #include "macro-assembler.h" | 36 #include "macro-assembler.h" |
37 #include "serialize.h" | 37 #include "serialize.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 static v8::Persistent<v8::Context> env; | |
44 | |
45 static void InitializeVM() { | |
46 if (env.IsEmpty()) { | |
47 env = v8::Context::New(); | |
48 } | |
49 } | |
50 | |
51 | |
52 bool DisassembleAndCompare(byte* pc, const char* compare_string) { | 43 bool DisassembleAndCompare(byte* pc, const char* compare_string) { |
53 disasm::NameConverter converter; | 44 disasm::NameConverter converter; |
54 disasm::Disassembler disasm(converter); | 45 disasm::Disassembler disasm(converter); |
55 EmbeddedVector<char, 128> disasm_buffer; | 46 EmbeddedVector<char, 128> disasm_buffer; |
56 | 47 |
57 disasm.InstructionDecode(disasm_buffer, pc); | 48 disasm.InstructionDecode(disasm_buffer, pc); |
58 | 49 |
59 if (strcmp(compare_string, disasm_buffer.start()) != 0) { | 50 if (strcmp(compare_string, disasm_buffer.start()) != 0) { |
60 fprintf(stderr, | 51 fprintf(stderr, |
61 "expected: \n" | 52 "expected: \n" |
62 "%s\n" | 53 "%s\n" |
63 "disassembled: \n" | 54 "disassembled: \n" |
64 "%s\n\n", | 55 "%s\n\n", |
65 compare_string, disasm_buffer.start()); | 56 compare_string, disasm_buffer.start()); |
66 return false; | 57 return false; |
67 } | 58 } |
68 return true; | 59 return true; |
69 } | 60 } |
70 | 61 |
71 | 62 |
72 // Set up V8 to a state where we can at least run the assembler and | 63 // Set up V8 to a state where we can at least run the assembler and |
73 // disassembler. Declare the variables and allocate the data structures used | 64 // disassembler. Declare the variables and allocate the data structures used |
74 // in the rest of the macros. | 65 // in the rest of the macros. |
75 #define SET_UP() \ | 66 #define SET_UP() \ |
76 InitializeVM(); \ | 67 CcTest::InitializeVM(); \ |
77 Isolate* isolate = Isolate::Current(); \ | 68 Isolate* isolate = Isolate::Current(); \ |
78 HandleScope scope(isolate); \ | 69 HandleScope scope(isolate); \ |
79 byte *buffer = reinterpret_cast<byte*>(malloc(4*1024)); \ | 70 byte *buffer = reinterpret_cast<byte*>(malloc(4*1024)); \ |
80 Assembler assm(isolate, buffer, 4*1024); \ | 71 Assembler assm(isolate, buffer, 4*1024); \ |
81 bool failure = false; | 72 bool failure = false; |
82 | 73 |
83 | 74 |
84 // This macro assembles one instruction using the preallocated assembler and | 75 // This macro assembles one instruction using the preallocated assembler and |
85 // disassembles the generated instruction, comparing the output to the expected | 76 // disassembles the generated instruction, comparing the output to the expected |
86 // value. If the comparison fails an error message is printed, but the test | 77 // value. If the comparison fails an error message is printed, but the test |
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
862 COMPARE(strd(r8, r9, MemOperand(r9, -127, PostIndex)), | 853 COMPARE(strd(r8, r9, MemOperand(r9, -127, PostIndex)), |
863 "e04987ff strd r8, [r9], #-127"); | 854 "e04987ff strd r8, [r9], #-127"); |
864 COMPARE(strd(r10, fp, MemOperand(fp, 127, PreIndex)), | 855 COMPARE(strd(r10, fp, MemOperand(fp, 127, PreIndex)), |
865 "e1eba7ff strd r10, [fp, #+127]!"); | 856 "e1eba7ff strd r10, [fp, #+127]!"); |
866 COMPARE(strd(ip, sp, MemOperand(sp, -127, PreIndex)), | 857 COMPARE(strd(ip, sp, MemOperand(sp, -127, PreIndex)), |
867 "e16dc7ff strd ip, [sp, #-127]!"); | 858 "e16dc7ff strd ip, [sp, #-127]!"); |
868 } | 859 } |
869 | 860 |
870 VERIFY_RUN(); | 861 VERIFY_RUN(); |
871 } | 862 } |
OLD | NEW |