| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved.7 | 1 // Copyright 2012 the V8 project authors. All rights reserved.7 |
| 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 4535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4546 __ SmiTag(ToRegister(output), ToRegister(input)); | 4546 __ SmiTag(ToRegister(output), ToRegister(input)); |
| 4547 } | 4547 } |
| 4548 | 4548 |
| 4549 | 4549 |
| 4550 void LCodeGen::DoNumberTagI(LNumberTagI* instr) { | 4550 void LCodeGen::DoNumberTagI(LNumberTagI* instr) { |
| 4551 class DeferredNumberTagI V8_FINAL : public LDeferredCode { | 4551 class DeferredNumberTagI V8_FINAL : public LDeferredCode { |
| 4552 public: | 4552 public: |
| 4553 DeferredNumberTagI(LCodeGen* codegen, LNumberTagI* instr) | 4553 DeferredNumberTagI(LCodeGen* codegen, LNumberTagI* instr) |
| 4554 : LDeferredCode(codegen), instr_(instr) { } | 4554 : LDeferredCode(codegen), instr_(instr) { } |
| 4555 virtual void Generate() V8_OVERRIDE { | 4555 virtual void Generate() V8_OVERRIDE { |
| 4556 codegen()->DoDeferredNumberTagI(instr_, | 4556 codegen()->DoDeferredNumberTagIU(instr_, |
| 4557 instr_->value(), | 4557 instr_->value(), |
| 4558 SIGNED_INT32); | 4558 instr_->temp1(), |
| 4559 instr_->temp2(), |
| 4560 SIGNED_INT32); |
| 4559 } | 4561 } |
| 4560 virtual LInstruction* instr() V8_OVERRIDE { return instr_; } | 4562 virtual LInstruction* instr() V8_OVERRIDE { return instr_; } |
| 4561 private: | 4563 private: |
| 4562 LNumberTagI* instr_; | 4564 LNumberTagI* instr_; |
| 4563 }; | 4565 }; |
| 4564 | 4566 |
| 4565 Register src = ToRegister(instr->value()); | 4567 Register src = ToRegister(instr->value()); |
| 4566 Register dst = ToRegister(instr->result()); | 4568 Register dst = ToRegister(instr->result()); |
| 4567 Register overflow = scratch0(); | 4569 Register overflow = scratch0(); |
| 4568 | 4570 |
| 4569 DeferredNumberTagI* deferred = new(zone()) DeferredNumberTagI(this, instr); | 4571 DeferredNumberTagI* deferred = new(zone()) DeferredNumberTagI(this, instr); |
| 4570 __ SmiTagCheckOverflow(dst, src, overflow); | 4572 __ SmiTagCheckOverflow(dst, src, overflow); |
| 4571 __ BranchOnOverflow(deferred->entry(), overflow); | 4573 __ BranchOnOverflow(deferred->entry(), overflow); |
| 4572 __ bind(deferred->exit()); | 4574 __ bind(deferred->exit()); |
| 4573 } | 4575 } |
| 4574 | 4576 |
| 4575 | 4577 |
| 4576 void LCodeGen::DoNumberTagU(LNumberTagU* instr) { | 4578 void LCodeGen::DoNumberTagU(LNumberTagU* instr) { |
| 4577 class DeferredNumberTagU V8_FINAL : public LDeferredCode { | 4579 class DeferredNumberTagU V8_FINAL : public LDeferredCode { |
| 4578 public: | 4580 public: |
| 4579 DeferredNumberTagU(LCodeGen* codegen, LNumberTagU* instr) | 4581 DeferredNumberTagU(LCodeGen* codegen, LNumberTagU* instr) |
| 4580 : LDeferredCode(codegen), instr_(instr) { } | 4582 : LDeferredCode(codegen), instr_(instr) { } |
| 4581 virtual void Generate() V8_OVERRIDE { | 4583 virtual void Generate() V8_OVERRIDE { |
| 4582 codegen()->DoDeferredNumberTagI(instr_, | 4584 codegen()->DoDeferredNumberTagIU(instr_, |
| 4583 instr_->value(), | 4585 instr_->value(), |
| 4584 UNSIGNED_INT32); | 4586 instr_->temp1(), |
| 4587 instr_->temp2(), |
| 4588 UNSIGNED_INT32); |
| 4585 } | 4589 } |
| 4586 virtual LInstruction* instr() V8_OVERRIDE { return instr_; } | 4590 virtual LInstruction* instr() V8_OVERRIDE { return instr_; } |
| 4587 private: | 4591 private: |
| 4588 LNumberTagU* instr_; | 4592 LNumberTagU* instr_; |
| 4589 }; | 4593 }; |
| 4590 | 4594 |
| 4591 Register input = ToRegister(instr->value()); | 4595 Register input = ToRegister(instr->value()); |
| 4592 Register result = ToRegister(instr->result()); | 4596 Register result = ToRegister(instr->result()); |
| 4593 | 4597 |
| 4594 DeferredNumberTagU* deferred = new(zone()) DeferredNumberTagU(this, instr); | 4598 DeferredNumberTagU* deferred = new(zone()) DeferredNumberTagU(this, instr); |
| 4595 __ Branch(deferred->entry(), hi, input, Operand(Smi::kMaxValue)); | 4599 __ Branch(deferred->entry(), hi, input, Operand(Smi::kMaxValue)); |
| 4596 __ SmiTag(result, input); | 4600 __ SmiTag(result, input); |
| 4597 __ bind(deferred->exit()); | 4601 __ bind(deferred->exit()); |
| 4598 } | 4602 } |
| 4599 | 4603 |
| 4600 | 4604 |
| 4601 void LCodeGen::DoDeferredNumberTagI(LInstruction* instr, | 4605 void LCodeGen::DoDeferredNumberTagIU(LInstruction* instr, |
| 4602 LOperand* value, | 4606 LOperand* value, |
| 4603 IntegerSignedness signedness) { | 4607 LOperand* temp1, |
| 4604 Label slow; | 4608 LOperand* temp2, |
| 4609 IntegerSignedness signedness) { |
| 4610 Label done, slow; |
| 4605 Register src = ToRegister(value); | 4611 Register src = ToRegister(value); |
| 4606 Register dst = ToRegister(instr->result()); | 4612 Register dst = ToRegister(instr->result()); |
| 4613 Register tmp1 = scratch0(); |
| 4614 Register tmp2 = ToRegister(temp1); |
| 4615 Register tmp3 = ToRegister(temp2); |
| 4607 DoubleRegister dbl_scratch = double_scratch0(); | 4616 DoubleRegister dbl_scratch = double_scratch0(); |
| 4608 | 4617 |
| 4609 // Preserve the value of all registers. | |
| 4610 PushSafepointRegistersScope scope(this, Safepoint::kWithRegisters); | |
| 4611 | |
| 4612 Label done; | |
| 4613 if (signedness == SIGNED_INT32) { | 4618 if (signedness == SIGNED_INT32) { |
| 4614 // There was overflow, so bits 30 and 31 of the original integer | 4619 // There was overflow, so bits 30 and 31 of the original integer |
| 4615 // disagree. Try to allocate a heap number in new space and store | 4620 // disagree. Try to allocate a heap number in new space and store |
| 4616 // the value in there. If that fails, call the runtime system. | 4621 // the value in there. If that fails, call the runtime system. |
| 4617 if (dst.is(src)) { | 4622 if (dst.is(src)) { |
| 4618 __ SmiUntag(src, dst); | 4623 __ SmiUntag(src, dst); |
| 4619 __ Xor(src, src, Operand(0x80000000)); | 4624 __ Xor(src, src, Operand(0x80000000)); |
| 4620 } | 4625 } |
| 4621 __ mtc1(src, dbl_scratch); | 4626 __ mtc1(src, dbl_scratch); |
| 4622 __ cvt_d_w(dbl_scratch, dbl_scratch); | 4627 __ cvt_d_w(dbl_scratch, dbl_scratch); |
| 4623 } else { | 4628 } else { |
| 4624 __ mtc1(src, dbl_scratch); | 4629 __ mtc1(src, dbl_scratch); |
| 4625 __ Cvt_d_uw(dbl_scratch, dbl_scratch, f22); | 4630 __ Cvt_d_uw(dbl_scratch, dbl_scratch, f22); |
| 4626 } | 4631 } |
| 4627 | 4632 |
| 4628 if (FLAG_inline_new) { | 4633 if (FLAG_inline_new) { |
| 4629 __ LoadRoot(scratch0(), Heap::kHeapNumberMapRootIndex); | 4634 __ LoadRoot(tmp3, Heap::kHeapNumberMapRootIndex); |
| 4630 __ AllocateHeapNumber(t1, a3, t0, scratch0(), &slow, DONT_TAG_RESULT); | 4635 __ AllocateHeapNumber(dst, tmp1, tmp2, tmp3, &slow, DONT_TAG_RESULT); |
| 4631 __ Move(dst, t1); | |
| 4632 __ Branch(&done); | 4636 __ Branch(&done); |
| 4633 } | 4637 } |
| 4634 | 4638 |
| 4635 // Slow case: Call the runtime system to do the number allocation. | 4639 // Slow case: Call the runtime system to do the number allocation. |
| 4636 __ bind(&slow); | 4640 __ bind(&slow); |
| 4641 { |
| 4642 // TODO(3095996): Put a valid pointer value in the stack slot where the |
| 4643 // result register is stored, as this register is in the pointer map, but |
| 4644 // contains an integer value. |
| 4645 __ mov(dst, zero_reg); |
| 4637 | 4646 |
| 4638 // TODO(3095996): Put a valid pointer value in the stack slot where the result | 4647 // Preserve the value of all registers. |
| 4639 // register is stored, as this register is in the pointer map, but contains an | 4648 PushSafepointRegistersScope scope(this, Safepoint::kWithRegisters); |
| 4640 // integer value. | 4649 |
| 4641 __ StoreToSafepointRegisterSlot(zero_reg, dst); | 4650 // NumberTagI and NumberTagD use the context from the frame, rather than |
| 4642 // NumberTagI and NumberTagD use the context from the frame, rather than | 4651 // the environment's HContext or HInlinedContext value. |
| 4643 // the environment's HContext or HInlinedContext value. | 4652 // They only call Runtime::kAllocateHeapNumber. |
| 4644 // They only call Runtime::kAllocateHeapNumber. | 4653 // The corresponding HChange instructions are added in a phase that does |
| 4645 // The corresponding HChange instructions are added in a phase that does | 4654 // not have easy access to the local context. |
| 4646 // not have easy access to the local context. | 4655 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 4647 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 4656 __ CallRuntimeSaveDoubles(Runtime::kAllocateHeapNumber); |
| 4648 __ CallRuntimeSaveDoubles(Runtime::kAllocateHeapNumber); | 4657 RecordSafepointWithRegisters( |
| 4649 RecordSafepointWithRegisters( | 4658 instr->pointer_map(), 0, Safepoint::kNoLazyDeopt); |
| 4650 instr->pointer_map(), 0, Safepoint::kNoLazyDeopt); | 4659 __ Subu(v0, v0, kHeapObjectTag); |
| 4651 __ Move(dst, v0); | 4660 __ StoreToSafepointRegisterSlot(v0, dst); |
| 4652 __ Subu(dst, dst, kHeapObjectTag); | 4661 } |
| 4662 |
| 4653 | 4663 |
| 4654 // Done. Put the value in dbl_scratch into the value of the allocated heap | 4664 // Done. Put the value in dbl_scratch into the value of the allocated heap |
| 4655 // number. | 4665 // number. |
| 4656 __ bind(&done); | 4666 __ bind(&done); |
| 4657 __ sdc1(dbl_scratch, MemOperand(dst, HeapNumber::kValueOffset)); | 4667 __ sdc1(dbl_scratch, MemOperand(dst, HeapNumber::kValueOffset)); |
| 4658 __ Addu(dst, dst, kHeapObjectTag); | 4668 __ Addu(dst, dst, kHeapObjectTag); |
| 4659 __ StoreToSafepointRegisterSlot(dst, dst); | |
| 4660 } | 4669 } |
| 4661 | 4670 |
| 4662 | 4671 |
| 4663 void LCodeGen::DoNumberTagD(LNumberTagD* instr) { | 4672 void LCodeGen::DoNumberTagD(LNumberTagD* instr) { |
| 4664 class DeferredNumberTagD V8_FINAL : public LDeferredCode { | 4673 class DeferredNumberTagD V8_FINAL : public LDeferredCode { |
| 4665 public: | 4674 public: |
| 4666 DeferredNumberTagD(LCodeGen* codegen, LNumberTagD* instr) | 4675 DeferredNumberTagD(LCodeGen* codegen, LNumberTagD* instr) |
| 4667 : LDeferredCode(codegen), instr_(instr) { } | 4676 : LDeferredCode(codegen), instr_(instr) { } |
| 4668 virtual void Generate() V8_OVERRIDE { | 4677 virtual void Generate() V8_OVERRIDE { |
| 4669 codegen()->DoDeferredNumberTagD(instr_); | 4678 codegen()->DoDeferredNumberTagD(instr_); |
| (...skipping 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5753 __ Subu(scratch, result, scratch); | 5762 __ Subu(scratch, result, scratch); |
| 5754 __ lw(result, FieldMemOperand(scratch, | 5763 __ lw(result, FieldMemOperand(scratch, |
| 5755 FixedArray::kHeaderSize - kPointerSize)); | 5764 FixedArray::kHeaderSize - kPointerSize)); |
| 5756 __ bind(&done); | 5765 __ bind(&done); |
| 5757 } | 5766 } |
| 5758 | 5767 |
| 5759 | 5768 |
| 5760 #undef __ | 5769 #undef __ |
| 5761 | 5770 |
| 5762 } } // namespace v8::internal | 5771 } } // namespace v8::internal |
| OLD | NEW |