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_macros.h" | 7 #include "vm/assembler_macros.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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 virtual const char* ToCString() const { | 195 virtual const char* ToCString() const { |
196 const char* format = "ret aft oti:%"Pd"(%"Pd")"; | 196 const char* format = "ret aft oti:%"Pd"(%"Pd")"; |
197 intptr_t len = OS::SNPrint(NULL, 0, format, object_table_index_, deopt_id_); | 197 intptr_t len = OS::SNPrint(NULL, 0, format, object_table_index_, deopt_id_); |
198 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1); | 198 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1); |
199 OS::SNPrint(chars, len + 1, format, object_table_index_, deopt_id_); | 199 OS::SNPrint(chars, len + 1, format, object_table_index_, deopt_id_); |
200 return chars; | 200 return chars; |
201 } | 201 } |
202 | 202 |
203 void Execute(DeoptimizationContext* deopt_context, intptr_t to_index) { | 203 void Execute(DeoptimizationContext* deopt_context, intptr_t to_index) { |
204 Function& function = Function::Handle(deopt_context->isolate()); | 204 Function& function = Function::Handle(deopt_context->isolate()); |
205 function ^= deopt_context->ObjectAt(object_table_index_); | 205 function |= deopt_context->ObjectAt(object_table_index_); |
206 const Code& code = | 206 const Code& code = |
207 Code::Handle(deopt_context->isolate(), function.unoptimized_code()); | 207 Code::Handle(deopt_context->isolate(), function.unoptimized_code()); |
208 uword continue_at_pc = code.GetDeoptAfterPcAtDeoptId(deopt_id_); | 208 uword continue_at_pc = code.GetDeoptAfterPcAtDeoptId(deopt_id_); |
209 intptr_t* to_addr = deopt_context->GetToFrameAddressAt(to_index); | 209 intptr_t* to_addr = deopt_context->GetToFrameAddressAt(to_index); |
210 *to_addr = continue_at_pc; | 210 *to_addr = continue_at_pc; |
211 } | 211 } |
212 | 212 |
213 static void GetEncodedValues(intptr_t from_index, | 213 static void GetEncodedValues(intptr_t from_index, |
214 intptr_t* object_table_index, | 214 intptr_t* object_table_index, |
215 intptr_t* deopt_id) { | 215 intptr_t* deopt_id) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 virtual const char* ToCString() const { | 254 virtual const char* ToCString() const { |
255 const char* format = "ret bef oti:%"Pd"(%"Pd")"; | 255 const char* format = "ret bef oti:%"Pd"(%"Pd")"; |
256 intptr_t len = OS::SNPrint(NULL, 0, format, object_table_index_, deopt_id_); | 256 intptr_t len = OS::SNPrint(NULL, 0, format, object_table_index_, deopt_id_); |
257 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1); | 257 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1); |
258 OS::SNPrint(chars, len + 1, format, object_table_index_, deopt_id_); | 258 OS::SNPrint(chars, len + 1, format, object_table_index_, deopt_id_); |
259 return chars; | 259 return chars; |
260 } | 260 } |
261 | 261 |
262 void Execute(DeoptimizationContext* deopt_context, intptr_t to_index) { | 262 void Execute(DeoptimizationContext* deopt_context, intptr_t to_index) { |
263 Function& function = Function::Handle(deopt_context->isolate()); | 263 Function& function = Function::Handle(deopt_context->isolate()); |
264 function ^= deopt_context->ObjectAt(object_table_index_); | 264 function |= deopt_context->ObjectAt(object_table_index_); |
265 const Code& code = | 265 const Code& code = |
266 Code::Handle(deopt_context->isolate(), function.unoptimized_code()); | 266 Code::Handle(deopt_context->isolate(), function.unoptimized_code()); |
267 uword continue_at_pc = code.GetDeoptBeforePcAtDeoptId(deopt_id_); | 267 uword continue_at_pc = code.GetDeoptBeforePcAtDeoptId(deopt_id_); |
268 intptr_t* to_addr = deopt_context->GetToFrameAddressAt(to_index); | 268 intptr_t* to_addr = deopt_context->GetToFrameAddressAt(to_index); |
269 *to_addr = continue_at_pc; | 269 *to_addr = continue_at_pc; |
270 | 270 |
271 uword pc = code.GetPcForDeoptId(deopt_id_, PcDescriptors::kIcCall); | 271 uword pc = code.GetPcForDeoptId(deopt_id_, PcDescriptors::kIcCall); |
272 if (pc != 0) { | 272 if (pc != 0) { |
273 // If the deoptimization happened at an IC call, update the IC data | 273 // If the deoptimization happened at an IC call, update the IC data |
274 // to avoid repeated deoptimization at the same site next time around. | 274 // to avoid repeated deoptimization at the same site next time around. |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 virtual const char* ToCString() const { | 432 virtual const char* ToCString() const { |
433 const char* format = "pcmark oti:%"Pd""; | 433 const char* format = "pcmark oti:%"Pd""; |
434 intptr_t len = OS::SNPrint(NULL, 0, format, object_table_index_); | 434 intptr_t len = OS::SNPrint(NULL, 0, format, object_table_index_); |
435 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1); | 435 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1); |
436 OS::SNPrint(chars, len + 1, format, object_table_index_); | 436 OS::SNPrint(chars, len + 1, format, object_table_index_); |
437 return chars; | 437 return chars; |
438 } | 438 } |
439 | 439 |
440 void Execute(DeoptimizationContext* deopt_context, intptr_t to_index) { | 440 void Execute(DeoptimizationContext* deopt_context, intptr_t to_index) { |
441 Function& function = Function::Handle(deopt_context->isolate()); | 441 Function& function = Function::Handle(deopt_context->isolate()); |
442 function ^= deopt_context->ObjectAt(object_table_index_); | 442 function |= deopt_context->ObjectAt(object_table_index_); |
443 const Code& code = | 443 const Code& code = |
444 Code::Handle(deopt_context->isolate(), function.unoptimized_code()); | 444 Code::Handle(deopt_context->isolate(), function.unoptimized_code()); |
445 ASSERT(!code.IsNull()); | 445 ASSERT(!code.IsNull()); |
446 intptr_t pc_marker = code.EntryPoint() + | 446 intptr_t pc_marker = code.EntryPoint() + |
447 AssemblerMacros::kOffsetOfSavedPCfromEntrypoint; | 447 AssemblerMacros::kOffsetOfSavedPCfromEntrypoint; |
448 intptr_t* to_addr = deopt_context->GetToFrameAddressAt(to_index); | 448 intptr_t* to_addr = deopt_context->GetToFrameAddressAt(to_index); |
449 *to_addr = pc_marker; | 449 *to_addr = pc_marker; |
450 // Increment the deoptimization counter. This effectively increments each | 450 // Increment the deoptimization counter. This effectively increments each |
451 // function occurring in the optimized frame. | 451 // function occurring in the optimized frame. |
452 function.set_deoptimization_counter(function.deoptimization_counter() + 1); | 452 function.set_deoptimization_counter(function.deoptimization_counter() + 1); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 uword DeoptInstr::GetRetAfterAddress(intptr_t from_index, | 578 uword DeoptInstr::GetRetAfterAddress(intptr_t from_index, |
579 const Array& object_table, | 579 const Array& object_table, |
580 Function* func) { | 580 Function* func) { |
581 ASSERT(!object_table.IsNull()); | 581 ASSERT(!object_table.IsNull()); |
582 ASSERT(func != NULL); | 582 ASSERT(func != NULL); |
583 intptr_t object_table_index; | 583 intptr_t object_table_index; |
584 intptr_t deopt_id; | 584 intptr_t deopt_id; |
585 DeoptRetAfterAddressInstr::GetEncodedValues(from_index, | 585 DeoptRetAfterAddressInstr::GetEncodedValues(from_index, |
586 &object_table_index, | 586 &object_table_index, |
587 &deopt_id); | 587 &deopt_id); |
588 *func ^= object_table.At(object_table_index); | 588 *func |= object_table.At(object_table_index); |
589 const Code& code = Code::Handle(func->unoptimized_code()); | 589 const Code& code = Code::Handle(func->unoptimized_code()); |
590 return code.GetDeoptAfterPcAtDeoptId(deopt_id); | 590 return code.GetDeoptAfterPcAtDeoptId(deopt_id); |
591 } | 591 } |
592 | 592 |
593 | 593 |
594 DeoptInstr* DeoptInstr::Create(intptr_t kind_as_int, intptr_t from_index) { | 594 DeoptInstr* DeoptInstr::Create(intptr_t kind_as_int, intptr_t from_index) { |
595 Kind kind = static_cast<Kind>(kind_as_int); | 595 Kind kind = static_cast<Kind>(kind_as_int); |
596 switch (kind) { | 596 switch (kind) { |
597 case kStackSlot: return new DeoptStackSlotInstr(from_index); | 597 case kStackSlot: return new DeoptStackSlotInstr(from_index); |
598 case kDoubleStackSlot: return new DeoptDoubleStackSlotInstr(from_index); | 598 case kDoubleStackSlot: return new DeoptDoubleStackSlotInstr(from_index); |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 return table.Length() / kEntrySize; | 816 return table.Length() / kEntrySize; |
817 } | 817 } |
818 | 818 |
819 | 819 |
820 void DeoptTable::GetEntry(const Array& table, | 820 void DeoptTable::GetEntry(const Array& table, |
821 intptr_t index, | 821 intptr_t index, |
822 Smi* offset, | 822 Smi* offset, |
823 DeoptInfo* info, | 823 DeoptInfo* info, |
824 Smi* reason) { | 824 Smi* reason) { |
825 intptr_t i = index * kEntrySize; | 825 intptr_t i = index * kEntrySize; |
826 *offset ^= table.At(i); | 826 *offset |= table.At(i); |
827 *info ^= table.At(i + 1); | 827 *info |= table.At(i + 1); |
828 *reason ^= table.At(i + 2); | 828 *reason |= table.At(i + 2); |
829 } | 829 } |
830 | 830 |
831 } // namespace dart | 831 } // namespace dart |
OLD | NEW |