| 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_SELECTOR_H_ | 5 #ifndef V8_COMPILER_INSTRUCTION_SELECTOR_H_ |
| 6 #define V8_COMPILER_INSTRUCTION_SELECTOR_H_ | 6 #define V8_COMPILER_INSTRUCTION_SELECTOR_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "src/compiler/common-operator.h" | 10 #include "src/compiler/common-operator.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 }; | 42 }; |
| 43 | 43 |
| 44 // Instruction selection generates an InstructionSequence for a given Schedule. | 44 // Instruction selection generates an InstructionSequence for a given Schedule. |
| 45 class InstructionSelector final { | 45 class InstructionSelector final { |
| 46 public: | 46 public: |
| 47 // Forward declarations. | 47 // Forward declarations. |
| 48 class Features; | 48 class Features; |
| 49 | 49 |
| 50 enum SourcePositionMode { kCallSourcePositions, kAllSourcePositions }; | 50 enum SourcePositionMode { kCallSourcePositions, kAllSourcePositions }; |
| 51 enum EnableScheduling { kDisableScheduling, kEnableScheduling }; | 51 enum EnableScheduling { kDisableScheduling, kEnableScheduling }; |
| 52 enum EnableSerialization { kDisableSerialization, kEnableSerialization }; |
| 52 | 53 |
| 53 InstructionSelector( | 54 InstructionSelector( |
| 54 Zone* zone, size_t node_count, Linkage* linkage, | 55 Zone* zone, size_t node_count, Linkage* linkage, |
| 55 InstructionSequence* sequence, Schedule* schedule, | 56 InstructionSequence* sequence, Schedule* schedule, |
| 56 SourcePositionTable* source_positions, Frame* frame, | 57 SourcePositionTable* source_positions, Frame* frame, |
| 57 SourcePositionMode source_position_mode = kCallSourcePositions, | 58 SourcePositionMode source_position_mode = kCallSourcePositions, |
| 58 Features features = SupportedFeatures(), | 59 Features features = SupportedFeatures(), |
| 59 EnableScheduling enable_scheduling = FLAG_turbo_instruction_scheduling | 60 EnableScheduling enable_scheduling = FLAG_turbo_instruction_scheduling |
| 60 ? kEnableScheduling | 61 ? kEnableScheduling |
| 61 : kDisableScheduling); | 62 : kDisableScheduling, |
| 63 EnableSerialization enable_serialization = kDisableSerialization); |
| 62 | 64 |
| 63 // Visit code for the entire graph with the included schedule. | 65 // Visit code for the entire graph with the included schedule. |
| 64 bool SelectInstructions(); | 66 bool SelectInstructions(); |
| 65 | 67 |
| 66 void StartBlock(RpoNumber rpo); | 68 void StartBlock(RpoNumber rpo); |
| 67 void EndBlock(RpoNumber rpo); | 69 void EndBlock(RpoNumber rpo); |
| 68 void AddInstruction(Instruction* instr); | 70 void AddInstruction(Instruction* instr); |
| 69 | 71 |
| 70 // =========================================================================== | 72 // =========================================================================== |
| 71 // ============= Architecture-independent code emission methods. ============= | 73 // ============= Architecture-independent code emission methods. ============= |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 | 193 |
| 192 // Checks if {node} is currently live. | 194 // Checks if {node} is currently live. |
| 193 bool IsLive(Node* node) const { return !IsDefined(node) && IsUsed(node); } | 195 bool IsLive(Node* node) const { return !IsDefined(node) && IsUsed(node); } |
| 194 | 196 |
| 195 // Gets the effect level of {node}. | 197 // Gets the effect level of {node}. |
| 196 int GetEffectLevel(Node* node) const; | 198 int GetEffectLevel(Node* node) const; |
| 197 | 199 |
| 198 int GetVirtualRegister(const Node* node); | 200 int GetVirtualRegister(const Node* node); |
| 199 const std::map<NodeId, int> GetVirtualRegistersForTesting() const; | 201 const std::map<NodeId, int> GetVirtualRegistersForTesting() const; |
| 200 | 202 |
| 203 // Check if we can generate loads and stores of ExternalConstants relative |
| 204 // to the roots register, i.e. if both a root register is available for this |
| 205 // compilation unit and the serializer is disabled. |
| 206 bool CanAddressRelativeToRootsRegister() const; |
| 207 |
| 201 Isolate* isolate() const { return sequence()->isolate(); } | 208 Isolate* isolate() const { return sequence()->isolate(); } |
| 202 | 209 |
| 203 private: | 210 private: |
| 204 friend class OperandGenerator; | 211 friend class OperandGenerator; |
| 205 | 212 |
| 206 bool UseInstructionScheduling() const { | 213 bool UseInstructionScheduling() const { |
| 207 return (enable_scheduling_ == kEnableScheduling) && | 214 return (enable_scheduling_ == kEnableScheduling) && |
| 208 InstructionScheduler::SchedulerSupported(); | 215 InstructionScheduler::SchedulerSupported(); |
| 209 } | 216 } |
| 210 | 217 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 Schedule* const schedule_; | 355 Schedule* const schedule_; |
| 349 BasicBlock* current_block_; | 356 BasicBlock* current_block_; |
| 350 ZoneVector<Instruction*> instructions_; | 357 ZoneVector<Instruction*> instructions_; |
| 351 BoolVector defined_; | 358 BoolVector defined_; |
| 352 BoolVector used_; | 359 BoolVector used_; |
| 353 IntVector effect_level_; | 360 IntVector effect_level_; |
| 354 IntVector virtual_registers_; | 361 IntVector virtual_registers_; |
| 355 IntVector virtual_register_rename_; | 362 IntVector virtual_register_rename_; |
| 356 InstructionScheduler* scheduler_; | 363 InstructionScheduler* scheduler_; |
| 357 EnableScheduling enable_scheduling_; | 364 EnableScheduling enable_scheduling_; |
| 365 EnableSerialization enable_serialization_; |
| 358 Frame* frame_; | 366 Frame* frame_; |
| 359 bool instruction_selection_failed_; | 367 bool instruction_selection_failed_; |
| 360 }; | 368 }; |
| 361 | 369 |
| 362 } // namespace compiler | 370 } // namespace compiler |
| 363 } // namespace internal | 371 } // namespace internal |
| 364 } // namespace v8 | 372 } // namespace v8 |
| 365 | 373 |
| 366 #endif // V8_COMPILER_INSTRUCTION_SELECTOR_H_ | 374 #endif // V8_COMPILER_INSTRUCTION_SELECTOR_H_ |
| OLD | NEW |