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

Side by Side Diff: src/frames.cc

Issue 1166353004: [deoptimizer] Remove uses of TranslationIterator outside the deoptimizer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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
« no previous file with comments | « src/deoptimizer.cc ('k') | no next file » | 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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/frames.h" 5 #include "src/frames.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 8
9 #include "src/v8.h" 9 #include "src/v8.h"
10 10
(...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 DCHECK(frames->length() == 0); 877 DCHECK(frames->length() == 0);
878 DCHECK(is_optimized()); 878 DCHECK(is_optimized());
879 879
880 // Delegate to JS frame in absence of turbofan deoptimization. 880 // Delegate to JS frame in absence of turbofan deoptimization.
881 // TODO(turbofan): Revisit once we support deoptimization across the board. 881 // TODO(turbofan): Revisit once we support deoptimization across the board.
882 if (LookupCode()->is_turbofanned() && function()->shared()->asm_function() && 882 if (LookupCode()->is_turbofanned() && function()->shared()->asm_function() &&
883 !FLAG_turbo_asm_deoptimization) { 883 !FLAG_turbo_asm_deoptimization) {
884 return JavaScriptFrame::Summarize(frames); 884 return JavaScriptFrame::Summarize(frames);
885 } 885 }
886 886
887 int deopt_index = Safepoint::kNoDeoptimizationIndex;
888 DeoptimizationInputData* data = GetDeoptimizationData(&deopt_index);
889 FixedArray* literal_array = data->LiteralArray();
890
891 // BUG(3243555): Since we don't have a lazy-deopt registered at
892 // throw-statements, we can't use the translation at the call-site of
893 // throw. An entry with no deoptimization index indicates a call-site
894 // without a lazy-deopt. As a consequence we are not allowed to inline
895 // functions containing throw.
896 DCHECK(deopt_index != Safepoint::kNoDeoptimizationIndex);
897
898 TranslationIterator it(data->TranslationByteArray(),
899 data->TranslationIndex(deopt_index)->value());
900 Translation::Opcode opcode = static_cast<Translation::Opcode>(it.Next());
901 DCHECK(opcode == Translation::BEGIN);
902 it.Next(); // Drop frame count.
903 int jsframe_count = it.Next();
904
905 // We create the summary in reverse order because the frames 887 // We create the summary in reverse order because the frames
906 // in the deoptimization translation are ordered bottom-to-top. 888 // in the deoptimization translation are ordered bottom-to-top.
889 TranslatedState state(this);
Jarin 2015/06/09 12:32:53 I am wondering whether we should put this in no-al
907 bool is_constructor = IsConstructor(); 890 bool is_constructor = IsConstructor();
908 int i = jsframe_count; 891 for (TranslatedFrame const& frame : state) {
909 while (i > 0) { 892 switch (frame.kind()) {
910 opcode = static_cast<Translation::Opcode>(it.Next()); 893 case TranslatedFrame::kFunction: {
911 if (opcode == Translation::JS_FRAME) { 894 BailoutId const ast_id = frame.node_id();
912 i--; 895 JSFunction* const function = frame.raw_function();
913 BailoutId ast_id = BailoutId(it.Next());
914 JSFunction* function = LiteralAt(literal_array, it.Next());
915 it.Next(); // Skip height.
916 896
917 // The translation commands are ordered and the receiver is always 897 // Get the correct receiver in the optimized frame.
918 // at the first position. 898 Object* receiver = frame.front().GetRawValue();
919 // If we are at a call, the receiver is always in a stack slot. 899 if (receiver == isolate()->heap()->arguments_marker()) {
920 // Otherwise we are not guaranteed to get the receiver value. 900 // TODO(jarin): Materializing a captured object (or duplicated
921 opcode = static_cast<Translation::Opcode>(it.Next()); 901 // object) is hard, we return undefined for now. This breaks the
922 int index = it.Next(); 902 // produced stack trace, as constructor frames aren't marked as
903 // such anymore.
904 receiver = isolate()->heap()->undefined_value();
905 }
923 906
924 // Get the correct receiver in the optimized frame. 907 Code* code = function->shared()->code();
925 Object* receiver = NULL; 908 DeoptimizationOutputData* output_data =
926 if (opcode == Translation::LITERAL) { 909 DeoptimizationOutputData::cast(code->deoptimization_data());
927 receiver = data->LiteralArray()->get(index); 910 unsigned entry =
928 } else if (opcode == Translation::STACK_SLOT) { 911 Deoptimizer::GetOutputInfo(output_data, ast_id, function->shared());
929 // Positive index means the value is spilled to the locals 912 unsigned pc_offset =
930 // area. Negative means it is stored in the incoming parameter 913 FullCodeGenerator::PcField::decode(entry) + Code::kHeaderSize;
931 // area. 914 DCHECK(pc_offset > 0);
932 if (index >= 0) { 915
933 receiver = GetExpression(index); 916 FrameSummary summary(receiver, function, code, pc_offset,
934 } else { 917 is_constructor);
935 // Index -1 overlaps with last parameter, -n with the first parameter, 918 frames->Add(summary);
936 // (-n - 1) with the receiver with n being the number of parameters 919 is_constructor = false;
937 // of the outermost, optimized frame. 920 break;
938 int parameter_count = ComputeParametersCount();
939 int parameter_index = index + parameter_count;
940 receiver = (parameter_index == -1)
941 ? this->receiver()
942 : this->GetParameter(parameter_index);
943 }
944 } else {
945 // The receiver is not in a stack slot nor in a literal. We give up.
946 // TODO(3029): Materializing a captured object (or duplicated
947 // object) is hard, we return undefined for now. This breaks the
948 // produced stack trace, as constructor frames aren't marked as
949 // such anymore.
950 receiver = isolate()->heap()->undefined_value();
951 } 921 }
952 922
953 Code* code = function->shared()->code(); 923 case TranslatedFrame::kConstructStub: {
954 DeoptimizationOutputData* output_data = 924 // The next encountered JS_FRAME will be marked as a constructor call.
955 DeoptimizationOutputData::cast(code->deoptimization_data()); 925 DCHECK(!is_constructor);
956 unsigned entry = Deoptimizer::GetOutputInfo(output_data, 926 is_constructor = true;
957 ast_id, 927 break;
958 function->shared()); 928 }
959 unsigned pc_offset =
960 FullCodeGenerator::PcField::decode(entry) + Code::kHeaderSize;
961 DCHECK(pc_offset > 0);
962 929
963 FrameSummary summary(receiver, function, code, pc_offset, is_constructor); 930 case TranslatedFrame::kInvalid:
964 frames->Add(summary); 931 UNREACHABLE();
965 is_constructor = false; 932 case TranslatedFrame::kArgumentsAdaptor:
966 } else if (opcode == Translation::CONSTRUCT_STUB_FRAME) { 933 case TranslatedFrame::kCompiledStub:
967 // The next encountered JS_FRAME will be marked as a constructor call. 934 case TranslatedFrame::kGetter:
968 it.Skip(Translation::NumberOfOperandsFor(opcode)); 935 case TranslatedFrame::kSetter:
969 DCHECK(!is_constructor); 936 break;
970 is_constructor = true;
971 } else {
972 // Skip over operands to advance to the next opcode.
973 it.Skip(Translation::NumberOfOperandsFor(opcode));
974 } 937 }
975 } 938 }
976 DCHECK(!is_constructor); 939 DCHECK(!is_constructor);
977 } 940 }
978 941
979 942
980 int OptimizedFrame::LookupExceptionHandlerInTable( 943 int OptimizedFrame::LookupExceptionHandlerInTable(
981 int* stack_slots, HandlerTable::CatchPrediction* prediction) { 944 int* stack_slots, HandlerTable::CatchPrediction* prediction) {
982 Code* code = LookupCode(); 945 Code* code = LookupCode();
983 DCHECK(code->is_optimized_code()); 946 DCHECK(code->is_optimized_code());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1017 DCHECK(functions->length() == 0); 980 DCHECK(functions->length() == 0);
1018 DCHECK(is_optimized()); 981 DCHECK(is_optimized());
1019 982
1020 // Delegate to JS frame in absence of turbofan deoptimization. 983 // Delegate to JS frame in absence of turbofan deoptimization.
1021 // TODO(turbofan): Revisit once we support deoptimization across the board. 984 // TODO(turbofan): Revisit once we support deoptimization across the board.
1022 if (LookupCode()->is_turbofanned() && function()->shared()->asm_function() && 985 if (LookupCode()->is_turbofanned() && function()->shared()->asm_function() &&
1023 !FLAG_turbo_asm_deoptimization) { 986 !FLAG_turbo_asm_deoptimization) {
1024 return JavaScriptFrame::GetFunctions(functions); 987 return JavaScriptFrame::GetFunctions(functions);
1025 } 988 }
1026 989
1027 int deopt_index = Safepoint::kNoDeoptimizationIndex; 990 TranslatedState state(this);
1028 DeoptimizationInputData* data = GetDeoptimizationData(&deopt_index); 991 for (TranslatedFrame const& frame : state) {
1029 FixedArray* literal_array = data->LiteralArray(); 992 if (frame.kind() == TranslatedFrame::kFunction) {
1030 993 functions->Add(frame.raw_function());
1031 TranslationIterator it(data->TranslationByteArray(),
1032 data->TranslationIndex(deopt_index)->value());
1033 Translation::Opcode opcode = static_cast<Translation::Opcode>(it.Next());
1034 DCHECK(opcode == Translation::BEGIN);
1035 it.Next(); // Drop frame count.
1036 int jsframe_count = it.Next();
1037
1038 // We insert the frames in reverse order because the frames
1039 // in the deoptimization translation are ordered bottom-to-top.
1040 while (jsframe_count > 0) {
1041 opcode = static_cast<Translation::Opcode>(it.Next());
1042 if (opcode == Translation::JS_FRAME) {
1043 jsframe_count--;
1044 it.Next(); // Skip ast id.
1045 JSFunction* function = LiteralAt(literal_array, it.Next());
1046 it.Next(); // Skip height.
1047 functions->Add(function);
1048 } else {
1049 // Skip over operands to advance to the next opcode.
1050 it.Skip(Translation::NumberOfOperandsFor(opcode));
1051 } 994 }
1052 } 995 }
1053 } 996 }
1054 997
1055 998
1056 int ArgumentsAdaptorFrame::GetNumberOfIncomingArguments() const { 999 int ArgumentsAdaptorFrame::GetNumberOfIncomingArguments() const {
1057 return Smi::cast(GetExpression(0))->value(); 1000 return Smi::cast(GetExpression(0))->value();
1058 } 1001 }
1059 1002
1060 1003
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
1495 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { 1438 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) {
1496 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); 1439 StackFrame* frame = AllocateFrameCopy(it.frame(), zone);
1497 list.Add(frame, zone); 1440 list.Add(frame, zone);
1498 } 1441 }
1499 return list.ToVector(); 1442 return list.ToVector();
1500 } 1443 }
1501 1444
1502 1445
1503 } // namespace internal 1446 } // namespace internal
1504 } // namespace v8 1447 } // namespace v8
OLDNEW
« no previous file with comments | « src/deoptimizer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698