| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 | 58 |
| 59 // Get the optimized code. | 59 // Get the optimized code. |
| 60 Code* code = function->code(); | 60 Code* code = function->code(); |
| 61 | 61 |
| 62 // Invalidate the relocation information, as it will become invalid by the | 62 // Invalidate the relocation information, as it will become invalid by the |
| 63 // code patching below, and is not needed any more. | 63 // code patching below, and is not needed any more. |
| 64 code->InvalidateRelocation(); | 64 code->InvalidateRelocation(); |
| 65 | 65 |
| 66 // For each return after a safepoint insert an absolute call to the | 66 // For each return after a safepoint insert an absolute call to the |
| 67 // corresponding deoptimization entry. | 67 // corresponding deoptimization entry. |
| 68 ASSERT(patch_size() % Assembler::kInstrSize == 0); | |
| 69 int call_size_in_words = patch_size() / Assembler::kInstrSize; | |
| 70 unsigned last_pc_offset = 0; | 68 unsigned last_pc_offset = 0; |
| 71 SafepointTable table(function->code()); | 69 SafepointTable table(function->code()); |
| 72 for (unsigned i = 0; i < table.length(); i++) { | 70 for (unsigned i = 0; i < table.length(); i++) { |
| 73 unsigned pc_offset = table.GetPcOffset(i); | 71 unsigned pc_offset = table.GetPcOffset(i); |
| 74 SafepointEntry safepoint_entry = table.GetEntry(i); | 72 SafepointEntry safepoint_entry = table.GetEntry(i); |
| 75 int deoptimization_index = safepoint_entry.deoptimization_index(); | 73 int deoptimization_index = safepoint_entry.deoptimization_index(); |
| 76 int gap_code_size = safepoint_entry.gap_code_size(); | 74 int gap_code_size = safepoint_entry.gap_code_size(); |
| 77 // Check that we did not shoot past next safepoint. | 75 // Check that we did not shoot past next safepoint. |
| 78 CHECK(pc_offset >= last_pc_offset); | 76 CHECK(pc_offset >= last_pc_offset); |
| 79 #ifdef DEBUG | 77 #ifdef DEBUG |
| 80 // Destroy the code which is not supposed to be run again. | 78 // Destroy the code which is not supposed to be run again. |
| 81 int instructions = (pc_offset - last_pc_offset) / Assembler::kInstrSize; | 79 int instructions = (pc_offset - last_pc_offset) / Assembler::kInstrSize; |
| 82 CodePatcher destroyer(code->instruction_start() + last_pc_offset, | 80 CodePatcher destroyer(code->instruction_start() + last_pc_offset, |
| 83 instructions); | 81 instructions); |
| 84 for (int x = 0; x < instructions; x++) { | 82 for (int x = 0; x < instructions; x++) { |
| 85 destroyer.masm()->bkpt(0); | 83 destroyer.masm()->bkpt(0); |
| 86 } | 84 } |
| 87 #endif | 85 #endif |
| 88 last_pc_offset = pc_offset; | 86 last_pc_offset = pc_offset; |
| 89 if (deoptimization_index != Safepoint::kNoDeoptimizationIndex) { | 87 if (deoptimization_index != Safepoint::kNoDeoptimizationIndex) { |
| 88 Address deoptimization_entry = Deoptimizer::GetDeoptimizationEntry( |
| 89 deoptimization_index, Deoptimizer::LAZY); |
| 90 last_pc_offset += gap_code_size; | 90 last_pc_offset += gap_code_size; |
| 91 int call_size_in_bytes = MacroAssembler::CallSize(deoptimization_entry, |
| 92 RelocInfo::NONE); |
| 93 int call_size_in_words = call_size_in_bytes / Assembler::kInstrSize; |
| 94 ASSERT(call_size_in_bytes % Assembler::kInstrSize == 0); |
| 95 ASSERT(call_size_in_bytes <= patch_size()); |
| 91 CodePatcher patcher(code->instruction_start() + last_pc_offset, | 96 CodePatcher patcher(code->instruction_start() + last_pc_offset, |
| 92 call_size_in_words); | 97 call_size_in_words); |
| 93 Address deoptimization_entry = Deoptimizer::GetDeoptimizationEntry( | |
| 94 deoptimization_index, Deoptimizer::LAZY); | |
| 95 patcher.masm()->Call(deoptimization_entry, RelocInfo::NONE); | 98 patcher.masm()->Call(deoptimization_entry, RelocInfo::NONE); |
| 96 last_pc_offset += patch_size(); | 99 last_pc_offset += call_size_in_bytes; |
| 97 } | 100 } |
| 98 } | 101 } |
| 99 | 102 |
| 100 | 103 |
| 101 #ifdef DEBUG | 104 #ifdef DEBUG |
| 102 // Destroy the code which is not supposed to be run again. | 105 // Destroy the code which is not supposed to be run again. |
| 103 int instructions = | 106 int instructions = |
| 104 (code->safepoint_table_offset() - last_pc_offset) / Assembler::kInstrSize; | 107 (code->safepoint_table_offset() - last_pc_offset) / Assembler::kInstrSize; |
| 105 CodePatcher destroyer(code->instruction_start() + last_pc_offset, | 108 CodePatcher destroyer(code->instruction_start() + last_pc_offset, |
| 106 instructions); | 109 instructions); |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 (DwVfpRegister::kNumAllocatableRegisters - 1)); | 587 (DwVfpRegister::kNumAllocatableRegisters - 1)); |
| 585 #ifdef DEBUG | 588 #ifdef DEBUG |
| 586 for (int i = 0; i <= (DwVfpRegister::kNumAllocatableRegisters - 1); i++) { | 589 for (int i = 0; i <= (DwVfpRegister::kNumAllocatableRegisters - 1); i++) { |
| 587 ASSERT((DwVfpRegister::FromAllocationIndex(i).code() <= last.code()) && | 590 ASSERT((DwVfpRegister::FromAllocationIndex(i).code() <= last.code()) && |
| 588 (DwVfpRegister::FromAllocationIndex(i).code() >= first.code())); | 591 (DwVfpRegister::FromAllocationIndex(i).code() >= first.code())); |
| 589 } | 592 } |
| 590 #endif | 593 #endif |
| 591 __ vstm(db_w, sp, first, last); | 594 __ vstm(db_w, sp, first, last); |
| 592 | 595 |
| 593 // Push all 16 registers (needed to populate FrameDescription::registers_). | 596 // Push all 16 registers (needed to populate FrameDescription::registers_). |
| 597 // TODO(1588) Note that using pc with stm is deprecated, so we should perhaps |
| 598 // handle this a bit differently. |
| 594 __ stm(db_w, sp, restored_regs | sp.bit() | lr.bit() | pc.bit()); | 599 __ stm(db_w, sp, restored_regs | sp.bit() | lr.bit() | pc.bit()); |
| 595 | 600 |
| 596 const int kSavedRegistersAreaSize = | 601 const int kSavedRegistersAreaSize = |
| 597 (kNumberOfRegisters * kPointerSize) + kDoubleRegsSize; | 602 (kNumberOfRegisters * kPointerSize) + kDoubleRegsSize; |
| 598 | 603 |
| 599 // Get the bailout id from the stack. | 604 // Get the bailout id from the stack. |
| 600 __ ldr(r2, MemOperand(sp, kSavedRegistersAreaSize)); | 605 __ ldr(r2, MemOperand(sp, kSavedRegistersAreaSize)); |
| 601 | 606 |
| 602 // Get the address of the location in the code object if possible (r3) (return | 607 // Get the address of the location in the code object if possible (r3) (return |
| 603 // address for lazy deoptimization) and compute the fp-to-sp delta in | 608 // address for lazy deoptimization) and compute the fp-to-sp delta in |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 761 __ push(ip); | 766 __ push(ip); |
| 762 __ b(&done); | 767 __ b(&done); |
| 763 ASSERT(masm()->pc_offset() - start == table_entry_size_); | 768 ASSERT(masm()->pc_offset() - start == table_entry_size_); |
| 764 } | 769 } |
| 765 __ bind(&done); | 770 __ bind(&done); |
| 766 } | 771 } |
| 767 | 772 |
| 768 #undef __ | 773 #undef __ |
| 769 | 774 |
| 770 } } // namespace v8::internal | 775 } } // namespace v8::internal |
| OLD | NEW |