OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "v8.h" | 5 #include "v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_IA32 | 7 #if V8_TARGET_ARCH_IA32 |
8 | 8 |
9 #include "ia32/lithium-codegen-ia32.h" | 9 #include "ia32/lithium-codegen-ia32.h" |
10 #include "ic.h" | 10 #include "ic.h" |
(...skipping 4429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4440 LOperand* output = instr->result(); | 4440 LOperand* output = instr->result(); |
4441 ASSERT(input->IsRegister() || input->IsStackSlot()); | 4441 ASSERT(input->IsRegister() || input->IsStackSlot()); |
4442 ASSERT(output->IsDoubleRegister()); | 4442 ASSERT(output->IsDoubleRegister()); |
4443 __ Cvtsi2sd(ToDoubleRegister(output), ToOperand(input)); | 4443 __ Cvtsi2sd(ToDoubleRegister(output), ToOperand(input)); |
4444 } | 4444 } |
4445 | 4445 |
4446 | 4446 |
4447 void LCodeGen::DoUint32ToDouble(LUint32ToDouble* instr) { | 4447 void LCodeGen::DoUint32ToDouble(LUint32ToDouble* instr) { |
4448 LOperand* input = instr->value(); | 4448 LOperand* input = instr->value(); |
4449 LOperand* output = instr->result(); | 4449 LOperand* output = instr->result(); |
4450 LOperand* temp = instr->temp(); | 4450 __ LoadUint32(ToDoubleRegister(output), ToRegister(input)); |
4451 __ LoadUint32(ToDoubleRegister(output), | |
4452 ToRegister(input), | |
4453 ToDoubleRegister(temp)); | |
4454 } | 4451 } |
4455 | 4452 |
4456 | 4453 |
4457 void LCodeGen::DoNumberTagI(LNumberTagI* instr) { | 4454 void LCodeGen::DoNumberTagI(LNumberTagI* instr) { |
4458 class DeferredNumberTagI V8_FINAL : public LDeferredCode { | 4455 class DeferredNumberTagI V8_FINAL : public LDeferredCode { |
4459 public: | 4456 public: |
4460 DeferredNumberTagI(LCodeGen* codegen, | 4457 DeferredNumberTagI(LCodeGen* codegen, |
4461 LNumberTagI* instr) | 4458 LNumberTagI* instr) |
4462 : LDeferredCode(codegen), instr_(instr) { } | 4459 : LDeferredCode(codegen), instr_(instr) { } |
4463 virtual void Generate() V8_OVERRIDE { | 4460 virtual void Generate() V8_OVERRIDE { |
4464 codegen()->DoDeferredNumberTagIU(instr_, instr_->value(), instr_->temp(), | 4461 codegen()->DoDeferredNumberTagIU( |
4465 NULL, SIGNED_INT32); | 4462 instr_, instr_->value(), instr_->temp(), SIGNED_INT32); |
4466 } | 4463 } |
4467 virtual LInstruction* instr() V8_OVERRIDE { return instr_; } | 4464 virtual LInstruction* instr() V8_OVERRIDE { return instr_; } |
4468 private: | 4465 private: |
4469 LNumberTagI* instr_; | 4466 LNumberTagI* instr_; |
4470 }; | 4467 }; |
4471 | 4468 |
4472 LOperand* input = instr->value(); | 4469 LOperand* input = instr->value(); |
4473 ASSERT(input->IsRegister() && input->Equals(instr->result())); | 4470 ASSERT(input->IsRegister() && input->Equals(instr->result())); |
4474 Register reg = ToRegister(input); | 4471 Register reg = ToRegister(input); |
4475 | 4472 |
4476 DeferredNumberTagI* deferred = | 4473 DeferredNumberTagI* deferred = |
4477 new(zone()) DeferredNumberTagI(this, instr); | 4474 new(zone()) DeferredNumberTagI(this, instr); |
4478 __ SmiTag(reg); | 4475 __ SmiTag(reg); |
4479 __ j(overflow, deferred->entry()); | 4476 __ j(overflow, deferred->entry()); |
4480 __ bind(deferred->exit()); | 4477 __ bind(deferred->exit()); |
4481 } | 4478 } |
4482 | 4479 |
4483 | 4480 |
4484 void LCodeGen::DoNumberTagU(LNumberTagU* instr) { | 4481 void LCodeGen::DoNumberTagU(LNumberTagU* instr) { |
4485 class DeferredNumberTagU V8_FINAL : public LDeferredCode { | 4482 class DeferredNumberTagU V8_FINAL : public LDeferredCode { |
4486 public: | 4483 public: |
4487 DeferredNumberTagU(LCodeGen* codegen, LNumberTagU* instr) | 4484 DeferredNumberTagU(LCodeGen* codegen, LNumberTagU* instr) |
4488 : LDeferredCode(codegen), instr_(instr) { } | 4485 : LDeferredCode(codegen), instr_(instr) { } |
4489 virtual void Generate() V8_OVERRIDE { | 4486 virtual void Generate() V8_OVERRIDE { |
4490 codegen()->DoDeferredNumberTagIU(instr_, instr_->value(), instr_->temp1(), | 4487 codegen()->DoDeferredNumberTagIU( |
4491 instr_->temp2(), UNSIGNED_INT32); | 4488 instr_, instr_->value(), instr_->temp(), UNSIGNED_INT32); |
4492 } | 4489 } |
4493 virtual LInstruction* instr() V8_OVERRIDE { return instr_; } | 4490 virtual LInstruction* instr() V8_OVERRIDE { return instr_; } |
4494 private: | 4491 private: |
4495 LNumberTagU* instr_; | 4492 LNumberTagU* instr_; |
4496 }; | 4493 }; |
4497 | 4494 |
4498 LOperand* input = instr->value(); | 4495 LOperand* input = instr->value(); |
4499 ASSERT(input->IsRegister() && input->Equals(instr->result())); | 4496 ASSERT(input->IsRegister() && input->Equals(instr->result())); |
4500 Register reg = ToRegister(input); | 4497 Register reg = ToRegister(input); |
4501 | 4498 |
4502 DeferredNumberTagU* deferred = | 4499 DeferredNumberTagU* deferred = |
4503 new(zone()) DeferredNumberTagU(this, instr); | 4500 new(zone()) DeferredNumberTagU(this, instr); |
4504 __ cmp(reg, Immediate(Smi::kMaxValue)); | 4501 __ cmp(reg, Immediate(Smi::kMaxValue)); |
4505 __ j(above, deferred->entry()); | 4502 __ j(above, deferred->entry()); |
4506 __ SmiTag(reg); | 4503 __ SmiTag(reg); |
4507 __ bind(deferred->exit()); | 4504 __ bind(deferred->exit()); |
4508 } | 4505 } |
4509 | 4506 |
4510 | 4507 |
4511 void LCodeGen::DoDeferredNumberTagIU(LInstruction* instr, | 4508 void LCodeGen::DoDeferredNumberTagIU(LInstruction* instr, |
4512 LOperand* value, | 4509 LOperand* value, |
4513 LOperand* temp1, | 4510 LOperand* temp, |
4514 LOperand* temp2, | |
4515 IntegerSignedness signedness) { | 4511 IntegerSignedness signedness) { |
4516 Label done, slow; | 4512 Label done, slow; |
4517 Register reg = ToRegister(value); | 4513 Register reg = ToRegister(value); |
4518 Register tmp = ToRegister(temp1); | 4514 Register tmp = ToRegister(temp); |
4519 XMMRegister xmm_scratch = double_scratch0(); | 4515 XMMRegister xmm_scratch = double_scratch0(); |
4520 | 4516 |
4521 if (signedness == SIGNED_INT32) { | 4517 if (signedness == SIGNED_INT32) { |
4522 // There was overflow, so bits 30 and 31 of the original integer | 4518 // There was overflow, so bits 30 and 31 of the original integer |
4523 // disagree. Try to allocate a heap number in new space and store | 4519 // disagree. Try to allocate a heap number in new space and store |
4524 // the value in there. If that fails, call the runtime system. | 4520 // the value in there. If that fails, call the runtime system. |
4525 __ SmiUntag(reg); | 4521 __ SmiUntag(reg); |
4526 __ xor_(reg, 0x80000000); | 4522 __ xor_(reg, 0x80000000); |
4527 __ Cvtsi2sd(xmm_scratch, Operand(reg)); | 4523 __ Cvtsi2sd(xmm_scratch, Operand(reg)); |
4528 } else { | 4524 } else { |
4529 __ LoadUint32(xmm_scratch, reg, ToDoubleRegister(temp2)); | 4525 __ LoadUint32(xmm_scratch, reg); |
4530 } | 4526 } |
4531 | 4527 |
4532 if (FLAG_inline_new) { | 4528 if (FLAG_inline_new) { |
4533 __ AllocateHeapNumber(reg, tmp, no_reg, &slow); | 4529 __ AllocateHeapNumber(reg, tmp, no_reg, &slow); |
4534 __ jmp(&done, Label::kNear); | 4530 __ jmp(&done, Label::kNear); |
4535 } | 4531 } |
4536 | 4532 |
4537 // Slow case: Call the runtime system to do the number allocation. | 4533 // Slow case: Call the runtime system to do the number allocation. |
4538 __ bind(&slow); | 4534 __ bind(&slow); |
4539 { | 4535 { |
(...skipping 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5670 __ bind(deferred->exit()); | 5666 __ bind(deferred->exit()); |
5671 __ bind(&done); | 5667 __ bind(&done); |
5672 } | 5668 } |
5673 | 5669 |
5674 | 5670 |
5675 #undef __ | 5671 #undef __ |
5676 | 5672 |
5677 } } // namespace v8::internal | 5673 } } // namespace v8::internal |
5678 | 5674 |
5679 #endif // V8_TARGET_ARCH_IA32 | 5675 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |