| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #ifndef V8_ARM_LITHIUM_CODEGEN_ARM_H_ | 28 #ifndef V8_ARM_LITHIUM_CODEGEN_ARM_H_ |
| 29 #define V8_ARM_LITHIUM_CODEGEN_ARM_H_ | 29 #define V8_ARM_LITHIUM_CODEGEN_ARM_H_ |
| 30 | 30 |
| 31 #include "arm/lithium-arm.h" | 31 #include "arm/lithium-arm.h" |
| 32 | 32 #include "arm/lithium-gap-resolver-arm.h" |
| 33 #include "deoptimizer.h" | 33 #include "deoptimizer.h" |
| 34 #include "safepoint-table.h" | 34 #include "safepoint-table.h" |
| 35 #include "scopes.h" | 35 #include "scopes.h" |
| 36 | 36 |
| 37 namespace v8 { | 37 namespace v8 { |
| 38 namespace internal { | 38 namespace internal { |
| 39 | 39 |
| 40 // Forward declarations. | 40 // Forward declarations. |
| 41 class LDeferredCode; | 41 class LDeferredCode; |
| 42 class LGapNode; | |
| 43 class SafepointGenerator; | 42 class SafepointGenerator; |
| 44 | 43 |
| 45 class LGapResolver BASE_EMBEDDED { | |
| 46 public: | |
| 47 LGapResolver(); | |
| 48 const ZoneList<LMoveOperands>* Resolve(const ZoneList<LMoveOperands>* moves, | |
| 49 LOperand* marker_operand); | |
| 50 | |
| 51 private: | |
| 52 LGapNode* LookupNode(LOperand* operand); | |
| 53 bool CanReach(LGapNode* a, LGapNode* b, int visited_id); | |
| 54 bool CanReach(LGapNode* a, LGapNode* b); | |
| 55 void RegisterMove(LMoveOperands move); | |
| 56 void AddResultMove(LOperand* from, LOperand* to); | |
| 57 void AddResultMove(LGapNode* from, LGapNode* to); | |
| 58 void ResolveCycle(LGapNode* start, LOperand* marker_operand); | |
| 59 | |
| 60 ZoneList<LGapNode*> nodes_; | |
| 61 ZoneList<LGapNode*> identified_cycles_; | |
| 62 ZoneList<LMoveOperands> result_; | |
| 63 int next_visited_id_; | |
| 64 }; | |
| 65 | |
| 66 | |
| 67 class LCodeGen BASE_EMBEDDED { | 44 class LCodeGen BASE_EMBEDDED { |
| 68 public: | 45 public: |
| 69 LCodeGen(LChunk* chunk, MacroAssembler* assembler, CompilationInfo* info) | 46 LCodeGen(LChunk* chunk, MacroAssembler* assembler, CompilationInfo* info) |
| 70 : chunk_(chunk), | 47 : chunk_(chunk), |
| 71 masm_(assembler), | 48 masm_(assembler), |
| 72 info_(info), | 49 info_(info), |
| 73 current_block_(-1), | 50 current_block_(-1), |
| 74 current_instruction_(-1), | 51 current_instruction_(-1), |
| 75 instructions_(chunk->instructions()), | 52 instructions_(chunk->instructions()), |
| 76 deoptimizations_(4), | 53 deoptimizations_(4), |
| 77 deoptimization_literals_(8), | 54 deoptimization_literals_(8), |
| 78 inlined_function_count_(0), | 55 inlined_function_count_(0), |
| 79 scope_(chunk->graph()->info()->scope()), | 56 scope_(chunk->graph()->info()->scope()), |
| 80 status_(UNUSED), | 57 status_(UNUSED), |
| 81 deferred_(8), | 58 deferred_(8), |
| 82 osr_pc_offset_(-1) { | 59 osr_pc_offset_(-1), |
| 60 resolver_(this) { |
| 83 PopulateDeoptimizationLiteralsWithInlinedFunctions(); | 61 PopulateDeoptimizationLiteralsWithInlinedFunctions(); |
| 84 } | 62 } |
| 85 | 63 |
| 64 |
| 65 // Simple accessors. |
| 66 MacroAssembler* masm() const { return masm_; } |
| 67 |
| 68 // Support for converting LOperands to assembler types. |
| 69 // LOperand must be a register. |
| 70 Register ToRegister(LOperand* op) const; |
| 71 |
| 72 // LOperand is loaded into scratch, unless already a register. |
| 73 Register EmitLoadRegister(LOperand* op, Register scratch); |
| 74 |
| 75 // LOperand must be a double register. |
| 76 DoubleRegister ToDoubleRegister(LOperand* op) const; |
| 77 |
| 78 // LOperand is loaded into dbl_scratch, unless already a double register. |
| 79 DoubleRegister EmitLoadDoubleRegister(LOperand* op, |
| 80 SwVfpRegister flt_scratch, |
| 81 DoubleRegister dbl_scratch); |
| 82 int ToInteger32(LConstantOperand* op) const; |
| 83 Operand ToOperand(LOperand* op); |
| 84 MemOperand ToMemOperand(LOperand* op) const; |
| 85 // Returns a MemOperand pointing to the high word of a DoubleStackSlot. |
| 86 MemOperand ToHighMemOperand(LOperand* op) const; |
| 87 |
| 86 // Try to generate code for the entire chunk, but it may fail if the | 88 // Try to generate code for the entire chunk, but it may fail if the |
| 87 // chunk contains constructs we cannot handle. Returns true if the | 89 // chunk contains constructs we cannot handle. Returns true if the |
| 88 // code generation attempt succeeded. | 90 // code generation attempt succeeded. |
| 89 bool GenerateCode(); | 91 bool GenerateCode(); |
| 90 | 92 |
| 91 // Finish the code by setting stack height, safepoint, and bailout | 93 // Finish the code by setting stack height, safepoint, and bailout |
| 92 // information on it. | 94 // information on it. |
| 93 void FinishCode(Handle<Code> code); | 95 void FinishCode(Handle<Code> code); |
| 94 | 96 |
| 95 // Deferred code support. | 97 // Deferred code support. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 125 }; | 127 }; |
| 126 | 128 |
| 127 bool is_unused() const { return status_ == UNUSED; } | 129 bool is_unused() const { return status_ == UNUSED; } |
| 128 bool is_generating() const { return status_ == GENERATING; } | 130 bool is_generating() const { return status_ == GENERATING; } |
| 129 bool is_done() const { return status_ == DONE; } | 131 bool is_done() const { return status_ == DONE; } |
| 130 bool is_aborted() const { return status_ == ABORTED; } | 132 bool is_aborted() const { return status_ == ABORTED; } |
| 131 | 133 |
| 132 LChunk* chunk() const { return chunk_; } | 134 LChunk* chunk() const { return chunk_; } |
| 133 Scope* scope() const { return scope_; } | 135 Scope* scope() const { return scope_; } |
| 134 HGraph* graph() const { return chunk_->graph(); } | 136 HGraph* graph() const { return chunk_->graph(); } |
| 135 MacroAssembler* masm() const { return masm_; } | |
| 136 | 137 |
| 137 Register scratch0() { return r9; } | 138 Register scratch0() { return r9; } |
| 138 DwVfpRegister double_scratch0() { return d0; } | 139 DwVfpRegister double_scratch0() { return d0; } |
| 139 | 140 |
| 140 int GetNextEmittedBlock(int block); | 141 int GetNextEmittedBlock(int block); |
| 141 LInstruction* GetNextInstruction(); | 142 LInstruction* GetNextInstruction(); |
| 142 | 143 |
| 143 void EmitClassOfTest(Label* if_true, | 144 void EmitClassOfTest(Label* if_true, |
| 144 Label* if_false, | 145 Label* if_false, |
| 145 Handle<String> class_name, | 146 Handle<String> class_name, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 LOperand* op, | 192 LOperand* op, |
| 192 bool is_tagged); | 193 bool is_tagged); |
| 193 void PopulateDeoptimizationData(Handle<Code> code); | 194 void PopulateDeoptimizationData(Handle<Code> code); |
| 194 int DefineDeoptimizationLiteral(Handle<Object> literal); | 195 int DefineDeoptimizationLiteral(Handle<Object> literal); |
| 195 | 196 |
| 196 void PopulateDeoptimizationLiteralsWithInlinedFunctions(); | 197 void PopulateDeoptimizationLiteralsWithInlinedFunctions(); |
| 197 | 198 |
| 198 Register ToRegister(int index) const; | 199 Register ToRegister(int index) const; |
| 199 DoubleRegister ToDoubleRegister(int index) const; | 200 DoubleRegister ToDoubleRegister(int index) const; |
| 200 | 201 |
| 201 // LOperand must be a register. | |
| 202 Register ToRegister(LOperand* op) const; | |
| 203 | |
| 204 // LOperand is loaded into scratch, unless already a register. | |
| 205 Register EmitLoadRegister(LOperand* op, Register scratch); | |
| 206 | |
| 207 // LOperand must be a double register. | |
| 208 DoubleRegister ToDoubleRegister(LOperand* op) const; | |
| 209 | |
| 210 // LOperand is loaded into dbl_scratch, unless already a double register. | |
| 211 DoubleRegister EmitLoadDoubleRegister(LOperand* op, | |
| 212 SwVfpRegister flt_scratch, | |
| 213 DoubleRegister dbl_scratch); | |
| 214 | |
| 215 int ToInteger32(LConstantOperand* op) const; | |
| 216 Operand ToOperand(LOperand* op); | |
| 217 MemOperand ToMemOperand(LOperand* op) const; | |
| 218 | |
| 219 // Specific math operations - used from DoUnaryMathOperation. | 202 // Specific math operations - used from DoUnaryMathOperation. |
| 220 void EmitIntegerMathAbs(LUnaryMathOperation* instr); | 203 void EmitIntegerMathAbs(LUnaryMathOperation* instr); |
| 221 void DoMathAbs(LUnaryMathOperation* instr); | 204 void DoMathAbs(LUnaryMathOperation* instr); |
| 222 void DoMathFloor(LUnaryMathOperation* instr); | 205 void DoMathFloor(LUnaryMathOperation* instr); |
| 223 void DoMathSqrt(LUnaryMathOperation* instr); | 206 void DoMathSqrt(LUnaryMathOperation* instr); |
| 224 | 207 |
| 225 // Support for recording safepoint and position information. | 208 // Support for recording safepoint and position information. |
| 226 void RecordSafepoint(LPointerMap* pointers, int deoptimization_index); | 209 void RecordSafepoint(LPointerMap* pointers, int deoptimization_index); |
| 227 void RecordSafepointWithRegisters(LPointerMap* pointers, | 210 void RecordSafepointWithRegisters(LPointerMap* pointers, |
| 228 int arguments, | 211 int arguments, |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 private: | 289 private: |
| 307 LCodeGen* codegen_; | 290 LCodeGen* codegen_; |
| 308 Label entry_; | 291 Label entry_; |
| 309 Label exit_; | 292 Label exit_; |
| 310 Label* external_exit_; | 293 Label* external_exit_; |
| 311 }; | 294 }; |
| 312 | 295 |
| 313 } } // namespace v8::internal | 296 } } // namespace v8::internal |
| 314 | 297 |
| 315 #endif // V8_ARM_LITHIUM_CODEGEN_ARM_H_ | 298 #endif // V8_ARM_LITHIUM_CODEGEN_ARM_H_ |
| OLD | NEW |