| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 RelocInfoWriter reloc_info_writer(reloc_end_address, code_start_address); | 73 RelocInfoWriter reloc_info_writer(reloc_end_address, code_start_address); |
| 74 | 74 |
| 75 // For each return after a safepoint insert a call to the corresponding | 75 // For each return after a safepoint insert a call to the corresponding |
| 76 // deoptimization entry. Since the call is a relative encoding, write new | 76 // deoptimization entry. Since the call is a relative encoding, write new |
| 77 // reloc info. We do not need any of the existing reloc info because the | 77 // reloc info. We do not need any of the existing reloc info because the |
| 78 // existing code will not be used again (we zap it in debug builds). | 78 // existing code will not be used again (we zap it in debug builds). |
| 79 SafepointTable table(code); | 79 SafepointTable table(code); |
| 80 Address prev_address = code_start_address; | 80 Address prev_address = code_start_address; |
| 81 for (unsigned i = 0; i < table.length(); ++i) { | 81 for (unsigned i = 0; i < table.length(); ++i) { |
| 82 Address curr_address = code_start_address + table.GetPcOffset(i); | 82 Address curr_address = code_start_address + table.GetPcOffset(i); |
| 83 ASSERT_GE(curr_address - prev_address, patch_size()); |
| 83 ZapCodeRange(prev_address, curr_address); | 84 ZapCodeRange(prev_address, curr_address); |
| 84 | 85 |
| 85 SafepointEntry safepoint_entry = table.GetEntry(i); | 86 SafepointEntry safepoint_entry = table.GetEntry(i); |
| 86 int deoptimization_index = safepoint_entry.deoptimization_index(); | 87 int deoptimization_index = safepoint_entry.deoptimization_index(); |
| 87 if (deoptimization_index != Safepoint::kNoDeoptimizationIndex) { | 88 if (deoptimization_index != Safepoint::kNoDeoptimizationIndex) { |
| 88 // The gap code is needed to get to the state expected at the bailout. | 89 // The gap code is needed to get to the state expected at the bailout. |
| 89 curr_address += safepoint_entry.gap_code_size(); | 90 curr_address += safepoint_entry.gap_code_size(); |
| 90 | 91 |
| 91 CodePatcher patcher(curr_address, patch_size()); | 92 CodePatcher patcher(curr_address, patch_size()); |
| 92 Address deopt_entry = GetDeoptimizationEntry(deoptimization_index, LAZY); | 93 Address deopt_entry = GetDeoptimizationEntry(deoptimization_index, LAZY); |
| 93 patcher.masm()->call(deopt_entry, RelocInfo::NONE); | 94 patcher.masm()->call(deopt_entry, RelocInfo::NONE); |
| 94 | 95 |
| 95 // We use RUNTIME_ENTRY for deoptimization bailouts. | 96 // We use RUNTIME_ENTRY for deoptimization bailouts. |
| 96 RelocInfo rinfo(curr_address + 1, // 1 after the call opcode. | 97 RelocInfo rinfo(curr_address + 1, // 1 after the call opcode. |
| 97 RelocInfo::RUNTIME_ENTRY, | 98 RelocInfo::RUNTIME_ENTRY, |
| 98 reinterpret_cast<intptr_t>(deopt_entry)); | 99 reinterpret_cast<intptr_t>(deopt_entry)); |
| 99 reloc_info_writer.Write(&rinfo); | 100 reloc_info_writer.Write(&rinfo); |
| 100 | 101 ASSERT_GE(reloc_info_writer.pos(), |
| 102 reloc_info->address() + ByteArray::kHeaderSize); |
| 101 curr_address += patch_size(); | 103 curr_address += patch_size(); |
| 102 } | 104 } |
| 103 prev_address = curr_address; | 105 prev_address = curr_address; |
| 104 } | 106 } |
| 105 ZapCodeRange(prev_address, | 107 ZapCodeRange(prev_address, |
| 106 code_start_address + code->safepoint_table_offset()); | 108 code_start_address + code->safepoint_table_offset()); |
| 107 | 109 |
| 108 // Move the relocation info to the beginning of the byte array. | 110 // Move the relocation info to the beginning of the byte array. |
| 109 int new_reloc_size = reloc_end_address - reloc_info_writer.pos(); | 111 int new_reloc_size = reloc_end_address - reloc_info_writer.pos(); |
| 110 memmove(code->relocation_start(), reloc_info_writer.pos(), new_reloc_size); | 112 memmove(code->relocation_start(), reloc_info_writer.pos(), new_reloc_size); |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 } | 653 } |
| 652 __ bind(&done); | 654 __ bind(&done); |
| 653 } | 655 } |
| 654 | 656 |
| 655 #undef __ | 657 #undef __ |
| 656 | 658 |
| 657 | 659 |
| 658 } } // namespace v8::internal | 660 } } // namespace v8::internal |
| 659 | 661 |
| 660 #endif // V8_TARGET_ARCH_IA32 | 662 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |