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

Side by Side Diff: src/frames.cc

Issue 1186823003: Clean up JSConstructStub (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: improve JavaScriptFrame::Print() 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/arm64/builtins-arm64.cc ('k') | src/ia32/builtins-ia32.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 // 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 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after
1040 } 1040 }
1041 1041
1042 1042
1043 void StackFrame::PrintIndex(StringStream* accumulator, 1043 void StackFrame::PrintIndex(StringStream* accumulator,
1044 PrintMode mode, 1044 PrintMode mode,
1045 int index) { 1045 int index) {
1046 accumulator->Add((mode == OVERVIEW) ? "%5d: " : "[%d]: ", index); 1046 accumulator->Add((mode == OVERVIEW) ? "%5d: " : "[%d]: ", index);
1047 } 1047 }
1048 1048
1049 1049
1050 static void PrintFunctionSource(StringStream* accumulator,
Benedikt Meurer 2015/06/17 03:21:39 Nit: Put into anonymous namespace instead of using
Jakob Kummerow 2015/06/17 11:23:45 Done.
1051 SharedFunctionInfo* shared, Code* code) {
1052 if (FLAG_max_stack_trace_source_length != 0 && code != NULL) {
1053 std::ostringstream os;
1054 os << "--------- s o u r c e c o d e ---------\n"
1055 << SourceCodeOf(shared, FLAG_max_stack_trace_source_length)
1056 << "\n-----------------------------------------\n";
1057 accumulator->Add(os.str().c_str());
1058 }
1059 }
1060
1061
1050 void JavaScriptFrame::Print(StringStream* accumulator, 1062 void JavaScriptFrame::Print(StringStream* accumulator,
1051 PrintMode mode, 1063 PrintMode mode,
1052 int index) const { 1064 int index) const {
1053 DisallowHeapAllocation no_gc; 1065 DisallowHeapAllocation no_gc;
1054 Object* receiver = this->receiver(); 1066 Object* receiver = this->receiver();
1055 JSFunction* function = this->function(); 1067 JSFunction* function = this->function();
1056 1068
1057 accumulator->PrintSecurityTokenIfChanged(function); 1069 accumulator->PrintSecurityTokenIfChanged(function);
1058 PrintIndex(accumulator, mode, index); 1070 PrintIndex(accumulator, mode, index);
1059 Code* code = NULL; 1071 Code* code = NULL;
(...skipping 17 matching lines...) Expand all
1077 pc >= code->instruction_start() && pc < code->instruction_end()) { 1089 pc >= code->instruction_start() && pc < code->instruction_end()) {
1078 int source_pos = code->SourcePosition(pc); 1090 int source_pos = code->SourcePosition(pc);
1079 int line = script->GetLineNumber(source_pos) + 1; 1091 int line = script->GetLineNumber(source_pos) + 1;
1080 accumulator->Add(":%d", line); 1092 accumulator->Add(":%d", line);
1081 } else { 1093 } else {
1082 int function_start_pos = shared->start_position(); 1094 int function_start_pos = shared->start_position();
1083 int line = script->GetLineNumber(function_start_pos) + 1; 1095 int line = script->GetLineNumber(function_start_pos) + 1;
1084 accumulator->Add(":~%d", line); 1096 accumulator->Add(":~%d", line);
1085 } 1097 }
1086 1098
1087 accumulator->Add("] "); 1099 accumulator->Add("] [pc=%p] ", pc);
1088 } 1100 }
1089 1101
1090 accumulator->Add("(this=%o", receiver); 1102 accumulator->Add("(this=%o", receiver);
1091 1103
1092 // Print the parameters. 1104 // Print the parameters.
1093 int parameters_count = ComputeParametersCount(); 1105 int parameters_count = ComputeParametersCount();
1094 for (int i = 0; i < parameters_count; i++) { 1106 for (int i = 0; i < parameters_count; i++) {
1095 accumulator->Add(","); 1107 accumulator->Add(",");
1096 // If we have a name for the parameter we print it. Nameless 1108 // If we have a name for the parameter we print it. Nameless
1097 // parameters are either because we have more actual parameters 1109 // parameters are either because we have more actual parameters
1098 // than formal parameters or because we have no scope information. 1110 // than formal parameters or because we have no scope information.
1099 if (i < scope_info->ParameterCount()) { 1111 if (i < scope_info->ParameterCount()) {
1100 accumulator->PrintName(scope_info->ParameterName(i)); 1112 accumulator->PrintName(scope_info->ParameterName(i));
1101 accumulator->Add("="); 1113 accumulator->Add("=");
1102 } 1114 }
1103 accumulator->Add("%o", GetParameter(i)); 1115 accumulator->Add("%o", GetParameter(i));
1104 } 1116 }
1105 1117
1106 accumulator->Add(")"); 1118 accumulator->Add(")");
1107 if (mode == OVERVIEW) { 1119 if (mode == OVERVIEW) {
1108 accumulator->Add("\n"); 1120 accumulator->Add("\n");
1109 return; 1121 return;
1110 } 1122 }
1111 if (is_optimized()) { 1123 if (is_optimized()) {
1112 accumulator->Add(" {\n// optimized frame\n}\n"); 1124 accumulator->Add(" {\n// optimized frame\n");
1125 PrintFunctionSource(accumulator, shared, code);
1126 accumulator->Add("}\n");
1113 return; 1127 return;
1114 } 1128 }
1115 accumulator->Add(" {\n"); 1129 accumulator->Add(" {\n");
1116 1130
1117 // Compute the number of locals and expression stack elements. 1131 // Compute the number of locals and expression stack elements.
1118 int stack_locals_count = scope_info->StackLocalCount(); 1132 int stack_locals_count = scope_info->StackLocalCount();
1119 int heap_locals_count = scope_info->ContextLocalCount(); 1133 int heap_locals_count = scope_info->ContextLocalCount();
1120 int expressions_count = ComputeExpressionsCount(); 1134 int expressions_count = ComputeExpressionsCount();
1121 1135
1122 // Print stack-allocated local variables. 1136 // Print stack-allocated local variables.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1169 1183
1170 // Print the expression stack. 1184 // Print the expression stack.
1171 int expressions_start = stack_locals_count; 1185 int expressions_start = stack_locals_count;
1172 if (expressions_start < expressions_count) { 1186 if (expressions_start < expressions_count) {
1173 accumulator->Add(" // expression stack (top to bottom)\n"); 1187 accumulator->Add(" // expression stack (top to bottom)\n");
1174 } 1188 }
1175 for (int i = expressions_count - 1; i >= expressions_start; i--) { 1189 for (int i = expressions_count - 1; i >= expressions_start; i--) {
1176 accumulator->Add(" [%02d] : %o\n", i, GetExpression(i)); 1190 accumulator->Add(" [%02d] : %o\n", i, GetExpression(i));
1177 } 1191 }
1178 1192
1179 // Print details about the function. 1193 PrintFunctionSource(accumulator, shared, code);
1180 if (FLAG_max_stack_trace_source_length != 0 && code != NULL) {
1181 std::ostringstream os;
1182 SharedFunctionInfo* shared = function->shared();
1183 os << "--------- s o u r c e c o d e ---------\n"
1184 << SourceCodeOf(shared, FLAG_max_stack_trace_source_length)
1185 << "\n-----------------------------------------\n";
1186 accumulator->Add(os.str().c_str());
1187 }
1188 1194
1189 accumulator->Add("}\n\n"); 1195 accumulator->Add("}\n\n");
1190 } 1196 }
1191 1197
1192 1198
1193 void ArgumentsAdaptorFrame::Print(StringStream* accumulator, 1199 void ArgumentsAdaptorFrame::Print(StringStream* accumulator,
1194 PrintMode mode, 1200 PrintMode mode,
1195 int index) const { 1201 int index) const {
1196 int actual = ComputeParametersCount(); 1202 int actual = ComputeParametersCount();
1197 int expected = -1; 1203 int expected = -1;
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
1451 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { 1457 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) {
1452 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); 1458 StackFrame* frame = AllocateFrameCopy(it.frame(), zone);
1453 list.Add(frame, zone); 1459 list.Add(frame, zone);
1454 } 1460 }
1455 return list.ToVector(); 1461 return list.ToVector();
1456 } 1462 }
1457 1463
1458 1464
1459 } // namespace internal 1465 } // namespace internal
1460 } // namespace v8 1466 } // namespace v8
OLDNEW
« no previous file with comments | « src/arm64/builtins-arm64.cc ('k') | src/ia32/builtins-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698