| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 14 matching lines...) Expand all Loading... |
| 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 |
| 33 #include "arm/lithium-gap-resolver-arm.h" | 33 #include "arm/lithium-gap-resolver-arm.h" |
| 34 #include "deoptimizer.h" | 34 #include "deoptimizer.h" |
| 35 #include "lithium-codegen.h" |
| 35 #include "safepoint-table.h" | 36 #include "safepoint-table.h" |
| 36 #include "scopes.h" | 37 #include "scopes.h" |
| 37 #include "v8utils.h" | 38 #include "v8utils.h" |
| 38 | 39 |
| 39 namespace v8 { | 40 namespace v8 { |
| 40 namespace internal { | 41 namespace internal { |
| 41 | 42 |
| 42 // Forward declarations. | 43 // Forward declarations. |
| 43 class LDeferredCode; | 44 class LDeferredCode; |
| 44 class SafepointGenerator; | 45 class SafepointGenerator; |
| 45 | 46 |
| 46 class LCodeGen V8_FINAL BASE_EMBEDDED { | 47 class LCodeGen: public LCodeGenBase { |
| 47 public: | 48 public: |
| 48 LCodeGen(LChunk* chunk, MacroAssembler* assembler, CompilationInfo* info) | 49 LCodeGen(LChunk* chunk, MacroAssembler* assembler, CompilationInfo* info) |
| 49 : zone_(info->zone()), | 50 : LCodeGenBase(chunk, assembler, info), |
| 50 chunk_(static_cast<LPlatformChunk*>(chunk)), | |
| 51 masm_(assembler), | |
| 52 info_(info), | |
| 53 current_block_(-1), | |
| 54 current_instruction_(-1), | |
| 55 instructions_(chunk->instructions()), | |
| 56 deoptimizations_(4, info->zone()), | 51 deoptimizations_(4, info->zone()), |
| 57 deopt_jump_table_(4, info->zone()), | 52 deopt_jump_table_(4, info->zone()), |
| 58 deoptimization_literals_(8, info->zone()), | 53 deoptimization_literals_(8, info->zone()), |
| 59 inlined_function_count_(0), | 54 inlined_function_count_(0), |
| 60 scope_(info->scope()), | 55 scope_(info->scope()), |
| 61 status_(UNUSED), | |
| 62 translations_(info->zone()), | 56 translations_(info->zone()), |
| 63 deferred_(8, info->zone()), | 57 deferred_(8, info->zone()), |
| 64 osr_pc_offset_(-1), | 58 osr_pc_offset_(-1), |
| 65 last_lazy_deopt_pc_(0), | |
| 66 frame_is_built_(false), | 59 frame_is_built_(false), |
| 67 safepoints_(info->zone()), | 60 safepoints_(info->zone()), |
| 68 resolver_(this), | 61 resolver_(this), |
| 69 expected_safepoint_kind_(Safepoint::kSimple), | 62 expected_safepoint_kind_(Safepoint::kSimple), |
| 70 old_position_(RelocInfo::kNoPosition) { | 63 old_position_(RelocInfo::kNoPosition) { |
| 71 PopulateDeoptimizationLiteralsWithInlinedFunctions(); | 64 PopulateDeoptimizationLiteralsWithInlinedFunctions(); |
| 72 } | 65 } |
| 73 | 66 |
| 74 | 67 |
| 75 // Simple accessors. | |
| 76 MacroAssembler* masm() const { return masm_; } | |
| 77 CompilationInfo* info() const { return info_; } | |
| 78 Isolate* isolate() const { return info_->isolate(); } | |
| 79 Factory* factory() const { return isolate()->factory(); } | |
| 80 Heap* heap() const { return isolate()->heap(); } | |
| 81 Zone* zone() const { return zone_; } | |
| 82 | |
| 83 int LookupDestination(int block_id) const { | 68 int LookupDestination(int block_id) const { |
| 84 return chunk()->LookupDestination(block_id); | 69 return chunk()->LookupDestination(block_id); |
| 85 } | 70 } |
| 86 | 71 |
| 87 bool IsNextEmittedBlock(int block_id) const { | 72 bool IsNextEmittedBlock(int block_id) const { |
| 88 return LookupDestination(block_id) == GetNextEmittedBlock(); | 73 return LookupDestination(block_id) == GetNextEmittedBlock(); |
| 89 } | 74 } |
| 90 | 75 |
| 91 bool NeedsEagerFrame() const { | 76 bool NeedsEagerFrame() const { |
| 92 return GetStackSlotCount() > 0 || | 77 return GetStackSlotCount() > 0 || |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 | 156 |
| 172 // Emit frame translation commands for an environment. | 157 // Emit frame translation commands for an environment. |
| 173 void WriteTranslation(LEnvironment* environment, Translation* translation); | 158 void WriteTranslation(LEnvironment* environment, Translation* translation); |
| 174 | 159 |
| 175 // Declare methods that deal with the individual node types. | 160 // Declare methods that deal with the individual node types. |
| 176 #define DECLARE_DO(type) void Do##type(L##type* node); | 161 #define DECLARE_DO(type) void Do##type(L##type* node); |
| 177 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_DO) | 162 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_DO) |
| 178 #undef DECLARE_DO | 163 #undef DECLARE_DO |
| 179 | 164 |
| 180 private: | 165 private: |
| 181 enum Status { | |
| 182 UNUSED, | |
| 183 GENERATING, | |
| 184 DONE, | |
| 185 ABORTED | |
| 186 }; | |
| 187 | |
| 188 bool is_unused() const { return status_ == UNUSED; } | |
| 189 bool is_generating() const { return status_ == GENERATING; } | |
| 190 bool is_done() const { return status_ == DONE; } | |
| 191 bool is_aborted() const { return status_ == ABORTED; } | |
| 192 | |
| 193 StrictModeFlag strict_mode_flag() const { | 166 StrictModeFlag strict_mode_flag() const { |
| 194 return info()->is_classic_mode() ? kNonStrictMode : kStrictMode; | 167 return info()->is_classic_mode() ? kNonStrictMode : kStrictMode; |
| 195 } | 168 } |
| 196 | 169 |
| 197 LPlatformChunk* chunk() const { return chunk_; } | |
| 198 Scope* scope() const { return scope_; } | 170 Scope* scope() const { return scope_; } |
| 199 HGraph* graph() const { return chunk()->graph(); } | |
| 200 | 171 |
| 201 Register scratch0() { return r9; } | 172 Register scratch0() { return r9; } |
| 202 LowDwVfpRegister double_scratch0() { return kScratchDoubleReg; } | 173 LowDwVfpRegister double_scratch0() { return kScratchDoubleReg; } |
| 203 | 174 |
| 204 int GetNextEmittedBlock() const; | |
| 205 LInstruction* GetNextInstruction(); | 175 LInstruction* GetNextInstruction(); |
| 206 | 176 |
| 207 void EmitClassOfTest(Label* if_true, | 177 void EmitClassOfTest(Label* if_true, |
| 208 Label* if_false, | 178 Label* if_false, |
| 209 Handle<String> class_name, | 179 Handle<String> class_name, |
| 210 Register input, | 180 Register input, |
| 211 Register temporary, | 181 Register temporary, |
| 212 Register temporary2); | 182 Register temporary2); |
| 213 | 183 |
| 214 int GetStackSlotCount() const { return chunk()->spill_slot_count(); } | 184 int GetStackSlotCount() const { return chunk()->spill_slot_count(); } |
| 215 | 185 |
| 216 void Abort(BailoutReason reason); | 186 void Abort(BailoutReason reason); |
| 217 void FPRINTF_CHECKING Comment(const char* format, ...); | |
| 218 | 187 |
| 219 void AddDeferredCode(LDeferredCode* code) { deferred_.Add(code, zone()); } | 188 void AddDeferredCode(LDeferredCode* code) { deferred_.Add(code, zone()); } |
| 220 | 189 |
| 221 // Code generation passes. Returns true if code generation should | 190 // Code generation passes. Returns true if code generation should |
| 222 // continue. | 191 // continue. |
| 223 bool GeneratePrologue(); | 192 bool GeneratePrologue(); |
| 224 bool GenerateBody(); | |
| 225 bool GenerateDeferredCode(); | 193 bool GenerateDeferredCode(); |
| 226 bool GenerateDeoptJumpTable(); | 194 bool GenerateDeoptJumpTable(); |
| 227 bool GenerateSafepointTable(); | 195 bool GenerateSafepointTable(); |
| 228 | 196 |
| 229 // Generates the custom OSR entrypoint and sets the osr_pc_offset. | 197 // Generates the custom OSR entrypoint and sets the osr_pc_offset. |
| 230 void GenerateOsrPrologue(); | 198 void GenerateOsrPrologue(); |
| 231 | 199 |
| 232 enum SafepointMode { | 200 enum SafepointMode { |
| 233 RECORD_SIMPLE_SAFEPOINT, | 201 RECORD_SIMPLE_SAFEPOINT, |
| 234 RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS | 202 RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 Safepoint::DeoptMode mode); | 284 Safepoint::DeoptMode mode); |
| 317 void RecordSafepoint(LPointerMap* pointers, Safepoint::DeoptMode mode); | 285 void RecordSafepoint(LPointerMap* pointers, Safepoint::DeoptMode mode); |
| 318 void RecordSafepoint(Safepoint::DeoptMode mode); | 286 void RecordSafepoint(Safepoint::DeoptMode mode); |
| 319 void RecordSafepointWithRegisters(LPointerMap* pointers, | 287 void RecordSafepointWithRegisters(LPointerMap* pointers, |
| 320 int arguments, | 288 int arguments, |
| 321 Safepoint::DeoptMode mode); | 289 Safepoint::DeoptMode mode); |
| 322 void RecordSafepointWithRegistersAndDoubles(LPointerMap* pointers, | 290 void RecordSafepointWithRegistersAndDoubles(LPointerMap* pointers, |
| 323 int arguments, | 291 int arguments, |
| 324 Safepoint::DeoptMode mode); | 292 Safepoint::DeoptMode mode); |
| 325 void RecordPosition(int position); | 293 void RecordPosition(int position); |
| 326 void RecordAndUpdatePosition(int position); | 294 void RecordAndUpdatePosition(int position) V8_OVERRIDE; |
| 327 | 295 |
| 328 static Condition TokenToCondition(Token::Value op, bool is_unsigned); | 296 static Condition TokenToCondition(Token::Value op, bool is_unsigned); |
| 329 void EmitGoto(int block); | 297 void EmitGoto(int block); |
| 330 template<class InstrType> | 298 template<class InstrType> |
| 331 void EmitBranch(InstrType instr, Condition condition); | 299 void EmitBranch(InstrType instr, Condition condition); |
| 332 template<class InstrType> | 300 template<class InstrType> |
| 333 void EmitFalseBranch(InstrType instr, Condition condition); | 301 void EmitFalseBranch(InstrType instr, Condition condition); |
| 334 void EmitNumberUntagD(Register input, | 302 void EmitNumberUntagD(Register input, |
| 335 DwVfpRegister result, | 303 DwVfpRegister result, |
| 336 bool allow_undefined_as_nan, | 304 bool allow_undefined_as_nan, |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 // Inputs are signed. | 346 // Inputs are signed. |
| 379 // All registers are clobbered. | 347 // All registers are clobbered. |
| 380 // If 'remainder' is no_reg, it is not computed. | 348 // If 'remainder' is no_reg, it is not computed. |
| 381 void EmitSignedIntegerDivisionByConstant(Register result, | 349 void EmitSignedIntegerDivisionByConstant(Register result, |
| 382 Register dividend, | 350 Register dividend, |
| 383 int32_t divisor, | 351 int32_t divisor, |
| 384 Register remainder, | 352 Register remainder, |
| 385 Register scratch, | 353 Register scratch, |
| 386 LEnvironment* environment); | 354 LEnvironment* environment); |
| 387 | 355 |
| 388 void EnsureSpaceForLazyDeopt(); | 356 void EnsureSpaceForLazyDeopt(int space_needed) V8_OVERRIDE; |
| 389 void DoLoadKeyedExternalArray(LLoadKeyed* instr); | 357 void DoLoadKeyedExternalArray(LLoadKeyed* instr); |
| 390 void DoLoadKeyedFixedDoubleArray(LLoadKeyed* instr); | 358 void DoLoadKeyedFixedDoubleArray(LLoadKeyed* instr); |
| 391 void DoLoadKeyedFixedArray(LLoadKeyed* instr); | 359 void DoLoadKeyedFixedArray(LLoadKeyed* instr); |
| 392 void DoStoreKeyedExternalArray(LStoreKeyed* instr); | 360 void DoStoreKeyedExternalArray(LStoreKeyed* instr); |
| 393 void DoStoreKeyedFixedDoubleArray(LStoreKeyed* instr); | 361 void DoStoreKeyedFixedDoubleArray(LStoreKeyed* instr); |
| 394 void DoStoreKeyedFixedArray(LStoreKeyed* instr); | 362 void DoStoreKeyedFixedArray(LStoreKeyed* instr); |
| 395 | 363 |
| 396 Zone* zone_; | |
| 397 LPlatformChunk* const chunk_; | |
| 398 MacroAssembler* const masm_; | |
| 399 CompilationInfo* const info_; | |
| 400 | |
| 401 int current_block_; | |
| 402 int current_instruction_; | |
| 403 const ZoneList<LInstruction*>* instructions_; | |
| 404 ZoneList<LEnvironment*> deoptimizations_; | 364 ZoneList<LEnvironment*> deoptimizations_; |
| 405 ZoneList<Deoptimizer::JumpTableEntry> deopt_jump_table_; | 365 ZoneList<Deoptimizer::JumpTableEntry> deopt_jump_table_; |
| 406 ZoneList<Handle<Object> > deoptimization_literals_; | 366 ZoneList<Handle<Object> > deoptimization_literals_; |
| 407 int inlined_function_count_; | 367 int inlined_function_count_; |
| 408 Scope* const scope_; | 368 Scope* const scope_; |
| 409 Status status_; | |
| 410 TranslationBuffer translations_; | 369 TranslationBuffer translations_; |
| 411 ZoneList<LDeferredCode*> deferred_; | 370 ZoneList<LDeferredCode*> deferred_; |
| 412 int osr_pc_offset_; | 371 int osr_pc_offset_; |
| 413 int last_lazy_deopt_pc_; | |
| 414 bool frame_is_built_; | 372 bool frame_is_built_; |
| 415 | 373 |
| 416 // Builder that keeps track of safepoints in the code. The table | 374 // Builder that keeps track of safepoints in the code. The table |
| 417 // itself is emitted at the end of the generated code. | 375 // itself is emitted at the end of the generated code. |
| 418 SafepointTableBuilder safepoints_; | 376 SafepointTableBuilder safepoints_; |
| 419 | 377 |
| 420 // Compiler from a set of parallel moves to a sequential list of moves. | 378 // Compiler from a set of parallel moves to a sequential list of moves. |
| 421 LGapResolver resolver_; | 379 LGapResolver resolver_; |
| 422 | 380 |
| 423 Safepoint::Kind expected_safepoint_kind_; | 381 Safepoint::Kind expected_safepoint_kind_; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 LCodeGen* codegen_; | 456 LCodeGen* codegen_; |
| 499 Label entry_; | 457 Label entry_; |
| 500 Label exit_; | 458 Label exit_; |
| 501 Label* external_exit_; | 459 Label* external_exit_; |
| 502 int instruction_index_; | 460 int instruction_index_; |
| 503 }; | 461 }; |
| 504 | 462 |
| 505 } } // namespace v8::internal | 463 } } // namespace v8::internal |
| 506 | 464 |
| 507 #endif // V8_ARM_LITHIUM_CODEGEN_ARM_H_ | 465 #endif // V8_ARM_LITHIUM_CODEGEN_ARM_H_ |
| OLD | NEW |