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

Side by Side Diff: src/source-position.h

Issue 2559743002: Merged: [cpu-profiler] use new source position information for deoptimization in cpu profiler (Closed)
Patch Set: addressed comment 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
« no previous file with comments | « src/profiler/profiler-listener.cc ('k') | src/source-position.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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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 #ifndef V8_SOURCE_POSITION_H_ 5 #ifndef V8_SOURCE_POSITION_H_
6 #define V8_SOURCE_POSITION_H_ 6 #define V8_SOURCE_POSITION_H_
7 7
8 #include <ostream> 8 #include <ostream>
9 9
10 #include "src/flags.h" 10 #include "src/flags.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 DCHECK(inlining_id <= InliningIdField::kMax - 2); 60 DCHECK(inlining_id <= InliningIdField::kMax - 2);
61 DCHECK(inlining_id >= kNotInlined); 61 DCHECK(inlining_id >= kNotInlined);
62 value_ = InliningIdField::update(value_, inlining_id + 1); 62 value_ = InliningIdField::update(value_, inlining_id + 1);
63 } 63 }
64 64
65 static const int kNotInlined = -1; 65 static const int kNotInlined = -1;
66 STATIC_ASSERT(kNoSourcePosition == -1); 66 STATIC_ASSERT(kNoSourcePosition == -1);
67 67
68 int64_t raw() const { return static_cast<int64_t>(value_); } 68 int64_t raw() const { return static_cast<int64_t>(value_); }
69 static SourcePosition FromRaw(int64_t raw) { 69 static SourcePosition FromRaw(int64_t raw) {
70 SourcePosition position; 70 SourcePosition position = Unknown();
71 DCHECK_GE(raw, 0); 71 DCHECK_GE(raw, 0);
72 position.value_ = static_cast<uint64_t>(raw); 72 position.value_ = static_cast<uint64_t>(raw);
73 return position; 73 return position;
74 } 74 }
75 75
76 private: 76 private:
77 // SourcePosition is used in a union in CodeEventsContainer, which requires a
78 // trivial constructor.
79 SourcePosition() = default;
80
81 void Print(std::ostream& out, SharedFunctionInfo* function) const; 77 void Print(std::ostream& out, SharedFunctionInfo* function) const;
82 SourcePositionInfo Info(Handle<SharedFunctionInfo> script) const; 78 SourcePositionInfo Info(Handle<SharedFunctionInfo> script) const;
83 79
84 // InliningId is in the high bits for better compression in 80 // InliningId is in the high bits for better compression in
85 // SourcePositionTable. 81 // SourcePositionTable.
86 typedef BitField64<int, 0, 31> ScriptOffsetField; 82 typedef BitField64<int, 0, 31> ScriptOffsetField;
87 typedef BitField64<int, 31, 16> InliningIdField; 83 typedef BitField64<int, 31, 16> InliningIdField;
88 // Leaving the highest bit untouched to allow for signed conversion. 84 // Leaving the highest bit untouched to allow for signed conversion.
89 uint64_t value_; 85 uint64_t value_;
90 }; 86 };
91 87
92 inline bool operator==(const SourcePosition& lhs, const SourcePosition& rhs) { 88 inline bool operator==(const SourcePosition& lhs, const SourcePosition& rhs) {
93 return lhs.raw() == rhs.raw(); 89 return lhs.raw() == rhs.raw();
94 } 90 }
95 91
96 inline bool operator!=(const SourcePosition& lhs, const SourcePosition& rhs) { 92 inline bool operator!=(const SourcePosition& lhs, const SourcePosition& rhs) {
97 return !(lhs == rhs); 93 return !(lhs == rhs);
98 } 94 }
99 95
100 struct InliningPosition { 96 struct InliningPosition {
101 // position of the inlined call 97 // position of the inlined call
102 SourcePosition position = SourcePosition::Unknown(); 98 SourcePosition position = SourcePosition::Unknown();
103 99
104 // references position in DeoptimizationInputData::literals() 100 // references position in DeoptimizationInputData::literals()
105 int inlined_function_id; 101 int inlined_function_id;
106 }; 102 };
107 103
108 struct SourcePositionInfo { 104 struct SourcePositionInfo {
109 explicit SourcePositionInfo(SourcePosition pos) : position(pos) {} 105 explicit SourcePositionInfo(SourcePosition pos, Handle<SharedFunctionInfo> f)
106 : position(pos), function(f) {}
110 107
111 SourcePosition position; 108 SourcePosition position;
112 MaybeHandle<SharedFunctionInfo> function; 109 Handle<SharedFunctionInfo> function;
113 int line = -1; 110 int line = -1;
114 int column = -1; 111 int column = -1;
115 }; 112 };
116 113
117 std::ostream& operator<<(std::ostream& out, const SourcePosition& pos); 114 std::ostream& operator<<(std::ostream& out, const SourcePosition& pos);
118 115
119 std::ostream& operator<<(std::ostream& out, const SourcePositionInfo& pos); 116 std::ostream& operator<<(std::ostream& out, const SourcePositionInfo& pos);
120 std::ostream& operator<<(std::ostream& out, 117 std::ostream& operator<<(std::ostream& out,
121 const std::vector<SourcePositionInfo>& stack); 118 const std::vector<SourcePositionInfo>& stack);
122 119
123 } // namespace internal 120 } // namespace internal
124 } // namespace v8 121 } // namespace v8
125 122
126 #endif // V8_SOURCE_POSITION_H_ 123 #endif // V8_SOURCE_POSITION_H_
OLDNEW
« no previous file with comments | « src/profiler/profiler-listener.cc ('k') | src/source-position.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698