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/ast.h" | 9 #include "src/ast/ast.h" |
10 #include "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
11 #include "src/compilation-dependencies.h" | 11 #include "src/compilation-dependencies.h" |
12 #include "src/signature.h" | 12 #include "src/signature.h" |
| 13 #include "src/source-position.h" |
13 #include "src/zone.h" | 14 #include "src/zone.h" |
14 | 15 |
15 namespace v8 { | 16 namespace v8 { |
16 namespace internal { | 17 namespace internal { |
17 | 18 |
18 class AstValueFactory; | 19 // Forward declarations. |
19 class HydrogenCodeStub; | |
20 class JavaScriptFrame; | 20 class JavaScriptFrame; |
21 class ParseInfo; | 21 class ParseInfo; |
22 class ScriptData; | 22 class ScriptData; |
23 | 23 |
24 | 24 |
25 // This class encapsulates encoding and decoding of sources positions from | |
26 // which hydrogen values originated. | |
27 // When FLAG_track_hydrogen_positions is set this object encodes the | |
28 // identifier of the inlining and absolute offset from the start of the | |
29 // inlined function. | |
30 // When the flag is not set we simply track absolute offset from the | |
31 // script start. | |
32 class SourcePosition { | |
33 public: | |
34 static SourcePosition Unknown() { | |
35 return SourcePosition::FromRaw(kNoPosition); | |
36 } | |
37 | |
38 bool IsUnknown() const { return value_ == kNoPosition; } | |
39 | |
40 uint32_t position() const { return PositionField::decode(value_); } | |
41 void set_position(uint32_t position) { | |
42 if (FLAG_hydrogen_track_positions) { | |
43 value_ = static_cast<uint32_t>(PositionField::update(value_, position)); | |
44 } else { | |
45 value_ = position; | |
46 } | |
47 } | |
48 | |
49 uint32_t inlining_id() const { return InliningIdField::decode(value_); } | |
50 void set_inlining_id(uint32_t inlining_id) { | |
51 if (FLAG_hydrogen_track_positions) { | |
52 value_ = | |
53 static_cast<uint32_t>(InliningIdField::update(value_, inlining_id)); | |
54 } | |
55 } | |
56 | |
57 uint32_t raw() const { return value_; } | |
58 | |
59 private: | |
60 static const uint32_t kNoPosition = | |
61 static_cast<uint32_t>(RelocInfo::kNoPosition); | |
62 typedef BitField<uint32_t, 0, 9> InliningIdField; | |
63 | |
64 // Offset from the start of the inlined function. | |
65 typedef BitField<uint32_t, 9, 23> PositionField; | |
66 | |
67 friend class HPositionInfo; | |
68 friend class Deoptimizer; | |
69 | |
70 static SourcePosition FromRaw(uint32_t raw_position) { | |
71 SourcePosition position; | |
72 position.value_ = raw_position; | |
73 return position; | |
74 } | |
75 | |
76 // If FLAG_hydrogen_track_positions is set contains bitfields InliningIdField | |
77 // and PositionField. | |
78 // Otherwise contains absolute offset from the script start. | |
79 uint32_t value_; | |
80 }; | |
81 | |
82 | |
83 std::ostream& operator<<(std::ostream& os, const SourcePosition& p); | |
84 | |
85 | |
86 struct InlinedFunctionInfo { | 25 struct InlinedFunctionInfo { |
87 InlinedFunctionInfo(int parent_id, SourcePosition inline_position, | 26 InlinedFunctionInfo(int parent_id, SourcePosition inline_position, |
88 int script_id, int start_position) | 27 int script_id, int start_position) |
89 : parent_id(parent_id), | 28 : parent_id(parent_id), |
90 inline_position(inline_position), | 29 inline_position(inline_position), |
91 script_id(script_id), | 30 script_id(script_id), |
92 start_position(start_position) {} | 31 start_position(start_position) {} |
93 int parent_id; | 32 int parent_id; |
94 SourcePosition inline_position; | 33 SourcePosition inline_position; |
95 int script_id; | 34 int script_id; |
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 size_t info_zone_start_allocation_size_; | 658 size_t info_zone_start_allocation_size_; |
720 base::ElapsedTimer timer_; | 659 base::ElapsedTimer timer_; |
721 | 660 |
722 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); | 661 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); |
723 }; | 662 }; |
724 | 663 |
725 } // namespace internal | 664 } // namespace internal |
726 } // namespace v8 | 665 } // namespace v8 |
727 | 666 |
728 #endif // V8_COMPILER_H_ | 667 #endif // V8_COMPILER_H_ |
OLD | NEW |