| 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 24 matching lines...) Expand all Loading... |
| 35 #include "scopes.h" | 35 #include "scopes.h" |
| 36 #include "v8utils.h" | 36 #include "v8utils.h" |
| 37 | 37 |
| 38 namespace v8 { | 38 namespace v8 { |
| 39 namespace internal { | 39 namespace internal { |
| 40 | 40 |
| 41 // Forward declarations. | 41 // Forward declarations. |
| 42 class LDeferredCode; | 42 class LDeferredCode; |
| 43 class SafepointGenerator; | 43 class SafepointGenerator; |
| 44 | 44 |
| 45 class LCodeGen BASE_EMBEDDED { | 45 class LCodeGen V8_FINAL BASE_EMBEDDED { |
| 46 public: | 46 public: |
| 47 LCodeGen(LChunk* chunk, MacroAssembler* assembler, CompilationInfo* info) | 47 LCodeGen(LChunk* chunk, MacroAssembler* assembler, CompilationInfo* info) |
| 48 : zone_(info->zone()), | 48 : zone_(info->zone()), |
| 49 chunk_(static_cast<LPlatformChunk*>(chunk)), | 49 chunk_(static_cast<LPlatformChunk*>(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, info->zone()), | 55 deoptimizations_(4, info->zone()), |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 CallKind call_kind, | 270 CallKind call_kind, |
| 271 A1State a1_state); | 271 A1State a1_state); |
| 272 | 272 |
| 273 void LoadHeapObject(Register result, Handle<HeapObject> object); | 273 void LoadHeapObject(Register result, Handle<HeapObject> object); |
| 274 | 274 |
| 275 void RecordSafepointWithLazyDeopt(LInstruction* instr, | 275 void RecordSafepointWithLazyDeopt(LInstruction* instr, |
| 276 SafepointMode safepoint_mode); | 276 SafepointMode safepoint_mode); |
| 277 | 277 |
| 278 void RegisterEnvironmentForDeoptimization(LEnvironment* environment, | 278 void RegisterEnvironmentForDeoptimization(LEnvironment* environment, |
| 279 Safepoint::DeoptMode mode); | 279 Safepoint::DeoptMode mode); |
| 280 void DeoptimizeIf(Condition cc, | 280 void DeoptimizeIf(Condition condition, |
| 281 LEnvironment* environment, | 281 LEnvironment* environment, |
| 282 Deoptimizer::BailoutType bailout_type, | 282 Deoptimizer::BailoutType bailout_type, |
| 283 Register src1 = zero_reg, | 283 Register src1 = zero_reg, |
| 284 const Operand& src2 = Operand(zero_reg)); | 284 const Operand& src2 = Operand(zero_reg)); |
| 285 void DeoptimizeIf(Condition cc, | 285 void DeoptimizeIf(Condition condition, |
| 286 LEnvironment* environment, | 286 LEnvironment* environment, |
| 287 Register src1 = zero_reg, | 287 Register src1 = zero_reg, |
| 288 const Operand& src2 = Operand(zero_reg)); | 288 const Operand& src2 = Operand(zero_reg)); |
| 289 void ApplyCheckIf(Condition cc, | 289 void ApplyCheckIf(Condition condition, |
| 290 LBoundsCheck* check, | 290 LBoundsCheck* check, |
| 291 Register src1 = zero_reg, | 291 Register src1 = zero_reg, |
| 292 const Operand& src2 = Operand(zero_reg)); | 292 const Operand& src2 = Operand(zero_reg)); |
| 293 | 293 |
| 294 void AddToTranslation(LEnvironment* environment, | 294 void AddToTranslation(LEnvironment* environment, |
| 295 Translation* translation, | 295 Translation* translation, |
| 296 LOperand* op, | 296 LOperand* op, |
| 297 bool is_tagged, | 297 bool is_tagged, |
| 298 bool is_uint32, | 298 bool is_uint32, |
| 299 int* object_index_pointer, | 299 int* object_index_pointer, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 322 void RecordSafepointWithRegistersAndDoubles(LPointerMap* pointers, | 322 void RecordSafepointWithRegistersAndDoubles(LPointerMap* pointers, |
| 323 int arguments, | 323 int arguments, |
| 324 Safepoint::DeoptMode mode); | 324 Safepoint::DeoptMode mode); |
| 325 void RecordPosition(int position); | 325 void RecordPosition(int position); |
| 326 void RecordAndUpdatePosition(int position); | 326 void RecordAndUpdatePosition(int position); |
| 327 | 327 |
| 328 static Condition TokenToCondition(Token::Value op, bool is_unsigned); | 328 static Condition TokenToCondition(Token::Value op, bool is_unsigned); |
| 329 void EmitGoto(int block); | 329 void EmitGoto(int block); |
| 330 template<class InstrType> | 330 template<class InstrType> |
| 331 void EmitBranch(InstrType instr, | 331 void EmitBranch(InstrType instr, |
| 332 Condition cc, | 332 Condition condition, |
| 333 Register src1, | 333 Register src1, |
| 334 const Operand& src2); | 334 const Operand& src2); |
| 335 template<class InstrType> | 335 template<class InstrType> |
| 336 void EmitBranchF(InstrType instr, | 336 void EmitBranchF(InstrType instr, |
| 337 Condition cc, | 337 Condition condition, |
| 338 FPURegister src1, | 338 FPURegister src1, |
| 339 FPURegister src2); | 339 FPURegister src2); |
| 340 template<class InstrType> |
| 341 void EmitFalseBranchF(InstrType instr, |
| 342 Condition condition, |
| 343 FPURegister src1, |
| 344 FPURegister src2); |
| 340 void EmitCmpI(LOperand* left, LOperand* right); | 345 void EmitCmpI(LOperand* left, LOperand* right); |
| 341 void EmitNumberUntagD(Register input, | 346 void EmitNumberUntagD(Register input, |
| 342 DoubleRegister result, | 347 DoubleRegister result, |
| 343 bool allow_undefined_as_nan, | 348 bool allow_undefined_as_nan, |
| 344 bool deoptimize_on_minus_zero, | 349 bool deoptimize_on_minus_zero, |
| 345 LEnvironment* env, | 350 LEnvironment* env, |
| 346 NumberUntagDMode mode); | 351 NumberUntagDMode mode); |
| 347 | 352 |
| 348 // Emits optimized code for typeof x == "y". Modifies input register. | 353 // Emits optimized code for typeof x == "y". Modifies input register. |
| 349 // Returns the condition on which a final split to | 354 // Returns the condition on which a final split to |
| (...skipping 21 matching lines...) Expand all Loading... |
| 371 // true and false label should be made, to optimize fallthrough. | 376 // true and false label should be made, to optimize fallthrough. |
| 372 Condition EmitIsString(Register input, | 377 Condition EmitIsString(Register input, |
| 373 Register temp1, | 378 Register temp1, |
| 374 Label* is_not_string, | 379 Label* is_not_string, |
| 375 SmiCheck check_needed); | 380 SmiCheck check_needed); |
| 376 | 381 |
| 377 // Emits optimized code for %_IsConstructCall(). | 382 // Emits optimized code for %_IsConstructCall(). |
| 378 // Caller should branch on equal condition. | 383 // Caller should branch on equal condition. |
| 379 void EmitIsConstructCall(Register temp1, Register temp2); | 384 void EmitIsConstructCall(Register temp1, Register temp2); |
| 380 | 385 |
| 381 void EmitLoadFieldOrConstantFunction(Register result, | |
| 382 Register object, | |
| 383 Handle<Map> type, | |
| 384 Handle<String> name, | |
| 385 LEnvironment* env); | |
| 386 | |
| 387 // Emits optimized code to deep-copy the contents of statically known | 386 // Emits optimized code to deep-copy the contents of statically known |
| 388 // object graphs (e.g. object literal boilerplate). | 387 // object graphs (e.g. object literal boilerplate). |
| 389 void EmitDeepCopy(Handle<JSObject> object, | 388 void EmitDeepCopy(Handle<JSObject> object, |
| 390 Register result, | 389 Register result, |
| 391 Register source, | 390 Register source, |
| 392 int* offset, | 391 int* offset, |
| 393 AllocationSiteMode mode); | 392 AllocationSiteMode mode); |
| 394 // Emit optimized code for integer division. | 393 // Emit optimized code for integer division. |
| 395 // Inputs are signed. | 394 // Inputs are signed. |
| 396 // All registers are clobbered. | 395 // All registers are clobbered. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 // itself is emitted at the end of the generated code. | 434 // itself is emitted at the end of the generated code. |
| 436 SafepointTableBuilder safepoints_; | 435 SafepointTableBuilder safepoints_; |
| 437 | 436 |
| 438 // Compiler from a set of parallel moves to a sequential list of moves. | 437 // Compiler from a set of parallel moves to a sequential list of moves. |
| 439 LGapResolver resolver_; | 438 LGapResolver resolver_; |
| 440 | 439 |
| 441 Safepoint::Kind expected_safepoint_kind_; | 440 Safepoint::Kind expected_safepoint_kind_; |
| 442 | 441 |
| 443 int old_position_; | 442 int old_position_; |
| 444 | 443 |
| 445 class PushSafepointRegistersScope BASE_EMBEDDED { | 444 class PushSafepointRegistersScope V8_FINAL BASE_EMBEDDED { |
| 446 public: | 445 public: |
| 447 PushSafepointRegistersScope(LCodeGen* codegen, | 446 PushSafepointRegistersScope(LCodeGen* codegen, |
| 448 Safepoint::Kind kind) | 447 Safepoint::Kind kind) |
| 449 : codegen_(codegen) { | 448 : codegen_(codegen) { |
| 450 ASSERT(codegen_->info()->is_calling()); | 449 ASSERT(codegen_->info()->is_calling()); |
| 451 ASSERT(codegen_->expected_safepoint_kind_ == Safepoint::kSimple); | 450 ASSERT(codegen_->expected_safepoint_kind_ == Safepoint::kSimple); |
| 452 codegen_->expected_safepoint_kind_ = kind; | 451 codegen_->expected_safepoint_kind_ = kind; |
| 453 | 452 |
| 454 switch (codegen_->expected_safepoint_kind_) { | 453 switch (codegen_->expected_safepoint_kind_) { |
| 455 case Safepoint::kWithRegisters: | 454 case Safepoint::kWithRegisters: |
| (...skipping 27 matching lines...) Expand all Loading... |
| 483 LCodeGen* codegen_; | 482 LCodeGen* codegen_; |
| 484 }; | 483 }; |
| 485 | 484 |
| 486 friend class LDeferredCode; | 485 friend class LDeferredCode; |
| 487 friend class LEnvironment; | 486 friend class LEnvironment; |
| 488 friend class SafepointGenerator; | 487 friend class SafepointGenerator; |
| 489 DISALLOW_COPY_AND_ASSIGN(LCodeGen); | 488 DISALLOW_COPY_AND_ASSIGN(LCodeGen); |
| 490 }; | 489 }; |
| 491 | 490 |
| 492 | 491 |
| 493 class LDeferredCode: public ZoneObject { | 492 class LDeferredCode : public ZoneObject { |
| 494 public: | 493 public: |
| 495 explicit LDeferredCode(LCodeGen* codegen) | 494 explicit LDeferredCode(LCodeGen* codegen) |
| 496 : codegen_(codegen), | 495 : codegen_(codegen), |
| 497 external_exit_(NULL), | 496 external_exit_(NULL), |
| 498 instruction_index_(codegen->current_instruction_) { | 497 instruction_index_(codegen->current_instruction_) { |
| 499 codegen->AddDeferredCode(this); | 498 codegen->AddDeferredCode(this); |
| 500 } | 499 } |
| 501 | 500 |
| 502 virtual ~LDeferredCode() { } | 501 virtual ~LDeferredCode() {} |
| 503 virtual void Generate() = 0; | 502 virtual void Generate() = 0; |
| 504 virtual LInstruction* instr() = 0; | 503 virtual LInstruction* instr() = 0; |
| 505 | 504 |
| 506 void SetExit(Label* exit) { external_exit_ = exit; } | 505 void SetExit(Label* exit) { external_exit_ = exit; } |
| 507 Label* entry() { return &entry_; } | 506 Label* entry() { return &entry_; } |
| 508 Label* exit() { return external_exit_ != NULL ? external_exit_ : &exit_; } | 507 Label* exit() { return external_exit_ != NULL ? external_exit_ : &exit_; } |
| 509 int instruction_index() const { return instruction_index_; } | 508 int instruction_index() const { return instruction_index_; } |
| 510 | 509 |
| 511 protected: | 510 protected: |
| 512 LCodeGen* codegen() const { return codegen_; } | 511 LCodeGen* codegen() const { return codegen_; } |
| 513 MacroAssembler* masm() const { return codegen_->masm(); } | 512 MacroAssembler* masm() const { return codegen_->masm(); } |
| 514 | 513 |
| 515 private: | 514 private: |
| 516 LCodeGen* codegen_; | 515 LCodeGen* codegen_; |
| 517 Label entry_; | 516 Label entry_; |
| 518 Label exit_; | 517 Label exit_; |
| 519 Label* external_exit_; | 518 Label* external_exit_; |
| 520 int instruction_index_; | 519 int instruction_index_; |
| 521 }; | 520 }; |
| 522 | 521 |
| 523 } } // namespace v8::internal | 522 } } // namespace v8::internal |
| 524 | 523 |
| 525 #endif // V8_MIPS_LITHIUM_CODEGEN_MIPS_H_ | 524 #endif // V8_MIPS_LITHIUM_CODEGEN_MIPS_H_ |
| OLD | NEW |