| 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 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 #ifndef V8_IA32_LITHIUM_CODEGEN_IA32_H_ | 28 #ifndef V8_IA32_LITHIUM_CODEGEN_IA32_H_ |
| 29 #define V8_IA32_LITHIUM_CODEGEN_IA32_H_ | 29 #define V8_IA32_LITHIUM_CODEGEN_IA32_H_ |
| 30 | 30 |
| 31 #include "ia32/lithium-ia32.h" | 31 #include "ia32/lithium-ia32.h" |
| 32 | 32 |
| 33 #include "checks.h" | 33 #include "checks.h" |
| 34 #include "deoptimizer.h" | 34 #include "deoptimizer.h" |
| 35 #include "safepoint-table.h" | 35 #include "safepoint-table.h" |
| 36 #include "scopes.h" | 36 #include "scopes.h" |
| 37 #include "ia32/lithium-gap-resolver-ia32.h" |
| 37 | 38 |
| 38 namespace v8 { | 39 namespace v8 { |
| 39 namespace internal { | 40 namespace internal { |
| 40 | 41 |
| 41 // Forward declarations. | 42 // Forward declarations. |
| 42 class LDeferredCode; | 43 class LDeferredCode; |
| 44 class LGapNode; |
| 43 class SafepointGenerator; | 45 class SafepointGenerator; |
| 44 | 46 |
| 45 class LCodeGen BASE_EMBEDDED { | 47 class LCodeGen BASE_EMBEDDED { |
| 46 public: | 48 public: |
| 47 LCodeGen(LChunk* chunk, MacroAssembler* assembler, CompilationInfo* info) | 49 LCodeGen(LChunk* chunk, MacroAssembler* assembler, CompilationInfo* info) |
| 48 : chunk_(chunk), | 50 : chunk_(chunk), |
| 49 masm_(assembler), | 51 masm_(assembler), |
| 50 info_(info), | 52 info_(info), |
| 51 current_block_(-1), | 53 current_block_(-1), |
| 52 current_instruction_(-1), | 54 current_instruction_(-1), |
| 53 instructions_(chunk->instructions()), | 55 instructions_(chunk->instructions()), |
| 54 deoptimizations_(4), | 56 deoptimizations_(4), |
| 55 deoptimization_literals_(8), | 57 deoptimization_literals_(8), |
| 56 inlined_function_count_(0), | 58 inlined_function_count_(0), |
| 57 scope_(chunk->graph()->info()->scope()), | 59 scope_(chunk->graph()->info()->scope()), |
| 58 status_(UNUSED), | 60 status_(UNUSED), |
| 59 deferred_(8), | 61 deferred_(8), |
| 60 osr_pc_offset_(-1) { | 62 osr_pc_offset_(-1), |
| 63 resolver_(this) { |
| 61 PopulateDeoptimizationLiteralsWithInlinedFunctions(); | 64 PopulateDeoptimizationLiteralsWithInlinedFunctions(); |
| 62 } | 65 } |
| 63 | 66 |
| 67 // Simple accessors. |
| 68 MacroAssembler* masm() const { return masm_; } |
| 69 |
| 70 // Support for converting LOperands to assembler types. |
| 71 Operand ToOperand(LOperand* op) const; |
| 72 Register ToRegister(LOperand* op) const; |
| 73 XMMRegister ToDoubleRegister(LOperand* op) const; |
| 74 Immediate ToImmediate(LOperand* op); |
| 75 |
| 76 // The operand denoting the second word (the one with a higher address) of |
| 77 // a double stack slot. |
| 78 Operand HighOperand(LOperand* op); |
| 79 |
| 64 // Try to generate code for the entire chunk, but it may fail if the | 80 // Try to generate code for the entire chunk, but it may fail if the |
| 65 // chunk contains constructs we cannot handle. Returns true if the | 81 // chunk contains constructs we cannot handle. Returns true if the |
| 66 // code generation attempt succeeded. | 82 // code generation attempt succeeded. |
| 67 bool GenerateCode(); | 83 bool GenerateCode(); |
| 68 | 84 |
| 69 // Finish the code by setting stack height, safepoint, and bailout | 85 // Finish the code by setting stack height, safepoint, and bailout |
| 70 // information on it. | 86 // information on it. |
| 71 void FinishCode(Handle<Code> code); | 87 void FinishCode(Handle<Code> code); |
| 72 | 88 |
| 73 // Deferred code support. | 89 // Deferred code support. |
| 74 void DoDeferredNumberTagD(LNumberTagD* instr); | 90 void DoDeferredNumberTagD(LNumberTagD* instr); |
| 75 void DoDeferredNumberTagI(LNumberTagI* instr); | 91 void DoDeferredNumberTagI(LNumberTagI* instr); |
| 76 void DoDeferredTaggedToI(LTaggedToI* instr); | 92 void DoDeferredTaggedToI(LTaggedToI* instr); |
| 77 void DoDeferredMathAbsTaggedHeapNumber(LUnaryMathOperation* instr); | 93 void DoDeferredMathAbsTaggedHeapNumber(LUnaryMathOperation* instr); |
| 78 void DoDeferredStackCheck(LGoto* instr); | 94 void DoDeferredStackCheck(LGoto* instr); |
| 95 void DoDeferredStringCharCodeAt(LStringCharCodeAt* instr); |
| 79 void DoDeferredLInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr, | 96 void DoDeferredLInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr, |
| 80 Label* map_check); | 97 Label* map_check); |
| 81 | 98 |
| 82 // Parallel move support. | 99 // Parallel move support. |
| 83 void DoParallelMove(LParallelMove* move); | 100 void DoParallelMove(LParallelMove* move); |
| 84 | 101 |
| 85 // Emit frame translation commands for an environment. | 102 // Emit frame translation commands for an environment. |
| 86 void WriteTranslation(LEnvironment* environment, Translation* translation); | 103 void WriteTranslation(LEnvironment* environment, Translation* translation); |
| 87 | 104 |
| 88 // Declare methods that deal with the individual node types. | 105 // Declare methods that deal with the individual node types. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 99 }; | 116 }; |
| 100 | 117 |
| 101 bool is_unused() const { return status_ == UNUSED; } | 118 bool is_unused() const { return status_ == UNUSED; } |
| 102 bool is_generating() const { return status_ == GENERATING; } | 119 bool is_generating() const { return status_ == GENERATING; } |
| 103 bool is_done() const { return status_ == DONE; } | 120 bool is_done() const { return status_ == DONE; } |
| 104 bool is_aborted() const { return status_ == ABORTED; } | 121 bool is_aborted() const { return status_ == ABORTED; } |
| 105 | 122 |
| 106 LChunk* chunk() const { return chunk_; } | 123 LChunk* chunk() const { return chunk_; } |
| 107 Scope* scope() const { return scope_; } | 124 Scope* scope() const { return scope_; } |
| 108 HGraph* graph() const { return chunk_->graph(); } | 125 HGraph* graph() const { return chunk_->graph(); } |
| 109 MacroAssembler* masm() const { return masm_; } | |
| 110 | 126 |
| 111 int GetNextEmittedBlock(int block); | 127 int GetNextEmittedBlock(int block); |
| 112 LInstruction* GetNextInstruction(); | 128 LInstruction* GetNextInstruction(); |
| 113 | 129 |
| 114 void EmitClassOfTest(Label* if_true, | 130 void EmitClassOfTest(Label* if_true, |
| 115 Label* if_false, | 131 Label* if_false, |
| 116 Handle<String> class_name, | 132 Handle<String> class_name, |
| 117 Register input, | 133 Register input, |
| 118 Register temporary, | 134 Register temporary, |
| 119 Register temporary2); | 135 Register temporary2); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 145 const Runtime::Function* function = Runtime::FunctionForId(id); | 161 const Runtime::Function* function = Runtime::FunctionForId(id); |
| 146 CallRuntime(function, num_arguments, instr); | 162 CallRuntime(function, num_arguments, instr); |
| 147 } | 163 } |
| 148 | 164 |
| 149 // Generate a direct call to a known function. Expects the function | 165 // Generate a direct call to a known function. Expects the function |
| 150 // to be in edi. | 166 // to be in edi. |
| 151 void CallKnownFunction(Handle<JSFunction> function, | 167 void CallKnownFunction(Handle<JSFunction> function, |
| 152 int arity, | 168 int arity, |
| 153 LInstruction* instr); | 169 LInstruction* instr); |
| 154 | 170 |
| 155 void LoadPrototype(Register result, Handle<JSObject> prototype); | 171 void LoadHeapObject(Register result, Handle<HeapObject> object); |
| 156 | 172 |
| 157 void RegisterLazyDeoptimization(LInstruction* instr); | 173 void RegisterLazyDeoptimization(LInstruction* instr); |
| 158 void RegisterEnvironmentForDeoptimization(LEnvironment* environment); | 174 void RegisterEnvironmentForDeoptimization(LEnvironment* environment); |
| 159 void DeoptimizeIf(Condition cc, LEnvironment* environment); | 175 void DeoptimizeIf(Condition cc, LEnvironment* environment); |
| 160 | 176 |
| 161 void AddToTranslation(Translation* translation, | 177 void AddToTranslation(Translation* translation, |
| 162 LOperand* op, | 178 LOperand* op, |
| 163 bool is_tagged); | 179 bool is_tagged); |
| 164 void PopulateDeoptimizationData(Handle<Code> code); | 180 void PopulateDeoptimizationData(Handle<Code> code); |
| 165 int DefineDeoptimizationLiteral(Handle<Object> literal); | 181 int DefineDeoptimizationLiteral(Handle<Object> literal); |
| 166 | 182 |
| 167 void PopulateDeoptimizationLiteralsWithInlinedFunctions(); | 183 void PopulateDeoptimizationLiteralsWithInlinedFunctions(); |
| 168 | 184 |
| 169 Register ToRegister(int index) const; | 185 Register ToRegister(int index) const; |
| 170 XMMRegister ToDoubleRegister(int index) const; | 186 XMMRegister ToDoubleRegister(int index) const; |
| 171 Register ToRegister(LOperand* op) const; | |
| 172 XMMRegister ToDoubleRegister(LOperand* op) const; | |
| 173 int ToInteger32(LConstantOperand* op) const; | 187 int ToInteger32(LConstantOperand* op) const; |
| 174 Operand ToOperand(LOperand* op) const; | |
| 175 Immediate ToImmediate(LOperand* op); | |
| 176 | 188 |
| 177 // Specific math operations - used from DoUnaryMathOperation. | 189 // Specific math operations - used from DoUnaryMathOperation. |
| 190 void EmitIntegerMathAbs(LUnaryMathOperation* instr); |
| 178 void DoMathAbs(LUnaryMathOperation* instr); | 191 void DoMathAbs(LUnaryMathOperation* instr); |
| 179 void DoMathFloor(LUnaryMathOperation* instr); | 192 void DoMathFloor(LUnaryMathOperation* instr); |
| 180 void DoMathRound(LUnaryMathOperation* instr); | 193 void DoMathRound(LUnaryMathOperation* instr); |
| 181 void DoMathSqrt(LUnaryMathOperation* instr); | 194 void DoMathSqrt(LUnaryMathOperation* instr); |
| 182 void DoMathPowHalf(LUnaryMathOperation* instr); | 195 void DoMathPowHalf(LUnaryMathOperation* instr); |
| 183 void DoMathLog(LUnaryMathOperation* instr); | 196 void DoMathLog(LUnaryMathOperation* instr); |
| 184 void DoMathCos(LUnaryMathOperation* instr); | 197 void DoMathCos(LUnaryMathOperation* instr); |
| 185 void DoMathSin(LUnaryMathOperation* instr); | 198 void DoMathSin(LUnaryMathOperation* instr); |
| 186 | 199 |
| 187 // Support for recording safepoint and position information. | 200 // Support for recording safepoint and position information. |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 private: | 276 private: |
| 264 LCodeGen* codegen_; | 277 LCodeGen* codegen_; |
| 265 Label entry_; | 278 Label entry_; |
| 266 Label exit_; | 279 Label exit_; |
| 267 Label* external_exit_; | 280 Label* external_exit_; |
| 268 }; | 281 }; |
| 269 | 282 |
| 270 } } // namespace v8::internal | 283 } } // namespace v8::internal |
| 271 | 284 |
| 272 #endif // V8_IA32_LITHIUM_CODEGEN_IA32_H_ | 285 #endif // V8_IA32_LITHIUM_CODEGEN_IA32_H_ |
| OLD | NEW |