Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Side by Side Diff: src/frames.cc

Issue 10103035: Share optimized code for closures. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/frames.h ('k') | src/heap.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 814 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 PrintF("\nfunction: "); 825 PrintF("\nfunction: ");
826 function_->shared()->DebugName()->ShortPrint(); 826 function_->shared()->DebugName()->ShortPrint();
827 PrintF("\ncode: "); 827 PrintF("\ncode: ");
828 code_->ShortPrint(); 828 code_->ShortPrint();
829 if (code_->kind() == Code::FUNCTION) PrintF(" NON-OPT"); 829 if (code_->kind() == Code::FUNCTION) PrintF(" NON-OPT");
830 if (code_->kind() == Code::OPTIMIZED_FUNCTION) PrintF(" OPT"); 830 if (code_->kind() == Code::OPTIMIZED_FUNCTION) PrintF(" OPT");
831 PrintF("\npc: %d\n", offset_); 831 PrintF("\npc: %d\n", offset_);
832 } 832 }
833 833
834 834
835 JSFunction* OptimizedFrame::LiteralAt(FixedArray* literal_array,
836 int literal_id) {
837 if (literal_id == Translation::kSelfLiteralId) {
838 return JSFunction::cast(function());
839 }
840
841 return JSFunction::cast(literal_array->get(literal_id));
842 }
843
844
835 void OptimizedFrame::Summarize(List<FrameSummary>* frames) { 845 void OptimizedFrame::Summarize(List<FrameSummary>* frames) {
836 ASSERT(frames->length() == 0); 846 ASSERT(frames->length() == 0);
837 ASSERT(is_optimized()); 847 ASSERT(is_optimized());
838 848
839 int deopt_index = Safepoint::kNoDeoptimizationIndex; 849 int deopt_index = Safepoint::kNoDeoptimizationIndex;
840 DeoptimizationInputData* data = GetDeoptimizationData(&deopt_index); 850 DeoptimizationInputData* data = GetDeoptimizationData(&deopt_index);
851 FixedArray* literal_array = data->LiteralArray();
841 852
842 // BUG(3243555): Since we don't have a lazy-deopt registered at 853 // BUG(3243555): Since we don't have a lazy-deopt registered at
843 // throw-statements, we can't use the translation at the call-site of 854 // throw-statements, we can't use the translation at the call-site of
844 // throw. An entry with no deoptimization index indicates a call-site 855 // throw. An entry with no deoptimization index indicates a call-site
845 // without a lazy-deopt. As a consequence we are not allowed to inline 856 // without a lazy-deopt. As a consequence we are not allowed to inline
846 // functions containing throw. 857 // functions containing throw.
847 if (deopt_index == Safepoint::kNoDeoptimizationIndex) { 858 if (deopt_index == Safepoint::kNoDeoptimizationIndex) {
848 JavaScriptFrame::Summarize(frames); 859 JavaScriptFrame::Summarize(frames);
849 return; 860 return;
850 } 861 }
851 862
852 TranslationIterator it(data->TranslationByteArray(), 863 TranslationIterator it(data->TranslationByteArray(),
853 data->TranslationIndex(deopt_index)->value()); 864 data->TranslationIndex(deopt_index)->value());
854 Translation::Opcode opcode = static_cast<Translation::Opcode>(it.Next()); 865 Translation::Opcode opcode = static_cast<Translation::Opcode>(it.Next());
855 ASSERT(opcode == Translation::BEGIN); 866 ASSERT(opcode == Translation::BEGIN);
856 it.Next(); // Drop frame count. 867 it.Next(); // Drop frame count.
857 int jsframe_count = it.Next(); 868 int jsframe_count = it.Next();
858 869
859 // We create the summary in reverse order because the frames 870 // We create the summary in reverse order because the frames
860 // in the deoptimization translation are ordered bottom-to-top. 871 // in the deoptimization translation are ordered bottom-to-top.
861 bool is_constructor = IsConstructor(); 872 bool is_constructor = IsConstructor();
862 int i = jsframe_count; 873 int i = jsframe_count;
863 while (i > 0) { 874 while (i > 0) {
864 opcode = static_cast<Translation::Opcode>(it.Next()); 875 opcode = static_cast<Translation::Opcode>(it.Next());
865 if (opcode == Translation::JS_FRAME) { 876 if (opcode == Translation::JS_FRAME) {
866 i--; 877 i--;
867 int ast_id = it.Next(); 878 int ast_id = it.Next();
868 int function_id = it.Next(); 879 JSFunction* function = LiteralAt(literal_array, it.Next());
869 it.Next(); // Skip height. 880 it.Next(); // Skip height.
870 JSFunction* function =
871 JSFunction::cast(data->LiteralArray()->get(function_id));
872 881
873 // The translation commands are ordered and the receiver is always 882 // The translation commands are ordered and the receiver is always
874 // at the first position. Since we are always at a call when we need 883 // at the first position. Since we are always at a call when we need
875 // to construct a stack trace, the receiver is always in a stack slot. 884 // to construct a stack trace, the receiver is always in a stack slot.
876 opcode = static_cast<Translation::Opcode>(it.Next()); 885 opcode = static_cast<Translation::Opcode>(it.Next());
877 ASSERT(opcode == Translation::STACK_SLOT || 886 ASSERT(opcode == Translation::STACK_SLOT ||
878 opcode == Translation::LITERAL); 887 opcode == Translation::LITERAL);
879 int index = it.Next(); 888 int index = it.Next();
880 889
881 // Get the correct receiver in the optimized frame. 890 // Get the correct receiver in the optimized frame.
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 return jsframe_count; 977 return jsframe_count;
969 } 978 }
970 979
971 980
972 void OptimizedFrame::GetFunctions(List<JSFunction*>* functions) { 981 void OptimizedFrame::GetFunctions(List<JSFunction*>* functions) {
973 ASSERT(functions->length() == 0); 982 ASSERT(functions->length() == 0);
974 ASSERT(is_optimized()); 983 ASSERT(is_optimized());
975 984
976 int deopt_index = Safepoint::kNoDeoptimizationIndex; 985 int deopt_index = Safepoint::kNoDeoptimizationIndex;
977 DeoptimizationInputData* data = GetDeoptimizationData(&deopt_index); 986 DeoptimizationInputData* data = GetDeoptimizationData(&deopt_index);
987 FixedArray* literal_array = data->LiteralArray();
978 988
979 TranslationIterator it(data->TranslationByteArray(), 989 TranslationIterator it(data->TranslationByteArray(),
980 data->TranslationIndex(deopt_index)->value()); 990 data->TranslationIndex(deopt_index)->value());
981 Translation::Opcode opcode = static_cast<Translation::Opcode>(it.Next()); 991 Translation::Opcode opcode = static_cast<Translation::Opcode>(it.Next());
982 ASSERT(opcode == Translation::BEGIN); 992 ASSERT(opcode == Translation::BEGIN);
983 it.Next(); // Drop frame count. 993 it.Next(); // Drop frame count.
984 int jsframe_count = it.Next(); 994 int jsframe_count = it.Next();
985 995
986 // We insert the frames in reverse order because the frames 996 // We insert the frames in reverse order because the frames
987 // in the deoptimization translation are ordered bottom-to-top. 997 // in the deoptimization translation are ordered bottom-to-top.
988 while (jsframe_count > 0) { 998 while (jsframe_count > 0) {
989 opcode = static_cast<Translation::Opcode>(it.Next()); 999 opcode = static_cast<Translation::Opcode>(it.Next());
990 if (opcode == Translation::JS_FRAME) { 1000 if (opcode == Translation::JS_FRAME) {
991 jsframe_count--; 1001 jsframe_count--;
992 it.Next(); // Skip ast id. 1002 it.Next(); // Skip ast id.
993 int function_id = it.Next(); 1003 JSFunction* function = LiteralAt(literal_array, it.Next());
994 it.Next(); // Skip height. 1004 it.Next(); // Skip height.
995 JSFunction* function =
996 JSFunction::cast(data->LiteralArray()->get(function_id));
997 functions->Add(function); 1005 functions->Add(function);
998 } else { 1006 } else {
999 // Skip over operands to advance to the next opcode. 1007 // Skip over operands to advance to the next opcode.
1000 it.Skip(Translation::NumberOfOperandsFor(opcode)); 1008 it.Skip(Translation::NumberOfOperandsFor(opcode));
1001 } 1009 }
1002 } 1010 }
1003 } 1011 }
1004 1012
1005 1013
1006 int ArgumentsAdaptorFrame::GetNumberOfIncomingArguments() const { 1014 int ArgumentsAdaptorFrame::GetNumberOfIncomingArguments() const {
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
1428 ZoneList<StackFrame*> list(10, zone); 1436 ZoneList<StackFrame*> list(10, zone);
1429 for (StackFrameIterator it; !it.done(); it.Advance()) { 1437 for (StackFrameIterator it; !it.done(); it.Advance()) {
1430 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); 1438 StackFrame* frame = AllocateFrameCopy(it.frame(), zone);
1431 list.Add(frame, zone); 1439 list.Add(frame, zone);
1432 } 1440 }
1433 return list.ToVector(); 1441 return list.ToVector();
1434 } 1442 }
1435 1443
1436 1444
1437 } } // namespace v8::internal 1445 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/frames.h ('k') | src/heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698