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

Side by Side Diff: src/frames.cc

Issue 8352039: Cleanup ScopeInfo and SerializedScopeInfo. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Converted ScopeInfo accessors to CamelCase. Created 9 years, 1 month 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/factory.cc ('k') | src/full-codegen.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 984 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 HandleScope scope; 995 HandleScope scope;
996 Object* receiver = this->receiver(); 996 Object* receiver = this->receiver();
997 Object* function = this->function(); 997 Object* function = this->function();
998 998
999 accumulator->PrintSecurityTokenIfChanged(function); 999 accumulator->PrintSecurityTokenIfChanged(function);
1000 PrintIndex(accumulator, mode, index); 1000 PrintIndex(accumulator, mode, index);
1001 Code* code = NULL; 1001 Code* code = NULL;
1002 if (IsConstructor()) accumulator->Add("new "); 1002 if (IsConstructor()) accumulator->Add("new ");
1003 accumulator->PrintFunction(function, receiver, &code); 1003 accumulator->PrintFunction(function, receiver, &code);
1004 1004
1005 Handle<SerializedScopeInfo> scope_info(SerializedScopeInfo::Empty()); 1005 // Get scope information for nicer output, if possible. If code is NULL, or
1006 // doesn't contain scope info, scope_info will return 0 for the number of
1007 // parameters, stack local variables, context local variables, stack slots,
1008 // or context slots.
1009 Handle<ScopeInfo> scope_info(ScopeInfo::Empty());
1006 1010
1007 if (function->IsJSFunction()) { 1011 if (function->IsJSFunction()) {
1008 Handle<SharedFunctionInfo> shared(JSFunction::cast(function)->shared()); 1012 Handle<SharedFunctionInfo> shared(JSFunction::cast(function)->shared());
1009 scope_info = Handle<SerializedScopeInfo>(shared->scope_info()); 1013 scope_info = Handle<ScopeInfo>(shared->scope_info());
1010 Object* script_obj = shared->script(); 1014 Object* script_obj = shared->script();
1011 if (script_obj->IsScript()) { 1015 if (script_obj->IsScript()) {
1012 Handle<Script> script(Script::cast(script_obj)); 1016 Handle<Script> script(Script::cast(script_obj));
1013 accumulator->Add(" ["); 1017 accumulator->Add(" [");
1014 accumulator->PrintName(script->name()); 1018 accumulator->PrintName(script->name());
1015 1019
1016 Address pc = this->pc(); 1020 Address pc = this->pc();
1017 if (code != NULL && code->kind() == Code::FUNCTION && 1021 if (code != NULL && code->kind() == Code::FUNCTION &&
1018 pc >= code->instruction_start() && pc < code->instruction_end()) { 1022 pc >= code->instruction_start() && pc < code->instruction_end()) {
1019 int source_pos = code->SourcePosition(pc); 1023 int source_pos = code->SourcePosition(pc);
1020 int line = GetScriptLineNumberSafe(script, source_pos) + 1; 1024 int line = GetScriptLineNumberSafe(script, source_pos) + 1;
1021 accumulator->Add(":%d", line); 1025 accumulator->Add(":%d", line);
1022 } else { 1026 } else {
1023 int function_start_pos = shared->start_position(); 1027 int function_start_pos = shared->start_position();
1024 int line = GetScriptLineNumberSafe(script, function_start_pos) + 1; 1028 int line = GetScriptLineNumberSafe(script, function_start_pos) + 1;
1025 accumulator->Add(":~%d", line); 1029 accumulator->Add(":~%d", line);
1026 } 1030 }
1027 1031
1028 accumulator->Add("] "); 1032 accumulator->Add("] ");
1029 } 1033 }
1030 } 1034 }
1031 1035
1032 accumulator->Add("(this=%o", receiver); 1036 accumulator->Add("(this=%o", receiver);
1033 1037
1034 // Get scope information for nicer output, if possible. If code is
1035 // NULL, or doesn't contain scope info, info will return 0 for the
1036 // number of parameters, stack slots, or context slots.
1037 ScopeInfo<PreallocatedStorage> info(*scope_info);
1038
1039 // Print the parameters. 1038 // Print the parameters.
1040 int parameters_count = ComputeParametersCount(); 1039 int parameters_count = ComputeParametersCount();
1041 for (int i = 0; i < parameters_count; i++) { 1040 for (int i = 0; i < parameters_count; i++) {
1042 accumulator->Add(","); 1041 accumulator->Add(",");
1043 // If we have a name for the parameter we print it. Nameless 1042 // If we have a name for the parameter we print it. Nameless
1044 // parameters are either because we have more actual parameters 1043 // parameters are either because we have more actual parameters
1045 // than formal parameters or because we have no scope information. 1044 // than formal parameters or because we have no scope information.
1046 if (i < info.number_of_parameters()) { 1045 if (i < scope_info->NumParameters()) {
Kevin Millikin (Chromium) 2011/11/03 09:18:38 OK, but "Num" grinds on me in identifier names, be
Steven 2011/11/03 10:32:34 Yeah we talked about this earlier. Also renamed th
1047 accumulator->PrintName(*info.parameter_name(i)); 1046 accumulator->PrintName(scope_info->ParameterName(i));
1048 accumulator->Add("="); 1047 accumulator->Add("=");
1049 } 1048 }
1050 accumulator->Add("%o", GetParameter(i)); 1049 accumulator->Add("%o", GetParameter(i));
1051 } 1050 }
1052 1051
1053 accumulator->Add(")"); 1052 accumulator->Add(")");
1054 if (mode == OVERVIEW) { 1053 if (mode == OVERVIEW) {
1055 accumulator->Add("\n"); 1054 accumulator->Add("\n");
1056 return; 1055 return;
1057 } 1056 }
1058 if (is_optimized()) { 1057 if (is_optimized()) {
1059 accumulator->Add(" {\n// optimized frame\n}\n"); 1058 accumulator->Add(" {\n// optimized frame\n}\n");
1060 return; 1059 return;
1061 } 1060 }
1062 accumulator->Add(" {\n"); 1061 accumulator->Add(" {\n");
1063 1062
1064 // Compute the number of locals and expression stack elements. 1063 // Compute the number of locals and expression stack elements.
1065 int stack_locals_count = info.number_of_stack_slots(); 1064 int stack_locals_count = scope_info->NumStackLocals();
1066 int heap_locals_count = info.number_of_context_slots(); 1065 int heap_locals_count = scope_info->NumContextLocals();
1067 int expressions_count = ComputeExpressionsCount(); 1066 int expressions_count = ComputeExpressionsCount();
1068 1067
1069 // Print stack-allocated local variables. 1068 // Print stack-allocated local variables.
1070 if (stack_locals_count > 0) { 1069 if (stack_locals_count > 0) {
1071 accumulator->Add(" // stack-allocated locals\n"); 1070 accumulator->Add(" // stack-allocated locals\n");
1072 } 1071 }
1073 for (int i = 0; i < stack_locals_count; i++) { 1072 for (int i = 0; i < stack_locals_count; i++) {
1074 accumulator->Add(" var "); 1073 accumulator->Add(" var ");
1075 accumulator->PrintName(*info.stack_slot_name(i)); 1074 accumulator->PrintName(scope_info->StackLocalName(i));
1076 accumulator->Add(" = "); 1075 accumulator->Add(" = ");
1077 if (i < expressions_count) { 1076 if (i < expressions_count) {
1078 accumulator->Add("%o", GetExpression(i)); 1077 accumulator->Add("%o", GetExpression(i));
1079 } else { 1078 } else {
1080 accumulator->Add("// no expression found - inconsistent frame?"); 1079 accumulator->Add("// no expression found - inconsistent frame?");
1081 } 1080 }
1082 accumulator->Add("\n"); 1081 accumulator->Add("\n");
1083 } 1082 }
1084 1083
1085 // Try to get hold of the context of this frame. 1084 // Try to get hold of the context of this frame.
1086 Context* context = NULL; 1085 Context* context = NULL;
1087 if (this->context() != NULL && this->context()->IsContext()) { 1086 if (this->context() != NULL && this->context()->IsContext()) {
1088 context = Context::cast(this->context()); 1087 context = Context::cast(this->context());
1089 } 1088 }
1090 1089
1091 // Print heap-allocated local variables. 1090 // Print heap-allocated local variables.
1092 if (heap_locals_count > Context::MIN_CONTEXT_SLOTS) { 1091 if (heap_locals_count > 0) {
1093 accumulator->Add(" // heap-allocated locals\n"); 1092 accumulator->Add(" // heap-allocated locals\n");
1094 } 1093 }
1095 for (int i = Context::MIN_CONTEXT_SLOTS; i < heap_locals_count; i++) { 1094 for (int i = 0; i < heap_locals_count; i++) {
1096 accumulator->Add(" var "); 1095 accumulator->Add(" var ");
1097 accumulator->PrintName(*info.context_slot_name(i)); 1096 accumulator->PrintName(scope_info->ContextLocalName(i));
1098 accumulator->Add(" = "); 1097 accumulator->Add(" = ");
1099 if (context != NULL) { 1098 if (context != NULL) {
1100 if (i < context->length()) { 1099 if (i < context->length()) {
1101 accumulator->Add("%o", context->get(i)); 1100 accumulator->Add("%o", context->get(Context::MIN_CONTEXT_SLOTS + i));
1102 } else { 1101 } else {
1103 accumulator->Add( 1102 accumulator->Add(
1104 "// warning: missing context slot - inconsistent frame?"); 1103 "// warning: missing context slot - inconsistent frame?");
1105 } 1104 }
1106 } else { 1105 } else {
1107 accumulator->Add("// warning: no context found - inconsistent frame?"); 1106 accumulator->Add("// warning: no context found - inconsistent frame?");
1108 } 1107 }
1109 accumulator->Add("\n"); 1108 accumulator->Add("\n");
1110 } 1109 }
1111 1110
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
1382 ZoneList<StackFrame*> list(10); 1381 ZoneList<StackFrame*> list(10);
1383 for (StackFrameIterator it; !it.done(); it.Advance()) { 1382 for (StackFrameIterator it; !it.done(); it.Advance()) {
1384 StackFrame* frame = AllocateFrameCopy(it.frame()); 1383 StackFrame* frame = AllocateFrameCopy(it.frame());
1385 list.Add(frame); 1384 list.Add(frame);
1386 } 1385 }
1387 return list.ToVector(); 1386 return list.ToVector();
1388 } 1387 }
1389 1388
1390 1389
1391 } } // namespace v8::internal 1390 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/factory.cc ('k') | src/full-codegen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698