5 #ifndef V8_SOURCE_POSITION_H_ 6 #define V8_SOURCE_POSITION_H_ 10 #include "src/flags.h" 11 #include "src/globals.h" 12 #include "src/handles.h" 13 #include "src/utils.h" 19 class OptimizedCompilationInfo;
21 class SharedFunctionInfo;
22 struct SourcePositionInfo;
33 explicit SourcePosition(
int script_offset,
int inlining_id = kNotInlined)
35 SetScriptOffset(script_offset);
36 SetInliningId(inlining_id);
40 bool IsKnown()
const {
41 return ScriptOffset() != kNoSourcePosition || InliningId() != kNotInlined;
43 bool isInlined()
const {
return InliningId() != kNotInlined; }
46 std::vector<SourcePositionInfo> InliningStack(
Handle<Code> code)
const;
47 std::vector<SourcePositionInfo> InliningStack(
50 void Print(std::ostream& out,
Code code)
const;
51 void PrintJson(std::ostream& out)
const;
53 int ScriptOffset()
const {
return ScriptOffsetField::decode(value_) - 1; }
54 int InliningId()
const {
return InliningIdField::decode(value_) - 1; }
56 void SetScriptOffset(
int script_offset) {
57 DCHECK(script_offset <= ScriptOffsetField::kMax - 2);
58 DCHECK_GE(script_offset, kNoSourcePosition);
59 value_ = ScriptOffsetField::update(value_, script_offset + 1);
61 void SetInliningId(
int inlining_id) {
62 DCHECK(inlining_id <= InliningIdField::kMax - 2);
63 DCHECK_GE(inlining_id, kNotInlined);
64 value_ = InliningIdField::update(value_, inlining_id + 1);
67 static const int kNotInlined = -1;
68 STATIC_ASSERT(kNoSourcePosition == -1);
74 position.value_ =
static_cast<uint64_t
>(raw);
90 return lhs.raw() == rhs.raw();
93 inline bool operator!=(
const SourcePosition& lhs,
const SourcePosition& rhs) {
102 int inlined_function_id;
114 std::ostream& operator<<(std::ostream& out,
const SourcePosition& pos);
117 std::ostream& operator<<(std::ostream& out,
118 const std::vector<SourcePositionInfo>& stack);
123 #endif // V8_SOURCE_POSITION_H_