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 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 // 0x710fac 216 83c404 add esp,0x4 | 462 // 0x710fac 216 83c404 add esp,0x4 |
463 last_pc_[0] = 0x83; | 463 last_pc_[0] = 0x83; |
464 last_pc_[1] = 0xc4; | 464 last_pc_[1] = 0xc4; |
465 last_pc_[2] = 0x04; | 465 last_pc_[2] = 0x04; |
466 last_pc_ = NULL; | 466 last_pc_ = NULL; |
467 if (FLAG_print_push_pop_elimination) { | 467 if (FLAG_print_push_pop_elimination) { |
468 PrintF("%d push/pop (mov-pop) eliminated\n", pc_offset()); | 468 PrintF("%d push/pop (mov-pop) eliminated\n", pc_offset()); |
469 } | 469 } |
470 return; | 470 return; |
471 } | 471 } |
| 472 } else if (instr == 0x6a && dst.is(eax)) { // push of immediate 8 bit |
| 473 byte imm8 = last_pc_[1]; |
| 474 if (imm8 == 0) { |
| 475 // 6a00 push 0x0 |
| 476 // 58 pop eax |
| 477 last_pc_[0] = 0x31; |
| 478 last_pc_[1] = 0xc0; |
| 479 // change to |
| 480 // 31c0 xor eax,eax |
| 481 last_pc_ = NULL; |
| 482 return; |
| 483 } else { |
| 484 // 6a00 push 0xXX |
| 485 // 58 pop eax |
| 486 last_pc_[0] = 0xb8; |
| 487 EnsureSpace ensure_space(this); |
| 488 if ((imm8 & 0x80) != 0) { |
| 489 EMIT(0xff); |
| 490 EMIT(0xff); |
| 491 EMIT(0xff); |
| 492 // change to |
| 493 // b8XXffffff mov eax,0xffffffXX |
| 494 } else { |
| 495 EMIT(0x00); |
| 496 EMIT(0x00); |
| 497 EMIT(0x00); |
| 498 // change to |
| 499 // b8XX000000 mov eax,0x000000XX |
| 500 } |
| 501 last_pc_ = NULL; |
| 502 return; |
| 503 } |
| 504 } else if (instr == 0x68 && dst.is(eax)) { // push of immediate 32 bit |
| 505 // 68XXXXXXXX push 0xXXXXXXXX |
| 506 // 58 pop eax |
| 507 last_pc_[0] = 0xb8; |
| 508 last_pc_ = NULL; |
| 509 // change to |
| 510 // b8XXXXXXXX mov eax,0xXXXXXXXX |
| 511 return; |
472 } | 512 } |
| 513 |
473 // Other potential patterns for peephole: | 514 // Other potential patterns for peephole: |
474 // 0x712716 102 890424 mov [esp], eax | 515 // 0x712716 102 890424 mov [esp], eax |
475 // 0x712719 105 8b1424 mov edx, [esp] | 516 // 0x712719 105 8b1424 mov edx, [esp] |
476 } | 517 } |
477 EnsureSpace ensure_space(this); | 518 EnsureSpace ensure_space(this); |
478 last_pc_ = pc_; | 519 last_pc_ = pc_; |
479 EMIT(0x58 | dst.code()); | 520 EMIT(0x58 | dst.code()); |
480 } | 521 } |
481 | 522 |
482 | 523 |
(...skipping 1558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2041 ASSERT(bound_label.is_bound()); | 2082 ASSERT(bound_label.is_bound()); |
2042 ASSERT(0 <= position); | 2083 ASSERT(0 <= position); |
2043 ASSERT(position + static_cast<int>(sizeof(uint32_t)) <= pc_offset()); | 2084 ASSERT(position + static_cast<int>(sizeof(uint32_t)) <= pc_offset()); |
2044 ASSERT(long_at(position) == 0); // only initialize once! | 2085 ASSERT(long_at(position) == 0); // only initialize once! |
2045 | 2086 |
2046 uint32_t label_loc = reinterpret_cast<uint32_t>(addr_at(bound_label.pos())); | 2087 uint32_t label_loc = reinterpret_cast<uint32_t>(addr_at(bound_label.pos())); |
2047 long_at_put(position, label_loc); | 2088 long_at_put(position, label_loc); |
2048 } | 2089 } |
2049 | 2090 |
2050 } } // namespace v8::internal | 2091 } } // namespace v8::internal |
OLD | NEW |