| 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 19 matching lines...) Expand all Loading... |
| 30 #if defined(V8_TARGET_ARCH_IA32) | 30 #if defined(V8_TARGET_ARCH_IA32) |
| 31 | 31 |
| 32 #include "codegen.h" | 32 #include "codegen.h" |
| 33 #include "deoptimizer.h" | 33 #include "deoptimizer.h" |
| 34 #include "full-codegen.h" | 34 #include "full-codegen.h" |
| 35 #include "safepoint-table.h" | 35 #include "safepoint-table.h" |
| 36 | 36 |
| 37 namespace v8 { | 37 namespace v8 { |
| 38 namespace internal { | 38 namespace internal { |
| 39 | 39 |
| 40 int Deoptimizer::table_entry_size_ = 10; |
| 40 | 41 |
| 41 int Deoptimizer::table_entry_size_ = 10; | 42 |
| 43 int Deoptimizer::patch_size() { |
| 44 return Assembler::kCallInstructionLength; |
| 45 } |
| 46 |
| 42 | 47 |
| 43 void Deoptimizer::DeoptimizeFunction(JSFunction* function) { | 48 void Deoptimizer::DeoptimizeFunction(JSFunction* function) { |
| 44 AssertNoAllocation no_allocation; | 49 AssertNoAllocation no_allocation; |
| 45 | 50 |
| 46 if (!function->IsOptimized()) return; | 51 if (!function->IsOptimized()) return; |
| 47 | 52 |
| 48 // Get the optimized code. | 53 // Get the optimized code. |
| 49 Code* code = function->code(); | 54 Code* code = function->code(); |
| 50 | 55 |
| 51 // For each return after a safepoint insert a absolute call to the | 56 // For each return after a safepoint insert a absolute call to the |
| (...skipping 18 matching lines...) Expand all Loading... |
| 70 // Destroy the code which is not supposed to run again. | 75 // Destroy the code which is not supposed to run again. |
| 71 unsigned instructions = pc_offset - last_pc_offset; | 76 unsigned instructions = pc_offset - last_pc_offset; |
| 72 CodePatcher destroyer(code->instruction_start() + last_pc_offset, | 77 CodePatcher destroyer(code->instruction_start() + last_pc_offset, |
| 73 instructions); | 78 instructions); |
| 74 for (unsigned i = 0; i < instructions; i++) { | 79 for (unsigned i = 0; i < instructions; i++) { |
| 75 destroyer.masm()->int3(); | 80 destroyer.masm()->int3(); |
| 76 } | 81 } |
| 77 #endif | 82 #endif |
| 78 last_pc_offset = pc_offset; | 83 last_pc_offset = pc_offset; |
| 79 if (deoptimization_index != Safepoint::kNoDeoptimizationIndex) { | 84 if (deoptimization_index != Safepoint::kNoDeoptimizationIndex) { |
| 80 Address call_pc = code->instruction_start() + pc_offset + gap_code_size; | 85 last_pc_offset += gap_code_size; |
| 81 CodePatcher patcher(call_pc, Assembler::kCallInstructionLength); | 86 Address call_pc = code->instruction_start() + last_pc_offset; |
| 87 CodePatcher patcher(call_pc, patch_size()); |
| 82 Address entry = GetDeoptimizationEntry(deoptimization_index, LAZY); | 88 Address entry = GetDeoptimizationEntry(deoptimization_index, LAZY); |
| 83 patcher.masm()->call(entry, RelocInfo::NONE); | 89 patcher.masm()->call(entry, RelocInfo::NONE); |
| 84 last_pc_offset += gap_code_size + Assembler::kCallInstructionLength; | 90 last_pc_offset += patch_size(); |
| 85 RelocInfo rinfo(call_pc + 1, RelocInfo::RUNTIME_ENTRY, | 91 RelocInfo rinfo(call_pc + 1, RelocInfo::RUNTIME_ENTRY, |
| 86 reinterpret_cast<intptr_t>(entry)); | 92 reinterpret_cast<intptr_t>(entry)); |
| 87 reloc_info_writer.Write(&rinfo); | 93 reloc_info_writer.Write(&rinfo); |
| 88 } | 94 } |
| 89 } | 95 } |
| 90 #ifdef DEBUG | 96 #ifdef DEBUG |
| 91 // Destroy the code which is not supposed to run again. | 97 // Destroy the code which is not supposed to run again. |
| 92 unsigned instructions = code->safepoint_table_start() - last_pc_offset; | 98 unsigned instructions = code->safepoint_table_start() - last_pc_offset; |
| 93 CodePatcher destroyer(code->instruction_start() + last_pc_offset, | 99 CodePatcher destroyer(code->instruction_start() + last_pc_offset, |
| 94 instructions); | 100 instructions); |
| (...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 } | 688 } |
| 683 __ bind(&done); | 689 __ bind(&done); |
| 684 } | 690 } |
| 685 | 691 |
| 686 #undef __ | 692 #undef __ |
| 687 | 693 |
| 688 | 694 |
| 689 } } // namespace v8::internal | 695 } } // namespace v8::internal |
| 690 | 696 |
| 691 #endif // V8_TARGET_ARCH_IA32 | 697 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |