| OLD | NEW |
| 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. |
| 2 // All Rights Reserved. | 2 // All Rights Reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions | 5 // modification, are permitted provided that the following conditions |
| 6 // are met: | 6 // are met: |
| 7 // | 7 // |
| 8 // - Redistributions of source code must retain the above copyright notice, | 8 // - Redistributions of source code must retain the above copyright notice, |
| 9 // this list of conditions and the following disclaimer. | 9 // this list of conditions and the following disclaimer. |
| 10 // | 10 // |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 } else if (instr == 0x6a && dst.is(eax)) { // push of immediate 8 bit | 468 } else if (instr == 0x6a && dst.is(eax)) { // push of immediate 8 bit |
| 469 byte imm8 = last_pc_[1]; | 469 byte imm8 = last_pc_[1]; |
| 470 if (imm8 == 0) { | 470 if (imm8 == 0) { |
| 471 // 6a00 push 0x0 | 471 // 6a00 push 0x0 |
| 472 // 58 pop eax | 472 // 58 pop eax |
| 473 last_pc_[0] = 0x31; | 473 last_pc_[0] = 0x31; |
| 474 last_pc_[1] = 0xc0; | 474 last_pc_[1] = 0xc0; |
| 475 // change to | 475 // change to |
| 476 // 31c0 xor eax,eax | 476 // 31c0 xor eax,eax |
| 477 last_pc_ = NULL; | 477 last_pc_ = NULL; |
| 478 if (FLAG_print_push_pop_elimination) { |
| 479 PrintF("%d push/pop (imm->reg) eliminated\n", pc_offset()); |
| 480 } |
| 478 return; | 481 return; |
| 479 } else { | 482 } else { |
| 480 // 6a00 push 0xXX | 483 // 6a00 push 0xXX |
| 481 // 58 pop eax | 484 // 58 pop eax |
| 482 last_pc_[0] = 0xb8; | 485 last_pc_[0] = 0xb8; |
| 483 EnsureSpace ensure_space(this); | 486 EnsureSpace ensure_space(this); |
| 484 if ((imm8 & 0x80) != 0) { | 487 if ((imm8 & 0x80) != 0) { |
| 485 EMIT(0xff); | 488 EMIT(0xff); |
| 486 EMIT(0xff); | 489 EMIT(0xff); |
| 487 EMIT(0xff); | 490 EMIT(0xff); |
| 488 // change to | 491 // change to |
| 489 // b8XXffffff mov eax,0xffffffXX | 492 // b8XXffffff mov eax,0xffffffXX |
| 490 } else { | 493 } else { |
| 491 EMIT(0x00); | 494 EMIT(0x00); |
| 492 EMIT(0x00); | 495 EMIT(0x00); |
| 493 EMIT(0x00); | 496 EMIT(0x00); |
| 494 // change to | 497 // change to |
| 495 // b8XX000000 mov eax,0x000000XX | 498 // b8XX000000 mov eax,0x000000XX |
| 496 } | 499 } |
| 497 last_pc_ = NULL; | 500 last_pc_ = NULL; |
| 501 if (FLAG_print_push_pop_elimination) { |
| 502 PrintF("%d push/pop (imm->reg) eliminated\n", pc_offset()); |
| 503 } |
| 498 return; | 504 return; |
| 499 } | 505 } |
| 500 } else if (instr == 0x68 && dst.is(eax)) { // push of immediate 32 bit | 506 } else if (instr == 0x68 && dst.is(eax)) { // push of immediate 32 bit |
| 501 // 68XXXXXXXX push 0xXXXXXXXX | 507 // 68XXXXXXXX push 0xXXXXXXXX |
| 502 // 58 pop eax | 508 // 58 pop eax |
| 503 last_pc_[0] = 0xb8; | 509 last_pc_[0] = 0xb8; |
| 504 last_pc_ = NULL; | 510 last_pc_ = NULL; |
| 505 // change to | 511 // change to |
| 506 // b8XXXXXXXX mov eax,0xXXXXXXXX | 512 // b8XXXXXXXX mov eax,0xXXXXXXXX |
| 513 if (FLAG_print_push_pop_elimination) { |
| 514 PrintF("%d push/pop (imm->reg) eliminated\n", pc_offset()); |
| 515 } |
| 507 return; | 516 return; |
| 508 } | 517 } |
| 509 | 518 |
| 510 // Other potential patterns for peephole: | 519 // Other potential patterns for peephole: |
| 511 // 0x712716 102 890424 mov [esp], eax | 520 // 0x712716 102 890424 mov [esp], eax |
| 512 // 0x712719 105 8b1424 mov edx, [esp] | 521 // 0x712719 105 8b1424 mov edx, [esp] |
| 513 } | 522 } |
| 514 EnsureSpace ensure_space(this); | 523 EnsureSpace ensure_space(this); |
| 515 last_pc_ = pc_; | 524 last_pc_ = pc_; |
| 516 EMIT(0x58 | dst.code()); | 525 EMIT(0x58 | dst.code()); |
| (...skipping 1504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2021 ASSERT(bound_label.is_bound()); | 2030 ASSERT(bound_label.is_bound()); |
| 2022 ASSERT(0 <= position); | 2031 ASSERT(0 <= position); |
| 2023 ASSERT(position + static_cast<int>(sizeof(uint32_t)) <= pc_offset()); | 2032 ASSERT(position + static_cast<int>(sizeof(uint32_t)) <= pc_offset()); |
| 2024 ASSERT(long_at(position) == 0); // only initialize once! | 2033 ASSERT(long_at(position) == 0); // only initialize once! |
| 2025 | 2034 |
| 2026 uint32_t label_loc = reinterpret_cast<uint32_t>(addr_at(bound_label.pos())); | 2035 uint32_t label_loc = reinterpret_cast<uint32_t>(addr_at(bound_label.pos())); |
| 2027 long_at_put(position, label_loc); | 2036 long_at_put(position, label_loc); |
| 2028 } | 2037 } |
| 2029 | 2038 |
| 2030 } } // namespace v8::internal | 2039 } } // namespace v8::internal |
| OLD | NEW |