| OLD | NEW |
| 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/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/ast.h" | 7 #include "src/ast.h" |
| 8 #include "src/deoptimizer.h" | 8 #include "src/deoptimizer.h" |
| 9 #include "src/frames-inl.h" | 9 #include "src/frames-inl.h" |
| 10 #include "src/full-codegen.h" | 10 #include "src/full-codegen.h" |
| (...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 int offset = static_cast<int>(pc() - code_pointer->address()); | 770 int offset = static_cast<int>(pc() - code_pointer->address()); |
| 771 FrameSummary summary(receiver(), | 771 FrameSummary summary(receiver(), |
| 772 function(), | 772 function(), |
| 773 code_pointer, | 773 code_pointer, |
| 774 offset, | 774 offset, |
| 775 IsConstructor()); | 775 IsConstructor()); |
| 776 functions->Add(summary); | 776 functions->Add(summary); |
| 777 } | 777 } |
| 778 | 778 |
| 779 | 779 |
| 780 void JavaScriptFrame::PrintTop(Isolate* isolate, | 780 void JavaScriptFrame::PrintFunctionAndOffset(JSFunction* function, Code* code, |
| 781 FILE* file, | 781 Address pc, FILE* file, |
| 782 bool print_args, | 782 bool print_line_number) { |
| 783 PrintF(file, "%s", function->IsOptimized() ? "*" : "~"); |
| 784 function->PrintName(file); |
| 785 int code_offset = static_cast<int>(pc - code->instruction_start()); |
| 786 PrintF(file, "+%d", code_offset); |
| 787 if (print_line_number) { |
| 788 SharedFunctionInfo* shared = function->shared(); |
| 789 int source_pos = code->SourcePosition(pc); |
| 790 Object* maybe_script = shared->script(); |
| 791 if (maybe_script->IsScript()) { |
| 792 Script* script = Script::cast(maybe_script); |
| 793 int line = script->GetLineNumber(source_pos) + 1; |
| 794 Object* script_name_raw = script->name(); |
| 795 if (script_name_raw->IsString()) { |
| 796 String* script_name = String::cast(script->name()); |
| 797 SmartArrayPointer<char> c_script_name = |
| 798 script_name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
| 799 PrintF(file, " at %s:%d", c_script_name.get(), line); |
| 800 } else { |
| 801 PrintF(file, " at <unknown>:%d", line); |
| 802 } |
| 803 } else { |
| 804 PrintF(file, " at <unknown>:<unknown>"); |
| 805 } |
| 806 } |
| 807 } |
| 808 |
| 809 |
| 810 void JavaScriptFrame::PrintTop(Isolate* isolate, FILE* file, bool print_args, |
| 783 bool print_line_number) { | 811 bool print_line_number) { |
| 784 // constructor calls | 812 // constructor calls |
| 785 DisallowHeapAllocation no_allocation; | 813 DisallowHeapAllocation no_allocation; |
| 786 JavaScriptFrameIterator it(isolate); | 814 JavaScriptFrameIterator it(isolate); |
| 787 while (!it.done()) { | 815 while (!it.done()) { |
| 788 if (it.frame()->is_java_script()) { | 816 if (it.frame()->is_java_script()) { |
| 789 JavaScriptFrame* frame = it.frame(); | 817 JavaScriptFrame* frame = it.frame(); |
| 790 if (frame->IsConstructor()) PrintF(file, "new "); | 818 if (frame->IsConstructor()) PrintF(file, "new "); |
| 791 // function name | 819 PrintFunctionAndOffset(frame->function(), frame->unchecked_code(), |
| 792 JSFunction* fun = frame->function(); | 820 frame->pc(), file, print_line_number); |
| 793 fun->PrintName(); | |
| 794 Code* js_code = frame->unchecked_code(); | |
| 795 Address pc = frame->pc(); | |
| 796 int code_offset = | |
| 797 static_cast<int>(pc - js_code->instruction_start()); | |
| 798 PrintF("+%d", code_offset); | |
| 799 SharedFunctionInfo* shared = fun->shared(); | |
| 800 if (print_line_number) { | |
| 801 Code* code = Code::cast(isolate->FindCodeObject(pc)); | |
| 802 int source_pos = code->SourcePosition(pc); | |
| 803 Object* maybe_script = shared->script(); | |
| 804 if (maybe_script->IsScript()) { | |
| 805 Script* script = Script::cast(maybe_script); | |
| 806 int line = script->GetLineNumber(source_pos) + 1; | |
| 807 Object* script_name_raw = script->name(); | |
| 808 if (script_name_raw->IsString()) { | |
| 809 String* script_name = String::cast(script->name()); | |
| 810 SmartArrayPointer<char> c_script_name = | |
| 811 script_name->ToCString(DISALLOW_NULLS, | |
| 812 ROBUST_STRING_TRAVERSAL); | |
| 813 PrintF(file, " at %s:%d", c_script_name.get(), line); | |
| 814 } else { | |
| 815 PrintF(file, " at <unknown>:%d", line); | |
| 816 } | |
| 817 } else { | |
| 818 PrintF(file, " at <unknown>:<unknown>"); | |
| 819 } | |
| 820 } | |
| 821 | |
| 822 if (print_args) { | 821 if (print_args) { |
| 823 // function arguments | 822 // function arguments |
| 824 // (we are intentionally only printing the actually | 823 // (we are intentionally only printing the actually |
| 825 // supplied parameters, not all parameters required) | 824 // supplied parameters, not all parameters required) |
| 826 PrintF(file, "(this="); | 825 PrintF(file, "(this="); |
| 827 frame->receiver()->ShortPrint(file); | 826 frame->receiver()->ShortPrint(file); |
| 828 const int length = frame->ComputeParametersCount(); | 827 const int length = frame->ComputeParametersCount(); |
| 829 for (int i = 0; i < length; i++) { | 828 for (int i = 0; i < length; i++) { |
| 830 PrintF(file, ", "); | 829 PrintF(file, ", "); |
| 831 frame->GetParameter(i)->ShortPrint(file); | 830 frame->GetParameter(i)->ShortPrint(file); |
| (...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1620 ZoneList<StackFrame*> list(10, zone); | 1619 ZoneList<StackFrame*> list(10, zone); |
| 1621 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { | 1620 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { |
| 1622 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); | 1621 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); |
| 1623 list.Add(frame, zone); | 1622 list.Add(frame, zone); |
| 1624 } | 1623 } |
| 1625 return list.ToVector(); | 1624 return list.ToVector(); |
| 1626 } | 1625 } |
| 1627 | 1626 |
| 1628 | 1627 |
| 1629 } } // namespace v8::internal | 1628 } } // namespace v8::internal |
| OLD | NEW |