| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/deopt_instructions.h" | 5 #include "vm/deopt_instructions.h" |
| 6 | 6 |
| 7 #include "vm/assembler.h" | 7 #include "vm/assembler.h" |
| 8 #include "vm/code_patcher.h" | 8 #include "vm/code_patcher.h" |
| 9 #include "vm/intermediate_language.h" | 9 #include "vm/intermediate_language.h" |
| 10 #include "vm/locations.h" | 10 #include "vm/locations.h" |
| (...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 virtual const char* ToCString() const { | 561 virtual const char* ToCString() const { |
| 562 return Isolate::Current()->current_zone()->PrintToString( | 562 return Isolate::Current()->current_zone()->PrintToString( |
| 563 "ret oti:%" Pd "(%" Pd ")", object_table_index_, deopt_id_); | 563 "ret oti:%" Pd "(%" Pd ")", object_table_index_, deopt_id_); |
| 564 } | 564 } |
| 565 | 565 |
| 566 void Execute(DeoptContext* deopt_context, intptr_t* dest_addr) { | 566 void Execute(DeoptContext* deopt_context, intptr_t* dest_addr) { |
| 567 Code& code = Code::Handle(deopt_context->isolate()); | 567 Code& code = Code::Handle(deopt_context->isolate()); |
| 568 code ^= deopt_context->ObjectAt(object_table_index_); | 568 code ^= deopt_context->ObjectAt(object_table_index_); |
| 569 ASSERT(!code.IsNull()); | 569 ASSERT(!code.IsNull()); |
| 570 uword continue_at_pc = code.GetPcForDeoptId(deopt_id_, | 570 uword continue_at_pc = code.GetPcForDeoptId(deopt_id_, |
| 571 PcDescriptors::kDeopt); | 571 RawPcDescriptors::kDeopt); |
| 572 ASSERT(continue_at_pc != 0); | 572 ASSERT(continue_at_pc != 0); |
| 573 *dest_addr = continue_at_pc; | 573 *dest_addr = continue_at_pc; |
| 574 | 574 |
| 575 uword pc = code.GetPcForDeoptId(deopt_id_, PcDescriptors::kIcCall); | 575 uword pc = code.GetPcForDeoptId(deopt_id_, RawPcDescriptors::kIcCall); |
| 576 if (pc != 0) { | 576 if (pc != 0) { |
| 577 // If the deoptimization happened at an IC call, update the IC data | 577 // If the deoptimization happened at an IC call, update the IC data |
| 578 // to avoid repeated deoptimization at the same site next time around. | 578 // to avoid repeated deoptimization at the same site next time around. |
| 579 ICData& ic_data = ICData::Handle(); | 579 ICData& ic_data = ICData::Handle(); |
| 580 CodePatcher::GetInstanceCallAt(pc, code, &ic_data); | 580 CodePatcher::GetInstanceCallAt(pc, code, &ic_data); |
| 581 if (!ic_data.IsNull()) { | 581 if (!ic_data.IsNull()) { |
| 582 ic_data.AddDeoptReason(deopt_context->deopt_reason()); | 582 ic_data.AddDeoptReason(deopt_context->deopt_reason()); |
| 583 } | 583 } |
| 584 } else if (deopt_context->deopt_reason() == | 584 } else if (deopt_context->deopt_reason() == |
| 585 ICData::kDeoptHoistedCheckClass) { | 585 ICData::kDeoptHoistedCheckClass) { |
| (...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1249 DeoptRetAddressInstr* ret_address_instr = | 1249 DeoptRetAddressInstr* ret_address_instr = |
| 1250 static_cast<DeoptRetAddressInstr*>(instr); | 1250 static_cast<DeoptRetAddressInstr*>(instr); |
| 1251 // The following assert may trigger when displaying a backtrace | 1251 // The following assert may trigger when displaying a backtrace |
| 1252 // from the simulator. | 1252 // from the simulator. |
| 1253 ASSERT(Isolate::IsDeoptAfter(ret_address_instr->deopt_id())); | 1253 ASSERT(Isolate::IsDeoptAfter(ret_address_instr->deopt_id())); |
| 1254 ASSERT(!object_table.IsNull()); | 1254 ASSERT(!object_table.IsNull()); |
| 1255 ASSERT(code != NULL); | 1255 ASSERT(code != NULL); |
| 1256 *code ^= object_table.At(ret_address_instr->object_table_index()); | 1256 *code ^= object_table.At(ret_address_instr->object_table_index()); |
| 1257 ASSERT(!code->IsNull()); | 1257 ASSERT(!code->IsNull()); |
| 1258 uword res = code->GetPcForDeoptId(ret_address_instr->deopt_id(), | 1258 uword res = code->GetPcForDeoptId(ret_address_instr->deopt_id(), |
| 1259 PcDescriptors::kDeopt); | 1259 RawPcDescriptors::kDeopt); |
| 1260 ASSERT(res != 0); | 1260 ASSERT(res != 0); |
| 1261 return res; | 1261 return res; |
| 1262 } | 1262 } |
| 1263 | 1263 |
| 1264 | 1264 |
| 1265 DeoptInstr* DeoptInstr::Create(intptr_t kind_as_int, intptr_t source_index) { | 1265 DeoptInstr* DeoptInstr::Create(intptr_t kind_as_int, intptr_t source_index) { |
| 1266 Kind kind = static_cast<Kind>(kind_as_int); | 1266 Kind kind = static_cast<Kind>(kind_as_int); |
| 1267 switch (kind) { | 1267 switch (kind) { |
| 1268 case kStackSlot: return new DeoptStackSlotInstr(source_index); | 1268 case kStackSlot: return new DeoptStackSlotInstr(source_index); |
| 1269 case kDoubleStackSlot: return new DeoptDoubleStackSlotInstr(source_index); | 1269 case kDoubleStackSlot: return new DeoptDoubleStackSlotInstr(source_index); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1387 } | 1387 } |
| 1388 | 1388 |
| 1389 | 1389 |
| 1390 void DeoptInfoBuilder::AddReturnAddress(const Code& code, | 1390 void DeoptInfoBuilder::AddReturnAddress(const Code& code, |
| 1391 intptr_t deopt_id, | 1391 intptr_t deopt_id, |
| 1392 intptr_t dest_index) { | 1392 intptr_t dest_index) { |
| 1393 // Check that deopt_id exists. | 1393 // Check that deopt_id exists. |
| 1394 // TODO(vegorov): verify after deoptimization targets as well. | 1394 // TODO(vegorov): verify after deoptimization targets as well. |
| 1395 #ifdef DEBUG | 1395 #ifdef DEBUG |
| 1396 ASSERT(Isolate::IsDeoptAfter(deopt_id) || | 1396 ASSERT(Isolate::IsDeoptAfter(deopt_id) || |
| 1397 (code.GetPcForDeoptId(deopt_id, PcDescriptors::kDeopt) != 0)); | 1397 (code.GetPcForDeoptId(deopt_id, RawPcDescriptors::kDeopt) != 0)); |
| 1398 #endif | 1398 #endif |
| 1399 const intptr_t object_table_index = FindOrAddObjectInTable(code); | 1399 const intptr_t object_table_index = FindOrAddObjectInTable(code); |
| 1400 ASSERT(dest_index == FrameSize()); | 1400 ASSERT(dest_index == FrameSize()); |
| 1401 instructions_.Add( | 1401 instructions_.Add( |
| 1402 new(isolate()) DeoptRetAddressInstr(object_table_index, deopt_id)); | 1402 new(isolate()) DeoptRetAddressInstr(object_table_index, deopt_id)); |
| 1403 } | 1403 } |
| 1404 | 1404 |
| 1405 | 1405 |
| 1406 void DeoptInfoBuilder::AddPcMarker(const Code& code, | 1406 void DeoptInfoBuilder::AddPcMarker(const Code& code, |
| 1407 intptr_t dest_index) { | 1407 intptr_t dest_index) { |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1667 Smi* offset, | 1667 Smi* offset, |
| 1668 DeoptInfo* info, | 1668 DeoptInfo* info, |
| 1669 Smi* reason) { | 1669 Smi* reason) { |
| 1670 intptr_t i = index * kEntrySize; | 1670 intptr_t i = index * kEntrySize; |
| 1671 *offset ^= table.At(i); | 1671 *offset ^= table.At(i); |
| 1672 *info ^= table.At(i + 1); | 1672 *info ^= table.At(i + 1); |
| 1673 *reason ^= table.At(i + 2); | 1673 *reason ^= table.At(i + 2); |
| 1674 } | 1674 } |
| 1675 | 1675 |
| 1676 } // namespace dart | 1676 } // namespace dart |
| OLD | NEW |