OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
811 PrintF("\nfunction: "); | 811 PrintF("\nfunction: "); |
812 function_->shared()->DebugName()->ShortPrint(); | 812 function_->shared()->DebugName()->ShortPrint(); |
813 PrintF("\ncode: "); | 813 PrintF("\ncode: "); |
814 code_->ShortPrint(); | 814 code_->ShortPrint(); |
815 if (code_->kind() == Code::FUNCTION) PrintF(" NON-OPT"); | 815 if (code_->kind() == Code::FUNCTION) PrintF(" NON-OPT"); |
816 if (code_->kind() == Code::OPTIMIZED_FUNCTION) PrintF(" OPT"); | 816 if (code_->kind() == Code::OPTIMIZED_FUNCTION) PrintF(" OPT"); |
817 PrintF("\npc: %d\n", offset_); | 817 PrintF("\npc: %d\n", offset_); |
818 } | 818 } |
819 | 819 |
820 | 820 |
821 JSFunction* OptimizedFrame::LiteralAt(FixedArray* literal_array, | |
822 int literal_id) { | |
823 if (literal_id == Translation::kSelfLiteralId) { | |
824 return JSFunction::cast(function()); | |
825 } | |
826 | |
827 return JSFunction::cast(literal_array->get(literal_id)); | |
828 } | |
829 | |
830 | |
821 void OptimizedFrame::Summarize(List<FrameSummary>* frames) { | 831 void OptimizedFrame::Summarize(List<FrameSummary>* frames) { |
822 ASSERT(frames->length() == 0); | 832 ASSERT(frames->length() == 0); |
823 ASSERT(is_optimized()); | 833 ASSERT(is_optimized()); |
824 | 834 |
825 int deopt_index = Safepoint::kNoDeoptimizationIndex; | 835 int deopt_index = Safepoint::kNoDeoptimizationIndex; |
826 DeoptimizationInputData* data = GetDeoptimizationData(&deopt_index); | 836 DeoptimizationInputData* data = GetDeoptimizationData(&deopt_index); |
837 FixedArray* literal_array = data->LiteralArray(); | |
Michael Starzinger
2012/05/23 11:16:29
I know this is not part of your change, but for co
| |
827 | 838 |
828 // BUG(3243555): Since we don't have a lazy-deopt registered at | 839 // BUG(3243555): Since we don't have a lazy-deopt registered at |
829 // throw-statements, we can't use the translation at the call-site of | 840 // throw-statements, we can't use the translation at the call-site of |
830 // throw. An entry with no deoptimization index indicates a call-site | 841 // throw. An entry with no deoptimization index indicates a call-site |
831 // without a lazy-deopt. As a consequence we are not allowed to inline | 842 // without a lazy-deopt. As a consequence we are not allowed to inline |
832 // functions containing throw. | 843 // functions containing throw. |
833 if (deopt_index == Safepoint::kNoDeoptimizationIndex) { | 844 if (deopt_index == Safepoint::kNoDeoptimizationIndex) { |
834 JavaScriptFrame::Summarize(frames); | 845 JavaScriptFrame::Summarize(frames); |
835 return; | 846 return; |
836 } | 847 } |
837 | 848 |
838 TranslationIterator it(data->TranslationByteArray(), | 849 TranslationIterator it(data->TranslationByteArray(), |
839 data->TranslationIndex(deopt_index)->value()); | 850 data->TranslationIndex(deopt_index)->value()); |
840 Translation::Opcode opcode = static_cast<Translation::Opcode>(it.Next()); | 851 Translation::Opcode opcode = static_cast<Translation::Opcode>(it.Next()); |
841 ASSERT(opcode == Translation::BEGIN); | 852 ASSERT(opcode == Translation::BEGIN); |
842 it.Next(); // Drop frame count. | 853 it.Next(); // Drop frame count. |
843 int jsframe_count = it.Next(); | 854 int jsframe_count = it.Next(); |
844 | 855 |
845 // We create the summary in reverse order because the frames | 856 // We create the summary in reverse order because the frames |
846 // in the deoptimization translation are ordered bottom-to-top. | 857 // in the deoptimization translation are ordered bottom-to-top. |
847 bool is_constructor = IsConstructor(); | 858 bool is_constructor = IsConstructor(); |
848 int i = jsframe_count; | 859 int i = jsframe_count; |
849 while (i > 0) { | 860 while (i > 0) { |
850 opcode = static_cast<Translation::Opcode>(it.Next()); | 861 opcode = static_cast<Translation::Opcode>(it.Next()); |
851 if (opcode == Translation::JS_FRAME) { | 862 if (opcode == Translation::JS_FRAME) { |
852 i--; | 863 i--; |
853 int ast_id = it.Next(); | 864 int ast_id = it.Next(); |
854 int function_id = it.Next(); | 865 JSFunction* function = LiteralAt(literal_array, it.Next()); |
855 it.Next(); // Skip height. | 866 it.Next(); // Skip height. |
856 JSFunction* function = | |
857 JSFunction::cast(data->LiteralArray()->get(function_id)); | |
858 | 867 |
859 // The translation commands are ordered and the receiver is always | 868 // The translation commands are ordered and the receiver is always |
860 // at the first position. Since we are always at a call when we need | 869 // at the first position. Since we are always at a call when we need |
861 // to construct a stack trace, the receiver is always in a stack slot. | 870 // to construct a stack trace, the receiver is always in a stack slot. |
862 opcode = static_cast<Translation::Opcode>(it.Next()); | 871 opcode = static_cast<Translation::Opcode>(it.Next()); |
863 ASSERT(opcode == Translation::STACK_SLOT || | 872 ASSERT(opcode == Translation::STACK_SLOT || |
864 opcode == Translation::LITERAL); | 873 opcode == Translation::LITERAL); |
865 int index = it.Next(); | 874 int index = it.Next(); |
866 | 875 |
867 // Get the correct receiver in the optimized frame. | 876 // Get the correct receiver in the optimized frame. |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
954 return jsframe_count; | 963 return jsframe_count; |
955 } | 964 } |
956 | 965 |
957 | 966 |
958 void OptimizedFrame::GetFunctions(List<JSFunction*>* functions) { | 967 void OptimizedFrame::GetFunctions(List<JSFunction*>* functions) { |
959 ASSERT(functions->length() == 0); | 968 ASSERT(functions->length() == 0); |
960 ASSERT(is_optimized()); | 969 ASSERT(is_optimized()); |
961 | 970 |
962 int deopt_index = Safepoint::kNoDeoptimizationIndex; | 971 int deopt_index = Safepoint::kNoDeoptimizationIndex; |
963 DeoptimizationInputData* data = GetDeoptimizationData(&deopt_index); | 972 DeoptimizationInputData* data = GetDeoptimizationData(&deopt_index); |
973 FixedArray* literal_array = data->LiteralArray(); | |
964 | 974 |
965 TranslationIterator it(data->TranslationByteArray(), | 975 TranslationIterator it(data->TranslationByteArray(), |
966 data->TranslationIndex(deopt_index)->value()); | 976 data->TranslationIndex(deopt_index)->value()); |
967 Translation::Opcode opcode = static_cast<Translation::Opcode>(it.Next()); | 977 Translation::Opcode opcode = static_cast<Translation::Opcode>(it.Next()); |
968 ASSERT(opcode == Translation::BEGIN); | 978 ASSERT(opcode == Translation::BEGIN); |
969 it.Next(); // Drop frame count. | 979 it.Next(); // Drop frame count. |
970 int jsframe_count = it.Next(); | 980 int jsframe_count = it.Next(); |
971 | 981 |
972 // We insert the frames in reverse order because the frames | 982 // We insert the frames in reverse order because the frames |
973 // in the deoptimization translation are ordered bottom-to-top. | 983 // in the deoptimization translation are ordered bottom-to-top. |
974 while (jsframe_count > 0) { | 984 while (jsframe_count > 0) { |
975 opcode = static_cast<Translation::Opcode>(it.Next()); | 985 opcode = static_cast<Translation::Opcode>(it.Next()); |
976 if (opcode == Translation::JS_FRAME) { | 986 if (opcode == Translation::JS_FRAME) { |
977 jsframe_count--; | 987 jsframe_count--; |
978 it.Next(); // Skip ast id. | 988 it.Next(); // Skip ast id. |
979 int function_id = it.Next(); | 989 JSFunction* function = LiteralAt(literal_array, it.Next()); |
980 it.Next(); // Skip height. | 990 it.Next(); // Skip height. |
981 JSFunction* function = | |
982 JSFunction::cast(data->LiteralArray()->get(function_id)); | |
983 functions->Add(function); | 991 functions->Add(function); |
984 } else { | 992 } else { |
985 // Skip over operands to advance to the next opcode. | 993 // Skip over operands to advance to the next opcode. |
986 it.Skip(Translation::NumberOfOperandsFor(opcode)); | 994 it.Skip(Translation::NumberOfOperandsFor(opcode)); |
987 } | 995 } |
988 } | 996 } |
989 } | 997 } |
990 | 998 |
991 | 999 |
992 int ArgumentsAdaptorFrame::GetNumberOfIncomingArguments() const { | 1000 int ArgumentsAdaptorFrame::GetNumberOfIncomingArguments() const { |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1414 ZoneList<StackFrame*> list(10); | 1422 ZoneList<StackFrame*> list(10); |
1415 for (StackFrameIterator it; !it.done(); it.Advance()) { | 1423 for (StackFrameIterator it; !it.done(); it.Advance()) { |
1416 StackFrame* frame = AllocateFrameCopy(it.frame()); | 1424 StackFrame* frame = AllocateFrameCopy(it.frame()); |
1417 list.Add(frame); | 1425 list.Add(frame); |
1418 } | 1426 } |
1419 return list.ToVector(); | 1427 return list.ToVector(); |
1420 } | 1428 } |
1421 | 1429 |
1422 | 1430 |
1423 } } // namespace v8::internal | 1431 } } // namespace v8::internal |
OLD | NEW |