OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_INSTRUCTION_H_ | 5 #ifndef V8_COMPILER_INSTRUCTION_H_ |
6 #define V8_COMPILER_INSTRUCTION_H_ | 6 #define V8_COMPILER_INSTRUCTION_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <iosfwd> | 9 #include <iosfwd> |
10 #include <map> | 10 #include <map> |
11 #include <set> | 11 #include <set> |
12 | 12 |
13 #include "src/compiler/common-operator.h" | 13 #include "src/compiler/common-operator.h" |
14 #include "src/compiler/frame.h" | 14 #include "src/compiler/frame.h" |
15 #include "src/compiler/instruction-codes.h" | 15 #include "src/compiler/instruction-codes.h" |
16 #include "src/compiler/opcodes.h" | 16 #include "src/compiler/opcodes.h" |
17 #include "src/compiler/source-position.h" | 17 #include "src/compiler/source-position.h" |
18 #include "src/macro-assembler.h" | 18 #include "src/macro-assembler.h" |
19 #include "src/register-configuration.h" | 19 #include "src/register-configuration.h" |
20 #include "src/zone-allocator.h" | 20 #include "src/zone-allocator.h" |
21 | 21 |
22 namespace v8 { | 22 namespace v8 { |
23 namespace internal { | 23 namespace internal { |
24 namespace compiler { | 24 namespace compiler { |
25 | 25 |
| 26 class FrameStateDescriptor; |
26 class Schedule; | 27 class Schedule; |
27 | 28 |
| 29 |
28 class InstructionOperand { | 30 class InstructionOperand { |
29 public: | 31 public: |
30 static const int kInvalidVirtualRegister = -1; | 32 static const int kInvalidVirtualRegister = -1; |
31 | 33 |
32 // TODO(dcarney): recover bit. INVALID can be represented as UNALLOCATED with | 34 // TODO(dcarney): recover bit. INVALID can be represented as UNALLOCATED with |
33 // kInvalidVirtualRegister and some DCHECKS. | 35 // kInvalidVirtualRegister and some DCHECKS. |
34 enum Kind { INVALID, UNALLOCATED, CONSTANT, IMMEDIATE, EXPLICIT, ALLOCATED }; | 36 enum Kind { INVALID, UNALLOCATED, CONSTANT, IMMEDIATE, EXPLICIT, ALLOCATED }; |
35 | 37 |
36 InstructionOperand() : InstructionOperand(INVALID) {} | 38 InstructionOperand() : InstructionOperand(INVALID) {} |
37 | 39 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 explicit InstructionOperand(Kind kind) : value_(KindField::encode(kind)) {} | 100 explicit InstructionOperand(Kind kind) : value_(KindField::encode(kind)) {} |
99 | 101 |
100 inline uint64_t GetCanonicalizedValue() const; | 102 inline uint64_t GetCanonicalizedValue() const; |
101 | 103 |
102 class KindField : public BitField64<Kind, 0, 3> {}; | 104 class KindField : public BitField64<Kind, 0, 3> {}; |
103 | 105 |
104 uint64_t value_; | 106 uint64_t value_; |
105 }; | 107 }; |
106 | 108 |
107 | 109 |
| 110 typedef ZoneVector<InstructionOperand> InstructionOperandVector; |
| 111 |
| 112 |
108 struct PrintableInstructionOperand { | 113 struct PrintableInstructionOperand { |
109 const RegisterConfiguration* register_configuration_; | 114 const RegisterConfiguration* register_configuration_; |
110 InstructionOperand op_; | 115 InstructionOperand op_; |
111 }; | 116 }; |
112 | 117 |
113 | 118 |
114 std::ostream& operator<<(std::ostream& os, | 119 std::ostream& operator<<(std::ostream& os, |
115 const PrintableInstructionOperand& op); | 120 const PrintableInstructionOperand& op); |
116 | 121 |
117 | 122 |
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
921 DCHECK_EQ(kHeapObject, type()); | 926 DCHECK_EQ(kHeapObject, type()); |
922 return bit_cast<Handle<HeapObject> >(static_cast<intptr_t>(value_)); | 927 return bit_cast<Handle<HeapObject> >(static_cast<intptr_t>(value_)); |
923 } | 928 } |
924 | 929 |
925 private: | 930 private: |
926 Type type_; | 931 Type type_; |
927 int64_t value_; | 932 int64_t value_; |
928 }; | 933 }; |
929 | 934 |
930 | 935 |
931 class FrameStateDescriptor : public ZoneObject { | |
932 public: | |
933 FrameStateDescriptor(Zone* zone, FrameStateType type, BailoutId bailout_id, | |
934 OutputFrameStateCombine state_combine, | |
935 size_t parameters_count, size_t locals_count, | |
936 size_t stack_count, | |
937 MaybeHandle<SharedFunctionInfo> shared_info, | |
938 FrameStateDescriptor* outer_state = nullptr); | |
939 | |
940 FrameStateType type() const { return type_; } | |
941 BailoutId bailout_id() const { return bailout_id_; } | |
942 OutputFrameStateCombine state_combine() const { return frame_state_combine_; } | |
943 size_t parameters_count() const { return parameters_count_; } | |
944 size_t locals_count() const { return locals_count_; } | |
945 size_t stack_count() const { return stack_count_; } | |
946 MaybeHandle<SharedFunctionInfo> shared_info() const { return shared_info_; } | |
947 FrameStateDescriptor* outer_state() const { return outer_state_; } | |
948 bool HasContext() const { | |
949 return type_ == FrameStateType::kJavaScriptFunction; | |
950 } | |
951 | |
952 size_t GetSize(OutputFrameStateCombine combine = | |
953 OutputFrameStateCombine::Ignore()) const; | |
954 size_t GetTotalSize() const; | |
955 size_t GetFrameCount() const; | |
956 size_t GetJSFrameCount() const; | |
957 | |
958 MachineType GetType(size_t index) const; | |
959 void SetType(size_t index, MachineType type); | |
960 | |
961 private: | |
962 FrameStateType type_; | |
963 BailoutId bailout_id_; | |
964 OutputFrameStateCombine frame_state_combine_; | |
965 size_t parameters_count_; | |
966 size_t locals_count_; | |
967 size_t stack_count_; | |
968 ZoneVector<MachineType> types_; | |
969 MaybeHandle<SharedFunctionInfo> const shared_info_; | |
970 FrameStateDescriptor* outer_state_; | |
971 }; | |
972 | |
973 std::ostream& operator<<(std::ostream& os, const Constant& constant); | 936 std::ostream& operator<<(std::ostream& os, const Constant& constant); |
974 | 937 |
975 | 938 |
976 class PhiInstruction final : public ZoneObject { | 939 class PhiInstruction final : public ZoneObject { |
977 public: | 940 public: |
978 typedef ZoneVector<InstructionOperand> Inputs; | 941 typedef ZoneVector<InstructionOperand> Inputs; |
979 | 942 |
980 PhiInstruction(Zone* zone, int virtual_register, size_t input_count); | 943 PhiInstruction(Zone* zone, int virtual_register, size_t input_count); |
981 | 944 |
982 void SetInput(size_t offset, int virtual_register); | 945 void SetInput(size_t offset, int virtual_register); |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1277 | 1240 |
1278 | 1241 |
1279 std::ostream& operator<<(std::ostream& os, | 1242 std::ostream& operator<<(std::ostream& os, |
1280 const PrintableInstructionSequence& code); | 1243 const PrintableInstructionSequence& code); |
1281 | 1244 |
1282 } // namespace compiler | 1245 } // namespace compiler |
1283 } // namespace internal | 1246 } // namespace internal |
1284 } // namespace v8 | 1247 } // namespace v8 |
1285 | 1248 |
1286 #endif // V8_COMPILER_INSTRUCTION_H_ | 1249 #endif // V8_COMPILER_INSTRUCTION_H_ |
OLD | NEW |