Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/x64/lithium-codegen-x64.cc

Issue 23938003: Move ToInt conversions to the MacroAssembler for x64 (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: address review Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/x64/lithium-codegen-x64.h ('k') | src/x64/macro-assembler-x64.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 frame_is_built_ = true; 350 frame_is_built_ = true;
351 // Build the frame in such a way that esi isn't trashed. 351 // Build the frame in such a way that esi isn't trashed.
352 __ push(rbp); // Caller's frame pointer. 352 __ push(rbp); // Caller's frame pointer.
353 __ push(Operand(rbp, StandardFrameConstants::kContextOffset)); 353 __ push(Operand(rbp, StandardFrameConstants::kContextOffset));
354 __ Push(Smi::FromInt(StackFrame::STUB)); 354 __ Push(Smi::FromInt(StackFrame::STUB));
355 __ lea(rbp, Operand(rsp, 2 * kPointerSize)); 355 __ lea(rbp, Operand(rsp, 2 * kPointerSize));
356 Comment(";;; Deferred code"); 356 Comment(";;; Deferred code");
357 } 357 }
358 code->Generate(); 358 code->Generate();
359 if (NeedsDeferredFrame()) { 359 if (NeedsDeferredFrame()) {
360 __ bind(code->done());
360 Comment(";;; Destroy frame"); 361 Comment(";;; Destroy frame");
361 ASSERT(frame_is_built_); 362 ASSERT(frame_is_built_);
362 frame_is_built_ = false; 363 frame_is_built_ = false;
363 __ movq(rsp, rbp); 364 __ movq(rsp, rbp);
364 __ pop(rbp); 365 __ pop(rbp);
365 } 366 }
366 __ jmp(code->exit()); 367 __ jmp(code->exit());
367 } 368 }
368 } 369 }
369 370
(...skipping 4306 matching lines...) Expand 10 before | Expand all | Expand 10 after
4676 } 4677 }
4677 4678
4678 // Smi to XMM conversion 4679 // Smi to XMM conversion
4679 __ bind(&load_smi); 4680 __ bind(&load_smi);
4680 __ SmiToInteger32(kScratchRegister, input_reg); 4681 __ SmiToInteger32(kScratchRegister, input_reg);
4681 __ cvtlsi2sd(result_reg, kScratchRegister); 4682 __ cvtlsi2sd(result_reg, kScratchRegister);
4682 __ bind(&done); 4683 __ bind(&done);
4683 } 4684 }
4684 4685
4685 4686
4686 void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr) { 4687 void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr, Label* done) {
4687 Label done, heap_number; 4688 Label heap_number;
4688 Register input_reg = ToRegister(instr->value()); 4689 Register input_reg = ToRegister(instr->value());
4689 4690
4690 // Heap number map check.
4691 __ CompareRoot(FieldOperand(input_reg, HeapObject::kMapOffset),
4692 Heap::kHeapNumberMapRootIndex);
4693 4691
4694 if (instr->truncating()) { 4692 if (instr->truncating()) {
4693 // Heap number map check.
4694 __ CompareRoot(FieldOperand(input_reg, HeapObject::kMapOffset),
4695 Heap::kHeapNumberMapRootIndex);
4695 __ j(equal, &heap_number, Label::kNear); 4696 __ j(equal, &heap_number, Label::kNear);
4696 // Check for undefined. Undefined is converted to zero for truncating 4697 // Check for undefined. Undefined is converted to zero for truncating
4697 // conversions. 4698 // conversions.
4698 __ CompareRoot(input_reg, Heap::kUndefinedValueRootIndex); 4699 __ CompareRoot(input_reg, Heap::kUndefinedValueRootIndex);
4699 DeoptimizeIf(not_equal, instr->environment()); 4700 DeoptimizeIf(not_equal, instr->environment());
4700 __ Set(input_reg, 0); 4701 __ Set(input_reg, 0);
4701 __ jmp(&done, Label::kNear); 4702 __ jmp(done);
4702 4703
4703 __ bind(&heap_number); 4704 __ bind(&heap_number);
4705 __ TruncateHeapNumberToI(input_reg, input_reg);
4706 } else {
4707 Label bailout;
4708 XMMRegister xmm_temp = ToDoubleRegister(instr->temp());
4709 __ TaggedToI(input_reg, input_reg, xmm_temp,
4710 instr->hydrogen()->GetMinusZeroMode(), &bailout, Label::kNear);
4704 4711
4705 __ movsd(xmm0, FieldOperand(input_reg, HeapNumber::kValueOffset)); 4712 __ jmp(done);
4706 __ cvttsd2siq(input_reg, xmm0); 4713 __ bind(&bailout);
4707 __ Set(kScratchRegister, V8_UINT64_C(0x8000000000000000)); 4714 DeoptimizeIf(no_condition, instr->environment());
4708 __ cmpq(input_reg, kScratchRegister);
4709 DeoptimizeIf(equal, instr->environment());
4710 } else {
4711 // Deoptimize if we don't have a heap number.
4712 DeoptimizeIf(not_equal, instr->environment());
4713
4714 XMMRegister xmm_temp = ToDoubleRegister(instr->temp());
4715 __ movsd(xmm0, FieldOperand(input_reg, HeapNumber::kValueOffset));
4716 __ cvttsd2si(input_reg, xmm0);
4717 __ cvtlsi2sd(xmm_temp, input_reg);
4718 __ ucomisd(xmm0, xmm_temp);
4719 DeoptimizeIf(not_equal, instr->environment());
4720 DeoptimizeIf(parity_even, instr->environment()); // NaN.
4721 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
4722 __ testl(input_reg, input_reg);
4723 __ j(not_zero, &done);
4724 __ movmskpd(input_reg, xmm0);
4725 __ andl(input_reg, Immediate(1));
4726 DeoptimizeIf(not_zero, instr->environment());
4727 }
4728 } 4715 }
4729 __ bind(&done);
4730 } 4716 }
4731 4717
4732 4718
4733 void LCodeGen::DoTaggedToI(LTaggedToI* instr) { 4719 void LCodeGen::DoTaggedToI(LTaggedToI* instr) {
4734 class DeferredTaggedToI V8_FINAL : public LDeferredCode { 4720 class DeferredTaggedToI V8_FINAL : public LDeferredCode {
4735 public: 4721 public:
4736 DeferredTaggedToI(LCodeGen* codegen, LTaggedToI* instr) 4722 DeferredTaggedToI(LCodeGen* codegen, LTaggedToI* instr)
4737 : LDeferredCode(codegen), instr_(instr) { } 4723 : LDeferredCode(codegen), instr_(instr) { }
4738 virtual void Generate() V8_OVERRIDE { 4724 virtual void Generate() V8_OVERRIDE {
4739 codegen()->DoDeferredTaggedToI(instr_); 4725 codegen()->DoDeferredTaggedToI(instr_, done());
4740 } 4726 }
4741 virtual LInstruction* instr() V8_OVERRIDE { return instr_; } 4727 virtual LInstruction* instr() V8_OVERRIDE { return instr_; }
4742 private: 4728 private:
4743 LTaggedToI* instr_; 4729 LTaggedToI* instr_;
4744 }; 4730 };
4745 4731
4746 LOperand* input = instr->value(); 4732 LOperand* input = instr->value();
4747 ASSERT(input->IsRegister()); 4733 ASSERT(input->IsRegister());
4748 ASSERT(input->Equals(instr->result())); 4734 ASSERT(input->Equals(instr->result()));
4749 4735
(...skipping 29 matching lines...) Expand all
4779 void LCodeGen::DoDoubleToI(LDoubleToI* instr) { 4765 void LCodeGen::DoDoubleToI(LDoubleToI* instr) {
4780 LOperand* input = instr->value(); 4766 LOperand* input = instr->value();
4781 ASSERT(input->IsDoubleRegister()); 4767 ASSERT(input->IsDoubleRegister());
4782 LOperand* result = instr->result(); 4768 LOperand* result = instr->result();
4783 ASSERT(result->IsRegister()); 4769 ASSERT(result->IsRegister());
4784 4770
4785 XMMRegister input_reg = ToDoubleRegister(input); 4771 XMMRegister input_reg = ToDoubleRegister(input);
4786 Register result_reg = ToRegister(result); 4772 Register result_reg = ToRegister(result);
4787 4773
4788 if (instr->truncating()) { 4774 if (instr->truncating()) {
4789 // Performs a truncating conversion of a floating point number as used by 4775 __ TruncateDoubleToI(result_reg, input_reg);
4790 // the JS bitwise operations.
4791 __ cvttsd2siq(result_reg, input_reg);
4792 __ movq(kScratchRegister,
4793 V8_INT64_C(0x8000000000000000),
4794 RelocInfo::NONE64);
4795 __ cmpq(result_reg, kScratchRegister);
4796 DeoptimizeIf(equal, instr->environment());
4797 } else { 4776 } else {
4798 __ cvttsd2si(result_reg, input_reg); 4777 Label bailout, done;
4799 __ cvtlsi2sd(xmm0, result_reg); 4778 __ DoubleToI(result_reg, input_reg, xmm0,
4800 __ ucomisd(xmm0, input_reg); 4779 instr->hydrogen()->GetMinusZeroMode(), &bailout, Label::kNear);
4801 DeoptimizeIf(not_equal, instr->environment()); 4780
4802 DeoptimizeIf(parity_even, instr->environment()); // NaN. 4781 __ jmp(&done, Label::kNear);
4803 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { 4782 __ bind(&bailout);
4804 Label done; 4783 DeoptimizeIf(no_condition, instr->environment());
4805 // The integer converted back is equal to the original. We 4784 __ bind(&done);
4806 // only have to test if we got -0 as an input.
4807 __ testl(result_reg, result_reg);
4808 __ j(not_zero, &done, Label::kNear);
4809 __ movmskpd(result_reg, input_reg);
4810 // Bit 0 contains the sign of the double in input_reg.
4811 // If input was positive, we are ok and return 0, otherwise
4812 // deoptimize.
4813 __ andl(result_reg, Immediate(1));
4814 DeoptimizeIf(not_zero, instr->environment());
4815 __ bind(&done);
4816 }
4817 } 4785 }
4818 } 4786 }
4819 4787
4820 4788
4821 void LCodeGen::DoDoubleToSmi(LDoubleToSmi* instr) { 4789 void LCodeGen::DoDoubleToSmi(LDoubleToSmi* instr) {
4822 LOperand* input = instr->value(); 4790 LOperand* input = instr->value();
4823 ASSERT(input->IsDoubleRegister()); 4791 ASSERT(input->IsDoubleRegister());
4824 LOperand* result = instr->result(); 4792 LOperand* result = instr->result();
4825 ASSERT(result->IsRegister()); 4793 ASSERT(result->IsRegister());
4826 CpuFeatureScope scope(masm(), SSE2);
4827 4794
4828 XMMRegister input_reg = ToDoubleRegister(input); 4795 XMMRegister input_reg = ToDoubleRegister(input);
4829 Register result_reg = ToRegister(result); 4796 Register result_reg = ToRegister(result);
4830 4797
4831 Label done; 4798 Label bailout, done;
4832 __ cvttsd2si(result_reg, input_reg); 4799 __ DoubleToI(result_reg, input_reg, xmm0,
4833 __ cvtlsi2sd(xmm0, result_reg); 4800 instr->hydrogen()->GetMinusZeroMode(), &bailout, Label::kNear);
4834 __ ucomisd(xmm0, input_reg);
4835 DeoptimizeIf(not_equal, instr->environment());
4836 DeoptimizeIf(parity_even, instr->environment()); // NaN.
4837 4801
4838 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { 4802 __ jmp(&done, Label::kNear);
4839 // The integer converted back is equal to the original. We 4803 __ bind(&bailout);
4840 // only have to test if we got -0 as an input. 4804 DeoptimizeIf(no_condition, instr->environment());
4841 __ testl(result_reg, result_reg); 4805 __ bind(&done);
4842 __ j(not_zero, &done, Label::kNear); 4806
4843 __ movmskpd(result_reg, input_reg);
4844 // Bit 0 contains the sign of the double in input_reg.
4845 // If input was positive, we are ok and return 0, otherwise
4846 // deoptimize.
4847 __ andl(result_reg, Immediate(1));
4848 DeoptimizeIf(not_zero, instr->environment());
4849 __ bind(&done);
4850 }
4851 __ Integer32ToSmi(result_reg, result_reg); 4807 __ Integer32ToSmi(result_reg, result_reg);
4852 DeoptimizeIf(overflow, instr->environment()); 4808 DeoptimizeIf(overflow, instr->environment());
4853 } 4809 }
4854 4810
4855 4811
4856 void LCodeGen::DoCheckSmi(LCheckSmi* instr) { 4812 void LCodeGen::DoCheckSmi(LCheckSmi* instr) {
4857 LOperand* input = instr->value(); 4813 LOperand* input = instr->value();
4858 Condition cc = masm()->CheckSmi(ToRegister(input)); 4814 Condition cc = masm()->CheckSmi(ToRegister(input));
4859 DeoptimizeIf(NegateCondition(cc), instr->environment()); 4815 DeoptimizeIf(NegateCondition(cc), instr->environment());
4860 } 4816 }
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
5550 FixedArray::kHeaderSize - kPointerSize)); 5506 FixedArray::kHeaderSize - kPointerSize));
5551 __ bind(&done); 5507 __ bind(&done);
5552 } 5508 }
5553 5509
5554 5510
5555 #undef __ 5511 #undef __
5556 5512
5557 } } // namespace v8::internal 5513 } } // namespace v8::internal
5558 5514
5559 #endif // V8_TARGET_ARCH_X64 5515 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/lithium-codegen-x64.h ('k') | src/x64/macro-assembler-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698