| 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 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 PrintF("\nfunction: "); | 687 PrintF("\nfunction: "); |
| 688 function_->shared()->DebugName()->ShortPrint(); | 688 function_->shared()->DebugName()->ShortPrint(); |
| 689 PrintF("\ncode: "); | 689 PrintF("\ncode: "); |
| 690 code_->ShortPrint(); | 690 code_->ShortPrint(); |
| 691 if (code_->kind() == Code::FUNCTION) PrintF(" NON-OPT"); | 691 if (code_->kind() == Code::FUNCTION) PrintF(" NON-OPT"); |
| 692 if (code_->kind() == Code::OPTIMIZED_FUNCTION) PrintF(" OPT"); | 692 if (code_->kind() == Code::OPTIMIZED_FUNCTION) PrintF(" OPT"); |
| 693 PrintF("\npc: %d\n", offset_); | 693 PrintF("\npc: %d\n", offset_); |
| 694 } | 694 } |
| 695 | 695 |
| 696 | 696 |
| 697 JSFunction* OptimizedFrame::LiteralAt(FixedArray* literal_array, |
| 698 int literal_id) { |
| 699 if (literal_id == Translation::kSelfLiteralId) { |
| 700 return JSFunction::cast(function()); |
| 701 } |
| 702 |
| 703 return JSFunction::cast(literal_array->get(literal_id)); |
| 704 } |
| 705 |
| 706 |
| 697 void OptimizedFrame::Summarize(List<FrameSummary>* frames) { | 707 void OptimizedFrame::Summarize(List<FrameSummary>* frames) { |
| 698 ASSERT(frames->length() == 0); | 708 ASSERT(frames->length() == 0); |
| 699 ASSERT(is_optimized()); | 709 ASSERT(is_optimized()); |
| 700 | 710 |
| 701 int deopt_index = Safepoint::kNoDeoptimizationIndex; | 711 int deopt_index = Safepoint::kNoDeoptimizationIndex; |
| 702 DeoptimizationInputData* data = GetDeoptimizationData(&deopt_index); | 712 DeoptimizationInputData* data = GetDeoptimizationData(&deopt_index); |
| 713 FixedArray* literal_array = data->LiteralArray(); |
| 703 | 714 |
| 704 // BUG(3243555): Since we don't have a lazy-deopt registered at | 715 // BUG(3243555): Since we don't have a lazy-deopt registered at |
| 705 // throw-statements, we can't use the translation at the call-site of | 716 // throw-statements, we can't use the translation at the call-site of |
| 706 // throw. An entry with no deoptimization index indicates a call-site | 717 // throw. An entry with no deoptimization index indicates a call-site |
| 707 // without a lazy-deopt. As a consequence we are not allowed to inline | 718 // without a lazy-deopt. As a consequence we are not allowed to inline |
| 708 // functions containing throw. | 719 // functions containing throw. |
| 709 if (deopt_index == Safepoint::kNoDeoptimizationIndex) { | 720 if (deopt_index == Safepoint::kNoDeoptimizationIndex) { |
| 710 JavaScriptFrame::Summarize(frames); | 721 JavaScriptFrame::Summarize(frames); |
| 711 return; | 722 return; |
| 712 } | 723 } |
| 713 | 724 |
| 714 TranslationIterator it(data->TranslationByteArray(), | 725 TranslationIterator it(data->TranslationByteArray(), |
| 715 data->TranslationIndex(deopt_index)->value()); | 726 data->TranslationIndex(deopt_index)->value()); |
| 716 Translation::Opcode opcode = static_cast<Translation::Opcode>(it.Next()); | 727 Translation::Opcode opcode = static_cast<Translation::Opcode>(it.Next()); |
| 717 ASSERT(opcode == Translation::BEGIN); | 728 ASSERT(opcode == Translation::BEGIN); |
| 718 int frame_count = it.Next(); | 729 int frame_count = it.Next(); |
| 719 | 730 |
| 720 // We create the summary in reverse order because the frames | 731 // We create the summary in reverse order because the frames |
| 721 // in the deoptimization translation are ordered bottom-to-top. | 732 // in the deoptimization translation are ordered bottom-to-top. |
| 722 int i = frame_count; | 733 int i = frame_count; |
| 723 while (i > 0) { | 734 while (i > 0) { |
| 724 opcode = static_cast<Translation::Opcode>(it.Next()); | 735 opcode = static_cast<Translation::Opcode>(it.Next()); |
| 725 if (opcode == Translation::FRAME) { | 736 if (opcode == Translation::FRAME) { |
| 726 // We don't inline constructor calls, so only the first, outermost | 737 // We don't inline constructor calls, so only the first, outermost |
| 727 // frame can be a constructor frame in case of inlining. | 738 // frame can be a constructor frame in case of inlining. |
| 728 bool is_constructor = (i == frame_count) && IsConstructor(); | 739 bool is_constructor = (i == frame_count) && IsConstructor(); |
| 729 | 740 |
| 730 i--; | 741 i--; |
| 731 int ast_id = it.Next(); | 742 int ast_id = it.Next(); |
| 732 int function_id = it.Next(); | 743 JSFunction* function = LiteralAt(literal_array, it.Next()); |
| 733 it.Next(); // Skip height. | 744 it.Next(); // Skip height. |
| 734 JSFunction* function = | |
| 735 JSFunction::cast(data->LiteralArray()->get(function_id)); | |
| 736 | 745 |
| 737 // The translation commands are ordered and the receiver is always | 746 // The translation commands are ordered and the receiver is always |
| 738 // at the first position. Since we are always at a call when we need | 747 // at the first position. Since we are always at a call when we need |
| 739 // to construct a stack trace, the receiver is always in a stack slot. | 748 // to construct a stack trace, the receiver is always in a stack slot. |
| 740 opcode = static_cast<Translation::Opcode>(it.Next()); | 749 opcode = static_cast<Translation::Opcode>(it.Next()); |
| 741 ASSERT(opcode == Translation::STACK_SLOT); | 750 ASSERT(opcode == Translation::STACK_SLOT); |
| 742 int input_slot_index = it.Next(); | 751 int input_slot_index = it.Next(); |
| 743 | 752 |
| 744 // Get the correct receiver in the optimized frame. | 753 // Get the correct receiver in the optimized frame. |
| 745 Object* receiver = NULL; | 754 Object* receiver = NULL; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 801 return DeoptimizationInputData::cast(code->deoptimization_data()); | 810 return DeoptimizationInputData::cast(code->deoptimization_data()); |
| 802 } | 811 } |
| 803 | 812 |
| 804 | 813 |
| 805 void OptimizedFrame::GetFunctions(List<JSFunction*>* functions) { | 814 void OptimizedFrame::GetFunctions(List<JSFunction*>* functions) { |
| 806 ASSERT(functions->length() == 0); | 815 ASSERT(functions->length() == 0); |
| 807 ASSERT(is_optimized()); | 816 ASSERT(is_optimized()); |
| 808 | 817 |
| 809 int deopt_index = Safepoint::kNoDeoptimizationIndex; | 818 int deopt_index = Safepoint::kNoDeoptimizationIndex; |
| 810 DeoptimizationInputData* data = GetDeoptimizationData(&deopt_index); | 819 DeoptimizationInputData* data = GetDeoptimizationData(&deopt_index); |
| 820 FixedArray* literal_array = data->LiteralArray(); |
| 811 | 821 |
| 812 TranslationIterator it(data->TranslationByteArray(), | 822 TranslationIterator it(data->TranslationByteArray(), |
| 813 data->TranslationIndex(deopt_index)->value()); | 823 data->TranslationIndex(deopt_index)->value()); |
| 814 Translation::Opcode opcode = static_cast<Translation::Opcode>(it.Next()); | 824 Translation::Opcode opcode = static_cast<Translation::Opcode>(it.Next()); |
| 815 ASSERT(opcode == Translation::BEGIN); | 825 ASSERT(opcode == Translation::BEGIN); |
| 816 int frame_count = it.Next(); | 826 int frame_count = it.Next(); |
| 817 | 827 |
| 818 // We insert the frames in reverse order because the frames | 828 // We insert the frames in reverse order because the frames |
| 819 // in the deoptimization translation are ordered bottom-to-top. | 829 // in the deoptimization translation are ordered bottom-to-top. |
| 820 while (frame_count > 0) { | 830 while (frame_count > 0) { |
| 821 opcode = static_cast<Translation::Opcode>(it.Next()); | 831 opcode = static_cast<Translation::Opcode>(it.Next()); |
| 822 if (opcode == Translation::FRAME) { | 832 if (opcode == Translation::FRAME) { |
| 823 frame_count--; | 833 frame_count--; |
| 824 it.Next(); // Skip ast id. | 834 it.Next(); // Skip ast id. |
| 825 int function_id = it.Next(); | 835 JSFunction* function = LiteralAt(literal_array, it.Next()); |
| 826 it.Next(); // Skip height. | 836 it.Next(); // Skip height. |
| 827 JSFunction* function = | |
| 828 JSFunction::cast(data->LiteralArray()->get(function_id)); | |
| 829 functions->Add(function); | 837 functions->Add(function); |
| 830 } else { | 838 } else { |
| 831 // Skip over operands to advance to the next opcode. | 839 // Skip over operands to advance to the next opcode. |
| 832 it.Skip(Translation::NumberOfOperandsFor(opcode)); | 840 it.Skip(Translation::NumberOfOperandsFor(opcode)); |
| 833 } | 841 } |
| 834 } | 842 } |
| 835 } | 843 } |
| 836 | 844 |
| 837 | 845 |
| 838 Address ArgumentsAdaptorFrame::GetCallerStackPointer() const { | 846 Address ArgumentsAdaptorFrame::GetCallerStackPointer() const { |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1233 ZoneList<StackFrame*> list(10); | 1241 ZoneList<StackFrame*> list(10); |
| 1234 for (StackFrameIterator it; !it.done(); it.Advance()) { | 1242 for (StackFrameIterator it; !it.done(); it.Advance()) { |
| 1235 StackFrame* frame = AllocateFrameCopy(it.frame()); | 1243 StackFrame* frame = AllocateFrameCopy(it.frame()); |
| 1236 list.Add(frame); | 1244 list.Add(frame); |
| 1237 } | 1245 } |
| 1238 return list.ToVector(); | 1246 return list.ToVector(); |
| 1239 } | 1247 } |
| 1240 | 1248 |
| 1241 | 1249 |
| 1242 } } // namespace v8::internal | 1250 } } // namespace v8::internal |
| OLD | NEW |