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 #ifndef V8_COMPILER_H_ | 5 #ifndef V8_COMPILER_H_ |
6 #define V8_COMPILER_H_ | 6 #define V8_COMPILER_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/ast.h" | 9 #include "src/ast.h" |
10 #include "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 // which hydrogen values originated. | 34 // which hydrogen values originated. |
35 // When FLAG_track_hydrogen_positions is set this object encodes the | 35 // When FLAG_track_hydrogen_positions is set this object encodes the |
36 // identifier of the inlining and absolute offset from the start of the | 36 // identifier of the inlining and absolute offset from the start of the |
37 // inlined function. | 37 // inlined function. |
38 // When the flag is not set we simply track absolute offset from the | 38 // When the flag is not set we simply track absolute offset from the |
39 // script start. | 39 // script start. |
40 class SourcePosition { | 40 class SourcePosition { |
41 public: | 41 public: |
42 SourcePosition(const SourcePosition& other) : value_(other.value_) {} | 42 SourcePosition(const SourcePosition& other) : value_(other.value_) {} |
43 | 43 |
44 static SourcePosition Unknown() { | 44 static SourcePosition Unknown() { return SourcePosition(kNoPosition); } |
45 return SourcePosition(RelocInfo::kNoPosition); | |
46 } | |
47 | 45 |
48 bool IsUnknown() const { return value_ == RelocInfo::kNoPosition; } | 46 bool IsUnknown() const { return value_ == kNoPosition; } |
49 | 47 |
50 int position() const { return PositionField::decode(value_); } | 48 uint32_t position() const { return PositionField::decode(value_); } |
51 void set_position(int position) { | 49 void set_position(uint32_t position) { |
52 if (FLAG_hydrogen_track_positions) { | 50 if (FLAG_hydrogen_track_positions) { |
53 value_ = static_cast<int>(PositionField::update(value_, position)); | 51 value_ = static_cast<uint32_t>(PositionField::update(value_, position)); |
54 } else { | 52 } else { |
55 value_ = position; | 53 value_ = position; |
56 } | 54 } |
57 } | 55 } |
58 | 56 |
59 int inlining_id() const { return InliningIdField::decode(value_); } | 57 uint32_t inlining_id() const { return InliningIdField::decode(value_); } |
60 void set_inlining_id(int inlining_id) { | 58 void set_inlining_id(uint32_t inlining_id) { |
61 if (FLAG_hydrogen_track_positions) { | 59 if (FLAG_hydrogen_track_positions) { |
62 value_ = static_cast<int>(InliningIdField::update(value_, inlining_id)); | 60 value_ = |
| 61 static_cast<uint32_t>(InliningIdField::update(value_, inlining_id)); |
63 } | 62 } |
64 } | 63 } |
65 | 64 |
66 int raw() const { return value_; } | 65 uint32_t raw() const { return value_; } |
67 | 66 |
68 private: | 67 private: |
69 typedef BitField<int, 0, 9> InliningIdField; | 68 static const uint32_t kNoPosition = |
| 69 static_cast<uint32_t>(RelocInfo::kNoPosition); |
| 70 typedef BitField<uint32_t, 0, 9> InliningIdField; |
70 | 71 |
71 // Offset from the start of the inlined function. | 72 // Offset from the start of the inlined function. |
72 typedef BitField<int, 9, 23> PositionField; | 73 typedef BitField<uint32_t, 9, 23> PositionField; |
73 | 74 |
74 explicit SourcePosition(int value) : value_(value) {} | 75 explicit SourcePosition(uint32_t value) : value_(value) {} |
75 | 76 |
76 friend class HPositionInfo; | 77 friend class HPositionInfo; |
77 friend class LCodeGenBase; | 78 friend class LCodeGenBase; |
78 | 79 |
79 // If FLAG_hydrogen_track_positions is set contains bitfields InliningIdField | 80 // If FLAG_hydrogen_track_positions is set contains bitfields InliningIdField |
80 // and PositionField. | 81 // and PositionField. |
81 // Otherwise contains absolute offset from the script start. | 82 // Otherwise contains absolute offset from the script start. |
82 int value_; | 83 uint32_t value_; |
83 }; | 84 }; |
84 | 85 |
85 | 86 |
86 std::ostream& operator<<(std::ostream& os, const SourcePosition& p); | 87 std::ostream& operator<<(std::ostream& os, const SourcePosition& p); |
87 | 88 |
88 | 89 |
89 class InlinedFunctionInfo { | 90 class InlinedFunctionInfo { |
90 public: | 91 public: |
91 explicit InlinedFunctionInfo(Handle<SharedFunctionInfo> shared) | 92 explicit InlinedFunctionInfo(Handle<SharedFunctionInfo> shared) |
92 : shared_(shared), start_position_(shared->start_position()) {} | 93 : shared_(shared), start_position_(shared->start_position()) {} |
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 Zone zone_; | 858 Zone zone_; |
858 size_t info_zone_start_allocation_size_; | 859 size_t info_zone_start_allocation_size_; |
859 base::ElapsedTimer timer_; | 860 base::ElapsedTimer timer_; |
860 | 861 |
861 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); | 862 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); |
862 }; | 863 }; |
863 | 864 |
864 } } // namespace v8::internal | 865 } } // namespace v8::internal |
865 | 866 |
866 #endif // V8_COMPILER_H_ | 867 #endif // V8_COMPILER_H_ |
OLD | NEW |