OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 // Disable compilation of natives. | |
47 FLAG_disable_native_files = true; | |
48 if (env.IsEmpty()) { | |
49 env = v8::Context::New(); | |
50 } | |
51 } | |
52 | |
53 | |
54 bool DisassembleAndCompare(byte* pc, const char* compare_string) { | 43 bool DisassembleAndCompare(byte* pc, const char* compare_string) { |
55 disasm::NameConverter converter; | 44 disasm::NameConverter converter; |
56 disasm::Disassembler disasm(converter); | 45 disasm::Disassembler disasm(converter); |
57 EmbeddedVector<char, 128> disasm_buffer; | 46 EmbeddedVector<char, 128> disasm_buffer; |
58 | 47 |
59 disasm.InstructionDecode(disasm_buffer, pc); | 48 disasm.InstructionDecode(disasm_buffer, pc); |
60 | 49 |
61 if (strcmp(compare_string, disasm_buffer.start()) != 0) { | 50 if (strcmp(compare_string, disasm_buffer.start()) != 0) { |
62 fprintf(stderr, | 51 fprintf(stderr, |
63 "expected: \n" | 52 "expected: \n" |
64 "%s\n" | 53 "%s\n" |
65 "disassembled: \n" | 54 "disassembled: \n" |
66 "%s\n\n", | 55 "%s\n\n", |
67 compare_string, disasm_buffer.start()); | 56 compare_string, disasm_buffer.start()); |
68 return false; | 57 return false; |
69 } | 58 } |
70 return true; | 59 return true; |
71 } | 60 } |
72 | 61 |
73 | 62 |
74 // 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 |
75 // disassembler. Declare the variables and allocate the data structures used | 64 // disassembler. Declare the variables and allocate the data structures used |
76 // in the rest of the macros. | 65 // in the rest of the macros. |
77 #define SET_UP() \ | 66 #define SET_UP() \ |
78 InitializeVM(); \ | 67 CcTest::InitializeVM(); \ |
79 Isolate* isolate = Isolate::Current(); \ | 68 Isolate* isolate = Isolate::Current(); \ |
80 HandleScope scope(isolate); \ | 69 HandleScope scope(isolate); \ |
81 byte *buffer = reinterpret_cast<byte*>(malloc(4*1024)); \ | 70 byte *buffer = reinterpret_cast<byte*>(malloc(4*1024)); \ |
82 Assembler assm(isolate, buffer, 4*1024); \ | 71 Assembler assm(isolate, buffer, 4*1024); \ |
83 bool failure = false; | 72 bool failure = false; |
84 | 73 |
85 | 74 |
86 // This macro assembles one instruction using the preallocated assembler and | 75 // This macro assembles one instruction using the preallocated assembler and |
87 // disassembles the generated instruction, comparing the output to the expected | 76 // disassembles the generated instruction, comparing the output to the expected |
88 // 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 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 COMPARE(ext_(a0, a1, 31, 1), | 422 COMPARE(ext_(a0, a1, 31, 1), |
434 "7ca407c0 ext a0, a1, 31, 1"); | 423 "7ca407c0 ext a0, a1, 31, 1"); |
435 COMPARE(ext_(s6, s7, 30, 2), | 424 COMPARE(ext_(s6, s7, 30, 2), |
436 "7ef60f80 ext s6, s7, 30, 2"); | 425 "7ef60f80 ext s6, s7, 30, 2"); |
437 COMPARE(ext_(v0, v1, 0, 32), | 426 COMPARE(ext_(v0, v1, 0, 32), |
438 "7c62f800 ext v0, v1, 0, 32"); | 427 "7c62f800 ext v0, v1, 0, 32"); |
439 } | 428 } |
440 | 429 |
441 VERIFY_RUN(); | 430 VERIFY_RUN(); |
442 } | 431 } |
OLD | NEW |