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 788 matching lines...) Loading... |
799 IsConstructor()); | 799 IsConstructor()); |
800 functions->Add(summary); | 800 functions->Add(summary); |
801 } | 801 } |
802 | 802 |
803 | 803 |
804 void JavaScriptFrame::PrintTop(Isolate* isolate, | 804 void JavaScriptFrame::PrintTop(Isolate* isolate, |
805 FILE* file, | 805 FILE* file, |
806 bool print_args, | 806 bool print_args, |
807 bool print_line_number) { | 807 bool print_line_number) { |
808 // constructor calls | 808 // constructor calls |
809 HandleScope scope(isolate); | |
810 DisallowHeapAllocation no_allocation; | 809 DisallowHeapAllocation no_allocation; |
811 JavaScriptFrameIterator it(isolate); | 810 JavaScriptFrameIterator it(isolate); |
812 while (!it.done()) { | 811 while (!it.done()) { |
813 if (it.frame()->is_java_script()) { | 812 if (it.frame()->is_java_script()) { |
814 JavaScriptFrame* frame = it.frame(); | 813 JavaScriptFrame* frame = it.frame(); |
815 if (frame->IsConstructor()) PrintF(file, "new "); | 814 if (frame->IsConstructor()) PrintF(file, "new "); |
816 // function name | 815 // function name |
817 JSFunction* fun = frame->function(); | 816 JSFunction* fun = frame->function(); |
818 fun->PrintName(); | 817 fun->PrintName(); |
819 Code* js_code = frame->unchecked_code(); | 818 Code* js_code = frame->unchecked_code(); |
820 Address pc = frame->pc(); | 819 Address pc = frame->pc(); |
821 int code_offset = | 820 int code_offset = |
822 static_cast<int>(pc - js_code->instruction_start()); | 821 static_cast<int>(pc - js_code->instruction_start()); |
823 PrintF("+%d", code_offset); | 822 PrintF("+%d", code_offset); |
824 SharedFunctionInfo* shared = fun->shared(); | 823 SharedFunctionInfo* shared = fun->shared(); |
825 if (print_line_number) { | 824 if (print_line_number) { |
826 Code* code = Code::cast(isolate->FindCodeObject(pc)); | 825 Code* code = Code::cast(isolate->FindCodeObject(pc)); |
827 int source_pos = code->SourcePosition(pc); | 826 int source_pos = code->SourcePosition(pc); |
828 Object* maybe_script = shared->script(); | 827 Object* maybe_script = shared->script(); |
829 if (maybe_script->IsScript()) { | 828 if (maybe_script->IsScript()) { |
830 Handle<Script> script(Script::cast(maybe_script)); | 829 Script* script = Script::cast(maybe_script); |
831 int line = GetScriptLineNumberSafe(script, source_pos) + 1; | 830 int line = script->GetLineNumber(source_pos) + 1; |
832 Object* script_name_raw = script->name(); | 831 Object* script_name_raw = script->name(); |
833 if (script_name_raw->IsString()) { | 832 if (script_name_raw->IsString()) { |
834 String* script_name = String::cast(script->name()); | 833 String* script_name = String::cast(script->name()); |
835 SmartArrayPointer<char> c_script_name = | 834 SmartArrayPointer<char> c_script_name = |
836 script_name->ToCString(DISALLOW_NULLS, | 835 script_name->ToCString(DISALLOW_NULLS, |
837 ROBUST_STRING_TRAVERSAL); | 836 ROBUST_STRING_TRAVERSAL); |
838 PrintF(file, " at %s:%d", c_script_name.get(), line); | 837 PrintF(file, " at %s:%d", c_script_name.get(), line); |
839 } else { | 838 } else { |
840 PrintF(file, " at <unknown>:%d", line); | 839 PrintF(file, " at <unknown>:%d", line); |
841 } | 840 } |
(...skipping 322 matching lines...) Loading... |
1164 void StackFrame::PrintIndex(StringStream* accumulator, | 1163 void StackFrame::PrintIndex(StringStream* accumulator, |
1165 PrintMode mode, | 1164 PrintMode mode, |
1166 int index) { | 1165 int index) { |
1167 accumulator->Add((mode == OVERVIEW) ? "%5d: " : "[%d]: ", index); | 1166 accumulator->Add((mode == OVERVIEW) ? "%5d: " : "[%d]: ", index); |
1168 } | 1167 } |
1169 | 1168 |
1170 | 1169 |
1171 void JavaScriptFrame::Print(StringStream* accumulator, | 1170 void JavaScriptFrame::Print(StringStream* accumulator, |
1172 PrintMode mode, | 1171 PrintMode mode, |
1173 int index) const { | 1172 int index) const { |
1174 HandleScope scope(isolate()); | 1173 DisallowHeapAllocation no_gc; |
1175 Object* receiver = this->receiver(); | 1174 Object* receiver = this->receiver(); |
1176 JSFunction* function = this->function(); | 1175 JSFunction* function = this->function(); |
1177 | 1176 |
1178 accumulator->PrintSecurityTokenIfChanged(function); | 1177 accumulator->PrintSecurityTokenIfChanged(function); |
1179 PrintIndex(accumulator, mode, index); | 1178 PrintIndex(accumulator, mode, index); |
1180 Code* code = NULL; | 1179 Code* code = NULL; |
1181 if (IsConstructor()) accumulator->Add("new "); | 1180 if (IsConstructor()) accumulator->Add("new "); |
1182 accumulator->PrintFunction(function, receiver, &code); | 1181 accumulator->PrintFunction(function, receiver, &code); |
1183 | 1182 |
1184 // Get scope information for nicer output, if possible. If code is NULL, or | 1183 // Get scope information for nicer output, if possible. If code is NULL, or |
1185 // doesn't contain scope info, scope_info will return 0 for the number of | 1184 // doesn't contain scope info, scope_info will return 0 for the number of |
1186 // parameters, stack local variables, context local variables, stack slots, | 1185 // parameters, stack local variables, context local variables, stack slots, |
1187 // or context slots. | 1186 // or context slots. |
1188 Handle<ScopeInfo> scope_info(ScopeInfo::Empty(isolate())); | 1187 SharedFunctionInfo* shared = function->shared(); |
1189 | 1188 ScopeInfo* scope_info = shared->scope_info(); |
1190 Handle<SharedFunctionInfo> shared(function->shared()); | |
1191 scope_info = Handle<ScopeInfo>(shared->scope_info()); | |
1192 Object* script_obj = shared->script(); | 1189 Object* script_obj = shared->script(); |
1193 if (script_obj->IsScript()) { | 1190 if (script_obj->IsScript()) { |
1194 Handle<Script> script(Script::cast(script_obj)); | 1191 Script* script = Script::cast(script_obj); |
1195 accumulator->Add(" ["); | 1192 accumulator->Add(" ["); |
1196 accumulator->PrintName(script->name()); | 1193 accumulator->PrintName(script->name()); |
1197 | 1194 |
1198 Address pc = this->pc(); | 1195 Address pc = this->pc(); |
1199 if (code != NULL && code->kind() == Code::FUNCTION && | 1196 if (code != NULL && code->kind() == Code::FUNCTION && |
1200 pc >= code->instruction_start() && pc < code->instruction_end()) { | 1197 pc >= code->instruction_start() && pc < code->instruction_end()) { |
1201 int source_pos = code->SourcePosition(pc); | 1198 int source_pos = code->SourcePosition(pc); |
1202 int line = GetScriptLineNumberSafe(script, source_pos) + 1; | 1199 int line = script->GetLineNumber(source_pos) + 1; |
1203 accumulator->Add(":%d", line); | 1200 accumulator->Add(":%d", line); |
1204 } else { | 1201 } else { |
1205 int function_start_pos = shared->start_position(); | 1202 int function_start_pos = shared->start_position(); |
1206 int line = GetScriptLineNumberSafe(script, function_start_pos) + 1; | 1203 int line = script->GetLineNumber(function_start_pos) + 1; |
1207 accumulator->Add(":~%d", line); | 1204 accumulator->Add(":~%d", line); |
1208 } | 1205 } |
1209 | 1206 |
1210 accumulator->Add("] "); | 1207 accumulator->Add("] "); |
1211 } | 1208 } |
1212 | 1209 |
1213 accumulator->Add("(this=%o", receiver); | 1210 accumulator->Add("(this=%o", receiver); |
1214 | 1211 |
1215 // Print the parameters. | 1212 // Print the parameters. |
1216 int parameters_count = ComputeParametersCount(); | 1213 int parameters_count = ComputeParametersCount(); |
(...skipping 427 matching lines...) Loading... |
1644 ZoneList<StackFrame*> list(10, zone); | 1641 ZoneList<StackFrame*> list(10, zone); |
1645 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { | 1642 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { |
1646 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); | 1643 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); |
1647 list.Add(frame, zone); | 1644 list.Add(frame, zone); |
1648 } | 1645 } |
1649 return list.ToVector(); | 1646 return list.ToVector(); |
1650 } | 1647 } |
1651 | 1648 |
1652 | 1649 |
1653 } } // namespace v8::internal | 1650 } } // namespace v8::internal |
OLD | NEW |