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 4438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4449 Register scratch = scratch0(); | 4449 Register scratch = scratch0(); |
4450 __ lw(scratch, ToMemOperand(input)); | 4450 __ lw(scratch, ToMemOperand(input)); |
4451 __ mtc1(scratch, single_scratch); | 4451 __ mtc1(scratch, single_scratch); |
4452 } else { | 4452 } else { |
4453 __ mtc1(ToRegister(input), single_scratch); | 4453 __ mtc1(ToRegister(input), single_scratch); |
4454 } | 4454 } |
4455 __ cvt_d_w(ToDoubleRegister(output), single_scratch); | 4455 __ cvt_d_w(ToDoubleRegister(output), single_scratch); |
4456 } | 4456 } |
4457 | 4457 |
4458 | 4458 |
4459 void LCodeGen::DoInteger32ToSmi(LInteger32ToSmi* instr) { | |
4460 LOperand* input = instr->value(); | |
4461 LOperand* output = instr->result(); | |
4462 Register scratch = scratch0(); | |
4463 | |
4464 ASSERT(output->IsRegister()); | |
4465 if (!instr->hydrogen()->value()->HasRange() || | |
4466 !instr->hydrogen()->value()->range()->IsInSmiRange()) { | |
4467 __ SmiTagCheckOverflow(ToRegister(output), ToRegister(input), scratch); | |
4468 DeoptimizeIf(lt, instr->environment(), scratch, Operand(zero_reg)); | |
4469 } else { | |
4470 __ SmiTag(ToRegister(output), ToRegister(input)); | |
4471 } | |
4472 } | |
4473 | |
4474 | |
4475 void LCodeGen::DoUint32ToDouble(LUint32ToDouble* instr) { | 4459 void LCodeGen::DoUint32ToDouble(LUint32ToDouble* instr) { |
4476 LOperand* input = instr->value(); | 4460 LOperand* input = instr->value(); |
4477 LOperand* output = instr->result(); | 4461 LOperand* output = instr->result(); |
4478 | 4462 |
4479 FPURegister dbl_scratch = double_scratch0(); | 4463 FPURegister dbl_scratch = double_scratch0(); |
4480 __ mtc1(ToRegister(input), dbl_scratch); | 4464 __ mtc1(ToRegister(input), dbl_scratch); |
4481 __ Cvt_d_uw(ToDoubleRegister(output), dbl_scratch, f22); | 4465 __ Cvt_d_uw(ToDoubleRegister(output), dbl_scratch, f22); |
4482 } | 4466 } |
4483 | 4467 |
4484 | 4468 |
4485 void LCodeGen::DoUint32ToSmi(LUint32ToSmi* instr) { | |
4486 LOperand* input = instr->value(); | |
4487 LOperand* output = instr->result(); | |
4488 if (!instr->hydrogen()->value()->HasRange() || | |
4489 !instr->hydrogen()->value()->range()->IsInSmiRange()) { | |
4490 Register scratch = scratch0(); | |
4491 __ And(scratch, ToRegister(input), Operand(0xc0000000)); | |
4492 DeoptimizeIf(ne, instr->environment(), scratch, Operand(zero_reg)); | |
4493 } | |
4494 __ SmiTag(ToRegister(output), ToRegister(input)); | |
4495 } | |
4496 | |
4497 | |
4498 void LCodeGen::DoNumberTagI(LNumberTagI* instr) { | 4469 void LCodeGen::DoNumberTagI(LNumberTagI* instr) { |
4499 class DeferredNumberTagI V8_FINAL : public LDeferredCode { | 4470 class DeferredNumberTagI V8_FINAL : public LDeferredCode { |
4500 public: | 4471 public: |
4501 DeferredNumberTagI(LCodeGen* codegen, LNumberTagI* instr) | 4472 DeferredNumberTagI(LCodeGen* codegen, LNumberTagI* instr) |
4502 : LDeferredCode(codegen), instr_(instr) { } | 4473 : LDeferredCode(codegen), instr_(instr) { } |
4503 virtual void Generate() V8_OVERRIDE { | 4474 virtual void Generate() V8_OVERRIDE { |
4504 codegen()->DoDeferredNumberTagIU(instr_, | 4475 codegen()->DoDeferredNumberTagIU(instr_, |
4505 instr_->value(), | 4476 instr_->value(), |
4506 instr_->temp1(), | 4477 instr_->temp1(), |
4507 instr_->temp2(), | 4478 instr_->temp2(), |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4668 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 4639 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
4669 __ CallRuntimeSaveDoubles(Runtime::kAllocateHeapNumber); | 4640 __ CallRuntimeSaveDoubles(Runtime::kAllocateHeapNumber); |
4670 RecordSafepointWithRegisters( | 4641 RecordSafepointWithRegisters( |
4671 instr->pointer_map(), 0, Safepoint::kNoLazyDeopt); | 4642 instr->pointer_map(), 0, Safepoint::kNoLazyDeopt); |
4672 __ Subu(v0, v0, kHeapObjectTag); | 4643 __ Subu(v0, v0, kHeapObjectTag); |
4673 __ StoreToSafepointRegisterSlot(v0, reg); | 4644 __ StoreToSafepointRegisterSlot(v0, reg); |
4674 } | 4645 } |
4675 | 4646 |
4676 | 4647 |
4677 void LCodeGen::DoSmiTag(LSmiTag* instr) { | 4648 void LCodeGen::DoSmiTag(LSmiTag* instr) { |
4678 ASSERT(!instr->hydrogen_value()->CheckFlag(HValue::kCanOverflow)); | 4649 HChange* hchange = instr->hydrogen(); |
4679 __ SmiTag(ToRegister(instr->result()), ToRegister(instr->value())); | 4650 Register input = ToRegister(instr->value()); |
| 4651 Register output = ToRegister(instr->result()); |
| 4652 if (hchange->CheckFlag(HValue::kCanOverflow) && |
| 4653 hchange->value()->CheckFlag(HValue::kUint32)) { |
| 4654 __ And(at, input, Operand(0xc0000000)); |
| 4655 DeoptimizeIf(ne, instr->environment(), at, Operand(zero_reg)); |
| 4656 } |
| 4657 if (hchange->CheckFlag(HValue::kCanOverflow) && |
| 4658 !hchange->value()->CheckFlag(HValue::kUint32)) { |
| 4659 __ SmiTagCheckOverflow(output, input, at); |
| 4660 DeoptimizeIf(lt, instr->environment(), at, Operand(zero_reg)); |
| 4661 } else { |
| 4662 __ SmiTag(output, input); |
| 4663 } |
4680 } | 4664 } |
4681 | 4665 |
4682 | 4666 |
4683 void LCodeGen::DoSmiUntag(LSmiUntag* instr) { | 4667 void LCodeGen::DoSmiUntag(LSmiUntag* instr) { |
4684 Register scratch = scratch0(); | 4668 Register scratch = scratch0(); |
4685 Register input = ToRegister(instr->value()); | 4669 Register input = ToRegister(instr->value()); |
4686 Register result = ToRegister(instr->result()); | 4670 Register result = ToRegister(instr->result()); |
4687 if (instr->needs_check()) { | 4671 if (instr->needs_check()) { |
4688 STATIC_ASSERT(kHeapObjectTag == 1); | 4672 STATIC_ASSERT(kHeapObjectTag == 1); |
4689 // If the input is a HeapObject, value of scratch won't be zero. | 4673 // If the input is a HeapObject, value of scratch won't be zero. |
(...skipping 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5725 __ Subu(scratch, result, scratch); | 5709 __ Subu(scratch, result, scratch); |
5726 __ lw(result, FieldMemOperand(scratch, | 5710 __ lw(result, FieldMemOperand(scratch, |
5727 FixedArray::kHeaderSize - kPointerSize)); | 5711 FixedArray::kHeaderSize - kPointerSize)); |
5728 __ bind(&done); | 5712 __ bind(&done); |
5729 } | 5713 } |
5730 | 5714 |
5731 | 5715 |
5732 #undef __ | 5716 #undef __ |
5733 | 5717 |
5734 } } // namespace v8::internal | 5718 } } // namespace v8::internal |
OLD | NEW |