| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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" |
| 11 #include "vm/parser.h" | 11 #include "vm/parser.h" |
| 12 | 12 |
| 13 namespace dart { | 13 namespace dart { |
| 14 | 14 |
| 15 DEFINE_FLAG(bool, compress_deopt_info, true, | 15 DEFINE_FLAG(bool, compress_deopt_info, true, |
| 16 "Compress the size of the deoptimization info for optimized code."); | 16 "Compress the size of the deoptimization info for optimized code."); |
| 17 DECLARE_FLAG(bool, trace_deoptimization); |
| 17 | 18 |
| 18 DeoptimizationContext::DeoptimizationContext(intptr_t* to_frame_start, | 19 DeoptimizationContext::DeoptimizationContext(intptr_t* to_frame_start, |
| 19 intptr_t to_frame_size, | 20 intptr_t to_frame_size, |
| 20 const Array& object_table, | 21 const Array& object_table, |
| 21 intptr_t num_args, | 22 intptr_t num_args, |
| 22 DeoptReasonId deopt_reason) | 23 DeoptReasonId deopt_reason) |
| 23 : object_table_(object_table), | 24 : object_table_(object_table), |
| 24 to_frame_(to_frame_start), | 25 to_frame_(to_frame_start), |
| 25 to_frame_size_(to_frame_size), | 26 to_frame_size_(to_frame_size), |
| 26 from_frame_(NULL), | 27 from_frame_(NULL), |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 const Code& code = | 437 const Code& code = |
| 437 Code::Handle(deopt_context->isolate(), function.unoptimized_code()); | 438 Code::Handle(deopt_context->isolate(), function.unoptimized_code()); |
| 438 ASSERT(!code.IsNull()); | 439 ASSERT(!code.IsNull()); |
| 439 intptr_t pc_marker = code.EntryPoint() + | 440 intptr_t pc_marker = code.EntryPoint() + |
| 440 AssemblerMacros::kOffsetOfSavedPCfromEntrypoint; | 441 AssemblerMacros::kOffsetOfSavedPCfromEntrypoint; |
| 441 intptr_t* to_addr = deopt_context->GetToFrameAddressAt(to_index); | 442 intptr_t* to_addr = deopt_context->GetToFrameAddressAt(to_index); |
| 442 *to_addr = pc_marker; | 443 *to_addr = pc_marker; |
| 443 // Increment the deoptimization counter. This effectively increments each | 444 // Increment the deoptimization counter. This effectively increments each |
| 444 // function occurring in the optimized frame. | 445 // function occurring in the optimized frame. |
| 445 function.set_deoptimization_counter(function.deoptimization_counter() + 1); | 446 function.set_deoptimization_counter(function.deoptimization_counter() + 1); |
| 447 if (FLAG_trace_deoptimization) { |
| 448 OS::PrintErr("Deoptimizing inlined %s (count %d)\n", |
| 449 function.ToFullyQualifiedCString(), |
| 450 function.deoptimization_counter()); |
| 451 } |
| 446 // Clear invocation counter so that hopefully the function gets reoptimized | 452 // Clear invocation counter so that hopefully the function gets reoptimized |
| 447 // only after more feedback has been collected. | 453 // only after more feedback has been collected. |
| 448 function.set_usage_counter(0); | 454 function.set_usage_counter(0); |
| 449 if (function.HasOptimizedCode()) function.SwitchToUnoptimizedCode(); | 455 if (function.HasOptimizedCode()) function.SwitchToUnoptimizedCode(); |
| 450 } | 456 } |
| 451 | 457 |
| 452 private: | 458 private: |
| 453 intptr_t object_table_index_; | 459 intptr_t object_table_index_; |
| 454 | 460 |
| 455 DISALLOW_COPY_AND_ASSIGN(DeoptPcMarkerInstr); | 461 DISALLOW_COPY_AND_ASSIGN(DeoptPcMarkerInstr); |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 794 Smi* offset, | 800 Smi* offset, |
| 795 DeoptInfo* info, | 801 DeoptInfo* info, |
| 796 Smi* reason) { | 802 Smi* reason) { |
| 797 intptr_t i = index * kEntrySize; | 803 intptr_t i = index * kEntrySize; |
| 798 *offset ^= table.At(i); | 804 *offset ^= table.At(i); |
| 799 *info ^= table.At(i + 1); | 805 *info ^= table.At(i + 1); |
| 800 *reason ^= table.At(i + 2); | 806 *reason ^= table.At(i + 2); |
| 801 } | 807 } |
| 802 | 808 |
| 803 } // namespace dart | 809 } // namespace dart |
| OLD | NEW |