| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #if V8_TARGET_ARCH_X87 | 5 #if V8_TARGET_ARCH_X87 |
| 6 | 6 |
| 7 #include "src/codegen.h" | 7 #include "src/codegen.h" |
| 8 #include "src/deoptimizer.h" | 8 #include "src/deoptimizer.h" |
| 9 #include "src/full-codegen/full-codegen.h" | 9 #include "src/full-codegen/full-codegen.h" |
| 10 #include "src/register-configuration.h" | 10 #include "src/register-configuration.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 Address code_start_address = code->instruction_start(); | 94 Address code_start_address = code->instruction_start(); |
| 95 | 95 |
| 96 if (FLAG_zap_code_space) { | 96 if (FLAG_zap_code_space) { |
| 97 // Fail hard and early if we enter this code object again. | 97 // Fail hard and early if we enter this code object again. |
| 98 byte* pointer = code->FindCodeAgeSequence(); | 98 byte* pointer = code->FindCodeAgeSequence(); |
| 99 if (pointer != NULL) { | 99 if (pointer != NULL) { |
| 100 pointer += kNoCodeAgeSequenceLength; | 100 pointer += kNoCodeAgeSequenceLength; |
| 101 } else { | 101 } else { |
| 102 pointer = code->instruction_start(); | 102 pointer = code->instruction_start(); |
| 103 } | 103 } |
| 104 CodePatcher patcher(pointer, 1); | 104 CodePatcher patcher(isolate, pointer, 1); |
| 105 patcher.masm()->int3(); | 105 patcher.masm()->int3(); |
| 106 | 106 |
| 107 DeoptimizationInputData* data = | 107 DeoptimizationInputData* data = |
| 108 DeoptimizationInputData::cast(code->deoptimization_data()); | 108 DeoptimizationInputData::cast(code->deoptimization_data()); |
| 109 int osr_offset = data->OsrPcOffset()->value(); | 109 int osr_offset = data->OsrPcOffset()->value(); |
| 110 if (osr_offset > 0) { | 110 if (osr_offset > 0) { |
| 111 CodePatcher osr_patcher(code->instruction_start() + osr_offset, 1); | 111 CodePatcher osr_patcher(isolate, code->instruction_start() + osr_offset, |
| 112 1); |
| 112 osr_patcher.masm()->int3(); | 113 osr_patcher.masm()->int3(); |
| 113 } | 114 } |
| 114 } | 115 } |
| 115 | 116 |
| 116 // We will overwrite the code's relocation info in-place. Relocation info | 117 // We will overwrite the code's relocation info in-place. Relocation info |
| 117 // is written backward. The relocation info is the payload of a byte | 118 // is written backward. The relocation info is the payload of a byte |
| 118 // array. Later on we will slide this to the start of the byte array and | 119 // array. Later on we will slide this to the start of the byte array and |
| 119 // create a filler object in the remaining space. | 120 // create a filler object in the remaining space. |
| 120 ByteArray* reloc_info = code->relocation_info(); | 121 ByteArray* reloc_info = code->relocation_info(); |
| 121 Address reloc_end_address = reloc_info->address() + reloc_info->Size(); | 122 Address reloc_end_address = reloc_info->address() + reloc_info->Size(); |
| 122 RelocInfoWriter reloc_info_writer(reloc_end_address, code_start_address); | 123 RelocInfoWriter reloc_info_writer(reloc_end_address, code_start_address); |
| 123 | 124 |
| 124 // Since the call is a relative encoding, write new | 125 // Since the call is a relative encoding, write new |
| 125 // reloc info. We do not need any of the existing reloc info because the | 126 // reloc info. We do not need any of the existing reloc info because the |
| 126 // existing code will not be used again (we zap it in debug builds). | 127 // existing code will not be used again (we zap it in debug builds). |
| 127 // | 128 // |
| 128 // Emit call to lazy deoptimization at all lazy deopt points. | 129 // Emit call to lazy deoptimization at all lazy deopt points. |
| 129 DeoptimizationInputData* deopt_data = | 130 DeoptimizationInputData* deopt_data = |
| 130 DeoptimizationInputData::cast(code->deoptimization_data()); | 131 DeoptimizationInputData::cast(code->deoptimization_data()); |
| 131 #ifdef DEBUG | 132 #ifdef DEBUG |
| 132 Address prev_call_address = NULL; | 133 Address prev_call_address = NULL; |
| 133 #endif | 134 #endif |
| 134 // For each LLazyBailout instruction insert a call to the corresponding | 135 // For each LLazyBailout instruction insert a call to the corresponding |
| 135 // deoptimization entry. | 136 // deoptimization entry. |
| 136 for (int i = 0; i < deopt_data->DeoptCount(); i++) { | 137 for (int i = 0; i < deopt_data->DeoptCount(); i++) { |
| 137 if (deopt_data->Pc(i)->value() == -1) continue; | 138 if (deopt_data->Pc(i)->value() == -1) continue; |
| 138 // Patch lazy deoptimization entry. | 139 // Patch lazy deoptimization entry. |
| 139 Address call_address = code_start_address + deopt_data->Pc(i)->value(); | 140 Address call_address = code_start_address + deopt_data->Pc(i)->value(); |
| 140 CodePatcher patcher(call_address, patch_size()); | 141 CodePatcher patcher(isolate, call_address, patch_size()); |
| 141 Address deopt_entry = GetDeoptimizationEntry(isolate, i, LAZY); | 142 Address deopt_entry = GetDeoptimizationEntry(isolate, i, LAZY); |
| 142 patcher.masm()->call(deopt_entry, RelocInfo::NONE32); | 143 patcher.masm()->call(deopt_entry, RelocInfo::NONE32); |
| 143 // We use RUNTIME_ENTRY for deoptimization bailouts. | 144 // We use RUNTIME_ENTRY for deoptimization bailouts. |
| 144 RelocInfo rinfo(call_address + 1, // 1 after the call opcode. | 145 RelocInfo rinfo(call_address + 1, // 1 after the call opcode. |
| 145 RelocInfo::RUNTIME_ENTRY, | 146 RelocInfo::RUNTIME_ENTRY, |
| 146 reinterpret_cast<intptr_t>(deopt_entry), | 147 reinterpret_cast<intptr_t>(deopt_entry), |
| 147 NULL); | 148 NULL); |
| 148 reloc_info_writer.Write(&rinfo); | 149 reloc_info_writer.Write(&rinfo); |
| 149 DCHECK_GE(reloc_info_writer.pos(), | 150 DCHECK_GE(reloc_info_writer.pos(), |
| 150 reloc_info->address() + ByteArray::kHeaderSize); | 151 reloc_info->address() + ByteArray::kHeaderSize); |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 } | 470 } |
| 470 | 471 |
| 471 | 472 |
| 472 #undef __ | 473 #undef __ |
| 473 | 474 |
| 474 | 475 |
| 475 } // namespace internal | 476 } // namespace internal |
| 476 } // namespace v8 | 477 } // namespace v8 |
| 477 | 478 |
| 478 #endif // V8_TARGET_ARCH_X87 | 479 #endif // V8_TARGET_ARCH_X87 |
| OLD | NEW |