| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 return kCallInstructionSizeInWords * Assembler::kInstrSize; | 43 return kCallInstructionSizeInWords * Assembler::kInstrSize; |
| 44 } | 44 } |
| 45 | 45 |
| 46 | 46 |
| 47 void Deoptimizer::PatchCodeForDeoptimization(Isolate* isolate, Code* code) { | 47 void Deoptimizer::PatchCodeForDeoptimization(Isolate* isolate, Code* code) { |
| 48 Address code_start_address = code->instruction_start(); | 48 Address code_start_address = code->instruction_start(); |
| 49 // Invalidate the relocation information, as it will become invalid by the | 49 // Invalidate the relocation information, as it will become invalid by the |
| 50 // code patching below, and is not needed any more. | 50 // code patching below, and is not needed any more. |
| 51 code->InvalidateRelocation(); | 51 code->InvalidateRelocation(); |
| 52 | 52 |
| 53 // For each LLazyBailout instruction insert a call to the corresponding | 53 if (FLAG_zap_code_space) { |
| 54 // deoptimization entry. | 54 // Fail hard and early if we enter this code object again. |
| 55 byte* pointer = code->FindCodeAgeSequence(); |
| 56 if (pointer != NULL) { |
| 57 pointer += kNoCodeAgeSequenceLength * Assembler::kInstrSize; |
| 58 } else { |
| 59 pointer = code->instruction_start(); |
| 60 } |
| 61 CodePatcher patcher(pointer, 1); |
| 62 patcher.masm()->bkpt(0); |
| 63 |
| 64 DeoptimizationInputData* data = |
| 65 DeoptimizationInputData::cast(code->deoptimization_data()); |
| 66 int osr_offset = data->OsrPcOffset()->value(); |
| 67 if (osr_offset > 0) { |
| 68 CodePatcher osr_patcher(code->instruction_start() + osr_offset, 1); |
| 69 osr_patcher.masm()->bkpt(0); |
| 70 } |
| 71 } |
| 72 |
| 55 DeoptimizationInputData* deopt_data = | 73 DeoptimizationInputData* deopt_data = |
| 56 DeoptimizationInputData::cast(code->deoptimization_data()); | 74 DeoptimizationInputData::cast(code->deoptimization_data()); |
| 75 SharedFunctionInfo* shared = |
| 76 SharedFunctionInfo::cast(deopt_data->SharedFunctionInfo()); |
| 77 shared->EvictFromOptimizedCodeMap(code, "deoptimized code"); |
| 57 #ifdef DEBUG | 78 #ifdef DEBUG |
| 58 Address prev_call_address = NULL; | 79 Address prev_call_address = NULL; |
| 59 #endif | 80 #endif |
| 81 // For each LLazyBailout instruction insert a call to the corresponding |
| 82 // deoptimization entry. |
| 60 for (int i = 0; i < deopt_data->DeoptCount(); i++) { | 83 for (int i = 0; i < deopt_data->DeoptCount(); i++) { |
| 61 if (deopt_data->Pc(i)->value() == -1) continue; | 84 if (deopt_data->Pc(i)->value() == -1) continue; |
| 62 Address call_address = code_start_address + deopt_data->Pc(i)->value(); | 85 Address call_address = code_start_address + deopt_data->Pc(i)->value(); |
| 63 Address deopt_entry = GetDeoptimizationEntry(isolate, i, LAZY); | 86 Address deopt_entry = GetDeoptimizationEntry(isolate, i, LAZY); |
| 64 // We need calls to have a predictable size in the unoptimized code, but | 87 // We need calls to have a predictable size in the unoptimized code, but |
| 65 // this is optimized code, so we don't have to have a predictable size. | 88 // this is optimized code, so we don't have to have a predictable size. |
| 66 int call_size_in_bytes = | 89 int call_size_in_bytes = |
| 67 MacroAssembler::CallSizeNotPredictableCodeSize(deopt_entry, | 90 MacroAssembler::CallSizeNotPredictableCodeSize(deopt_entry, |
| 68 RelocInfo::NONE32); | 91 RelocInfo::NONE32); |
| 69 int call_size_in_words = call_size_in_bytes / Assembler::kInstrSize; | 92 int call_size_in_words = call_size_in_bytes / Assembler::kInstrSize; |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 | 369 |
| 347 | 370 |
| 348 void FrameDescription::SetCallerFp(unsigned offset, intptr_t value) { | 371 void FrameDescription::SetCallerFp(unsigned offset, intptr_t value) { |
| 349 SetFrameSlot(offset, value); | 372 SetFrameSlot(offset, value); |
| 350 } | 373 } |
| 351 | 374 |
| 352 | 375 |
| 353 #undef __ | 376 #undef __ |
| 354 | 377 |
| 355 } } // namespace v8::internal | 378 } } // namespace v8::internal |
| OLD | NEW |