| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 class LCodeGen BASE_EMBEDDED { | 46 class LCodeGen BASE_EMBEDDED { |
| 47 public: | 47 public: |
| 48 LCodeGen(LChunk* chunk, MacroAssembler* assembler, CompilationInfo* info) | 48 LCodeGen(LChunk* chunk, MacroAssembler* assembler, CompilationInfo* info) |
| 49 : chunk_(chunk), | 49 : chunk_(chunk), |
| 50 masm_(assembler), | 50 masm_(assembler), |
| 51 info_(info), | 51 info_(info), |
| 52 current_block_(-1), | 52 current_block_(-1), |
| 53 current_instruction_(-1), | 53 current_instruction_(-1), |
| 54 instructions_(chunk->instructions()), | 54 instructions_(chunk->instructions()), |
| 55 deoptimizations_(4), | 55 deoptimizations_(4), |
| 56 jump_table_(4), |
| 56 deoptimization_literals_(8), | 57 deoptimization_literals_(8), |
| 57 inlined_function_count_(0), | 58 inlined_function_count_(0), |
| 58 scope_(chunk->graph()->info()->scope()), | 59 scope_(chunk->graph()->info()->scope()), |
| 59 status_(UNUSED), | 60 status_(UNUSED), |
| 60 deferred_(8), | 61 deferred_(8), |
| 61 osr_pc_offset_(-1), | 62 osr_pc_offset_(-1), |
| 62 resolver_(this) { | 63 resolver_(this) { |
| 63 PopulateDeoptimizationLiteralsWithInlinedFunctions(); | 64 PopulateDeoptimizationLiteralsWithInlinedFunctions(); |
| 64 } | 65 } |
| 65 | 66 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 84 | 85 |
| 85 // Finish the code by setting stack height, safepoint, and bailout | 86 // Finish the code by setting stack height, safepoint, and bailout |
| 86 // information on it. | 87 // information on it. |
| 87 void FinishCode(Handle<Code> code); | 88 void FinishCode(Handle<Code> code); |
| 88 | 89 |
| 89 // Deferred code support. | 90 // Deferred code support. |
| 90 void DoDeferredNumberTagD(LNumberTagD* instr); | 91 void DoDeferredNumberTagD(LNumberTagD* instr); |
| 91 void DoDeferredTaggedToI(LTaggedToI* instr); | 92 void DoDeferredTaggedToI(LTaggedToI* instr); |
| 92 void DoDeferredMathAbsTaggedHeapNumber(LUnaryMathOperation* instr); | 93 void DoDeferredMathAbsTaggedHeapNumber(LUnaryMathOperation* instr); |
| 93 void DoDeferredStackCheck(LGoto* instr); | 94 void DoDeferredStackCheck(LGoto* instr); |
| 94 void DoDeferredLInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr, | 95 void DoDeferredStringCharCodeAt(LStringCharCodeAt* instr); |
| 95 Label* map_check); | 96 void DoDeferredLInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr); |
| 96 | 97 |
| 97 // Parallel move support. | 98 // Parallel move support. |
| 98 void DoParallelMove(LParallelMove* move); | 99 void DoParallelMove(LParallelMove* move); |
| 99 | 100 |
| 100 // Emit frame translation commands for an environment. | 101 // Emit frame translation commands for an environment. |
| 101 void WriteTranslation(LEnvironment* environment, Translation* translation); | 102 void WriteTranslation(LEnvironment* environment, Translation* translation); |
| 102 | 103 |
| 103 // Declare methods that deal with the individual node types. | 104 // Declare methods that deal with the individual node types. |
| 104 #define DECLARE_DO(type) void Do##type(L##type* node); | 105 #define DECLARE_DO(type) void Do##type(L##type* node); |
| 105 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_DO) | 106 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_DO) |
| 106 #undef DECLARE_DO | 107 #undef DECLARE_DO |
| 107 | 108 |
| 108 private: | 109 private: |
| 109 enum Status { | 110 enum Status { |
| 110 UNUSED, | 111 UNUSED, |
| 111 GENERATING, | 112 GENERATING, |
| 112 DONE, | 113 DONE, |
| 113 ABORTED | 114 ABORTED |
| 114 }; | 115 }; |
| 115 | 116 |
| 116 bool is_unused() const { return status_ == UNUSED; } | 117 bool is_unused() const { return status_ == UNUSED; } |
| 117 bool is_generating() const { return status_ == GENERATING; } | 118 bool is_generating() const { return status_ == GENERATING; } |
| 118 bool is_done() const { return status_ == DONE; } | 119 bool is_done() const { return status_ == DONE; } |
| 119 bool is_aborted() const { return status_ == ABORTED; } | 120 bool is_aborted() const { return status_ == ABORTED; } |
| 120 | 121 |
| 122 int strict_mode_flag() const { |
| 123 return info_->is_strict() ? kStrictMode : kNonStrictMode; |
| 124 } |
| 125 |
| 121 LChunk* chunk() const { return chunk_; } | 126 LChunk* chunk() const { return chunk_; } |
| 122 Scope* scope() const { return scope_; } | 127 Scope* scope() const { return scope_; } |
| 123 HGraph* graph() const { return chunk_->graph(); } | 128 HGraph* graph() const { return chunk_->graph(); } |
| 124 | 129 |
| 125 int GetNextEmittedBlock(int block); | 130 int GetNextEmittedBlock(int block); |
| 126 LInstruction* GetNextInstruction(); | 131 LInstruction* GetNextInstruction(); |
| 127 | 132 |
| 128 void EmitClassOfTest(Label* if_true, | 133 void EmitClassOfTest(Label* if_true, |
| 129 Label* if_false, | 134 Label* if_false, |
| 130 Handle<String> class_name, | 135 Handle<String> class_name, |
| 131 Register input, | 136 Register input, |
| 132 Register temporary); | 137 Register temporary); |
| 133 | 138 |
| 134 int StackSlotCount() const { return chunk()->spill_slot_count(); } | 139 int StackSlotCount() const { return chunk()->spill_slot_count(); } |
| 135 int ParameterCount() const { return scope()->num_parameters(); } | 140 int ParameterCount() const { return scope()->num_parameters(); } |
| 136 | 141 |
| 137 void Abort(const char* format, ...); | 142 void Abort(const char* format, ...); |
| 138 void Comment(const char* format, ...); | 143 void Comment(const char* format, ...); |
| 139 | 144 |
| 140 void AddDeferredCode(LDeferredCode* code) { deferred_.Add(code); } | 145 void AddDeferredCode(LDeferredCode* code) { deferred_.Add(code); } |
| 141 | 146 |
| 142 // Code generation passes. Returns true if code generation should | 147 // Code generation passes. Returns true if code generation should |
| 143 // continue. | 148 // continue. |
| 144 bool GeneratePrologue(); | 149 bool GeneratePrologue(); |
| 145 bool GenerateBody(); | 150 bool GenerateBody(); |
| 146 bool GenerateDeferredCode(); | 151 bool GenerateDeferredCode(); |
| 152 bool GenerateJumpTable(); |
| 147 bool GenerateSafepointTable(); | 153 bool GenerateSafepointTable(); |
| 148 | 154 |
| 149 void CallCode(Handle<Code> code, | 155 void CallCode(Handle<Code> code, |
| 150 RelocInfo::Mode mode, | 156 RelocInfo::Mode mode, |
| 151 LInstruction* instr); | 157 LInstruction* instr); |
| 152 void CallRuntime(const Runtime::Function* function, | 158 void CallRuntime(const Runtime::Function* function, |
| 153 int num_arguments, | 159 int num_arguments, |
| 154 LInstruction* instr); | 160 LInstruction* instr); |
| 155 void CallRuntime(Runtime::FunctionId id, | 161 void CallRuntime(Runtime::FunctionId id, |
| 156 int num_arguments, | 162 int num_arguments, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 176 bool is_tagged); | 182 bool is_tagged); |
| 177 void PopulateDeoptimizationData(Handle<Code> code); | 183 void PopulateDeoptimizationData(Handle<Code> code); |
| 178 int DefineDeoptimizationLiteral(Handle<Object> literal); | 184 int DefineDeoptimizationLiteral(Handle<Object> literal); |
| 179 | 185 |
| 180 void PopulateDeoptimizationLiteralsWithInlinedFunctions(); | 186 void PopulateDeoptimizationLiteralsWithInlinedFunctions(); |
| 181 | 187 |
| 182 Register ToRegister(int index) const; | 188 Register ToRegister(int index) const; |
| 183 XMMRegister ToDoubleRegister(int index) const; | 189 XMMRegister ToDoubleRegister(int index) const; |
| 184 | 190 |
| 185 // Specific math operations - used from DoUnaryMathOperation. | 191 // Specific math operations - used from DoUnaryMathOperation. |
| 192 void EmitIntegerMathAbs(LUnaryMathOperation* instr); |
| 186 void DoMathAbs(LUnaryMathOperation* instr); | 193 void DoMathAbs(LUnaryMathOperation* instr); |
| 187 void DoMathFloor(LUnaryMathOperation* instr); | 194 void DoMathFloor(LUnaryMathOperation* instr); |
| 188 void DoMathRound(LUnaryMathOperation* instr); | 195 void DoMathRound(LUnaryMathOperation* instr); |
| 189 void DoMathSqrt(LUnaryMathOperation* instr); | 196 void DoMathSqrt(LUnaryMathOperation* instr); |
| 190 void DoMathPowHalf(LUnaryMathOperation* instr); | 197 void DoMathPowHalf(LUnaryMathOperation* instr); |
| 191 void DoMathLog(LUnaryMathOperation* instr); | 198 void DoMathLog(LUnaryMathOperation* instr); |
| 192 void DoMathCos(LUnaryMathOperation* instr); | 199 void DoMathCos(LUnaryMathOperation* instr); |
| 193 void DoMathSin(LUnaryMathOperation* instr); | 200 void DoMathSin(LUnaryMathOperation* instr); |
| 194 | 201 |
| 195 // Support for recording safepoint and position information. | 202 // Support for recording safepoint and position information. |
| 196 void RecordSafepoint(LPointerMap* pointers, | 203 void RecordSafepoint(LPointerMap* pointers, |
| 197 Safepoint::Kind kind, | 204 Safepoint::Kind kind, |
| 198 int arguments, | 205 int arguments, |
| 199 int deoptimization_index); | 206 int deoptimization_index); |
| 200 void RecordSafepoint(LPointerMap* pointers, int deoptimization_index); | 207 void RecordSafepoint(LPointerMap* pointers, int deoptimization_index); |
| 208 void RecordSafepoint(int deoptimization_index); |
| 201 void RecordSafepointWithRegisters(LPointerMap* pointers, | 209 void RecordSafepointWithRegisters(LPointerMap* pointers, |
| 202 int arguments, | 210 int arguments, |
| 203 int deoptimization_index); | 211 int deoptimization_index); |
| 204 void RecordPosition(int position); | 212 void RecordPosition(int position); |
| 205 | 213 |
| 206 static Condition TokenToCondition(Token::Value op, bool is_unsigned); | 214 static Condition TokenToCondition(Token::Value op, bool is_unsigned); |
| 207 void EmitGoto(int block, LDeferredCode* deferred_stack_check = NULL); | 215 void EmitGoto(int block, LDeferredCode* deferred_stack_check = NULL); |
| 208 void EmitBranch(int left_block, int right_block, Condition cc); | 216 void EmitBranch(int left_block, int right_block, Condition cc); |
| 209 void EmitCmpI(LOperand* left, LOperand* right); | 217 void EmitCmpI(LOperand* left, LOperand* right); |
| 210 void EmitNumberUntagD(Register input, XMMRegister result, LEnvironment* env); | 218 void EmitNumberUntagD(Register input, XMMRegister result, LEnvironment* env); |
| 211 | 219 |
| 212 // Emits optimized code for typeof x == "y". Modifies input register. | 220 // Emits optimized code for typeof x == "y". Modifies input register. |
| 213 // Returns the condition on which a final split to | 221 // Returns the condition on which a final split to |
| 214 // true and false label should be made, to optimize fallthrough. | 222 // true and false label should be made, to optimize fallthrough. |
| 215 Condition EmitTypeofIs(Label* true_label, Label* false_label, | 223 Condition EmitTypeofIs(Label* true_label, Label* false_label, |
| 216 Register input, Handle<String> type_name); | 224 Register input, Handle<String> type_name); |
| 217 | 225 |
| 218 // Emits optimized code for %_IsObject(x). Preserves input register. | 226 // Emits optimized code for %_IsObject(x). Preserves input register. |
| 219 // Returns the condition on which a final split to | 227 // Returns the condition on which a final split to |
| 220 // true and false label should be made, to optimize fallthrough. | 228 // true and false label should be made, to optimize fallthrough. |
| 221 Condition EmitIsObject(Register input, | 229 Condition EmitIsObject(Register input, |
| 222 Label* is_not_object, | 230 Label* is_not_object, |
| 223 Label* is_object); | 231 Label* is_object); |
| 224 | 232 |
| 225 // Emits optimized code for %_IsConstructCall(). | 233 // Emits optimized code for %_IsConstructCall(). |
| 226 // Caller should branch on equal condition. | 234 // Caller should branch on equal condition. |
| 227 void EmitIsConstructCall(Register temp); | 235 void EmitIsConstructCall(Register temp); |
| 228 | 236 |
| 237 // Emits code for pushing a constant operand. |
| 238 void EmitPushConstantOperand(LOperand* operand); |
| 239 |
| 240 struct JumpTableEntry { |
| 241 inline JumpTableEntry(Address address) |
| 242 : label_(), |
| 243 address_(address) { } |
| 244 Label label_; |
| 245 Address address_; |
| 246 }; |
| 247 |
| 229 LChunk* const chunk_; | 248 LChunk* const chunk_; |
| 230 MacroAssembler* const masm_; | 249 MacroAssembler* const masm_; |
| 231 CompilationInfo* const info_; | 250 CompilationInfo* const info_; |
| 232 | 251 |
| 233 int current_block_; | 252 int current_block_; |
| 234 int current_instruction_; | 253 int current_instruction_; |
| 235 const ZoneList<LInstruction*>* instructions_; | 254 const ZoneList<LInstruction*>* instructions_; |
| 236 ZoneList<LEnvironment*> deoptimizations_; | 255 ZoneList<LEnvironment*> deoptimizations_; |
| 256 ZoneList<JumpTableEntry*> jump_table_; |
| 237 ZoneList<Handle<Object> > deoptimization_literals_; | 257 ZoneList<Handle<Object> > deoptimization_literals_; |
| 238 int inlined_function_count_; | 258 int inlined_function_count_; |
| 239 Scope* const scope_; | 259 Scope* const scope_; |
| 240 Status status_; | 260 Status status_; |
| 241 TranslationBuffer translations_; | 261 TranslationBuffer translations_; |
| 242 ZoneList<LDeferredCode*> deferred_; | 262 ZoneList<LDeferredCode*> deferred_; |
| 243 int osr_pc_offset_; | 263 int osr_pc_offset_; |
| 244 | 264 |
| 245 // Builder that keeps track of safepoints in the code. The table | 265 // Builder that keeps track of safepoints in the code. The table |
| 246 // itself is emitted at the end of the generated code. | 266 // itself is emitted at the end of the generated code. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 277 private: | 297 private: |
| 278 LCodeGen* codegen_; | 298 LCodeGen* codegen_; |
| 279 Label entry_; | 299 Label entry_; |
| 280 Label exit_; | 300 Label exit_; |
| 281 Label* external_exit_; | 301 Label* external_exit_; |
| 282 }; | 302 }; |
| 283 | 303 |
| 284 } } // namespace v8::internal | 304 } } // namespace v8::internal |
| 285 | 305 |
| 286 #endif // V8_X64_LITHIUM_CODEGEN_X64_H_ | 306 #endif // V8_X64_LITHIUM_CODEGEN_X64_H_ |
| OLD | NEW |