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

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

Issue 2568303008: [source-positions] make the SourcePositionInfo constructor actually compute position info (Closed)
Patch Set: 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 | « no previous file | 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 25 matching lines...) Expand all
36 SetScriptOffset(script_offset); 36 SetScriptOffset(script_offset);
37 SetInliningId(inlining_id); 37 SetInliningId(inlining_id);
38 } 38 }
39 39
40 static SourcePosition Unknown() { return SourcePosition(kNoSourcePosition); } 40 static SourcePosition Unknown() { return SourcePosition(kNoSourcePosition); }
41 bool IsKnown() const { 41 bool IsKnown() const {
42 return ScriptOffset() != kNoSourcePosition || InliningId() != kNotInlined; 42 return ScriptOffset() != kNoSourcePosition || InliningId() != kNotInlined;
43 } 43 }
44 bool isInlined() const { return InliningId() != kNotInlined; } 44 bool isInlined() const { return InliningId() != kNotInlined; }
45 45
46 // Assumes that the code object is optimized
46 std::vector<SourcePositionInfo> InliningStack(Handle<Code> code) const; 47 std::vector<SourcePositionInfo> InliningStack(Handle<Code> code) const;
47 std::vector<SourcePositionInfo> InliningStack(CompilationInfo* code) const; 48 std::vector<SourcePositionInfo> InliningStack(CompilationInfo* cinfo) const;
48 49
49 void Print(std::ostream& out, Code* function) const; 50 void Print(std::ostream& out, Code* code) const;
50 51
51 int ScriptOffset() const { return ScriptOffsetField::decode(value_) - 1; } 52 int ScriptOffset() const { return ScriptOffsetField::decode(value_) - 1; }
52 int InliningId() const { return InliningIdField::decode(value_) - 1; } 53 int InliningId() const { return InliningIdField::decode(value_) - 1; }
53 54
54 void SetScriptOffset(int script_offset) { 55 void SetScriptOffset(int script_offset) {
55 DCHECK(script_offset <= ScriptOffsetField::kMax - 2); 56 DCHECK(script_offset <= ScriptOffsetField::kMax - 2);
56 DCHECK(script_offset >= kNoSourcePosition); 57 DCHECK(script_offset >= kNoSourcePosition);
57 value_ = ScriptOffsetField::update(value_, script_offset + 1); 58 value_ = ScriptOffsetField::update(value_, script_offset + 1);
58 } 59 }
59 void SetInliningId(int inlining_id) { 60 void SetInliningId(int inlining_id) {
60 DCHECK(inlining_id <= InliningIdField::kMax - 2); 61 DCHECK(inlining_id <= InliningIdField::kMax - 2);
61 DCHECK(inlining_id >= kNotInlined); 62 DCHECK(inlining_id >= kNotInlined);
62 value_ = InliningIdField::update(value_, inlining_id + 1); 63 value_ = InliningIdField::update(value_, inlining_id + 1);
63 } 64 }
64 65
65 static const int kNotInlined = -1; 66 static const int kNotInlined = -1;
66 STATIC_ASSERT(kNoSourcePosition == -1); 67 STATIC_ASSERT(kNoSourcePosition == -1);
67 68
68 int64_t raw() const { return static_cast<int64_t>(value_); } 69 int64_t raw() const { return static_cast<int64_t>(value_); }
69 static SourcePosition FromRaw(int64_t raw) { 70 static SourcePosition FromRaw(int64_t raw) {
70 SourcePosition position = Unknown(); 71 SourcePosition position = Unknown();
71 DCHECK_GE(raw, 0); 72 DCHECK_GE(raw, 0);
72 position.value_ = static_cast<uint64_t>(raw); 73 position.value_ = static_cast<uint64_t>(raw);
73 return position; 74 return position;
74 } 75 }
75 76
76 private: 77 private:
77 void Print(std::ostream& out, SharedFunctionInfo* function) const; 78 void Print(std::ostream& out, SharedFunctionInfo* function) const;
78 SourcePositionInfo Info(Handle<SharedFunctionInfo> script) const;
79 79
80 // InliningId is in the high bits for better compression in 80 // InliningId is in the high bits for better compression in
81 // SourcePositionTable. 81 // SourcePositionTable.
82 typedef BitField64<int, 0, 31> ScriptOffsetField; 82 typedef BitField64<int, 0, 31> ScriptOffsetField;
83 typedef BitField64<int, 31, 16> InliningIdField; 83 typedef BitField64<int, 31, 16> InliningIdField;
84 // Leaving the highest bit untouched to allow for signed conversion. 84 // Leaving the highest bit untouched to allow for signed conversion.
85 uint64_t value_; 85 uint64_t value_;
86 }; 86 };
87 87
88 inline bool operator==(const SourcePosition& lhs, const SourcePosition& rhs) { 88 inline bool operator==(const SourcePosition& lhs, const SourcePosition& rhs) {
89 return lhs.raw() == rhs.raw(); 89 return lhs.raw() == rhs.raw();
90 } 90 }
91 91
92 inline bool operator!=(const SourcePosition& lhs, const SourcePosition& rhs) { 92 inline bool operator!=(const SourcePosition& lhs, const SourcePosition& rhs) {
93 return !(lhs == rhs); 93 return !(lhs == rhs);
94 } 94 }
95 95
96 struct InliningPosition { 96 struct InliningPosition {
97 // position of the inlined call 97 // position of the inlined call
98 SourcePosition position = SourcePosition::Unknown(); 98 SourcePosition position = SourcePosition::Unknown();
99 99
100 // references position in DeoptimizationInputData::literals() 100 // references position in DeoptimizationInputData::literals()
101 int inlined_function_id; 101 int inlined_function_id;
102 }; 102 };
103 103
104 struct SourcePositionInfo { 104 struct SourcePositionInfo {
105 explicit SourcePositionInfo(SourcePosition pos, Handle<SharedFunctionInfo> f) 105 SourcePositionInfo(SourcePosition pos, Handle<SharedFunctionInfo> f);
106 : position(pos), function(f) {}
107 106
108 SourcePosition position; 107 SourcePosition position;
109 Handle<SharedFunctionInfo> function; 108 Handle<SharedFunctionInfo> function;
110 int line = -1; 109 int line = -1;
111 int column = -1; 110 int column = -1;
112 }; 111 };
113 112
114 std::ostream& operator<<(std::ostream& out, const SourcePosition& pos); 113 std::ostream& operator<<(std::ostream& out, const SourcePosition& pos);
115 114
116 std::ostream& operator<<(std::ostream& out, const SourcePositionInfo& pos); 115 std::ostream& operator<<(std::ostream& out, const SourcePositionInfo& pos);
117 std::ostream& operator<<(std::ostream& out, 116 std::ostream& operator<<(std::ostream& out,
118 const std::vector<SourcePositionInfo>& stack); 117 const std::vector<SourcePositionInfo>& stack);
119 118
120 } // namespace internal 119 } // namespace internal
121 } // namespace v8 120 } // namespace v8
122 121
123 #endif // V8_SOURCE_POSITION_H_ 122 #endif // V8_SOURCE_POSITION_H_
OLDNEW
« no previous file with comments | « no previous file | src/source-position.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698