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/frames.h" | 5 #include "src/frames.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <sstream> | 8 #include <sstream> |
9 | 9 |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
11 #include "src/deoptimizer.h" | 11 #include "src/deoptimizer.h" |
12 #include "src/frames-inl.h" | 12 #include "src/frames-inl.h" |
13 #include "src/full-codegen/full-codegen.h" | 13 #include "src/full-codegen/full-codegen.h" |
| 14 #include "src/ic/ic-stats.h" |
14 #include "src/register-configuration.h" | 15 #include "src/register-configuration.h" |
15 #include "src/safepoint-table.h" | 16 #include "src/safepoint-table.h" |
16 #include "src/string-stream.h" | 17 #include "src/string-stream.h" |
17 #include "src/vm-state-inl.h" | 18 #include "src/vm-state-inl.h" |
18 #include "src/wasm/wasm-module.h" | 19 #include "src/wasm/wasm-module.h" |
19 #include "src/wasm/wasm-objects.h" | 20 #include "src/wasm/wasm-objects.h" |
20 | 21 |
21 namespace v8 { | 22 namespace v8 { |
22 namespace internal { | 23 namespace internal { |
23 | 24 |
(...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1010 PrintF(file, " at %s:%d", c_script_name.get(), line); | 1011 PrintF(file, " at %s:%d", c_script_name.get(), line); |
1011 } else { | 1012 } else { |
1012 PrintF(file, " at <unknown>:%d", line); | 1013 PrintF(file, " at <unknown>:%d", line); |
1013 } | 1014 } |
1014 } else { | 1015 } else { |
1015 PrintF(file, " at <unknown>:<unknown>"); | 1016 PrintF(file, " at <unknown>:<unknown>"); |
1016 } | 1017 } |
1017 } | 1018 } |
1018 } | 1019 } |
1019 | 1020 |
1020 | |
1021 void JavaScriptFrame::PrintTop(Isolate* isolate, FILE* file, bool print_args, | 1021 void JavaScriptFrame::PrintTop(Isolate* isolate, FILE* file, bool print_args, |
1022 bool print_line_number) { | 1022 bool print_line_number) { |
1023 // constructor calls | 1023 // constructor calls |
1024 DisallowHeapAllocation no_allocation; | 1024 DisallowHeapAllocation no_allocation; |
1025 JavaScriptFrameIterator it(isolate); | 1025 JavaScriptFrameIterator it(isolate); |
1026 while (!it.done()) { | 1026 while (!it.done()) { |
1027 if (it.frame()->is_java_script()) { | 1027 if (it.frame()->is_java_script()) { |
1028 JavaScriptFrame* frame = it.frame(); | 1028 JavaScriptFrame* frame = it.frame(); |
1029 if (frame->IsConstructor()) PrintF(file, "new "); | 1029 if (frame->IsConstructor()) PrintF(file, "new "); |
1030 JSFunction* function = frame->function(); | 1030 JSFunction* function = frame->function(); |
(...skipping 19 matching lines...) Expand all Loading... |
1050 frame->GetParameter(i)->ShortPrint(file); | 1050 frame->GetParameter(i)->ShortPrint(file); |
1051 } | 1051 } |
1052 PrintF(file, ")"); | 1052 PrintF(file, ")"); |
1053 } | 1053 } |
1054 break; | 1054 break; |
1055 } | 1055 } |
1056 it.Advance(); | 1056 it.Advance(); |
1057 } | 1057 } |
1058 } | 1058 } |
1059 | 1059 |
| 1060 void JavaScriptFrame::CollectFunctionAndOffsetForICStats(JSFunction* function, |
| 1061 AbstractCode* code, |
| 1062 int code_offset) { |
| 1063 auto ic_stats = ICStats::instance(); |
| 1064 ICInfo& ic_info = ic_stats->Current(); |
| 1065 SharedFunctionInfo* shared = function->shared(); |
| 1066 |
| 1067 ic_info.function_name = ic_stats->GetOrCacheFunctionName(function); |
| 1068 ic_info.script_offset = code_offset; |
| 1069 |
| 1070 int source_pos = code->SourcePosition(code_offset); |
| 1071 Object* maybe_script = shared->script(); |
| 1072 if (maybe_script->IsScript()) { |
| 1073 Script* script = Script::cast(maybe_script); |
| 1074 ic_info.line_num = script->GetLineNumber(source_pos) + 1; |
| 1075 ic_info.script_name = ic_stats->GetOrCacheScriptName(script); |
| 1076 } |
| 1077 } |
| 1078 |
| 1079 void JavaScriptFrame::CollectTopFrameForICStats(Isolate* isolate) { |
| 1080 // constructor calls |
| 1081 DisallowHeapAllocation no_allocation; |
| 1082 JavaScriptFrameIterator it(isolate); |
| 1083 ICInfo& ic_info = ICStats::instance()->Current(); |
| 1084 while (!it.done()) { |
| 1085 if (it.frame()->is_java_script()) { |
| 1086 JavaScriptFrame* frame = it.frame(); |
| 1087 if (frame->IsConstructor()) ic_info.is_constructor = true; |
| 1088 JSFunction* function = frame->function(); |
| 1089 int code_offset = 0; |
| 1090 if (frame->is_interpreted()) { |
| 1091 InterpretedFrame* iframe = reinterpret_cast<InterpretedFrame*>(frame); |
| 1092 code_offset = iframe->GetBytecodeOffset(); |
| 1093 } else { |
| 1094 Code* code = frame->unchecked_code(); |
| 1095 code_offset = static_cast<int>(frame->pc() - code->instruction_start()); |
| 1096 } |
| 1097 CollectFunctionAndOffsetForICStats(function, function->abstract_code(), |
| 1098 code_offset); |
| 1099 return; |
| 1100 } |
| 1101 it.Advance(); |
| 1102 } |
| 1103 } |
| 1104 |
1060 Object* JavaScriptFrame::GetParameter(int index) const { | 1105 Object* JavaScriptFrame::GetParameter(int index) const { |
1061 return Memory::Object_at(GetParameterSlot(index)); | 1106 return Memory::Object_at(GetParameterSlot(index)); |
1062 } | 1107 } |
1063 | 1108 |
1064 int JavaScriptFrame::ComputeParametersCount() const { | 1109 int JavaScriptFrame::ComputeParametersCount() const { |
1065 return GetNumberOfIncomingArguments(); | 1110 return GetNumberOfIncomingArguments(); |
1066 } | 1111 } |
1067 | 1112 |
1068 namespace { | 1113 namespace { |
1069 | 1114 |
(...skipping 909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1979 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { | 2024 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { |
1980 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); | 2025 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); |
1981 list.Add(frame, zone); | 2026 list.Add(frame, zone); |
1982 } | 2027 } |
1983 return list.ToVector(); | 2028 return list.ToVector(); |
1984 } | 2029 } |
1985 | 2030 |
1986 | 2031 |
1987 } // namespace internal | 2032 } // namespace internal |
1988 } // namespace v8 | 2033 } // namespace v8 |
OLD | NEW |