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/base/compiler-specific.h" |
13 #include "src/compiler/common-operator.h" | 14 #include "src/compiler/common-operator.h" |
14 #include "src/compiler/frame.h" | 15 #include "src/compiler/frame.h" |
15 #include "src/compiler/instruction-codes.h" | 16 #include "src/compiler/instruction-codes.h" |
16 #include "src/compiler/opcodes.h" | 17 #include "src/compiler/opcodes.h" |
17 #include "src/compiler/source-position.h" | 18 #include "src/compiler/source-position.h" |
| 19 #include "src/globals.h" |
18 #include "src/macro-assembler.h" | 20 #include "src/macro-assembler.h" |
19 #include "src/register-configuration.h" | 21 #include "src/register-configuration.h" |
20 #include "src/zone/zone-allocator.h" | 22 #include "src/zone/zone-allocator.h" |
21 | 23 |
22 namespace v8 { | 24 namespace v8 { |
23 namespace internal { | 25 namespace internal { |
24 namespace compiler { | 26 namespace compiler { |
25 | 27 |
26 // Forward declarations. | 28 // Forward declarations. |
27 class Schedule; | 29 class Schedule; |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 DCHECK(op.IsAnyLocationOperand()); | 511 DCHECK(op.IsAnyLocationOperand()); |
510 return *static_cast<const LocationOperand*>(&op); | 512 return *static_cast<const LocationOperand*>(&op); |
511 } | 513 } |
512 | 514 |
513 STATIC_ASSERT(KindField::kSize == 3); | 515 STATIC_ASSERT(KindField::kSize == 3); |
514 class LocationKindField : public BitField64<LocationKind, 3, 2> {}; | 516 class LocationKindField : public BitField64<LocationKind, 3, 2> {}; |
515 class RepresentationField : public BitField64<MachineRepresentation, 5, 8> {}; | 517 class RepresentationField : public BitField64<MachineRepresentation, 5, 8> {}; |
516 class IndexField : public BitField64<int32_t, 35, 29> {}; | 518 class IndexField : public BitField64<int32_t, 35, 29> {}; |
517 }; | 519 }; |
518 | 520 |
519 | 521 class V8_EXPORT_PRIVATE ExplicitOperand |
520 class ExplicitOperand : public LocationOperand { | 522 : public NON_EXPORTED_BASE(LocationOperand) { |
521 public: | 523 public: |
522 ExplicitOperand(LocationKind kind, MachineRepresentation rep, int index); | 524 ExplicitOperand(LocationKind kind, MachineRepresentation rep, int index); |
523 | 525 |
524 static ExplicitOperand* New(Zone* zone, LocationKind kind, | 526 static ExplicitOperand* New(Zone* zone, LocationKind kind, |
525 MachineRepresentation rep, int index) { | 527 MachineRepresentation rep, int index) { |
526 return InstructionOperand::New(zone, ExplicitOperand(kind, rep, index)); | 528 return InstructionOperand::New(zone, ExplicitOperand(kind, rep, index)); |
527 } | 529 } |
528 | 530 |
529 INSTRUCTION_OPERAND_CASTS(ExplicitOperand, EXPLICIT); | 531 INSTRUCTION_OPERAND_CASTS(ExplicitOperand, EXPLICIT); |
530 }; | 532 }; |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 friend std::ostream& operator<<(std::ostream& os, const ReferenceMap& pm); | 787 friend std::ostream& operator<<(std::ostream& os, const ReferenceMap& pm); |
786 | 788 |
787 ZoneVector<InstructionOperand> reference_operands_; | 789 ZoneVector<InstructionOperand> reference_operands_; |
788 int instruction_position_; | 790 int instruction_position_; |
789 }; | 791 }; |
790 | 792 |
791 std::ostream& operator<<(std::ostream& os, const ReferenceMap& pm); | 793 std::ostream& operator<<(std::ostream& os, const ReferenceMap& pm); |
792 | 794 |
793 class InstructionBlock; | 795 class InstructionBlock; |
794 | 796 |
795 class Instruction final { | 797 class V8_EXPORT_PRIVATE Instruction final { |
796 public: | 798 public: |
797 size_t OutputCount() const { return OutputCountField::decode(bit_field_); } | 799 size_t OutputCount() const { return OutputCountField::decode(bit_field_); } |
798 const InstructionOperand* OutputAt(size_t i) const { | 800 const InstructionOperand* OutputAt(size_t i) const { |
799 DCHECK(i < OutputCount()); | 801 DCHECK(i < OutputCount()); |
800 return &operands_[i]; | 802 return &operands_[i]; |
801 } | 803 } |
802 InstructionOperand* OutputAt(size_t i) { | 804 InstructionOperand* OutputAt(size_t i) { |
803 DCHECK(i < OutputCount()); | 805 DCHECK(i < OutputCount()); |
804 return &operands_[i]; | 806 return &operands_[i]; |
805 } | 807 } |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1012 bool operator>=(RpoNumber other) const { return index_ >= other.index_; } | 1014 bool operator>=(RpoNumber other) const { return index_ >= other.index_; } |
1013 | 1015 |
1014 private: | 1016 private: |
1015 explicit RpoNumber(int32_t index) : index_(index) {} | 1017 explicit RpoNumber(int32_t index) : index_(index) {} |
1016 int32_t index_; | 1018 int32_t index_; |
1017 }; | 1019 }; |
1018 | 1020 |
1019 | 1021 |
1020 std::ostream& operator<<(std::ostream&, const RpoNumber&); | 1022 std::ostream& operator<<(std::ostream&, const RpoNumber&); |
1021 | 1023 |
1022 | 1024 class V8_EXPORT_PRIVATE Constant final { |
1023 class Constant final { | |
1024 public: | 1025 public: |
1025 enum Type { | 1026 enum Type { |
1026 kInt32, | 1027 kInt32, |
1027 kInt64, | 1028 kInt64, |
1028 kFloat32, | 1029 kFloat32, |
1029 kFloat64, | 1030 kFloat64, |
1030 kExternalReference, | 1031 kExternalReference, |
1031 kHeapObject, | 1032 kHeapObject, |
1032 kRpoNumber | 1033 kRpoNumber |
1033 }; | 1034 }; |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1204 FrameStateDescriptor* descriptor() const { return descriptor_; } | 1205 FrameStateDescriptor* descriptor() const { return descriptor_; } |
1205 DeoptimizeReason reason() const { return reason_; } | 1206 DeoptimizeReason reason() const { return reason_; } |
1206 | 1207 |
1207 private: | 1208 private: |
1208 FrameStateDescriptor* descriptor_ = nullptr; | 1209 FrameStateDescriptor* descriptor_ = nullptr; |
1209 DeoptimizeReason reason_ = DeoptimizeReason::kNoReason; | 1210 DeoptimizeReason reason_ = DeoptimizeReason::kNoReason; |
1210 }; | 1211 }; |
1211 | 1212 |
1212 typedef ZoneVector<DeoptimizationEntry> DeoptimizationVector; | 1213 typedef ZoneVector<DeoptimizationEntry> DeoptimizationVector; |
1213 | 1214 |
1214 class PhiInstruction final : public ZoneObject { | 1215 class V8_EXPORT_PRIVATE PhiInstruction final |
| 1216 : public NON_EXPORTED_BASE(ZoneObject) { |
1215 public: | 1217 public: |
1216 typedef ZoneVector<InstructionOperand> Inputs; | 1218 typedef ZoneVector<InstructionOperand> Inputs; |
1217 | 1219 |
1218 PhiInstruction(Zone* zone, int virtual_register, size_t input_count); | 1220 PhiInstruction(Zone* zone, int virtual_register, size_t input_count); |
1219 | 1221 |
1220 void SetInput(size_t offset, int virtual_register); | 1222 void SetInput(size_t offset, int virtual_register); |
1221 void RenameInput(size_t offset, int virtual_register); | 1223 void RenameInput(size_t offset, int virtual_register); |
1222 | 1224 |
1223 int virtual_register() const { return virtual_register_; } | 1225 int virtual_register() const { return virtual_register_; } |
1224 const IntVector& operands() const { return operands_; } | 1226 const IntVector& operands() const { return operands_; } |
1225 | 1227 |
1226 // TODO(dcarney): this has no real business being here, since it's internal to | 1228 // TODO(dcarney): this has no real business being here, since it's internal to |
1227 // the register allocator, but putting it here was convenient. | 1229 // the register allocator, but putting it here was convenient. |
1228 const InstructionOperand& output() const { return output_; } | 1230 const InstructionOperand& output() const { return output_; } |
1229 InstructionOperand& output() { return output_; } | 1231 InstructionOperand& output() { return output_; } |
1230 | 1232 |
1231 private: | 1233 private: |
1232 const int virtual_register_; | 1234 const int virtual_register_; |
1233 InstructionOperand output_; | 1235 InstructionOperand output_; |
1234 IntVector operands_; | 1236 IntVector operands_; |
1235 }; | 1237 }; |
1236 | 1238 |
1237 | 1239 |
1238 // Analogue of BasicBlock for Instructions instead of Nodes. | 1240 // Analogue of BasicBlock for Instructions instead of Nodes. |
1239 class InstructionBlock final : public ZoneObject { | 1241 class V8_EXPORT_PRIVATE InstructionBlock final |
| 1242 : public NON_EXPORTED_BASE(ZoneObject) { |
1240 public: | 1243 public: |
1241 InstructionBlock(Zone* zone, RpoNumber rpo_number, RpoNumber loop_header, | 1244 InstructionBlock(Zone* zone, RpoNumber rpo_number, RpoNumber loop_header, |
1242 RpoNumber loop_end, bool deferred, bool handler); | 1245 RpoNumber loop_end, bool deferred, bool handler); |
1243 | 1246 |
1244 // Instruction indexes (used by the register allocator). | 1247 // Instruction indexes (used by the register allocator). |
1245 int first_instruction_index() const { | 1248 int first_instruction_index() const { |
1246 DCHECK(code_start_ >= 0); | 1249 DCHECK(code_start_ >= 0); |
1247 DCHECK(code_end_ > 0); | 1250 DCHECK(code_end_ > 0); |
1248 DCHECK(code_end_ >= code_start_); | 1251 DCHECK(code_end_ >= code_start_); |
1249 return code_start_; | 1252 return code_start_; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1336 typedef ZoneDeque<ReferenceMap*> ReferenceMapDeque; | 1339 typedef ZoneDeque<ReferenceMap*> ReferenceMapDeque; |
1337 typedef ZoneVector<InstructionBlock*> InstructionBlocks; | 1340 typedef ZoneVector<InstructionBlock*> InstructionBlocks; |
1338 | 1341 |
1339 | 1342 |
1340 // Forward declarations. | 1343 // Forward declarations. |
1341 struct PrintableInstructionSequence; | 1344 struct PrintableInstructionSequence; |
1342 | 1345 |
1343 | 1346 |
1344 // Represents architecture-specific generated code before, during, and after | 1347 // Represents architecture-specific generated code before, during, and after |
1345 // register allocation. | 1348 // register allocation. |
1346 class InstructionSequence final : public ZoneObject { | 1349 class V8_EXPORT_PRIVATE InstructionSequence final |
| 1350 : public NON_EXPORTED_BASE(ZoneObject) { |
1347 public: | 1351 public: |
1348 static InstructionBlocks* InstructionBlocksFor(Zone* zone, | 1352 static InstructionBlocks* InstructionBlocksFor(Zone* zone, |
1349 const Schedule* schedule); | 1353 const Schedule* schedule); |
1350 // Puts the deferred blocks last. | 1354 // Puts the deferred blocks last. |
1351 static void ComputeAssemblyOrder(InstructionBlocks* blocks); | 1355 static void ComputeAssemblyOrder(InstructionBlocks* blocks); |
1352 | 1356 |
1353 InstructionSequence(Isolate* isolate, Zone* zone, | 1357 InstructionSequence(Isolate* isolate, Zone* zone, |
1354 InstructionBlocks* instruction_blocks); | 1358 InstructionBlocks* instruction_blocks); |
1355 | 1359 |
1356 int NextVirtualRegister(); | 1360 int NextVirtualRegister(); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1494 | 1498 |
1495 void PrintBlock(const RegisterConfiguration* config, int block_id) const; | 1499 void PrintBlock(const RegisterConfiguration* config, int block_id) const; |
1496 void PrintBlock(int block_id) const; | 1500 void PrintBlock(int block_id) const; |
1497 | 1501 |
1498 void ValidateEdgeSplitForm() const; | 1502 void ValidateEdgeSplitForm() const; |
1499 void ValidateDeferredBlockExitPaths() const; | 1503 void ValidateDeferredBlockExitPaths() const; |
1500 void ValidateDeferredBlockEntryPaths() const; | 1504 void ValidateDeferredBlockEntryPaths() const; |
1501 void ValidateSSA() const; | 1505 void ValidateSSA() const; |
1502 | 1506 |
1503 private: | 1507 private: |
1504 friend std::ostream& operator<<(std::ostream& os, | 1508 friend V8_EXPORT_PRIVATE std::ostream& operator<<( |
1505 const PrintableInstructionSequence& code); | 1509 std::ostream& os, const PrintableInstructionSequence& code); |
1506 | 1510 |
1507 typedef ZoneMap<const Instruction*, SourcePosition> SourcePositionMap; | 1511 typedef ZoneMap<const Instruction*, SourcePosition> SourcePositionMap; |
1508 | 1512 |
1509 Isolate* isolate_; | 1513 Isolate* isolate_; |
1510 Zone* const zone_; | 1514 Zone* const zone_; |
1511 InstructionBlocks* const instruction_blocks_; | 1515 InstructionBlocks* const instruction_blocks_; |
1512 SourcePositionMap source_positions_; | 1516 SourcePositionMap source_positions_; |
1513 ConstantMap constants_; | 1517 ConstantMap constants_; |
1514 Immediates immediates_; | 1518 Immediates immediates_; |
1515 InstructionDeque instructions_; | 1519 InstructionDeque instructions_; |
1516 int next_virtual_register_; | 1520 int next_virtual_register_; |
1517 ReferenceMapDeque reference_maps_; | 1521 ReferenceMapDeque reference_maps_; |
1518 ZoneVector<MachineRepresentation> representations_; | 1522 ZoneVector<MachineRepresentation> representations_; |
1519 DeoptimizationVector deoptimization_entries_; | 1523 DeoptimizationVector deoptimization_entries_; |
1520 | 1524 |
1521 // Used at construction time | 1525 // Used at construction time |
1522 InstructionBlock* current_block_; | 1526 InstructionBlock* current_block_; |
1523 | 1527 |
1524 DISALLOW_COPY_AND_ASSIGN(InstructionSequence); | 1528 DISALLOW_COPY_AND_ASSIGN(InstructionSequence); |
1525 }; | 1529 }; |
1526 | 1530 |
1527 | 1531 |
1528 struct PrintableInstructionSequence { | 1532 struct PrintableInstructionSequence { |
1529 const RegisterConfiguration* register_configuration_; | 1533 const RegisterConfiguration* register_configuration_; |
1530 const InstructionSequence* sequence_; | 1534 const InstructionSequence* sequence_; |
1531 }; | 1535 }; |
1532 | 1536 |
1533 | 1537 V8_EXPORT_PRIVATE std::ostream& operator<<( |
1534 std::ostream& operator<<(std::ostream& os, | 1538 std::ostream& os, const PrintableInstructionSequence& code); |
1535 const PrintableInstructionSequence& code); | |
1536 | 1539 |
1537 } // namespace compiler | 1540 } // namespace compiler |
1538 } // namespace internal | 1541 } // namespace internal |
1539 } // namespace v8 | 1542 } // namespace v8 |
1540 | 1543 |
1541 #endif // V8_COMPILER_INSTRUCTION_H_ | 1544 #endif // V8_COMPILER_INSTRUCTION_H_ |
OLD | NEW |