| 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_X64 | 5 #if V8_TARGET_ARCH_X64 |
| 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 23 matching lines...) Expand all Loading... |
| 34 code->InvalidateRelocation(); | 34 code->InvalidateRelocation(); |
| 35 | 35 |
| 36 if (FLAG_zap_code_space) { | 36 if (FLAG_zap_code_space) { |
| 37 // Fail hard and early if we enter this code object again. | 37 // Fail hard and early if we enter this code object again. |
| 38 byte* pointer = code->FindCodeAgeSequence(); | 38 byte* pointer = code->FindCodeAgeSequence(); |
| 39 if (pointer != NULL) { | 39 if (pointer != NULL) { |
| 40 pointer += kNoCodeAgeSequenceLength; | 40 pointer += kNoCodeAgeSequenceLength; |
| 41 } else { | 41 } else { |
| 42 pointer = code->instruction_start(); | 42 pointer = code->instruction_start(); |
| 43 } | 43 } |
| 44 CodePatcher patcher(pointer, 1); | 44 CodePatcher patcher(isolate, pointer, 1); |
| 45 patcher.masm()->int3(); | 45 patcher.masm()->int3(); |
| 46 | 46 |
| 47 DeoptimizationInputData* data = | 47 DeoptimizationInputData* data = |
| 48 DeoptimizationInputData::cast(code->deoptimization_data()); | 48 DeoptimizationInputData::cast(code->deoptimization_data()); |
| 49 int osr_offset = data->OsrPcOffset()->value(); | 49 int osr_offset = data->OsrPcOffset()->value(); |
| 50 if (osr_offset > 0) { | 50 if (osr_offset > 0) { |
| 51 CodePatcher osr_patcher(code->instruction_start() + osr_offset, 1); | 51 CodePatcher osr_patcher(isolate, code->instruction_start() + osr_offset, |
| 52 1); |
| 52 osr_patcher.masm()->int3(); | 53 osr_patcher.masm()->int3(); |
| 53 } | 54 } |
| 54 } | 55 } |
| 55 | 56 |
| 56 // For each LLazyBailout instruction insert a absolute call to the | 57 // For each LLazyBailout instruction insert a absolute call to the |
| 57 // corresponding deoptimization entry, or a short call to an absolute | 58 // corresponding deoptimization entry, or a short call to an absolute |
| 58 // jump if space is short. The absolute jumps are put in a table just | 59 // jump if space is short. The absolute jumps are put in a table just |
| 59 // before the safepoint table (space was allocated there when the Code | 60 // before the safepoint table (space was allocated there when the Code |
| 60 // object was created, if necessary). | 61 // object was created, if necessary). |
| 61 | 62 |
| 62 Address instruction_start = code->instruction_start(); | 63 Address instruction_start = code->instruction_start(); |
| 63 #ifdef DEBUG | 64 #ifdef DEBUG |
| 64 Address prev_call_address = NULL; | 65 Address prev_call_address = NULL; |
| 65 #endif | 66 #endif |
| 66 DeoptimizationInputData* deopt_data = | 67 DeoptimizationInputData* deopt_data = |
| 67 DeoptimizationInputData::cast(code->deoptimization_data()); | 68 DeoptimizationInputData::cast(code->deoptimization_data()); |
| 68 deopt_data->SetSharedFunctionInfo(Smi::FromInt(0)); | 69 deopt_data->SetSharedFunctionInfo(Smi::FromInt(0)); |
| 69 // For each LLazyBailout instruction insert a call to the corresponding | 70 // For each LLazyBailout instruction insert a call to the corresponding |
| 70 // deoptimization entry. | 71 // deoptimization entry. |
| 71 for (int i = 0; i < deopt_data->DeoptCount(); i++) { | 72 for (int i = 0; i < deopt_data->DeoptCount(); i++) { |
| 72 if (deopt_data->Pc(i)->value() == -1) continue; | 73 if (deopt_data->Pc(i)->value() == -1) continue; |
| 73 // Position where Call will be patched in. | 74 // Position where Call will be patched in. |
| 74 Address call_address = instruction_start + deopt_data->Pc(i)->value(); | 75 Address call_address = instruction_start + deopt_data->Pc(i)->value(); |
| 75 // There is room enough to write a long call instruction because we pad | 76 // There is room enough to write a long call instruction because we pad |
| 76 // LLazyBailout instructions with nops if necessary. | 77 // LLazyBailout instructions with nops if necessary. |
| 77 CodePatcher patcher(call_address, Assembler::kCallSequenceLength); | 78 CodePatcher patcher(isolate, call_address, Assembler::kCallSequenceLength); |
| 78 patcher.masm()->Call(GetDeoptimizationEntry(isolate, i, LAZY), | 79 patcher.masm()->Call(GetDeoptimizationEntry(isolate, i, LAZY), |
| 79 Assembler::RelocInfoNone()); | 80 Assembler::RelocInfoNone()); |
| 80 DCHECK(prev_call_address == NULL || | 81 DCHECK(prev_call_address == NULL || |
| 81 call_address >= prev_call_address + patch_size()); | 82 call_address >= prev_call_address + patch_size()); |
| 82 DCHECK(call_address + patch_size() <= code->instruction_end()); | 83 DCHECK(call_address + patch_size() <= code->instruction_end()); |
| 83 #ifdef DEBUG | 84 #ifdef DEBUG |
| 84 prev_call_address = call_address; | 85 prev_call_address = call_address; |
| 85 #endif | 86 #endif |
| 86 } | 87 } |
| 87 } | 88 } |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 } | 354 } |
| 354 | 355 |
| 355 | 356 |
| 356 #undef __ | 357 #undef __ |
| 357 | 358 |
| 358 | 359 |
| 359 } // namespace internal | 360 } // namespace internal |
| 360 } // namespace v8 | 361 } // namespace v8 |
| 361 | 362 |
| 362 #endif // V8_TARGET_ARCH_X64 | 363 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |