| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 met: | 3 // modification, are permitted provided that the following conditions are met: |
| 4 // | 4 // |
| 5 // * Redistributions of source code must retain the above copyright notice, | 5 // * Redistributions of source code must retain the above copyright notice, |
| 6 // this list of conditions and the following disclaimer. | 6 // this list of conditions and the following disclaimer. |
| 7 // * Redistributions in binary form must reproduce the above copyright notice, | 7 // * Redistributions in binary form must reproduce the above copyright notice, |
| 8 // this list of conditions and the following disclaimer in the documentation | 8 // this list of conditions and the following disclaimer in the documentation |
| 9 // and/or other materials provided with the distribution. | 9 // and/or other materials provided with the distribution. |
| 10 // * Neither the name of ARM Limited nor the names of its contributors may be | 10 // * Neither the name of ARM Limited nor the names of its contributors may be |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 Decoder decoder; | 41 Decoder decoder; |
| 42 Instruction buffer[kInstructionSize]; | 42 Instruction buffer[kInstructionSize]; |
| 43 | 43 |
| 44 for (int i = 0; i < instruction_count; i++) { | 44 for (int i = 0; i < instruction_count; i++) { |
| 45 uint32_t instr = mrand48(); | 45 uint32_t instr = mrand48(); |
| 46 buffer->SetInstructionBits(instr); | 46 buffer->SetInstructionBits(instr); |
| 47 decoder.Decode(buffer); | 47 decoder.Decode(buffer); |
| 48 } | 48 } |
| 49 } | 49 } |
| 50 | 50 |
| 51 |
| 51 TEST(FUZZ_disasm) { | 52 TEST(FUZZ_disasm) { |
| 52 // Feed noise into the disassembler to check that it doesn't crash. | 53 // Feed noise into the disassembler to check that it doesn't crash. |
| 53 // 9 million = ~0.2% of the instruction space. | 54 // 9 million = ~0.2% of the instruction space. |
| 54 static const int instruction_count = 9 * 1024 * 1024; | 55 static const int instruction_count = 9 * 1024 * 1024; |
| 55 | 56 |
| 56 uint16_t seed[3] = {42, 43, 44}; | 57 uint16_t seed[3] = {42, 43, 44}; |
| 57 seed48(seed); | 58 seed48(seed); |
| 58 | 59 |
| 59 Decoder decoder; | 60 Decoder decoder; |
| 60 Disassembler disasm; | 61 Disassembler disasm; |
| 61 Instruction buffer[kInstructionSize]; | 62 Instruction buffer[kInstructionSize]; |
| 62 | 63 |
| 63 decoder.AppendVisitor(&disasm); | 64 decoder.AppendVisitor(&disasm); |
| 64 for (int i = 0; i < instruction_count; i++) { | 65 for (int i = 0; i < instruction_count; i++) { |
| 65 uint32_t instr = mrand48(); | 66 uint32_t instr = mrand48(); |
| 66 buffer->SetInstructionBits(instr); | 67 buffer->SetInstructionBits(instr); |
| 67 decoder.Decode(buffer); | 68 decoder.Decode(buffer); |
| 68 } | 69 } |
| 69 } | 70 } |
| OLD | NEW |