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 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 | 421 |
422 | 422 |
423 void Assembler::pop(Register dst) { | 423 void Assembler::pop(Register dst) { |
424 ASSERT(reloc_info_writer.last_pc() != NULL); | 424 ASSERT(reloc_info_writer.last_pc() != NULL); |
425 if (FLAG_push_pop_elimination && (reloc_info_writer.last_pc() <= last_pc_)) { | 425 if (FLAG_push_pop_elimination && (reloc_info_writer.last_pc() <= last_pc_)) { |
426 // (last_pc_ != NULL) is rolled into the above check | 426 // (last_pc_ != NULL) is rolled into the above check |
427 // If a last_pc_ is set, we need to make sure that there has not been any | 427 // If a last_pc_ is set, we need to make sure that there has not been any |
428 // relocation information generated between the last instruction and this | 428 // relocation information generated between the last instruction and this |
429 // pop instruction. | 429 // pop instruction. |
430 byte instr = last_pc_[0]; | 430 byte instr = last_pc_[0]; |
431 if (instr == (0x50 | dst.code())) { | 431 if ((instr & ~0x7) == 0x50) { |
432 pc_ = last_pc_; | 432 int push_reg_code = instr & 0x7; |
| 433 if (push_reg_code == dst.code()) { |
| 434 pc_ = last_pc_; |
| 435 if (FLAG_print_push_pop_elimination) { |
| 436 PrintF("%d push/pop (same reg) eliminated\n", pc_offset()); |
| 437 } |
| 438 } else { |
| 439 // Convert 'push src; pop dst' to 'mov dst, src'. |
| 440 last_pc_[0] = 0x8b; |
| 441 Register src = { push_reg_code }; |
| 442 EnsureSpace ensure_space(this); |
| 443 emit_operand(dst, Operand(src)); |
| 444 if (FLAG_print_push_pop_elimination) { |
| 445 PrintF("%d push/pop (reg->reg) eliminated\n", pc_offset()); |
| 446 } |
| 447 } |
433 last_pc_ = NULL; | 448 last_pc_ = NULL; |
434 if (FLAG_print_push_pop_elimination) { | |
435 PrintF("%d push/pop (same reg) eliminated\n", pc_offset()); | |
436 } | |
437 return; | 449 return; |
438 } else if (instr == 0xff) { // push of an operand, convert to a move | 450 } else if (instr == 0xff) { // push of an operand, convert to a move |
439 byte op1 = last_pc_[1]; | 451 byte op1 = last_pc_[1]; |
440 // Check if the operation is really a push | 452 // Check if the operation is really a push |
441 if ((op1 & 0x38) == (6 << 3)) { | 453 if ((op1 & 0x38) == (6 << 3)) { |
442 op1 = (op1 & ~0x38) | static_cast<byte>(dst.code() << 3); | 454 op1 = (op1 & ~0x38) | static_cast<byte>(dst.code() << 3); |
443 last_pc_[0] = 0x8b; | 455 last_pc_[0] = 0x8b; |
444 last_pc_[1] = op1; | 456 last_pc_[1] = op1; |
445 last_pc_ = NULL; | 457 last_pc_ = NULL; |
446 if (FLAG_print_push_pop_elimination) { | 458 if (FLAG_print_push_pop_elimination) { |
(...skipping 1600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2047 ASSERT(bound_label.is_bound()); | 2059 ASSERT(bound_label.is_bound()); |
2048 ASSERT(0 <= position); | 2060 ASSERT(0 <= position); |
2049 ASSERT(position + static_cast<int>(sizeof(uint32_t)) <= pc_offset()); | 2061 ASSERT(position + static_cast<int>(sizeof(uint32_t)) <= pc_offset()); |
2050 ASSERT(long_at(position) == 0); // only initialize once! | 2062 ASSERT(long_at(position) == 0); // only initialize once! |
2051 | 2063 |
2052 uint32_t label_loc = reinterpret_cast<uint32_t>(addr_at(bound_label.pos())); | 2064 uint32_t label_loc = reinterpret_cast<uint32_t>(addr_at(bound_label.pos())); |
2053 long_at_put(position, label_loc); | 2065 long_at_put(position, label_loc); |
2054 } | 2066 } |
2055 | 2067 |
2056 } } // namespace v8::internal | 2068 } } // namespace v8::internal |
OLD | NEW |