| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 if (code_->kind() == Code::FUNCTION) PrintF(" NON-OPT"); | 675 if (code_->kind() == Code::FUNCTION) PrintF(" NON-OPT"); |
| 676 if (code_->kind() == Code::OPTIMIZED_FUNCTION) PrintF(" OPT"); | 676 if (code_->kind() == Code::OPTIMIZED_FUNCTION) PrintF(" OPT"); |
| 677 PrintF("\npc: %d\n", offset_); | 677 PrintF("\npc: %d\n", offset_); |
| 678 } | 678 } |
| 679 | 679 |
| 680 | 680 |
| 681 void OptimizedFrame::Summarize(List<FrameSummary>* frames) { | 681 void OptimizedFrame::Summarize(List<FrameSummary>* frames) { |
| 682 ASSERT(frames->length() == 0); | 682 ASSERT(frames->length() == 0); |
| 683 ASSERT(is_optimized()); | 683 ASSERT(is_optimized()); |
| 684 | 684 |
| 685 int deopt_index = AstNode::kNoNumber; | 685 AstId deopt_index = kNoAstId; |
| 686 DeoptimizationInputData* data = GetDeoptimizationData(&deopt_index); | 686 DeoptimizationInputData* data = GetDeoptimizationData(&deopt_index); |
| 687 | 687 |
| 688 // BUG(3243555): Since we don't have a lazy-deopt registered at | 688 // BUG(3243555): Since we don't have a lazy-deopt registered at |
| 689 // throw-statements, we can't use the translation at the call-site of | 689 // throw-statements, we can't use the translation at the call-site of |
| 690 // throw. An entry with no deoptimization index indicates a call-site | 690 // throw. An entry with no deoptimization index indicates a call-site |
| 691 // without a lazy-deopt. As a consequence we are not allowed to inline | 691 // without a lazy-deopt. As a consequence we are not allowed to inline |
| 692 // functions containing throw. | 692 // functions containing throw. |
| 693 if (deopt_index == Safepoint::kNoDeoptimizationIndex) { | 693 if (deopt_index == Safepoint::kNoDeoptimizationIndex) { |
| 694 JavaScriptFrame::Summarize(frames); | 694 JavaScriptFrame::Summarize(frames); |
| 695 return; | 695 return; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 frames->Add(summary); | 756 frames->Add(summary); |
| 757 } else { | 757 } else { |
| 758 // Skip over operands to advance to the next opcode. | 758 // Skip over operands to advance to the next opcode. |
| 759 it.Skip(Translation::NumberOfOperandsFor(opcode)); | 759 it.Skip(Translation::NumberOfOperandsFor(opcode)); |
| 760 } | 760 } |
| 761 } | 761 } |
| 762 } | 762 } |
| 763 | 763 |
| 764 | 764 |
| 765 DeoptimizationInputData* OptimizedFrame::GetDeoptimizationData( | 765 DeoptimizationInputData* OptimizedFrame::GetDeoptimizationData( |
| 766 int* deopt_index) { | 766 AstId* deopt_index) { |
| 767 ASSERT(is_optimized()); | 767 ASSERT(is_optimized()); |
| 768 | 768 |
| 769 JSFunction* opt_function = JSFunction::cast(function()); | 769 JSFunction* opt_function = JSFunction::cast(function()); |
| 770 Code* code = opt_function->code(); | 770 Code* code = opt_function->code(); |
| 771 | 771 |
| 772 // The code object may have been replaced by lazy deoptimization. Fall | 772 // The code object may have been replaced by lazy deoptimization. Fall |
| 773 // back to a slow search in this case to find the original optimized | 773 // back to a slow search in this case to find the original optimized |
| 774 // code object. | 774 // code object. |
| 775 if (!code->contains(pc())) { | 775 if (!code->contains(pc())) { |
| 776 code = PcToCodeCache::GcSafeFindCodeForPc(pc()); | 776 code = PcToCodeCache::GcSafeFindCodeForPc(pc()); |
| 777 } | 777 } |
| 778 ASSERT(code != NULL); | 778 ASSERT(code != NULL); |
| 779 ASSERT(code->kind() == Code::OPTIMIZED_FUNCTION); | 779 ASSERT(code->kind() == Code::OPTIMIZED_FUNCTION); |
| 780 | 780 |
| 781 SafepointTable table(code); | 781 SafepointTable table(code); |
| 782 unsigned pc_offset = static_cast<unsigned>(pc() - code->instruction_start()); | 782 unsigned pc_offset = static_cast<unsigned>(pc() - code->instruction_start()); |
| 783 for (unsigned i = 0; i < table.length(); i++) { | 783 for (unsigned i = 0; i < table.length(); i++) { |
| 784 if (table.GetPcOffset(i) == pc_offset) { | 784 if (table.GetPcOffset(i) == pc_offset) { |
| 785 *deopt_index = table.GetDeoptimizationIndex(i); | 785 *deopt_index = table.GetDeoptimizationIndex(i); |
| 786 break; | 786 break; |
| 787 } | 787 } |
| 788 } | 788 } |
| 789 ASSERT(*deopt_index != AstNode::kNoNumber); | 789 ASSERT(*deopt_index != kNoAstId); |
| 790 | 790 |
| 791 return DeoptimizationInputData::cast(code->deoptimization_data()); | 791 return DeoptimizationInputData::cast(code->deoptimization_data()); |
| 792 } | 792 } |
| 793 | 793 |
| 794 | 794 |
| 795 void OptimizedFrame::GetFunctions(List<JSFunction*>* functions) { | 795 void OptimizedFrame::GetFunctions(List<JSFunction*>* functions) { |
| 796 ASSERT(functions->length() == 0); | 796 ASSERT(functions->length() == 0); |
| 797 ASSERT(is_optimized()); | 797 ASSERT(is_optimized()); |
| 798 | 798 |
| 799 int deopt_index = AstNode::kNoNumber; | 799 AstId deopt_index = kNoAstId; |
| 800 DeoptimizationInputData* data = GetDeoptimizationData(&deopt_index); | 800 DeoptimizationInputData* data = GetDeoptimizationData(&deopt_index); |
| 801 | 801 |
| 802 TranslationIterator it(data->TranslationByteArray(), | 802 TranslationIterator it(data->TranslationByteArray(), |
| 803 data->TranslationIndex(deopt_index)->value()); | 803 data->TranslationIndex(deopt_index)->value()); |
| 804 Translation::Opcode opcode = static_cast<Translation::Opcode>(it.Next()); | 804 Translation::Opcode opcode = static_cast<Translation::Opcode>(it.Next()); |
| 805 ASSERT(opcode == Translation::BEGIN); | 805 ASSERT(opcode == Translation::BEGIN); |
| 806 int frame_count = it.Next(); | 806 int frame_count = it.Next(); |
| 807 | 807 |
| 808 // We insert the frames in reverse order because the frames | 808 // We insert the frames in reverse order because the frames |
| 809 // in the deoptimization translation are ordered bottom-to-top. | 809 // in the deoptimization translation are ordered bottom-to-top. |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1216 ZoneList<StackFrame*> list(10); | 1216 ZoneList<StackFrame*> list(10); |
| 1217 for (StackFrameIterator it; !it.done(); it.Advance()) { | 1217 for (StackFrameIterator it; !it.done(); it.Advance()) { |
| 1218 StackFrame* frame = AllocateFrameCopy(it.frame()); | 1218 StackFrame* frame = AllocateFrameCopy(it.frame()); |
| 1219 list.Add(frame); | 1219 list.Add(frame); |
| 1220 } | 1220 } |
| 1221 return list.ToVector(); | 1221 return list.ToVector(); |
| 1222 } | 1222 } |
| 1223 | 1223 |
| 1224 | 1224 |
| 1225 } } // namespace v8::internal | 1225 } } // namespace v8::internal |
| OLD | NEW |