| 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" |
| 11 #include "vm/parser.h" | 11 #include "vm/parser.h" |
| 12 #include "vm/stack_frame.h" | 12 #include "vm/stack_frame.h" |
| 13 #include "vm/trace_buffer.h" |
| 13 | 14 |
| 14 namespace dart { | 15 namespace dart { |
| 15 | 16 |
| 16 DEFINE_FLAG(bool, compress_deopt_info, true, | 17 DEFINE_FLAG(bool, compress_deopt_info, true, |
| 17 "Compress the size of the deoptimization info for optimized code."); | 18 "Compress the size of the deoptimization info for optimized code."); |
| 18 DECLARE_FLAG(bool, trace_deoptimization); | 19 DECLARE_FLAG(bool, trace_deoptimization); |
| 19 DECLARE_FLAG(bool, trace_deoptimization_verbose); | 20 DECLARE_FLAG(bool, trace_deoptimization_verbose); |
| 20 | 21 |
| 21 | 22 |
| 22 DeoptContext::DeoptContext(const StackFrame* frame, | 23 DeoptContext::DeoptContext(const StackFrame* frame, |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 FillDeferredSlots(this, &deferred_object_refs_); | 333 FillDeferredSlots(this, &deferred_object_refs_); |
| 333 | 334 |
| 334 // Compute total number of artificial arguments used during deoptimization. | 335 // Compute total number of artificial arguments used during deoptimization. |
| 335 intptr_t deopt_arg_count = 0; | 336 intptr_t deopt_arg_count = 0; |
| 336 for (intptr_t i = 0; i < DeferredObjectsCount(); i++) { | 337 for (intptr_t i = 0; i < DeferredObjectsCount(); i++) { |
| 337 deopt_arg_count += GetDeferredObject(i)->ArgumentCount(); | 338 deopt_arg_count += GetDeferredObject(i)->ArgumentCount(); |
| 338 } | 339 } |
| 339 | 340 |
| 340 // Since this is the only step where GC can occur during deoptimization, | 341 // Since this is the only step where GC can occur during deoptimization, |
| 341 // use it to report the source line where deoptimization occured. | 342 // use it to report the source line where deoptimization occured. |
| 343 const Code& code = Code::Handle(code_); |
| 344 ASSERT(!code.IsNull()); |
| 345 const Function& top_function = Function::Handle(code.function()); |
| 346 // TODO(johnmccutchan): Enable appending service objects to a trace message. |
| 347 // Once that is possible, add the Code object which was deoptimized. |
| 348 top_function.log()->TraceF("Deoptimized (reason %" Pd " '%s')", |
| 349 static_cast<intptr_t>(deopt_reason()), |
| 350 DeoptReasonToText(deopt_reason())); |
| 351 |
| 342 if (FLAG_trace_deoptimization || FLAG_trace_deoptimization_verbose) { | 352 if (FLAG_trace_deoptimization || FLAG_trace_deoptimization_verbose) { |
| 343 DartFrameIterator iterator; | 353 DartFrameIterator iterator; |
| 344 StackFrame* top_frame = iterator.NextFrame(); | 354 StackFrame* top_frame = iterator.NextFrame(); |
| 345 ASSERT(top_frame != NULL); | 355 ASSERT(top_frame != NULL); |
| 346 const Code& code = Code::Handle(top_frame->LookupDartCode()); | |
| 347 const Function& top_function = Function::Handle(code.function()); | |
| 348 const Script& script = Script::Handle(top_function.script()); | 356 const Script& script = Script::Handle(top_function.script()); |
| 349 const intptr_t token_pos = code.GetTokenIndexOfPC(top_frame->pc()); | 357 const intptr_t token_pos = code.GetTokenIndexOfPC(top_frame->pc()); |
| 350 intptr_t line, column; | 358 intptr_t line, column; |
| 351 script.GetTokenLocation(token_pos, &line, &column); | 359 script.GetTokenLocation(token_pos, &line, &column); |
| 352 String& line_string = String::Handle(script.GetLine(line)); | 360 String& line_string = String::Handle(script.GetLine(line)); |
| 353 OS::PrintErr(" Function: %s\n", top_function.ToFullyQualifiedCString()); | 361 OS::PrintErr(" Function: %s\n", top_function.ToFullyQualifiedCString()); |
| 354 OS::PrintErr(" Line %" Pd ": '%s'\n", line, line_string.ToCString()); | 362 OS::PrintErr(" Line %" Pd ": '%s'\n", line, line_string.ToCString()); |
| 355 OS::PrintErr(" Deopt args: %" Pd "\n", deopt_arg_count); | 363 OS::PrintErr(" Deopt args: %" Pd "\n", deopt_arg_count); |
| 364 top_function.log()->TraceF("Deoptimized at line %" Pd ": '%s'", |
| 365 line, |
| 366 line_string.ToCString()); |
| 356 } | 367 } |
| 357 | 368 |
| 358 return deopt_arg_count; | 369 return deopt_arg_count; |
| 359 } | 370 } |
| 360 | 371 |
| 361 | 372 |
| 362 RawArray* DeoptContext::DestFrameAsArray() { | 373 RawArray* DeoptContext::DestFrameAsArray() { |
| 363 ASSERT(dest_frame_ != NULL && dest_frame_is_allocated_); | 374 ASSERT(dest_frame_ != NULL && dest_frame_is_allocated_); |
| 364 const Array& dest_array = | 375 const Array& dest_array = |
| 365 Array::Handle(Array::New(dest_frame_size_)); | 376 Array::Handle(Array::New(dest_frame_size_)); |
| (...skipping 1111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1477 Smi* offset, | 1488 Smi* offset, |
| 1478 DeoptInfo* info, | 1489 DeoptInfo* info, |
| 1479 Smi* reason) { | 1490 Smi* reason) { |
| 1480 intptr_t i = index * kEntrySize; | 1491 intptr_t i = index * kEntrySize; |
| 1481 *offset ^= table.At(i); | 1492 *offset ^= table.At(i); |
| 1482 *info ^= table.At(i + 1); | 1493 *info ^= table.At(i + 1); |
| 1483 *reason ^= table.At(i + 2); | 1494 *reason ^= table.At(i + 2); |
| 1484 } | 1495 } |
| 1485 | 1496 |
| 1486 } // namespace dart | 1497 } // namespace dart |
| OLD | NEW |