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

Side by Side Diff: src/frames.cc

Issue 2503183002: [Tracing] Implement IC statistics in tracing. (Closed)
Patch Set: add cache for function name Created 4 years 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
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 <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
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
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.offset = code_offset;
1069
1070 int source_pos = code->SourcePosition(code_offset);
1071 Object* maybe_script = shared->script();
1072 if (maybe_script->IsScript()) {
1073 ic_info.line_num =
1074 Script::cast(maybe_script)->GetLineNumber(source_pos) + 1;
1075 ic_info.script_name =
1076 ic_stats->GetOrCacheScriptName(maybe_script);
1077 }
1078 }
1079
1080 void JavaScriptFrame::CollectTopFrameForICStats(Isolate* isolate) {
1081 // constructor calls
1082 DisallowHeapAllocation no_allocation;
1083 JavaScriptFrameIterator it(isolate);
1084 ICInfo& ic_info = ICStats::instance()->Current();
1085 while (!it.done()) {
1086 if (it.frame()->is_java_script()) {
1087 JavaScriptFrame* frame = it.frame();
1088 if (frame->IsConstructor()) ic_info.constructor = 1;
1089 JSFunction* function = frame->function();
1090 int code_offset = 0;
1091 if (frame->is_interpreted()) {
1092 InterpretedFrame* iframe = reinterpret_cast<InterpretedFrame*>(frame);
1093 code_offset = iframe->GetBytecodeOffset();
1094 } else {
1095 Code* code = frame->unchecked_code();
1096 code_offset = static_cast<int>(frame->pc() - code->instruction_start());
1097 }
1098 CollectFunctionAndOffsetForICStats(function, function->abstract_code(),
1099 code_offset);
1100 return;
1101 }
1102 it.Advance();
1103 }
1104 }
1105
1060 Object* JavaScriptFrame::GetParameter(int index) const { 1106 Object* JavaScriptFrame::GetParameter(int index) const {
1061 return Memory::Object_at(GetParameterSlot(index)); 1107 return Memory::Object_at(GetParameterSlot(index));
1062 } 1108 }
1063 1109
1064 int JavaScriptFrame::ComputeParametersCount() const { 1110 int JavaScriptFrame::ComputeParametersCount() const {
1065 return GetNumberOfIncomingArguments(); 1111 return GetNumberOfIncomingArguments();
1066 } 1112 }
1067 1113
1068 namespace { 1114 namespace {
1069 1115
(...skipping 909 matching lines...) Expand 10 before | Expand all | Expand 10 after
1979 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { 2025 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) {
1980 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); 2026 StackFrame* frame = AllocateFrameCopy(it.frame(), zone);
1981 list.Add(frame, zone); 2027 list.Add(frame, zone);
1982 } 2028 }
1983 return list.ToVector(); 2029 return list.ToVector();
1984 } 2030 }
1985 2031
1986 2032
1987 } // namespace internal 2033 } // namespace internal
1988 } // namespace v8 2034 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698