| OLD | NEW |
| 1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2008 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 compare_string, disasm_buffer.start()); | 65 compare_string, disasm_buffer.start()); |
| 66 return false; | 66 return false; |
| 67 } | 67 } |
| 68 return true; | 68 return true; |
| 69 } | 69 } |
| 70 | 70 |
| 71 | 71 |
| 72 // Setup V8 to a state where we can at least run the assembler and | 72 // Setup V8 to a state where we can at least run the assembler and |
| 73 // disassembler. Declare the variables and allocate the data structures used | 73 // disassembler. Declare the variables and allocate the data structures used |
| 74 // in the rest of the macros. | 74 // in the rest of the macros. |
| 75 #define SETUP() \ | 75 #define SETUP() \ |
| 76 InitializeVM(); \ | 76 InitializeVM(); \ |
| 77 v8::HandleScope scope; \ | 77 v8::HandleScope scope; \ |
| 78 byte *buffer = reinterpret_cast<byte*>(malloc(4*1024)); \ | 78 byte *buffer = reinterpret_cast<byte*>(malloc(4*1024)); \ |
| 79 Assembler assm(Isolate::Current(), buffer, 4*1024); \ | 79 Assembler assm(buffer, 4*1024); \ |
| 80 bool failure = false; | 80 bool failure = false; |
| 81 | 81 |
| 82 | 82 |
| 83 // This macro assembles one instruction using the preallocated assembler and | 83 // This macro assembles one instruction using the preallocated assembler and |
| 84 // disassembles the generated instruction, comparing the output to the expected | 84 // disassembles the generated instruction, comparing the output to the expected |
| 85 // value. If the comparison fails an error message is printed, but the test | 85 // value. If the comparison fails an error message is printed, but the test |
| 86 // continues to run until the end. | 86 // continues to run until the end. |
| 87 #define COMPARE(asm_, compare_string) \ | 87 #define COMPARE(asm_, compare_string) \ |
| 88 { \ | 88 { \ |
| 89 int pc_offset = assm.pc_offset(); \ | 89 int pc_offset = assm.pc_offset(); \ |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 COMPARE(mvn(r3, Operand(-1), LeaveCC, al), | 263 COMPARE(mvn(r3, Operand(-1), LeaveCC, al), |
| 264 "e3a03000 mov r3, #0"); | 264 "e3a03000 mov r3, #0"); |
| 265 COMPARE(mvn(r4, Operand(-2), SetCC, al), | 265 COMPARE(mvn(r4, Operand(-2), SetCC, al), |
| 266 "e3b04001 movs r4, #1"); | 266 "e3b04001 movs r4, #1"); |
| 267 COMPARE(mvn(r5, Operand(0x0ffffff0), SetCC, ne), | 267 COMPARE(mvn(r5, Operand(0x0ffffff0), SetCC, ne), |
| 268 "13b052ff movnes r5, #-268435441"); | 268 "13b052ff movnes r5, #-268435441"); |
| 269 COMPARE(mvn(r6, Operand(-1), LeaveCC, ne), | 269 COMPARE(mvn(r6, Operand(-1), LeaveCC, ne), |
| 270 "13a06000 movne r6, #0"); | 270 "13a06000 movne r6, #0"); |
| 271 | 271 |
| 272 // mov -> movw. | 272 // mov -> movw. |
| 273 if (CpuFeatures::IsSupported(ARMv7)) { | 273 if (Isolate::Current()->cpu_features()->IsSupported(ARMv7)) { |
| 274 COMPARE(mov(r5, Operand(0x01234), LeaveCC, ne), | 274 COMPARE(mov(r5, Operand(0x01234), LeaveCC, ne), |
| 275 "13015234 movwne r5, #4660"); | 275 "13015234 movwne r5, #4660"); |
| 276 // We only disassemble one instruction so the eor instruction is not here. | 276 // We only disassemble one instruction so the eor instruction is not here. |
| 277 COMPARE(eor(r5, r4, Operand(0x1234), LeaveCC, ne), | 277 COMPARE(eor(r5, r4, Operand(0x1234), LeaveCC, ne), |
| 278 "1301c234 movwne ip, #4660"); | 278 "1301c234 movwne ip, #4660"); |
| 279 // Movw can't do setcc so we don't get that here. Mov immediate with setcc | 279 // Movw can't do setcc so we don't get that here. Mov immediate with setcc |
| 280 // is pretty strange anyway. | 280 // is pretty strange anyway. |
| 281 COMPARE(mov(r5, Operand(0x01234), SetCC, ne), | 281 COMPARE(mov(r5, Operand(0x01234), SetCC, ne), |
| 282 "159fc000 ldrne ip, [pc, #+0]"); | 282 "159fc000 ldrne ip, [pc, #+0]"); |
| 283 // We only disassemble one instruction so the eor instruction is not here. | 283 // We only disassemble one instruction so the eor instruction is not here. |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 COMPARE(eor(r4, r1, Operand(0x10000000), SetCC, cc), | 353 COMPARE(eor(r4, r1, Operand(0x10000000), SetCC, cc), |
| 354 "32314201 eorccs r4, r1, #268435456"); | 354 "32314201 eorccs r4, r1, #268435456"); |
| 355 | 355 |
| 356 VERIFY_RUN(); | 356 VERIFY_RUN(); |
| 357 } | 357 } |
| 358 | 358 |
| 359 | 359 |
| 360 TEST(Type3) { | 360 TEST(Type3) { |
| 361 SETUP(); | 361 SETUP(); |
| 362 | 362 |
| 363 if (CpuFeatures::IsSupported(ARMv7)) { | 363 if (Isolate::Current()->cpu_features()->IsSupported(ARMv7)) { |
| 364 COMPARE(ubfx(r0, r1, 5, 10), | 364 COMPARE(ubfx(r0, r1, 5, 10), |
| 365 "e7e902d1 ubfx r0, r1, #5, #10"); | 365 "e7e902d1 ubfx r0, r1, #5, #10"); |
| 366 COMPARE(ubfx(r1, r0, 5, 10), | 366 COMPARE(ubfx(r1, r0, 5, 10), |
| 367 "e7e912d0 ubfx r1, r0, #5, #10"); | 367 "e7e912d0 ubfx r1, r0, #5, #10"); |
| 368 COMPARE(ubfx(r0, r1, 31, 1), | 368 COMPARE(ubfx(r0, r1, 31, 1), |
| 369 "e7e00fd1 ubfx r0, r1, #31, #1"); | 369 "e7e00fd1 ubfx r0, r1, #31, #1"); |
| 370 COMPARE(ubfx(r1, r0, 31, 1), | 370 COMPARE(ubfx(r1, r0, 31, 1), |
| 371 "e7e01fd0 ubfx r1, r0, #31, #1"); | 371 "e7e01fd0 ubfx r1, r0, #31, #1"); |
| 372 | 372 |
| 373 COMPARE(sbfx(r0, r1, 5, 10), | 373 COMPARE(sbfx(r0, r1, 5, 10), |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 } | 408 } |
| 409 | 409 |
| 410 VERIFY_RUN(); | 410 VERIFY_RUN(); |
| 411 } | 411 } |
| 412 | 412 |
| 413 | 413 |
| 414 | 414 |
| 415 TEST(Vfp) { | 415 TEST(Vfp) { |
| 416 SETUP(); | 416 SETUP(); |
| 417 | 417 |
| 418 if (CpuFeatures::IsSupported(VFP3)) { | 418 if (Isolate::Current()->cpu_features()->IsSupported(VFP3)) { |
| 419 CpuFeatures::Scope scope(VFP3); | 419 CpuFeatures::Scope scope(VFP3); |
| 420 COMPARE(vmov(d0, d1), | 420 COMPARE(vmov(d0, d1), |
| 421 "eeb00b41 vmov.f64 d0, d1"); | 421 "eeb00b41 vmov.f64 d0, d1"); |
| 422 COMPARE(vmov(d3, d3, eq), | 422 COMPARE(vmov(d3, d3, eq), |
| 423 "0eb03b43 vmov.f64eq d3, d3"); | 423 "0eb03b43 vmov.f64eq d3, d3"); |
| 424 | 424 |
| 425 COMPARE(vmov(s0, s31), | 425 COMPARE(vmov(s0, s31), |
| 426 "eeb00a6f vmov.f32 s0, s31"); | 426 "eeb00a6f vmov.f32 s0, s31"); |
| 427 COMPARE(vmov(s31, s0), | 427 COMPARE(vmov(s31, s0), |
| 428 "eef0fa40 vmov.f32 s31, s0"); | 428 "eef0fa40 vmov.f32 s31, s0"); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 COMPARE(vmrs(r5), | 519 COMPARE(vmrs(r5), |
| 520 "eef15a10 vmrs r5, FPSCR"); | 520 "eef15a10 vmrs r5, FPSCR"); |
| 521 COMPARE(vmrs(r10, ge), | 521 COMPARE(vmrs(r10, ge), |
| 522 "aef1aa10 vmrsge r10, FPSCR"); | 522 "aef1aa10 vmrsge r10, FPSCR"); |
| 523 COMPARE(vmrs(pc), | 523 COMPARE(vmrs(pc), |
| 524 "eef1fa10 vmrs APSR, FPSCR"); | 524 "eef1fa10 vmrs APSR, FPSCR"); |
| 525 } | 525 } |
| 526 | 526 |
| 527 VERIFY_RUN(); | 527 VERIFY_RUN(); |
| 528 } | 528 } |
| OLD | NEW |